linux/net/can
Oliver Hartkopp 42b7a7c962 can: gw: fix RCU/BH usage in cgw_create_job()
[ Upstream commit 511e64e13d ]

As reported by Sebastian Andrzej Siewior the use of local_bh_disable()
is only feasible in uni processor systems to update the modification rules.
The usual use-case to update the modification rules is to update the data
of the modifications but not the modification types (AND/OR/XOR/SET) or
the checksum functions itself.

To omit additional memory allocations to maintain fast modification
switching times, the modification description space is doubled at gw-job
creation time so that only the reference to the active modification
description is changed under rcu protection.

Rename cgw_job::mod to cf_mod and make it a RCU pointer. Allocate in
cgw_create_job() and free it together with cgw_job in
cgw_job_free_rcu(). Update all users to dereference cgw_job::cf_mod with
a RCU accessor and if possible once.

[bigeasy: Replace mod1/mod2 from the Oliver's original patch with dynamic
allocation, use RCU annotation and accessor]

Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Closes: https://lore.kernel.org/linux-can/20231031112349.y0aLoBrz@linutronix.de/
Fixes: dd895d7f21 ("can: cangw: introduce optional uid to reference created routing jobs")
Tested-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://patch.msgid.link/20250429070555.cs-7b_eZ@linutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-05-18 08:24:05 +02:00
..
j1939 can: j1939: j1939_sk_send_loop(): fix unable to send messages with data length zero 2025-02-21 13:57:16 +01:00
af_can.c can: statistics: use atomic access in hot path 2025-04-10 14:37:38 +02:00
af_can.h can: statistics: use atomic access in hot path 2025-04-10 14:37:38 +02:00
bcm.c can: bcm: Clear bo->bcm_proc_read after remove_proc_entry(). 2024-10-04 16:28:58 +02:00
gw.c can: gw: fix RCU/BH usage in cgw_create_job() 2025-05-18 08:24:05 +02:00
isotp.c can: isotp: isotp_sendmsg(): fix TX state detection and wait behavior 2023-10-06 12:54:33 +02:00
Kconfig net: Kconfig: move the CAN device menu to the "Device Drivers" section 2022-06-11 17:11:02 +02:00
Makefile can: add ISO 15765-2:2016 transport protocol 2020-10-07 23:18:33 +02:00
proc.c can: statistics: use atomic access in hot path 2025-04-10 14:37:38 +02:00
raw.c can: raw: add missing refcount for memory leak fix 2023-08-22 17:18:50 -07:00