mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-01-16 06:31:46 +00:00
e07b98d9bf
Add a new field, "prog_flags", and an initial flag value BPF_F_STRICT_ALIGNMENT. When set, the verifier will enforce strict pointer alignment regardless of the setting of CONFIG_EFFICIENT_UNALIGNED_ACCESS. The verifier, in this mode, will also use a fixed value of "2" in place of NET_IP_ALIGN. This facilitates test cases that will exercise and validate this part of the verifier even when run on architectures where alignment doesn't matter. Signed-off-by: David S. Miller <davem@davemloft.net> Acked-by: Daniel Borkmann <daniel@iogearbox.net>
40 lines
815 B
C
40 lines
815 B
C
#include <asm/unistd.h>
|
|
#include <linux/bpf.h>
|
|
#include <unistd.h>
|
|
|
|
#ifndef __NR_bpf
|
|
# if defined(__i386__)
|
|
# define __NR_bpf 357
|
|
# elif defined(__x86_64__)
|
|
# define __NR_bpf 321
|
|
# elif defined(__aarch64__)
|
|
# define __NR_bpf 280
|
|
# elif defined(__sparc__)
|
|
# define __NR_bpf 349
|
|
# else
|
|
# error __NR_bpf not defined. libbpf does not support your arch.
|
|
# endif
|
|
#endif
|
|
|
|
int main(void)
|
|
{
|
|
union bpf_attr attr;
|
|
|
|
/* Check fields in attr */
|
|
attr.prog_type = BPF_PROG_TYPE_KPROBE;
|
|
attr.insn_cnt = 0;
|
|
attr.insns = 0;
|
|
attr.license = 0;
|
|
attr.log_buf = 0;
|
|
attr.log_size = 0;
|
|
attr.log_level = 0;
|
|
attr.kern_version = 0;
|
|
attr.prog_flags = 0;
|
|
|
|
/*
|
|
* Test existence of __NR_bpf and BPF_PROG_LOAD.
|
|
* This call should fail if we run the testcase.
|
|
*/
|
|
return syscall(__NR_bpf, BPF_PROG_LOAD, &attr, sizeof(attr));
|
|
}
|