]> git.baikalelectronics.ru Git - kernel.git/commit
can: isotp: prevent race between isotp_bind() and isotp_setsockopt()
authorNorbert Slusarek <nslusarek@gmx.net>
Tue, 11 May 2021 22:43:54 +0000 (00:43 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 12 May 2021 06:52:47 +0000 (08:52 +0200)
commitc8b1291d33e28533d86cd4506c9741d36853ecd9
tree9698aa0e13520c2f97bc508c37a19a98906f751b
parent86e2e903ced75a5e50e68027f7b1eec1b1f0a9c3
can: isotp: prevent race between isotp_bind() and isotp_setsockopt()

A race condition was found in isotp_setsockopt() which allows to
change socket options after the socket was bound.
For the specific case of SF_BROADCAST support, this might lead to possible
use-after-free because can_rx_unregister() is not called.

Checking for the flag under the socket lock in isotp_bind() and taking
the lock in isotp_setsockopt() fixes the issue.

Fixes: f9575758e4b8 ("can: isotp: add SF_BROADCAST support for functional addressing")
Link: https://lore.kernel.org/r/trinity-e6ae9efa-9afb-4326-84c0-f3609b9b8168-1620773528307@3c-app-gmx-bs06
Reported-by: Norbert Slusarek <nslusarek@gmx.net>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Norbert Slusarek <nslusarek@gmx.net>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
net/can/isotp.c