summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Wellving <andreas.wellving@enea.com>2019-01-25 16:16:10 +0100
committerAdrian Mangeac <Adrian.Mangeac@enea.com>2019-02-01 16:23:59 +0100
commitc1c186fd627f69cb4c02c5f4f3b6bf3d1b65fcde (patch)
treefaba3679e391e7119dc3970a402a496c1eb939f1
parent5dd4ff4afafddef0d56795990f9190d19326bac7 (diff)
downloadenea-kernel-cache-c1c186fd627f69cb4c02c5f4f3b6bf3d1b65fcde.tar.gz
proc: CVE-2018-17972
proc: restrict kernel stack dumps to root References: https://nvd.nist.gov/vuln/detail/CVE-2018-17972 https://marc.info/?l=linux-fsdevel&m=153806242024956&w=2 Change-Id: I20b7879d32e4485e92e4952be90cbb71bd7acfdb Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
-rw-r--r--patches/cve/4.14.x.scc2
-rw-r--r--patches/cve/CVE-2018-17972-proc-restrict-kernel-stack-dumps-to-root.patch79
2 files changed, 81 insertions, 0 deletions
diff --git a/patches/cve/4.14.x.scc b/patches/cve/4.14.x.scc
index 78e3e2d..26e55cf 100644
--- a/patches/cve/4.14.x.scc
+++ b/patches/cve/4.14.x.scc
@@ -2,3 +2,5 @@
2patch CVE-2018-13099-f2fs-fix-to-do-sanity-check-with-reserved-blkaddr-of.patch 2patch CVE-2018-13099-f2fs-fix-to-do-sanity-check-with-reserved-blkaddr-of.patch
3#CVEs fixed in 4.14.73: 3#CVEs fixed in 4.14.73:
4patch CVE-2018-14633-scsi-target-iscsi-Use-hex2bin-instead-of-a-re-implem.patch 4patch CVE-2018-14633-scsi-target-iscsi-Use-hex2bin-instead-of-a-re-implem.patch
5#CVEs fixed in 4.14.75:
6patch CVE-2018-17972-proc-restrict-kernel-stack-dumps-to-root.patch
diff --git a/patches/cve/CVE-2018-17972-proc-restrict-kernel-stack-dumps-to-root.patch b/patches/cve/CVE-2018-17972-proc-restrict-kernel-stack-dumps-to-root.patch
new file mode 100644
index 0000000..9daec53
--- /dev/null
+++ b/patches/cve/CVE-2018-17972-proc-restrict-kernel-stack-dumps-to-root.patch
@@ -0,0 +1,79 @@
1From f8566a92ab75d442a823453414c6158b0b3c5ce7 Mon Sep 17 00:00:00 2001
2From: Jann Horn <jannh@google.com>
3Date: Fri, 5 Oct 2018 15:51:58 -0700
4Subject: [PATCH] proc: restrict kernel stack dumps to root
5
6commit f8a00cef17206ecd1b30d3d9f99e10d9fa707aa7 upstream.
7
8Currently, you can use /proc/self/task/*/stack to cause a stack walk on
9a task you control while it is running on another CPU. That means that
10the stack can change under the stack walker. The stack walker does
11have guards against going completely off the rails and into random
12kernel memory, but it can interpret random data from your kernel stack
13as instruction pointers and stack pointers. This can cause exposure of
14kernel stack contents to userspace.
15
16Restrict the ability to inspect kernel stacks of arbitrary tasks to root
17in order to prevent a local attacker from exploiting racy stack unwinding
18to leak kernel task stack contents. See the added comment for a longer
19rationale.
20
21There don't seem to be any users of this userspace API that can't
22gracefully bail out if reading from the file fails. Therefore, I believe
23that this change is unlikely to break things. In the case that this patch
24does end up needing a revert, the next-best solution might be to fake a
25single-entry stack based on wchan.
26
27CVE: CVE-2018-17972
28Upstream-Status: Backport
29
30Link: http://lkml.kernel.org/r/20180927153316.200286-1-jannh@google.com
31Fixes: 2ec220e27f50 ("proc: add /proc/*/stack")
32Signed-off-by: Jann Horn <jannh@google.com>
33Acked-by: Kees Cook <keescook@chromium.org>
34Cc: Alexey Dobriyan <adobriyan@gmail.com>
35Cc: Ken Chen <kenchen@google.com>
36Cc: Will Deacon <will.deacon@arm.com>
37Cc: Laura Abbott <labbott@redhat.com>
38Cc: Andy Lutomirski <luto@amacapital.net>
39Cc: Catalin Marinas <catalin.marinas@arm.com>
40Cc: Josh Poimboeuf <jpoimboe@redhat.com>
41Cc: Thomas Gleixner <tglx@linutronix.de>
42Cc: Ingo Molnar <mingo@redhat.com>
43Cc: "H . Peter Anvin" <hpa@zytor.com>
44Cc: <stable@vger.kernel.org>
45Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
46Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
47Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
48---
49 fs/proc/base.c | 14 ++++++++++++++
50 1 file changed, 14 insertions(+)
51
52diff --git a/fs/proc/base.c b/fs/proc/base.c
53index c5c42f3e33d1..9063738ff1f0 100644
54--- a/fs/proc/base.c
55+++ b/fs/proc/base.c
56@@ -431,6 +431,20 @@ static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns,
57 int err;
58 int i;
59
60+ /*
61+ * The ability to racily run the kernel stack unwinder on a running task
62+ * and then observe the unwinder output is scary; while it is useful for
63+ * debugging kernel issues, it can also allow an attacker to leak kernel
64+ * stack contents.
65+ * Doing this in a manner that is at least safe from races would require
66+ * some work to ensure that the remote task can not be scheduled; and
67+ * even then, this would still expose the unwinder as local attack
68+ * surface.
69+ * Therefore, this interface is restricted to root.
70+ */
71+ if (!file_ns_capable(m->file, &init_user_ns, CAP_SYS_ADMIN))
72+ return -EACCES;
73+
74 entries = kmalloc(MAX_STACK_TRACE_DEPTH * sizeof(*entries), GFP_KERNEL);
75 if (!entries)
76 return -ENOMEM;
77--
782.19.2
79