]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: add a test for device cgroup controller
authorRoman Gushchin <guro@fb.com>
Sun, 5 Nov 2017 13:15:34 +0000 (08:15 -0500)
committerDavid S. Miller <davem@davemloft.net>
Sun, 5 Nov 2017 14:26:51 +0000 (23:26 +0900)
commit6205110ada29325d0ee8ad1577b76b2eb17bd2f5
treea6b3aebc786eeb512dfde7d6bae130cc136ede4b
parent33fe098febc201ac647613e1bed3c05e82ace8db
selftests/bpf: add a test for device cgroup controller

Add a test for device cgroup controller.

The test loads a simple bpf program which logs all
device access attempts using trace_printk() and forbids
all operations except operations with /dev/zero and
/dev/urandom.

Then the test creates and joins a test cgroup, and attaches
the bpf program to it.

Then it tries to perform some simple device operations
and checks the result:

  create /dev/null (should fail)
  create /dev/zero (should pass)
  copy data from /dev/urandom to /dev/zero (should pass)
  copy data from /dev/urandom to /dev/full (should fail)
  copy data from /dev/random to /dev/zero (should fail)

Signed-off-by: Roman Gushchin <guro@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/bpf/dev_cgroup.c [new file with mode: 0644]
tools/testing/selftests/bpf/test_dev_cgroup.c [new file with mode: 0644]