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

Add min lifetime option #35

Merged
merged 2 commits into from
Sep 3, 2021
Merged

Conversation

scottmayhew
Copy link
Contributor

It's possible for gssproxy to return a cached credential with a very small remaining lifetime. This can be problematic for NFS clients since it requires a round trip to the NFS server to establish a GSS context. Add a min_lifetime option that represents the lowest value that the lifetime of the cached credential can be. Any lower than that, and gp_check_cred() returns GSS_S_CREDENTIALS_EXPIRED, so that gp_add_krb5_creds() is forced to try to obtain a new credential.

This fixes an issue where NFS clients (particularly ones using the interposer mechanism) can receive EKEYEXPIRED/EACCES/EIO at the time of Kerberos ticket expiration.

Also, fix an issue where debug messages aren't getting logged during config parsing.

Currently gp_debug_toggle() is called at the end of load_config(), and
as a result any GPDEBUG() calls that happen during config processing are
no-ops.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Copy link
Contributor

@simo5 simo5 left a comment

Choose a reason for hiding this comment

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

Just minor nits, the approach looks good.

I need to think if w want to set a small default anyway, returning a credentials with less than at least a few seconds (5 or 10) is not very useful ...

src/gp_config.c Outdated
@@ -538,6 +538,17 @@ static int load_services(struct gp_config *cfg, struct gp_ini_context *ctx)
goto done;
}
}

cfg->svcs[n]->min_lifetime = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please ad a DEFAULT_MIN_LIFETIME macro for this?
We might actually set a default min_lifetime that is not 0, thinking about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. Have you thought about whether you want the default to be non-zero?

src/gp_config.c Show resolved Hide resolved
src/gp_config.c Show resolved Hide resolved
src/gp_creds.c Outdated
ret_maj = GSS_S_COMPLETE;
if (svc->min_lifetime && lifetime < svc->min_lifetime) {
GPDEBUG("%s: lifetime (%u) less than min_lifetime (%u) "
"for service \"%s\" - returning GSS_S_CREDENTIALS_EXPIRED\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please drop the " - returning GSS_S_CREDENTIALS_EXPIRED" part, as that will be logged already as the return error of the function in debug mode. Replace with just "returning".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay.

src/gp_creds.c Outdated
@@ -492,6 +492,7 @@ static int gp_get_cred_environment(struct gp_call_ctx *gpcall,
}

static uint32_t gp_check_cred(uint32_t *min,
struct gp_call_ctx *gpcall,
Copy link
Contributor

Choose a reason for hiding this comment

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

You are not using gpcall, please pass in a pointer to gp_service directly instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay.

@simo5
Copy link
Contributor

simo5 commented Sep 2, 2021

We should probably have a test for this, I wonder if we can add one easily ?

@scottmayhew
Copy link
Contributor Author

We should probably have a test for this, I wonder if we can add one easily ?

I would think a test program would need to use of gss_inquire_cred() to check the lifetime, and from what I've seen with rpc.gssd, when we call gss_inquire_cred() we don't get the correct lifetime back from gssproxy (it sort of sounds like the same issue being described in #33).

@simo5
Copy link
Contributor

simo5 commented Sep 3, 2021

I think we want to set a DEFAULT_MIN_LIFETIME of 15, it's not a lot, but should allow at least a couple of roundtrips before creds become useless.

It's possible for gssproxy to return a cached credential with a very
small remaining lifetime.  This can be problematic for NFS clients since
it requires a round trip to the NFS server to establish a GSS context.
Add a min_lifetime option that represents the lowest value that the
lifetime of the cached credential can be.  Any lower than that, and
gp_check_cred() returns GSS_S_CREDENTIALS_EXPIRED, so that
gp_add_krb5_creds() is forced to try to obtain a new credential.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
@scottmayhew scottmayhew force-pushed the add-min-lifetime-option branch from d3ce1f9 to e420f95 Compare September 3, 2021 18:48
@simo5
Copy link
Contributor

simo5 commented Sep 3, 2021

Thanks Scott, I think this is good enough to be merged, I will think later about how to test, given I will need to deal with time manipulation in order to not have to just slow down tests.

@simo5 simo5 merged commit c6847f0 into gssapi:main Sep 3, 2021
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.

2 participants