aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-08-19 20:17:57 -0400
committerJames Morris <jmorris@namei.org>2019-08-20 00:54:16 -0400
commit02e935bf5b34edcc4cb0dc532dd0e1a1bfb33b51 (patch)
treed1029d3f5dccd6dbba74b1d0b445fa2b5ee4ffb4
parent906357f77a077508d160e729f917c5f0a4304f25 (diff)
lockdown: Lock down /proc/kcore
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>
-rw-r--r--fs/proc/kcore.c5
-rw-r--r--include/linux/security.h1
-rw-r--r--security/lockdown/lockdown.c1
3 files changed, 7 insertions, 0 deletions
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index f5834488b67d..ee2c576cc94e 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -31,6 +31,7 @@
31#include <linux/ioport.h> 31#include <linux/ioport.h>
32#include <linux/memory.h> 32#include <linux/memory.h>
33#include <linux/sched/task.h> 33#include <linux/sched/task.h>
34#include <linux/security.h>
34#include <asm/sections.h> 35#include <asm/sections.h>
35#include "internal.h" 36#include "internal.h"
36 37
@@ -545,6 +546,10 @@ out:
545 546
546static int open_kcore(struct inode *inode, struct file *filp) 547static int open_kcore(struct inode *inode, struct file *filp)
547{ 548{
549 int ret = security_locked_down(LOCKDOWN_KCORE);
550
551 if (ret)
552 return ret;
548 if (!capable(CAP_SYS_RAWIO)) 553 if (!capable(CAP_SYS_RAWIO))
549 return -EPERM; 554 return -EPERM;
550 555
diff --git a/include/linux/security.h b/include/linux/security.h
index d8db7ea4c4bf..669e8de5299d 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -116,6 +116,7 @@ enum lockdown_reason {
116 LOCKDOWN_MODULE_PARAMETERS, 116 LOCKDOWN_MODULE_PARAMETERS,
117 LOCKDOWN_MMIOTRACE, 117 LOCKDOWN_MMIOTRACE,
118 LOCKDOWN_INTEGRITY_MAX, 118 LOCKDOWN_INTEGRITY_MAX,
119 LOCKDOWN_KCORE,
119 LOCKDOWN_CONFIDENTIALITY_MAX, 120 LOCKDOWN_CONFIDENTIALITY_MAX,
120}; 121};
121 122
diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c
index 2eadbe0667e7..403b30357f75 100644
--- a/security/lockdown/lockdown.c
+++ b/security/lockdown/lockdown.c
@@ -31,6 +31,7 @@ static char *lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = {
31 [LOCKDOWN_MODULE_PARAMETERS] = "unsafe module parameters", 31 [LOCKDOWN_MODULE_PARAMETERS] = "unsafe module parameters",
32 [LOCKDOWN_MMIOTRACE] = "unsafe mmio", 32 [LOCKDOWN_MMIOTRACE] = "unsafe mmio",
33 [LOCKDOWN_INTEGRITY_MAX] = "integrity", 33 [LOCKDOWN_INTEGRITY_MAX] = "integrity",
34 [LOCKDOWN_KCORE] = "/proc/kcore access",
34 [LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality", 35 [LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality",
35}; 36};
36 37