summaryrefslogtreecommitdiffstats
path: root/xlators/nfs/server/src/auth-cache.c
diff options
context:
space:
mode:
authorShreyas Siravara <sshreyas@fb.com>2017-12-07 08:00:16 -0800
committerJeff Darcy <jeff@pl.atyp.us>2017-12-08 22:33:20 +0000
commit1926cada4a7acf48aa7cbf5ef8bb8942ae10b522 (patch)
tree060a48ca983a9cb6052865cf2d44ae01d8ae26a9 /xlators/nfs/server/src/auth-cache.c
parent742a4eed244833761697646044f20675d1411292 (diff)
nfs: Reference count export items
Export items are used in the auth cache and need to be reference counted to avoid use-after free bugs. Change-Id: I5cdcdc1cc6abad26c7077d66a14f263da07678ac BUG: 1522847 Signed-off-by: Shreyas Siravara <sshreyas@fb.com>
Diffstat (limited to 'xlators/nfs/server/src/auth-cache.c')
-rw-r--r--xlators/nfs/server/src/auth-cache.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/xlators/nfs/server/src/auth-cache.c b/xlators/nfs/server/src/auth-cache.c
index 2b37a7f06bd..a1aacaba61a 100644
--- a/xlators/nfs/server/src/auth-cache.c
+++ b/xlators/nfs/server/src/auth-cache.c
@@ -232,6 +232,8 @@ auth_cache_get (struct auth_cache *cache, char *hashkey,
if (_auth_cache_expired (cache, lookup_res)) {
ret = ENTRY_EXPIRED;
+ GF_REF_PUT (lookup_res->item);
+ lookup_res->item = NULL;
/* free entry and remove from the cache */
GF_FREE (lookup_res);
@@ -473,7 +475,11 @@ cache_nfs_fh (struct auth_cache *cache, struct nfs3_fh *fh,
}
entry->timestamp = time (NULL);
- entry->item = export_item;
+ /* Update entry->item if it is pointing to a different export_item */
+ if (entry->item && entry->item != export_item) {
+ GF_REF_PUT (entry->item);
+ }
+ entry->item = GF_REF_GET (export_item);
ret = auth_cache_add (cache, hashkey, entry);
GF_REF_PUT (entry);