diff options
author | David Miller <davem@davemloft.net> | 2018-11-30 21:08:14 -0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2018-11-30 21:38:48 -0800 |
commit | e9ee9efc0d176512cdce9d27ff8549d7ffa2bfcd (patch) | |
tree | 94b32bfcaa32c3538810330370ed7cd4b07e15e4 /kernel/bpf/verifier.c | |
parent | 88945f460603ad8909b556c67a9229bb23188d41 (diff) | |
download | linux-e9ee9efc0d176512cdce9d27ff8549d7ffa2bfcd.tar.gz linux-e9ee9efc0d176512cdce9d27ff8549d7ffa2bfcd.tar.bz2 linux-e9ee9efc0d176512cdce9d27ff8549d7ffa2bfcd.zip |
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>
Diffstat (limited to 'kernel/bpf/verifier.c')
-rw-r--r-- | kernel/bpf/verifier.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 9584438fa2cc..71988337ac14 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -6505,6 +6505,8 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, env->strict_alignment = !!(attr->prog_flags & BPF_F_STRICT_ALIGNMENT); if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)) env->strict_alignment = true; + if (attr->prog_flags & BPF_F_ANY_ALIGNMENT) + env->strict_alignment = false; ret = replace_map_fd_with_map_ptr(env); if (ret < 0) |