android_kernel_xiaomi_sm8450/net/hsr
Sebastian Andrzej Siewior 13f6937f53 hsr: Avoid double remove of a node.
[ Upstream commit 0c74d9f79ec4299365bbe803baa736ae0068179e ]

Due to the hashed-MAC optimisation one problem become visible:
hsr_handle_sup_frame() walks over the list of available nodes and merges
two node entries into one if based on the information in the supervision
both MAC addresses belong to one node. The list-walk happens on a RCU
protected list and delete operation happens under a lock.

If the supervision arrives on both slave interfaces at the same time
then this delete operation can occur simultaneously on two CPUs. The
result is the first-CPU deletes the from the list and the second CPUs
BUGs while attempting to dereference a poisoned list-entry. This happens
more likely with the optimisation because a new node for the mac_B entry
is created once a packet has been received and removed (merged) once the
supervision frame has been received.

Avoid removing/ cleaning up a hsr_node twice by adding a `removed' field
which is set to true after the removal and checked before the removal.

Fixes: f266a683a4 ("net/hsr: Better frame dispatch")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-01 13:16:46 +01:00
..
hsr_debugfs.c net: hsr: Convert to DEFINE_SHOW_ATTRIBUTE 2020-09-17 17:05:10 -07:00
hsr_device.c net: hsr: remove WARN_ONCE() in send_hsr_supervision_frame() 2024-02-23 08:42:26 +01:00
hsr_device.h hsr: enhance netlink socket interface to support PRP 2020-07-27 12:20:40 -07:00
hsr_forward.c hsr: Prevent use after free in prp_create_tagged_frame() 2023-11-20 11:06:55 +01:00
hsr_forward.h net: hsr: fix mac_len checks 2021-06-03 09:00:50 +02:00
hsr_framereg.c hsr: Avoid double remove of a node. 2024-03-01 13:16:46 +01:00
hsr_framereg.h hsr: Avoid double remove of a node. 2024-03-01 13:16:46 +01:00
hsr_main.c hsr: enhance netlink socket interface to support PRP 2020-07-27 12:20:40 -07:00
hsr_main.h net: hsr: fix mac_len checks 2021-06-03 09:00:50 +02:00
hsr_netlink.c genetlink: move to smaller ops wherever possible 2020-10-02 19:11:11 -07:00
hsr_netlink.h hsr: enhance netlink socket interface to support PRP 2020-07-27 12:20:40 -07:00
hsr_slave.c net: hsr: fix mac_len checks 2021-06-03 09:00:50 +02:00
hsr_slave.h net: prp: add packet handling support 2020-07-27 12:20:40 -07:00
Kconfig hsr: enhance netlink socket interface to support PRP 2020-07-27 12:20:40 -07:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00