mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-07 17:19:07 +08:00
bpf: Disallow bpf programs call prog_run command.
The verifier cannot perform sufficient validation of bpf_attr->test.ctx_in pointer, therefore bpf programs should not be allowed to call BPF_PROG_RUN command from within the program. To fix this issue split bpf_sys_bpf() bpf helper into normal kern_sys_bpf() kernel function that can only be used by the kernel light skeleton directly. Reported-by: YiFei Zhu <zhuyifei@google.com> Fixes: b1d18a7574d0 ("bpf: Extend sys_bpf commands for bpf_syscall programs.") Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Andrii Nakryiko
parent
45dca19bd2
commit
6fdbfb00f1
@@ -66,13 +66,13 @@ struct bpf_load_and_run_opts {
|
|||||||
const char *errstr;
|
const char *errstr;
|
||||||
};
|
};
|
||||||
|
|
||||||
long bpf_sys_bpf(__u32 cmd, void *attr, __u32 attr_size);
|
long kern_sys_bpf(__u32 cmd, void *attr, __u32 attr_size);
|
||||||
|
|
||||||
static inline int skel_sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,
|
static inline int skel_sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
return bpf_sys_bpf(cmd, attr, size);
|
return kern_sys_bpf(cmd, attr, size);
|
||||||
#else
|
#else
|
||||||
return syscall(__NR_bpf, cmd, attr, size);
|
return syscall(__NR_bpf, cmd, attr, size);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user