bpf, samples: Use bpf_probe_read_user where appropriate
Use bpf_probe_read_user() helper instead of bpf_probe_read() for samples that attach to kprobes probing on user addresses. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/5b0144b3f8e031ec5e2438bd7de8d7877e63bf2f.1572649915.git.daniel@iogearbox.net
This commit is contained in:
parent
6e07a63412
commit
251e2d337a
|
@ -181,8 +181,8 @@ int stress_lru_hmap_alloc(struct pt_regs *ctx)
|
||||||
if (addrlen != sizeof(*in6))
|
if (addrlen != sizeof(*in6))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = bpf_probe_read(test_params.dst6, sizeof(test_params.dst6),
|
ret = bpf_probe_read_user(test_params.dst6, sizeof(test_params.dst6),
|
||||||
&in6->sin6_addr);
|
&in6->sin6_addr);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ int trace_sys_connect(struct pt_regs *ctx)
|
||||||
if (addrlen != sizeof(*in6))
|
if (addrlen != sizeof(*in6))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = bpf_probe_read(dst6, sizeof(dst6), &in6->sin6_addr);
|
ret = bpf_probe_read_user(dst6, sizeof(dst6), &in6->sin6_addr);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
inline_ret = ret;
|
inline_ret = ret;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -129,7 +129,7 @@ int trace_sys_connect(struct pt_regs *ctx)
|
||||||
|
|
||||||
test_case = dst6[7];
|
test_case = dst6[7];
|
||||||
|
|
||||||
ret = bpf_probe_read(&port, sizeof(port), &in6->sin6_port);
|
ret = bpf_probe_read_user(&port, sizeof(port), &in6->sin6_port);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
inline_ret = ret;
|
inline_ret = ret;
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
@ -37,7 +37,7 @@ int bpf_prog1(struct pt_regs *ctx)
|
||||||
if (sockaddr_len > sizeof(orig_addr))
|
if (sockaddr_len > sizeof(orig_addr))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (bpf_probe_read(&orig_addr, sizeof(orig_addr), sockaddr_arg) != 0)
|
if (bpf_probe_read_user(&orig_addr, sizeof(orig_addr), sockaddr_arg) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
mapped_addr = bpf_map_lookup_elem(&dnat_map, &orig_addr);
|
mapped_addr = bpf_map_lookup_elem(&dnat_map, &orig_addr);
|
||||||
|
|
Loading…
Reference in New Issue