mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
bpf: don't skip other information if xlated_prog_insns is skipped
If xlated_prog_insns should not be exposed, other information (such as func_info) still can and should be filled in. Therefore, instead of directly terminating in this case, continue with the normal flow. Signed-off-by: Max Altgelt <max.altgelt@nextron-systems.com> Link: https://lore.kernel.org/r/efd00fcec5e3e247af551632726e2a90c105fbd8.camel@nextron-systems.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Alexei Starovoitov
parent
6cc73f3540
commit
4722981cca
@@ -5056,19 +5056,19 @@ static int bpf_prog_get_info_by_fd(struct file *file,
|
||||
struct bpf_insn *insns_sanitized;
|
||||
bool fault;
|
||||
|
||||
if (prog->blinded && !bpf_dump_raw_ok(file->f_cred)) {
|
||||
if (!prog->blinded || bpf_dump_raw_ok(file->f_cred)) {
|
||||
insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred);
|
||||
if (!insns_sanitized)
|
||||
return -ENOMEM;
|
||||
uinsns = u64_to_user_ptr(info.xlated_prog_insns);
|
||||
ulen = min_t(u32, info.xlated_prog_len, ulen);
|
||||
fault = copy_to_user(uinsns, insns_sanitized, ulen);
|
||||
kfree(insns_sanitized);
|
||||
if (fault)
|
||||
return -EFAULT;
|
||||
} else {
|
||||
info.xlated_prog_insns = 0;
|
||||
goto done;
|
||||
}
|
||||
insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred);
|
||||
if (!insns_sanitized)
|
||||
return -ENOMEM;
|
||||
uinsns = u64_to_user_ptr(info.xlated_prog_insns);
|
||||
ulen = min_t(u32, info.xlated_prog_len, ulen);
|
||||
fault = copy_to_user(uinsns, insns_sanitized, ulen);
|
||||
kfree(insns_sanitized);
|
||||
if (fault)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (bpf_prog_is_offloaded(prog->aux)) {
|
||||
|
||||
Reference in New Issue
Block a user