netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Self-XORing BPF registers is undefined behavior
@ 2018-12-13 11:00 Alexander Potapenko
  2018-12-13 11:06 ` Eric Dumazet
  2018-12-13 11:59 ` Michal Kubecek
  0 siblings, 2 replies; 26+ messages in thread
From: Alexander Potapenko @ 2018-12-13 11:00 UTC (permalink / raw)
  To: ast, daniel; +Cc: Dmitriy Vyukov, Networking

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.

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2020-06-03 16:33 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-13 11:00 Self-XORing BPF registers is undefined behavior Alexander Potapenko
2018-12-13 11:06 ` Eric Dumazet
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

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).