kernel_samsung_a53x/tools
Jose E. Marchesi 4487ec2968 bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD
[ Upstream commit 009367099eb61a4fc2af44d4eb06b6b4de7de6db ]

[Changes from V1:
 - Use a default branch in the switch statement to initialize `val'.]

GCC warns that `val' may be used uninitialized in the
BPF_CRE_READ_BITFIELD macro, defined in bpf_core_read.h as:

	[...]
	unsigned long long val;						      \
	[...]								      \
	switch (__CORE_RELO(s, field, BYTE_SIZE)) {			      \
	case 1: val = *(const unsigned char *)p; break;			      \
	case 2: val = *(const unsigned short *)p; break;		      \
	case 4: val = *(const unsigned int *)p; break;			      \
	case 8: val = *(const unsigned long long *)p; break;		      \
        }       							      \
	[...]
	val;								      \
	}								      \

This patch adds a default entry in the switch statement that sets
`val' to zero in order to avoid the warning, and random values to be
used in case __builtin_preserve_field_info returns unexpected values
for BPF_FIELD_BYTE_SIZE.

Tested in bpf-next master.
No regressions.

Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240508101313.16662-1-jose.marchesi@oracle.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 14:19:41 +01:00
..
accounting Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arch x86/insn: Fix PUSH instruction in x86 instruction decoder opcode map 2024-11-19 12:26:59 +01:00
bootconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bpf bpf: Fix potential integer overflow in resolve_btfids 2024-11-19 12:27:10 +01:00
build Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cgroup Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
crypto Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugging Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
edid Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
firewire Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
firmware Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gpio Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hv Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
iio tools: iio: replace seekdir() in iio_generic_buffer 2024-11-19 09:23:15 +01:00
include hugetlb_encode.h: fix undefined behaviour (34 << 26) 2024-11-19 14:19:05 +01:00
io_uring Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm/kvm_stat Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
laptop Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lib bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD 2024-11-19 14:19:41 +01:00
memory-model Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
objtool exit: Rename module_put_and_exit to module_put_and_kthread_exit 2024-11-19 12:27:50 +01:00
pci Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pcmcia Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
perf perf stat: Avoid metric-only segv 2024-11-19 08:44:53 +01:00
power tools/power turbostat: Fix Bzy_MHz documentation typo 2024-11-19 11:32:44 +01:00
scripts Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
spi Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
testing kselftest: arm64: Add a null pointer check 2024-11-19 14:19:06 +01:00
thermal/tmon Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
time Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
usb Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
virtio Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vm Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wmi Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00