linux-stable/include
Jakub Kicinski 444da3f524 bitfield.h: don't compile-time validate _val in FIELD_FIT
When ur_load_imm_any() is inlined into jeq_imm(), it's possible for the
compiler to deduce a case where _val can only have the value of -1 at
compile time. Specifically,

/* struct bpf_insn: _s32 imm */
u64 imm = insn->imm; /* sign extend */
if (imm >> 32) { /* non-zero only if insn->imm is negative */
  /* inlined from ur_load_imm_any */
  u32 __imm = imm >> 32; /* therefore, always 0xffffffff */
  if (__builtin_constant_p(__imm) && __imm > 255)
    compiletime_assert_XXX()

This can result in tripping a BUILD_BUG_ON() in __BF_FIELD_CHECK() that
checks that a given value is representable in one byte (interpreted as
unsigned).

FIELD_FIT() should return true or false at runtime for whether a value
can fit for not. Don't break the build over a value that's too large for
the mask. We'd prefer to keep the inlining and compiler optimizations
though we know this case will always return false.

Cc: stable@vger.kernel.org
Fixes: 1697599ee3 ("bitfield.h: add FIELD_FIT() helper")
Link: https://lore.kernel.org/kernel-hardening/CAK7LNASvb0UDJ0U5wkYYRzTAdnEs64HjXpEUL7d=V0CXiAXcNw@mail.gmail.com/
Reported-by: Masahiro Yamada <masahiroy@kernel.org>
Debugged-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-08-10 12:16:51 -07:00
..
acpi ACPI updates for 5.9-rc1 2020-08-03 20:37:22 -07:00
asm-generic Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-08-05 20:13:21 -07:00
clocksource
crypto It's been a busy cycle for documentation - hopefully the busiest for a 2020-08-04 22:47:54 -07:00
drm drm next for 5.9-rc1 2020-08-05 19:50:06 -07:00
dt-bindings drm next for 5.9-rc1 2020-08-05 19:50:06 -07:00
keys It's been a busy cycle for documentation - hopefully the busiest for a 2020-08-04 22:47:54 -07:00
kunit
kvm
linux bitfield.h: don't compile-time validate _val in FIELD_FIT 2020-08-10 12:16:51 -07:00
math-emu
media
memory
misc
net tcp: correct read of TFO keys on big endian systems 2020-08-10 12:12:35 -07:00
pcmcia
ras
rdma IB/rdmavt: Fix RQ counting issues causing use of an invalid RWQE 2020-07-29 15:54:36 -03:00
scsi
soc Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-08-05 20:13:21 -07:00
sound ASoC: Fixes for v5.8 2020-07-17 18:19:02 +02:00
target
trace Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-08-05 20:13:21 -07:00
uapi bpf: Change uapi for bpf iterator map elements 2020-08-06 16:39:14 -07:00
vdso arm64/vdso: Add time namespace page 2020-07-24 13:15:20 +01:00
video
xen