Blame SOURCES/CVE-2022-0492.patch

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