Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Yonghong Song <yhs@fb.com>, bpf <bpf@vger.kernel.org>,
Networking <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 1/2] bpf: permit map_ptr arithmetic with opcode add and offset 0
Date: Mon, 7 Sep 2020 16:21:17 +0200 [thread overview]
Message-ID: <417158cc-4b80-83df-0544-e8e6defb44b4@iogearbox.net> (raw)
In-Reply-To: <CAADnVQJrjPynzVZTDvDh7qosBVFO8+iKEKDbC4=yK+4HVZ6Tng@mail.gmail.com>
On 9/5/20 2:10 AM, Alexei Starovoitov wrote:
> On Fri, Sep 4, 2020 at 5:08 PM Andrii Nakryiko
> <andrii.nakryiko@gmail.com> wrote:
>> On Fri, Sep 4, 2020 at 4:20 PM Yonghong Song <yhs@fb.com> 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;
}
next prev parent reply other threads:[~2020-09-07 14:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 19:49 [PATCH bpf-next 0/2] " Yonghong Song
2020-09-04 19:49 ` [PATCH bpf-next 1/2] " Yonghong Song
2020-09-04 20:30 ` Andrii Nakryiko
2020-09-04 23:20 ` Yonghong Song
2020-09-05 0:08 ` Andrii Nakryiko
2020-09-05 0:10 ` Alexei Starovoitov
2020-09-07 14:21 ` Daniel Borkmann [this message]
2020-09-04 19:49 ` [PATCH bpf-next 2/2] selftests/bpf: add test for map_ptr arithmetic Yonghong Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=417158cc-4b80-83df-0544-e8e6defb44b4@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--cc=yhs@fb.com \
--subject='Re: [PATCH bpf-next 1/2] bpf: permit map_ptr arithmetic with opcode add and offset 0' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).