Skip to content

Commit 073f197

Browse files
committed
NFSD: fix use-after-free in __nfs42_ssc_open()
jira LE-1907 cve CVE-2022-4379 Rebuild_History Non-Buildable kernel-rt-5.14.0-284.30.1.rt14.315.el9_2 commit-author Dai Ngo <dai.ngo@oracle.com> commit 75333d4 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> (cherry picked from commit 75333d4) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 3153cb6 commit 073f197

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
@@ -1469,13 +1469,6 @@ nfsd4_interssc_connect(struct nl4_server *nss, struct svc_rqst *rqstp,
14691469
return status;
14701470
}
14711471

1472-
static void
1473-
nfsd4_interssc_disconnect(struct vfsmount *ss_mnt)
1474-
{
1475-
nfs_do_sb_deactive(ss_mnt->mnt_sb);
1476-
mntput(ss_mnt);
1477-
}
1478-
14791472
/*
14801473
* Verify COPY destination stateid.
14811474
*
@@ -1578,11 +1571,6 @@ nfsd4_cleanup_inter_ssc(struct vfsmount *ss_mnt, struct file *filp,
15781571
{
15791572
}
15801573

1581-
static void
1582-
nfsd4_interssc_disconnect(struct vfsmount *ss_mnt)
1583-
{
1584-
}
1585-
15861574
static struct file *nfs42_ssc_open(struct vfsmount *ss_mnt,
15871575
struct nfs_fh *src_fh,
15881576
nfs4_stateid *stateid)
@@ -1774,7 +1762,7 @@ static int nfsd4_do_async_copy(void *data)
17741762
default:
17751763
nfserr = nfserr_offload_denied;
17761764
}
1777-
nfsd4_interssc_disconnect(copy->ss_mnt);
1765+
/* ss_mnt will be unmounted by the laundromat */
17781766
goto do_callback;
17791767
}
17801768
nfserr = nfsd4_do_copy(copy, filp, copy->nf_dst->nf_file,
@@ -1855,8 +1843,10 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18551843
if (async_copy)
18561844
cleanup_async_copy(async_copy);
18571845
status = nfserrno(-ENOMEM);
1858-
if (nfsd4_ssc_is_inter(copy))
1859-
nfsd4_interssc_disconnect(copy->ss_mnt);
1846+
/*
1847+
* source's vfsmount of inter-copy will be unmounted
1848+
* by the laundromat
1849+
*/
18601850
goto out;
18611851
}
18621852

0 commit comments

Comments
 (0)