]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
nfsd: fix use-after-free in nfsd_file_do_acquire tracepoint
authorJeff Layton <jlayton@kernel.org>
Sat, 5 Nov 2022 13:49:26 +0000 (09:49 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Sat, 5 Nov 2022 15:29:55 +0000 (11:29 -0400)
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: 243a5263014a ("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>
fs/nfsd/filecache.c

index adc4e87a71d25e57785d530ca1b4bff3f0d379ed..ec3fceb92236eb3be76e42ee0107245559741d1e 100644 (file)
@@ -1076,6 +1076,7 @@ retry:
                goto open_file;
 
        nfsd_file_slab_free(&nf->nf_rcu);
+       nf = NULL;
        if (ret == -EEXIST)
                goto retry;
        trace_nfsd_file_insert_err(rqstp, key.inode, may_flags, ret);