OSDN Git Service

bpf: Add BPF_F_ANY_ALIGNMENT.
authorDavid Miller <davem@davemloft.net>
Sat, 1 Dec 2018 05:08:14 +0000 (21:08 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 1 Dec 2018 05:38:48 +0000 (21:38 -0800)
commite9ee9efc0d176512cdce9d27ff8549d7ffa2bfcd
tree94b32bfcaa32c3538810330370ed7cd4b07e15e4
parent88945f460603ad8909b556c67a9229bb23188d41
bpf: Add BPF_F_ANY_ALIGNMENT.

Often we want to write tests cases that check things like bad context
offset accesses.  And one way to do this is to use an odd offset on,
for example, a 32-bit load.

This unfortunately triggers the alignment checks first on platforms
that do not set CONFIG_EFFICIENT_UNALIGNED_ACCESS.  So the test
case see the alignment failure rather than what it was testing for.

It is often not completely possible to respect the original intention
of the test, or even test the same exact thing, while solving the
alignment issue.

Another option could have been to check the alignment after the
context and other validations are performed by the verifier, but
that is a non-trivial change to the verifier.

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/uapi/linux/bpf.h
kernel/bpf/syscall.c
kernel/bpf/verifier.c
tools/include/uapi/linux/bpf.h
tools/lib/bpf/bpf.c
tools/lib/bpf/bpf.h
tools/testing/selftests/bpf/test_align.c
tools/testing/selftests/bpf/test_verifier.c