Skip to content

fix ignored clearold flag #20197

Closed
Closed

Description

@oferhz

Wanted to notify about this bug in OpenSSL, I stumbled upon it during development of vpp static server https POST that uses crypto engine + pipeline support.

I failed to get the git push working, so I am posting the commit that fixes the bug I experienced.

From ea7e8b0f6123846d143d0a6132b47c62a931db5e Mon Sep 17 00:00:00 2001
From: Ofer Heifetz <[email protected]>
Date: Tue, 24 Jan 2023 12:16:33 -0800
Subject: [PATCH] fix ignored clearold flag

When ssl3_read_n() is called with clearold == 1, packet data should
be moved to start of buffer, but the routine had a memmove() call
regardless to clearold value.

On a system that is configured to use piplines, the above flag ignorance
may cause situation where two records use the same address.

Signed-off-by: Ofer Heifetz <[email protected]>
---
 ssl/record/rec_layer_s3.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c
index 1db1712a09..58e0066dee 100644
--- a/ssl/record/rec_layer_s3.c
+++ b/ssl/record/rec_layer_s3.c
@@ -230,8 +230,10 @@ int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold,
                  * effect on memmove arguments and therefore no buffer
                  * overrun can be triggered.
                  */
-                memmove(rb->buf + align, pkt, left);
-                rb->offset = align;
+                if (clearold == 1) {
+                    memmove(rb->buf + align, pkt, left);
+                    rb->offset = align;
+                }
             }
         }
         s->rlayer.packet = rb->buf + rb->offset;
-- 
2.25.1

Activity

  1. added
    issue: bug report
    on Feb 2, 2023
  2. added
    triaged: bug
    and removed
    issue: bug report
    on Feb 3, 2023
  3. mattcaswell commented on Feb 3, 2023

    @mattcaswell
    Member

    Interesting. This is actually the same bug that was fixed in master recently - see #19456. The code has been moved around a bit there (it now lives in a different file in a different function) - but its the same thing. Probably a backport of the same fix that was applied there should be applied here too. Your proposed fix is not wrong, but I think the memmove is actually redundant in the clearold == 1 case for the reasons explained in #19456 (comment)

  4. added a commit that references this issue on Feb 3, 2023
    cef6288
  5. mattcaswell commented on Feb 3, 2023

    @mattcaswell
    Member

    My fix for this, plus some backports of other related pipelining bugs that were fixed in master recently is in #20208

  6. oferhz commented on Feb 3, 2023

    @oferhz
    Author

    So both 1.1.1 and 3.1/3.0 next release should have the above mentioned pipeline issue resolved?
    When I saw the bug first thing I did is look at latest release of above OpenSSL and saw that the same code exists.

  7. mattcaswell commented on Feb 6, 2023

    @mattcaswell
    Member

    So both 1.1.1 and 3.1/3.0 next release should have the above mentioned pipeline issue resolved?

    Well it will be fixed in the next release after #20208 is merged. The code repository is currently frozen due to the 3.0.8/1.1.1t release taking place tomorrow. So it won't be in the next release - but hopefully the one after that. I've currently only backported it to 3.1/3.0. 1.1.1 is in security fix only mode at the moment.

    It should already be fixed in master (the 3.2 development branch).

  8. added 2 commits that reference this issue on Feb 24, 2023
    1d06598
    55c5421
  9. slontis commented on Mar 6, 2023

    @slontis
    Member

    @mattcaswell this looks like it is addressed now?

  10. mattcaswell commented on Mar 6, 2023

    @mattcaswell
    Member

    @mattcaswell this looks like it is addressed now?

    Yes. This is fixed. Closing.

  11. added 5 commits that reference this issue on Jul 13, 2023
    3cac286
    798cd9b
    28110f9
    e3e8cc3
    93a1e76
  12. added a commit that references this issue on Aug 1, 2023
    f4dd74c
  13. added 2 commits that reference this issue on Aug 19, 2023
    122ceb2
    4eaf68c
  14. added a commit that references this issue on Sep 12, 2023
    d6819ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triaged: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions