Skip to content

Fix pipelining in 3.1/3.0 - #20208

Closed
mattcaswell wants to merge 5 commits into
openssl:openssl-3.1from
mattcaswell:fix-pipelining-31
Closed

mattcaswell wants to merge 5 commits into
openssl:openssl-3.1from
mattcaswell:fix-pipelining-31

Conversation

@mattcaswell

Copy link
Copy Markdown
Member

This PR backports the fixes to a number of pipelining bugs that were resolved in master recently to 3.1/3.0. It also adds a new test for the pipelining code which would have caught these issues.

It is mostly a backport of PR #19456, plus an additional fix which was included in a much larger commit in master (c618679) related to moving the pipelining code into the new record layer that exists there.

Fixes #20197

TLS pipelining provides the ability for libssl to read or write multiple
records in parallel. It requires special ciphers to do this, and there are
currently no built-in ciphers that provide this capability. However, the
dasync engine does have such a cipher, so we add a test for this capability
using that engine.
…lled

The pipeline input/output buf arrays must remain accessible to the
EVP_CIPHER_CTX until EVP_Cipher is subsequently called. This fixes an
asan error discovered by the newly added pipeline test.
During read pipelining we must ensure that the buffer is sufficiently large
to read enough data to fill our pipelines. We also remove some code that
moved data to the start of the packet if we can. This was unnecessary
because of later code which would end up moving it anyway. The earlier move
was also incorrect in the case that |clearold| was 0. This would cause the
read pipelining code to fail with sufficiently large records.

Fixes openssl#20197
Document the effect on the internal read buffer when using pipelining.
We shouldn't be putting more data into a pipeline than the value of
split_send_fragment.

This is a backport of a fix which was included in a much larger commit in
master (c618679) related to moving the pipelining code into the new
record layer that exists there.
@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 Feb 3, 2023
@t8m t8m added triaged: bug The issue/pr is/fixes a bug tests: present The PR has suitable tests present and removed approval: otc review pending labels Feb 6, 2023
@mattcaswell

Copy link
Copy Markdown
Member Author

Ping for second review

Comment thread ssl/record/ssl3_buffer.c Resolved
@paulidale paulidale 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 Feb 22, 2023
@openssl-machine openssl-machine added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Feb 23, 2023
@openssl-machine

Copy link
Copy Markdown
Collaborator

This pull request is ready to merge

openssl-machine pushed a commit that referenced this pull request Feb 24, 2023
TLS pipelining provides the ability for libssl to read or write multiple
records in parallel. It requires special ciphers to do this, and there are
currently no built-in ciphers that provide this capability. However, the
dasync engine does have such a cipher, so we add a test for this capability
using that engine.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #20208)
openssl-machine pushed a commit that referenced this pull request Feb 24, 2023
…lled

The pipeline input/output buf arrays must remain accessible to the
EVP_CIPHER_CTX until EVP_Cipher is subsequently called. This fixes an
asan error discovered by the newly added pipeline test.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #20208)
openssl-machine pushed a commit that referenced this pull request Feb 24, 2023
During read pipelining we must ensure that the buffer is sufficiently large
to read enough data to fill our pipelines. We also remove some code that
moved data to the start of the packet if we can. This was unnecessary
because of later code which would end up moving it anyway. The earlier move
was also incorrect in the case that |clearold| was 0. This would cause the
read pipelining code to fail with sufficiently large records.

Fixes #20197

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #20208)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 13, 2023
We shouldn't be putting more data into a pipeline than the value of
split_send_fragment.

This is a backport of a fix which was included in a much larger commit in
master (c618679) related to moving the pipelining code into the new
record layer that exists there.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 2c4b1c7)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 16, 2023
TLS pipelining provides the ability for libssl to read or write multiple
records in parallel. It requires special ciphers to do this, and there are
currently no built-in ciphers that provide this capability. However, the
dasync engine does have such a cipher, so we add a test for this capability
using that engine.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 24c7d36)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 16, 2023
…lled

