Skip to content

Commit bdd6b56

Browse files
jtlaytonchucklever
authored andcommitted
nfsd: fix use-after-free in nfsd_file_do_acquire tracepoint
When we fail to insert into the hashtable with a non-retryable error, we'll free the object and then goto out_status. If the tracepoint is enabled, it'll end up accessing the freed object when it tries to grab the fields out of it. Set nf to NULL after freeing it to avoid the issue. Fixes: 243a526 ("nfsd: rework hashtable handling in nfsd_do_file_acquire") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent d3aefd2 commit bdd6b56

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/nfsd/filecache.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,7 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
10761076
goto open_file;
10771077

10781078
nfsd_file_slab_free(&nf->nf_rcu);
1079+
nf = NULL;
10791080
if (ret == -EEXIST)
10801081
goto retry;
10811082
trace_nfsd_file_insert_err(rqstp, key.inode, may_flags, ret);

0 commit comments

Comments
 (0)