[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <253dd595-c850-c09f-2057-641487024fb7@huaweicloud.com>
Date: Sat, 25 Mar 2023 09:57:31 +0800
From: Xu Kuohai <xukuohai@...weicloud.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: bpf <bpf@...r.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
John Fastabend <john.fastabend@...il.com>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>,
Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
Mykola Lysenko <mykolal@...com>, Shuah Khan <shuah@...nel.org>
Subject: Re: [PATCH bpf-next v2 1/2] bpf: add bound tracking for BPF_MOD
On 3/24/2023 1:16 AM, Alexei Starovoitov wrote:
> On Thu, Mar 23, 2023 at 8:59 AM Xu Kuohai <xukuohai@...weicloud.com> wrote:
>>
>> From: Xu Kuohai <xukuohai@...wei.com>
>>
>> dst_reg is marked as unknown when BPF_MOD instruction is verified, causing
>> the following bpf prog to be incorrectly rejected.
>>
>> 0: r0 = 0
>> 1: r0 %= 1 // r0 is marked as unknown
>> 2: r1 = 0
>> 3: r1 += 1
>> 4: if r1 < r0 goto pc-2 // verifier treats the loop as unbounded
>> 5: exit
>>
>> To teach verifier to accept the above prog, this patch adds bound tracking
>> for BPF_MOD.
>>
>> The approach is based on the following rules:
>>
>> 1. BPF_MOD is unsigned;
>>
>> 2. For an unsigned constant divisor x:
>>
>> a. when x != 0, the resulted dst_reg bits are in the range [0, x - 1],
>> and if no wrapping occurs, the result can be further narrowed down
>> to [umin mod x, umax mod x];
>>
>> b. when x == 0, dst_reg is truncated to 32 bits by mod32 or remains
>> unchanged by mod64.
>>
>> Signed-off-by: Xu Kuohai <xukuohai@...wei.com>
>
> Same Nack as before.
Sorry, I did not receive Nack for this patch before.
> You haven't answered _why_ anyone needs it.
No idea, I simply believe it's good to have a closer estimate of the result.
Powered by blists - more mailing lists