From: Jeff Layton Date: Sat, 5 Nov 2022 13:49:26 +0000 (-0400) Subject: nfsd: fix use-after-free in nfsd_file_do_acquire tracepoint X-Git-Tag: v6.6.17~6123^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bdd6b5624c62d0acd350d07564f1c82fe649235f;p=platform%2Fkernel%2Flinux-rpi.git 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: 243a5263014a ("nfsd: rework hashtable handling in nfsd_do_file_acquire") Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Jeff Layton Signed-off-by: Chuck Lever --- diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index adc4e87..ec3fceb 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -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);