linux-uconsole/drivers/net/netdevsim
Haimin Zhang 1a34fb9e2b netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_alloc
[ Upstream commit 481221775d ]

Zero-initialize memory for new map's value in function nsim_bpf_map_alloc
since it may cause a potential kernel information leak issue, as follows:
1. nsim_bpf_map_alloc calls nsim_map_alloc_elem to allocate elements for
a new map.
2. nsim_map_alloc_elem uses kmalloc to allocate map's value, but doesn't
zero it.
3. A user application can use IOCTL BPF_MAP_LOOKUP_ELEM to get specific
element's information in the map.
4. The kernel function map_lookup_elem will call bpf_map_copy_value to get
the information allocated at step-2, then use copy_to_user to copy to the
user buffer.
This can only leak information for an array map.

Fixes: 395cacb5f1 ("netdevsim: bpf: support fake map offload")
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Haimin Zhang <tcs.kernel@gmail.com>
Link: https://lore.kernel.org/r/20211215111530.72103-1-tcs.kernel@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-12-22 09:30:55 +01:00
..
bpf.c netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_alloc 2021-12-22 09:30:55 +01:00
bus.c
dev.c netdevsim: dev: Initialize FIB module after debugfs 2021-04-07 15:00:07 +02:00
ethtool.c netdevsim: fix duplicated debugfs directory 2020-09-26 14:19:08 -07:00
fib.c
health.c netdevsim: set .owner to THIS_MODULE 2020-11-17 14:08:59 -08:00
ipsec.c net: netdevsim: use xso.real_dev instead of xso.dev in callback functions of struct xfrmdev_ops 2021-07-25 14:36:19 +02:00
Makefile netdevsim: add pause frame stats 2020-09-15 13:26:28 -07:00
netdev.c netdevsim: init u64 stats for 32bit hardware 2021-03-17 17:06:15 +01:00
netdevsim.h netdevsim: Add debugfs toggle to reject BPF programs in verifier 2020-12-09 16:27:42 +01:00
udp_tunnels.c netdevsim: set .owner to THIS_MODULE 2020-11-17 14:08:59 -08:00