Skip to content

Commit a94549d

Browse files
dhowellsxjamesmorris
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 <alexei.starovoitov@gmail.com> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Matthew Garrett <mjg59@google.com> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Cc: Naveen N. Rao <naveen.n.rao@linux.ibm.com> Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Cc: davem@davemloft.net Cc: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: James Morris <jmorris@namei.org>
1 parent 02e935b commit a94549d

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎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)