In preparation for compat64 handling, move the bpf_check_uarg_tail_zero function call from: syscall.c:bpf_btf_get_info_by_fd -> btf.c:btf_get_info_by_fd
The arguments to bpf_check_uarg_tail_zero() will need to vary depending on whether we're in a compat64 syscall or not. By moving the check to btf.c we can avoid duplication by using the compat64 handling there instead.
Signed-off-by: Zachary Leaf zachary.leaf@arm.com --- kernel/bpf/btf.c | 5 +++++ kernel/bpf/syscall.c | 8 -------- 2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 061a8356abf5..e7dac3c07f08 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -7229,6 +7229,11 @@ int btf_get_info_by_fd(const struct btf *btf, uinfo = u64_to_user_ptr(attr->info.info); uinfo_len = attr->info.info_len;
+ ret = bpf_check_uarg_tail_zero(USER_BPFPTR(uinfo), sizeof(*uinfo), + uinfo_len); + if (ret) + return ret; + info_copy = min_t(u32, uinfo_len, sizeof(info)); memset(&info, 0, sizeof(info)); if (copy_from_user(&info, uinfo, info_copy)) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index bc2046303e08..1daae6f1de9d 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -4289,14 +4289,6 @@ static int bpf_btf_get_info_by_fd(struct file *file, const union bpf_attr *attr, union bpf_attr __user *uattr) { - struct bpf_btf_info __user *uinfo = u64_to_user_ptr(attr->info.info); - u32 info_len = attr->info.info_len; - int err; - - err = bpf_check_uarg_tail_zero(USER_BPFPTR(uinfo), sizeof(*uinfo), info_len); - if (err) - return err; - return btf_get_info_by_fd(btf, attr, uattr); }