Skip to content

Commit 75333d4

Browse files
daimngochucklever
authored andcommitted
NFSD: fix use-after-free in __nfs42_ssc_open()
Problem caused by source's vfsmount being unmounted but remains on the delayed unmount list. This happens when nfs42_ssc_open() return errors. Fixed by removing nfsd4_interssc_connect(), leave the vfsmount for the laundromat to unmount when idle time expires. We don't need to call nfs_do_sb_deactive when nfs42_ssc_open return errors since the file was not opened so nfs_server->active was not incremented. Same as in nfsd4_copy, if we fail to launch nfsd4_do_async_copy thread then there's no need to call nfs_do_sb_deactive Reported-by: Xingyuan Mo <hdthky0@gmail.com> Signed-off-by: Dai Ngo <dai.ngo@oracle.com> Tested-by: Xingyuan Mo <hdthky0@gmail.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 3bc8edc commit 75333d4

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,13 +1461,6 @@ nfsd4_interssc_connect(struct nl4_server *nss, struct svc_rqst *rqstp,
14611461
return status;
14621462
}
14631463

1464-
static void
1465-
nfsd4_interssc_disconnect(struct vfsmount *ss_mnt)
1466-
{
1467-
nfs_do_sb_deactive(ss_mnt->mnt_sb);
1468-
mntput(ss_mnt);
1469-
}
1470-
14711464
/*
14721465
* Verify COPY destination stateid.
14731466
*
@@ -1570,11 +1563,6 @@ nfsd4_cleanup_inter_ssc(struct vfsmount *ss_mnt, struct file *filp,
15701563
{
15711564
}
15721565

1573-
static void
1574-
nfsd4_interssc_disconnect(struct vfsmount *ss_mnt)
1575-
{
1576-
}
1577-
15781566
static struct file *nfs42_ssc_open(struct vfsmount *ss_mnt,
15791567
struct nfs_fh *src_fh,
15801568
nfs4_stateid *stateid)
@@ -1770,7 +1758,7 @@ static int nfsd4_do_async_copy(void *data)
17701758
default:
17711759
nfserr = nfserr_offload_denied;
17721760
}
1773-
nfsd4_interssc_disconnect(copy->ss_mnt);
1761+
/* ss_mnt will be unmounted by the laundromat */
17741762
goto do_callback;
17751763
}
17761764
nfserr = nfsd4_do_copy(copy, filp, copy->nf_dst->nf_file,
@@ -1851,8 +1839,10 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18511839
if (async_copy)
18521840
cleanup_async_copy(async_copy);
18531841
status = nfserrno(-ENOMEM);
1854-
if (nfsd4_ssc_is_inter(copy))
1855-
nfsd4_interssc_disconnect(copy->ss_mnt);
1842+
/*
1843+
* source's vfsmount of inter-copy will be unmounted
1844+
* by the laundromat
1845+
*/
18561846
goto out;
18571847
}
18581848

0 commit comments

Comments
 (0)