-
Notifications
You must be signed in to change notification settings - Fork 721
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
fix: close all /dev/urandom open fds #4835
Conversation
5c0dece
to
938bf29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, this change needs better documentation / explanation. That means some combination of code comments, expanding the PR description, and moving the s2n_rand_cleanup calls closer to the code that requires the cleanup.
It's not obvious that you're calling s2n_rand_cleanup to cleanup/reset custom callbacks, so that END_TEST will cleanup the default callbacks set by BEGIN_TEST, so that the default callbacks won't leak fds.
1b50164
to
b0b49b5
Compare
* make comments more precise * move s2n_rand_cleanup to proper location
b0b49b5
to
1f1d3de
Compare
* Change PR comments for them to be more precise * Move s2n_rand_cleanup to above s2n_rand_set_callbacks
* move s2n_rand_cleanup in s2n_override_openssl_random_test.c back to the end to fix the failed unit test * make comments in s2n_drbg_test.c more precise
c4389df
to
78a44f2
Compare
* Find out dev_urandom in s2n_override_openssl_random_test.c and close it before callbacks are reset
* Modify comments
338e0b0
to
5a7221c
Compare
* use s2n_rand_init to restart engine
5a7221c
to
904d8fd
Compare
Co-authored-by: Sam Clark <[email protected]>
Resolved issues:
Partially solve #4005
Description of changes:
s2n_rand_cleanup
to close/dev/urandom
ins2n_drbg_test.c
ands2n_override_openssl_random_test.c
.s2n_drbg_test.c
ands2n_override_openssl_random_test.c
callss2n_rand_set_callbacks
function which resets the default cleanup callback functions.rand_cleanup_callback
parameter is supposed to close/dev/urandom
, buts2n_cleanup
no longer calls that function, since that parameter is overwritten to some other clean up functions, likenist_fake_entropy_init_cleanup
.s2n_rand_cleanup
to run those fake clean up call back functions, and reset those call back functions back to default.END_TEST
will cleanup the default callbacks set byBEGIN_TEST
, so that the default callbacks won't leak fds.s2n_rand_cleanup
to cleanup the default random callbacks. Then we calls2n_rand_init
to reinitiate the randomness engine again.s2n_rand_set_callbacks
beforeBEGIN_TEST
.s2n_drbg_test.c
wants to pass two different generators tos2n_rand_set_callbacks
, so fix a generator beforeBEGIN_TEST
will change the test itself./dev/urandom
ins2n_fork_generation_number_test.c
.s2n_rand_clean_up()
directly for the reason of this comment.dev_urandom
ins2n_random_test.c
for both test 0 and 1.dev_urandom
before we make that fd invalid.Call-outs:
Testing:
--track-fds=yes
to CTest memcheck and direct all Valgrind output toMemoryTester.log
files./dev/urandom
./dev/urandom
in tests that are fixed../codebuild/bin/test_exec_leak.sh
.s2n-tls/codebuild/bin/test_exec_leak.sh
Lines 82 to 97 in 6bb195c
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.