-
-
Notifications
You must be signed in to change notification settings - Fork 11k
Fix invalid malloc failures in PEM_write_bio_PKCS8PrivateKey*()
#17507
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
Conversation
|
In general this is wrong place to fix your problem. This needs to be properly handled at the callers to not try 0 bytes size allocation or memory duplication. |
b7dcbd1 to
3df2ce3
Compare
PEM_write_bio_PKCS8PrivateKey()
167f7d1 to
ee25717
Compare
@t8m thanks, updated accordingly. |
ee25717 to
0ed5713
Compare
t8m
left a comment
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.
LGTM. To be able to accept the PR we will need a CLA signed from you. Please follow the process described at https://www.openssl.org/policies/cla.html
|
The CI failures are relevant. |
0ed5713 to
2a0f6be
Compare
|
@t8m it's just the callback variation that fails which was happening even before this change was added. I'm suspecting that's happening due to an incorrect invocation of the API? (suggestions would be great!) I've commented out that test for now with a TODO. If CI passes now (not sure why these tests aren't run for me locally, will investigate later) and y'all are good with the change, I'll try to sign the CLA. |
2a0f6be to
00a1dad
Compare
|
Please re-enable the last test case. The error can be fixed by changing https://github.com/openssl/openssl/blob/master/crypto/ui/ui_util.c#L117 to |
|
Also please sign and send the CLA. |
but please be careful, return values 0 and -1 have a special meaning, Lines 516 to 530 in 5288303
and this is the callee: Lines 111 to 121 in 5288303
|
|
@bernd-edlinger the callback is the pem callback which returns 0 if the password is zero length, not that the callback has failed. We should not return 0 from ui_read() if the pem callback did not fail but simply returned 0 length password. |
|
This pull request is ready to merge |
When `PEM_write_bio_PKCS8PrivateKey()` was passed an empty passphrase string, `OPENSSL_memdup()` was incorrectly getting used for 0 bytes size allocation, which resulted in malloc failures. Fixes: #17506 Signed-off-by: Darshan Sen <[email protected]> Reviewed-by: Bernd Edlinger <[email protected]> Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from #17507)
Signed-off-by: Darshan Sen <[email protected]> Reviewed-by: Bernd Edlinger <[email protected]> Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from #17507)
When `PEM_write_bio_PKCS8PrivateKey()` was passed an empty passphrase string, `OPENSSL_memdup()` was incorrectly getting used for 0 bytes size allocation, which resulted in malloc failures. Fixes: #17506 Signed-off-by: Darshan Sen <[email protected]> Reviewed-by: Bernd Edlinger <[email protected]> Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from #17507) (cherry picked from commit 59ccb72)
Signed-off-by: Darshan Sen <[email protected]> Reviewed-by: Bernd Edlinger <[email protected]> Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from #17507) (cherry picked from commit 1d28ada)
|
Merged to master and 3.0 branches (resolving the CHANGES.md conflict manually). Thank you for your contribution. |
|
@t8m thanks! Should this PR be closed, now that my commits have landed on the relevant branches or is there anything else I can help out with? |
When `PEM_write_bio_PKCS8PrivateKey()` was passed an empty passphrase string, `OPENSSL_memdup()` was incorrectly getting used for 0 bytes size allocation, which resulted in malloc failures. Fixes: openssl#17506 Signed-off-by: Darshan Sen <[email protected]> Reviewed-by: Bernd Edlinger <[email protected]> Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from openssl#17507)
Signed-off-by: Darshan Sen <[email protected]> Reviewed-by: Bernd Edlinger <[email protected]> Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from openssl#17507)
openssl/openssl@59ccb72: ``` commit 59ccb72cd5cec3b4e312853621e12a68dacdbc7e Author: Darshan Sen <[email protected]> Date: Fri Jan 14 16:22:41 2022 +0530 Fix invalid malloc failures in PEM_write_bio_PKCS8PrivateKey() When `PEM_write_bio_PKCS8PrivateKey()` was passed an empty passphrase string, `OPENSSL_memdup()` was incorrectly getting used for 0 bytes size allocation, which resulted in malloc failures. Fixes: openssl/openssl#17506 Signed-off-by: Darshan Sen <[email protected]> Reviewed-by: Bernd Edlinger <[email protected]> Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from openssl/openssl#17507) ``` openssl/openssl@1d28ada: ``` commit 1d28ada1c39997c10fe5392f4235bbd2bc44b40f Author: Darshan Sen <[email protected]> Date: Sat Jan 22 17:56:05 2022 +0530 Allow empty passphrase in PEM_write_bio_PKCS8PrivateKey_nid() Signed-off-by: Darshan Sen <[email protected]> Reviewed-by: Bernd Edlinger <[email protected]> Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from openssl/openssl#17507) ``` Refs: openssl/openssl#17507 Fixes: nodejs#41428 Signed-off-by: Darshan Sen <[email protected]>
Refs: openssl/openssl#17507 Refs: nodejs#41428 Signed-off-by: Darshan Sen <[email protected]>
Refs: openssl/openssl#17507 Refs: #41428 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #42319 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Refs: openssl/openssl#17507 Refs: #41428 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #42319 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Refs: openssl/openssl#17507 Refs: nodejs#41428 Signed-off-by: Darshan Sen <[email protected]> PR-URL: nodejs#42319 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Refs: openssl/openssl#17507 Refs: #41428 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #42319 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Refs: openssl/openssl#17507 Refs: #41428 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #42319 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Refs: openssl/openssl#17507 Refs: #41428 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #42319 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Refs: openssl/openssl#17507 Refs: nodejs#41428 Signed-off-by: Darshan Sen <[email protected]> PR-URL: nodejs#42319 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
When
PEM_write_bio_PKCS8PrivateKey()andPEM_write_bio_PKCS8PrivateKey_nid()were passed empty passphrase strings,
OPENSSL_memdup()was incorrectly gettingused for 0 bytes size allocations, which resulted in malloc failures.
Fixes: #17506
Signed-off-by: Darshan Sen [email protected]
Checklist