Blame SOURCES/CVE-2022-4379.patch

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