Re: [PATCH bpf-next 1/2] bpf: permit map_ptr arithmetic with opcode add and offset 0

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

 



On 9/5/20 2:10 AM, Alexei Starovoitov wrote:
On Fri, Sep 4, 2020 at 5:08 PM Andrii Nakryiko
<andrii.nakryiko@xxxxxxxxx> wrote:
On Fri, Sep 4, 2020 at 4:20 PM Yonghong Song <yhs@xxxxxx> wrote:
[...]
for scalar constant, reg->var_off.mask should be 0. so we will have
reg->smin_value = reg->smax_value = (s64)reg->var_off.value.

The smin_val is also used below, e.g., BPF_ADD, for a known value.
That is why I am using smin_val here.

Will add a comment and submit v2.

it would be way-way more obvious (and reliable in the long run,
probably) if you just used (known && reg->var_off.value == 0). or just
tnum_equals_const(reg->var_off, 0)?

Pls dont. smin_val == 0 is a standard way to do this.
Just check all other places in this function and everywhere else.

Also, we taint the reg earlier in that function if its known and min != max:

        if ((known && (smin_val != smax_val || umin_val != umax_val)) ||
            smin_val > smax_val || umin_val > umax_val) {
                /* Taint dst register if offset had invalid bounds derived from
                 * e.g. dead branches.
                 */
                __mark_reg_unknown(env, dst_reg);
                return 0;
        }



[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