Blame SOURCES/CVE-2022-0492.patch

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