The pipeline input/output buf arrays must remain accessible to the
EVP_CIPHER_CTX until EVP_Cipher is subsequently called. This fixes an
asan error discovered by the newly added pipeline test.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit df9c7ce)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 16, 2023
During read pipelining we must ensure that the buffer is sufficiently large
to read enough data to fill our pipelines. We also remove some code that
moved data to the start of the packet if we can. This was unnecessary
because of later code which would end up moving it anyway. The earlier move
was also incorrect in the case that |clearold| was 0. This would cause the
read pipelining code to fail with sufficiently large records.

Fixes openssl#20197

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 1d06598)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 16, 2023
We shouldn't be putting more data into a pipeline than the value of
split_send_fragment.

This is a backport of a fix which was included in a much larger commit in
master (c618679) related to moving the pipelining code into the new
record layer that exists there.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 2c4b1c7)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 19, 2023
TLS pipelining provides the ability for libssl to read or write multiple
records in parallel. It requires special ciphers to do this, and there are
currently no built-in ciphers that provide this capability. However, the
dasync engine does have such a cipher, so we add a test for this capability
using that engine.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 24c7d36)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 19, 2023
…lled

The pipeline input/output buf arrays must remain accessible to the
EVP_CIPHER_CTX until EVP_Cipher is subsequently called. This fixes an
asan error discovered by the newly added pipeline test.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit df9c7ce)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 19, 2023
During read pipelining we must ensure that the buffer is sufficiently large
to read enough data to fill our pipelines. We also remove some code that
moved data to the start of the packet if we can. This was unnecessary
because of later code which would end up moving it anyway. The earlier move
was also incorrect in the case that |clearold| was 0. This would cause the
read pipelining code to fail with sufficiently large records.

Fixes openssl#20197

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 1d06598)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 19, 2023
We shouldn't be putting more data into a pipeline than the value of
split_send_fragment.

This is a backport of a fix which was included in a much larger commit in
master (c618679) related to moving the pipelining code into the new
record layer that exists there.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 2c4b1c7)
Comment thread test/sslapitest.c
goto end;

if (!TEST_true(SSL_set_cipher_list(clientssl, "AES128-SHA")))
goto end;

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.

hmm, @mattcaswell, when any of these goto end are executed and idx == 5
then the statement below

    if (idx == 5)
        OPENSSL_free(msg);

will crash, because msg is still initialized from above:

    unsigned char *msg = (unsigned char *)
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123";

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.

It would be better to report this as separate issue, or a PR with a fix. Comments in closed PRs often get lost/ignored.

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.

OK, done: #21512

bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 21, 2023
TLS pipelining provides the ability for libssl to read or write multiple
records in parallel. It requires special ciphers to do this, and there are
currently no built-in ciphers that provide this capability. However, the
dasync engine does have such a cipher, so we add a test for this capability
using that engine.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 24c7d36)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 21, 2023
…lled

The pipeline input/output buf arrays must remain accessible to the
EVP_CIPHER_CTX until EVP_Cipher is subsequently called. This fixes an
asan error discovered by the newly added pipeline test.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit df9c7ce)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 21, 2023
During read pipelining we must ensure that the buffer is sufficiently large
to read enough data to fill our pipelines. We also remove some code that
moved data to the start of the packet if we can. This was unnecessary
because of later code which would end up moving it anyway. The earlier move
was also incorrect in the case that |clearold| was 0. This would cause the
read pipelining code to fail with sufficiently large records.

Fixes openssl#20197

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 1d06598)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Jul 21, 2023
We shouldn't be putting more data into a pipeline than the value of
split_send_fragment.

This is a backport of a fix which was included in a much larger commit in
master (c618679) related to moving the pipelining code into the new
record layer that exists there.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 2c4b1c7)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 1, 2023
TLS pipelining provides the ability for libssl to read or write multiple
records in parallel. It requires special ciphers to do this, and there are
currently no built-in ciphers that provide this capability. However, the
dasync engine does have such a cipher, so we add a test for this capability
using that engine.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 24c7d36)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 1, 2023
…lled

The pipeline input/output buf arrays must remain accessible to the
EVP_CIPHER_CTX until EVP_Cipher is subsequently called. This fixes an
asan error discovered by the newly added pipeline test.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit df9c7ce)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 1, 2023
During read pipelining we must ensure that the buffer is sufficiently large
to read enough data to fill our pipelines. We also remove some code that
moved data to the start of the packet if we can. This was unnecessary
because of later code which would end up moving it anyway. The earlier move
was also incorrect in the case that |clearold| was 0. This would cause the
read pipelining code to fail with sufficiently large records.

