lockdown: Lock down /proc/kcore
authorDavid Howells <dhowells@redhat.com>
Tue, 20 Aug 2019 00:17:57 +0000 (17:17 -0700)
committerJames Morris <jmorris@namei.org>
Tue, 20 Aug 2019 04:54:16 +0000 (21:54 -0700)
Disallow access to /proc/kcore when the kernel is locked down to prevent
access to cryptographic data. This is limited to lockdown
confidentiality mode and is still permitted in integrity mode.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Matthew Garrett <mjg59@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: James Morris <jmorris@namei.org>
fs/proc/kcore.c
include/linux/security.h
security/lockdown/lockdown.c

index f5834488b67d564d91b5534c210fc7fcd8e95969..ee2c576cc94ea9a2786c8a774a0c73ead77b1e95 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/ioport.h>
 #include <linux/memory.h>
 #include <linux/sched/task.h>
+#include <linux/security.h>
 #include <asm/sections.h>
 #include "internal.h"
 
@@ -545,6 +546,10 @@ out:
 
 static int open_kcore(struct inode *inode, struct file *filp)
 {
+       int ret = security_locked_down(LOCKDOWN_KCORE);
+
+       if (ret)
+               return ret;
        if (!capable(CAP_SYS_RAWIO))
                return -EPERM;
 
index d8db7ea4c4bfd97ff43d81558de33bd96cb34661..669e8de5299dc1a5b83af33e73884e4e70be02b9 100644 (file)
@@ -116,6 +116,7 @@ enum lockdown_reason {
        LOCKDOWN_MODULE_PARAMETERS,
        LOCKDOWN_MMIOTRACE,
        LOCKDOWN_INTEGRITY_MAX,
+       LOCKDOWN_KCORE,
        LOCKDOWN_CONFIDENTIALITY_MAX,
 };
 
index 2eadbe0667e7a6c910689e16561813fc658d8866..403b30357f75a76560253d6b36bea82cdaf81a82 100644 (file)
@@ -31,6 +31,7 @@ static char *lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = {
        [LOCKDOWN_MODULE_PARAMETERS] = "unsafe module parameters",
        [LOCKDOWN_MMIOTRACE] = "unsafe mmio",
        [LOCKDOWN_INTEGRITY_MAX] = "integrity",
+       [LOCKDOWN_KCORE] = "/proc/kcore access",
        [LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality",
 };