Blame SOURCES/CVE-2022-0492.patch

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