AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/07/11 17:33 flow patch-triage
0m Args:
null

Results:
{
  "EnableConfigs": [
    "XDP_SOCKETS"
  ],
  "FocusSymbols": [
    "xsk_tx_completed",
    "xsk_tx_commit_batch",
    "__xsk_tx_peek_release_desc_batch",
    "xsk_tx_peek_release_shared_desc_batch",
    "xsk_tx_peek_release_desc_batch",
    "xsk_cq_submit_addr_single_locked",
    "xsk_drop_skb",
    "xsk_build_skb_zerocopy",
    "xsk_build_skb",
    "__xsk_generic_xmit",
    "xp_alloc_tx_descs"
  ],
  "Reasoning": "The patch modifies the AF_XDP multi-buffer (SG) packet transmission logic, introducing batching and reclaim descriptors to handle invalid descriptors and boundaries correctly. It modifies core XDP socket code in net/xdp/xsk.c and net/xdp/xsk_queue.h. This is reachable and functional code that should be fuzzed.",
  "WorthFuzzing": true
}

1/1 2026/07/11 17:33 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 330d4f7ebc1aef7966ab39eed9fda4a759908fe8\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Sat Jul 11 17:33:44 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h\nindex ebac60a3d8a17b..8b51876efbed1a 100644\n--- a/include/net/xdp_sock.h\n+++ b/include/net/xdp_sock.h\n@@ -80,6 +80,7 @@ struct xdp_sock {\n \t * call of __xsk_generic_xmit().\n \t */\n \tstruct sk_buff *skb;\n+\tbool drain_cont;\n \n \tstruct list_head map_list;\n \t/* Protects map_list */\ndiff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h\nindex ccb3b350001f24..fb59e205ac7d7e 100644\n--- a/include/net/xsk_buff_pool.h\n+++ b/include/net/xsk_buff_pool.h\n@@ -78,6 +78,9 @@ struct xsk_buff_pool {\n \tu32 chunk_size;\n \tu32 chunk_shift;\n \tu32 frame_len;\n+\tu32 tx_descs_nentries;\n+\tu32 reclaim_descs;\n+\tu32 tx_zc_pending_descs;\n \tu32 xdp_zc_max_segs;\n \tu8 tx_metadata_len; /* inherited from umem */\n \tu8 cached_need_wakeup;\ndiff --git a/net/xdp/xsk.c b/net/xdp/xsk.c\nindex b970f30ea9b9d8..7d8b42c4c214ba 100644\n--- a/net/xdp/xsk.c\n+++ b/net/xdp/xsk.c\n@@ -499,6 +499,23 @@ void __xsk_map_flush(struct list_head *flush_list)\n \n void xsk_tx_completed(struct xsk_buff_pool *pool, u32 nb_entries)\n {\n+\tu32 reclaim_descs = READ_ONCE(pool-\u003ereclaim_descs);\n+\n+\tif (unlikely(reclaim_descs)) {\n+\t\tu32 pending_descs = READ_ONCE(pool-\u003etx_zc_pending_descs);\n+\n+\t\tif (nb_entries \u003c pending_descs) {\n+\t\t\tWRITE_ONCE(pool-\u003etx_zc_pending_descs,\n+\t\t\t\t   pending_descs - nb_entries);\n+\t\t\txskq_prod_submit_n(pool-\u003ecq, nb_entries);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tWRITE_ONCE(pool-\u003etx_zc_pending_descs, 0);\n+\t\tnb_entries += reclaim_descs;\n+\t\tWRITE_ONCE(pool-\u003ereclaim_descs, 0);\n+\t}\n+\n \txskq_prod_submit_n(pool-\u003ecq, nb_entries);\n }\n EXPORT_SYMBOL(xsk_tx_completed);\n@@ -574,22 +591,169 @@ static u32 xsk_tx_peek_release_fallback(struct xsk_buff_pool *pool, u32 max_entr\n \treturn nb_pkts;\n }\n \n+static void xsk_tx_commit_batch(struct xsk_buff_pool *pool,\n+\t\t\t\tstruct xsk_tx_batch *batch,\n+\t\t\t\tu32 cq_cached_prod)\n+{\n+\tu32 nb_descs = xsk_tx_batch_cq_descs(batch);\n+\n+\tif (!nb_descs)\n+\t\treturn;\n+\n+\txskq_prod_write_addr_batch(pool-\u003ecq, pool-\u003etx_descs, nb_descs);\n+\n+\tif (unlikely(batch-\u003ereclaim_descs)) {\n+\t\tu32 cq_pending_descs;\n+\n+\t\t/* CQ is positional. Descriptors already written but not\n+\t\t * submitted must complete before any reclaim-only descriptors\n+\t\t * appended below.\n+\t\t */\n+\t\tcq_pending_descs = cq_cached_prod - xskq_get_prod(pool-\u003ecq);\n+\n+\t\tWRITE_ONCE(pool-\u003etx_zc_pending_descs, batch-\u003etx_descs + cq_pending_descs);\n+\t\tWRITE_ONCE(pool-\u003ereclaim_descs, batch-\u003ereclaim_descs);\n+\t\tif (unlikely(!pool-\u003etx_zc_pending_descs))\n+\t\t\txsk_tx_completed(pool, 0);\n+\t}\n+}\n+\n+static struct xsk_tx_batch\n+__xsk_tx_peek_release_desc_batch(struct xsk_buff_pool *pool, struct xdp_sock *xs,\n+\t\t\t\t struct xdp_desc *descs, u32 max_descs)\n+{\n+\tstruct xsk_tx_batch batch = {};\n+\tu32 entries;\n+\n+\tentries = xskq_cons_nb_entries(xs-\u003etx, max_descs);\n+\tif (!entries)\n+\t\treturn batch;\n+\n+\tbatch = xskq_cons_read_desc_batch(xs, pool, descs, entries);\n+\tif (!xsk_tx_batch_cq_descs(\u0026batch)) {\n+\t\txs-\u003etx-\u003equeue_empty_descs++;\n+\t\tif (batch.consumed_descs) {\n+\t\t\t__xskq_cons_release(xs-\u003etx);\n+\t\t\txs-\u003esk.sk_write_space(\u0026xs-\u003esk);\n+\t\t}\n+\t\treturn batch;\n+\t}\n+\n+\t__xskq_cons_release(xs-\u003etx);\n+\txs-\u003esk.sk_write_space(\u0026xs-\u003esk);\n+\treturn batch;\n+}\n+\n+static struct xsk_tx_batch\n+xsk_tx_peek_release_shared_desc_batch(struct xsk_buff_pool *pool, u32 max_descs)\n+{\n+\tu32 cq_descs_before, cq_descs_after;\n+\tstruct xsk_tx_batch sum_batch = {};\n+\tbool budget_exhausted;\n+\tu32 per_socket_budget;\n+\tstruct xdp_sock *xs;\n+\n+\tmax_descs = xskq_prod_nb_free(pool-\u003ecq, max_descs);\n+\tif (!max_descs)\n+\t\treturn sum_batch;\n+\n+\t/* The fairness quota must allow one maximum-sized valid packet. */\n+\tper_socket_budget = max_t(u32, MAX_PER_SOCKET_BUDGET,\n+\t\t\t\t  pool-\u003exdp_zc_max_segs);\n+\n+again:\n+\tbudget_exhausted = false;\n+\tcq_descs_before = xsk_tx_batch_cq_descs(\u0026sum_batch);\n+\tlist_for_each_entry_rcu(xs, \u0026pool-\u003exsk_tx_list, tx_list) {\n+\t\tu32 budget, budget_left, offset, remaining;\n+\t\tstruct xsk_tx_batch curr_batch;\n+\n+\t\t/* Once reclaim-only descriptors have been appended to the CQ address\n+\t\t * area, do not append driver-visible Tx descriptors from another\n+\t\t * socket after them. xsk_tx_completed() relies on all driver-visible\n+\t\t * descriptors preceding all reclaim-only descriptors in CQ order.\n+\t\t */\n+\t\tif (sum_batch.reclaim_descs)\n+\t\t\tbreak;\n+\n+\t\t/* be gentle when playing with pool-\u003etx_descs */\n+\t\toffset = xsk_tx_batch_cq_descs(\u0026sum_batch);\n+\t\tif (offset \u003e= max_descs)\n+\t\t\tbreak;\n+\n+\t\tif (xs-\u003etx_budget_spent \u003e= per_socket_budget) {\n+\t\t\tif (xskq_cons_nb_entries(xs-\u003etx, 1))\n+\t\t\t\tbudget_exhausted = true;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tbudget_left = per_socket_budget - xs-\u003etx_budget_spent;\n+\t\tremaining = max_descs - offset;\n+\t\tbudget = min(remaining, budget_left);\n+\n+\t\tcurr_batch = __xsk_tx_peek_release_desc_batch(pool, xs,\n+\t\t\t\t\t\t\t      pool-\u003etx_descs + offset,\n+\t\t\t\t\t\t\t      budget);\n+\t\tif (!xsk_tx_batch_cq_descs(\u0026curr_batch)) {\n+\t\t\tif (curr_batch.budget_limited \u0026\u0026 budget_left \u003c remaining)\n+\t\t\t\tbudget_exhausted = true;\n+\t\t\txs-\u003etx_budget_spent += curr_batch.consumed_descs;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\txs-\u003etx_budget_spent += curr_batch.consumed_descs;\n+\t\tsum_batch.tx_descs += curr_batch.tx_descs;\n+\t\tsum_batch.reclaim_descs += curr_batch.reclaim_descs;\n+\t}\n+\n+\tcq_descs_after = xsk_tx_batch_cq_descs(\u0026sum_batch);\n+\n+\tif (sum_batch.reclaim_descs || cq_descs_after \u003e= max_descs)\n+\t\treturn sum_batch;\n+\n+\t/* Continue filling the batch while this pass made progress */\n+\tif (cq_descs_before != cq_descs_after)\n+\t\tgoto again;\n+\n+\tif (!budget_exhausted)\n+\t\treturn sum_batch;\n+\n+\tlist_for_each_entry_rcu(xs, \u0026pool-\u003exsk_tx_list, tx_list)\n+\t\txs-\u003etx_budget_spent = 0;\n+\tgoto again;\n+}\n+\n u32 xsk_tx_peek_release_desc_batch(struct xsk_buff_pool *pool, u32 nb_pkts)\n {\n+\tstruct xsk_tx_batch batch = {};\n \tstruct xdp_sock *xs;\n+\tu32 cq_cached_prod;\n \n \trcu_read_lock();\n+\tif (unlikely(READ_ONCE(pool-\u003ereclaim_descs)))\n+\t\tgoto out;\n+\tnb_pkts = min(nb_pkts, pool-\u003etx_descs_nentries);\n+\tif (!nb_pkts)\n+\t\tgoto out;\n \tif (!list_is_singular(\u0026pool-\u003exsk_tx_list)) {\n-\t\t/* Fallback to the non-batched version */\n+\t\t/* Keep the legacy one-descriptor fallback for non-SG users.  The\n+\t\t * shared SG path needs packet-framed parsing so invalid/overflowed\n+\t\t * multi-buffer packets are drained as a unit.\n+\t\t */\n+\t\tif (pool-\u003eumem-\u003eflags \u0026 XDP_UMEM_SG_FLAG) {\n+\t\t\tbatch = xsk_tx_peek_release_shared_desc_batch(pool, nb_pkts);\n+\t\t\tcq_cached_prod = pool-\u003ecq-\u003ecached_prod;\n+\t\t\txsk_tx_commit_batch(pool, \u0026batch, cq_cached_prod);\n+\t\t\tgoto out;\n+\t\t}\n+\n \t\trcu_read_unlock();\n \t\treturn xsk_tx_peek_release_fallback(pool, nb_pkts);\n \t}\n \n \txs = list_first_or_null_rcu(\u0026pool-\u003exsk_tx_list, struct xdp_sock, tx_list);\n-\tif (!xs) {\n-\t\tnb_pkts = 0;\n+\tif (!xs)\n \t\tgoto out;\n-\t}\n \n \tnb_pkts = xskq_cons_nb_entries(xs-\u003etx, nb_pkts);\n \n@@ -603,19 +767,18 @@ u32 xsk_tx_peek_release_desc_batch(struct xsk_buff_pool *pool, u32 nb_pkts)\n \tif (!nb_pkts)\n \t\tgoto out;\n \n-\tnb_pkts = xskq_cons_read_desc_batch(xs-\u003etx, pool, nb_pkts);\n-\tif (!nb_pkts) {\n-\t\txs-\u003etx-\u003equeue_empty_descs++;\n+\tbatch = __xsk_tx_peek_release_desc_batch(pool, xs, pool-\u003etx_descs,\n+\t\t\t\t\t\t nb_pkts);\n+\tnb_pkts = xsk_tx_batch_cq_descs(\u0026batch);\n+\tif (!nb_pkts)\n \t\tgoto out;\n-\t}\n \n-\t__xskq_cons_release(xs-\u003etx);\n-\txskq_prod_write_addr_batch(pool-\u003ecq, pool-\u003etx_descs, nb_pkts);\n-\txs-\u003esk.sk_write_space(\u0026xs-\u003esk);\n+\tcq_cached_prod = pool-\u003ecq-\u003ecached_prod;\n+\txsk_tx_commit_batch(pool, \u0026batch, cq_cached_prod);\n \n out:\n \trcu_read_unlock();\n-\treturn nb_pkts;\n+\treturn batch.tx_descs;\n }\n EXPORT_SYMBOL(xsk_tx_peek_release_desc_batch);\n \n@@ -737,6 +900,19 @@ static void xsk_cq_submit_addr_locked(struct xsk_buff_pool *pool,\n \tspin_unlock_irqrestore(\u0026pool-\u003ecq_prod_lock, flags);\n }\n \n+static void xsk_cq_submit_addr_single_locked(struct xsk_buff_pool *pool,\n+\t\t\t\t\t     struct xdp_desc *desc)\n+{\n+\tunsigned long flags;\n+\tu32 idx;\n+\n+\tspin_lock_irqsave(\u0026pool-\u003ecq_prod_lock, flags);\n+\tidx = xskq_get_prod(pool-\u003ecq);\n+\txskq_prod_write_addr(pool-\u003ecq, idx, desc-\u003eaddr);\n+\txskq_prod_submit_n(pool-\u003ecq, 1);\n+\tspin_unlock_irqrestore(\u0026pool-\u003ecq_prod_lock, flags);\n+}\n+\n static void xsk_cq_cancel_locked(struct xsk_buff_pool *pool, u32 n)\n {\n \tspin_lock(\u0026pool-\u003ecq-\u003ecq_cached_prod_lock);\n@@ -794,8 +970,11 @@ static void xsk_consume_skb(struct sk_buff *skb)\n \n static void xsk_drop_skb(struct sk_buff *skb)\n {\n-\txdp_sk(skb-\u003esk)-\u003etx-\u003einvalid_descs += xsk_get_num_desc(skb);\n-\txsk_consume_skb(skb);\n+\tstruct xdp_sock *xs = xdp_sk(skb-\u003esk);\n+\n+\txs-\u003etx-\u003einvalid_descs += xsk_get_num_desc(skb);\n+\tconsume_skb(skb);\n+\txs-\u003eskb = NULL;\n }\n \n static int xsk_skb_metadata(struct sk_buff *skb, void *buffer,\n@@ -877,7 +1056,7 @@ static struct sk_buff *xsk_build_skb_zerocopy(struct xdp_sock *xs,\n \t\t\treturn ERR_PTR(-ENOMEM);\n \n \t\t/* in case of -EOVERFLOW that could happen below,\n-\t\t * xsk_consume_skb() will release this node as whole skb\n+\t\t * xsk_drop_skb() will release this node as whole skb\n \t\t * would be dropped, which implies freeing all list elements\n \t\t */\n \t\txsk_addr-\u003eaddrs[xsk_addr-\u003enum_descs] = desc-\u003eaddr;\n@@ -969,6 +1148,8 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,\n \t\t\t\tgoto free_err;\n \t\t\t}\n \n+\t\t\txsk_addr-\u003eaddrs[xsk_addr-\u003enum_descs] = desc-\u003eaddr;\n+\n \t\t\tif (unlikely(nr_frags == (MAX_SKB_FRAGS - 1) \u0026\u0026 xp_mb_desc(desc))) {\n \t\t\t\terr = -EOVERFLOW;\n \t\t\t\tgoto free_err;\n@@ -986,8 +1167,6 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,\n \n \t\t\tskb_add_rx_frag(skb, nr_frags, page, 0, len, PAGE_SIZE);\n \t\t\trefcount_add(PAGE_SIZE, \u0026xs-\u003esk.sk_wmem_alloc);\n-\n-\t\t\txsk_addr-\u003eaddrs[xsk_addr-\u003enum_descs] = desc-\u003eaddr;\n \t\t}\n \t}\n \n@@ -1060,11 +1239,22 @@ static int __xsk_generic_xmit(struct sock *sk)\n \t\t\tgoto out;\n \t\t}\n \n+\t\tif (unlikely(xs-\u003edrain_cont)) {\n+\t\t\txsk_cq_submit_addr_single_locked(xs-\u003epool, \u0026desc);\n+\n+\t\t\txs-\u003etx-\u003einvalid_descs++;\n+\t\t\txskq_cons_release(xs-\u003etx);\n+\t\t\txs-\u003edrain_cont = xp_mb_desc(\u0026desc);\n+\t\t\tcontinue;\n+\t\t}\n+\n \t\tskb = xsk_build_skb(xs, \u0026desc);\n \t\tif (IS_ERR(skb)) {\n \t\t\terr = PTR_ERR(skb);\n \t\t\tif (err != -EOVERFLOW)\n \t\t\t\tgoto out;\n+\t\t\tif (xp_mb_desc(\u0026desc))\n+\t\t\t\txs-\u003edrain_cont = true;\n \t\t\terr = 0;\n \t\t\tcontinue;\n \t\t}\n@@ -1098,9 +1288,24 @@ static int __xsk_generic_xmit(struct sock *sk)\n \t}\n \n \tif (xskq_has_descs(xs-\u003etx)) {\n+\t\tbool reclaim_desc = xs-\u003eskb || xs-\u003edrain_cont;\n+\n+\t\tif (reclaim_desc) {\n+\t\t\terr = xsk_cq_reserve_locked(xs-\u003epool);\n+\t\t\tif (err) {\n+\t\t\t\terr = -EAGAIN;\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\t\t}\n+\n \t\tif (xs-\u003eskb)\n \t\t\txsk_drop_skb(xs-\u003eskb);\n+\n+\t\tif (reclaim_desc)\n+\t\t\txsk_cq_submit_addr_single_locked(xs-\u003epool, \u0026desc);\n+\n \t\txskq_cons_release(xs-\u003etx);\n+\t\txs-\u003edrain_cont = xp_mb_desc(\u0026desc);\n \t}\n \n out:\ndiff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c\nindex 1f28a9641571e4..b862addcd8fdaf 100644\n--- a/net/xdp/xsk_buff_pool.c\n+++ b/net/xdp/xsk_buff_pool.c\n@@ -48,6 +48,7 @@ int xp_alloc_tx_descs(struct xsk_buff_pool *pool, struct xdp_sock *xs)\n \tif (!pool-\u003etx_descs)\n \t\treturn -ENOMEM;\n \n+\tpool-\u003etx_descs_nentries = xs-\u003etx-\u003enentries;\n \treturn 0;\n }\n \ndiff --git a/net/xdp/xsk_queue.h b/net/xdp/xsk_queue.h\nindex 3e3fbb73d23e2f..a15ff1929db623 100644\n--- a/net/xdp/xsk_queue.h\n+++ b/net/xdp/xsk_queue.h\n@@ -58,6 +58,18 @@ struct parsed_desc {\n \tu32 valid;\n };\n \n+struct xsk_tx_batch {\n+\tu32 tx_descs;\n+\tu32 reclaim_descs;\n+\tu32 consumed_descs;\n+\tbool budget_limited;\n+};\n+\n+static inline u32 xsk_tx_batch_cq_descs(const struct xsk_tx_batch *batch)\n+{\n+\treturn batch-\u003etx_descs + batch-\u003ereclaim_descs;\n+}\n+\n /* The structure of the shared state of the rings are a simple\n  * circular buffer, as outlined in\n  * Documentation/core-api/circular-buffers.rst. For the Rx and\n@@ -263,17 +275,18 @@ static inline void parse_desc(struct xsk_queue *q, struct xsk_buff_pool *pool,\n \tparsed-\u003emb = xp_mb_desc(desc);\n }\n \n-static inline\n-u32 xskq_cons_read_desc_batch(struct xsk_queue *q, struct xsk_buff_pool *pool,\n-\t\t\t      u32 max)\n+static inline struct xsk_tx_batch\n+xskq_cons_read_desc_batch(struct xdp_sock *xs, struct xsk_buff_pool *pool,\n+\t\t\t  struct xdp_desc *descs, u32 max)\n {\n-\tu32 cached_cons = q-\u003ecached_cons, nb_entries = 0;\n-\tstruct xdp_desc *descs = pool-\u003etx_descs;\n-\tu32 total_descs = 0, nr_frags = 0;\n+\tbool drain = READ_ONCE(xs-\u003edrain_cont);\n+\tu32 cached_cons, nb_entries = 0, released;\n+\tstruct xsk_tx_batch batch = {};\n+\tstruct xsk_queue *q = xs-\u003etx;\n+\tu32 nr_frags = 0;\n+\n+\tcached_cons = q-\u003ecached_cons;\n \n-\t/* track first entry, if stumble upon *any* invalid descriptor, rewind\n-\t * current packet that consists of frags and stop the processing\n-\t */\n \twhile (cached_cons != q-\u003ecached_prod \u0026\u0026 nb_entries \u003c max) {\n \t\tstruct xdp_rxtx_ring *ring = (struct xdp_rxtx_ring *)q-\u003ering;\n \t\tu32 idx = cached_cons \u0026 q-\u003ering_mask;\n@@ -282,26 +295,49 @@ u32 xskq_cons_read_desc_batch(struct xsk_queue *q, struct xsk_buff_pool *pool,\n \t\tdescs[nb_entries] = ring-\u003edesc[idx];\n \t\tcached_cons++;\n \t\tparse_desc(q, pool, \u0026descs[nb_entries], \u0026parsed);\n-\t\tif (unlikely(!parsed.valid))\n-\t\t\tbreak;\n+\t\tif (unlikely(!parsed.valid)) {\n+\t\t\tif (!drain \u0026\u0026 !nr_frags \u0026\u0026 !parsed.mb)\n+\t\t\t\tbreak;\n+\n+\t\t\tdrain = true;\n+\t\t}\n+\n+\t\tnr_frags++;\n+\t\tnb_entries++;\n \n \t\tif (likely(!parsed.mb)) {\n-\t\t\ttotal_descs += (nr_frags + 1);\n-\t\t\tnr_frags = 0;\n-\t\t} else {\n-\t\t\tnr_frags++;\n-\t\t\tif (nr_frags == pool-\u003exdp_zc_max_segs) {\n+\t\t\tif (unlikely(drain)) {\n+\t\t\t\tbatch.reclaim_descs = nr_frags;\n+\t\t\t\tWRITE_ONCE(xs-\u003edrain_cont, false);\n \t\t\t\tnr_frags = 0;\n \t\t\t\tbreak;\n \t\t\t}\n+\n+\t\t\tbatch.tx_descs += nr_frags;\n+\t\t\tnr_frags = 0;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (nr_frags == pool-\u003exdp_zc_max_segs)\n+\t\t\tdrain = true;\n+\t}\n+\n+\tif (nr_frags) {\n+\t\tif (drain) {\n+\t\t\tbatch.reclaim_descs = nr_frags;\n+\t\t\tWRITE_ONCE(xs-\u003edrain_cont, true);\n+\t\t} else {\n+\t\t\tif (nb_entries == max)\n+\t\t\t\tbatch.budget_limited = true;\n+\t\t\tcached_cons -= nr_frags;\n \t\t}\n-\t\tnb_entries++;\n \t}\n \n-\tcached_cons -= nr_frags;\n+\treleased = cached_cons - q-\u003ecached_cons;\n \t/* Release valid plus any invalid entries */\n-\txskq_cons_release_n(q, cached_cons - q-\u003ecached_cons);\n-\treturn total_descs;\n+\txskq_cons_release_n(q, released);\n+\tbatch.consumed_descs = released;\n+\treturn batch;\n }\n \n /* Functions for consumers */\ndiff --git a/tools/testing/selftests/bpf/prog_tests/test_xsk.c b/tools/testing/selftests/bpf/prog_tests/test_xsk.c\nindex 6eb9096d084c01..7abb4935edf9ad 100644\n--- a/tools/testing/selftests/bpf/prog_tests/test_xsk.c\n+++ b/tools/testing/selftests/bpf/prog_tests/test_xsk.c\n@@ -427,14 +427,14 @@ static u32 pkt_nb_frags(u32 frame_size, struct pkt_stream *pkt_stream, struct pk\n \t}\n \n \t/* Search for the end of the packet in verbatim mode */\n-\tif (!pkt_continues(pkt-\u003eoptions) || !pkt-\u003evalid)\n+\tif (!pkt_continues(pkt-\u003eoptions))\n \t\treturn nb_frags;\n \n \tnext_frag = pkt_stream-\u003ecurrent_pkt_nb;\n \tpkt++;\n \twhile (next_frag++ \u003c pkt_stream-\u003enb_pkts) {\n \t\tnb_frags++;\n-\t\tif (!pkt_continues(pkt-\u003eoptions) || !pkt-\u003evalid)\n+\t\tif (!pkt_continues(pkt-\u003eoptions))\n \t\t\tbreak;\n \t\tpkt++;\n \t}\n@@ -665,11 +665,11 @@ static struct pkt_stream *__pkt_stream_generate_custom(struct ifobject *ifobj, s\n \t\t\tif (!frame-\u003evalid || !pkt_continues(frame-\u003eoptions))\n \t\t\t\tpayload++;\n \t\t} else {\n-\t\t\tif (frame-\u003evalid)\n+\t\t\tif (frame-\u003evalid) {\n \t\t\t\tlen += frame-\u003elen;\n-\t\t\tif (frame-\u003evalid \u0026\u0026 pkt_continues(frame-\u003eoptions))\n-\t\t\t\tcontinue;\n-\n+\t\t\t\tif (pkt_continues(frame-\u003eoptions))\n+\t\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tpkt-\u003epkt_nb = pkt_nb;\n \t\t\tpkt-\u003elen = len;\n \t\t\tpkt-\u003evalid = frame-\u003evalid;\n@@ -1209,6 +1209,7 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk,\n \tfor (i = 0; i \u003c xsk-\u003ebatch_size; i++) {\n \t\tstruct pkt *pkt = pkt_stream_get_next_tx_pkt(pkt_stream);\n \t\tu32 nb_frags_left, nb_frags, bytes_written = 0;\n+\t\tstruct pkt *first_pkt = pkt;\n \n \t\tif (!pkt)\n \t\t\tbreak;\n@@ -1253,6 +1254,8 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk,\n \t\tif (pkt \u0026\u0026 pkt-\u003evalid) {\n \t\t\tvalid_pkts++;\n \t\t\tvalid_frags += nb_frags;\n+\t\t} else if (pkt_stream-\u003everbatim \u0026\u0026 pkt_continues(first_pkt-\u003eoptions)) {\n+\t\t\tvalid_frags += nb_frags;\n \t\t}\n \t}\n \n@@ -2099,13 +2102,16 @@ int testapp_invalid_desc_mb(struct test_spec *test)\n \t\t{0, 0, 0, false, 0},\n \t\t/* Invalid address in the second frame */\n \t\t{0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},\n-\t\t{umem_sz, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},\n+\t\t{umem_sz * 2, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},\n+\t\t{0, MIN_PKT_SIZE, 0, false, 0},\n \t\t/* Invalid len in the middle */\n \t\t{0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},\n \t\t{0, XSK_UMEM__INVALID_FRAME_SIZE, 0, false, XDP_PKT_CONTD},\n+\t\t{0, MIN_PKT_SIZE, 0, false, 0},\n \t\t/* Invalid options in the middle */\n \t\t{0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},\n \t\t{0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XSK_DESC__INVALID_OPTION},\n+\t\t{0, MIN_PKT_SIZE, 0, false, 0},\n \t\t/* Transmit 2 frags, receive 3 */\n \t\t{0, XSK_UMEM__MAX_FRAME_SIZE, 0, true, XDP_PKT_CONTD},\n \t\t{0, XSK_UMEM__MAX_FRAME_SIZE, 0, true, 0},\n@@ -2117,8 +2123,8 @@ int testapp_invalid_desc_mb(struct test_spec *test)\n \n \tif (umem-\u003eunaligned_mode) {\n \t\t/* Crossing a chunk boundary allowed */\n-\t\tpkts[12].valid = true;\n-\t\tpkts[13].valid = true;\n+\t\tpkts[15].valid = true;\n+\t\tpkts[16].valid = true;\n \t}\n \n \ttest-\u003emtu = MAX_ETH_JUMBO_SIZE;\n@@ -2270,7 +2276,7 @@ int testapp_too_many_frags(struct test_spec *test)\n \t\tmax_frags += 1;\n \t}\n \n-\tpkts = calloc(2 * max_frags + 2, sizeof(struct pkt));\n+\tpkts = calloc(2 * max_frags + 3, sizeof(struct pkt));\n \tif (!pkts)\n \t\treturn TEST_FAILURE;\n \n@@ -2288,24 +2294,30 @@ int testapp_too_many_frags(struct test_spec *test)\n \t}\n \tpkts[max_frags].options = 0;\n \n-\t/* An invalid packet with the max amount of frags but signals packet\n-\t * continues on the last frag\n-\t */\n-\tfor (i = max_frags + 1; i \u003c 2 * max_frags + 1; i++) {\n+\t/* An invalid packet with the max + 1 amount of frags */\n+\tfor (i = max_frags + 1; i \u003c 2 * max_frags + 2; i++) {\n \t\tpkts[i].len = MIN_PKT_SIZE;\n \t\tpkts[i].options = XDP_PKT_CONTD;\n-\t\tpkts[i].valid = false;\n+\t\tpkts[i].valid = true;\n \t}\n+\tpkts[2 * max_frags + 1].options = 0;\n \n \t/* Valid packet for synch */\n-\tpkts[2 * max_frags + 1].len = MIN_PKT_SIZE;\n-\tpkts[2 * max_frags + 1].valid = true;\n+\tpkts[2 * max_frags + 2].len = MIN_PKT_SIZE;\n+\tpkts[2 * max_frags + 2].valid = true;\n \n-\tif (pkt_stream_generate_custom(test, pkts, 2 * max_frags + 2)) {\n+\tif (pkt_stream_generate_custom(test, pkts, 2 * max_frags + 3)) {\n \t\tfree(pkts);\n \t\treturn TEST_FAILURE;\n \t}\n \n+\t/* The generated Tx stream must keep the too-big packet valid so that\n+\t * __send_pkts() accounts its descriptors in outstanding_tx. The Rx\n+\t * stream, however, must not expect this packet on the wire.\n+\t */\n+\ttest-\u003eifobj_rx-\u003exsk-\u003epkt_stream-\u003epkts[2].valid = false;\n+\ttest-\u003eifobj_rx-\u003exsk-\u003epkt_stream-\u003enb_valid_entries--;\n+\n \tret = testapp_validate_traffic(test);\n \tfree(pkts);\n \treturn ret;\n"
}

2/1 2026/07/11 17:33 agent patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
{
  "EnableConfigs": [
    "XDP_SOCKETS"
  ],
  "FocusSymbols": [
    "xsk_tx_completed",
    "xsk_tx_commit_batch",
    "__xsk_tx_peek_release_desc_batch",
    "xsk_tx_peek_release_shared_desc_batch",
    "xsk_tx_peek_release_desc_batch",
    "xsk_cq_submit_addr_single_locked",
    "xsk_drop_skb",
    "xsk_build_skb_zerocopy",
    "xsk_build_skb",
    "__xsk_generic_xmit",
    "xp_alloc_tx_descs"
  ],
  "Reasoning": "The patch modifies the AF_XDP multi-buffer (SG) packet transmission logic, introducing batching and reclaim descriptors to handle invalid descriptors and boundaries correctly. It modifies core XDP socket code in net/xdp/xsk.c and net/xdp/xsk_queue.h. This is reachable and functional code that should be fuzzed.",
  "WorthFuzzing": true
}

Instruction:
You are an expert Linux kernel maintainer.
Your job is to review a provided patch series and determine
if it makes functional changes to the kernel that should be fuzzed.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively
use your code access tools to examine the actual source code and confirm any assumptions.

Return WorthFuzzing=false if the patch only contains:
- Modifications to Documentation/, Kconfig files, or code comments.
- Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints.
- Changes to numeric constants or macros that do not functionally alter execution flow.
- Code paths that are impossible to reach in virtualized environments like GCE or QEMU,
even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim).

If it modifies reachable core kernel logic, drivers, or architectures, use your code search
tools to verify the code can be executed, then return WorthFuzzing=true.

When returning WorthFuzzing=true, you MUST ALSO:
1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols.
   Avoid listing generic hot-path functions to prevent skewed test distributions.
2. Identify any specific CONFIG_ options required to properly test this new/modified feature.
   Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions.
   Do not list too generic configs (we already have them enabled). Only list those that
   specifically cover the modified code. List them in the EnableConfigs output array,
   and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
For your convenience, here is the diff of the changes:
commit 330d4f7ebc1aef7966ab39eed9fda4a759908fe8
Author: syz-cluster <triage@syzkaller.com>
Date:   Sat Jul 11 17:33:44 2026 +0000

    syz-cluster: applied patch under review

diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
index ebac60a3d8a17b..8b51876efbed1a 100644
--- a/include/net/xdp_sock.h
+++ b/include/net/xdp_sock.h
@@ -80,6 +80,7 @@ struct xdp_sock {
 	 * call of __xsk_generic_xmit().
 	 */
 	struct sk_buff *skb;
+	bool drain_cont;
 
 	struct list_head map_list;
 	/* Protects map_list */
diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h
index ccb3b350001f24..fb59e205ac7d7e 100644
--- a/include/net/xsk_buff_pool.h
+++ b/include/net/xsk_buff_pool.h
@@ -78,6 +78,9 @@ struct xsk_buff_pool {
 	u32 chunk_size;
 	u32 chunk_shift;
 	u32 frame_len;
+	u32 tx_descs_nentries;
+	u32 reclaim_descs;
+	u32 tx_zc_pending_descs;
 	u32 xdp_zc_max_segs;
 	u8 tx_metadata_len; /* inherited from umem */
 	u8 cached_need_wakeup;
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index b970f30ea9b9d8..7d8b42c4c214ba 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -499,6 +499,23 @@ void __xsk_map_flush(struct list_head *flush_list)
 
 void xsk_tx_completed(struct xsk_buff_pool *pool, u32 nb_entries)
 {
+	u32 reclaim_descs = READ_ONCE(pool->reclaim_descs);
+
+	if (unlikely(reclaim_descs)) {
+		u32 pending_descs = READ_ONCE(pool->tx_zc_pending_descs);
+
+		if (nb_entries < pending_descs) {
+			WRITE_ONCE(pool->tx_zc_pending_descs,
+				   pending_descs - nb_entries);
+			xskq_prod_submit_n(pool->cq, nb_entries);
+			return;
+		}
+
+		WRITE_ONCE(pool->tx_zc_pending_descs, 0);
+		nb_entries += reclaim_descs;
+		WRITE_ONCE(pool->reclaim_descs, 0);
+	}
+
 	xskq_prod_submit_n(pool->cq, nb_entries);
 }
 EXPORT_SYMBOL(xsk_tx_completed);
@@ -574,22 +591,169 @@ static u32 xsk_tx_peek_release_fallback(struct xsk_buff_pool *pool, u32 max_entr
 	return nb_pkts;
 }
 
+static void xsk_tx_commit_batch(struct xsk_buff_pool *pool,
+				struct xsk_tx_batch *batch,
+				u32 cq_cached_prod)
+{
+	u32 nb_descs = xsk_tx_batch_cq_descs(batch);
+
+	if (!nb_descs)
+		return;
+
+	xskq_prod_write_addr_batch(pool->cq, pool->tx_descs, nb_descs);
+
+	if (unlikely(batch->reclaim_descs)) {
+		u32 cq_pending_descs;
+
+		/* CQ is positional. Descriptors already written but not
+		 * submitted must complete before any reclaim-only descriptors
+		 * appended below.
+		 */
+		cq_pending_descs = cq_cached_prod - xskq_get_prod(pool->cq);
+
+		WRITE_ONCE(pool->tx_zc_pending_descs, batch->tx_descs + cq_pending_descs);
+		WRITE_ONCE(pool->reclaim_descs, batch->reclaim_descs);
+		if (unlikely(!pool->tx_zc_pending_descs))
+			xsk_tx_completed(pool, 0);
+	}
+}
+
+static struct xsk_tx_batch
+__xsk_tx_peek_release_desc_batch(struct xsk_buff_pool *pool, struct xdp_sock *xs,
+				 struct xdp_desc *descs, u32 max_descs)
+{
+	struct xsk_tx_batch batch = {};
+	u32 entries;
+
+	entries = xskq_cons_nb_entries(xs->tx, max_descs);
+	if (!entries)
+		return batch;
+
+	batch = xskq_cons_read_desc_batch(xs, pool, descs, entries);
+	if (!xsk_tx_batch_cq_descs(&batch)) {
+		xs->tx->queue_empty_descs++;
+		if (batch.consumed_descs) {
+			__xskq_cons_release(xs->tx);
+			xs->sk.sk_write_space(&xs->sk);
+		}
+		return batch;
+	}
+
+	__xskq_cons_release(xs->tx);
+	xs->sk.sk_write_space(&xs->sk);
+	return batch;
+}
+
+static struct xsk_tx_batch
+xsk_tx_peek_release_shared_desc_batch(struct xsk_buff_pool *pool, u32 max_descs)
+{
+	u32 cq_descs_before, cq_descs_after;
+	struct xsk_tx_batch sum_batch = {};
+	bool budget_exhausted;
+	u32 per_socket_budget;
+	struct xdp_sock *xs;
+
+	max_descs = xskq_prod_nb_free(pool->cq, max_descs);
+	if (!max_descs)
+		return sum_batch;
+
+	/* The fairness quota must allow one maximum-sized valid packet. */
+	per_socket_budget = max_t(u32, MAX_PER_SOCKET_BUDGET,
+				  pool->xdp_zc_max_segs);
+
+again:
+	budget_exhausted = false;
+	cq_descs_before = xsk_tx_batch_cq_descs(&sum_batch);
+	list_for_each_entry_rcu(xs, &pool->xsk_tx_list, tx_list) {
+		u32 budget, budget_left, offset, remaining;
+		struct xsk_tx_batch curr_batch;
+
+		/* Once reclaim-only descriptors have been appended to the CQ address
+		 * area, do not append driver-visible Tx descriptors from another
+		 * socket after them. xsk_tx_completed() relies on all driver-visible
+		 * descriptors preceding all reclaim-only descriptors in CQ order.
+		 */
+		if (sum_batch.reclaim_descs)
+			break;
+
+		/* be gentle when playing with pool->tx_descs */
+		offset = xsk_tx_batch_cq_descs(&sum_batch);
+		if (offset >= max_descs)
+			break;
+
+		if (xs->tx_budget_spent >= per_socket_budget) {
+			if (xskq_cons_nb_entries(xs->tx, 1))
+				budget_exhausted = true;
+			continue;
+		}
+
+		budget_left = per_socket_budget - xs->tx_budget_spent;
+		remaining = max_descs - offset;
+		budget = min(remaining, budget_left);
+
+		curr_batch = __xsk_tx_peek_release_desc_batch(pool, xs,
+							      pool->tx_descs + offset,
+							      budget);
+		if (!xsk_tx_batch_cq_descs(&curr_batch)) {
+			if (curr_batch.budget_limited && budget_left < remaining)
+				budget_exhausted = true;
+			xs->tx_budget_spent += curr_batch.consumed_descs;
+			continue;
+		}
+
+		xs->tx_budget_spent += curr_batch.consumed_descs;
+		sum_batch.tx_descs += curr_batch.tx_descs;
+		sum_batch.reclaim_descs += curr_batch.reclaim_descs;
+	}
+
+	cq_descs_after = xsk_tx_batch_cq_descs(&sum_batch);
+
+	if (sum_batch.reclaim_descs || cq_descs_after >= max_descs)
+		return sum_batch;
+
+	/* Continue filling the batch while this pass made progress */
+	if (cq_descs_before != cq_descs_after)
+		goto again;
+
+	if (!budget_exhausted)
+		return sum_batch;
+
+	list_for_each_entry_rcu(xs, &pool->xsk_tx_list, tx_list)
+		xs->tx_budget_spent = 0;
+	goto again;
+}
+
 u32 xsk_tx_peek_release_desc_batch(struct xsk_buff_pool *pool, u32 nb_pkts)
 {
+	struct xsk_tx_batch batch = {};
 	struct xdp_sock *xs;
+	u32 cq_cached_prod;
 
 	rcu_read_lock();
+	if (unlikely(READ_ONCE(pool->reclaim_descs)))
+		goto out;
+	nb_pkts = min(nb_pkts, pool->tx_descs_nentries);
+	if (!nb_pkts)
+		goto out;
 	if (!list_is_singular(&pool->xsk_tx_list)) {
-		/* Fallback to the non-batched version */
+		/* Keep the legacy one-descriptor fallback for non-SG users.  The
+		 * shared SG path needs packet-framed parsing so invalid/overflowed
+		 * multi-buffer packets are drained as a unit.
+		 */
+		if (pool->umem->flags & XDP_UMEM_SG_FLAG) {
+			batch = xsk_tx_peek_release_shared_desc_batch(pool, nb_pkts);
+			cq_cached_prod = pool->cq->cached_prod;
+			xsk_tx_commit_batch(pool, &batch, cq_cached_prod);
+			goto out;
+		}
+
 		rcu_read_unlock();
 		return xsk_tx_peek_release_fallback(pool, nb_pkts);
 	}
 
 	xs = list_first_or_null_rcu(&pool->xsk_tx_list, struct xdp_sock, tx_list);
-	if (!xs) {
-		nb_pkts = 0;
+	if (!xs)
 		goto out;
-	}
 
 	nb_pkts = xskq_cons_nb_entries(xs->tx, nb_pkts);
 
@@ -603,19 +767,18 @@ u32 xsk_tx_peek_release_desc_batch(struct xsk_buff_pool *pool, u32 nb_pkts)
 	if (!nb_pkts)
 		goto out;
 
-	nb_pkts = xskq_cons_read_desc_batch(xs->tx, pool, nb_pkts);
-	if (!nb_pkts) {
-		xs->tx->queue_empty_descs++;
+	batch = __xsk_tx_peek_release_desc_batch(pool, xs, pool->tx_descs,
+						 nb_pkts);
+	nb_pkts = xsk_tx_batch_cq_descs(&batch);
+	if (!nb_pkts)
 		goto out;
-	}
 
-	__xskq_cons_release(xs->tx);
-	xskq_prod_write_addr_batch(pool->cq, pool->tx_descs, nb_pkts);
-	xs->sk.sk_write_space(&xs->sk);
+	cq_cached_prod = pool->cq->cached_prod;
+	xsk_tx_commit_batch(pool, &batch, cq_cached_prod);
 
 out:
 	rcu_read_unlock();
-	return nb_pkts;
+	return batch.tx_descs;
 }
 EXPORT_SYMBOL(xsk_tx_peek_release_desc_batch);
 
@@ -737,6 +900,19 @@ static void xsk_cq_submit_addr_locked(struct xsk_buff_pool *pool,
 	spin_unlock_irqrestore(&pool->cq_prod_lock, flags);
 }
 
+static void xsk_cq_submit_addr_single_locked(struct xsk_buff_pool *pool,
+					     struct xdp_desc *desc)
+{
+	unsigned long flags;
+	u32 idx;
+
+	spin_lock_irqsave(&pool->cq_prod_lock, flags);
+	idx = xskq_get_prod(pool->cq);
+	xskq_prod_write_addr(pool->cq, idx, desc->addr);
+	xskq_prod_submit_n(pool->cq, 1);
+	spin_unlock_irqrestore(&pool->cq_prod_lock, flags);
+}
+
 static void xsk_cq_cancel_locked(struct xsk_buff_pool *pool, u32 n)
 {
 	spin_lock(&pool->cq->cq_cached_prod_lock);
@@ -794,8 +970,11 @@ static void xsk_consume_skb(struct sk_buff *skb)
 
 static void xsk_drop_skb(struct sk_buff *skb)
 {
-	xdp_sk(skb->sk)->tx->invalid_descs += xsk_get_num_desc(skb);
-	xsk_consume_skb(skb);
+	struct xdp_sock *xs = xdp_sk(skb->sk);
+
+	xs->tx->invalid_descs += xsk_get_num_desc(skb);
+	consume_skb(skb);
+	xs->skb = NULL;
 }
 
 static int xsk_skb_metadata(struct sk_buff *skb, void *buffer,
@@ -877,7 +1056,7 @@ static struct sk_buff *xsk_build_skb_zerocopy(struct xdp_sock *xs,
 			return ERR_PTR(-ENOMEM);
 
 		/* in case of -EOVERFLOW that could happen below,
-		 * xsk_consume_skb() will release this node as whole skb
+		 * xsk_drop_skb() will release this node as whole skb
 		 * would be dropped, which implies freeing all list elements
 		 */
 		xsk_addr->addrs[xsk_addr->num_descs] = desc->addr;
@@ -969,6 +1148,8 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
 				goto free_err;
 			}
 
+			xsk_addr->addrs[xsk_addr->num_descs] = desc->addr;
+
 			if (unlikely(nr_frags == (MAX_SKB_FRAGS - 1) && xp_mb_desc(desc))) {
 				err = -EOVERFLOW;
 				goto free_err;
@@ -986,8 +1167,6 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
 
 			skb_add_rx_frag(skb, nr_frags, page, 0, len, PAGE_SIZE);
 			refcount_add(PAGE_SIZE, &xs->sk.sk_wmem_alloc);
-
-			xsk_addr->addrs[xsk_addr->num_descs] = desc->addr;
 		}
 	}
 
@@ -1060,11 +1239,22 @@ static int __xsk_generic_xmit(struct sock *sk)
 			goto out;
 		}
 
+		if (unlikely(xs->drain_cont)) {
+			xsk_cq_submit_addr_single_locked(xs->pool, &desc);
+
+			xs->tx->invalid_descs++;
+			xskq_cons_release(xs->tx);
+			xs->drain_cont = xp_mb_desc(&desc);
+			continue;
+		}
+
 		skb = xsk_build_skb(xs, &desc);
 		if (IS_ERR(skb)) {
 			err = PTR_ERR(skb);
 			if (err != -EOVERFLOW)
 				goto out;
+			if (xp_mb_desc(&desc))
+				xs->drain_cont = true;
 			err = 0;
 			continue;
 		}
@@ -1098,9 +1288,24 @@ static int __xsk_generic_xmit(struct sock *sk)
 	}
 
 	if (xskq_has_descs(xs->tx)) {
+		bool reclaim_desc = xs->skb || xs->drain_cont;
+
+		if (reclaim_desc) {
+			err = xsk_cq_reserve_locked(xs->pool);
+			if (err) {
+				err = -EAGAIN;
+				goto out;
+			}
+		}
+
 		if (xs->skb)
 			xsk_drop_skb(xs->skb);
+
+		if (reclaim_desc)
+			xsk_cq_submit_addr_single_locked(xs->pool, &desc);
+
 		xskq_cons_release(xs->tx);
+		xs->drain_cont = xp_mb_desc(&desc);
 	}
 
 out:
diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index 1f28a9641571e4..b862addcd8fdaf 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -48,6 +48,7 @@ int xp_alloc_tx_descs(struct xsk_buff_pool *pool, struct xdp_sock *xs)
 	if (!pool->tx_descs)
 		return -ENOMEM;
 
+	pool->tx_descs_nentries = xs->tx->nentries;
 	return 0;
 }
 
diff --git a/net/xdp/xsk_queue.h b/net/xdp/xsk_queue.h
index 3e3fbb73d23e2f..a15ff1929db623 100644
--- a/net/xdp/xsk_queue.h
+++ b/net/xdp/xsk_queue.h
@@ -58,6 +58,18 @@ struct parsed_desc {
 	u32 valid;
 };
 
+struct xsk_tx_batch {
+	u32 tx_descs;
+	u32 reclaim_descs;
+	u32 consumed_descs;
+	bool budget_limited;
+};
+
+static inline u32 xsk_tx_batch_cq_descs(const struct xsk_tx_batch *batch)
+{
+	return batch->tx_descs + batch->reclaim_descs;
+}
+
 /* The structure of the shared state of the rings are a simple
  * circular buffer, as outlined in
  * Documentation/core-api/circular-buffers.rst. For the Rx and
@@ -263,17 +275,18 @@ static inline void parse_desc(struct xsk_queue *q, struct xsk_buff_pool *pool,
 	parsed->mb = xp_mb_desc(desc);
 }
 
-static inline
-u32 xskq_cons_read_desc_batch(struct xsk_queue *q, struct xsk_buff_pool *pool,
-			      u32 max)
+static inline struct xsk_tx_batch
+xskq_cons_read_desc_batch(struct xdp_sock *xs, struct xsk_buff_pool *pool,
+			  struct xdp_desc *descs, u32 max)
 {
-	u32 cached_cons = q->cached_cons, nb_entries = 0;
-	struct xdp_desc *descs = pool->tx_descs;
-	u32 total_descs = 0, nr_frags = 0;
+	bool drain = READ_ONCE(xs->drain_cont);
+	u32 cached_cons, nb_entries = 0, released;
+	struct xsk_tx_batch batch = {};
+	struct xsk_queue *q = xs->tx;
+	u32 nr_frags = 0;
+
+	cached_cons = q->cached_cons;
 
-	/* track first entry, if stumble upon *any* invalid descriptor, rewind
-	 * current packet that consists of frags and stop the processing
-	 */
 	while (cached_cons != q->cached_prod && nb_entries < max) {
 		struct xdp_rxtx_ring *ring = (struct xdp_rxtx_ring *)q->ring;
 		u32 idx = cached_cons & q->ring_mask;
@@ -282,26 +295,49 @@ u32 xskq_cons_read_desc_batch(struct xsk_queue *q, struct xsk_buff_pool *pool,
 		descs[nb_entries] = ring->desc[idx];
 		cached_cons++;
 		parse_desc(q, pool, &descs[nb_entries], &parsed);
-		if (unlikely(!parsed.valid))
-			break;
+		if (unlikely(!parsed.valid)) {
+			if (!drain && !nr_frags && !parsed.mb)
+				break;
+
+			drain = true;
+		}
+
+		nr_frags++;
+		nb_entries++;
 
 		if (likely(!parsed.mb)) {
-			total_descs += (nr_frags + 1);
-			nr_frags = 0;
-		} else {
-			nr_frags++;
-			if (nr_frags == pool->xdp_zc_max_segs) {
+			if (unlikely(drain)) {
+				batch.reclaim_descs = nr_frags;
+				WRITE_ONCE(xs->drain_cont, false);
 				nr_frags = 0;
 				break;
 			}
+
+			batch.tx_descs += nr_frags;
+			nr_frags = 0;
+			continue;
+		}
+
+		if (nr_frags == pool->xdp_zc_max_segs)
+			drain = true;
+	}
+
+	if (nr_frags) {
+		if (drain) {
+			batch.reclaim_descs = nr_frags;
+			WRITE_ONCE(xs->drain_cont, true);
+		} else {
+			if (nb_entries == max)
+				batch.budget_limited = true;
+			cached_cons -= nr_frags;
 		}
-		nb_entries++;
 	}
 
-	cached_cons -= nr_frags;
+	released = cached_cons - q->cached_cons;
 	/* Release valid plus any invalid entries */
-	xskq_cons_release_n(q, cached_cons - q->cached_cons);
-	return total_descs;
+	xskq_cons_release_n(q, released);
+	batch.consumed_descs = released;
+	return batch;
 }
 
 /* Functions for consumers */
diff --git a/tools/testing/selftests/bpf/prog_tests/test_xsk.c b/tools/testing/selftests/bpf/prog_tests/test_xsk.c
index 6eb9096d084c01..7abb4935edf9ad 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_xsk.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_xsk.c
@@ -427,14 +427,14 @@ static u32 pkt_nb_frags(u32 frame_size, struct pkt_stream *pkt_stream, struct pk
 	}
 
 	/* Search for the end of the packet in verbatim mode */
-	if (!pkt_continues(pkt->options) || !pkt->valid)
+	if (!pkt_continues(pkt->options))
 		return nb_frags;
 
 	next_frag = pkt_stream->current_pkt_nb;
 	pkt++;
 	while (next_frag++ < pkt_stream->nb_pkts) {
 		nb_frags++;
-		if (!pkt_continues(pkt->options) || !pkt->valid)
+		if (!pkt_continues(pkt->options))
 			break;
 		pkt++;
 	}
@@ -665,11 +665,11 @@ static struct pkt_stream *__pkt_stream_generate_custom(struct ifobject *ifobj, s
 			if (!frame->valid || !pkt_continues(frame->options))
 				payload++;
 		} else {
-			if (frame->valid)
+			if (frame->valid) {
 				len += frame->len;
-			if (frame->valid && pkt_continues(frame->options))
-				continue;
-
+				if (pkt_continues(frame->options))
+					continue;
+			}
 			pkt->pkt_nb = pkt_nb;
 			pkt->len = len;
 			pkt->valid = frame->valid;
@@ -1209,6 +1209,7 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk,
 	for (i = 0; i < xsk->batch_size; i++) {
 		struct pkt *pkt = pkt_stream_get_next_tx_pkt(pkt_stream);
 		u32 nb_frags_left, nb_frags, bytes_written = 0;
+		struct pkt *first_pkt = pkt;
 
 		if (!pkt)
 			break;
@@ -1253,6 +1254,8 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk,
 		if (pkt && pkt->valid) {
 			valid_pkts++;
 			valid_frags += nb_frags;
+		} else if (pkt_stream->verbatim && pkt_continues(first_pkt->options)) {
+			valid_frags += nb_frags;
 		}
 	}
 
@@ -2099,13 +2102,16 @@ int testapp_invalid_desc_mb(struct test_spec *test)
 		{0, 0, 0, false, 0},
 		/* Invalid address in the second frame */
 		{0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
-		{umem_sz, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
+		{umem_sz * 2, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
+		{0, MIN_PKT_SIZE, 0, false, 0},
 		/* Invalid len in the middle */
 		{0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
 		{0, XSK_UMEM__INVALID_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
+		{0, MIN_PKT_SIZE, 0, false, 0},
 		/* Invalid options in the middle */
 		{0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
 		{0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XSK_DESC__INVALID_OPTION},
+		{0, MIN_PKT_SIZE, 0, false, 0},
 		/* Transmit 2 frags, receive 3 */
 		{0, XSK_UMEM__MAX_FRAME_SIZE, 0, true, XDP_PKT_CONTD},
 		{0, XSK_UMEM__MAX_FRAME_SIZE, 0, true, 0},
@@ -2117,8 +2123,8 @@ int testapp_invalid_desc_mb(struct test_spec *test)
 
 	if (umem->unaligned_mode) {
 		/* Crossing a chunk boundary allowed */
-		pkts[12].valid = true;
-		pkts[13].valid = true;
+		pkts[15].valid = true;
+		pkts[16].valid = true;
 	}
 
 	test->mtu = MAX_ETH_JUMBO_SIZE;
@@ -2270,7 +2276,7 @@ int testapp_too_many_frags(struct test_spec *test)
 		max_frags += 1;
 	}
 
-	pkts = calloc(2 * max_frags + 2, sizeof(struct pkt));
+	pkts = calloc(2 * max_frags + 3, sizeof(struct pkt));
 	if (!pkts)
 		return TEST_FAILURE;
 
@@ -2288,24 +2294,30 @@ int testapp_too_many_frags(struct test_spec *test)
 	}
 	pkts[max_frags].options = 0;
 
-	/* An invalid packet with the max amount of frags but signals packet
-	 * continues on the last frag
-	 */
-	for (i = max_frags + 1; i < 2 * max_frags + 1; i++) {
+	/* An invalid packet with the max + 1 amount of frags */
+	for (i = max_frags + 1; i < 2 * max_frags + 2; i++) {
 		pkts[i].len = MIN_PKT_SIZE;
 		pkts[i].options = XDP_PKT_CONTD;
-		pkts[i].valid = false;
+		pkts[i].valid = true;
 	}
+	pkts[2 * max_frags + 1].options = 0;
 
 	/* Valid packet for synch */
-	pkts[2 * max_frags + 1].len = MIN_PKT_SIZE;
-	pkts[2 * max_frags + 1].valid = true;
+	pkts[2 * max_frags + 2].len = MIN_PKT_SIZE;
+	pkts[2 * max_frags + 2].valid = true;
 
-	if (pkt_stream_generate_custom(test, pkts, 2 * max_frags + 2)) {
+	if (pkt_stream_generate_custom(test, pkts, 2 * max_frags + 3)) {
 		free(pkts);
 		return TEST_FAILURE;
 	}
 
+	/* The generated Tx stream must keep the too-big packet valid so that
+	 * __send_pkts() accounts its descriptors in outstanding_tx. The Rx
+	 * stream, however, must not expect this packet on the wire.
+	 */
+	test->ifobj_rx->xsk->pkt_stream->pkts[2].valid = false;
+	test->ifobj_rx->xsk->pkt_stream->nb_valid_entries--;
+
 	ret = testapp_validate_traffic(test);
 	free(pkts);
 	return ret;

3/2 2026/07/11 17:33 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 9906
							output: 57
							thoughts: 531
						

Thoughts:
**Analyzing the AF_XDP Multi-Buffer Patch**

Okay, so I've got this patch series touching several key files related to AF_XDP: `xdp_sock.h`, `xsk_buff_pool.h`, `xsk.c`, `xsk_buff_pool.c`, `xsk_queue.h`, and a selftest. This is all about handling multi-buffer or SG (scatter-gather) packets within AF_XDP, which piques my interest immediately. It's touching core logic. I'm seeing additions of variables like `drain_cont`, `tx_descs_nentries`, `reclaim_descs`, and `tx_zc_pending_descs` in the `xdp_sock` and `xsk_buff_pool` structures, which indicates changes in descriptor management.

First, let's confirm AF_XDP itself is reachable and functioning as expected – good, that's a baseline. Now, should we fuzz this? Absolutely, considering this modifies the fundamental multi-buffer TX path. This is definitely worth the effort.

Now, let's identify the specific functions that the patch modifies. It's impacting critical parts of the XDP data path. I've got a list here: `xsk_tx_completed`, and some new ones like `xsk_tx_commit_batch`, `__xsk_tx_peek_release_desc_batch`, `xsk_tx_peek_release_shared_desc_batch` and `xsk_cq_submit_addr_single_locked`. It's also making changes to `xsk_drop_skb`, and the SKB building functions `xsk_build_skb_zerocopy` and `xsk_build_skb`. Finally, I see `__xsk_generic_xmit`, `xp_alloc_tx_descs`, and `xskq_cons_read_desc_batch` in the mix.

Time to drill down. I'm going to quickly grep through `net/xdp/xsk.c` and `net/xdp/xsk_queue.h` to confirm the exact function names and get a clearer picture of the code being changed. Understanding the control flow around these functions is crucial for building a strong fuzzing strategy.



4/2 2026/07/11 17:33 tool grepper
0m Args:
{
  "Expression": "^(static )?(void|u32|int|struct [a-z_]+ \\*) [a-z_]+\\(",
  "PathPrefix": "net/xdp/xsk.c"
}

Results:
{
  "Output": "net/xdp/xsk.c=49=static struct kmem_cache *xsk_tx_generic_cache;\nnet/xdp/xsk.c-50-\nnet/xdp/xsk.c:51:void xsk_set_rx_need_wakeup(struct xsk_buff_pool *pool)\nnet/xdp/xsk.c-52-{\n--\nnet/xdp/xsk.c=59=EXPORT_SYMBOL(xsk_set_rx_need_wakeup);\nnet/xdp/xsk.c-60-\nnet/xdp/xsk.c:61:void xsk_set_tx_need_wakeup(struct xsk_buff_pool *pool)\nnet/xdp/xsk.c-62-{\n--\nnet/xdp/xsk.c=76=EXPORT_SYMBOL(xsk_set_tx_need_wakeup);\nnet/xdp/xsk.c-77-\nnet/xdp/xsk.c:78:void xsk_clear_rx_need_wakeup(struct xsk_buff_pool *pool)\nnet/xdp/xsk.c-79-{\n--\nnet/xdp/xsk.c=86=EXPORT_SYMBOL(xsk_clear_rx_need_wakeup);\nnet/xdp/xsk.c-87-\nnet/xdp/xsk.c:88:void xsk_clear_tx_need_wakeup(struct xsk_buff_pool *pool)\nnet/xdp/xsk.c-89-{\n--\nnet/xdp/xsk.c=121=EXPORT_SYMBOL(xsk_get_pool_from_qid);\nnet/xdp/xsk.c-122-\nnet/xdp/xsk.c:123:static void __xsk_clear_pool_at_qid(struct net_device *dev, u16 queue_id)\nnet/xdp/xsk.c-124-{\n--\nnet/xdp/xsk.c-130-\nnet/xdp/xsk.c:131:void xsk_clear_pool_at_qid(struct net_device *dev, u16 queue_id)\nnet/xdp/xsk.c-132-{\n--\nnet/xdp/xsk.c-146-\nnet/xdp/xsk.c:147:static int __xsk_reg_pool_at_qid(struct net_device *dev,\nnet/xdp/xsk.c-148-\t\t\t\t struct xsk_buff_pool *pool, u16 queue_id)\n--\nnet/xdp/xsk.c-164- */\nnet/xdp/xsk.c:165:int xsk_reg_pool_at_qid(struct net_device *dev, struct xsk_buff_pool *pool,\nnet/xdp/xsk.c-166-\t\t\tu16 queue_id)\n--\nnet/xdp/xsk.c-190-\nnet/xdp/xsk.c:191:static int __xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff_xsk *xskb, u32 len,\nnet/xdp/xsk.c-192-\t\t\tu32 flags)\n--\nnet/xdp/xsk.c-207-\nnet/xdp/xsk.c:208:static void __xsk_rcv_zc_safe(struct xdp_sock *xs, struct xdp_buff_xsk *xskb,\nnet/xdp/xsk.c-209-\t\t\t      u32 len, u32 flags)\n--\nnet/xdp/xsk.c-218-\nnet/xdp/xsk.c:219:static int xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)\nnet/xdp/xsk.c-220-{\n--\nnet/xdp/xsk.c=260=static void *xsk_copy_xdp_start(struct xdp_buff *from)\n--\nnet/xdp/xsk.c-267-\nnet/xdp/xsk.c:268:static u32 xsk_copy_xdp(void *to, void **from, u32 to_len,\nnet/xdp/xsk.c-269-\t\t\tu32 *from_len, skb_frag_t **frag, u32 rem)\n--\nnet/xdp/xsk.c-295-\nnet/xdp/xsk.c:296:static int __xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)\nnet/xdp/xsk.c-297-{\n--\nnet/xdp/xsk.c=365=static bool xsk_tx_writeable(struct xdp_sock *xs)\n--\nnet/xdp/xsk.c-372-\nnet/xdp/xsk.c:373:static void __xsk_tx_release(struct xdp_sock *xs)\nnet/xdp/xsk.c-374-{\n--\nnet/xdp/xsk.c=390=static bool xsk_dev_queue_valid(const struct xdp_sock *xs,\n--\nnet/xdp/xsk.c-414-\nnet/xdp/xsk.c:415:static int xsk_rcv_check(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)\nnet/xdp/xsk.c-416-{\n--\nnet/xdp/xsk.c-429-\nnet/xdp/xsk.c:430:static void xsk_flush(struct xdp_sock *xs)\nnet/xdp/xsk.c-431-{\n--\nnet/xdp/xsk.c-436-\nnet/xdp/xsk.c:437:int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)\nnet/xdp/xsk.c-438-{\n--\nnet/xdp/xsk.c-452-\nnet/xdp/xsk.c:453:static int xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)\nnet/xdp/xsk.c-454-{\n--\nnet/xdp/xsk.c-472-\nnet/xdp/xsk.c:473:int __xsk_map_redirect(struct xdp_sock *xs, struct xdp_buff *xdp)\nnet/xdp/xsk.c-474-{\n--\nnet/xdp/xsk.c-489-\nnet/xdp/xsk.c:490:void __xsk_map_flush(struct list_head *flush_list)\nnet/xdp/xsk.c-491-{\n--\nnet/xdp/xsk.c-499-\nnet/xdp/xsk.c:500:void xsk_tx_completed(struct xsk_buff_pool *pool, u32 nb_entries)\nnet/xdp/xsk.c-501-{\n--\nnet/xdp/xsk.c=521=EXPORT_SYMBOL(xsk_tx_completed);\nnet/xdp/xsk.c-522-\nnet/xdp/xsk.c:523:void xsk_tx_release(struct xsk_buff_pool *pool)\nnet/xdp/xsk.c-524-{\n--\nnet/xdp/xsk.c=580=EXPORT_SYMBOL(xsk_tx_peek_desc);\nnet/xdp/xsk.c-581-\nnet/xdp/xsk.c:582:static u32 xsk_tx_peek_release_fallback(struct xsk_buff_pool *pool, u32 max_entries)\nnet/xdp/xsk.c-583-{\n--\nnet/xdp/xsk.c-593-\nnet/xdp/xsk.c:594:static void xsk_tx_commit_batch(struct xsk_buff_pool *pool,\nnet/xdp/xsk.c-595-\t\t\t\tstruct xsk_tx_batch *batch,\n--\nnet/xdp/xsk.c=648=xsk_tx_peek_release_shared_desc_batch(struct xsk_buff_pool *pool, u32 max_descs)\n--\nnet/xdp/xsk.c-725-\nnet/xdp/xsk.c:726:u32 xsk_tx_peek_release_desc_batch(struct xsk_buff_pool *pool, u32 nb_pkts)\nnet/xdp/xsk.c-727-{\n--\nnet/xdp/xsk.c=783=EXPORT_SYMBOL(xsk_tx_peek_release_desc_batch);\nnet/xdp/xsk.c-784-\nnet/xdp/xsk.c:785:static int xsk_wakeup(struct xdp_sock *xs, u8 flags)\nnet/xdp/xsk.c-786-{\n--\nnet/xdp/xsk.c-791-\nnet/xdp/xsk.c:792:static int xsk_cq_reserve_locked(struct xsk_buff_pool *pool)\nnet/xdp/xsk.c-793-{\n--\nnet/xdp/xsk.c=826=static struct xsk_addrs *xsk_addrs_alloc(struct sk_buff *skb)\n--\nnet/xdp/xsk.c-838-\nnet/xdp/xsk.c:839:static int xsk_skb_destructor_set_addr(struct sk_buff *skb, u64 addr)\nnet/xdp/xsk.c-840-{\n--\nnet/xdp/xsk.c-850-\nnet/xdp/xsk.c:851:static void xsk_inc_num_desc(struct sk_buff *skb)\nnet/xdp/xsk.c-852-{\n--\nnet/xdp/xsk.c-860-\nnet/xdp/xsk.c:861:static u32 xsk_get_num_desc(struct sk_buff *skb)\nnet/xdp/xsk.c-862-{\n--\nnet/xdp/xsk.c-872-\nnet/xdp/xsk.c:873:static void xsk_cq_submit_addr_locked(struct xsk_buff_pool *pool,\nnet/xdp/xsk.c-874-\t\t\t\t      struct sk_buff *skb)\n--\nnet/xdp/xsk.c-902-\nnet/xdp/xsk.c:903:static void xsk_cq_submit_addr_single_locked(struct xsk_buff_pool *pool,\nnet/xdp/xsk.c-904-\t\t\t\t\t     struct xdp_desc *desc)\n--\nnet/xdp/xsk.c-915-\nnet/xdp/xsk.c:916:static void xsk_cq_cancel_locked(struct xsk_buff_pool *pool, u32 n)\nnet/xdp/xsk.c-917-{\n--\nnet/xdp/xsk.c=923=INDIRECT_CALLABLE_SCOPE\nnet/xdp/xsk.c:924:void xsk_destruct_skb(struct sk_buff *skb)\nnet/xdp/xsk.c-925-{\n--\nnet/xdp/xsk.c-936-\nnet/xdp/xsk.c:937:static int xsk_skb_init_misc(struct sk_buff *skb, struct xdp_sock *xs,\nnet/xdp/xsk.c-938-\t\t\t     u64 addr)\n--\nnet/xdp/xsk.c-952-\nnet/xdp/xsk.c:953:static void xsk_consume_skb(struct sk_buff *skb)\nnet/xdp/xsk.c-954-{\n--\nnet/xdp/xsk.c-970-\nnet/xdp/xsk.c:971:static void xsk_drop_skb(struct sk_buff *skb)\nnet/xdp/xsk.c-972-{\n--\nnet/xdp/xsk.c-979-\nnet/xdp/xsk.c:980:static int xsk_skb_metadata(struct sk_buff *skb, void *buffer,\nnet/xdp/xsk.c-981-\t\t\t    struct xdp_desc *desc, struct xsk_buff_pool *pool,\n--\nnet/xdp/xsk.c=1098=static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,\n--\nnet/xdp/xsk.c-1203-\nnet/xdp/xsk.c:1204:static int __xsk_generic_xmit(struct sock *sk)\nnet/xdp/xsk.c-1205-{\n--\nnet/xdp/xsk.c-1318-\nnet/xdp/xsk.c:1319:static int xsk_generic_xmit(struct sock *sk)\nnet/xdp/xsk.c-1320-{\n--\nnet/xdp/xsk.c=1332=static bool xsk_no_wakeup(struct sock *sk)\n--\nnet/xdp/xsk.c-1342-\nnet/xdp/xsk.c:1343:static int xsk_check_common(struct xdp_sock *xs)\nnet/xdp/xsk.c-1344-{\n--\nnet/xdp/xsk.c-1352-\nnet/xdp/xsk.c:1353:static int __xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len)\nnet/xdp/xsk.c-1354-{\n--\nnet/xdp/xsk.c-1383-\nnet/xdp/xsk.c:1384:static int xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len)\nnet/xdp/xsk.c-1385-{\n--\nnet/xdp/xsk.c-1394-\nnet/xdp/xsk.c:1395:static int __xsk_recvmsg(struct socket *sock, struct msghdr *m, size_t len, int flags)\nnet/xdp/xsk.c-1396-{\n--\nnet/xdp/xsk.c-1420-\nnet/xdp/xsk.c:1421:static int xsk_recvmsg(struct socket *sock, struct msghdr *m, size_t len, int flags)\nnet/xdp/xsk.c-1422-{\n--\nnet/xdp/xsk.c=1432=static __poll_t xsk_poll(struct file *file, struct socket *sock,\n--\nnet/xdp/xsk.c-1464-\nnet/xdp/xsk.c:1465:static int xsk_init_queue(u32 entries, struct xsk_queue **queue,\nnet/xdp/xsk.c-1466-\t\t\t  bool umem_queue)\n--\nnet/xdp/xsk.c-1482-\nnet/xdp/xsk.c:1483:static void xsk_unbind_dev(struct xdp_sock *xs)\nnet/xdp/xsk.c-1484-{\n--\nnet/xdp/xsk.c=1497=static struct xsk_map *xsk_get_map_list_entry(struct xdp_sock *xs,\n--\nnet/xdp/xsk.c-1516-\nnet/xdp/xsk.c:1517:static void xsk_delete_from_maps(struct xdp_sock *xs)\nnet/xdp/xsk.c-1518-{\n--\nnet/xdp/xsk.c-1542-\nnet/xdp/xsk.c:1543:static int xsk_release(struct socket *sock)\nnet/xdp/xsk.c-1544-{\n--\nnet/xdp/xsk.c=1598=static bool xsk_validate_queues(struct xdp_sock *xs)\n--\nnet/xdp/xsk.c-1602-\nnet/xdp/xsk.c:1603:static int xsk_bind(struct socket *sock, struct sockaddr_unsized *addr, int addr_len)\nnet/xdp/xsk.c-1604-{\n--\nnet/xdp/xsk.c=1790=struct xdp_umem_reg_v1 {\n--\nnet/xdp/xsk.c-1796-\nnet/xdp/xsk.c:1797:static int xsk_setsockopt(struct socket *sock, int level, int optname,\nnet/xdp/xsk.c-1798-\t\t\t  sockptr_t optval, unsigned int optlen)\n--\nnet/xdp/xsk.c-1919-\nnet/xdp/xsk.c:1920:static void xsk_enter_rxtx_offsets(struct xdp_ring_offset_v1 *ring)\nnet/xdp/xsk.c-1921-{\n--\nnet/xdp/xsk.c-1926-\nnet/xdp/xsk.c:1927:static void xsk_enter_umem_offsets(struct xdp_ring_offset_v1 *ring)\nnet/xdp/xsk.c-1928-{\n--\nnet/xdp/xsk.c=1934=struct xdp_statistics_v1 {\n--\nnet/xdp/xsk.c-1939-\nnet/xdp/xsk.c:1940:static int xsk_getsockopt(struct socket *sock, int level, int optname,\nnet/xdp/xsk.c-1941-\t\t\t  sockopt_t *opt)\n--\nnet/xdp/xsk.c-2067-\nnet/xdp/xsk.c:2068:static int xsk_mmap(struct file *file, struct socket *sock,\nnet/xdp/xsk.c-2069-\t\t    struct vm_area_struct *vma)\n--\nnet/xdp/xsk.c-2105-\nnet/xdp/xsk.c:2106:static int xsk_notifier(struct notifier_block *this,\nnet/xdp/xsk.c-2107-\t\t\tunsigned long msg, void *ptr)\n--\nnet/xdp/xsk.c=2144=static const struct proto_ops xsk_proto_ops = {\n--\nnet/xdp/xsk.c-2163-\nnet/xdp/xsk.c:2164:static void xsk_destruct(struct sock *sk)\nnet/xdp/xsk.c-2165-{\n--\nnet/xdp/xsk.c-2174-\nnet/xdp/xsk.c:2175:static int xsk_create(struct net *net, struct socket *sock, int protocol,\nnet/xdp/xsk.c-2176-\t\t      int kern)\n"
}

5/2 2026/07/11 17:33 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 16026
							output: 59
							thoughts: 203
						

Thoughts:
Okay, let's break this down.

**My Analysis of Key XDP/XSK TX and RX Functions**

Alright, I need to get a handle on the core functions involved in XDP/XSK transmit and receive paths. The following are crucial for the task at hand: `xsk_tx_completed`, `xsk_tx_commit_batch`, `__xsk_tx_peek_release_desc_batch`, `xsk_tx_peek_release_shared_desc_batch`, (yes, that one is listed twice, but it's important), `xsk_cq_submit_addr_single_locked`, `xsk_drop_skb`, `xsk_build_skb_zerocopy`, `xsk_build_skb`, `__xsk_generic_xmit`, `xp_alloc_tx_descs`, and `xskq_cons_read_desc_batch`. That gives me the overview that I need for this section. I will start by examining the code for `xskq_cons_read_desc_batch`. To do that, I'll start by looking at `net/xdp/xsk_queue.h` to see how it's implemented and how it is meant to function.



6/2 2026/07/11 17:33 tool grepper
0m Args:
{
  "Expression": "^(static )?(void|u32|int|struct [a-z_]+ \\*) [a-z_]+\\(",
  "PathPrefix": "net/xdp/xsk_queue.h"
}

Results:
{
  "Output": "net/xdp/xsk_queue.h=541=struct xsk_queue *xskq_create(u32 nentries, bool umem_queue);\nnet/xdp/xsk_queue.h:542:void xskq_destroy(struct xsk_queue *q_ops);\nnet/xdp/xsk_queue.h-543-\n"
}

7/2 2026/07/11 17:33 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 16668
							output: 32
							thoughts: 199
						

Thoughts:
**Analyzing the Kernel's XDP Socket Consumption**

Okay, so I'm looking at this `xskq_cons_read_desc_batch` function. Right, it's a `static inline` function defined in `net/xdp/xsk_queue.h`. That means it won't be a visible symbol in the kernel image directly. But, that's not the end of the line, as I know it's *called* by `__xsk_tx_peek_release_desc_batch`.

Now, let's step back a bit and consider the configuration aspects here. AF_XDP's availability boils down to `CONFIG_XDP_SOCKETS`. I should probably check for any other relevant configurations that might come into play as well. Always good to have the full picture.



8/2 2026/07/11 17:34 tool grepper
0m Args:
{
  "Expression": "CONFIG_XDP_SOCKETS",
  "PathPrefix": "net/xdp/"
}

Results:
{
  "Output": "net/xdp/Makefile-1-# SPDX-License-Identifier: GPL-2.0-only\nnet/xdp/Makefile:2:obj-$(CONFIG_XDP_SOCKETS) += xsk.o xdp_umem.o xsk_queue.o xskmap.o\nnet/xdp/Makefile:3:obj-$(CONFIG_XDP_SOCKETS) += xsk_buff_pool.o\nnet/xdp/Makefile:4:obj-$(CONFIG_XDP_SOCKETS_DIAG) += xsk_diag.o\n"
}

9/2 2026/07/11 17:34 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 17216
							output: 41
							thoughts: 311
						

Thoughts:
**Refining the XDP-Sockets Function List**

Okay, so I'm focusing on `XDP_SOCKETS` specifically. Time to nail down the core functions I need to analyze. Let's see... I've got a preliminary list, and I need to refine it. I'm thinking:

*   `xsk_tx_completed`
*   `xsk_tx_commit_batch`
*   `__xsk_tx_peek_release_desc_batch`
*   `xsk_tx_peek_release_shared_desc_batch`
*   `xsk_tx_peek_release_desc_batch` (Duplicate, I'll clean that up later)
*   `xsk_cq_submit_addr_single_locked`
*   `xsk_drop_skb`
*   `xsk_build_skb_zerocopy`
*   `xsk_build_skb`
*   `__xsk_generic_xmit`
*   `xp_alloc_tx_descs`

Wait a minute, a few of those are marked as `static`: `xsk_tx_commit_batch`, `__xsk_tx_peek_release_desc_batch`, `xsk_tx_peek_release_shared_desc_batch`, `xsk_cq_submit_addr_single_locked`, and `xsk_drop_skb`. They might be inlined. I need to check if they're explicitly declared as `static inline`. Ah, no, just `static`. That means they're local to their compilation unit, but not necessarily inlined. They should be fine to include for a broader view.

I'll take a quick look at `xp_alloc_tx_descs` in `net/xdp/xsk_buff_pool.c` just to be sure. It's time to dig in.



10/2 2026/07/11 17:34 tool grepper
0m Args:
{
  "Expression": "xp_alloc_tx_descs",
  "PathPrefix": "net/xdp/xsk_buff_pool.c"
}

Results:
{
  "Output": "net/xdp/xsk_buff_pool.c=35=void xp_destroy(struct xsk_buff_pool *pool)\n--\nnet/xdp/xsk_buff_pool.c-44-\nnet/xdp/xsk_buff_pool.c:45:int xp_alloc_tx_descs(struct xsk_buff_pool *pool, struct xdp_sock *xs)\nnet/xdp/xsk_buff_pool.c-46-{\n--\nnet/xdp/xsk_buff_pool.c=55=struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs,\n--\nnet/xdp/xsk_buff_pool.c-72-\tif (xs-\u003etx)\nnet/xdp/xsk_buff_pool.c:73:\t\tif (xp_alloc_tx_descs(pool, xs))\nnet/xdp/xsk_buff_pool.c-74-\t\t\tgoto out;\n"
}

11/2 2026/07/11 17:34 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 18251
							output: 251
							thoughts: 603
						

Thoughts:
**My Analysis of AF_XDP Multi-Buffer Transmission Logic for Fuzzing**

Alright, let's break this down. First, I confirmed that `xp_alloc_tx_descs` is *not* a static function, which is key. Now, I have a solid list of functions to target for fuzzing based on the patch's scope:

*   `xsk_tx_completed`
*   `xsk_tx_commit_batch`
*   `__xsk_tx_peek_release_desc_batch`
*   `xsk_tx_peek_release_shared_desc_batch`
*   `xsk_tx_peek_release_desc_batch`
*   `xsk_cq_submit_addr_single_locked`
*   `xsk_drop_skb`
*   `xsk_build_skb_zerocopy`
*   `xsk_build_skb`
*   `__xsk_generic_xmit`
*   `xp_alloc_tx_descs`

Initially, I had a quick check on whether `__xsk_generic_xmit` was a static function. It is. However, I confirmed that it is the generic transmit function, and the patch has modified it. `xsk_tx_peek_release_desc_batch` is also a hot-path function. The instructions did warn against including generic hot-paths like `kfree` or `schedule`, but these functions are specific to AF\_XDP, so they're relevant and don't skew the distribution. Including them is acceptable.

The patch itself is focused on the AF\_XDP multi-buffer (SG) packet transmission. It's introducing batching and descriptor reclaim to handle invalid descriptors and boundary conditions. This is reachable and functional AF\_XDP code, so it makes perfect sense to fuzz it. The code's being modified within `net/xdp/xsk.c` and `net/xdp/xsk_queue.h`.

The configuration I need to ensure is enabled for this is `XDP_SOCKETS`. I briefly checked if `XDP_SOCKETS` depended on `BPF_SYSCALL`, and confirmed that `XDP_SOCKETS` is the key configuration to be checked. This confirms that these functions are enabled under the targeted configuration.

So, in summary, I have a good handle on the functions to focus on, the patch's scope, and the correct configuration to enable. I'm ready to move forward.



12/2 2026/07/11 17:34 tool set-results
0m Args:
{
  "EnableConfigs": [
    "XDP_SOCKETS"
  ],
  "FocusSymbols": [
    "xsk_tx_completed",
    "xsk_tx_commit_batch",
    "__xsk_tx_peek_release_desc_batch",
    "xsk_tx_peek_release_shared_desc_batch",
    "xsk_tx_peek_release_desc_batch",
    "xsk_cq_submit_addr_single_locked",
    "xsk_drop_skb",
    "xsk_build_skb_zerocopy",
    "xsk_build_skb",
    "__xsk_generic_xmit",
    "xp_alloc_tx_descs"
  ],
  "Reasoning": "The patch modifies the AF_XDP multi-buffer (SG) packet transmission logic, introducing batching and reclaim descriptors to handle invalid descriptors and boundaries correctly. It modifies core XDP socket code in net/xdp/xsk.c and net/xdp/xsk_queue.h. This is reachable and functional code that should be fuzzed.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "XDP_SOCKETS"
  ],
  "FocusSymbols": [
    "xsk_tx_completed",
    "xsk_tx_commit_batch",
    "__xsk_tx_peek_release_desc_batch",
    "xsk_tx_peek_release_shared_desc_batch",
    "xsk_tx_peek_release_desc_batch",
    "xsk_cq_submit_addr_single_locked",
    "xsk_drop_skb",
    "xsk_build_skb_zerocopy",
    "xsk_build_skb",
    "__xsk_generic_xmit",
    "xp_alloc_tx_descs"
  ],
  "Reasoning": "The patch modifies the AF_XDP multi-buffer (SG) packet transmission logic, introducing batching and reclaim descriptors to handle invalid descriptors and boundaries correctly. It modifies core XDP socket code in net/xdp/xsk.c and net/xdp/xsk_queue.h. This is reachable and functional code that should be fuzzed.",
  "WorthFuzzing": true
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)