From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Wang Nan <wangnan0@huawei.com>
Cc: ast@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, lizefan@huawei.com,
pi3orama@163.com
Subject: Re: [PATCH v2] bpf: fix a bug in verification logic when SUB operation taken on FRAME_PTR
Date: Thu, 18 Jun 2015 09:00:19 -0700 [thread overview]
Message-ID: <20150618160018.GA13470@Alexeis-MBP.westell.com> (raw)
In-Reply-To: <1434616305-97746-1-git-send-email-wangnan0@huawei.com>
On Thu, Jun 18, 2015 at 08:31:45AM +0000, Wang Nan wrote:
> Original code has a problem, cause following code failed to pass verifier:
>
> r1 <- r10
> r1 -= 8
> r2 = 8
> r3 = unsafe pointer
> call BPF_FUNC_probe_read <-- R1 type=inv expected=fp
>
> However, by replacing 'r1 -= 8' to 'r1 += -8' the above program can be
> loaded successfully.
>
> This is because the verifier allows only BPF_ADD instruction on a
> FRAME_PTR reigster to forge PTR_TO_STACK register, but makes BPF_SUB
> on FRAME_PTR reigster to get a UNKNOWN_VALUE register.
>
> This patch fix it by adding BPF_SUB in stack_relative checking.
It's not a bug. It's catching ADD only by design.
If we let it recognize SUB then one might argue we should let it
recognize multiply, shifts and all other arithmetic on pointers.
verifier will be getting bigger and bigger. Where do we stop?
llvm only emits canonical ADD. If you've seen llvm doing SUB,
let's fix it there.
So what piece generated this 'r1 -= 8' ?
next prev parent reply other threads:[~2015-06-18 16:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-18 8:12 [PATCH] " Wang Nan
2015-06-18 8:31 ` [PATCH v2] " Wang Nan
2015-06-18 16:00 ` Alexei Starovoitov [this message]
2015-06-19 0:44 ` Wangnan (F)
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=20150618160018.GA13470@Alexeis-MBP.westell.com \
--to=alexei.starovoitov@gmail.com \
--cc=ast@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pi3orama@163.com \
--cc=wangnan0@huawei.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®