Re: [PATCH bpf] bpf: fix tracking of stack size for var-off access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2023-11-21 at 18:16 +0100, Hao Sun wrote:
[...]
> Yet, the sample direct read would be rejected:
> 
> func#0 @0
> 0: R1=ctx() R10=fp0
> 0: (bf) r6 = r10                      ; R6_w=fp0 R10=fp0
> 1: (61) r7 = *(u32 *)(r6 -200)
> invalid read from stack R6 off=-200 size=4
> 
> Eduard, you added support for reading uninit slots, should we also add something
> like the following:
> 
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 8c2d31aa3d31..aa861d2da240 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -6446,7 +6446,7 @@ static int check_stack_slot_within_bounds(int off,
>  {
>         int min_valid_off;
> 
> -       if (t == BPF_WRITE)
> +       if (t == BPF_WRITE || env->allow_uninit_stack)
>                 min_valid_off = -MAX_BPF_STACK;
>         else
>                 min_valid_off = -state->allocated_stack;

I agree with your logic and this change seems reasonable.
Sorry for delayed response.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux