linux_dsm_epyc7002/arch
Luke Nelson 489553dd13 riscv, bpf: Fix offset range checking for auipc+jalr on RV64
The existing code in emit_call on RV64 checks that the PC-relative offset
to the function fits in 32 bits before calling emit_jump_and_link to emit
an auipc+jalr pair. However, this check is incorrect because offsets in
the range [2^31 - 2^11, 2^31 - 1] cannot be encoded using auipc+jalr on
RV64 (see discussion [1]). The RISC-V spec has recently been updated
to reflect this fact [2, 3].

This patch fixes the problem by moving the check on the offset into
emit_jump_and_link and modifying it to the correct range of encodable
offsets, which is [-2^31 - 2^11, 2^31 - 2^11). This also enforces the
check on the offset to other uses of emit_jump_and_link (e.g., BPF_JA)
as well.

Currently, this bug is unlikely to be triggered, because the memory
region from which JITed images are allocated is close enough to kernel
text for the offsets to not become too large; and because the bounds on
BPF program size are small enough. This patch prevents this problem from
becoming an issue if either of these change.

[1]: https://groups.google.com/a/groups.riscv.org/forum/#!topic/isa-dev/bwWFhBnnZFQ
[2]: b1e42e09ac
[3]: 4c1b2066eb

Signed-off-by: Luke Nelson <luke.r.nels@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200406221604.18547-1-luke.r.nels@gmail.com
2020-04-08 00:53:41 +02:00
..
alpha Updates for the interrupt subsystem: 2020-03-30 17:35:14 -07:00
arc Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-03-30 16:17:15 -07:00
arm Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-03-31 17:29:33 -07:00
arm64 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-03-31 17:29:33 -07:00
c6x c6x: Replace setup_irq() by request_irq() 2020-03-29 21:03:42 +02:00
csky csky: Remove mm.h from asm/uaccess.h 2020-03-21 16:00:21 +01:00
h8300 Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-01-28 10:07:09 -08:00
hexagon Updates for the interrupt subsystem: 2020-03-30 17:35:14 -07:00
ia64 Couple of cleanup patches 2020-03-31 09:26:06 -07:00
m68k m68k updates for v5.7 2020-03-31 08:49:26 -07:00
microblaze Microblaze patches for 5.7-rc1 2020-03-31 09:58:07 -07:00
mips MIPS updates for v5.7: 2020-03-31 08:51:45 -07:00
nds32 Merge branch 'uaccess.futex' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs into locking/core 2020-03-28 11:59:24 +01:00
nios2 TTY/Serial driver updates for 5.6-rc1 2020-01-29 10:13:27 -08:00
openrisc futex: arch_futex_atomic_op_inuser() calling conventions change 2020-03-27 23:58:51 -04:00
parisc CPU (hotplug) updates: 2020-03-30 18:06:39 -07:00
powerpc Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-03-31 17:29:33 -07:00
riscv riscv, bpf: Fix offset range checking for auipc+jalr on RV64 2020-04-08 00:53:41 +02:00
s390 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-03-31 17:29:33 -07:00
sh Kbuild updates for v5.7 2020-03-31 16:03:39 -07:00
sparc Kbuild updates for v5.7 2020-03-31 16:03:39 -07:00
um um: reject unsupported coalescing params 2020-03-06 22:45:54 -08:00
unicore32 Updates for the interrupt subsystem: 2020-03-30 17:35:14 -07:00
x86 x86: get rid of 'errret' argument to __get_user_xyz() macross 2020-03-31 18:23:47 -07:00
xtensa Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-03-30 16:17:15 -07:00
.gitignore
Kconfig NOHZ full updates: 2020-03-30 18:29:05 -07:00