Skip to content

Commit 02e935b

Browse files
dhowellsJames Morris
authored andcommitted
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 <[email protected]> Signed-off-by: Matthew Garrett <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: James Morris <[email protected]>
1 parent 906357f commit 02e935b

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

fs/proc/kcore.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/ioport.h>
3232
#include <linux/memory.h>
3333
#include <linux/sched/task.h>
34+
#include <linux/security.h>
3435
#include <asm/sections.h>
3536
#include "internal.h"
3637

@@ -545,6 +546,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
545546

546547
static int open_kcore(struct inode *inode, struct file *filp)
547548
{
549+
int ret = security_locked_down(LOCKDOWN_KCORE);
550+
551+
if (ret)
552+
return ret;
548553
if (!capable(CAP_SYS_RAWIO))
549554
return -EPERM;
550555

include/linux/security.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ enum lockdown_reason {
116116
LOCKDOWN_MODULE_PARAMETERS,
117117
LOCKDOWN_MMIOTRACE,
118118
LOCKDOWN_INTEGRITY_MAX,
119+
LOCKDOWN_KCORE,
119120
LOCKDOWN_CONFIDENTIALITY_MAX,
120121
};
121122

security/lockdown/lockdown.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static char *lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = {
3131
[LOCKDOWN_MODULE_PARAMETERS] = "unsafe module parameters",
3232
[LOCKDOWN_MMIOTRACE] = "unsafe mmio",
3333
[LOCKDOWN_INTEGRITY_MAX] = "integrity",
34+
[LOCKDOWN_KCORE] = "/proc/kcore access",
3435
[LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality",
3536
};
3637

0 commit comments

Comments
 (0)