bpf, testing: Add selftest to read/write sockaddr from user space
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 1 Nov 2019 23:18:03 +0000 (00:18 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 2 Nov 2019 19:45:08 +0000 (12:45 -0700)
commitfa553d9b57d4a98a160d1926b4e263e7a78c0cf3
tree59237fefc66616b1656f1ade555b2365e8d89d88
parent50f9aa44cac7256551b2e0901831e432a6c52b7f
bpf, testing: Add selftest to read/write sockaddr from user space

Tested on x86-64 and Ilya was also kind enough to give it a spin on
s390x, both passing with probe_user:OK there. The test is using the
newly added bpf_probe_read_user() to dump sockaddr from connect call
into .bss BPF map and overrides the user buffer via bpf_probe_write_user():

  # ./test_progs
  [...]
  #17 pkt_md_access:OK
  #18 probe_user:OK
  #19 prog_run_xattr:OK
  [...]

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/90f449d8af25354e05080e82fc6e2d3179da30ea.1572649915.git.daniel@iogearbox.net
tools/testing/selftests/bpf/prog_tests/probe_user.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_probe_user.c [new file with mode: 0644]