linux-stable/include
Andrei Matei 01f810ace9 bpf: Allow variable-offset stack access
Before this patch, variable offset access to the stack was dissalowed
for regular instructions, but was allowed for "indirect" accesses (i.e.
helpers). This patch removes the restriction, allowing reading and
writing to the stack through stack pointers with variable offsets. This
makes stack-allocated buffers more usable in programs, and brings stack
pointers closer to other types of pointers.

The motivation is being able to use stack-allocated buffers for data
manipulation. When the stack size limit is sufficient, allocating
buffers on the stack is simpler than per-cpu arrays, or other
alternatives.

In unpriviledged programs, variable-offset reads and writes are
disallowed (they were already disallowed for the indirect access case)
because the speculative execution checking code doesn't support them.
Additionally, when writing through a variable-offset stack pointer, if
any pointers are in the accessible range, there's possilibities of later
leaking pointers because the write cannot be tracked precisely.

Writes with variable offset mark the whole range as initialized, even
though we don't know which stack slots are actually written. This is in
order to not reject future reads to these slots. Note that this doesn't
affect writes done through helpers; like before, helpers need the whole
stack range to be initialized to begin with.
All the stack slots are in range are considered scalars after the write;
variable-offset register spills are not tracked.

For reads, all the stack slots in the variable range needs to be
initialized (but see above about what writes do), otherwise the read is
rejected. All register spilled in stack slots that might be read are
marked as having been read, however reads through such pointers don't do
register filling; the target register will always be either a scalar or
a constant zero.

Signed-off-by: Andrei Matei <andreimatei1@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210207011027.676572-2-andreimatei1@gmail.com
2021-02-10 10:44:19 -08:00
..
acpi More power management updates for 5.11-rc1 2020-12-22 14:12:10 -08:00
asm-generic arm64: make atomic helpers __always_inline 2021-01-13 15:09:06 +00:00
clocksource
crypto
drm
dt-bindings The core framework got some nice improvements this time around. We gained the 2020-12-21 10:39:37 -08:00
keys
kunit
kvm KVM: arm64: Replace KVM_ARM_PMU with HW_PERF_EVENTS 2021-01-04 16:50:16 +00:00
linux bpf: Allow variable-offset stack access 2021-02-10 10:44:19 -08:00
math-emu
media
memory
misc
net net, veth: Alloc skb in bulk for ndo_xdp_xmit 2021-02-04 01:00:07 +01:00
pcmcia
ras
rdma
scsi
soc net: mscc: ocelot: configure watermarks using devlink-sb 2021-01-15 20:02:35 -08:00
sound
target
trace trace: bpf: Allow bpf to attach to bare tracepoints 2021-01-20 14:13:59 -08:00
uapi bonding: add a vlan+srcmac tx hashing option 2021-01-19 19:30:32 -08:00
vdso
video
xen xen: Fix event channel callback via INTX/GSI 2021-01-13 16:12:00 +01:00