Skip to content

Commit

Permalink
sunrpc: expiry_time should be seconds not timeval
Browse files Browse the repository at this point in the history
commit 3d96208 upstream.

When upcalling gssproxy, cache_head.expiry_time is set as a
timeval, not seconds since boot. As such, RPC cache expiry
logic will not clean expired objects created under
auth.rpcsec.context cache.

This has proven to cause kernel memory leaks on field. Using
64 bit variants of getboottime/timespec

Expiration times have worked this way since 2010's c5b29f8 "sunrpc:
use seconds since boot in expiry cache".  The gssproxy code introduced
in 2012 added gss_proxy_save_rsc and introduced the bug.  That's a while
for this to lurk, but it required a bit of an extreme case to make it
obvious.

Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
Fixes: 030d794 "SUNRPC: Use gssproxy upcall for server..."
Tested-By: Frank Sorenson <sorenson@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
[bwh: Backported to 3.16: Use struct timespec and getboottime()]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
  • Loading branch information
Roberto Bergantinos Corpas authored and Ben Hutchings committed May 22, 2020
1 parent 888865c commit 4d91d2a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/sunrpc/auth_gss/svcauth_gss.c
Original file line number Diff line number Diff line change
@@ -1171,6 +1171,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
dprintk("RPC: No creds found!\n");
goto out;
} else {
struct timespec boot;

/* steal creds */
rsci.cred = ud->creds;
@@ -1191,6 +1192,9 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
&expiry, GFP_KERNEL);
if (status)
goto out;

getboottime(&boot);
expiry -= boot.tv_sec;
}

rsci.h.expiry_time = expiry;

0 comments on commit 4d91d2a

Please sign in to comment.