From nobody Mon Dec 1 22:07:31 2025 Received: from mail-gw02.astralinux.ru (mail-gw02.astralinux.ru [93.188.205.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DFD3303CAB; Fri, 28 Nov 2025 13:21:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.188.205.243 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764336108; cv=none; b=D2RKC+1LdeXxSdsX5srTMns+LI5C7xVWRPCJvuKoEhFf9IsmKELE5hgNAFVFxxnDHPYu6yga9OcnxY9zDzNdwABS9jeB9kLW63UlAdlSnXxdlskowZIprlKtAETo8+jsKFlXJ7vsd3zQQ5iD3dGopa0oXuF+Za1DNde0OovFHEk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764336108; c=relaxed/simple; bh=5MwlDraxyNlmirgOdWC70LRDoKS3QWroy32Zqswic8U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eImCTwoVZhnkx+6vBBsEwCYE/VHYfMTDzd3YzSZLnaD/mwCGA2GTbuyrJB2J/DFAD8zUDmypOEjKy3USxJoq1REcE7Fel24ysi8yJcXwgFXCKWwSGzO6giO0h5B2uFXM1wNJ8BXtrSm+14NAutmzZTTp+HachvuDeiq6W6Sz10g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=astralinux.ru; spf=pass smtp.mailfrom=astralinux.ru; dkim=pass (2048-bit key) header.d=astralinux.ru header.i=@astralinux.ru header.b=iEYthXr7; arc=none smtp.client-ip=93.188.205.243 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=astralinux.ru header.i=@astralinux.ru header.b="iEYthXr7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=astralinux.ru; s=mail; t=1764336104; bh=5MwlDraxyNlmirgOdWC70LRDoKS3QWroy32Zqswic8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iEYthXr7hVGMu+POu20QmNfAEi2+D9lQlGw7v7yUlMbAIGGNccmYyeawHbaMQyXkE cJyxFOOG9W3xxx3wu73mU2hcfqrWYVPYhBWi2b1/VRWLjOvoDsADzOdesdLI6PbCer uadrtGrNgbozczLXHRaBo5M4ILvfc/FdfpfpHlrC1AieO3RSb+6lJ2oqnP9q2Qpu+E n2QVWd7+PdLGifT5MJZpBlGPWx0Y/HS3Z+VU1OT2ErqufexJLkriaq8O4P9F4ZZG6A yWLtmIxh0LBglWgPosj+O9+iUHFJxbb6TP2wVbOYqqoSJadMYh1IgjPfVioc9mT/O2 XmLsE6SNX0R7w== Received: from gca-msk-a-srv-ksmg01 (localhost [127.0.0.1]) by mail-gw02.astralinux.ru (Postfix) with ESMTP id 3922F1F9C1; Fri, 28 Nov 2025 16:21:44 +0300 (MSK) Received: from new-mail.astralinux.ru (unknown [10.205.207.13]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-gw02.astralinux.ru (Postfix) with ESMTPS; Fri, 28 Nov 2025 16:21:43 +0300 (MSK) Received: from rbta-msk-lt-156703.astralinux.ru.astracloud.ru (rbta-msk-lt-156703.astralinux.ru [10.198.57.41]) by new-mail.astralinux.ru (Postfix) with ESMTPA id 4dHv8M5RpRzJqN0; Fri, 28 Nov 2025 16:21:39 +0300 (MSK) From: Alexey Panov To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Alexey Panov , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Jakub Kicinski , Moni Shoua , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Nikolay Aleksandrov , bpf@vger.kernel.org, lvc-project@linuxtesting.org, Nikolay Aleksandrov Subject: [PATCH 5.10 v3 1/3] bonding: restore IFF_MASTER/SLAVE flags on bond enslave ether type change Date: Fri, 28 Nov 2025 16:21:24 +0300 Message-Id: <20251128132126.7467-2-apanov@astralinux.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20251128132126.7467-1-apanov@astralinux.ru> References: <20251128132126.7467-1-apanov@astralinux.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Envelope-From: apanov@astralinux.ru X-KSMG-AntiSpam-Info: LuaCore: 81 0.3.81 2adfceff315e7344370a427642ad41a4cfd99e1f, {Tracking_uf_ne_domains}, {Tracking_from_domain_doesnt_match_to}, {Tracking_spam_in_reply_from_match_msgid}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;astralinux.ru:7.1.1;new-mail.astralinux.ru:7.1.1;127.0.0.199:7.1.2, FromAlignment: s X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiSpam-Lua-Profiles: 198520 [Nov 28 2025] X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Version: 6.1.1.20 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/11/28 12:43:00 #27986045 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: NotDetected X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 Content-Type: text/plain; charset="utf-8" From: Nikolay Aleksandrov [ Upstream commit 9ec7eb60dcbcb6c41076defbc5df7bbd95ceaba5 ] Add bond_ether_setup helper which is used to fix ether_setup() calls in the bonding driver. It takes care of both IFF_MASTER and IFF_SLAVE flags, the former is always restored and the latter only if it was set. If the bond enslaves non-ARPHRD_ETHER device (changes its type), then releases it and enslaves ARPHRD_ETHER device (changes back) then we use ether_setup() to restore the bond device type but it also resets its flags and removes IFF_MASTER and IFF_SLAVE[1]. Use the bond_ether_setup helper to restore both after such transition. [1] reproduce (nlmon is non-ARPHRD_ETHER): $ ip l add nlmon0 type nlmon $ ip l add bond2 type bond mode active-backup $ ip l set nlmon0 master bond2 $ ip l set nlmon0 nomaster $ ip l add bond1 type bond (we use bond1 as ARPHRD_ETHER device to restore bond2's mode) $ ip l set bond1 master bond2 $ ip l sh dev bond2 37: bond2: mtu 1500 qdisc noop state DOWN mode DEFAU= LT group default qlen 1000 link/ether be:d7:c5:40:5b:cc brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu= 68 maxmtu 1500 (notice bond2's IFF_MASTER is missing) Fixes: e36b9d16c6a6 ("bonding: clean muticast addresses when device changes= type") Signed-off-by: Nikolay Aleksandrov Signed-off-by: David S. Miller Signed-off-by: Alexey Panov --- drivers/net/bonding/bond_main.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_mai= n.c index 08bc930afc4c..127242101c8e 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1691,6 +1691,19 @@ void bond_lower_state_changed(struct slave *slave) netdev_lower_state_changed(slave->dev, &info); } =20 +/* The bonding driver uses ether_setup() to convert a master bond device + * to ARPHRD_ETHER, that resets the target netdevice's flags so we always + * have to restore the IFF_MASTER flag, and only restore IFF_SLAVE if it w= as set + */ +static void bond_ether_setup(struct net_device *bond_dev) +{ + unsigned int slave_flag =3D bond_dev->flags & IFF_SLAVE; + + ether_setup(bond_dev); + bond_dev->flags |=3D IFF_MASTER | slave_flag; + bond_dev->priv_flags &=3D ~IFF_TX_SKB_SHARING; +} + /* enslave device to bond device */ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, struct netlink_ext_ack *extack) @@ -1777,10 +1790,8 @@ int bond_enslave(struct net_device *bond_dev, struct= net_device *slave_dev, =20 if (slave_dev->type !=3D ARPHRD_ETHER) bond_setup_by_slave(bond_dev, slave_dev); - else { - ether_setup(bond_dev); - bond_dev->priv_flags &=3D ~IFF_TX_SKB_SHARING; - } + else + bond_ether_setup(bond_dev); =20 call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, bond_dev); --=20 2.30.2 From nobody Mon Dec 1 22:07:31 2025 Received: from mail-gw02.astralinux.ru (mail-gw02.astralinux.ru [93.188.205.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C06428E0F; Fri, 28 Nov 2025 13:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.188.205.243 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764336143; cv=none; b=RUaV/4FmWTomQB7V4tONHLm1xUD5bDe75CVY/MklMPHxWJP4ASVyD9275iAnab/4bYwHyiSMkXQsV8masmIXC2gI7Y6yrZhXzeEeWRfgTz6n22xbe4NvCIuDuPGkHB9iux44IuzDPL/pCc/MDzqJRQjeYK5/ClU/SGsp+Ajdffk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764336143; c=relaxed/simple; bh=6g7T2l9HW0KB/0B3LjK4bBlF1RgsQst32tmCQPSoqZw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sM1Tj5Db3ZmTkdsyQSVcv2xXSHUvzZ8YzLcFlXB77LcZyPLy3fcWbHi4ws6vyOZ21SZO0oelG/tpcKw02Dy1P7aABAQyso/u1TFCxNKS+M27hCdfOztw/D/9S5phdo+RaK12858c/6vKWe1LtlJ3ZIQVkZKn+FiFM3qhQXTiCEk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=astralinux.ru; spf=pass smtp.mailfrom=astralinux.ru; dkim=pass (2048-bit key) header.d=astralinux.ru header.i=@astralinux.ru header.b=u/EiK5o3; arc=none smtp.client-ip=93.188.205.243 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=astralinux.ru header.i=@astralinux.ru header.b="u/EiK5o3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=astralinux.ru; s=mail; t=1764336138; bh=6g7T2l9HW0KB/0B3LjK4bBlF1RgsQst32tmCQPSoqZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u/EiK5o3CWQ/bY0Qrc/YjWslG2XbXlayk7yhFBd9XoqM7Ybzu0aDMWTErTdqVSL8y MfXJ4ErcDAkmOSct3TOxDZ7LTGS1e9QRRewLt+NIV3H4AgIr4JvedL3JKUcDOvh7f0 VQgH1nQDt1BDv604Xcw6kk7CX3y+iIyMIf04pvNXnABGr9q2Slm7/RrPE9MBQ+0QDc ki4V+te0DXYq5rQJ+qzum/tzyjY5lzgm+jBBJK7CrGbK49Q15GfrfYPoagCwwc3iCN HQRFkA+DOOZz65j9kUnU9M4SxHxYL/zQoJQgcPQpHT/hSm5w+c+zftMiE9VPJM0bYT ihU+65/V4zHVg== Received: from gca-msk-a-srv-ksmg01 (localhost [127.0.0.1]) by mail-gw02.astralinux.ru (Postfix) with ESMTP id D8C711F745; Fri, 28 Nov 2025 16:22:18 +0300 (MSK) Received: from new-mail.astralinux.ru (unknown [10.205.207.13]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-gw02.astralinux.ru (Postfix) with ESMTPS; Fri, 28 Nov 2025 16:22:16 +0300 (MSK) Received: from rbta-msk-lt-156703.astralinux.ru.astracloud.ru (rbta-msk-lt-156703.astralinux.ru [10.198.57.41]) by new-mail.astralinux.ru (Postfix) with ESMTPA id 4dHv8R2wm9zJqN4; Fri, 28 Nov 2025 16:21:43 +0300 (MSK) From: Alexey Panov To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Alexey Panov , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Jakub Kicinski , Moni Shoua , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Nikolay Aleksandrov , bpf@vger.kernel.org, lvc-project@linuxtesting.org, Mirsad Goran Todorovac , Ido Schimmel , Jay Vosburgh Subject: [PATCH 5.10 v3 2/3] bonding: Fix memory leak when changing bond type to Ethernet Date: Fri, 28 Nov 2025 16:21:25 +0300 Message-Id: <20251128132126.7467-3-apanov@astralinux.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20251128132126.7467-1-apanov@astralinux.ru> References: <20251128132126.7467-1-apanov@astralinux.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-KSMG-AntiPhishing: NotDetected, bases: 2025/11/28 10:15:00 X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Envelope-From: apanov@astralinux.ru X-KSMG-AntiSpam-Info: LuaCore: 81 0.3.81 2adfceff315e7344370a427642ad41a4cfd99e1f, {Tracking_uf_ne_domains}, {Tracking_from_domain_doesnt_match_to}, {Tracking_spam_in_reply_from_match_msgid}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;astralinux.ru:7.1.1;lore.kernel.org:7.1.1;new-mail.astralinux.ru:7.1.1;127.0.0.199:7.1.2, FromAlignment: s X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiSpam-Lua-Profiles: 198520 [Nov 28 2025] X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Version: 6.1.1.20 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/11/28 12:43:00 #27986045 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: NotDetected, bases: 2025/11/28 10:15:00 X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 Content-Type: text/plain; charset="utf-8" From: Ido Schimmel [ Upstream commit c484fcc058bada604d7e4e5228d4affb646ddbc2 ] When a net device is put administratively up, its 'IFF_UP' flag is set (if not set already) and a 'NETDEV_UP' notification is emitted, which causes the 8021q driver to add VLAN ID 0 on the device. The reverse happens when a net device is put administratively down. When changing the type of a bond to Ethernet, its 'IFF_UP' flag is incorrectly cleared, resulting in the kernel skipping the above process and VLAN ID 0 being leaked [1]. Fix by restoring the flag when changing the type to Ethernet, in a similar fashion to the restoration of the 'IFF_SLAVE' flag. The issue can be reproduced using the script in [2], with example out before and after the fix in [3]. [1] unreferenced object 0xffff888103479900 (size 256): comm "ip", pid 329, jiffies 4294775225 (age 28.561s) hex dump (first 32 bytes): 00 a0 0c 15 81 88 ff ff 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [] kmalloc_trace+0x2a/0xe0 [] vlan_vid_add+0x30c/0x790 [] vlan_device_event+0x1491/0x21a0 [] notifier_call_chain+0xbe/0x1f0 [] call_netdevice_notifiers_info+0xba/0x150 [] __dev_notify_flags+0x132/0x2e0 [] dev_change_flags+0x11f/0x180 [] do_setlink+0xb96/0x4060 [] __rtnl_newlink+0xc0a/0x18a0 [] rtnl_newlink+0x6c/0xa0 [] rtnetlink_rcv_msg+0x43e/0xe00 [] netlink_rcv_skb+0x170/0x440 [] netlink_unicast+0x53f/0x810 [] netlink_sendmsg+0x96b/0xe90 [] ____sys_sendmsg+0x30f/0xa70 [] ___sys_sendmsg+0x13a/0x1e0 unreferenced object 0xffff88810f6a83e0 (size 32): comm "ip", pid 329, jiffies 4294775225 (age 28.561s) hex dump (first 32 bytes): a0 99 47 03 81 88 ff ff a0 99 47 03 81 88 ff ff ..G.......G..... 81 00 00 00 01 00 00 00 cc cc cc cc cc cc cc cc ................ backtrace: [] kmalloc_trace+0x2a/0xe0 [] vlan_vid_add+0x409/0x790 [] vlan_device_event+0x1491/0x21a0 [] notifier_call_chain+0xbe/0x1f0 [] call_netdevice_notifiers_info+0xba/0x150 [] __dev_notify_flags+0x132/0x2e0 [] dev_change_flags+0x11f/0x180 [] do_setlink+0xb96/0x4060 [] __rtnl_newlink+0xc0a/0x18a0 [] rtnl_newlink+0x6c/0xa0 [] rtnetlink_rcv_msg+0x43e/0xe00 [] netlink_rcv_skb+0x170/0x440 [] netlink_unicast+0x53f/0x810 [] netlink_sendmsg+0x96b/0xe90 [] ____sys_sendmsg+0x30f/0xa70 [] ___sys_sendmsg+0x13a/0x1e0 [2] ip link add name t-nlmon type nlmon ip link add name t-dummy type dummy ip link add name t-bond type bond mode active-backup ip link set dev t-bond up ip link set dev t-nlmon master t-bond ip link set dev t-nlmon nomaster ip link show dev t-bond ip link set dev t-dummy master t-bond ip link show dev t-bond ip link del dev t-bond ip link del dev t-dummy ip link del dev t-nlmon [3] Before: 12: t-bond: mtu 1500 qdisc noque= ue state DOWN mode DEFAULT group default qlen 1000 link/netlink 12: t-bond: mtu 1500 qdisc noqueue st= ate UP mode DEFAULT group default qlen 1000 link/ether 46:57:39:a4:46:a2 brd ff:ff:ff:ff:ff:ff After: 12: t-bond: mtu 1500 qdisc noque= ue state DOWN mode DEFAULT group default qlen 1000 link/netlink 12: t-bond: mtu 1500 qdisc noqueue= state UP mode DEFAULT group default qlen 1000 link/ether 66:48:7b:74:b6:8a brd ff:ff:ff:ff:ff:ff Fixes: e36b9d16c6a6 ("bonding: clean muticast addresses when device changes= type") Fixes: 75c78500ddad ("bonding: remap muticast addresses without using dev_c= lose() and dev_open()") Fixes: 9ec7eb60dcbc ("bonding: restore IFF_MASTER/SLAVE flags on bond ensla= ve ether type change") Reported-by: Mirsad Goran Todorovac Link: https://lore.kernel.org/netdev/78a8a03b-6070-3e6b-5042-f848dab16fb8@a= lu.unizg.hr/ Tested-by: Mirsad Goran Todorovac Signed-off-by: Ido Schimmel Acked-by: Jay Vosburgh Signed-off-by: David S. Miller Signed-off-by: Alexey Panov --- drivers/net/bonding/bond_main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_mai= n.c index 127242101c8e..97e556302b04 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1693,14 +1693,15 @@ void bond_lower_state_changed(struct slave *slave) =20 /* The bonding driver uses ether_setup() to convert a master bond device * to ARPHRD_ETHER, that resets the target netdevice's flags so we always - * have to restore the IFF_MASTER flag, and only restore IFF_SLAVE if it w= as set + * have to restore the IFF_MASTER flag, and only restore IFF_SLAVE and IFF= _UP + * if they were set */ static void bond_ether_setup(struct net_device *bond_dev) { - unsigned int slave_flag =3D bond_dev->flags & IFF_SLAVE; + unsigned int flags =3D bond_dev->flags & (IFF_SLAVE | IFF_UP); =20 ether_setup(bond_dev); - bond_dev->flags |=3D IFF_MASTER | slave_flag; + bond_dev->flags |=3D IFF_MASTER | flags; bond_dev->priv_flags &=3D ~IFF_TX_SKB_SHARING; } =20 --=20 2.39.5 From nobody Mon Dec 1 22:07:31 2025 Received: from mail-gw02.astralinux.ru (mail-gw02.astralinux.ru [93.188.205.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6703230E0F3; Fri, 28 Nov 2025 13:22:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.188.205.243 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764336145; cv=none; b=S1PYtZPWyMsUCNS1uNBf0XBuM88FUAgC/6JzdfZAYF1eiqKyGTegNLO2NFQyFpokfGFNqbElXhCvDFzfdHhdgTkUVWgOa1W73yBYz1ihSkRAns0iteWWF+gW477km5Zr5gvBqTrBFfZOvAp92CQDyNoO5g0MrPMMhiRwdfJIY64= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764336145; c=relaxed/simple; bh=0duWjTUsbySq3CaYAyrFjiAslVzcsNwSMNp0T9yZa6Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oOE/skPqHCB/q7va9zj4ApGACiL9CjZNmKrctIGmqFPWETdpjLV0PVtYoDaoFH3vXeFcEQjZT7AmLSRUJ1dzzFHG/1a0OVzLFNdypv0+T3RtzWtosx1ohFQESQxktnpnE3PMLKks8AEtZlp3ABOd48fR+v40ojUktaF5giokJ60= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=astralinux.ru; spf=pass smtp.mailfrom=astralinux.ru; dkim=pass (2048-bit key) header.d=astralinux.ru header.i=@astralinux.ru header.b=ReVJ1faD; arc=none smtp.client-ip=93.188.205.243 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=astralinux.ru header.i=@astralinux.ru header.b="ReVJ1faD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=astralinux.ru; s=mail; t=1764336141; bh=0duWjTUsbySq3CaYAyrFjiAslVzcsNwSMNp0T9yZa6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ReVJ1faDtdfMY+5dXYMSdIViHqOUEIto3OdUsmB13sQnWTzMjoyCyQdJXbZbyIYbM 170X1PaZ/5bEQQ5mYK6bzVCJ/7P8Tz25DYPsb6lVdAWTdXEXHKdB31SCChpwsel5HC 71BxzXXELUn7Cya4aiLTOBy0BmX5V/C0XN69szDiWMXO7ZBB9L5FSCFLPhdYxs4w3j mD+89pPja5NiHjB3WnVCxRIHEFklS1vUuSVEdraVkXKrFohm0Kg1TxtBAntr5bg5uf zk4JtUP8UcXE8Ql/QSAn7G7mOiaMB3IW79+vFpRnu6X2jxzE3S30cV3JcSAi9V/Vn1 jlC2RM38YxCBA== Received: from gca-msk-a-srv-ksmg01 (localhost [127.0.0.1]) by mail-gw02.astralinux.ru (Postfix) with ESMTP id A310B1F9C1; Fri, 28 Nov 2025 16:22:21 +0300 (MSK) Received: from new-mail.astralinux.ru (unknown [10.205.207.13]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-gw02.astralinux.ru (Postfix) with ESMTPS; Fri, 28 Nov 2025 16:22:19 +0300 (MSK) Received: from rbta-msk-lt-156703.astralinux.ru.astracloud.ru (rbta-msk-lt-156703.astralinux.ru [10.198.57.41]) by new-mail.astralinux.ru (Postfix) with ESMTPA id 4dHv8V2sZqzJqMr; Fri, 28 Nov 2025 16:21:46 +0300 (MSK) From: Alexey Panov To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Alexey Panov , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Jakub Kicinski , Moni Shoua , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Nikolay Aleksandrov , bpf@vger.kernel.org, lvc-project@linuxtesting.org, syzbot+9dfc3f3348729cc82277@syzkaller.appspotmail.com, Nikolay Aleksandrov , Michal Kubiak , Jonathan Toppins , Jay Vosburgh Subject: [PATCH 5.10 v3 3/3] bonding: restore bond's IFF_SLAVE flag if a non-eth dev enslave fails Date: Fri, 28 Nov 2025 16:21:26 +0300 Message-Id: <20251128132126.7467-4-apanov@astralinux.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20251128132126.7467-1-apanov@astralinux.ru> References: <20251128132126.7467-1-apanov@astralinux.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-KSMG-AntiPhishing: NotDetected, bases: 2025/11/28 10:15:00 X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Envelope-From: apanov@astralinux.ru X-KSMG-AntiSpam-Info: LuaCore: 81 0.3.81 2adfceff315e7344370a427642ad41a4cfd99e1f, {Tracking_one_url}, {Tracking_uf_ne_domains}, {Tracking_from_domain_doesnt_match_to}, {Tracking_spam_in_reply_from_match_msgid}, new-mail.astralinux.ru:7.1.1;127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;astralinux.ru:7.1.1;syzkaller.appspot.com:7.1.1,5.0.1, FromAlignment: s X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiSpam-Lua-Profiles: 198520 [Nov 28 2025] X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Version: 6.1.1.20 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/11/28 12:43:00 #27986045 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: NotDetected, bases: 2025/11/28 10:15:00 X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 Content-Type: text/plain; charset="utf-8" From: Nikolay Aleksandrov [ Upstream commit e667d469098671261d558be0cd93dca4d285ce1e ] syzbot reported a warning[1] where the bond device itself is a slave and we try to enslave a non-ethernet device as the first slave which fails but then in the error path when ether_setup() restores the bond device it also clears all flags. In my previous fix[2] I restored the IFF_MASTER flag, but I didn't consider the case that the bond device itself might also be a slave with IFF_SLAVE set, so we need to restore that flag as well. Use the bond_ether_setup helper which does the right thing and restores the bond's flags properly. Steps to reproduce using a nlmon dev: $ ip l add nlmon0 type nlmon $ ip l add bond1 type bond $ ip l add bond2 type bond $ ip l set bond1 master bond2 $ ip l set dev nlmon0 master bond1 $ ip -d l sh dev bond1 22: bond1: mtu 1500 qdisc noqueue master bond= 2 state DOWN mode DEFAULT group default qlen 1000 (now bond1's IFF_SLAVE flag is gone and we'll hit a warning[3] if we try to delete it) [1] https://syzkaller.appspot.com/bug?id=3D391c7b1f6522182899efba27d891f174= 3e8eb3ef [2] commit 7d5cd2ce5292 ("bonding: correctly handle bonding type change on = enslave failure") [3] example warning: [ 27.008664] bond1: (slave nlmon0): The slave device specified does not = support setting the MAC address [ 27.008692] bond1: (slave nlmon0): Error -95 calling set_mac_address [ 32.464639] bond1 (unregistering): Released all slaves [ 32.464685] ------------[ cut here ]------------ [ 32.464686] WARNING: CPU: 1 PID: 2004 at net/core/dev.c:10829 unregiste= r_netdevice_many+0x72a/0x780 [ 32.464694] Modules linked in: br_netfilter bridge bonding virtio_net [ 32.464699] CPU: 1 PID: 2004 Comm: ip Kdump: loaded Not tainted 5.18.0-= rc3+ #47 [ 32.464703] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.= 16.1-2.fc37 04/01/2014 [ 32.464704] RIP: 0010:unregister_netdevice_many+0x72a/0x780 [ 32.464707] Code: 99 fd ff ff ba 90 1a 00 00 48 c7 c6 f4 02 66 96 48 c7= c7 20 4d 35 96 c6 05 fa c7 2b 02 01 e8 be 6f 4a 00 0f 0b e9 73 fd ff ff <0= f> 0b e9 5f fd ff ff 80 3d e3 c7 2b 02 00 0f 85 3b fd ff ff ba 59 [ 32.464710] RSP: 0018:ffffa006422d7820 EFLAGS: 00010206 [ 32.464712] RAX: ffff8f6e077140a0 RBX: ffffa006422d7888 RCX: 0000000000= 000000 [ 32.464714] RDX: ffff8f6e12edbe58 RSI: 0000000000000296 RDI: ffffffff96= d4a520 [ 32.464716] RBP: ffff8f6e07714000 R08: ffffffff96d63600 R09: ffffa00642= 2d7728 [ 32.464717] R10: 0000000000000ec0 R11: ffffffff9698c988 R12: ffff8f6e12= edb140 [ 32.464719] R13: dead000000000122 R14: dead000000000100 R15: ffff8f6e12= edb140 [ 32.464723] FS: 00007f297c2f1740(0000) GS:ffff8f6e5d900000(0000) knlGS= :0000000000000000 [ 32.464725] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 32.464726] CR2: 00007f297bf1c800 CR3: 00000000115e8000 CR4: 0000000000= 350ee0 [ 32.464730] Call Trace: [ 32.464763] [ 32.464767] rtnl_dellink+0x13e/0x380 [ 32.464776] ? cred_has_capability.isra.0+0x68/0x100 [ 32.464780] ? __rtnl_unlock+0x33/0x60 [ 32.464783] ? bpf_lsm_capset+0x10/0x10 [ 32.464786] ? security_capable+0x36/0x50 [ 32.464790] rtnetlink_rcv_msg+0x14e/0x3b0 [ 32.464792] ? _copy_to_iter+0xb1/0x790 [ 32.464796] ? post_alloc_hook+0xa0/0x160 [ 32.464799] ? rtnl_calcit.isra.0+0x110/0x110 [ 32.464802] netlink_rcv_skb+0x50/0xf0 [ 32.464806] netlink_unicast+0x216/0x340 [ 32.464809] netlink_sendmsg+0x23f/0x480 [ 32.464812] sock_sendmsg+0x5e/0x60 [ 32.464815] ____sys_sendmsg+0x22c/0x270 [ 32.464818] ? import_iovec+0x17/0x20 [ 32.464821] ? sendmsg_copy_msghdr+0x59/0x90 [ 32.464823] ? do_set_pte+0xa0/0xe0 [ 32.464828] ___sys_sendmsg+0x81/0xc0 [ 32.464832] ? mod_objcg_state+0xc6/0x300 [ 32.464835] ? refill_obj_stock+0xa9/0x160 [ 32.464838] ? memcg_slab_free_hook+0x1a5/0x1f0 [ 32.464842] __sys_sendmsg+0x49/0x80 [ 32.464847] do_syscall_64+0x3b/0x90 [ 32.464851] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 32.464865] RIP: 0033:0x7f297bf2e5e7 [ 32.464868] Code: 64 89 02 48 c7 c0 ff ff ff ff eb bb 0f 1f 80 00 00 00= 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 2e 00 00 00 0f 05 <4= 8> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10 [ 32.464869] RSP: 002b:00007ffd96c824c8 EFLAGS: 00000246 ORIG_RAX: 00000= 0000000002e [ 32.464872] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f297b= f2e5e7 [ 32.464874] RDX: 0000000000000000 RSI: 00007ffd96c82540 RDI: 0000000000= 000003 [ 32.464875] RBP: 00000000640f19de R08: 0000000000000001 R09: 0000000000= 00007c [ 32.464876] R10: 00007f297bffabe0 R11: 0000000000000246 R12: 0000000000= 000001 [ 32.464877] R13: 00007ffd96c82d20 R14: 00007ffd96c82610 R15: 000055bfe3= 8a7020 [ 32.464881] [ 32.464882] ---[ end trace 0000000000000000 ]--- Fixes: 7d5cd2ce5292 ("bonding: correctly handle bonding type change on ensl= ave failure") Reported-by: syzbot+9dfc3f3348729cc82277@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?id=3D391c7b1f6522182899efba27d891f1= 743e8eb3ef Signed-off-by: Nikolay Aleksandrov Reviewed-by: Michal Kubiak Acked-by: Jonathan Toppins Acked-by: Jay Vosburgh Signed-off-by: David S. Miller Signed-off-by: Alexey Panov --- drivers/net/bonding/bond_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_mai= n.c index 127242101c8e..0c5bda75dc60 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -2176,9 +2176,7 @@ int bond_enslave(struct net_device *bond_dev, struct = net_device *slave_dev, eth_hw_addr_random(bond_dev); if (bond_dev->type !=3D ARPHRD_ETHER) { dev_close(bond_dev); - ether_setup(bond_dev); - bond_dev->flags |=3D IFF_MASTER; - bond_dev->priv_flags &=3D ~IFF_TX_SKB_SHARING; + bond_ether_setup(bond_dev); } } =20 --=20 2.30.2