Fixes openssl#20197

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 1d06598)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 1, 2023
We shouldn't be putting more data into a pipeline than the value of
split_send_fragment.

This is a backport of a fix which was included in a much larger commit in
master (c618679) related to moving the pipelining code into the new
record layer that exists there.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 2c4b1c7)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 19, 2023
TLS pipelining provides the ability for libssl to read or write multiple
records in parallel. It requires special ciphers to do this, and there are
currently no built-in ciphers that provide this capability. However, the
dasync engine does have such a cipher, so we add a test for this capability
using that engine.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 24c7d36)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 19, 2023
…lled

The pipeline input/output buf arrays must remain accessible to the
EVP_CIPHER_CTX until EVP_Cipher is subsequently called. This fixes an
asan error discovered by the newly added pipeline test.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit df9c7ce)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 19, 2023
During read pipelining we must ensure that the buffer is sufficiently large
to read enough data to fill our pipelines. We also remove some code that
moved data to the start of the packet if we can. This was unnecessary
because of later code which would end up moving it anyway. The earlier move
was also incorrect in the case that |clearold| was 0. This would cause the
read pipelining code to fail with sufficiently large records.

Fixes openssl#20197

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 1d06598)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 19, 2023
We shouldn't be putting more data into a pipeline than the value of
split_send_fragment.

This is a backport of a fix which was included in a much larger commit in
master (c618679) related to moving the pipelining code into the new
record layer that exists there.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 2c4b1c7)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 21, 2023
TLS pipelining provides the ability for libssl to read or write multiple
records in parallel. It requires special ciphers to do this, and there are
currently no built-in ciphers that provide this capability. However, the
dasync engine does have such a cipher, so we add a test for this capability
using that engine.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 24c7d36)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 21, 2023
…lled

The pipeline input/output buf arrays must remain accessible to the
EVP_CIPHER_CTX until EVP_Cipher is subsequently called. This fixes an
asan error discovered by the newly added pipeline test.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit df9c7ce)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 21, 2023
During read pipelining we must ensure that the buffer is sufficiently large
to read enough data to fill our pipelines. We also remove some code that
moved data to the start of the packet if we can. This was unnecessary
because of later code which would end up moving it anyway. The earlier move
was also incorrect in the case that |clearold| was 0. This would cause the
read pipelining code to fail with sufficiently large records.

Fixes openssl#20197

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 1d06598)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Aug 21, 2023
We shouldn't be putting more data into a pipeline than the value of
split_send_fragment.

This is a backport of a fix which was included in a much larger commit in
master (c618679) related to moving the pipelining code into the new
record layer that exists there.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 2c4b1c7)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Sep 12, 2023
TLS pipelining provides the ability for libssl to read or write multiple
records in parallel. It requires special ciphers to do this, and there are
currently no built-in ciphers that provide this capability. However, the
dasync engine does have such a cipher, so we add a test for this capability
using that engine.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 24c7d36)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Sep 12, 2023
…lled

The pipeline input/output buf arrays must remain accessible to the
EVP_CIPHER_CTX until EVP_Cipher is subsequently called. This fixes an
asan error discovered by the newly added pipeline test.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit df9c7ce)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Sep 12, 2023
During read pipelining we must ensure that the buffer is sufficiently large
to read enough data to fill our pipelines. We also remove some code that
moved data to the start of the packet if we can. This was unnecessary
because of later code which would end up moving it anyway. The earlier move
was also incorrect in the case that |clearold| was 0. This would cause the
read pipelining code to fail with sufficiently large records.

Fixes openssl#20197

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 1d06598)
bernd-edlinger pushed a commit to bernd-edlinger/openssl that referenced this pull request Sep 12, 2023
We shouldn't be putting more data into a pipeline than the value of
split_send_fragment.

This is a backport of a fix which was included in a much larger commit in
master (c618679) related to moving the pipelining code into the new
record layer that exists there.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from openssl#20208)

(cherry picked from commit 2c4b1c7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: ready to merge The 24 hour grace period has passed, ready to merge 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 triaged: bug The issue/pr is/fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants