]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
can: statistics: use atomic access in hot path
authorOliver Hartkopp <socketcan@hartkopp.net>
Mon, 10 Mar 2025 14:33:53 +0000 (15:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:37:38 +0000 (14:37 +0200)
commit68adc6f17a366a3acd68aa510cb83bc183e733c4
tree128e43934295a8f186f9e051a86e6356ce5ba4ec
parent2a435a8cb8910bba2a0eda6f23ed978f5e73de03
can: statistics: use atomic access in hot path

[ Upstream commit 80b5f90158d1364cbd80ad82852a757fc0692bf2 ]

In can_send() and can_receive() CAN messages and CAN filter matches are
counted to be visible in the CAN procfs files.

KCSAN detected a data race within can_send() when two CAN frames have
been generated by a timer event writing to the same CAN netdevice at the
same time. Use atomic operations to access the statistics in the hot path
to fix the KCSAN complaint.

Reported-by: syzbot+78ce4489b812515d5e4d@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/67cd717d.050a0220.e1a89.0006.GAE@google.com
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://patch.msgid.link/20250310143353.3242-1-socketcan@hartkopp.net
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/can/af_can.c
net/can/af_can.h
net/can/proc.c