Skip to content

Commit

Permalink
NFSD: Fix potential use-after-free in nfsd_file_put()
Browse files Browse the repository at this point in the history
nfsd_file_put_noref() can free @nf, so don't dereference @nf
immediately upon return from nfsd_file_put_noref().

Suggested-by: Trond Myklebust <trondmy@hammerspace.com>
Fixes: 9993979 ("nfsd: Clean up nfsd_file_put()")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
  • Loading branch information
Chuck Lever committed Jun 2, 2022
1 parent 9ff9f77 commit b6c71c6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions fs/nfsd/filecache.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,12 @@ nfsd_file_put(struct nfsd_file *nf)
if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags) == 0) {
nfsd_file_flush(nf);
nfsd_file_put_noref(nf);
} else {
} else if (nf->nf_file) {
nfsd_file_put_noref(nf);
if (nf->nf_file)
nfsd_file_schedule_laundrette();
}
nfsd_file_schedule_laundrette();
} else
nfsd_file_put_noref(nf);

if (atomic_long_read(&nfsd_filecache_count) >= NFSD_FILE_LRU_LIMIT)
nfsd_file_gc();
}
Expand Down

0 comments on commit b6c71c6

Please sign in to comment.