Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Hangbin Liu
Fri, 27 Nov 2026 03:08
[PATCH net] bonding: check slave xdp_features in bond_xdp_xmit
Author: Hangbin Liu
Date: Fri, 27 Nov 2026 03:08
Date: Fri, 27 Nov 2026 03:08
79 lines
11307 bytes
11307 bytes
From: Hangbin Liu <liuhangbin@kylinos.cn>
bond_xdp_xmit() may select a slave that bond_enslave() made visible
before bond_xdp_set_features() republished the bond's xdp_features.
Frames enqueued in that window pass __xdp_enqueue()'s bond-level
checks, and the bulk-queue flush later calls bond_xdp_xmit() without
rechecking anything. The selected slave may be unable to transmit
XDP frames:
- NETDEV_XDP_ACT_NDO_XMIT appears only once the driver's XDP TX
queues are up.
- a linear-only slave receives multi-buffer frames enqueued while
the bond still advertised NETDEV_XDP_ACT_NDO_XMIT_SG.
- with no bond->xdp_prog, bond_enslave() skips the capability
check: a slave without XDP joins while the bond still
advertises NETDEV_XDP_ACT_NDO_XMIT (built from the other
slaves; __xdp_enqueue() never looks at dev->xdp_prog) and
bond_xdp_set_features() drops the flag only afterwards.
Apply the __xdp_enqueue() contract to the selected slave at xmit
time: require NETDEV_XDP_ACT_NDO_XMIT and, for fragmented frames,
NETDEV_XDP_ACT_NDO_XMIT_SG, failing with -ENXIO otherwise (the
caller frees the frames).
Fixes: 9e2ee5c7e7c3 ("net, bonding: Add XDP support to the bonding driver")
Cc: stable@vger.kernel.org # b9d460c92455 ("bpf: devmap: check XDP features in __xdp_enqueue routine")
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
The issue was identified when sashiko review other patches.
The issue is theoretical and only happen in a race window, I didn't
reproduce it.
For Sashiko,
Please ignore the error out issues during bond_enslave. They will
be addressed in other patches.
---
drivers/net/bonding/bond_main.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 042d7c75548f..6ceefb0bfc20 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -5664,6 +5664,7 @@ static int bond_xdp_xmit(struct net_device *bond_dev,
struct xdp_frame *frame = frames[nxmit];
struct xdp_frame *frames1[] = {frame};
struct net_device *slave_dev;
+ xdp_features_t feats;
struct xdp_buff xdp;
xdp_convert_frame_to_buff(frame, &xdp);
@@ -5674,6 +5675,18 @@ static int bond_xdp_xmit(struct net_device *bond_dev,
break;
}
+ /* The slave can be selected before bond_xdp_set_features()
+ * republishes the bond's xdp_features, so apply the
+ * __xdp_enqueue() contract to the slave itself.
+ */
+ feats = READ_ONCE(slave_dev->xdp_features);
+ if (unlikely(!(feats & NETDEV_XDP_ACT_NDO_XMIT) ||
+ (!(feats & NETDEV_XDP_ACT_NDO_XMIT_SG) &&
+ xdp_frame_has_frags(frame)))) {
+ err = -ENXIO;
+ break;
+ }
+
err = slave_dev->netdev_ops->ndo_xdp_xmit(slave_dev, 1, frames1, flags);
if (err < 1)
break;
---
base-commit: e1055cbfd6eb578417f3ce983cf44462e8465267
change-id: 20261127-bond_xdp_xmit-5dfe5b99d10c
Best regards,
--
Hangbin Liu <liuhangbin@kylinos.cn>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads