bpf: Make btf_load command to be bpfptr_t compatible.
Similar to prog_load make btf_load command to be availble to bpf_prog_type_syscall program. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20210514003623.28033-7-alexei.starovoitov@gmail.com
This commit is contained in:
committed by
Daniel Borkmann
parent
00899e7e8d
commit
c571bd752e
@@ -4257,7 +4257,7 @@ static int btf_parse_hdr(struct btf_verifier_env *env)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct btf *btf_parse(void __user *btf_data, u32 btf_data_size,
|
||||
static struct btf *btf_parse(bpfptr_t btf_data, u32 btf_data_size,
|
||||
u32 log_level, char __user *log_ubuf, u32 log_size)
|
||||
{
|
||||
struct btf_verifier_env *env = NULL;
|
||||
@@ -4306,7 +4306,7 @@ static struct btf *btf_parse(void __user *btf_data, u32 btf_data_size,
|
||||
btf->data = data;
|
||||
btf->data_size = btf_data_size;
|
||||
|
||||
if (copy_from_user(data, btf_data, btf_data_size)) {
|
||||
if (copy_from_bpfptr(data, btf_data, btf_data_size)) {
|
||||
err = -EFAULT;
|
||||
goto errout;
|
||||
}
|
||||
@@ -5780,12 +5780,12 @@ static int __btf_new_fd(struct btf *btf)
|
||||
return anon_inode_getfd("btf", &btf_fops, btf, O_RDONLY | O_CLOEXEC);
|
||||
}
|
||||
|
||||
int btf_new_fd(const union bpf_attr *attr)
|
||||
int btf_new_fd(const union bpf_attr *attr, bpfptr_t uattr)
|
||||
{
|
||||
struct btf *btf;
|
||||
int ret;
|
||||
|
||||
btf = btf_parse(u64_to_user_ptr(attr->btf),
|
||||
btf = btf_parse(make_bpfptr(attr->btf, uattr.is_kernel),
|
||||
attr->btf_size, attr->btf_log_level,
|
||||
u64_to_user_ptr(attr->btf_log_buf),
|
||||
attr->btf_log_size);
|
||||
|
||||
Reference in New Issue
Block a user