linux/drivers/net/bonding
Oliver Hartkopp 69b78b5f30 bonding: refuse to enslave CAN devices
[ Upstream commit 8ba68464e4 ]

syzbot reported a kernel paging request crash in
can_rx_unregister() inside net/can/af_can.c. The crash occurs
because a virtual CAN device (vxcan) is being enslaved to a
bonding master.

During the enslavement process, the bonding driver mutates
and modifies the network device states to fit an Ethernet-like
aggregation model. However, CAN devices operate on a completely
different Layer 2 architecture, relying on the CAN mid-layer
private data structure (can_ml_priv) instead of standard
Ethernet structures. Since bonding does not initialize or
maintain these CAN structures, subsequent operations on the
half-enslaved interface (such as closing associated sockets
via isotp_release) lead to a null-pointer dereference when
accessing the CAN receiver lists.

Bonding CAN interfaces is architecturally invalid as CAN lacks
MAC addresses, ARP capabilities, and standard Ethernet
link-layer mechanisms. While generic loopback devices are
blocked globally in net/core/dev.c, virtual CAN devices
bypass this check because they do not carry the IFF_LOOPBACK
flag, despite acting as local software-loopbacks.

Fix this by explicitly blocking network devices of type
ARPHRD_CAN from being enslaved at the very beginning of
bond_enslave(). This prevents illegal state mutations,
eliminates the resulting KASAN crashes, and avoids potential
memory leaks from incomplete socket cleanups.

As the CAN support has been added a long time after bonding
the Fixes-tag points to the introduction of ARPHRD_CAN that
would have needed a specific handling in bonding_main.c.

Fixes: cd05acfe65 ("[CAN]: Allocate protocol numbers for PF_CAN")
Reported-by: syzbot+8ed98cbd0161632bce95@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=8ed98cbd0161632bce95
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Acked-by: Jay Vosburgh <jv@jvosburgh.net>
Link: https://patch.msgid.link/20260526-bonding-candev-v1-1-ba1df400918a@hartkopp.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-06-19 13:33:24 +02:00
..
bond_3ad.c bonding: update LACP activity flag after setting lacp_active 2025-08-28 16:24:38 +02:00
bond_alb.c bonding: return -ENOMEM instead of BUG in alb_upper_dev_walk 2024-02-23 08:54:41 +01:00
bond_debugfs.c net: bonding: fix NULL deref in bond_debug_rlb_hash_show 2026-04-18 10:33:21 +02:00
bond_main.c bonding: refuse to enslave CAN devices 2026-06-19 13:33:24 +02:00
bond_netlink.c bonding: fix send_peer_notif overflow 2023-06-05 09:21:19 +02:00
bond_options.c bonding: update LACP activity flag after setting lacp_active 2025-08-28 16:24:38 +02:00
bond_procfs.c Bonding: add arp_missed_max option 2023-06-05 09:21:19 +02:00
bond_sysfs.c Bonding: add arp_missed_max option 2023-06-05 09:21:19 +02:00
bond_sysfs_slave.c bonding: Fix a use-after-free problem when bond_sysfs_slave_add() failed 2021-11-18 19:17:08 +01:00
bonding_priv.h drivers: Remove inclusion of vermagic header 2020-04-21 13:27:37 -07:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00