selftests/bpf: Test indirect var_off stack access in unpriv mode
authorAndrey Ignatov <rdna@fb.com>
Thu, 4 Apr 2019 06:22:40 +0000 (23:22 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 5 Apr 2019 14:50:08 +0000 (16:50 +0200)
commit2c6927dbdc3fbd41207e671212f53a98bbebf6ba
treefead722fca639d9f3aef274e4a207acf3e6faf82
parent088ec26d9c2da9d879ab73e3f4117f9df6c566ee
selftests/bpf: Test indirect var_off stack access in unpriv mode

Test that verifier rejects indirect stack access with variable offset in
unprivileged mode and accepts same code in privileged mode.

Since pointer arithmetics is prohibited in unprivileged mode verifier
should reject the program even before it gets to helper call that uses
variable offset, at the time when that variable offset is trying to be
constructed.

Example of output:
  # ./test_verifier
  ...
  #859/u indirect variable-offset stack access, priv vs unpriv OK
  #859/p indirect variable-offset stack access, priv vs unpriv OK

Signed-off-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/verifier/var_off.c