Skip to content

Commit 4722981

Browse files
secDre4merAlexei Starovoitov
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/efd00fcec5e3e247af551632726e2a90c105fbd8.camel@nextron-systems.com Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 6cc73f3 commit 4722981

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

kernel/bpf/syscall.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5056,19 +5056,19 @@ static int bpf_prog_get_info_by_fd(struct file *file,
50565056
struct bpf_insn *insns_sanitized;
50575057
bool fault;
50585058

5059-
if (prog->blinded && !bpf_dump_raw_ok(file->f_cred)) {
5059+
if (!prog->blinded || bpf_dump_raw_ok(file->f_cred)) {
5060+
insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred);
5061+
if (!insns_sanitized)
5062+
return -ENOMEM;
5063+
uinsns = u64_to_user_ptr(info.xlated_prog_insns);
5064+
ulen = min_t(u32, info.xlated_prog_len, ulen);
5065+
fault = copy_to_user(uinsns, insns_sanitized, ulen);
5066+
kfree(insns_sanitized);
5067+
if (fault)
5068+
return -EFAULT;
5069+
} else {
50605070
info.xlated_prog_insns = 0;
5061-
goto done;
50625071
}
5063-
insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred);
5064-
if (!insns_sanitized)
5065-
return -ENOMEM;
5066-
uinsns = u64_to_user_ptr(info.xlated_prog_insns);
5067-
ulen = min_t(u32, info.xlated_prog_len, ulen);
5068-
fault = copy_to_user(uinsns, insns_sanitized, ulen);
5069-
kfree(insns_sanitized);
5070-
if (fault)
5071-
return -EFAULT;
50725072
}
50735073

50745074
if (bpf_prog_is_offloaded(prog->aux)) {

0 commit comments

Comments
 (0)