Don't open random devices while cleaning up.#7023
Don't open random devices while cleaning up.#7023mspncp wants to merge 2 commits intoopenssl:masterfrom
Conversation
Fixes openssl#7022 In pull request openssl#6432 a change was made to keep the handles to the random devices opened in order to avoid reseeding problems for applications in chroot environments. As a consequence, the handles of the random devices were leaked at exit if the random generator was not used by the application. This happened, because the call to RAND_set_rand_method(NULL) in rand_cleanup_int() triggered a call to the call_once function do_rand_init, which opened the random devices via rand_pool_init(void). Thanks to GitHub user @bwelling for reporting this issue.
8d4486a to
a18990d
Compare
| meth->cleanup(); | ||
| rand_pool_cleanup(); | ||
| RAND_set_rand_method(NULL); | ||
| rand_pool_cleanup(); |
There was a problem hiding this comment.
Swapping these two lines was my first attempt to fix the problem. However, the result was not satisfactory, because the devices were still opened by RAND_set_rand_method() and closed right afterwards in rand_pool_cleanup(). That's why I introduced rand_cleaning_up.
So strictly speaking this swapping is not necessary anymore, but conceptually it makes more sense to cleanup the entropy source after the random generator has been disabled and not before.
crypto/rand/rand_lib.c
Outdated
|
|
||
| if (!rand_pool_init()) | ||
| goto err3; | ||
| if (!rand_cleaning_up) |
There was a problem hiding this comment.
Better might be using && rather than nesting the if statements?
paulidale
left a comment
There was a problem hiding this comment.
One minor cleaning but it's not vital.
|
I'll merge this evening. |
|
Editorial note: I intend to apply two small cosmetical changes to the commit message when merging: |
Fixes #7022 In pull request #6432 a change was made to keep the handles to the random devices opened in order to avoid reseeding problems for applications in chroot environments. As a consequence, the handles of the random devices were leaked at exit if the random generator was not used by the application. This happened, because the call to RAND_set_rand_method(NULL) in rand_cleanup_int() triggered a call to the call_once function do_rand_init, which opened the random devices via rand_pool_init(). Thanks to GitHub user @bwelling for reporting this issue. Reviewed-by: Paul Dale <[email protected]> (Merged from #7023)
|
Ok, merged. Thanks! |
Fixes #7022
In pull request #6432 a change was made to keep the handles to the
random devices opened in order to avoid reseeding problems for
applications in chroot environments.
As a consequence, the handles of the random devices were leaked at exit
if the random generator was not used by the application. This happened,
because the call to RAND_set_rand_method(NULL) in rand_cleanup_int()
triggered a call to the call_once function do_rand_init, which opened
the random devices via rand_pool_init(void).
Thanks to GitHub user @bwelling for reporting this issue.