From: Eric Dumazet <eric.dumazet@gmail.com>
To: Alexander Potapenko <glider@google.com>,
ast@kernel.org, daniel@iogearbox.net
Cc: Dmitriy Vyukov <dvyukov@google.com>, Networking <netdev@vger.kernel.org>
Subject: Re: Self-XORing BPF registers is undefined behavior
Date: Thu, 13 Dec 2018 03:06:30 -0800 [thread overview]
Message-ID: <4cdabfb9-afe6-3180-28c9-60507dcdc55e@gmail.com> (raw)
In-Reply-To: <CAG_fn=W55uuPbpvjzCphgiMbmhnFmmWY=KcOGvmUv14_JOGc5g@mail.gmail.com>
On 12/13/2018 03:00 AM, Alexander Potapenko wrote:
> Hi BPF maintainers,
>
> some time ago KMSAN found an issue in BPF code which we decided to
> suppress at that point, but now I'd like to bring it to your
> attention.
> Namely, some BPF programs may contain instructions that XOR a register
> with itself.
> This effectively results in the following C code:
> regs[BPF_REG_A] = regs[BPF_REG_A] ^ regs[BPF_REG_A];
> or
> regs[BPF_REG_X] = regs[BPF_REG_X] ^ regs[BPF_REG_X];
> being executed.
>
> According to the C11 standard this is undefined behavior, so KMSAN
> reports an error in this case.
eBPF is not C11 ;)
XOR boolean operation on a cpu is following boolean logic, which is much stronger than
any C standard.
>
> Do you think it's feasible to explicitly initialize the register
> values like it's done here:
> https://github.com/google/kmsan/commit/813c0f3d45ebfa321d70b4b06cc054518dd1d90d
> ?
>
> Thanks,
> Alexander Potapenko
> Software Engineer
>
> Google Germany GmbH
> Erika-Mann-Straße, 33
> 80636 München
>
> Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
> Registergericht und -nummer: Hamburg, HRB 86891
> Sitz der Gesellschaft: Hamburg
>
next prev parent reply other threads:[~2018-12-13 11:06 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-13 11:00 Self-XORing BPF registers is undefined behavior Alexander Potapenko
2018-12-13 11:06 ` Eric Dumazet [this message]
2018-12-13 11:23 ` Alexander Potapenko
2018-12-13 11:59 ` Michal Kubecek
2018-12-13 12:20 ` Michal Kubecek
2018-12-13 12:24 ` Alexander Potapenko
2018-12-13 13:18 ` Daniel Borkmann
2018-12-13 14:54 ` Daniel Borkmann
2018-12-18 14:36 ` Alexander Potapenko
2020-05-27 15:52 ` Alexander Potapenko
2020-05-27 16:58 ` Alexei Starovoitov
2020-05-27 17:12 ` Alexander Potapenko
2020-05-27 17:14 ` Alexei Starovoitov
2020-05-28 9:54 ` Alexander Potapenko
2020-05-28 16:00 ` Alexei Starovoitov
2020-05-29 0:17 ` Edward Cree
2020-05-29 6:14 ` Dmitry Vyukov
2020-05-29 8:46 ` Edward Cree
2020-05-29 8:53 ` Dmitry Vyukov
2020-05-29 12:28 ` Alexander Potapenko
2020-06-01 9:55 ` Edward Cree
2020-06-02 13:31 ` Alexander Potapenko
2020-06-02 17:32 ` Alexei Starovoitov
2020-06-03 15:37 ` Edward Cree
2020-06-03 16:33 ` Alexander Potapenko
2018-12-18 14:09 ` Alexander Potapenko
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=4cdabfb9-afe6-3180-28c9-60507dcdc55e@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--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).