Skip to content

Commit ec60e94

Browse files
secDre4merKernel Patches Daemon
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]>
1 parent d8fdeee commit ec60e94

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
@@ -5034,19 +5034,19 @@ static int bpf_prog_get_info_by_fd(struct file *file,
50345034
struct bpf_insn *insns_sanitized;
50355035
bool fault;
50365036

5037-
if (prog->blinded && !bpf_dump_raw_ok(file->f_cred)) {
5037+
if (!prog->blinded || bpf_dump_raw_ok(file->f_cred)) {
5038+
insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred);
5039+
if (!insns_sanitized)
5040+
return -ENOMEM;
5041+
uinsns = u64_to_user_ptr(info.xlated_prog_insns);
5042+
ulen = min_t(u32, info.xlated_prog_len, ulen);
5043+
fault = copy_to_user(uinsns, insns_sanitized, ulen);
5044+
kfree(insns_sanitized);
5045+
if (fault)
5046+
return -EFAULT;
5047+
} else {
50385048
info.xlated_prog_insns = 0;
5039-
goto done;
50405049
}
5041-
insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred);
5042-
if (!insns_sanitized)
5043-
return -ENOMEM;
5044-
uinsns = u64_to_user_ptr(info.xlated_prog_insns);
5045-
ulen = min_t(u32, info.xlated_prog_len, ulen);
5046-
fault = copy_to_user(uinsns, insns_sanitized, ulen);
5047-
kfree(insns_sanitized);
5048-
if (fault)
5049-
return -EFAULT;
50505050
}
50515051

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

0 commit comments

Comments
 (0)