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

Fix ex_data and session_dup issues (1.1.0) #3625

Closed
wants to merge 1 commit into from

Conversation

tmshort
Copy link
Contributor

@tmshort tmshort commented Jun 6, 2017

Backport of PR #3323
Code was added in commit b3c31a6 that overwrote the last ex_data value
using CRYPTO_dup_ex_data() causing a memory leak, and potentially
confusing the ex_data dup() callback.

In ssl_session_dup(), fix error handling (properly reference and up-ref
shared data) and new-up the ex_data before calling CRYPTO_dup_ex_data();
all other structures that dup ex_data have the destination ex_data new'd
before the dup.

Fix up some of the ex_data documentation.

Reviewed-by: Matt Caswell matt@openssl.org
Reviewed-by: Rich Salz rsalz@openssl.org
(Merged from #3323)
(cherry picked from commit 1ee2125)

Checklist
  • documentation is added or updated
  • tests are added or updated

typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
int idx, long argl, void *argp);
typedef void CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
int idx, long argl, void *argp);
Copy link
Member

Choose a reason for hiding this comment

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

Side note: second time this makes me jump before I realise I'm looking at docs... ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be the third and final time!

@levitte
Copy link
Member

levitte commented Jun 7, 2017

Hmmm, was this a clean cherry pick of #3323? In that case, a separate PR shouldn't have been needed...

@tmshort
Copy link
Contributor Author

tmshort commented Jun 7, 2017

Hmmm, was this a clean cherry pick of #3323? In that case, a separate PR shouldn't have been needed...

No, I had significant updates to the unit test.

MYOBJ_EX_DATA *ex_data;

OPENSSL_assert(idx == saved_idx2);
if (idx != saved_idx2) {
Copy link
Member

Choose a reason for hiding this comment

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

OPENSSL_assert() kills the process on assertion failure even in non-debug mode, so this "if" will never fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought I was following a paradigm used elsewhere, but now, I'm not so sure. I will correct.

Copy link
Member

Choose a reason for hiding this comment

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

We have used that paradigm but with normal assert() not OPENSSL_assert().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

master uses the TEST macros, so this was just a backporting issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was in this file... so that's been corrected in the latest update.

cp = MYOBJ_gethello2(t3);
OPENSSL_assert(cp == p);
if (cp != p)
return 1;
MYOBJ_free(t1);
MYOBJ_free(t2);
MYOBJ_free(t3);
free(saved_argp);
free(p);
Copy link
Member

Choose a reason for hiding this comment

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

OPENSSL_free?

Code was added in commit b3c31a6 that overwrote the last ex_data value
using CRYPTO_dup_ex_data() causing a memory leak, and potentially
confusing the ex_data dup() callback.

In ssl_session_dup(), fix error handling (properly reference and up-ref
shared data) and new-up the ex_data before calling CRYPTO_dup_ex_data();
all other structures that dup ex_data have the destination ex_data new'd
before the dup.

Fix up some of the ex_data documentation.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from openssl#3323)
(cherry picked from commit 1ee2125)
@tmshort
Copy link
Contributor Author

tmshort commented Jun 12, 2017

Looking for one more? @levitte ?

@tmshort
Copy link
Contributor Author

tmshort commented Jun 13, 2017

ping @openssl/omc? This has already been committed into 1.0.2 and master; it's just missing in 1.1.0

@richsalz
Copy link
Contributor

@mattcaswell can you merge?

levitte pushed a commit that referenced this pull request Jun 14, 2017
Code was added in commit b3c31a6 that overwrote the last ex_data value
using CRYPTO_dup_ex_data() causing a memory leak, and potentially
confusing the ex_data dup() callback.

In ssl_session_dup(), fix error handling (properly reference and up-ref
shared data) and new-up the ex_data before calling CRYPTO_dup_ex_data();
all other structures that dup ex_data have the destination ex_data new'd
before the dup.

Fix up some of the ex_data documentation.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from #3625)
@mattcaswell
Copy link
Member

Pushed. Thanks.

@tmshort tmshort deleted the 110-ex_data branch June 14, 2017 12:35
pracj3am pushed a commit to cdn77/openssl that referenced this pull request Aug 22, 2017
Code was added in commit b3c31a6 that overwrote the last ex_data value
using CRYPTO_dup_ex_data() causing a memory leak, and potentially
confusing the ex_data dup() callback.

In ssl_session_dup(), fix error handling (properly reference and up-ref
shared data) and new-up the ex_data before calling CRYPTO_dup_ex_data();
all other structures that dup ex_data have the destination ex_data new'd
before the dup.

Fix up some of the ex_data documentation.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from openssl#3625)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants