]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
can: annotate mtu accesses with READ_ONCE()
authorVincent Mailhol <mailhol@kernel.org>
Tue, 23 Sep 2025 06:37:08 +0000 (15:37 +0900)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Tue, 23 Sep 2025 08:04:58 +0000 (10:04 +0200)
commitc67732d067860850b767c81736b49f88a946bffb
tree295f7fb0622dac2602415bfb25f007632c4ad0e6
parentc0b595230cc19833f3a3def766a5e9865b80f8fa
can: annotate mtu accesses with READ_ONCE()

As hinted in commit 501a90c94510 ("inet: protect against too small mtu
values."), net_device->mtu is vulnerable to race conditions if it is
written and read without holding the RTNL.

At the moment, all the writes are done while the interface is down,
either in the devices' probe() function or in can_changelink(). So
there are no such issues yet. But upcoming changes will allow to
modify the MTU while the CAN XL devices are up.

In preparation to the introduction of CAN XL, annotate all the
net_device->mtu accesses which are not yet guarded by the RTNL with a
READ_ONCE().

Note that all the write accesses are already either guarded by the
RTNL or are already annotated and thus need no changes.

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
Link: https://patch.msgid.link/20250923-can-fix-mtu-v3-1-581bde113f52@kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
net/can/af_can.c
net/can/isotp.c
net/can/raw.c