android_kernel_xiaomi_sm7250/net/core
Chen Zhongjin b736592de2 net, neigh: Fix null-ptr-deref in neigh_table_clear()
[ Upstream commit f8017317cb0b279b8ab98b0f3901a2e0ac880dad ]

When IPv6 module gets initialized but hits an error in the middle,
kenel panic with:

KASAN: null-ptr-deref in range [0x0000000000000598-0x000000000000059f]
CPU: 1 PID: 361 Comm: insmod
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
RIP: 0010:__neigh_ifdown.isra.0+0x24b/0x370
RSP: 0018:ffff888012677908 EFLAGS: 00000202
...
Call Trace:
 <TASK>
 neigh_table_clear+0x94/0x2d0
 ndisc_cleanup+0x27/0x40 [ipv6]
 inet6_init+0x21c/0x2cb [ipv6]
 do_one_initcall+0xd3/0x4d0
 do_init_module+0x1ae/0x670
...
Kernel panic - not syncing: Fatal exception

When ipv6 initialization fails, it will try to cleanup and calls:

neigh_table_clear()
  neigh_ifdown(tbl, NULL)
    pneigh_queue_purge(&tbl->proxy_queue, dev_net(dev == NULL))
    # dev_net(NULL) triggers null-ptr-deref.

Fix it by passing NULL to pneigh_queue_purge() in neigh_ifdown() if dev
is NULL, to make kernel not panic immediately.

Fixes: 66ba215cb513 ("neigh: fix possible DoS due to net iface start/stop loop")
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Link: https://lore.kernel.org/r/20221101121552.21890-1-chenzhongjin@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-11-10 17:46:53 +01:00
..
datagram.c
dev_addr_lists.c
dev_ioctl.c
dev.c net: Fix a data-race around netdev_budget_usecs. 2022-09-05 10:26:31 +02:00
devlink.c
drop_monitor.c
dst_cache.c
dst.c
ethtool.c
failover.c
fib_notifier.c
fib_rules.c
filter.c seg6: bpf: fix skb checksum in bpf_push_seg6_encap() 2022-07-21 21:09:29 +02:00
flow_dissector.c
gen_estimator.c
gen_stats.c
gro_cells.c
hwbm.c
link_watch.c
lwt_bpf.c
lwtunnel.c
Makefile
neighbour.c net, neigh: Fix null-ptr-deref in neigh_table_clear() 2022-11-10 17:46:53 +01:00
net_namespace.c net: fix UAF issue in nfqnl_nf_hook_drop() when ops_init() failed 2022-11-03 23:52:31 +09:00
net-procfs.c
net-sysfs.c
net-sysfs.h
net-traces.c
netclassid_cgroup.c
netevent.c
netpoll.c
netprio_cgroup.c
page_pool.c
pktgen.c
ptp_classifier.c
request_sock.c
rtnetlink.c
scm.c
secure_seq.c
skbuff.c net: Fix a data-race around sysctl_tstamp_allow_data. 2022-09-05 10:26:30 +02:00
sock_diag.c
sock_reuseport.c
sock.c net: Fix a data-race around sysctl_net_busy_read. 2022-09-05 10:26:31 +02:00
stream.c net: If sock is dead don't access sock's sk_wq in sk_stream_wait_memory 2022-10-26 13:19:38 +02:00
sysctl_net_core.c net: Fix data-races around weight_p and dev_weight_[rt]x_bias. 2022-09-05 10:26:30 +02:00
timestamping.c
tso.c
utils.c
xdp.c