gssd: check the machine ccache's TGT instead of a cached endtime
Subsystems (2)
PATCH 1/1 gssd: check the machine ccache's TGT instead of a cached endtime
gssd_get_single_krb5_cred() skips the keytab kinit while ple->endtime, the endtime of gssd's own last kinit, is more than 5 minutes away and the machine ccache file exists. Nothing reads the file again. If another writer replaces it with a ticket that then expires, gssd keeps logging "Credentials in CC ... are good until <date>" and returning success, while every machine upcall fails and the kernel gets -EACCES. File existence and mtime say nothing about the TGT: libkrb5 appends each new service ticket to the selected ccache, and only the TGT can get a ticket for a server that is not already in the file.
We hit this where a separate service keeps the machine ccache fresh by atomically replacing the file. When that service's ticket expired, machine upcalls failed for hours, and gssd logged "Credentials in CC 'FILE:...' are good until" a time 10 hours ahead immediately before "Failed to create machine krb5 context" and an err -13 downcall.
For the file ccache, read it on every call instead. Its default principal must be ple->princ, and it must hold a krbtgt/REALM@REALM ticket issued to ple->princ that has already started, is not marked invalid (postdated) and is valid for another 5 minutes, the existing margin. If so, use it. Otherwise kinit from the keytab exactly as before.
The TGT's client is checked in the same scan that finds the TGT. Each krb5_cc_* call reopens a FILE ccache, so a rename between krb5_cc_get_principal() and the scan could otherwise pair the old file's principal with the new file's TGT. Where an external refresher keeps the file valid, gssd now never kinits, so it no longer fights that refresher over the file. The read takes no lock: replacing the file with rename(2) is atomic, and a read that races gssd's own kinit fails the check and takes the existing locked kinit.
Also pass the retry flag in krb5_use_machine_creds() as force_renew. It passed a literal 0, so the "Machine cache prematurely expired or corrupted trying to recreate cache" retry repeated the first attempt with identical arguments. It now skips the ccache check and kinits from the keytab.
The memcache path is unchanged, and so is the existing "good until" log text, which now reports the endtime of the TGT in the file.
--- tools/nfs-fh-verify/nfs-fh-verify | Bin 145328 -> 142768 bytes utils/gssd/gssd_proc.c | 2 +- utils/gssd/krb5_util.c | 97 ++++++++++++++++++++++++------ 3 files changed, 78 insertions(+), 21 deletions(-)
tools/nfs-fh-verify/nfs-fh-verify binary +0 -0
utils/gssd/gssd_proc.c +1 -1
@@ -636,7 +636,7 @@ krb5_use_machine_creds(struct clnt_info *clp, uid_t uid, do { gssd_refresh_krb5_machine_credential(clp->servername, - service, srchost, 0); + service, srchost, nocache); /* * Get a list of credential cache names and try each * of them until one works or we've tried them all
utils/gssd/krb5_util.c +77 -20
150 lines not on this page · raw message
Signature · 1 line
2.52.0