]> www.infradead.org Git - linux-platform-drivers-x86.git/commitdiff
bpf: Refine retval for bpf_get_task_stack helper
authorDave Marchevsky <davemarchevsky@fb.com>
Fri, 16 Apr 2021 20:47:02 +0000 (13:47 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 20 Apr 2021 01:23:33 +0000 (18:23 -0700)
Verifier can constrain the min/max bounds of bpf_get_task_stack's return
value more tightly than the default tnum_unknown. Like bpf_get_stack,
return value is num bytes written into a caller-supplied buf, or error,
so do_refine_retval_range will work.

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20210416204704.2816874-2-davemarchevsky@fb.com
kernel/bpf/verifier.c

index 994ef36c5f60e4a4ff86d75c3ee70fdc86b5fb20..58730872f7e5e842c4d16cc42b2f5ccf8ae9f754 100644 (file)
@@ -5808,6 +5808,7 @@ static void do_refine_retval_range(struct bpf_reg_state *regs, int ret_type,
 
        if (ret_type != RET_INTEGER ||
            (func_id != BPF_FUNC_get_stack &&
+            func_id != BPF_FUNC_get_task_stack &&
             func_id != BPF_FUNC_probe_read_str &&
             func_id != BPF_FUNC_probe_read_kernel_str &&
             func_id != BPF_FUNC_probe_read_user_str))