Blame SOURCES/CVE-2022-4379.patch

734205
From 17ddede397702f9cb323ac8bbcc673c8dd00c0cf Mon Sep 17 00:00:00 2001
734205
From: Yannick Cote <ycote@redhat.com>
734205
Date: Fri, 27 Jan 2023 10:34:30 -0500
734205
Subject: [KPATCH CVE-2022-4379] kpatch fixes for CVE-2022-4379
734205
734205
Kernels:
734205
5.14.0-162.6.1.el9_1
734205
5.14.0-162.12.1.el9_1
734205
734205
734205
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-9/-/merge_requests/21
734205
Approved-by: Joe Lawrence (@joe.lawrence)
734205
Changes since last build:
734205
arches: x86_64 ppc64le
734205
l2cap_core.o: changed function: l2cap_rx_state_recv
734205
l2cap_core.o: changed function: l2cap_stream_rx
734205
nfs4proc.o: changed function: nfsd4_copy
734205
nfs4proc.o: changed function: nfsd4_do_async_copy
734205
nft_payload.o: changed function: nft_payload_copy_vlan
734205
sysctl.o: changed function: __do_proc_dointvec
734205
sysctl.o: changed function: __do_proc_douintvec
734205
sysctl.o: changed function: __do_proc_doulongvec_minmax
734205
sysctl.o: changed function: proc_get_long.constprop.0
734205
---------------------------
734205
734205
Modifications:
734205
- fix `kpatch_no_sibling_calls_ppc64le` with -fno-optimize-sibling-calls
734205
734205
commit e7df0c736aef6f0cc49758b8b0bdb27edf5c3e61
734205
Author: Benjamin Coddington <bcodding@redhat.com>
734205
Date:   Wed Dec 21 11:03:36 2022 -0500
734205
734205
    NFSD: fix use-after-free in __nfs42_ssc_open()
734205
734205
    Bugzilla: https://bugzilla.redhat.com/2152815
734205
    CVE: CVE-2022-4379
734205
    Y-Commit: a16ccb9a41ad6a36d58f690b823095798ba7f69c
734205
734205
    O-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152816
734205
    O-CVE: CVE-2022-4379
734205
    Conflicts: Slight context diff from upstream patch, as we've not yet taken
734205
    upstream commit 754035ff7.  This resulting fix is unchanged.
734205
734205
    commit 75333d48f92256a0dec91dbf07835e804fc411c0
734205
    Author: Dai Ngo <dai.ngo@oracle.com>
734205
    Date:   Mon Dec 12 14:50:11 2022 -0800
734205
734205
        NFSD: fix use-after-free in __nfs42_ssc_open()
734205
734205
        Problem caused by source's vfsmount being unmounted but remains
734205
        on the delayed unmount list. This happens when nfs42_ssc_open()
734205
        return errors.
734205
734205
        Fixed by removing nfsd4_interssc_connect(), leave the vfsmount
734205
        for the laundromat to unmount when idle time expires.
734205
734205
        We don't need to call nfs_do_sb_deactive when nfs42_ssc_open
734205
        return errors since the file was not opened so nfs_server->active
734205
        was not incremented. Same as in nfsd4_copy, if we fail to
734205
        launch nfsd4_do_async_copy thread then there's no need to
734205
        call nfs_do_sb_deactive
734205
734205
        Reported-by: Xingyuan Mo <hdthky0@gmail.com>
734205
        Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
734205
        Tested-by: Xingyuan Mo <hdthky0@gmail.com>
734205
        Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
734205
734205
    Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
734205
734205
    Conflicts: This area of code was refractored by c9s MR !1357 so
734205
               context is quite different.
734205
734205
    Signed-off-by: Patrick Talbert <ptalbert@redhat.com>
734205
734205
Signed-off-by: Yannick Cote <ycote@redhat.com>
734205
---
734205
 fs/nfsd/nfs4proc.c | 23 +++++++----------------
734205
 1 file changed, 7 insertions(+), 16 deletions(-)
734205
734205
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
734205
index bbd02c7f4ffe..87bb43a32aad 100644
734205
--- a/fs/nfsd/nfs4proc.c
734205
+++ b/fs/nfsd/nfs4proc.c
734205
@@ -1525,13 +1525,6 @@ nfsd4_interssc_connect(struct nl4_server *nss, struct svc_rqst *rqstp,
734205
 	return status;
734205
 }
734205
 
734205
-static void
734205
-nfsd4_interssc_disconnect(struct vfsmount *ss_mnt)
734205
-{
734205
-	nfs_do_sb_deactive(ss_mnt->mnt_sb);
734205
-	mntput(ss_mnt);
734205
-}
734205
-
734205
 /*
734205
  * Verify COPY destination stateid.
734205
  *
734205
@@ -1634,11 +1627,6 @@ nfsd4_cleanup_inter_ssc(struct vfsmount *ss_mnt, struct nfsd_file *src,
734205
 {
734205
 }
734205
 
734205
-static void
734205
-nfsd4_interssc_disconnect(struct vfsmount *ss_mnt)
734205
-{
734205
-}
734205
-
734205
 static struct file *nfs42_ssc_open(struct vfsmount *ss_mnt,
734205
 				   struct nfs_fh *src_fh,
734205
 				   nfs4_stateid *stateid)
734205
@@ -1794,14 +1782,14 @@ static int nfsd4_do_async_copy(void *data)
734205
 		copy->nf_src = kzalloc(sizeof(struct nfsd_file), GFP_KERNEL);
734205
 		if (!copy->nf_src) {
734205
 			copy->nfserr = nfserr_serverfault;
734205
-			nfsd4_interssc_disconnect(copy->ss_mnt);
734205
+			/* ss_mnt will be unmounted by the laundromat */
734205
 			goto do_callback;
734205
 		}
734205
 		copy->nf_src->nf_file = nfs42_ssc_open(copy->ss_mnt, &copy->c_fh,
734205
 					      &copy->stateid);
734205
 		if (IS_ERR(copy->nf_src->nf_file)) {
734205
 			copy->nfserr = nfserr_offload_denied;
734205
-			nfsd4_interssc_disconnect(copy->ss_mnt);
734205
+			/* ss_mnt will be unmounted by the laundromat */
734205
 			goto do_callback;
734205
 		}
734205
 	}
734205
@@ -1828,6 +1816,7 @@ static int nfsd4_do_async_copy(void *data)
734205
 	return 0;
734205
 }
734205
 
734205
+__attribute__((optimize("-fno-optimize-sibling-calls")))
734205
 static __be32
734205
 nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
734205
 		union nfsd4_op_u *u)
734205
@@ -1886,8 +1875,10 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
734205
 	if (async_copy)
734205
 		cleanup_async_copy(async_copy);
734205
 	status = nfserrno(-ENOMEM);
734205
-	if (!copy->cp_intra)
734205
-		nfsd4_interssc_disconnect(copy->ss_mnt);
734205
+	/*
734205
+	 * source's vfsmount of inter-copy will be unmounted
734205
+	 * by the laundromat
734205
+	 */
734205
 	goto out;
734205
 }
734205
 
734205
-- 
734205
2.39.1
734205
734205