|
|
23221e |
From 7d389a33490309d15530e3372c3045110b3031ab Mon Sep 17 00:00:00 2001
|
|
|
23221e |
From: Artem Savkov <asavkov@redhat.com>
|
|
|
23221e |
Date: Tue, 4 Jan 2022 10:40:56 +0100
|
|
|
23221e |
Subject: [KPATCH CVE-2021-4154] cgroup: verify that source is a string
|
|
|
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 |
|
|
|
23221e |
Changes since last build:
|
|
|
23221e |
arches: x86_64 ppc64le
|
|
|
23221e |
cgroup-v1.o: changed function: cgroup1_parse_param
|
|
|
23221e |
---------------------------
|
|
|
23221e |
|
|
|
23221e |
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-8/-/merge_requests/9
|
|
|
23221e |
Approved-by: Yannick Cote (@ycote1)
|
|
|
23221e |
Approved-by: Joe Lawrence (@joe.lawrence)
|
|
|
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 |
Z-MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-8/-/merge_requests/1865
|
|
|
23221e |
CVE: CVE-2021-4154
|
|
|
23221e |
|
|
|
23221e |
commit e1ee4bc6e6d8fd36b493fca941b7d5b6e987ae3c
|
|
|
23221e |
Author: Waiman Long <longman@redhat.com>
|
|
|
23221e |
Date: Tue Dec 21 09:47:25 2021 -0500
|
|
|
23221e |
|
|
|
23221e |
cgroup: verify that source is a string
|
|
|
23221e |
|
|
|
23221e |
Bugzilla: https://bugzilla.redhat.com/2034608
|
|
|
23221e |
Y-Commit: b6d2fff23b0eee0e82d128f23c4ebd99a30299c3
|
|
|
23221e |
|
|
|
23221e |
O-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2034609
|
|
|
23221e |
|
|
|
23221e |
commit 3b0462726e7ef281c35a7a4ae33e93ee2bc9975b
|
|
|
23221e |
Author: Christian Brauner <christian.brauner@ubuntu.com>
|
|
|
23221e |
Date: Wed, 14 Jul 2021 15:47:49 +0200
|
|
|
23221e |
|
|
|
23221e |
cgroup: verify that source is a string
|
|
|
23221e |
|
|
|
23221e |
The following sequence can be used to trigger a UAF:
|
|
|
23221e |
|
|
|
23221e |
int fscontext_fd = fsopen("cgroup");
|
|
|
23221e |
int fd_null = open("/dev/null, O_RDONLY);
|
|
|
23221e |
int fsconfig(fscontext_fd, FSCONFIG_SET_FD, "source", fd_null);
|
|
|
23221e |
close_range(3, ~0U, 0);
|
|
|
23221e |
|
|
|
23221e |
The cgroup v1 specific fs parser expects a string for the "source"
|
|
|
23221e |
parameter. However, it is perfectly legitimate to e.g. specify a file
|
|
|
23221e |
descriptor for the "source" parameter. The fs parser doesn't know what
|
|
|
23221e |
a filesystem allows there. So it's a bug to assume that "source" is
|
|
|
23221e |
always of type fs_value_is_string when it can reasonably also be
|
|
|
23221e |
fs_value_is_file.
|
|
|
23221e |
|
|
|
23221e |
This assumption in the cgroup code causes a UAF because struct
|
|
|
23221e |
fs_parameter uses a union for the actual value. Access to that union is
|
|
|
23221e |
guarded by the param->type member. Since the cgroup paramter parser
|
|
|
23221e |
didn't check param->type but unconditionally moved param->string into
|
|
|
23221e |
fc->source a close on the fscontext_fd would trigger a UAF during
|
|
|
23221e |
put_fs_context() which frees fc->source thereby freeing the file stashed
|
|
|
23221e |
in param->file causing a UAF during a close of the fd_null.
|
|
|
23221e |
|
|
|
23221e |
Fix this by verifying that param->type is actually a string and report
|
|
|
23221e |
an error if not.
|
|
|
23221e |
|
|
|
23221e |
In follow up patches I'll add a new generic helper that can be used here
|
|
|
23221e |
and by other filesystems instead of this error-prone copy-pasta fix.
|
|
|
23221e |
But fixing it in here first makes backporting a it to stable a lot
|
|
|
23221e |
easier.
|
|
|
23221e |
|
|
|
23221e |
Fixes: 8d2451f4994f ("cgroup1: switch to option-by-option parsing")
|
|
|
23221e |
Reported-by: syzbot+283ce5a46486d6acdbaf@syzkaller.appspotmail.com
|
|
|
23221e |
Cc: Christoph Hellwig <hch@lst.de>
|
|
|
23221e |
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
|
|
|
23221e |
Cc: Dmitry Vyukov <dvyukov@google.com>
|
|
|
23221e |
Cc: <stable@kernel.org>
|
|
|
23221e |
Cc: syzkaller-bugs <syzkaller-bugs@googlegroups.com>
|
|
|
23221e |
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
|
|
|
23221e |
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.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: Artem Savkov <asavkov@redhat.com>
|
|
|
23221e |
---
|
|
|
23221e |
kernel/cgroup/cgroup-v1.c | 2 ++
|
|
|
23221e |
1 file changed, 2 insertions(+)
|
|
|
23221e |
|
|
|
23221e |
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
|
|
|
23221e |
index 852f1349f9d9..291754068ec6 100644
|
|
|
23221e |
--- a/kernel/cgroup/cgroup-v1.c
|
|
|
23221e |
+++ b/kernel/cgroup/cgroup-v1.c
|
|
|
23221e |
@@ -907,6 +907,8 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param)
|
|
|
23221e |
opt = fs_parse(fc, cgroup1_fs_parameters, param, &result);
|
|
|
23221e |
if (opt == -ENOPARAM) {
|
|
|
23221e |
if (strcmp(param->key, "source") == 0) {
|
|
|
23221e |
+ if (param->type != fs_value_is_string)
|
|
|
23221e |
+ return invalf(fc, "Non-string source");
|
|
|
23221e |
if (fc->source)
|
|
|
23221e |
return invalf(fc, "Multiple sources not supported");
|
|
|
23221e |
fc->source = param->string;
|
|
|
23221e |
--
|
|
|
23221e |
2.34.1
|
|
|
23221e |
|
|
|
23221e |
|