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

ssl_lib: added pointer SSL_CONNECTION check to NULL before dereferencing it in ossl_ctrl_internal() #22470

Closed

Conversation

nv-dmd
Copy link

@nv-dmd nv-dmd commented Oct 23, 2023

Fixes: #22466

In ssl_lib.c added pointer SSL_CONNECTION check to NULL before dereferencing it in ossl_ctrl_internal()

t8m
t8m previously approved these changes Oct 23, 2023
@t8m t8m added branch: master Merge to master branch approval: review pending This pull request needs review by a committer approval: otc review pending This pull request needs review by an OTC member triaged: bug The issue/pr is/fixes a bug tests: exempted The PR is exempt from requirements for testing and removed approval: otc review pending This pull request needs review by an OTC member labels Oct 23, 2023
@@ -2908,6 +2908,9 @@ long ossl_ctrl_internal(SSL *s, int cmd, long larg, void *parg, int no_quic)
long l;
SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL(s);

if (sc == NULL)
return 0;

Copy link
Contributor

Choose a reason for hiding this comment

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

There are a few reasons SSL_CONNECTION_FROM_SSL might resolve to NULL. Clearly if s is NULL it will. But it will also return NULL if:
OPENSSL_NO_QUIC is not defined and the ssl type is neither SSL_TYPE_SSL_CONNECTION nor SSL_TYPE_QUIC_CONNECTION
or
if OPENSSL_NO_QUICK is defined and the ssl type is not SSL_TYPE_SSL_CONNECTION

Is it worth detecting that rasing an error based on those condtions? Otherwise users will get a 0 return code and no error when what otherwise appears to be a valid ssl object is passed in

Copy link
Author

Choose a reason for hiding this comment

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

I corrected the code so that pointer SSL is checked first. If it is equal to NULL, then returned 0, since pointer SSL_CONNECTION will also be NULL.
Next comes checking SSL_CONNECTION for NULL only by ssl type. Pointer SSL_CONNECTION needs to be checked, since it will be dereferenced next.

Copy link
Member

Choose a reason for hiding this comment

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

Please revert this to the original fix. In other cases we do not raise error for these failures and IMO there is no point doing that here anyway as these errors can happen only with severe application bugs.

Copy link
Author

Choose a reason for hiding this comment

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

Reverted to the original fix.

@t8m t8m removed the approval: review pending This pull request needs review by a committer label Oct 24, 2023
@t8m t8m dismissed their stale review October 24, 2023 11:23

changed since

@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Oct 24, 2023
@t8m t8m added the approval: review pending This pull request needs review by a committer label Oct 24, 2023
@github-actions github-actions bot removed the severity: fips change The pull request changes FIPS provider sources label Oct 24, 2023
@paulidale paulidale added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Oct 25, 2023
@openssl-machine openssl-machine added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Oct 26, 2023
@openssl-machine
Copy link
Collaborator

This pull request is ready to merge

@hlandau hlandau added the branch: 3.2 Merge to openssl-3.2 label Oct 26, 2023
@hlandau
Copy link
Member

hlandau commented Oct 26, 2023

This is also applicable to 3.2.

@hlandau
Copy link
Member

hlandau commented Oct 26, 2023

Merged to 3.2 and master. Thank you.

@hlandau hlandau closed this Oct 26, 2023
openssl-machine pushed a commit that referenced this pull request Oct 26, 2023
…ing it in ossl_ctrl_internal()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from #22470)
openssl-machine pushed a commit that referenced this pull request Oct 26, 2023
…referencing it in ossl_ctrl_internal()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from #22470)
openssl-machine pushed a commit that referenced this pull request Oct 26, 2023
…referencing it in ossl_ctrl_internal()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from #22470)
openssl-machine pushed a commit that referenced this pull request Oct 26, 2023
…ing it in ossl_ctrl_internal()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from #22470)
openssl-machine pushed a commit that referenced this pull request Oct 26, 2023
…ing it in ossl_ctrl_internal()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from #22470)

(cherry picked from commit 24844be)
openssl-machine pushed a commit that referenced this pull request Oct 26, 2023
…referencing it in ossl_ctrl_internal()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from #22470)

(cherry picked from commit b9788ce)
openssl-machine pushed a commit that referenced this pull request Oct 26, 2023
…referencing it in ossl_ctrl_internal()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from #22470)

(cherry picked from commit b419fcc)
openssl-machine pushed a commit that referenced this pull request Oct 26, 2023
…ing it in ossl_ctrl_internal()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from #22470)

(cherry picked from commit 8dc82c0)
@nv-dmd nv-dmd deleted the check_ssl_pointer_in_SSL_ctrl_funtion branch October 26, 2023 15:01
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Nov 4, 2023
…ing it in ossl_ctrl_internal()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from openssl/openssl#22470)

Signed-off-by: fly2x <fly2x@hitls.org>
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Nov 4, 2023
…referencing it in ossl_ctrl_internal()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from openssl/openssl#22470)

Signed-off-by: fly2x <fly2x@hitls.org>
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Nov 4, 2023
…referencing it in ossl_ctrl_internal()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from openssl/openssl#22470)

Signed-off-by: fly2x <fly2x@hitls.org>
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Nov 4, 2023
…ing it in ossl_ctrl_internal()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from openssl/openssl#22470)

Signed-off-by: fly2x <fly2x@hitls.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Merge to master branch branch: 3.2 Merge to openssl-3.2 tests: exempted The PR is exempt from requirements for testing triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash if SSL *s equal to NULL is passed to SSL_ctrl()
6 participants