diff options
Diffstat (limited to 'kernel/trace/bpf_trace.c')
-rw-r--r-- | kernel/trace/bpf_trace.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index d64c00afceb5..94b0e37d90ef 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c | |||
@@ -14,6 +14,8 @@ | |||
14 | #include <linux/syscalls.h> | 14 | #include <linux/syscalls.h> |
15 | #include <linux/error-injection.h> | 15 | #include <linux/error-injection.h> |
16 | 16 | ||
17 | #include <asm/tlb.h> | ||
18 | |||
17 | #include "trace_probe.h" | 19 | #include "trace_probe.h" |
18 | #include "trace.h" | 20 | #include "trace.h" |
19 | 21 | ||
@@ -163,6 +165,10 @@ BPF_CALL_3(bpf_probe_write_user, void *, unsafe_ptr, const void *, src, | |||
163 | * access_ok() should prevent writing to non-user memory, but in | 165 | * access_ok() should prevent writing to non-user memory, but in |
164 | * some situations (nommu, temporary switch, etc) access_ok() does | 166 | * some situations (nommu, temporary switch, etc) access_ok() does |
165 | * not provide enough validation, hence the check on KERNEL_DS. | 167 | * not provide enough validation, hence the check on KERNEL_DS. |
168 | * | ||
169 | * nmi_uaccess_okay() ensures the probe is not run in an interim | ||
170 | * state, when the task or mm are switched. This is specifically | ||
171 | * required to prevent the use of temporary mm. | ||
166 | */ | 172 | */ |
167 | 173 | ||
168 | if (unlikely(in_interrupt() || | 174 | if (unlikely(in_interrupt() || |
@@ -170,6 +176,8 @@ BPF_CALL_3(bpf_probe_write_user, void *, unsafe_ptr, const void *, src, | |||
170 | return -EPERM; | 176 | return -EPERM; |
171 | if (unlikely(uaccess_kernel())) | 177 | if (unlikely(uaccess_kernel())) |
172 | return -EPERM; | 178 | return -EPERM; |
179 | if (unlikely(!nmi_uaccess_okay())) | ||
180 | return -EPERM; | ||
173 | if (!access_ok(unsafe_ptr, size)) | 181 | if (!access_ok(unsafe_ptr, size)) |
174 | return -EPERM; | 182 | return -EPERM; |
175 | 183 | ||