Skip to content

Fix ssl3_do_write() to correctly handle retries (3.1/3.0) - #21435

Closed
mattcaswell wants to merge 2 commits into
openssl:openssl-3.1from
mattcaswell:fix-handshake-retry-31
Closed

mattcaswell wants to merge 2 commits into
openssl:openssl-3.1from
mattcaswell:fix-handshake-retry-31

Conversation

@mattcaswell

Copy link
Copy Markdown
Member

A BIO is documented to return -1 on write retry - but sometimes they return
0. ssl3_do_write() was incorrectly handling a 0 response.

Fixes #21422

This is a backport of #21434 for the 3.1/3.0 branches.

Test various scenarios for a write retry occuring during a handshake.
A BIO is documented to return -1 on write retry - but sometimes they return
0. ssl3_do_write() was incorrectly handling a 0 response.

Fixes openssl#21422
@mattcaswell mattcaswell added approval: review pending This pull request needs review by a committer approval: otc review pending branch: 3.0 Applies to openssl-3.0 branch (EOL) branch: 3.1 Applies to openssl-3.1 (EOL) labels Jul 12, 2023
@mattcaswell

mattcaswell commented Jul 12, 2023 •

Copy link
Copy Markdown
Member Author

Actually this is only really a problem in the 3.1/3.0 branches. By accident of the record layer refactor this doesn't actually impact the master branch. But the code is still wrong so I think we should apply the fix here anyway.
Ooops...meant to put this comment in #21434

@paulidale paulidale added tests: present The PR has suitable tests present and removed approval: otc review pending labels Jul 13, 2023
@mattcaswell

Copy link
Copy Markdown
Member Author

Ping for second review

@beldmit beldmit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@beldmit beldmit added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Jul 14, 2023
@beldmit

beldmit commented Jul 14, 2023

Copy link
Copy Markdown
Member

A BIO is documented to return -1 on write retry - but sometimes they return 0

Can we do anything with this behavior? It looks quite counter intuitive...

@mattcaswell

Copy link
Copy Markdown
Member Author

Can we do anything with this behavior? It looks quite counter intuitive...

Well not really. This is mostly about third party BIOs. You could call it a bug in those BIOs because it doesn't match the documentation - but in reality I think this behaviour has worked for a long time. If there are any of our own BIOs that do the wrong thing then we could fix those, but I haven't checked.

@openssl-machine

Copy link
Copy Markdown
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

@paulidale

Copy link
Copy Markdown
Contributor

Merged to both 3.x branches.

@paulidale paulidale closed this Jul 16, 2023
openssl-machine pushed a commit that referenced this pull request Jul 16, 2023
Test various scenarios for a write retry occuring during a handshake.

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #21435)

(cherry picked from commit d6179e6)
openssl-machine pushed a commit that referenced this pull request Jul 16, 2023
A BIO is documented to return -1 on write retry - but sometimes they return
0. ssl3_do_write() was incorrectly handling a 0 response.

Fixes #21422

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #21435)

(cherry picked from commit 034ea1d)
openssl-machine pushed a commit that referenced this pull request Jul 16, 2023
Test various scenarios for a write retry occuring during a handshake.

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #21435)
openssl-machine pushed a commit that referenced this pull request Jul 16, 2023
A BIO is documented to return -1 on write retry - but sometimes they return
0. ssl3_do_write() was incorrectly handling a 0 response.

Fixes #21422

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #21435)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 19, 2023
Test various scenarios for a write retry occuring during a handshake.

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#21435)

(cherry picked from commit d6179e6)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 19, 2023
A BIO is documented to return -1 on write retry - but sometimes they return
0. ssl3_do_write() was incorrectly handling a 0 response.

Fixes openssl#21422

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#21435)

(cherry picked from commit 034ea1d)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 19, 2023
Test various scenarios for a write retry occuring during a handshake.

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#21435)

(cherry picked from commit d6179e6)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 19, 2023
A BIO is documented to return -1 on write retry - but sometimes they return
0. ssl3_do_write() was incorrectly handling a 0 response.

Fixes openssl#21422

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#21435)

(cherry picked from commit 034ea1d)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 1, 2023
Test various scenarios for a write retry occuring during a handshake.

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#21435)

(cherry picked from commit d6179e6)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 1, 2023
A BIO is documented to return -1 on write retry - but sometimes they return
0. ssl3_do_write() was incorrectly handling a 0 response.

Fixes openssl#21422

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#21435)

(cherry picked from commit 034ea1d)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 19, 2023
Test various scenarios for a write retry occuring during a handshake.

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#21435)

(cherry picked from commit d6179e6)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 19, 2023
A BIO is documented to return -1 on write retry - but sometimes they return
0. ssl3_do_write() was incorrectly handling a 0 response.

Fixes openssl#21422

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#21435)

(cherry picked from commit 034ea1d)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Sep 12, 2023
Test various scenarios for a write retry occuring during a handshake.

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#21435)

(cherry picked from commit d6179e6)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Sep 12, 2023
A BIO is documented to return -1 on write retry - but sometimes they return
0. ssl3_do_write() was incorrectly handling a 0 response.

Fixes openssl#21422

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#21435)

(cherry picked from commit 034ea1d)
kafei-cy added a commit to kafei-cy/Tongsuo that referenced this pull request Mar 26, 2026
Include 2 commits:
1. Add a test for a retry during the handshake
2. Fix ssl3_do_write() to correctly handle retries

(Merged from openssl/openssl#21435)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: done This pull request has the required number of approvals branch: 3.0 Applies to openssl-3.0 branch (EOL) branch: 3.1 Applies to openssl-3.1 (EOL) tests: present The PR has suitable tests present

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants