Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope reduction to enable NULL check to protect dereferencing. #3312

Merged

Conversation

sander-visser
Copy link
Contributor

Signed-off-by: sander-visser [email protected]

Status

READY

Requires Backporting

NO

Migrations

NO

Additional comments

Any additional information that could be of interest

Todos

  • Tests
  • Documentation
  • Changelog updated
  • Backported

Steps to test or reproduce

Outline the steps to test or reproduce the PR here.

mpg
mpg previously approved these changes May 7, 2020
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@mpg
Copy link
Contributor

mpg commented May 7, 2020

Hi @sander-visser and thanks for your contribution! I've reviewed and approved the change, and it will need to be approved by another team member before we can merge it.

Also, it is our current policy to credit all external contributions in the ChangeLog. Could you add an entry by creating a new file in ChangeLog.d (see the Readme in that directory)? Thanks!

@mpg mpg added bug component-tls good-first-issue Good for newcomers needs: changelog needs-review Every commit must be reviewed by at least two team members, labels May 7, 2020
ronald-cron-arm
ronald-cron-arm previously approved these changes May 7, 2020
Copy link
Contributor

@ronald-cron-arm ronald-cron-arm left a comment

Choose a reason for hiding this comment

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

LGTM

@sander-visser sander-visser dismissed stale reviews from ronald-cron-arm and mpg via c64b723 May 7, 2020 18:09
#else
size_t out_buf_len = MBEDTLS_SSL_OUT_BUFFER_LEN;
#endif

mbedtls_platform_zeroize( ssl->out_buf, out_buf_len );
mbedtls_free( ssl->out_buf );
ssl->out_buf = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

The whole ssl record is unconditionally zeroed at the end of the function.
This assignment could be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed. And removing the assignment would also make things more consistent the other allocated structures (transform, session, etc) that we don't explicitly clear.

However IMO this is quite orthogonal to the goal of this PR, so should probably go in a separate PR.

#else
size_t in_buf_len = MBEDTLS_SSL_IN_BUFFER_LEN;
#endif

mbedtls_platform_zeroize( ssl->in_buf, in_buf_len );
mbedtls_free( ssl->in_buf );
ssl->in_buf = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

This assignment could be removed as well.

Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

Thanks for adding the ChangeLog entry. Looks good to me.

@mpg
Copy link
Contributor

mpg commented May 11, 2020

I checked the CI results, and the failure in pr-merge Mbed OS testing was an infrastructure glitch (failing to clone the repo), which is obviously unrelated to this PR and can be disregarded.

@ronald-cron-arm ronald-cron-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, labels May 11, 2020
@gilles-peskine-arm gilles-peskine-arm merged commit c39a80d into Mbed-TLS:development May 11, 2020
@ipodipad
Copy link

Could this patch enhance the bug reported in below?
https://forums.mbed.com/t/memory-leak-and-hardfault-at-ecdh-handshake/6447

yanesca pushed a commit that referenced this pull request Jul 1, 2020
* development: (81 commits)
  Add changelog entry file
  Remove obsolete comment
  Changelog entry noting the behavior change and storage format change
  Update SE support to pass a location when registering a driver
  Update SE support to pass a location when registering a driver
  Update the SE interface to pass a location when registering a driver
  Fix macros
  Missing word
  Define a macro to construct a lifetime from persistence and location
  Document PSA_KEY_PERSISTENCE_xxx and PSA_KEY_LOCATION_xxx
  Rename and clarify the default persistent location and persistence
  PSA_KEY_LIFETIME_PERSISTENT is a lifetime, not just a storage area
  Shorten type and value names for lifetime parts
  Define some structure for lifetime values
  Fix typo in program benchmark.
  Add changelog entry for #3310.
  Add variable initialization to large SSL TLS function.
  Add Changelog entry for #3312
  Scope reduction to enable NULL check to protect dereferencing.
  Expose SSL HW record acceleration error.
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports bug component-tls good-first-issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants