anolis-cloud-kernel/net/can
Thadeu Lima de Souza Cascardo bf499aa9dc can: bcm: delay release of struct bcm_op after synchronize_rcu()
OpenAnolis Bug Tracker: 0000368

commit d5f9023fa6 upstream.

can_rx_register() callbacks may be called concurrently to the call to
can_rx_unregister(). The callbacks and callback data, though, are
protected by RCU and the struct sock reference count.

So the callback data is really attached to the life of sk, meaning
that it should be released on sk_destruct. However, bcm_remove_op()
calls tasklet_kill(), and RCU callbacks may be called under RCU
softirq, so that cannot be used on kernels before the introduction of
HRTIMER_MODE_SOFT.

However, bcm_rx_handler() is called under RCU protection, so after
calling can_rx_unregister(), we may call synchronize_rcu() in order to
wait for any RCU read-side critical sections to finish. That is,
bcm_rx_handler() won't be called anymore for those ops. So, we only
free them, after we do that synchronize_rcu().

Fixes: ffd980f976 ("[CAN]: Add broadcast manager (bcm) protocol")
Link: https://lore.kernel.org/r/20210619161813.2098382-1-cascardo@canonical.com
Cc: linux-stable <stable@vger.kernel.org>
Reported-by: syzbot+0f7e7e5e2f4f40fa89c0@syzkaller.appspotmail.com
Reported-by: Norbert Slusarek <nslusarek@gmx.net>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Fixes: CVE-2021-3609
Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com>
Reviewed-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Acked-by: Shanpei Chen <shanpeic@linux.alibaba.com>
2021-11-12 17:43:28 +08:00
..
Kconfig can: migrate documentation to restructured text 2018-01-26 10:46:44 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
af_can.c can: af_can: Fix error path of can_init() 2019-07-14 08:11:07 +02:00
af_can.h can: af_can: give struct holding the CAN per device receive lists a sensible name 2018-01-05 11:12:08 +01:00
bcm.c can: bcm: delay release of struct bcm_op after synchronize_rcu() 2021-11-12 17:43:28 +08:00
gw.c can: gw: Fix error path of cgw_module_init 2019-08-29 08:28:30 +02:00
proc.c proc: introduce proc_create_net_single 2018-05-16 07:24:30 +02:00
raw.c can: raw: check for CAN FD capable netdev in raw_sendmsg() 2018-12-01 09:37:30 +01:00