Blame SOURCES/CVE-2022-0492.patch

23221e
From 6e23854a2c0c6acedb76eaeb306090aaacf58245 Mon Sep 17 00:00:00 2001
23221e
From: Joe Lawrence <joe.lawrence@redhat.com>
23221e
Date: Thu, 24 Feb 2022 13:03:17 -0500
23221e
Subject: [KPATCH CVE-2022-0492] cgroup-v1: kpatch fixes for CVE-2022-0492
23221e
23221e
Kernels:
23221e
4.18.0-348.el8
23221e
4.18.0-348.2.1.el8_5
23221e
4.18.0-348.7.1.el8_5
23221e
4.18.0-348.12.2.el8_5
23221e
23221e
Changes since last build:
23221e
arches: x86_64 ppc64le
23221e
cgroup-v1.o: changed function: cgroup1_parse_param
23221e
cgroup-v1.o: changed function: cgroup_release_agent_write
23221e
---------------------------
23221e
23221e
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-8/-/merge_requests/26
23221e
Approved-by: Yannick Cote (@ycote1)
23221e
Kernels:
23221e
4.18.0-348.el8
23221e
4.18.0-348.2.1.el8_5
23221e
4.18.0-348.7.1.el8_5
23221e
4.18.0-348.12.2.el8_5
23221e
23221e
Modifications: none
23221e
23221e
commit 07650ec60ef7ae3d33cde8faed38770c838ff4b1
23221e
Author: Waiman Long <longman@redhat.com>
23221e
Date:   Tue Feb 8 19:21:47 2022 -0500
23221e
23221e
    cgroup-v1: Require capabilities to set release_agent
23221e
23221e
    Bugzilla: https://bugzilla.redhat.com/2052166
23221e
    CVE: CVE-2022-0492
23221e
    Y-Commit: 55f79b1a4b02276a6edda7cb7ef5ec0c585141a1
23221e
23221e
    O-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2052167
23221e
    O-CVE: CVE-2022-0492
23221e
23221e
    commit 24f6008564183aa120d07c03d9289519c2fe02af
23221e
    Author: Eric W. Biederman <ebiederm@xmission.com>
23221e
    Date:   Thu, 20 Jan 2022 11:04:01 -0600
23221e
23221e
        cgroup-v1: Require capabilities to set release_agent
23221e
23221e
        The cgroup release_agent is called with call_usermodehelper.  The function
23221e
        call_usermodehelper starts the release_agent with a full set fo capabilities.
23221e
        Therefore require capabilities when setting the release_agaent.
23221e
23221e
        Reported-by: Tabitha Sable <tabitha.c.sable@gmail.com>
23221e
        Tested-by: Tabitha Sable <tabitha.c.sable@gmail.com>
23221e
        Fixes: 81a6a5cdd2c5 ("Task Control Groups: automatic userspace notification of idle cgroups")
23221e
        Cc: stable@vger.kernel.org # v2.6.24+
23221e
        Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
23221e
        Signed-off-by: Tejun Heo <tj@kernel.org>
23221e
23221e
    Signed-off-by: Waiman Long <longman@redhat.com>
23221e
    Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
23221e
23221e
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
23221e
---
23221e
 kernel/cgroup/cgroup-v1.c | 14 ++++++++++++++
23221e
 1 file changed, 14 insertions(+)
23221e
23221e
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
23221e
index 852f1349f9d9..fdf337ccda6b 100644
23221e
--- a/kernel/cgroup/cgroup-v1.c
23221e
+++ b/kernel/cgroup/cgroup-v1.c
23221e
@@ -544,6 +544,14 @@ static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of,
23221e
 
23221e
 	BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);
23221e
 
23221e
+	/*
23221e
+	 * Release agent gets called with all capabilities,
23221e
+	 * require capabilities to set release agent.
23221e
+	 */
23221e
+	if ((of->file->f_cred->user_ns != &init_user_ns) ||
23221e
+	    !capable(CAP_SYS_ADMIN))
23221e
+		return -EPERM;
23221e
+
23221e
 	cgrp = cgroup_kn_lock_live(of->kn, false);
23221e
 	if (!cgrp)
23221e
 		return -ENODEV;
23221e
@@ -951,6 +959,12 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param)
23221e
 		/* Specifying two release agents is forbidden */
23221e
 		if (ctx->release_agent)
23221e
 			return invalfc(fc, "release_agent respecified");
23221e
+		/*
23221e
+		 * Release agent gets called with all capabilities,
23221e
+		 * require capabilities to set release agent.
23221e
+		 */
23221e
+		if ((fc->user_ns != &init_user_ns) || !capable(CAP_SYS_ADMIN))
23221e
+			return invalfc(fc, "Setting release_agent not allowed");
23221e
 		ctx->release_agent = param->string;
23221e
 		param->string = NULL;
23221e
 		break;
23221e
-- 
23221e
2.34.1
23221e
23221e