Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

NFSD: fix nfs4_file access extra count in nfsd4_add_rdaccess_to_wrdeleg

In nfsd4_add_rdaccess_to_wrdeleg, if fp->fi_fds[O_RDONLY] is already
set by another thread, __nfs4_file_get_access should not be called
to increment the nfs4_file access count since that was already done
by the thread that added READ access to the file. The extra fi_access
count in nfs4_file can prevent the corresponding nfsd_file from being
freed.

When stopping nfs-server service, these extra access counts trigger a
BUG in kmem_cache_destroy() that shows nfsd_file object remaining on
__kmem_cache_shutdown.

This problem can be reproduced by running the Git project's test
suite over NFS.

Fixes: 8072e34e1387 ("nfsd: fix nfsd_file reference leak in nfsd4_add_rdaccess_to_wrdeleg()")
Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

authored by

Dai Ngo and committed by
Chuck Lever
b48f44f3 6f57293a

+2 -2
+2 -2
fs/nfsd/nfs4state.c
··· 6266 6266 return (false); 6267 6267 fp = stp->st_stid.sc_file; 6268 6268 spin_lock(&fp->fi_lock); 6269 - __nfs4_file_get_access(fp, NFS4_SHARE_ACCESS_READ); 6270 6269 if (!fp->fi_fds[O_RDONLY]) { 6270 + __nfs4_file_get_access(fp, NFS4_SHARE_ACCESS_READ); 6271 6271 fp->fi_fds[O_RDONLY] = nf; 6272 + fp->fi_rdeleg_file = nfsd_file_get(fp->fi_fds[O_RDONLY]); 6272 6273 nf = NULL; 6273 6274 } 6274 - fp->fi_rdeleg_file = nfsd_file_get(fp->fi_fds[O_RDONLY]); 6275 6275 spin_unlock(&fp->fi_lock); 6276 6276 if (nf) 6277 6277 nfsd_file_put(nf);