]> git.itanic.dy.fi Git - linux-stable/commit
can: raw: add missing refcount for memory leak fix
authorOliver Hartkopp <socketcan@hartkopp.net>
Mon, 21 Aug 2023 14:45:47 +0000 (16:45 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Aug 2023 14:18:20 +0000 (16:18 +0200)
commitef56cc8889be5e0d2568f72dcf228f964f8104a7
tree7d442e29d0c2da1d3687486a3aba88bbcdd64579
parent930f3f164964ea823e1fa342d6744d5caec20fd9
can: raw: add missing refcount for memory leak fix

commit c275a176e4b69868576e543409927ae75e3a3288 upstream.

Commit ee8b94c8510c ("can: raw: fix receiver memory leak") introduced
a new reference to the CAN netdevice that has assigned CAN filters.
But this new ro->dev reference did not maintain its own refcount which
lead to another KASAN use-after-free splat found by Eric Dumazet.

This patch ensures a proper refcount for the CAN nedevice.

Fixes: ee8b94c8510c ("can: raw: fix receiver memory leak")
Reported-by: Eric Dumazet <edumazet@google.com>
Cc: Ziyang Xuan <william.xuanziyang@huawei.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://lore.kernel.org/r/20230821144547.6658-3-socketcan@hartkopp.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/can/raw.c