From: Daniel Borkmann <dborkman@redhat.com>
To: Alexei Starovoitov <ast@plumgrid.com>
Cc: David Miller <davem@davemloft.net>,
Network Development <netdev@vger.kernel.org>
Subject: Re: [PATCH net] net: filter: initialize A and X registers
Date: Wed, 23 Apr 2014 09:02:54 +0200 [thread overview]
Message-ID: <5357659E.1070807@redhat.com> (raw)
In-Reply-To: <CAMEtUux=mOyZkfxMWi3eA01TvmJrfJpeBpGcHvheptcckA=dzQ@mail.gmail.com>
On 04/23/2014 06:59 AM, Alexei Starovoitov wrote:
> On Tue, Apr 22, 2014 at 8:57 PM, David Miller <davem@davemloft.net> wrote:
>> From: Alexei Starovoitov <ast@plumgrid.com>
>> Date: Tue, 22 Apr 2014 20:18:57 -0700
>>
>>> exisiting BPF verifier allows uninitialized access to registers,
>>> 'ret A' is considered to be a valid filter.
>>> So initialize A and X to zero to prevent leaking kernel memory
>>> In the future BPF verifier will be rejecting such filters
>>>
>>> Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
>>
>> Has the code always been like this?
I think it would be much cleaner to just prevent such filters that
only contain a 'ret A', or 'ret X' w/o a load into X from attaching.
By that, we would need to do slightly more work on the verifier
side (which seemed to allow such cases since ever), but therefore
can spare us the extra work in fast path.
Only 'ret A' doesn't make sense, and similarly a program that never
loads anything into X, but wants to return it. We already did a
similar thing for the scratch memory store where we checked stores
into M[] and loads from M[] into A. I can take a look if you want ...
I have some pending BPF cleanups anyway from before the merge window.
> the previous interpreter had:
> unsigned int sk_run_filter(const struct sk_buff *skb,
> const struct sock_filter *fentry)
> {
> void *ptr;
> u32 A = 0; /* Accumulator */
> u32 X = 0; /* Index Register */
> ...
> so it wasn't affected.
>
>> Did the eBPF changes introduce this problem either directly or
>> indirectly?
>
> this bug is an oversight on my side.
> I believe in the net-next it should be fixed by making verifier smarter
> instead of wasting run time cycles to initialize regs.
> For now the same fix is needed for both net and net-next.
> We can remove extra assignments when verifier becomes smarter.
> ebpf verifier that I posted earlier had checks for uninitialized regs and stack.
> I missed lack of uninit regs part in classic verifier when ebpf verifier and jit
> were dropped from the patch set.
> Sorry about this slip.
next prev parent reply other threads:[~2014-04-23 7:03 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-23 3:18 [PATCH net] net: filter: initialize A and X registers Alexei Starovoitov
2014-04-23 3:57 ` David Miller
2014-04-23 4:59 ` Alexei Starovoitov
2014-04-23 7:02 ` Daniel Borkmann [this message]
2014-04-23 16:52 ` David Miller
2014-04-23 17:20 ` Daniel Borkmann
2014-04-23 16:50 ` David Miller
2014-04-23 20:38 ` Alexei Starovoitov
2014-04-23 21:39 ` Eric Dumazet
2014-04-23 22:19 ` Alexei Starovoitov
2014-04-24 2:55 ` Eric Dumazet
2014-04-24 3:22 ` Alexei Starovoitov
2014-04-25 8:23 ` Daniel Borkmann
2014-04-24 7:07 ` Martin Schwidefsky
2014-04-23 5:13 ` Eric Dumazet
2014-04-23 11:45 ` Daniel Borkmann
2014-04-23 13:39 ` Eric Dumazet
2014-04-23 21:07 ` David Miller
2014-04-23 16:51 ` David Miller
2014-04-23 17:10 ` Daniel Borkmann
2014-04-23 17:14 ` Eric Dumazet
2014-04-24 17:24 ` David Miller
2014-04-24 18:11 ` Eric Dumazet
2014-04-24 22:18 ` Daniel Borkmann
2014-04-23 7:53 ` Daniel Borkmann
2014-04-23 16:13 ` Alexei Starovoitov
2014-04-23 19:35 ` David Miller
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=5357659E.1070807@redhat.com \
--to=dborkman@redhat.com \
--cc=ast@plumgrid.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).