Skip to content

Commit a94549d

Browse files
dhowellsJames Morris
authored andcommitted
lockdown: Lock down tracing and perf kprobes when in confidentiality mode
Disallow the creation of perf and ftrace kprobes when the kernel is locked down in confidentiality mode by preventing their registration. This prevents kprobes from being used to access kernel memory to steal crypto data, but continues to allow the use of kprobes from signed modules. Reported-by: Alexei Starovoitov <[email protected]> Signed-off-by: David Howells <[email protected]> Signed-off-by: Matthew Garrett <[email protected]> Acked-by: Masami Hiramatsu <[email protected]> Reviewed-by: Kees Cook <[email protected]> Cc: Naveen N. Rao <[email protected]> Cc: Anil S Keshavamurthy <[email protected]> Cc: [email protected] Cc: Masami Hiramatsu <[email protected]> Signed-off-by: James Morris <[email protected]>
1 parent 02e935b commit a94549d

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

include/linux/security.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ enum lockdown_reason {
117117
LOCKDOWN_MMIOTRACE,
118118
LOCKDOWN_INTEGRITY_MAX,
119119
LOCKDOWN_KCORE,
120+
LOCKDOWN_KPROBES,
120121
LOCKDOWN_CONFIDENTIALITY_MAX,
121122
};
122123

kernel/trace/trace_kprobe.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/uaccess.h>
1212
#include <linux/rculist.h>
1313
#include <linux/error-injection.h>
14+
#include <linux/security.h>
1415

1516
#include "trace_dynevent.h"
1617
#include "trace_kprobe_selftest.h"
@@ -415,6 +416,10 @@ static int __register_trace_kprobe(struct trace_kprobe *tk)
415416
{
416417
int i, ret;
417418

419+
ret = security_locked_down(LOCKDOWN_KPROBES);
420+
if (ret)
421+
return ret;
422+
418423
if (trace_probe_is_registered(&tk->tp))
419424
return -EINVAL;
420425

security/lockdown/lockdown.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static char *lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = {
3232
[LOCKDOWN_MMIOTRACE] = "unsafe mmio",
3333
[LOCKDOWN_INTEGRITY_MAX] = "integrity",
3434
[LOCKDOWN_KCORE] = "/proc/kcore access",
35+
[LOCKDOWN_KPROBES] = "use of kprobes",
3536
[LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality",
3637
};
3738

0 commit comments

Comments
 (0)