Skip to content

Conversation

simo5
Copy link
Contributor

@simo5 simo5 commented Aug 27, 2020

Return OIDs as static from SPI functions as expected by GSSAPI
Fix a bunch of leaks as reported by #11

Also improve how we handle reloads or waiting by avoiding arbitrary sleeps, although this did not help with the two tests failing under valgrind as hoped.

Fixes #9
Fixes #11

@frozencemetery
Copy link
Member

CI points out that with your changes, special_mechs can be removed.

@simo5 simo5 requested a review from frozencemetery August 27, 2020 19:36
@simo5 simo5 changed the title We leak WIP: We leak Aug 27, 2020
@simo5 simo5 added the WIP Work in Progres label Aug 27, 2020
@simo5
Copy link
Contributor Author

simo5 commented Aug 27, 2020

Changed to WIP, because I found other places we do not seem to exercise that need to return "static" oids

Copy link
Member

@frozencemetery frozencemetery left a comment

Choose a reason for hiding this comment

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

First pass as requested. Will re-review when moved off WIP (or sooner if requested)

@simo5 simo5 force-pushed the we_leak branch 2 times, most recently from 7cfaa7d to 7866618 Compare August 27, 2020 21:41
@simo5 simo5 removed the WIP Work in Progres label Aug 27, 2020
@simo5 simo5 changed the title WIP: We leak We leak Aug 27, 2020
@simo5 simo5 requested a review from frozencemetery August 27, 2020 21:44
@simo5 simo5 dismissed frozencemetery’s stale review August 27, 2020 21:44

all comments should have been handled

Copy link
Member

@frozencemetery frozencemetery left a comment

Choose a reason for hiding this comment

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

  • "Silence a bogus gcc warning" - what warning? (Can you add a note to the commit message?)

  • " Use the correct function to free unused creds" - grep indicates that this problem also occurs in gssi_import_cred_by_mech().

Before merging, I'll do a cleanup pass on commit messages and include what leaks are fixed unless you beat me to it :).

@simo5
Copy link
Contributor Author

simo5 commented Aug 31, 2020

* "Silence a bogus gcc warning" - what warning?  (Can you add a note to the commit message?)

I will

* " Use the correct function to free unused creds" - grep indicates that this problem also occurs in `gssi_import_cred_by_mech()`.

Fixed this too.

Before merging, I'll do a cleanup pass on commit messages and include what leaks are fixed unless you beat me to it :).

Let me know if what I've done is not sufficient.

Also improve the DEBUG by reporting that messages were truncated.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Simo Sorce <simo@redhat.com>
[rharwood@redhat.com: edit commit message]
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
Add a more robust method to wait until gssproxy has reconfigured.  This
should work better when tests ar run on slow machines or through tools
like valgrind which can considerably slow down the tooling.

Also increase timeouts to 30 seconds for said slower machines.

Signed-off-by: Simo Sorce <simo@redhat.com>
[rharwood@redhat.com: commit message tweaks]
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
GSSAPI requires some specific APIs to return "static" OIDs that the user
does not have to free.  The krb5 mechglue in fact requires mechanisms to
also honor this or the mech oid will be irretrievably leaked in some
cases.

To accomodate this, expand use of global mechs structure we already
allocate for the gss_inidicate_mechs case so we can return "static" OIDs
from calls like ISC and ASC.

Signed-off-by: Simo Sorce <simo@redhat.com>
[rharwood@redhat.com: commit message fixups]
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
@frozencemetery
Copy link
Member

Rebased onto main and made some docs changes.

@simo5
Copy link
Contributor Author

simo5 commented Sep 2, 2020

Fixed the item loop in init function and rebased

While we had already fixed the leak here in main, the code performed
unnecessary extra work, so just replacethe whole lot with a function
that does not do any extra allocation or copy.

Signed-off-by: Simo Sorce <simo@redhat.com>
[rharwood@redhat.com: commit message]
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
The xdr_free() call only frees the contents and not the containing
structure itself.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
These are mostly laziness in freeing since the programs are short-lived.

Signed-off-by: Simo Sorce <simo@redhat.com>
[rharwood@redhat.com: rewrote commit message]
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Simo Sorce <simo@redhat.com>
[rharwood@redhat.com: rewrote commit message]
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
gss_display_name and gss_inquire_name reteurn "static" oids, that are
generally not freed by callers, so make sure to match and return actual
static OIDs exported by GSSAPI.

Also remove gpm_equal_oids() and use the library provided gss_oid_equal
function instead.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Simo Sorce <simo@redhat.com>
[rharwood@redhat.com: clarified commit message]
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
As per other functions gssapi expect a static OID here.

Signed-off-by: Simo Sorce <simo@redhat.com>
[rharwood@redhat.com: commit message fixup]
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
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.

We leak Security context mech oids should be static

2 participants