Skip to content

Commit eb1b668

Browse files
borkmannAlexei Starovoitov
authored and
Alexei Starovoitov
committed
bpf: Make use of probe_user_write in probe write helper
Convert the bpf_probe_write_user() helper to probe_user_write() such that writes are not attempted under KERNEL_DS anymore which is buggy as kernel and user space pointers can have overlapping addresses. Also, given we have the access_ok() check inside probe_user_write(), the helper doesn't need to do it twice. Fixes: 96ae522 ("bpf: Add bpf_probe_write_user BPF helper to be called in tracers") Signed-off-by: Daniel Borkmann <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/841c461781874c07a0ee404a454c3bc0459eed30.1572649915.git.daniel@iogearbox.net
1 parent 75a1a60 commit eb1b668

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

kernel/trace/bpf_trace.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static const struct bpf_func_proto bpf_probe_read_proto = {
163163
.arg3_type = ARG_ANYTHING,
164164
};
165165

166-
BPF_CALL_3(bpf_probe_write_user, void *, unsafe_ptr, const void *, src,
166+
BPF_CALL_3(bpf_probe_write_user, void __user *, unsafe_ptr, const void *, src,
167167
u32, size)
168168
{
169169
/*
@@ -186,10 +186,8 @@ BPF_CALL_3(bpf_probe_write_user, void *, unsafe_ptr, const void *, src,
186186
return -EPERM;
187187
if (unlikely(!nmi_uaccess_okay()))
188188
return -EPERM;
189-
if (!access_ok(unsafe_ptr, size))
190-
return -EPERM;
191189

192-
return probe_kernel_write(unsafe_ptr, src, size);
190+
return probe_user_write(unsafe_ptr, src, size);
193191
}
194192

195193
static const struct bpf_func_proto bpf_probe_write_user_proto = {

0 commit comments

Comments
 (0)