AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/08/09 19:08 flow patch-triage
1m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch exclusively modifies the Microsoft Azure Network Adapter (MANA) driver, which is a vendor-specific SmartNIC driver. This hardware is not emulated in standard QEMU or GCE environments. Following the instructions to exclude vendor-specific SmartNIC drivers that require physical PCIe hardware not emulated in standard QEMU, this patch is not worth fuzzing.",
  "WorthFuzzing": false
}

1/1 2026/08/09 19:08 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 39e9409a76f26cae7e33f983e28ec6c35349732c\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Sun Aug 9 19:08:09 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/drivers/infiniband/hw/mana/cq.c b/drivers/infiniband/hw/mana/cq.c\nindex f2547989f4229..2bf4be21cede7 100644\n--- a/drivers/infiniband/hw/mana/cq.c\n+++ b/drivers/infiniband/hw/mana/cq.c\n@@ -131,12 +131,20 @@ static void mana_ib_cq_handler(void *ctx, struct gdma_queue *gdma_cq)\n int mana_ib_install_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq *cq)\n {\n \tstruct gdma_context *gc = mdev_to_gc(mdev);\n+\tstruct gdma_queue __rcu **cq_table;\n \tstruct gdma_queue *gdma_cq;\n \n-\tif (cq-\u003equeue.id \u003e= gc-\u003emax_num_cqs)\n+\t/* No rcu_read_lock(): install/remove run within the IB device\n+\t * lifetime, which mana_rdma_remove() (ib_unregister_device) drains\n+\t * before the base cq_table can be freed.  See gdma_context::cq_table\n+\t * in gdma.h for why \"true\" is sound.\n+\t */\n+\tcq_table = rcu_dereference_protected(gc-\u003ecq_table, true);\n+\tif (!cq_table || cq-\u003equeue.id \u003e= gc-\u003emax_num_cqs)\n \t\treturn -EINVAL;\n+\n \t/* Create CQ table entry, sharing a CQ between WQs is not supported */\n-\tif (gc-\u003ecq_table[cq-\u003equeue.id])\n+\tif (rcu_access_pointer(cq_table[cq-\u003equeue.id]))\n \t\treturn -EINVAL;\n \tif (cq-\u003equeue.kmem)\n \t\tgdma_cq = cq-\u003equeue.kmem;\n@@ -149,23 +157,49 @@ int mana_ib_install_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq *cq)\n \tgdma_cq-\u003etype = GDMA_CQ;\n \tgdma_cq-\u003ecq.callback = mana_ib_cq_handler;\n \tgdma_cq-\u003eid = cq-\u003equeue.id;\n-\tgc-\u003ecq_table[cq-\u003equeue.id] = gdma_cq;\n+\trcu_assign_pointer(cq_table[cq-\u003equeue.id], gdma_cq);\n \treturn 0;\n }\n \n void mana_ib_remove_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq *cq)\n {\n \tstruct gdma_context *gc = mdev_to_gc(mdev);\n+\tstruct gdma_queue __rcu **cq_table;\n+\tstruct gdma_queue *gdma_cq;\n \n-\tif (cq-\u003equeue.id \u003e= gc-\u003emax_num_cqs || cq-\u003equeue.id == INVALID_QUEUE_ID)\n+\tif (cq-\u003equeue.id == INVALID_QUEUE_ID)\n \t\treturn;\n \n \tif (cq-\u003equeue.kmem)\n \t/* Then it will be cleaned and removed by the mana */\n \t\treturn;\n \n-\tkfree(gc-\u003ecq_table[cq-\u003equeue.id]);\n-\tgc-\u003ecq_table[cq-\u003equeue.id] = NULL;\n+\t/* No rcu_read_lock(): like mana_ib_install_cq_cb(), this runs within\n+\t * the IB device lifetime that mana_rdma_remove() drains before the\n+\t * base cq_table can be freed.  See gdma_context::cq_table in gdma.h.\n+\t */\n+\tcq_table = rcu_dereference_protected(gc-\u003ecq_table, true);\n+\tif (!cq_table || cq-\u003equeue.id \u003e= gc-\u003emax_num_cqs)\n+\t\treturn;\n+\t/* Removers for a given CQ are serialized by the IB core, so the slot\n+\t * is read and cleared without rcu_read_lock() or atomicity: a CQ is\n+\t * never torn down while a live QP references it (cq-\u003eusecnt), nor\n+\t * while the QP-create that installed the entry is still running (that\n+\t * create holds a reference on the CQ uobject across its error path,\n+\t * before usecnt is taken).  Any double-remove is therefore sequential\n+\t * -- the later caller sees the NULL stored below and returns.\n+\t */\n+\tgdma_cq = rcu_dereference_protected(cq_table[cq-\u003equeue.id], true);\n+\tif (!gdma_cq)\n+\t\treturn;  /* already removed by a prior teardown path */\n+\n+\trcu_assign_pointer(cq_table[cq-\u003equeue.id], NULL);\n+\n+\t/* Wait for in-flight EQ handlers that may have loaded the old\n+\t * pointer via rcu_dereference() to finish before freeing.\n+\t */\n+\tsynchronize_rcu();\n+\tkfree(gdma_cq);\n }\n \n int mana_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)\ndiff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c\nindex e8b7ffb47eb98..9c2f5e0cfcbc1 100644\n--- a/drivers/net/ethernet/microsoft/mana/gdma_main.c\n+++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c\n@@ -310,7 +310,12 @@ static int mana_gd_query_hwc_timeout(struct pci_dev *pdev, u32 *timeout_val)\n \tif (err || resp.hdr.status)\n \t\treturn err ? err : -EPROTO;\n \n-\t*timeout_val = resp.timeout_ms;\n+\t/* A zero timeout would make every HWC command time out immediately\n+\t * and latch the channel (see the HWC_DATA_CFG_HWC_TIMEOUT handler).\n+\t * Ignore a zero from the device and keep the caller's positive value.\n+\t */\n+\tif (resp.timeout_ms)\n+\t\t*timeout_val = resp.timeout_ms;\n \n \treturn 0;\n }\n@@ -732,6 +737,7 @@ static void mana_gd_process_eqe(struct gdma_queue *eq)\n \tunion gdma_eqe_info eqe_info;\n \tenum gdma_eqe_type type;\n \tstruct gdma_event event;\n+\tstruct gdma_queue __rcu **cq_table;\n \tstruct gdma_queue *cq;\n \tstruct gdma_eqe *eqe;\n \tu32 cq_id;\n@@ -743,10 +749,11 @@ static void mana_gd_process_eqe(struct gdma_queue *eq)\n \tswitch (type) {\n \tcase GDMA_EQE_COMPLETION:\n \t\tcq_id = eqe-\u003edetails[0] \u0026 0xFFFFFF;\n-\t\tif (WARN_ON_ONCE(cq_id \u003e= gc-\u003emax_num_cqs))\n+\t\tcq_table = rcu_dereference(gc-\u003ecq_table);\n+\t\tif (WARN_ON_ONCE(cq_id \u003e= gc-\u003emax_num_cqs || !cq_table))\n \t\t\tbreak;\n \n-\t\tcq = gc-\u003ecq_table[cq_id];\n+\t\tcq = rcu_dereference(cq_table[cq_id]);\n \t\tif (WARN_ON_ONCE(!cq || cq-\u003etype != GDMA_CQ || cq-\u003eid != cq_id))\n \t\t\tbreak;\n \n@@ -1050,18 +1057,41 @@ static void mana_gd_create_cq(const struct gdma_queue_spec *spec,\n \tqueue-\u003ecq.callback = spec-\u003ecq.callback;\n }\n \n-static void mana_gd_destroy_cq(struct gdma_context *gc,\n-\t\t\t       struct gdma_queue *queue)\n+bool mana_gd_unpublish_cq(struct gdma_context *gc, struct gdma_queue *queue)\n {\n+\tstruct gdma_queue __rcu **cq_table;\n \tu32 id = queue-\u003eid;\n \n-\tif (id \u003e= gc-\u003emax_num_cqs)\n-\t\treturn;\n+\t/* No rcu_read_lock() here: unpublish runs only on the\n+\t * CQ-destroy/teardown path, where the base cq_table is stable.  See\n+\t * the lifecycle note on gdma_context::cq_table in gdma.h for why the\n+\t * \"true\" predicate is sound.\n+\t */\n+\tcq_table = rcu_dereference_protected(gc-\u003ecq_table, true);\n+\tif (!cq_table || id \u003e= gc-\u003emax_num_cqs)\n+\t\treturn false;\n+\n+\tif (!rcu_access_pointer(cq_table[id]))\n+\t\treturn false;\n \n-\tif (!gc-\u003ecq_table[id])\n+\trcu_assign_pointer(cq_table[id], NULL);\n+\treturn true;\n+}\n+\n+static void mana_gd_destroy_cq(struct gdma_context *gc,\n+\t\t\t       struct gdma_queue *queue)\n+{\n+\t/* A batched teardown may already have cleared the slot and taken the\n+\t * grace period; then there is nothing left to wait for.\n+\t */\n+\tif (!mana_gd_unpublish_cq(gc, queue))\n \t\treturn;\n \n-\tgc-\u003ecq_table[id] = NULL;\n+\t/* Wait for in-flight EQ handlers that may have loaded the old\n+\t * pointer via rcu_dereference() to finish before the caller\n+\t * frees the CQ memory.\n+\t */\n+\tsynchronize_rcu();\n }\n \n int mana_gd_create_hwc_queue(struct gdma_dev *gd,\ndiff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net/ethernet/microsoft/mana/hw_channel.c\nindex e3c24d50dad07..03b5e2f02e352 100644\n--- a/drivers/net/ethernet/microsoft/mana/hw_channel.c\n+++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c\n@@ -4,27 +4,61 @@\n #include \u003cnet/mana/gdma.h\u003e\n #include \u003cnet/mana/mana.h\u003e\n #include \u003cnet/mana/hw_channel.h\u003e\n+#include \u003clinux/pci.h\u003e\n #include \u003clinux/vmalloc.h\u003e\n \n+/* Acquire a free message slot from the inflight bitmap.  Returns\n+ * -ETIMEDOUT if a prior HWC command has timed out (preserving the\n+ * error code callers expect).\n+ */\n static int mana_hwc_get_msg_index(struct hw_channel_context *hwc, u16 *msg_id)\n {\n \tstruct gdma_resource *r = \u0026hwc-\u003einflight_msg_res;\n \tunsigned long flags;\n \tu32 index;\n \n-\tdown(\u0026hwc-\u003esema);\n+\tfor (;;) {\n+\t\tspin_lock_irqsave(\u0026r-\u003elock, flags);\n \n-\tspin_lock_irqsave(\u0026r-\u003elock, flags);\n+\t\tif (hwc-\u003ehwc_timed_out) {\n+\t\t\tspin_unlock_irqrestore(\u0026r-\u003elock, flags);\n+\t\t\treturn -ETIMEDOUT;\n+\t\t}\n \n-\tindex = find_first_zero_bit(hwc-\u003einflight_msg_res.map,\n-\t\t\t\t    hwc-\u003einflight_msg_res.size);\n+\t\tindex = find_first_zero_bit(r-\u003emap, r-\u003esize);\n+\t\tif (index \u003c r-\u003esize) {\n+\t\t\tstruct hwc_caller_ctx *ctx;\n+\n+\t\t\tbitmap_set(r-\u003emap, index, 1);\n+\t\t\tctx = \u0026hwc-\u003ecaller_ctx[index];\n+\t\t\treinit_completion(\u0026ctx-\u003ecomp_event);\n+\t\t\t/* Take the response-side reference here, under\n+\t\t\t * r-\u003elock and together with the slot bitmap bit,\n+\t\t\t * so a stale or duplicate response that lands\n+\t\t\t * before mana_hwc_send_request() posts the request\n+\t\t\t * cannot drop the refcount to zero and free the\n+\t\t\t * slot under the sender.  One reference is the\n+\t\t\t * sender's; the other is released by\n+\t\t\t * mana_hwc_handle_resp().\n+\t\t\t */\n+\t\t\trefcount_set(\u0026ctx-\u003erefcnt, 2);\n+\t\t\tctx-\u003eresponded = false;\n+\t\t\tctx-\u003emsg_id = index;\n+\t\t\tctx-\u003eerror = -EINPROGRESS;\n+\t\t\tspin_unlock_irqrestore(\u0026r-\u003elock, flags);\n+\t\t\tbreak;\n+\t\t}\n+\t\tspin_unlock_irqrestore(\u0026r-\u003elock, flags);\n \n-\tbitmap_set(hwc-\u003einflight_msg_res.map, index, 1);\n+\t\twait_event(hwc-\u003emsg_waitq,\n+\t\t\t   READ_ONCE(hwc-\u003ehwc_timed_out) ||\n+\t\t\t   !bitmap_full(r-\u003emap, r-\u003esize));\n \n-\tspin_unlock_irqrestore(\u0026r-\u003elock, flags);\n+\t\tif (READ_ONCE(hwc-\u003ehwc_timed_out))\n+\t\t\treturn -ETIMEDOUT;\n+\t}\n \n \t*msg_id = index;\n-\n \treturn 0;\n }\n \n@@ -34,10 +68,17 @@ static void mana_hwc_put_msg_index(struct hw_channel_context *hwc, u16 msg_id)\n \tunsigned long flags;\n \n \tspin_lock_irqsave(\u0026r-\u003elock, flags);\n-\tbitmap_clear(hwc-\u003einflight_msg_res.map, msg_id, 1);\n+\tbitmap_clear(r-\u003emap, msg_id, 1);\n \tspin_unlock_irqrestore(\u0026r-\u003elock, flags);\n \n-\tup(\u0026hwc-\u003esema);\n+\twake_up(\u0026hwc-\u003emsg_waitq);\n+}\n+\n+static void hwc_ctx_put(struct hw_channel_context *hwc,\n+\t\t\tstruct hwc_caller_ctx *ctx)\n+{\n+\tif (refcount_dec_and_test(\u0026ctx-\u003erefcnt))\n+\t\tmana_hwc_put_msg_index(hwc, ctx-\u003emsg_id);\n }\n \n static int mana_hwc_verify_resp_msg(const struct hwc_caller_ctx *caller_ctx,\n@@ -83,6 +124,19 @@ static void mana_hwc_handle_resp(struct hw_channel_context *hwc, u32 resp_len,\n \tstruct hwc_caller_ctx *ctx;\n \tint err;\n \n+\t/* Defence in depth: the sole caller, mana_hwc_rx_event_handler(),\n+\t * already rejects msg_id \u003e= hwc-\u003enum_inflight_msg with the value it\n+\t * passes here by value, so this cannot be reached out of range.  Keep\n+\t * the guard at the indexing site so the bitmap and caller_ctx array\n+\t * are never indexed without a bound in view.\n+\t */\n+\tif (msg_id \u003e= hwc-\u003enum_inflight_msg) {\n+\t\tdev_err(hwc-\u003edev, \"hwc_rx: msg_id %u \u003e= max %u\\n\",\n+\t\t\tmsg_id, hwc-\u003enum_inflight_msg);\n+\t\tmana_hwc_post_rx_wqe(hwc-\u003erxq, rx_req);\n+\t\treturn;\n+\t}\n+\n \tif (!test_bit(msg_id, hwc-\u003einflight_msg_res.map)) {\n \t\tdev_err(hwc-\u003edev, \"hwc_rx: invalid msg_id = %u\\n\", msg_id);\n \t\tmana_hwc_post_rx_wqe(hwc-\u003erxq, rx_req);\n@@ -90,22 +144,56 @@ static void mana_hwc_handle_resp(struct hw_channel_context *hwc, u32 resp_len,\n \t}\n \n \tctx = hwc-\u003ecaller_ctx + msg_id;\n-\terr = mana_hwc_verify_resp_msg(ctx, resp_msg, resp_len);\n-\tif (err)\n-\t\tgoto out;\n \n-\tctx-\u003estatus_code = resp_msg-\u003estatus;\n+\t/* Reject responses larger than the RX DMA buffer — the SGE\n+\t * limits what hardware can DMA, so an oversized resp_len\n+\t * indicates a firmware bug.  Fail rather than silently\n+\t * truncating.\n+\t */\n+\tif (resp_len \u003e rx_req-\u003ebuf_len) {\n+\t\tdev_err(hwc-\u003edev, \"HWC RX: resp_len %u \u003e buf_len %u\\n\",\n+\t\t\tresp_len, rx_req-\u003ebuf_len);\n+\t\tresp_len = 0;\n+\t}\n \n-\tmemcpy(ctx-\u003eoutput_buf, resp_msg, resp_len);\n-out:\n-\tctx-\u003eerror = err;\n+\tspin_lock(\u0026ctx-\u003elock);\n+\n+\tif (ctx-\u003eresponded) {\n+\t\t/* A response for this slot was already delivered; this is a\n+\t\t * duplicate or replayed one.  Drop it so the hwc_ctx_put()\n+\t\t * a first response performs is not done twice, which would\n+\t\t * over-release the slot while the sender still owns it.\n+\t\t */\n+\t\tspin_unlock(\u0026ctx-\u003elock);\n+\t\tmana_hwc_post_rx_wqe(hwc-\u003erxq, rx_req);\n+\t\treturn;\n+\t}\n+\tctx-\u003eresponded = true;\n+\n+\terr = mana_hwc_verify_resp_msg(ctx, resp_msg, resp_len);\n+\n+\tif (!err \u0026\u0026 ctx-\u003eoutput_buf) {\n+\t\tctx-\u003estatus_code = resp_msg-\u003estatus;\n+\t\tmemcpy(ctx-\u003eoutput_buf, resp_msg, resp_len);\n+\t\tctx-\u003eerror = 0;\n+\t} else if (ctx-\u003eoutput_buf) {\n+\t\t/* Record the error only while the sender still owns the\n+\t\t * request: a non-NULL output_buf means it is still waiting.\n+\t\t * Once it has timed out (or been force-completed by destroy)\n+\t\t * it clears output_buf and takes its own error, so a late\n+\t\t * response must not write ctx-\u003eerror or the buffer here.\n+\t\t */\n+\t\tctx-\u003eerror = err;\n+\t}\n \n-\t/* Must post rx wqe before complete(), otherwise the next rx may\n-\t * hit no_wqe error.\n+\t/* Post RX WQE before completing — the next response may arrive\n+\t * immediately and needs a posted buffer.\n \t */\n \tmana_hwc_post_rx_wqe(hwc-\u003erxq, rx_req);\n-\n \tcomplete(\u0026ctx-\u003ecomp_event);\n+\tspin_unlock(\u0026ctx-\u003elock);\n+\n+\thwc_ctx_put(hwc, ctx);\n }\n \n static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,\n@@ -158,7 +246,15 @@ static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,\n \t\t\tbreak;\n \n \t\tcase HWC_INIT_DATA_MAX_NUM_CQS:\n-\t\t\tgd-\u003egdma_context-\u003emax_num_cqs = val;\n+\t\t\t/* Store, don't apply: mana_hwc_establish_channel()\n+\t\t\t * commits this to gc-\u003emax_num_cqs once, together\n+\t\t\t * with sizing cq_table, so a spoofed post-init event\n+\t\t\t * cannot inflate the bound past the allocation.\n+\t\t\t * WRITE_ONCE() pairs with the READ_ONCE() there:\n+\t\t\t * this store runs in EQ interrupt context,\n+\t\t\t * concurrently with that process-context read.\n+\t\t\t */\n+\t\t\tWRITE_ONCE(hwc-\u003ehwc_init_max_num_cqs, val);\n \t\t\tbreak;\n \n \t\tcase HWC_INIT_DATA_PDID:\n@@ -192,7 +288,12 @@ static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,\n \n \t\tswitch (type) {\n \t\tcase HWC_DATA_CFG_HWC_TIMEOUT:\n-\t\t\thwc-\u003ehwc_timeout = val;\n+\t\t\t/* A zero timeout would make every command time out\n+\t\t\t * immediately and latch hwc_timed_out, disabling the\n+\t\t\t * channel.  Ignore it and keep the positive default.\n+\t\t\t */\n+\t\t\tif (val)\n+\t\t\t\thwc-\u003ehwc_timeout = val;\n \t\t\tbreak;\n \n \t\tcase HWC_DATA_HW_LINK_CONNECT:\n@@ -237,18 +338,39 @@ static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,\n \t}\n }\n \n+/* An RX WQE whose SGE the handler cannot trust is deliberately not\n+ * reposted: reposting a slot we may have mis-identified could double-post\n+ * a buffer the device still owns.  Each such leak permanently lowers the\n+ * RQ's posted depth, so once the whole depth is gone the channel can no\n+ * longer receive responses.  Make that terminal state explicit -- log it\n+ * once and shorten the command timeout so callers fail fast -- rather than\n+ * letting every later command drain its full timeout against a dead RQ.\n+ */\n+static void mana_hwc_rx_leak_wqe(struct hw_channel_context *hwc)\n+{\n+\tif (++hwc-\u003erx_leaked_wqe == hwc-\u003erxq-\u003equeue_depth) {\n+\t\tdev_err(hwc-\u003edev,\n+\t\t\t\"HWC RX: RQ exhausted after %u leaked WQEs; channel unusable\\n\",\n+\t\t\thwc-\u003erx_leaked_wqe);\n+\t\thwc-\u003ehwc_timeout = 1;\n+\t}\n+}\n+\n static void mana_hwc_rx_event_handler(void *ctx, u32 gdma_rxq_id,\n \t\t\t\t      const struct hwc_rx_oob *rx_oob)\n {\n \tstruct hw_channel_context *hwc = ctx;\n \tstruct hwc_wq *hwc_rxq = hwc-\u003erxq;\n \tstruct hwc_work_request *rx_req;\n+\tstruct gdma_wqe oob_snapshot;\n \tstruct gdma_resp_hdr *resp;\n \tstruct gdma_wqe *dma_oob;\n \tstruct gdma_queue *rq;\n \tstruct gdma_sge *sge;\n \tu64 rq_base_addr;\n \tu64 rx_req_idx;\n+\tu64 sge_addr;\n+\tu32 oob_div4;\n \tu16 msg_id;\n \tu8 *wqe;\n \n@@ -259,28 +381,76 @@ static void mana_hwc_rx_event_handler(void *ctx, u32 gdma_rxq_id,\n \twqe = mana_gd_get_wqe_ptr(rq, rx_oob-\u003ewqe_offset / GDMA_WQE_BU_SIZE);\n \tdma_oob = (struct gdma_wqe *)wqe;\n \n-\tsge = (struct gdma_sge *)(wqe + 8 + dma_oob-\u003einline_oob_size_div4 * 4);\n-\n-\t/* Select the RX work request for virtual address and for reposting. */\n+\t/* inline_oob_size_div4 lives in device-accessible RQ memory (shared\n+\t * and host-writable in a confidential VM), so snapshot it once and\n+\t * validate and use only the snapshot.  It is a bit-field, which\n+\t * READ_ONCE() cannot take the size of, so read the u32 flags word it\n+\t * shares through the union and extract the field from the local copy.\n+\t * The driver programs INLINE_OOB_SMALL_SIZE for every HWC RQ WQE via\n+\t * mana_gd_post_work_request(), so the only valid value is\n+\t * INLINE_OOB_SMALL_SIZE / 4, which puts the SGE at wqe + 16 inside\n+\t * this WQE's own BU.  Reject anything else -- the slot cannot be\n+\t * trusted, so leak this RX WQE rather than repost the wrong one.\n+\t */\n+\toob_snapshot.flags = READ_ONCE(dma_oob-\u003eflags);\n+\toob_div4 = oob_snapshot.inline_oob_size_div4;\n+\tif (oob_div4 != INLINE_OOB_SMALL_SIZE / 4) {\n+\t\tdev_err(hwc-\u003edev, \"HWC RX: unexpected inline_oob_size_div4=%u\\n\",\n+\t\t\toob_div4);\n+\t\tmana_hwc_rx_leak_wqe(hwc);\n+\t\treturn;\n+\t}\n+\tsge = (struct gdma_sge *)(wqe + 8 + oob_div4 * 4);\n+\n+\t/* Recover the originating RX slot from the SGE address.  Snapshot it\n+\t * once, for the same shared-memory reason: of the three terms only\n+\t * sge_addr comes from device memory; rq_base_addr and\n+\t * max_resp_msg_size are driver-private.  An in-range but wrong SGE\n+\t * would otherwise truncate onto a neighbouring slot, letting us read\n+\t * a stale response that could complete the wrong, reused in-flight\n+\t * request.  Require the index in range AND the address to exactly\n+\t * match the value the driver posted for that slot.\n+\t */\n+\tsge_addr = READ_ONCE(sge-\u003eaddress);\n \trq_base_addr = hwc_rxq-\u003emsg_buf-\u003emem_info.dma_handle;\n-\trx_req_idx = (sge-\u003eaddress - rq_base_addr) / hwc-\u003emax_req_msg_size;\n-\n-\tif (rx_req_idx \u003e= hwc_rxq-\u003emsg_buf-\u003enum_reqs) {\n-\t\tdev_err(hwc-\u003edev, \"HWC RX: wrong rx_req_idx=%llu, num_reqs=%u\\n\",\n-\t\t\trx_req_idx, hwc_rxq-\u003emsg_buf-\u003enum_reqs);\n+\trx_req_idx = (sge_addr - rq_base_addr) / hwc-\u003emax_resp_msg_size;\n+\n+\tif (rx_req_idx \u003e= hwc_rxq-\u003equeue_depth) {\n+\t\t/* Cannot identify the slot, so we cannot safely repost this\n+\t\t * WQE; leak it.  An out-of-range index means a corrupted SGE\n+\t\t * from hardware or host tampering.\n+\t\t */\n+\t\tdev_err(hwc-\u003edev, \"HWC RX: SGE idx %llu out of range\\n\",\n+\t\t\trx_req_idx);\n+\t\tmana_hwc_rx_leak_wqe(hwc);\n \t\treturn;\n \t}\n \n \trx_req = \u0026hwc_rxq-\u003emsg_buf-\u003ereqs[rx_req_idx];\n+\tif (sge_addr != (u64)rx_req-\u003ebuf_sge_addr) {\n+\t\t/* In-range index but the address does not match what the\n+\t\t * driver posted for that slot; the same unrecoverable case,\n+\t\t * so leak this WQE rather than repost the wrong one.\n+\t\t */\n+\t\tdev_err(hwc-\u003edev, \"HWC RX: invalid SGE address %llx (idx=%llu)\\n\",\n+\t\t\tsge_addr, rx_req_idx);\n+\t\tmana_hwc_rx_leak_wqe(hwc);\n+\t\treturn;\n+\t}\n+\n \tresp = (struct gdma_resp_hdr *)rx_req-\u003ebuf_va;\n \n-\t/* Read msg_id once from DMA buffer to prevent TOCTOU:\n-\t * DMA memory is shared/unencrypted in CVMs - host can\n-\t * modify it between reads.\n+\t/* Read msg_id once from the DMA buffer to prevent TOCTOU: DMA memory\n+\t * is shared/unencrypted in CVMs, so the host can modify it between\n+\t * reads.  A short response is not rejected here; it is handed to\n+\t * mana_hwc_handle_resp() below, whose mana_hwc_verify_resp_msg()\n+\t * fails it with -EPROTO and completes the waiting sender, so one\n+\t * malformed response cannot stall the whole channel.\n \t */\n \tmsg_id = READ_ONCE(resp-\u003eresponse.hwc_msg_id);\n \tif (msg_id \u003e= hwc-\u003enum_inflight_msg) {\n \t\tdev_err(hwc-\u003edev, \"HWC RX: wrong msg_id=%u\\n\", msg_id);\n+\t\tmana_hwc_post_rx_wqe(hwc_rxq, rx_req);\n \t\treturn;\n \t}\n \n@@ -384,14 +554,24 @@ static void mana_hwc_comp_event(void *ctx, struct gdma_queue *q_self)\n \n static void mana_hwc_destroy_cq(struct gdma_context *gc, struct hwc_cq *hwc_cq)\n {\n-\tkfree(hwc_cq-\u003ecomp_buf);\n+\t/* Destroy the EQ before the CQ.  mana_gd_destroy_queue() on the EQ\n+\t * deregisters its IRQ and waits out in-flight handlers, fencing all\n+\t * EQE dispatch — both the completion path and HWC init/reconfig\n+\t * events.  Freeing the CQ first would leave the EQ live and able to\n+\t * dispatch an event that dereferences hwc-\u003ecq-\u003egdma_cq (e.g.\n+\t * mana_hwc_init_event_handler()) after it has been freed.\n+\t */\n+\tif (hwc_cq-\u003egdma_eq)\n+\t\tmana_gd_destroy_queue(gc, hwc_cq-\u003egdma_eq);\n \n+\t/* comp_buf is reached only by mana_hwc_comp_event(), invoked from\n+\t * the now-fenced EQ handler, so it is safe to free once the EQ and\n+\t * CQ are gone.\n+\t */\n \tif (hwc_cq-\u003egdma_cq)\n \t\tmana_gd_destroy_queue(gc, hwc_cq-\u003egdma_cq);\n \n-\tif (hwc_cq-\u003egdma_eq)\n-\t\tmana_gd_destroy_queue(gc, hwc_cq-\u003egdma_eq);\n-\n+\tkfree(hwc_cq-\u003ecomp_buf);\n \tkfree(hwc_cq);\n }\n \n@@ -627,7 +807,7 @@ static int mana_hwc_init_inflight_msg(struct hw_channel_context *hwc,\n {\n \tint err;\n \n-\tsema_init(\u0026hwc-\u003esema, num_msg);\n+\tinit_waitqueue_head(\u0026hwc-\u003emsg_waitq);\n \n \terr = mana_gd_alloc_res_map(num_msg, \u0026hwc-\u003einflight_msg_res);\n \tif (err)\n@@ -657,8 +837,10 @@ static int mana_hwc_test_channel(struct hw_channel_context *hwc, u16 q_depth,\n \tif (!ctx)\n \t\treturn -ENOMEM;\n \n-\tfor (i = 0; i \u003c q_depth; ++i)\n+\tfor (i = 0; i \u003c q_depth; ++i) {\n+\t\tspin_lock_init(\u0026ctx[i].lock);\n \t\tinit_completion(\u0026ctx[i].comp_event);\n+\t}\n \n \thwc-\u003ecaller_ctx = ctx;\n \n@@ -669,11 +851,17 @@ static int mana_hwc_establish_channel(struct gdma_context *gc, u16 *q_depth,\n \t\t\t\t      u32 *max_req_msg_size,\n \t\t\t\t      u32 *max_resp_msg_size)\n {\n+\t/* No RCU needed: called only from mana_hwc_create_channel\n+\t * during init, before the channel is published to senders.\n+\t */\n \tstruct hw_channel_context *hwc = gc-\u003ehwc.driver_data;\n \tstruct gdma_queue *rq = hwc-\u003erxq-\u003egdma_wq;\n \tstruct gdma_queue *sq = hwc-\u003etxq-\u003egdma_wq;\n \tstruct gdma_queue *eq = hwc-\u003ecq-\u003egdma_eq;\n \tstruct gdma_queue *cq = hwc-\u003ecq-\u003egdma_cq;\n+\tstruct gdma_queue __rcu **cq_table;\n+\tu32 num_cqs;\n+\tu32 cq_id;\n \tint err;\n \n \tinit_completion(\u0026hwc-\u003ehwc_init_eqe_comp);\n@@ -687,6 +875,15 @@ static int mana_hwc_establish_channel(struct gdma_context *gc, u16 *q_depth,\n \tif (err)\n \t\treturn err;\n \n+\t/* setup_hwc activated MST entries — hardware can now DMA into our\n+\t * queue buffers.  Record that in setup_active so the caller's error\n+\t * path (mana_hwc_create_channel() -\u003e mana_hwc_destroy_channel())\n+\t * tears the HWC down exactly once.  Do not also tear down here: a\n+\t * second teardown would double the hardware timeout on failure and\n+\t * mask the original error code.\n+\t */\n+\thwc-\u003esetup_active = true;\n+\n \tif (!wait_for_completion_timeout(\u0026hwc-\u003ehwc_init_eqe_comp, 60 * HZ))\n \t\treturn -ETIMEDOUT;\n \n@@ -694,15 +891,33 @@ static int mana_hwc_establish_channel(struct gdma_context *gc, u16 *q_depth,\n \t*max_req_msg_size = hwc-\u003ehwc_init_max_req_msg_size;\n \t*max_resp_msg_size = hwc-\u003ehwc_init_max_resp_msg_size;\n \n-\t/* Both were set in mana_hwc_init_event_handler(). */\n-\tif (WARN_ON(cq-\u003eid \u003e= gc-\u003emax_num_cqs))\n+\t/* Snapshot the device-reported CQ count and CQ id into locals and\n+\t * use only the locals below, so the same value that sizes cq_table\n+\t * also bounds and indexes it -- even across the sleeping vcalloc().\n+\t * Both fields are written by mana_hwc_init_event_handler() from EQ\n+\t * interrupt context: hwc_init_max_num_cqs under WRITE_ONCE() (paired\n+\t * here), and cq-\u003eid as an ordinary store.  READ_ONCE() keeps each\n+\t * read tear-free and, crucially, non-reloadable, so a spoofed\n+\t * post-init event cannot make the WARN_ON() pass against one value\n+\t * while the allocation or the index uses another.\n+\t */\n+\tnum_cqs = READ_ONCE(hwc-\u003ehwc_init_max_num_cqs);\n+\tcq_id = READ_ONCE(cq-\u003eid);\n+\n+\tif (WARN_ON(cq_id \u003e= num_cqs))\n \t\treturn -EPROTO;\n \n-\tgc-\u003ecq_table = vcalloc(gc-\u003emax_num_cqs, sizeof(struct gdma_queue *));\n-\tif (!gc-\u003ecq_table)\n+\tcq_table = vcalloc(num_cqs, sizeof(*cq_table));\n+\tif (!cq_table)\n \t\treturn -ENOMEM;\n \n-\tgc-\u003ecq_table[cq-\u003eid] = cq;\n+\tgc-\u003emax_num_cqs = num_cqs;\n+\n+\trcu_assign_pointer(cq_table[cq_id], cq);\n+\t/* Publish the fully-initialised table last; pairs with the\n+\t * rcu_dereference(gc-\u003ecq_table) in mana_gd_process_eqe().\n+\t */\n+\trcu_assign_pointer(gc-\u003ecq_table, cq_table);\n \n \treturn 0;\n }\n@@ -728,14 +943,14 @@ static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth,\n \t\tgoto out;\n \t}\n \n-\terr = mana_hwc_create_wq(hwc, GDMA_RQ, q_depth, max_req_msg_size,\n+\terr = mana_hwc_create_wq(hwc, GDMA_RQ, q_depth, max_resp_msg_size,\n \t\t\t\t hwc-\u003ecq, \u0026hwc-\u003erxq);\n \tif (err) {\n \t\tdev_err(hwc-\u003edev, \"Failed to create HWC RQ: %d\\n\", err);\n \t\tgoto out;\n \t}\n \n-\terr = mana_hwc_create_wq(hwc, GDMA_SQ, q_depth, max_resp_msg_size,\n+\terr = mana_hwc_create_wq(hwc, GDMA_SQ, q_depth, max_req_msg_size,\n \t\t\t\t hwc-\u003ecq, \u0026hwc-\u003etxq);\n \tif (err) {\n \t\tdev_err(hwc-\u003edev, \"Failed to create HWC SQ: %d\\n\", err);\n@@ -744,6 +959,7 @@ static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth,\n \n \thwc-\u003enum_inflight_msg = q_depth;\n \thwc-\u003emax_req_msg_size = max_req_msg_size;\n+\thwc-\u003emax_resp_msg_size = max_resp_msg_size;\n \n \treturn 0;\n out:\n@@ -811,27 +1027,50 @@ int mana_hwc_create_channel(struct gdma_context *gc)\n void mana_hwc_destroy_channel(struct gdma_context *gc)\n {\n \tstruct hw_channel_context *hwc = gc-\u003ehwc.driver_data;\n+\tstruct gdma_queue __rcu **old_cq_table;\n \n \tif (!hwc)\n \t\treturn;\n \n-\t/* gc-\u003emax_num_cqs is set in mana_hwc_init_event_handler(). If it's\n-\t * non-zero, the HWC worked and we should tear down the HWC here.\n+\t/* Tear down the HWC if setup_hwc previously activated MST entries.\n+\t * This is the definitive flag — unlike max_num_cqs which depends\n+\t * on the init EQE arriving.\n+\t *\n+\t * If teardown fails the device may still have active MST entries\n+\t * and can DMA into the HWC queue buffers.  Freeing them would risk\n+\t * memory corruption on systems without an IOMMU to fault the stale\n+\t * DMA, so leak the HWC resources instead of handing the pages back\n+\t * to the allocator.  Keep setup_active set so the failure is not\n+\t * mistaken for a clean teardown.\n \t */\n-\tif (gc-\u003emax_num_cqs \u003e 0) {\n-\t\tmana_smc_teardown_hwc(\u0026gc-\u003eshm_channel, false);\n-\t\tgc-\u003emax_num_cqs = 0;\n+\tif (hwc-\u003esetup_active) {\n+\t\tint td_err = mana_smc_teardown_hwc(\u0026gc-\u003eshm_channel, false);\n+\n+\t\tif (td_err) {\n+\t\t\tdev_err(gc-\u003edev,\n+\t\t\t\t\"HWC teardown failed: %d, leaking resources\\n\",\n+\t\t\t\ttd_err);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\thwc-\u003esetup_active = false;\n \t}\n \n+\t/* Tear down the HWC CQ object first — mana_hwc_destroy_cq()\n+\t * both unpublishes the CQ from cq_table (+synchronize_rcu) and\n+\t * deregisters the HWC EQ from the interrupt handler list (via\n+\t * mana_gd_deregister_irq + synchronize_rcu), guaranteeing no\n+\t * interrupt handler can access RQ/TXQ buffers after this point.\n+\t */\n+\tif (hwc-\u003ecq)\n+\t\tmana_hwc_destroy_cq(hwc-\u003egdma_dev-\u003egdma_context, hwc-\u003ecq);\n+\n \tif (hwc-\u003etxq)\n \t\tmana_hwc_destroy_wq(hwc, hwc-\u003etxq);\n \n \tif (hwc-\u003erxq)\n \t\tmana_hwc_destroy_wq(hwc, hwc-\u003erxq);\n \n-\tif (hwc-\u003ecq)\n-\t\tmana_hwc_destroy_cq(hwc-\u003egdma_dev-\u003egdma_context, hwc-\u003ecq);\n-\n \tkfree(hwc-\u003ecaller_ctx);\n \thwc-\u003ecaller_ctx = NULL;\n \n@@ -848,8 +1087,9 @@ void mana_hwc_destroy_channel(struct gdma_context *gc)\n \tgc-\u003ehwc.driver_data = NULL;\n \tgc-\u003ehwc.gdma_context = NULL;\n \n-\tvfree(gc-\u003ecq_table);\n-\tgc-\u003ecq_table = NULL;\n+\told_cq_table = rcu_replace_pointer(gc-\u003ecq_table, NULL, true);\n+\tsynchronize_rcu();\n+\tvfree(old_cq_table);\n }\n \n int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,\n@@ -860,13 +1100,18 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,\n \tstruct hwc_wq *txq = hwc-\u003etxq;\n \tstruct gdma_req_hdr *req_msg;\n \tstruct hwc_caller_ctx *ctx;\n+\tunsigned long flags;\n+\tbool drop_resp_ref;\n \tu32 dest_vrcq = 0;\n \tu32 dest_vrq = 0;\n \tu32 command;\n+\tu32 status;\n \tu16 msg_id;\n \tint err;\n \n-\tmana_hwc_get_msg_index(hwc, \u0026msg_id);\n+\terr = mana_hwc_get_msg_index(hwc, \u0026msg_id);\n+\tif (err)\n+\t\treturn err;\n \n \ttx_wr = \u0026txq-\u003emsg_buf-\u003ereqs[msg_id];\n \n@@ -878,8 +1123,11 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,\n \t}\n \n \tctx = hwc-\u003ecaller_ctx + msg_id;\n+\n+\tspin_lock_irqsave(\u0026ctx-\u003elock, flags);\n \tctx-\u003eoutput_buf = resp;\n \tctx-\u003eoutput_buflen = resp_len;\n+\tspin_unlock_irqrestore(\u0026ctx-\u003elock, flags);\n \n \treq_msg = (struct gdma_req_hdr *)tx_wr-\u003ebuf_va;\n \tif (req)\n@@ -895,6 +1143,10 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,\n \t\tdest_vrcq = hwc-\u003epf_dest_vrcq_id;\n \t}\n \n+\t/* handle_resp()'s reference was taken in mana_hwc_get_msg_index(),\n+\t * so hardware responding immediately after the doorbell ring cannot\n+\t * release the slot before this sender is done with it.\n+\t */\n \terr = mana_hwc_post_tx_wqe(txq, tx_wr, dest_vrq, dest_vrcq, false);\n \tif (err) {\n \t\tdev_err(hwc-\u003edev, \"HWC: Failed to post send WQE: %d\\n\", err);\n@@ -907,31 +1159,95 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,\n \t\t\tdev_err(hwc-\u003edev, \"Command 0x%x timed out: %u ms\\n\",\n \t\t\t\tcommand, hwc-\u003ehwc_timeout);\n \n-\t\t/* Reduce further waiting if HWC no response */\n+\t\t/* NULL out output_buf so a late handle_resp() won't write\n+\t\t * into the caller's buffer after the sender returns, then\n+\t\t * check whether handle_resp() already delivered a valid\n+\t\t * response between the timeout firing and this lock\n+\t\t * acquisition — ctx-\u003eerror != -EINPROGRESS means it ran.\n+\t\t */\n+\t\tspin_lock_irqsave(\u0026ctx-\u003elock, flags);\n+\t\tctx-\u003eoutput_buf = NULL;\n+\t\terr = ctx-\u003eerror;\n+\t\tstatus = ctx-\u003estatus_code;\n+\t\tspin_unlock_irqrestore(\u0026ctx-\u003elock, flags);\n+\n+\t\tif (err != -EINPROGRESS) {\n+\t\t\t/* handle_resp() delivered a valid response just after\n+\t\t\t * the timeout fired.  The hardware is alive, so use\n+\t\t\t * the response and leave the channel usable; do not\n+\t\t\t * latch hwc_timed_out or degrade hwc_timeout for what\n+\t\t\t * turned out to be a transient race.\n+\t\t\t */\n+\t\t\thwc_ctx_put(hwc, ctx);\n+\t\t\tgoto check_status;\n+\t\t}\n+\n+\t\t/* Genuine timeout: no response arrived.  Reduce further\n+\t\t * waiting, and mark the channel timed out under the bitmap\n+\t\t * lock so get_msg_index() cannot acquire new slots after this.\n+\t\t */\n \t\tif (hwc-\u003ehwc_timeout \u003e 1)\n \t\t\thwc-\u003ehwc_timeout = 1;\n \n+\t\tspin_lock_irqsave(\u0026hwc-\u003einflight_msg_res.lock, flags);\n+\t\tWRITE_ONCE(hwc-\u003ehwc_timed_out, true);\n+\t\tspin_unlock_irqrestore(\u0026hwc-\u003einflight_msg_res.lock, flags);\n+\t\twake_up_all(\u0026hwc-\u003emsg_waitq);\n+\n \t\terr = -ETIMEDOUT;\n-\t\tgoto out;\n+\t\thwc_ctx_put(hwc, ctx);\n+\t\tgoto done;\n \t}\n \n-\tif (ctx-\u003eerror) {\n-\t\terr = ctx-\u003eerror;\n-\t\tgoto out;\n-\t}\n+\t/* NULL output_buf so a late handle_resp() won't memcpy into\n+\t * the caller's buffer after the sender exits.  Read error and\n+\t * status_code under the same lock — after hwc_ctx_put the slot\n+\t * may be reused and these fields overwritten.\n+\t */\n+\tspin_lock_irqsave(\u0026ctx-\u003elock, flags);\n+\tctx-\u003eoutput_buf = NULL;\n+\terr = ctx-\u003eerror;\n+\tstatus = ctx-\u003estatus_code;\n+\tspin_unlock_irqrestore(\u0026ctx-\u003elock, flags);\n+\thwc_ctx_put(hwc, ctx);\n+\n+check_status:\n+\tif (err)\n+\t\tgoto done;\n \n-\tif (ctx-\u003estatus_code \u0026\u0026 ctx-\u003estatus_code != GDMA_STATUS_MORE_ENTRIES) {\n-\t\tif (ctx-\u003estatus_code == GDMA_STATUS_CMD_UNSUPPORTED) {\n+\tif (status \u0026\u0026 status != GDMA_STATUS_MORE_ENTRIES) {\n+\t\tif (status == GDMA_STATUS_CMD_UNSUPPORTED) {\n \t\t\terr = -EOPNOTSUPP;\n-\t\t\tgoto out;\n+\t\t\tgoto done;\n \t\t}\n+\n \t\tif (command != MANA_QUERY_PHY_STAT)\n \t\t\tdev_err(hwc-\u003edev, \"Command 0x%x failed with status: 0x%x\\n\",\n-\t\t\t\tcommand, ctx-\u003estatus_code);\n+\t\t\t\tcommand, status);\n \t\terr = -EPROTO;\n-\t\tgoto out;\n+\t\tgoto done;\n \t}\n+\n+\terr = 0;\n+\tgoto done;\n out:\n-\tmana_hwc_put_msg_index(hwc, msg_id);\n+\t/* Pre-post error paths: the request was never submitted, so in the\n+\t * common case mana_hwc_handle_resp() will not run for this slot and\n+\t * the sender must drop both the response-side reference taken in\n+\t * mana_hwc_get_msg_index() and its own.  Guard against a stale or\n+\t * forged response that raced in first: latch -\u003eresponded under the\n+\t * lock so any later handle_resp() is a no-op, and drop the response-\n+\t * side reference here only if handle_resp() has not already done so.\n+\t */\n+\tctx = hwc-\u003ecaller_ctx + msg_id;\n+\tspin_lock_irqsave(\u0026ctx-\u003elock, flags);\n+\tctx-\u003eoutput_buf = NULL;\n+\tdrop_resp_ref = !ctx-\u003eresponded;\n+\tctx-\u003eresponded = true;\n+\tspin_unlock_irqrestore(\u0026ctx-\u003elock, flags);\n+\tif (drop_resp_ref)\n+\t\trefcount_dec(\u0026ctx-\u003erefcnt);\n+\thwc_ctx_put(hwc, ctx);\n+done:\n \treturn err;\n }\ndiff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c\nindex 92bb55935c1c4..5d215981bba83 100644\n--- a/drivers/net/ethernet/microsoft/mana/mana_en.c\n+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c\n@@ -2427,12 +2427,18 @@ static void mana_deinit_txq(struct mana_port_context *apc, struct mana_txq *txq)\n \n static void mana_destroy_txq(struct mana_port_context *apc)\n {\n+\tstruct gdma_context *gc = apc-\u003eac-\u003egdma_dev-\u003egdma_context;\n \tstruct napi_struct *napi;\n \tint i;\n \n \tif (!apc-\u003etx_qp)\n \t\treturn;\n \n+\t/* Pass 1: quiesce each CQ on the device and clear its cq_table slot.\n+\t * Taking one grace period below for the whole port avoids up to\n+\t * apc-\u003enum_queues serialized synchronize_rcu() calls (one per CQ in\n+\t * mana_gd_destroy_cq()) under RTNL on every teardown.\n+\t */\n \tfor (i = 0; i \u003c apc-\u003enum_queues; i++) {\n \t\tif (!apc-\u003etx_qp[i])\n \t\t\tcontinue;\n@@ -2448,8 +2454,24 @@ static void mana_destroy_txq(struct mana_port_context *apc)\n \t\t\tapc-\u003etx_qp[i]-\u003etxq.napi_initialized = false;\n \t\t}\n \n-\t\tif (apc-\u003etx_qp[i]-\u003etx_object != INVALID_MANA_HANDLE)\n-\t\t\tmana_destroy_wq_obj(apc, GDMA_SQ, apc-\u003etx_qp[i]-\u003etx_object);\n+\t\tif (apc-\u003etx_qp[i]-\u003etx_object != INVALID_MANA_HANDLE) {\n+\t\t\tmana_destroy_wq_obj(apc, GDMA_SQ,\n+\t\t\t\t\t    apc-\u003etx_qp[i]-\u003etx_object);\n+\t\t\tapc-\u003etx_qp[i]-\u003etx_object = INVALID_MANA_HANDLE;\n+\t\t}\n+\n+\t\tif (apc-\u003etx_qp[i]-\u003etx_cq.gdma_cq)\n+\t\t\tmana_gd_unpublish_cq(gc, apc-\u003etx_qp[i]-\u003etx_cq.gdma_cq);\n+\t}\n+\n+\tsynchronize_rcu();\n+\n+\t/* Pass 2: the slots are clear, so mana_gd_destroy_cq() skips its own\n+\t * grace period; free the CQ, the TXQ and the queue pair.\n+\t */\n+\tfor (i = 0; i \u003c apc-\u003enum_queues; i++) {\n+\t\tif (!apc-\u003etx_qp[i])\n+\t\t\tcontinue;\n \n \t\tmana_deinit_cq(apc, \u0026apc-\u003etx_qp[i]-\u003etx_cq);\n \n@@ -2496,6 +2518,7 @@ static int mana_create_txq(struct mana_port_context *apc,\n \tstruct mana_obj_spec cq_spec;\n \tstruct gdma_queue_spec spec;\n \tstruct gdma_context *gc;\n+\tstruct gdma_queue __rcu **cq_table;\n \tstruct mana_txq *txq;\n \tstruct mana_cq *cq;\n \tu32 txq_size;\n@@ -2596,12 +2619,18 @@ static int mana_create_txq(struct mana_port_context *apc,\n \n \t\tcq-\u003egdma_id = cq-\u003egdma_cq-\u003eid;\n \n-\t\tif (WARN_ON(cq-\u003egdma_id \u003e= gc-\u003emax_num_cqs)) {\n+\t\t/* No rcu_read_lock(): mana_create_txq runs under RTNL during\n+\t\t * netdev bring-up, inside the netdev lifetime that\n+\t\t * mana_remove() drains before the base cq_table can be freed.\n+\t\t * See gdma_context::cq_table in gdma.h for why \"true\" is sound.\n+\t\t */\n+\t\tcq_table = rcu_dereference_protected(gc-\u003ecq_table, true);\n+\t\tif (WARN_ON(!cq_table || cq-\u003egdma_id \u003e= gc-\u003emax_num_cqs)) {\n \t\t\terr = -EINVAL;\n \t\t\tgoto out;\n \t\t}\n \n-\t\tgc-\u003ecq_table[cq-\u003egdma_id] = cq-\u003egdma_cq;\n+\t\trcu_assign_pointer(cq_table[cq-\u003egdma_id], cq-\u003egdma_cq);\n \n \t\tmana_create_txq_debugfs(apc, i);\n \n@@ -2621,25 +2650,20 @@ static int mana_create_txq(struct mana_port_context *apc,\n \treturn err;\n }\n \n-static void mana_destroy_rxq(struct mana_port_context *apc,\n+/* Quiesce an RXQ's CQ on the device and clear its cq_table slot, without\n+ * waiting for a grace period.  Split out of mana_destroy_rxq() so a batch\n+ * teardown (mana_destroy_rxqs()) can quiesce every RXQ and then take a\n+ * single synchronize_rcu() instead of one per RXQ.\n+ */\n+static void mana_quiesce_rxq(struct mana_port_context *apc,\n \t\t\t     struct mana_rxq *rxq, bool napi_initialized)\n-\n {\n \tstruct gdma_context *gc = apc-\u003eac-\u003egdma_dev-\u003egdma_context;\n-\tstruct mana_recv_buf_oob *rx_oob;\n-\tstruct device *dev = gc-\u003edev;\n-\tstruct napi_struct *napi;\n-\tstruct page *page;\n-\tint i;\n-\n-\tif (!rxq)\n-\t\treturn;\n+\tstruct napi_struct *napi = \u0026rxq-\u003erx_cq.napi;\n \n \tdebugfs_remove_recursive(rxq-\u003emana_rx_debugfs);\n \trxq-\u003emana_rx_debugfs = NULL;\n \n-\tnapi = \u0026rxq-\u003erx_cq.napi;\n-\n \tif (napi_initialized) {\n \t\tnapi_synchronize(napi);\n \n@@ -2650,8 +2674,27 @@ static void mana_destroy_rxq(struct mana_port_context *apc,\n \tif (xdp_rxq_info_is_reg(\u0026rxq-\u003exdp_rxq))\n \t\txdp_rxq_info_unreg(\u0026rxq-\u003exdp_rxq);\n \n-\tif (rxq-\u003erxobj != INVALID_MANA_HANDLE)\n+\tif (rxq-\u003erxobj != INVALID_MANA_HANDLE) {\n \t\tmana_destroy_wq_obj(apc, GDMA_RQ, rxq-\u003erxobj);\n+\t\trxq-\u003erxobj = INVALID_MANA_HANDLE;\n+\t}\n+\n+\tif (rxq-\u003erx_cq.gdma_cq)\n+\t\tmana_gd_unpublish_cq(gc, rxq-\u003erx_cq.gdma_cq);\n+}\n+\n+/* Free an RXQ once its cq_table slot has been cleared and a grace period\n+ * has elapsed (see mana_quiesce_rxq()).  mana_deinit_cq() -\u003e\n+ * mana_gd_destroy_cq() finds the slot already NULL and skips its own\n+ * synchronize_rcu().\n+ */\n+static void mana_free_rxq(struct mana_port_context *apc, struct mana_rxq *rxq)\n+{\n+\tstruct gdma_context *gc = apc-\u003eac-\u003egdma_dev-\u003egdma_context;\n+\tstruct mana_recv_buf_oob *rx_oob;\n+\tstruct device *dev = gc-\u003edev;\n+\tstruct page *page;\n+\tint i;\n \n \tmana_deinit_cq(apc, \u0026rxq-\u003erx_cq);\n \n@@ -2685,6 +2728,23 @@ static void mana_destroy_rxq(struct mana_port_context *apc,\n \tkvfree(rxq);\n }\n \n+static void mana_destroy_rxq(struct mana_port_context *apc,\n+\t\t\t     struct mana_rxq *rxq, bool napi_initialized)\n+\n+{\n+\tif (!rxq)\n+\t\treturn;\n+\n+\tmana_quiesce_rxq(apc, rxq, napi_initialized);\n+\n+\t/* Wait for in-flight EQ handlers that may have loaded the old CQ\n+\t * pointer via rcu_dereference() before freeing.\n+\t */\n+\tsynchronize_rcu();\n+\n+\tmana_free_rxq(apc, rxq);\n+}\n+\n static int mana_fill_rx_oob(struct mana_recv_buf_oob *rx_oob, u32 mem_key,\n \t\t\t    struct mana_rxq *rxq, struct device *dev)\n {\n@@ -2821,6 +2881,7 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,\n \tstruct gdma_queue_spec spec;\n \tstruct mana_cq *cq = NULL;\n \tstruct gdma_context *gc;\n+\tstruct gdma_queue __rcu **cq_table;\n \tu32 cq_size, rq_size;\n \tstruct mana_rxq *rxq;\n \tint err;\n@@ -2905,12 +2966,18 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,\n \tif (err)\n \t\tgoto out;\n \n-\tif (WARN_ON(cq-\u003egdma_id \u003e= gc-\u003emax_num_cqs)) {\n+\t/* No rcu_read_lock(): mana_create_rxq runs under RTNL during netdev\n+\t * bring-up, inside the netdev lifetime that mana_remove() drains\n+\t * before the base cq_table can be freed.  See gdma_context::cq_table\n+\t * in gdma.h for why \"true\" is sound.\n+\t */\n+\tcq_table = rcu_dereference_protected(gc-\u003ecq_table, true);\n+\tif (WARN_ON(!cq_table || cq-\u003egdma_id \u003e= gc-\u003emax_num_cqs)) {\n \t\terr = -EINVAL;\n \t\tgoto out;\n \t}\n \n-\tgc-\u003ecq_table[cq-\u003egdma_id] = cq-\u003egdma_cq;\n+\trcu_assign_pointer(cq_table[cq-\u003egdma_id], cq-\u003egdma_cq);\n \n \tnetif_napi_add_weight_locked(ndev, \u0026cq-\u003enapi, mana_poll, 1);\n \n@@ -2987,16 +3054,31 @@ static void mana_destroy_rxqs(struct mana_port_context *apc)\n \tstruct mana_rxq *rxq;\n \tu32 rxq_idx;\n \n-\tif (apc-\u003erxqs) {\n+\tif (!apc-\u003erxqs)\n+\t\treturn;\n \n-\t\tfor (rxq_idx = 0; rxq_idx \u003c apc-\u003enum_queues; rxq_idx++) {\n-\t\t\trxq = apc-\u003erxqs[rxq_idx];\n-\t\t\tif (!rxq)\n-\t\t\t\tcontinue;\n+\t/* Pass 1: quiesce every RXQ's CQ and clear its cq_table slot. */\n+\tfor (rxq_idx = 0; rxq_idx \u003c apc-\u003enum_queues; rxq_idx++) {\n+\t\trxq = apc-\u003erxqs[rxq_idx];\n+\t\tif (!rxq)\n+\t\t\tcontinue;\n \n-\t\t\tmana_destroy_rxq(apc, rxq, true);\n-\t\t\tapc-\u003erxqs[rxq_idx] = NULL;\n-\t\t}\n+\t\tmana_quiesce_rxq(apc, rxq, true);\n+\t}\n+\n+\t/* One grace period for the whole port instead of one per RXQ. */\n+\tsynchronize_rcu();\n+\n+\t/* Pass 2: the slots are clear, so mana_gd_destroy_cq() skips its own\n+\t * grace period; free each RXQ.\n+\t */\n+\tfor (rxq_idx = 0; rxq_idx \u003c apc-\u003enum_queues; rxq_idx++) {\n+\t\trxq = apc-\u003erxqs[rxq_idx];\n+\t\tif (!rxq)\n+\t\t\tcontinue;\n+\n+\t\tmana_free_rxq(apc, rxq);\n+\t\tapc-\u003erxqs[rxq_idx] = NULL;\n \t}\n }\n \ndiff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h\nindex 0c395917b2144..e59b8b31e8345 100644\n--- a/include/net/mana/gdma.h\n+++ b/include/net/mana/gdma.h\n@@ -416,9 +416,39 @@ struct gdma_context {\n \t/* L2 MTU */\n \tu16 adapter_mtu;\n \n-\t/* This maps a CQ index to the queue structure. */\n+\t/* Size of cq_table, i.e. the largest valid CQ index + 1.  Set once\n+\t * when cq_table is allocated and treated as immutable for the\n+\t * table's lifetime (a bound only) -- it is never reset on teardown.\n+\t * cq_table == NULL is the sole \"table torn down\" signal, so every\n+\t * cq_table[id] access must guard with both !cq_table (gone) and\n+\t * id \u003e= max_num_cqs (out of bounds).\n+\t */\n \tunsigned int\t\tmax_num_cqs;\n-\tstruct gdma_queue\t**cq_table;\n+\t/* Both the base pointer and each entry are RCU-managed.  The fast\n+\t * path (mana_gd_process_eqe) reads the base via rcu_dereference()\n+\t * under rcu_read_lock(), so the table is freed with\n+\t * rcu_assign_pointer(NULL) + synchronize_rcu() and an in-flight\n+\t * reader can never observe freed memory.\n+\t *\n+\t * The slow paths -- mana_gd_destroy_cq() and the CQ install/remove\n+\t * callers (mana_create_txq/_rxq, mana_ib_install/remove_cq_cb) --\n+\t * instead read the base with rcu_dereference_protected(cq_table,\n+\t * true).  The bare \"true\" asserts teardown/bring-up ordering, not a\n+\t * lock: the base table is allocated in mana_hwc_establish_channel()\n+\t * and replaced+freed only by mana_hwc_destroy_channel() (via\n+\t * mana_gd_cleanup_device()) and the create-time reinit.  The reinit\n+\t * runs before either consumer is probed, and cleanup_device() runs\n+\t * after mana_remove() / mana_rdma_remove() have detached the ports\n+\t * under RTNL and drained the IB device, so no install/remove caller\n+\t * is running when the base is freed.  This is an ordering argument\n+\t * about when cleanup_device() runs: suspend and shutdown keep the\n+\t * netdev registered, so it does not rely on unregister_netdevice()\n+\t * having run on every path.  mana_hwc_destroy_channel() itself reads\n+\t * cq_table (mana_hwc_destroy_cq()) before it replaces and vfree()s\n+\t * the base, so that access is ordered ahead of the free by program\n+\t * order.\n+\t */\n+\tstruct gdma_queue\t__rcu * __rcu *cq_table;\n \n \t/* Protect eq_test_event and test_event_eq_id  */\n \tstruct mutex\t\teq_test_event_mutex;\n@@ -496,6 +526,12 @@ int mana_gd_create_mana_wq_cq(struct gdma_dev *gd,\n \n void mana_gd_destroy_queue(struct gdma_context *gc, struct gdma_queue *queue);\n \n+/* Clear a CQ's cq_table slot without waiting for a grace period.  Batched\n+ * teardown paths clear several slots and then take a single synchronize_rcu();\n+ * single-CQ callers use mana_gd_destroy_cq() instead, which also waits.\n+ */\n+bool mana_gd_unpublish_cq(struct gdma_context *gc, struct gdma_queue *queue);\n+\n int mana_gd_poll_cq(struct gdma_queue *cq, struct gdma_comp *comp, int num_cqe);\n \n void mana_gd_ring_cq(struct gdma_queue *cq, u8 arm_bit);\ndiff --git a/include/net/mana/hw_channel.h b/include/net/mana/hw_channel.h\nindex 16feb39616c1b..c275150baf490 100644\n--- a/include/net/mana/hw_channel.h\n+++ b/include/net/mana/hw_channel.h\n@@ -171,8 +171,25 @@ struct hwc_caller_ctx {\n \tvoid *output_buf;\n \tu32 output_buflen;\n \n-\tu32 error; /* Linux error code */\n+\tint error; /* Linux error code (negative errno or 0) */\n \tu32 status_code;\n+\n+\t/* Protects output_buf against concurrent access from\n+\t * handle_resp() (CQ interrupt) and the sender timeout path.\n+\t */\n+\tspinlock_t lock;\n+\n+\t/* Tracks sender + handle_resp ownership.  The last put\n+\t * (refcount reaches 0) releases the bitmap slot.\n+\t */\n+\trefcount_t refcnt;\n+\tu16 msg_id;\n+\n+\t/* Set under lock by the first handle_resp() for this slot so a\n+\t * duplicate or replayed response is dropped instead of consuming\n+\t * the response-side reference a second time.\n+\t */\n+\tbool responded;\n };\n \n struct hw_channel_context {\n@@ -181,10 +198,12 @@ struct hw_channel_context {\n \n \tu16 num_inflight_msg;\n \tu32 max_req_msg_size;\n+\tu32 max_resp_msg_size;\n \n \tu16 hwc_init_q_depth_max;\n \tu32 hwc_init_max_req_msg_size;\n \tu32 hwc_init_max_resp_msg_size;\n+\tu32 hwc_init_max_num_cqs;\n \n \tstruct completion hwc_init_eqe_comp;\n \n@@ -192,13 +211,34 @@ struct hw_channel_context {\n \tstruct hwc_wq *txq;\n \tstruct hwc_cq *cq;\n \n-\tstruct semaphore sema;\n \tstruct gdma_resource inflight_msg_res;\n+\t/* Waitqueue for senders blocked on a full inflight bitmap. */\n+\twait_queue_head_t msg_waitq;\n \n \tu32 pf_dest_vrq_id;\n \tu32 pf_dest_vrcq_id;\n \tu32 hwc_timeout;\n \n+\t/* Count of RX WQEs deliberately not reposted after an untrusted SGE\n+\t * (see mana_hwc_rx_leak_wqe()); once it reaches the RQ depth the\n+\t * channel can no longer receive responses.\n+\t */\n+\tu32 rx_leaked_wqe;\n+\n+\t/* Set on first HWC timeout.  Causes get_msg_index() to return\n+\t * -ETIMEDOUT instead of waiting, draining all queued senders.\n+\t */\n+\tbool hwc_timed_out;\n+\n+\t/* Set after mana_smc_setup_hwc() succeeds (hardware has active\n+\t * MST entries).  Cleared only after mana_smc_teardown_hwc()\n+\t * succeeds, on both the recoverable establish_channel path and the\n+\t * terminal destroy_channel path.  If teardown fails it stays set:\n+\t * establish_channel() skips its retry and destroy_channel() leaks\n+\t * the HWC rather than free buffers the device may still DMA into.\n+\t */\n+\tbool setup_active;\n+\n \tstruct hwc_caller_ctx *caller_ctx;\n };\n \n"
}

2/1 2026/08/09 19:08 agent patch-evaluator
1m Model:
best-expensive

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch exclusively modifies the Microsoft Azure Network Adapter (MANA) driver, which is a vendor-specific SmartNIC driver. This hardware is not emulated in standard QEMU or GCE environments. Following the instructions to exclude vendor-specific SmartNIC drivers that require physical PCIe hardware not emulated in standard QEMU, this patch is not worth fuzzing.",
  "WorthFuzzing": false
}

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).
- Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed,
  ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU.
- Driver .remove, .shutdown, or pci_unregister_driver teardown callbacks (e.g., igb_remove)
  that are executed only during PCI hot-unplug or sysfs driver unbind operations.

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.
   Prefer non-static, non-inlined API entrypoint functions over internal static helper functions
   (which are inlined by the compiler and do not have distinct symbol addresses).
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.
   Also check "depends on" lines in Kconfig to include any non-standard parent subsystem configs
   needed for Kbuild to compile the code statically into vmlinux. 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 39e9409a76f26cae7e33f983e28ec6c35349732c
Author: syz-cluster <triage@syzkaller.com>
Date:   Sun Aug 9 19:08:09 2026 +0000

    syz-cluster: applied patch under review

diff --git a/drivers/infiniband/hw/mana/cq.c b/drivers/infiniband/hw/mana/cq.c
index f2547989f4229..2bf4be21cede7 100644
--- a/drivers/infiniband/hw/mana/cq.c
+++ b/drivers/infiniband/hw/mana/cq.c
@@ -131,12 +131,20 @@ static void mana_ib_cq_handler(void *ctx, struct gdma_queue *gdma_cq)
 int mana_ib_install_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq *cq)
 {
 	struct gdma_context *gc = mdev_to_gc(mdev);
+	struct gdma_queue __rcu **cq_table;
 	struct gdma_queue *gdma_cq;
 
-	if (cq->queue.id >= gc->max_num_cqs)
+	/* No rcu_read_lock(): install/remove run within the IB device
+	 * lifetime, which mana_rdma_remove() (ib_unregister_device) drains
+	 * before the base cq_table can be freed.  See gdma_context::cq_table
+	 * in gdma.h for why "true" is sound.
+	 */
+	cq_table = rcu_dereference_protected(gc->cq_table, true);
+	if (!cq_table || cq->queue.id >= gc->max_num_cqs)
 		return -EINVAL;
+
 	/* Create CQ table entry, sharing a CQ between WQs is not supported */
-	if (gc->cq_table[cq->queue.id])
+	if (rcu_access_pointer(cq_table[cq->queue.id]))
 		return -EINVAL;
 	if (cq->queue.kmem)
 		gdma_cq = cq->queue.kmem;
@@ -149,23 +157,49 @@ int mana_ib_install_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq *cq)
 	gdma_cq->type = GDMA_CQ;
 	gdma_cq->cq.callback = mana_ib_cq_handler;
 	gdma_cq->id = cq->queue.id;
-	gc->cq_table[cq->queue.id] = gdma_cq;
+	rcu_assign_pointer(cq_table[cq->queue.id], gdma_cq);
 	return 0;
 }
 
 void mana_ib_remove_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq *cq)
 {
 	struct gdma_context *gc = mdev_to_gc(mdev);
+	struct gdma_queue __rcu **cq_table;
+	struct gdma_queue *gdma_cq;
 
-	if (cq->queue.id >= gc->max_num_cqs || cq->queue.id == INVALID_QUEUE_ID)
+	if (cq->queue.id == INVALID_QUEUE_ID)
 		return;
 
 	if (cq->queue.kmem)
 	/* Then it will be cleaned and removed by the mana */
 		return;
 
-	kfree(gc->cq_table[cq->queue.id]);
-	gc->cq_table[cq->queue.id] = NULL;
+	/* No rcu_read_lock(): like mana_ib_install_cq_cb(), this runs within
+	 * the IB device lifetime that mana_rdma_remove() drains before the
+	 * base cq_table can be freed.  See gdma_context::cq_table in gdma.h.
+	 */
+	cq_table = rcu_dereference_protected(gc->cq_table, true);
+	if (!cq_table || cq->queue.id >= gc->max_num_cqs)
+		return;
+	/* Removers for a given CQ are serialized by the IB core, so the slot
+	 * is read and cleared without rcu_read_lock() or atomicity: a CQ is
+	 * never torn down while a live QP references it (cq->usecnt), nor
+	 * while the QP-create that installed the entry is still running (that
+	 * create holds a reference on the CQ uobject across its error path,
+	 * before usecnt is taken).  Any double-remove is therefore sequential
+	 * -- the later caller sees the NULL stored below and returns.
+	 */
+	gdma_cq = rcu_dereference_protected(cq_table[cq->queue.id], true);
+	if (!gdma_cq)
+		return;  /* already removed by a prior teardown path */
+
+	rcu_assign_pointer(cq_table[cq->queue.id], NULL);
+
+	/* Wait for in-flight EQ handlers that may have loaded the old
+	 * pointer via rcu_dereference() to finish before freeing.
+	 */
+	synchronize_rcu();
+	kfree(gdma_cq);
 }
 
 int mana_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c
index e8b7ffb47eb98..9c2f5e0cfcbc1 100644
--- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
+++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
@@ -310,7 +310,12 @@ static int mana_gd_query_hwc_timeout(struct pci_dev *pdev, u32 *timeout_val)
 	if (err || resp.hdr.status)
 		return err ? err : -EPROTO;
 
-	*timeout_val = resp.timeout_ms;
+	/* A zero timeout would make every HWC command time out immediately
+	 * and latch the channel (see the HWC_DATA_CFG_HWC_TIMEOUT handler).
+	 * Ignore a zero from the device and keep the caller's positive value.
+	 */
+	if (resp.timeout_ms)
+		*timeout_val = resp.timeout_ms;
 
 	return 0;
 }
@@ -732,6 +737,7 @@ static void mana_gd_process_eqe(struct gdma_queue *eq)
 	union gdma_eqe_info eqe_info;
 	enum gdma_eqe_type type;
 	struct gdma_event event;
+	struct gdma_queue __rcu **cq_table;
 	struct gdma_queue *cq;
 	struct gdma_eqe *eqe;
 	u32 cq_id;
@@ -743,10 +749,11 @@ static void mana_gd_process_eqe(struct gdma_queue *eq)
 	switch (type) {
 	case GDMA_EQE_COMPLETION:
 		cq_id = eqe->details[0] & 0xFFFFFF;
-		if (WARN_ON_ONCE(cq_id >= gc->max_num_cqs))
+		cq_table = rcu_dereference(gc->cq_table);
+		if (WARN_ON_ONCE(cq_id >= gc->max_num_cqs || !cq_table))
 			break;
 
-		cq = gc->cq_table[cq_id];
+		cq = rcu_dereference(cq_table[cq_id]);
 		if (WARN_ON_ONCE(!cq || cq->type != GDMA_CQ || cq->id != cq_id))
 			break;
 
@@ -1050,18 +1057,41 @@ static void mana_gd_create_cq(const struct gdma_queue_spec *spec,
 	queue->cq.callback = spec->cq.callback;
 }
 
-static void mana_gd_destroy_cq(struct gdma_context *gc,
-			       struct gdma_queue *queue)
+bool mana_gd_unpublish_cq(struct gdma_context *gc, struct gdma_queue *queue)
 {
+	struct gdma_queue __rcu **cq_table;
 	u32 id = queue->id;
 
-	if (id >= gc->max_num_cqs)
-		return;
+	/* No rcu_read_lock() here: unpublish runs only on the
+	 * CQ-destroy/teardown path, where the base cq_table is stable.  See
+	 * the lifecycle note on gdma_context::cq_table in gdma.h for why the
+	 * "true" predicate is sound.
+	 */
+	cq_table = rcu_dereference_protected(gc->cq_table, true);
+	if (!cq_table || id >= gc->max_num_cqs)
+		return false;
+
+	if (!rcu_access_pointer(cq_table[id]))
+		return false;
 
-	if (!gc->cq_table[id])
+	rcu_assign_pointer(cq_table[id], NULL);
+	return true;
+}
+
+static void mana_gd_destroy_cq(struct gdma_context *gc,
+			       struct gdma_queue *queue)
+{
+	/* A batched teardown may already have cleared the slot and taken the
+	 * grace period; then there is nothing left to wait for.
+	 */
+	if (!mana_gd_unpublish_cq(gc, queue))
 		return;
 
-	gc->cq_table[id] = NULL;
+	/* Wait for in-flight EQ handlers that may have loaded the old
+	 * pointer via rcu_dereference() to finish before the caller
+	 * frees the CQ memory.
+	 */
+	synchronize_rcu();
 }
 
 int mana_gd_create_hwc_queue(struct gdma_dev *gd,
diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net/ethernet/microsoft/mana/hw_channel.c
index e3c24d50dad07..03b5e2f02e352 100644
--- a/drivers/net/ethernet/microsoft/mana/hw_channel.c
+++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c
@@ -4,27 +4,61 @@
 #include <net/mana/gdma.h>
 #include <net/mana/mana.h>
 #include <net/mana/hw_channel.h>
+#include <linux/pci.h>
 #include <linux/vmalloc.h>
 
+/* Acquire a free message slot from the inflight bitmap.  Returns
+ * -ETIMEDOUT if a prior HWC command has timed out (preserving the
+ * error code callers expect).
+ */
 static int mana_hwc_get_msg_index(struct hw_channel_context *hwc, u16 *msg_id)
 {
 	struct gdma_resource *r = &hwc->inflight_msg_res;
 	unsigned long flags;
 	u32 index;
 
-	down(&hwc->sema);
+	for (;;) {
+		spin_lock_irqsave(&r->lock, flags);
 
-	spin_lock_irqsave(&r->lock, flags);
+		if (hwc->hwc_timed_out) {
+			spin_unlock_irqrestore(&r->lock, flags);
+			return -ETIMEDOUT;
+		}
 
-	index = find_first_zero_bit(hwc->inflight_msg_res.map,
-				    hwc->inflight_msg_res.size);
+		index = find_first_zero_bit(r->map, r->size);
+		if (index < r->size) {
+			struct hwc_caller_ctx *ctx;
+
+			bitmap_set(r->map, index, 1);
+			ctx = &hwc->caller_ctx[index];
+			reinit_completion(&ctx->comp_event);
+			/* Take the response-side reference here, under
+			 * r->lock and together with the slot bitmap bit,
+			 * so a stale or duplicate response that lands
+			 * before mana_hwc_send_request() posts the request
+			 * cannot drop the refcount to zero and free the
+			 * slot under the sender.  One reference is the
+			 * sender's; the other is released by
+			 * mana_hwc_handle_resp().
+			 */
+			refcount_set(&ctx->refcnt, 2);
+			ctx->responded = false;
+			ctx->msg_id = index;
+			ctx->error = -EINPROGRESS;
+			spin_unlock_irqrestore(&r->lock, flags);
+			break;
+		}
+		spin_unlock_irqrestore(&r->lock, flags);
 
-	bitmap_set(hwc->inflight_msg_res.map, index, 1);
+		wait_event(hwc->msg_waitq,
+			   READ_ONCE(hwc->hwc_timed_out) ||
+			   !bitmap_full(r->map, r->size));
 
-	spin_unlock_irqrestore(&r->lock, flags);
+		if (READ_ONCE(hwc->hwc_timed_out))
+			return -ETIMEDOUT;
+	}
 
 	*msg_id = index;
-
 	return 0;
 }
 
@@ -34,10 +68,17 @@ static void mana_hwc_put_msg_index(struct hw_channel_context *hwc, u16 msg_id)
 	unsigned long flags;
 
 	spin_lock_irqsave(&r->lock, flags);
-	bitmap_clear(hwc->inflight_msg_res.map, msg_id, 1);
+	bitmap_clear(r->map, msg_id, 1);
 	spin_unlock_irqrestore(&r->lock, flags);
 
-	up(&hwc->sema);
+	wake_up(&hwc->msg_waitq);
+}
+
+static void hwc_ctx_put(struct hw_channel_context *hwc,
+			struct hwc_caller_ctx *ctx)
+{
+	if (refcount_dec_and_test(&ctx->refcnt))
+		mana_hwc_put_msg_index(hwc, ctx->msg_id);
 }
 
 static int mana_hwc_verify_resp_msg(const struct hwc_caller_ctx *caller_ctx,
@@ -83,6 +124,19 @@ static void mana_hwc_handle_resp(struct hw_channel_context *hwc, u32 resp_len,
 	struct hwc_caller_ctx *ctx;
 	int err;
 
+	/* Defence in depth: the sole caller, mana_hwc_rx_event_handler(),
+	 * already rejects msg_id >= hwc->num_inflight_msg with the value it
+	 * passes here by value, so this cannot be reached out of range.  Keep
+	 * the guard at the indexing site so the bitmap and caller_ctx array
+	 * are never indexed without a bound in view.
+	 */
+	if (msg_id >= hwc->num_inflight_msg) {
+		dev_err(hwc->dev, "hwc_rx: msg_id %u >= max %u\n",
+			msg_id, hwc->num_inflight_msg);
+		mana_hwc_post_rx_wqe(hwc->rxq, rx_req);
+		return;
+	}
+
 	if (!test_bit(msg_id, hwc->inflight_msg_res.map)) {
 		dev_err(hwc->dev, "hwc_rx: invalid msg_id = %u\n", msg_id);
 		mana_hwc_post_rx_wqe(hwc->rxq, rx_req);
@@ -90,22 +144,56 @@ static void mana_hwc_handle_resp(struct hw_channel_context *hwc, u32 resp_len,
 	}
 
 	ctx = hwc->caller_ctx + msg_id;
-	err = mana_hwc_verify_resp_msg(ctx, resp_msg, resp_len);
-	if (err)
-		goto out;
 
-	ctx->status_code = resp_msg->status;
+	/* Reject responses larger than the RX DMA buffer — the SGE
+	 * limits what hardware can DMA, so an oversized resp_len
+	 * indicates a firmware bug.  Fail rather than silently
+	 * truncating.
+	 */
+	if (resp_len > rx_req->buf_len) {
+		dev_err(hwc->dev, "HWC RX: resp_len %u > buf_len %u\n",
+			resp_len, rx_req->buf_len);
+		resp_len = 0;
+	}
 
-	memcpy(ctx->output_buf, resp_msg, resp_len);
-out:
-	ctx->error = err;
+	spin_lock(&ctx->lock);
+
+	if (ctx->responded) {
+		/* A response for this slot was already delivered; this is a
+		 * duplicate or replayed one.  Drop it so the hwc_ctx_put()
+		 * a first response performs is not done twice, which would
+		 * over-release the slot while the sender still owns it.
+		 */
+		spin_unlock(&ctx->lock);
+		mana_hwc_post_rx_wqe(hwc->rxq, rx_req);
+		return;
+	}
+	ctx->responded = true;
+
+	err = mana_hwc_verify_resp_msg(ctx, resp_msg, resp_len);
+
+	if (!err && ctx->output_buf) {
+		ctx->status_code = resp_msg->status;
+		memcpy(ctx->output_buf, resp_msg, resp_len);
+		ctx->error = 0;
+	} else if (ctx->output_buf) {
+		/* Record the error only while the sender still owns the
+		 * request: a non-NULL output_buf means it is still waiting.
+		 * Once it has timed out (or been force-completed by destroy)
+		 * it clears output_buf and takes its own error, so a late
+		 * response must not write ctx->error or the buffer here.
+		 */
+		ctx->error = err;
+	}
 
-	/* Must post rx wqe before complete(), otherwise the next rx may
-	 * hit no_wqe error.
+	/* Post RX WQE before completing — the next response may arrive
+	 * immediately and needs a posted buffer.
 	 */
 	mana_hwc_post_rx_wqe(hwc->rxq, rx_req);
-
 	complete(&ctx->comp_event);
+	spin_unlock(&ctx->lock);
+
+	hwc_ctx_put(hwc, ctx);
 }
 
 static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,
@@ -158,7 +246,15 @@ static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,
 			break;
 
 		case HWC_INIT_DATA_MAX_NUM_CQS:
-			gd->gdma_context->max_num_cqs = val;
+			/* Store, don't apply: mana_hwc_establish_channel()
+			 * commits this to gc->max_num_cqs once, together
+			 * with sizing cq_table, so a spoofed post-init event
+			 * cannot inflate the bound past the allocation.
+			 * WRITE_ONCE() pairs with the READ_ONCE() there:
+			 * this store runs in EQ interrupt context,
+			 * concurrently with that process-context read.
+			 */
+			WRITE_ONCE(hwc->hwc_init_max_num_cqs, val);
 			break;
 
 		case HWC_INIT_DATA_PDID:
@@ -192,7 +288,12 @@ static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,
 
 		switch (type) {
 		case HWC_DATA_CFG_HWC_TIMEOUT:
-			hwc->hwc_timeout = val;
+			/* A zero timeout would make every command time out
+			 * immediately and latch hwc_timed_out, disabling the
+			 * channel.  Ignore it and keep the positive default.
+			 */
+			if (val)
+				hwc->hwc_timeout = val;
 			break;
 
 		case HWC_DATA_HW_LINK_CONNECT:
@@ -237,18 +338,39 @@ static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,
 	}
 }
 
+/* An RX WQE whose SGE the handler cannot trust is deliberately not
+ * reposted: reposting a slot we may have mis-identified could double-post
+ * a buffer the device still owns.  Each such leak permanently lowers the
+ * RQ's posted depth, so once the whole depth is gone the channel can no
+ * longer receive responses.  Make that terminal state explicit -- log it
+ * once and shorten the command timeout so callers fail fast -- rather than
+ * letting every later command drain its full timeout against a dead RQ.
+ */
+static void mana_hwc_rx_leak_wqe(struct hw_channel_context *hwc)
+{
+	if (++hwc->rx_leaked_wqe == hwc->rxq->queue_depth) {
+		dev_err(hwc->dev,
+			"HWC RX: RQ exhausted after %u leaked WQEs; channel unusable\n",
+			hwc->rx_leaked_wqe);
+		hwc->hwc_timeout = 1;
+	}
+}
+
 static void mana_hwc_rx_event_handler(void *ctx, u32 gdma_rxq_id,
 				      const struct hwc_rx_oob *rx_oob)
 {
 	struct hw_channel_context *hwc = ctx;
 	struct hwc_wq *hwc_rxq = hwc->rxq;
 	struct hwc_work_request *rx_req;
+	struct gdma_wqe oob_snapshot;
 	struct gdma_resp_hdr *resp;
 	struct gdma_wqe *dma_oob;
 	struct gdma_queue *rq;
 	struct gdma_sge *sge;
 	u64 rq_base_addr;
 	u64 rx_req_idx;
+	u64 sge_addr;
+	u32 oob_div4;
 	u16 msg_id;
 	u8 *wqe;
 
@@ -259,28 +381,76 @@ static void mana_hwc_rx_event_handler(void *ctx, u32 gdma_rxq_id,
 	wqe = mana_gd_get_wqe_ptr(rq, rx_oob->wqe_offset / GDMA_WQE_BU_SIZE);
 	dma_oob = (struct gdma_wqe *)wqe;
 
-	sge = (struct gdma_sge *)(wqe + 8 + dma_oob->inline_oob_size_div4 * 4);
-
-	/* Select the RX work request for virtual address and for reposting. */
+	/* inline_oob_size_div4 lives in device-accessible RQ memory (shared
+	 * and host-writable in a confidential VM), so snapshot it once and
+	 * validate and use only the snapshot.  It is a bit-field, which
+	 * READ_ONCE() cannot take the size of, so read the u32 flags word it
+	 * shares through the union and extract the field from the local copy.
+	 * The driver programs INLINE_OOB_SMALL_SIZE for every HWC RQ WQE via
+	 * mana_gd_post_work_request(), so the only valid value is
+	 * INLINE_OOB_SMALL_SIZE / 4, which puts the SGE at wqe + 16 inside
+	 * this WQE's own BU.  Reject anything else -- the slot cannot be
+	 * trusted, so leak this RX WQE rather than repost the wrong one.
+	 */
+	oob_snapshot.flags = READ_ONCE(dma_oob->flags);
+	oob_div4 = oob_snapshot.inline_oob_size_div4;
+	if (oob_div4 != INLINE_OOB_SMALL_SIZE / 4) {
+		dev_err(hwc->dev, "HWC RX: unexpected inline_oob_size_div4=%u\n",
+			oob_div4);
+		mana_hwc_rx_leak_wqe(hwc);
+		return;
+	}
+	sge = (struct gdma_sge *)(wqe + 8 + oob_div4 * 4);
+
+	/* Recover the originating RX slot from the SGE address.  Snapshot it
+	 * once, for the same shared-memory reason: of the three terms only
+	 * sge_addr comes from device memory; rq_base_addr and
+	 * max_resp_msg_size are driver-private.  An in-range but wrong SGE
+	 * would otherwise truncate onto a neighbouring slot, letting us read
+	 * a stale response that could complete the wrong, reused in-flight
+	 * request.  Require the index in range AND the address to exactly
+	 * match the value the driver posted for that slot.
+	 */
+	sge_addr = READ_ONCE(sge->address);
 	rq_base_addr = hwc_rxq->msg_buf->mem_info.dma_handle;
-	rx_req_idx = (sge->address - rq_base_addr) / hwc->max_req_msg_size;
-
-	if (rx_req_idx >= hwc_rxq->msg_buf->num_reqs) {
-		dev_err(hwc->dev, "HWC RX: wrong rx_req_idx=%llu, num_reqs=%u\n",
-			rx_req_idx, hwc_rxq->msg_buf->num_reqs);
+	rx_req_idx = (sge_addr - rq_base_addr) / hwc->max_resp_msg_size;
+
+	if (rx_req_idx >= hwc_rxq->queue_depth) {
+		/* Cannot identify the slot, so we cannot safely repost this
+		 * WQE; leak it.  An out-of-range index means a corrupted SGE
+		 * from hardware or host tampering.
+		 */
+		dev_err(hwc->dev, "HWC RX: SGE idx %llu out of range\n",
+			rx_req_idx);
+		mana_hwc_rx_leak_wqe(hwc);
 		return;
 	}
 
 	rx_req = &hwc_rxq->msg_buf->reqs[rx_req_idx];
+	if (sge_addr != (u64)rx_req->buf_sge_addr) {
+		/* In-range index but the address does not match what the
+		 * driver posted for that slot; the same unrecoverable case,
+		 * so leak this WQE rather than repost the wrong one.
+		 */
+		dev_err(hwc->dev, "HWC RX: invalid SGE address %llx (idx=%llu)\n",
+			sge_addr, rx_req_idx);
+		mana_hwc_rx_leak_wqe(hwc);
+		return;
+	}
+
 	resp = (struct gdma_resp_hdr *)rx_req->buf_va;
 
-	/* Read msg_id once from DMA buffer to prevent TOCTOU:
-	 * DMA memory is shared/unencrypted in CVMs - host can
-	 * modify it between reads.
+	/* Read msg_id once from the DMA buffer to prevent TOCTOU: DMA memory
+	 * is shared/unencrypted in CVMs, so the host can modify it between
+	 * reads.  A short response is not rejected here; it is handed to
+	 * mana_hwc_handle_resp() below, whose mana_hwc_verify_resp_msg()
+	 * fails it with -EPROTO and completes the waiting sender, so one
+	 * malformed response cannot stall the whole channel.
 	 */
 	msg_id = READ_ONCE(resp->response.hwc_msg_id);
 	if (msg_id >= hwc->num_inflight_msg) {
 		dev_err(hwc->dev, "HWC RX: wrong msg_id=%u\n", msg_id);
+		mana_hwc_post_rx_wqe(hwc_rxq, rx_req);
 		return;
 	}
 
@@ -384,14 +554,24 @@ static void mana_hwc_comp_event(void *ctx, struct gdma_queue *q_self)
 
 static void mana_hwc_destroy_cq(struct gdma_context *gc, struct hwc_cq *hwc_cq)
 {
-	kfree(hwc_cq->comp_buf);
+	/* Destroy the EQ before the CQ.  mana_gd_destroy_queue() on the EQ
+	 * deregisters its IRQ and waits out in-flight handlers, fencing all
+	 * EQE dispatch — both the completion path and HWC init/reconfig
+	 * events.  Freeing the CQ first would leave the EQ live and able to
+	 * dispatch an event that dereferences hwc->cq->gdma_cq (e.g.
+	 * mana_hwc_init_event_handler()) after it has been freed.
+	 */
+	if (hwc_cq->gdma_eq)
+		mana_gd_destroy_queue(gc, hwc_cq->gdma_eq);
 
+	/* comp_buf is reached only by mana_hwc_comp_event(), invoked from
+	 * the now-fenced EQ handler, so it is safe to free once the EQ and
+	 * CQ are gone.
+	 */
 	if (hwc_cq->gdma_cq)
 		mana_gd_destroy_queue(gc, hwc_cq->gdma_cq);
 
-	if (hwc_cq->gdma_eq)
-		mana_gd_destroy_queue(gc, hwc_cq->gdma_eq);
-
+	kfree(hwc_cq->comp_buf);
 	kfree(hwc_cq);
 }
 
@@ -627,7 +807,7 @@ static int mana_hwc_init_inflight_msg(struct hw_channel_context *hwc,
 {
 	int err;
 
-	sema_init(&hwc->sema, num_msg);
+	init_waitqueue_head(&hwc->msg_waitq);
 
 	err = mana_gd_alloc_res_map(num_msg, &hwc->inflight_msg_res);
 	if (err)
@@ -657,8 +837,10 @@ static int mana_hwc_test_channel(struct hw_channel_context *hwc, u16 q_depth,
 	if (!ctx)
 		return -ENOMEM;
 
-	for (i = 0; i < q_depth; ++i)
+	for (i = 0; i < q_depth; ++i) {
+		spin_lock_init(&ctx[i].lock);
 		init_completion(&ctx[i].comp_event);
+	}
 
 	hwc->caller_ctx = ctx;
 
@@ -669,11 +851,17 @@ static int mana_hwc_establish_channel(struct gdma_context *gc, u16 *q_depth,
 				      u32 *max_req_msg_size,
 				      u32 *max_resp_msg_size)
 {
+	/* No RCU needed: called only from mana_hwc_create_channel
+	 * during init, before the channel is published to senders.
+	 */
 	struct hw_channel_context *hwc = gc->hwc.driver_data;
 	struct gdma_queue *rq = hwc->rxq->gdma_wq;
 	struct gdma_queue *sq = hwc->txq->gdma_wq;
 	struct gdma_queue *eq = hwc->cq->gdma_eq;
 	struct gdma_queue *cq = hwc->cq->gdma_cq;
+	struct gdma_queue __rcu **cq_table;
+	u32 num_cqs;
+	u32 cq_id;
 	int err;
 
 	init_completion(&hwc->hwc_init_eqe_comp);
@@ -687,6 +875,15 @@ static int mana_hwc_establish_channel(struct gdma_context *gc, u16 *q_depth,
 	if (err)
 		return err;
 
+	/* setup_hwc activated MST entries — hardware can now DMA into our
+	 * queue buffers.  Record that in setup_active so the caller's error
+	 * path (mana_hwc_create_channel() -> mana_hwc_destroy_channel())
+	 * tears the HWC down exactly once.  Do not also tear down here: a
+	 * second teardown would double the hardware timeout on failure and
+	 * mask the original error code.
+	 */
+	hwc->setup_active = true;
+
 	if (!wait_for_completion_timeout(&hwc->hwc_init_eqe_comp, 60 * HZ))
 		return -ETIMEDOUT;
 
@@ -694,15 +891,33 @@ static int mana_hwc_establish_channel(struct gdma_context *gc, u16 *q_depth,
 	*max_req_msg_size = hwc->hwc_init_max_req_msg_size;
 	*max_resp_msg_size = hwc->hwc_init_max_resp_msg_size;
 
-	/* Both were set in mana_hwc_init_event_handler(). */
-	if (WARN_ON(cq->id >= gc->max_num_cqs))
+	/* Snapshot the device-reported CQ count and CQ id into locals and
+	 * use only the locals below, so the same value that sizes cq_table
+	 * also bounds and indexes it -- even across the sleeping vcalloc().
+	 * Both fields are written by mana_hwc_init_event_handler() from EQ
+	 * interrupt context: hwc_init_max_num_cqs under WRITE_ONCE() (paired
+	 * here), and cq->id as an ordinary store.  READ_ONCE() keeps each
+	 * read tear-free and, crucially, non-reloadable, so a spoofed
+	 * post-init event cannot make the WARN_ON() pass against one value
+	 * while the allocation or the index uses another.
+	 */
+	num_cqs = READ_ONCE(hwc->hwc_init_max_num_cqs);
+	cq_id = READ_ONCE(cq->id);
+
+	if (WARN_ON(cq_id >= num_cqs))
 		return -EPROTO;
 
-	gc->cq_table = vcalloc(gc->max_num_cqs, sizeof(struct gdma_queue *));
-	if (!gc->cq_table)
+	cq_table = vcalloc(num_cqs, sizeof(*cq_table));
+	if (!cq_table)
 		return -ENOMEM;
 
-	gc->cq_table[cq->id] = cq;
+	gc->max_num_cqs = num_cqs;
+
+	rcu_assign_pointer(cq_table[cq_id], cq);
+	/* Publish the fully-initialised table last; pairs with the
+	 * rcu_dereference(gc->cq_table) in mana_gd_process_eqe().
+	 */
+	rcu_assign_pointer(gc->cq_table, cq_table);
 
 	return 0;
 }
@@ -728,14 +943,14 @@ static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth,
 		goto out;
 	}
 
-	err = mana_hwc_create_wq(hwc, GDMA_RQ, q_depth, max_req_msg_size,
+	err = mana_hwc_create_wq(hwc, GDMA_RQ, q_depth, max_resp_msg_size,
 				 hwc->cq, &hwc->rxq);
 	if (err) {
 		dev_err(hwc->dev, "Failed to create HWC RQ: %d\n", err);
 		goto out;
 	}
 
-	err = mana_hwc_create_wq(hwc, GDMA_SQ, q_depth, max_resp_msg_size,
+	err = mana_hwc_create_wq(hwc, GDMA_SQ, q_depth, max_req_msg_size,
 				 hwc->cq, &hwc->txq);
 	if (err) {
 		dev_err(hwc->dev, "Failed to create HWC SQ: %d\n", err);
@@ -744,6 +959,7 @@ static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth,
 
 	hwc->num_inflight_msg = q_depth;
 	hwc->max_req_msg_size = max_req_msg_size;
+	hwc->max_resp_msg_size = max_resp_msg_size;
 
 	return 0;
 out:
@@ -811,27 +1027,50 @@ int mana_hwc_create_channel(struct gdma_context *gc)
 void mana_hwc_destroy_channel(struct gdma_context *gc)
 {
 	struct hw_channel_context *hwc = gc->hwc.driver_data;
+	struct gdma_queue __rcu **old_cq_table;
 
 	if (!hwc)
 		return;
 
-	/* gc->max_num_cqs is set in mana_hwc_init_event_handler(). If it's
-	 * non-zero, the HWC worked and we should tear down the HWC here.
+	/* Tear down the HWC if setup_hwc previously activated MST entries.
+	 * This is the definitive flag — unlike max_num_cqs which depends
+	 * on the init EQE arriving.
+	 *
+	 * If teardown fails the device may still have active MST entries
+	 * and can DMA into the HWC queue buffers.  Freeing them would risk
+	 * memory corruption on systems without an IOMMU to fault the stale
+	 * DMA, so leak the HWC resources instead of handing the pages back
+	 * to the allocator.  Keep setup_active set so the failure is not
+	 * mistaken for a clean teardown.
 	 */
-	if (gc->max_num_cqs > 0) {
-		mana_smc_teardown_hwc(&gc->shm_channel, false);
-		gc->max_num_cqs = 0;
+	if (hwc->setup_active) {
+		int td_err = mana_smc_teardown_hwc(&gc->shm_channel, false);
+
+		if (td_err) {
+			dev_err(gc->dev,
+				"HWC teardown failed: %d, leaking resources\n",
+				td_err);
+			return;
+		}
+
+		hwc->setup_active = false;
 	}
 
+	/* Tear down the HWC CQ object first — mana_hwc_destroy_cq()
+	 * both unpublishes the CQ from cq_table (+synchronize_rcu) and
+	 * deregisters the HWC EQ from the interrupt handler list (via
+	 * mana_gd_deregister_irq + synchronize_rcu), guaranteeing no
+	 * interrupt handler can access RQ/TXQ buffers after this point.
+	 */
+	if (hwc->cq)
+		mana_hwc_destroy_cq(hwc->gdma_dev->gdma_context, hwc->cq);
+
 	if (hwc->txq)
 		mana_hwc_destroy_wq(hwc, hwc->txq);
 
 	if (hwc->rxq)
 		mana_hwc_destroy_wq(hwc, hwc->rxq);
 
-	if (hwc->cq)
-		mana_hwc_destroy_cq(hwc->gdma_dev->gdma_context, hwc->cq);
-
 	kfree(hwc->caller_ctx);
 	hwc->caller_ctx = NULL;
 
@@ -848,8 +1087,9 @@ void mana_hwc_destroy_channel(struct gdma_context *gc)
 	gc->hwc.driver_data = NULL;
 	gc->hwc.gdma_context = NULL;
 
-	vfree(gc->cq_table);
-	gc->cq_table = NULL;
+	old_cq_table = rcu_replace_pointer(gc->cq_table, NULL, true);
+	synchronize_rcu();
+	vfree(old_cq_table);
 }
 
 int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,
@@ -860,13 +1100,18 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,
 	struct hwc_wq *txq = hwc->txq;
 	struct gdma_req_hdr *req_msg;
 	struct hwc_caller_ctx *ctx;
+	unsigned long flags;
+	bool drop_resp_ref;
 	u32 dest_vrcq = 0;
 	u32 dest_vrq = 0;
 	u32 command;
+	u32 status;
 	u16 msg_id;
 	int err;
 
-	mana_hwc_get_msg_index(hwc, &msg_id);
+	err = mana_hwc_get_msg_index(hwc, &msg_id);
+	if (err)
+		return err;
 
 	tx_wr = &txq->msg_buf->reqs[msg_id];
 
@@ -878,8 +1123,11 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,
 	}
 
 	ctx = hwc->caller_ctx + msg_id;
+
+	spin_lock_irqsave(&ctx->lock, flags);
 	ctx->output_buf = resp;
 	ctx->output_buflen = resp_len;
+	spin_unlock_irqrestore(&ctx->lock, flags);
 
 	req_msg = (struct gdma_req_hdr *)tx_wr->buf_va;
 	if (req)
@@ -895,6 +1143,10 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,
 		dest_vrcq = hwc->pf_dest_vrcq_id;
 	}
 
+	/* handle_resp()'s reference was taken in mana_hwc_get_msg_index(),
+	 * so hardware responding immediately after the doorbell ring cannot
+	 * release the slot before this sender is done with it.
+	 */
 	err = mana_hwc_post_tx_wqe(txq, tx_wr, dest_vrq, dest_vrcq, false);
 	if (err) {
 		dev_err(hwc->dev, "HWC: Failed to post send WQE: %d\n", err);
@@ -907,31 +1159,95 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,
 			dev_err(hwc->dev, "Command 0x%x timed out: %u ms\n",
 				command, hwc->hwc_timeout);
 
-		/* Reduce further waiting if HWC no response */
+		/* NULL out output_buf so a late handle_resp() won't write
+		 * into the caller's buffer after the sender returns, then
+		 * check whether handle_resp() already delivered a valid
+		 * response between the timeout firing and this lock
+		 * acquisition — ctx->error != -EINPROGRESS means it ran.
+		 */
+		spin_lock_irqsave(&ctx->lock, flags);
+		ctx->output_buf = NULL;
+		err = ctx->error;
+		status = ctx->status_code;
+		spin_unlock_irqrestore(&ctx->lock, flags);
+
+		if (err != -EINPROGRESS) {
+			/* handle_resp() delivered a valid response just after
+			 * the timeout fired.  The hardware is alive, so use
+			 * the response and leave the channel usable; do not
+			 * latch hwc_timed_out or degrade hwc_timeout for what
+			 * turned out to be a transient race.
+			 */
+			hwc_ctx_put(hwc, ctx);
+			goto check_status;
+		}
+
+		/* Genuine timeout: no response arrived.  Reduce further
+		 * waiting, and mark the channel timed out under the bitmap
+		 * lock so get_msg_index() cannot acquire new slots after this.
+		 */
 		if (hwc->hwc_timeout > 1)
 			hwc->hwc_timeout = 1;
 
+		spin_lock_irqsave(&hwc->inflight_msg_res.lock, flags);
+		WRITE_ONCE(hwc->hwc_timed_out, true);
+		spin_unlock_irqrestore(&hwc->inflight_msg_res.lock, flags);
+		wake_up_all(&hwc->msg_waitq);
+
 		err = -ETIMEDOUT;
-		goto out;
+		hwc_ctx_put(hwc, ctx);
+		goto done;
 	}
 
-	if (ctx->error) {
-		err = ctx->error;
-		goto out;
-	}
+	/* NULL output_buf so a late handle_resp() won't memcpy into
+	 * the caller's buffer after the sender exits.  Read error and
+	 * status_code under the same lock — after hwc_ctx_put the slot
+	 * may be reused and these fields overwritten.
+	 */
+	spin_lock_irqsave(&ctx->lock, flags);
+	ctx->output_buf = NULL;
+	err = ctx->error;
+	status = ctx->status_code;
+	spin_unlock_irqrestore(&ctx->lock, flags);
+	hwc_ctx_put(hwc, ctx);
+
+check_status:
+	if (err)
+		goto done;
 
-	if (ctx->status_code && ctx->status_code != GDMA_STATUS_MORE_ENTRIES) {
-		if (ctx->status_code == GDMA_STATUS_CMD_UNSUPPORTED) {
+	if (status && status != GDMA_STATUS_MORE_ENTRIES) {
+		if (status == GDMA_STATUS_CMD_UNSUPPORTED) {
 			err = -EOPNOTSUPP;
-			goto out;
+			goto done;
 		}
+
 		if (command != MANA_QUERY_PHY_STAT)
 			dev_err(hwc->dev, "Command 0x%x failed with status: 0x%x\n",
-				command, ctx->status_code);
+				command, status);
 		err = -EPROTO;
-		goto out;
+		goto done;
 	}
+
+	err = 0;
+	goto done;
 out:
-	mana_hwc_put_msg_index(hwc, msg_id);
+	/* Pre-post error paths: the request was never submitted, so in the
+	 * common case mana_hwc_handle_resp() will not run for this slot and
+	 * the sender must drop both the response-side reference taken in
+	 * mana_hwc_get_msg_index() and its own.  Guard against a stale or
+	 * forged response that raced in first: latch ->responded under the
+	 * lock so any later handle_resp() is a no-op, and drop the response-
+	 * side reference here only if handle_resp() has not already done so.
+	 */
+	ctx = hwc->caller_ctx + msg_id;
+	spin_lock_irqsave(&ctx->lock, flags);
+	ctx->output_buf = NULL;
+	drop_resp_ref = !ctx->responded;
+	ctx->responded = true;
+	spin_unlock_irqrestore(&ctx->lock, flags);
+	if (drop_resp_ref)
+		refcount_dec(&ctx->refcnt);
+	hwc_ctx_put(hwc, ctx);
+done:
 	return err;
 }
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 92bb55935c1c4..5d215981bba83 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -2427,12 +2427,18 @@ static void mana_deinit_txq(struct mana_port_context *apc, struct mana_txq *txq)
 
 static void mana_destroy_txq(struct mana_port_context *apc)
 {
+	struct gdma_context *gc = apc->ac->gdma_dev->gdma_context;
 	struct napi_struct *napi;
 	int i;
 
 	if (!apc->tx_qp)
 		return;
 
+	/* Pass 1: quiesce each CQ on the device and clear its cq_table slot.
+	 * Taking one grace period below for the whole port avoids up to
+	 * apc->num_queues serialized synchronize_rcu() calls (one per CQ in
+	 * mana_gd_destroy_cq()) under RTNL on every teardown.
+	 */
 	for (i = 0; i < apc->num_queues; i++) {
 		if (!apc->tx_qp[i])
 			continue;
@@ -2448,8 +2454,24 @@ static void mana_destroy_txq(struct mana_port_context *apc)
 			apc->tx_qp[i]->txq.napi_initialized = false;
 		}
 
-		if (apc->tx_qp[i]->tx_object != INVALID_MANA_HANDLE)
-			mana_destroy_wq_obj(apc, GDMA_SQ, apc->tx_qp[i]->tx_object);
+		if (apc->tx_qp[i]->tx_object != INVALID_MANA_HANDLE) {
+			mana_destroy_wq_obj(apc, GDMA_SQ,
+					    apc->tx_qp[i]->tx_object);
+			apc->tx_qp[i]->tx_object = INVALID_MANA_HANDLE;
+		}
+
+		if (apc->tx_qp[i]->tx_cq.gdma_cq)
+			mana_gd_unpublish_cq(gc, apc->tx_qp[i]->tx_cq.gdma_cq);
+	}
+
+	synchronize_rcu();
+
+	/* Pass 2: the slots are clear, so mana_gd_destroy_cq() skips its own
+	 * grace period; free the CQ, the TXQ and the queue pair.
+	 */
+	for (i = 0; i < apc->num_queues; i++) {
+		if (!apc->tx_qp[i])
+			continue;
 
 		mana_deinit_cq(apc, &apc->tx_qp[i]->tx_cq);
 
@@ -2496,6 +2518,7 @@ static int mana_create_txq(struct mana_port_context *apc,
 	struct mana_obj_spec cq_spec;
 	struct gdma_queue_spec spec;
 	struct gdma_context *gc;
+	struct gdma_queue __rcu **cq_table;
 	struct mana_txq *txq;
 	struct mana_cq *cq;
 	u32 txq_size;
@@ -2596,12 +2619,18 @@ static int mana_create_txq(struct mana_port_context *apc,
 
 		cq->gdma_id = cq->gdma_cq->id;
 
-		if (WARN_ON(cq->gdma_id >= gc->max_num_cqs)) {
+		/* No rcu_read_lock(): mana_create_txq runs under RTNL during
+		 * netdev bring-up, inside the netdev lifetime that
+		 * mana_remove() drains before the base cq_table can be freed.
+		 * See gdma_context::cq_table in gdma.h for why "true" is sound.
+		 */
+		cq_table = rcu_dereference_protected(gc->cq_table, true);
+		if (WARN_ON(!cq_table || cq->gdma_id >= gc->max_num_cqs)) {
 			err = -EINVAL;
 			goto out;
 		}
 
-		gc->cq_table[cq->gdma_id] = cq->gdma_cq;
+		rcu_assign_pointer(cq_table[cq->gdma_id], cq->gdma_cq);
 
 		mana_create_txq_debugfs(apc, i);
 
@@ -2621,25 +2650,20 @@ static int mana_create_txq(struct mana_port_context *apc,
 	return err;
 }
 
-static void mana_destroy_rxq(struct mana_port_context *apc,
+/* Quiesce an RXQ's CQ on the device and clear its cq_table slot, without
+ * waiting for a grace period.  Split out of mana_destroy_rxq() so a batch
+ * teardown (mana_destroy_rxqs()) can quiesce every RXQ and then take a
+ * single synchronize_rcu() instead of one per RXQ.
+ */
+static void mana_quiesce_rxq(struct mana_port_context *apc,
 			     struct mana_rxq *rxq, bool napi_initialized)
-
 {
 	struct gdma_context *gc = apc->ac->gdma_dev->gdma_context;
-	struct mana_recv_buf_oob *rx_oob;
-	struct device *dev = gc->dev;
-	struct napi_struct *napi;
-	struct page *page;
-	int i;
-
-	if (!rxq)
-		return;
+	struct napi_struct *napi = &rxq->rx_cq.napi;
 
 	debugfs_remove_recursive(rxq->mana_rx_debugfs);
 	rxq->mana_rx_debugfs = NULL;
 
-	napi = &rxq->rx_cq.napi;
-
 	if (napi_initialized) {
 		napi_synchronize(napi);
 
@@ -2650,8 +2674,27 @@ static void mana_destroy_rxq(struct mana_port_context *apc,
 	if (xdp_rxq_info_is_reg(&rxq->xdp_rxq))
 		xdp_rxq_info_unreg(&rxq->xdp_rxq);
 
-	if (rxq->rxobj != INVALID_MANA_HANDLE)
+	if (rxq->rxobj != INVALID_MANA_HANDLE) {
 		mana_destroy_wq_obj(apc, GDMA_RQ, rxq->rxobj);
+		rxq->rxobj = INVALID_MANA_HANDLE;
+	}
+
+	if (rxq->rx_cq.gdma_cq)
+		mana_gd_unpublish_cq(gc, rxq->rx_cq.gdma_cq);
+}
+
+/* Free an RXQ once its cq_table slot has been cleared and a grace period
+ * has elapsed (see mana_quiesce_rxq()).  mana_deinit_cq() ->
+ * mana_gd_destroy_cq() finds the slot already NULL and skips its own
+ * synchronize_rcu().
+ */
+static void mana_free_rxq(struct mana_port_context *apc, struct mana_rxq *rxq)
+{
+	struct gdma_context *gc = apc->ac->gdma_dev->gdma_context;
+	struct mana_recv_buf_oob *rx_oob;
+	struct device *dev = gc->dev;
+	struct page *page;
+	int i;
 
 	mana_deinit_cq(apc, &rxq->rx_cq);
 
@@ -2685,6 +2728,23 @@ static void mana_destroy_rxq(struct mana_port_context *apc,
 	kvfree(rxq);
 }
 
+static void mana_destroy_rxq(struct mana_port_context *apc,
+			     struct mana_rxq *rxq, bool napi_initialized)
+
+{
+	if (!rxq)
+		return;
+
+	mana_quiesce_rxq(apc, rxq, napi_initialized);
+
+	/* Wait for in-flight EQ handlers that may have loaded the old CQ
+	 * pointer via rcu_dereference() before freeing.
+	 */
+	synchronize_rcu();
+
+	mana_free_rxq(apc, rxq);
+}
+
 static int mana_fill_rx_oob(struct mana_recv_buf_oob *rx_oob, u32 mem_key,
 			    struct mana_rxq *rxq, struct device *dev)
 {
@@ -2821,6 +2881,7 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,
 	struct gdma_queue_spec spec;
 	struct mana_cq *cq = NULL;
 	struct gdma_context *gc;
+	struct gdma_queue __rcu **cq_table;
 	u32 cq_size, rq_size;
 	struct mana_rxq *rxq;
 	int err;
@@ -2905,12 +2966,18 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,
 	if (err)
 		goto out;
 
-	if (WARN_ON(cq->gdma_id >= gc->max_num_cqs)) {
+	/* No rcu_read_lock(): mana_create_rxq runs under RTNL during netdev
+	 * bring-up, inside the netdev lifetime that mana_remove() drains
+	 * before the base cq_table can be freed.  See gdma_context::cq_table
+	 * in gdma.h for why "true" is sound.
+	 */
+	cq_table = rcu_dereference_protected(gc->cq_table, true);
+	if (WARN_ON(!cq_table || cq->gdma_id >= gc->max_num_cqs)) {
 		err = -EINVAL;
 		goto out;
 	}
 
-	gc->cq_table[cq->gdma_id] = cq->gdma_cq;
+	rcu_assign_pointer(cq_table[cq->gdma_id], cq->gdma_cq);
 
 	netif_napi_add_weight_locked(ndev, &cq->napi, mana_poll, 1);
 
@@ -2987,16 +3054,31 @@ static void mana_destroy_rxqs(struct mana_port_context *apc)
 	struct mana_rxq *rxq;
 	u32 rxq_idx;
 
-	if (apc->rxqs) {
+	if (!apc->rxqs)
+		return;
 
-		for (rxq_idx = 0; rxq_idx < apc->num_queues; rxq_idx++) {
-			rxq = apc->rxqs[rxq_idx];
-			if (!rxq)
-				continue;
+	/* Pass 1: quiesce every RXQ's CQ and clear its cq_table slot. */
+	for (rxq_idx = 0; rxq_idx < apc->num_queues; rxq_idx++) {
+		rxq = apc->rxqs[rxq_idx];
+		if (!rxq)
+			continue;
 
-			mana_destroy_rxq(apc, rxq, true);
-			apc->rxqs[rxq_idx] = NULL;
-		}
+		mana_quiesce_rxq(apc, rxq, true);
+	}
+
+	/* One grace period for the whole port instead of one per RXQ. */
+	synchronize_rcu();
+
+	/* Pass 2: the slots are clear, so mana_gd_destroy_cq() skips its own
+	 * grace period; free each RXQ.
+	 */
+	for (rxq_idx = 0; rxq_idx < apc->num_queues; rxq_idx++) {
+		rxq = apc->rxqs[rxq_idx];
+		if (!rxq)
+			continue;
+
+		mana_free_rxq(apc, rxq);
+		apc->rxqs[rxq_idx] = NULL;
 	}
 }
 
diff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h
index 0c395917b2144..e59b8b31e8345 100644
--- a/include/net/mana/gdma.h
+++ b/include/net/mana/gdma.h
@@ -416,9 +416,39 @@ struct gdma_context {
 	/* L2 MTU */
 	u16 adapter_mtu;
 
-	/* This maps a CQ index to the queue structure. */
+	/* Size of cq_table, i.e. the largest valid CQ index + 1.  Set once
+	 * when cq_table is allocated and treated as immutable for the
+	 * table's lifetime (a bound only) -- it is never reset on teardown.
+	 * cq_table == NULL is the sole "table torn down" signal, so every
+	 * cq_table[id] access must guard with both !cq_table (gone) and
+	 * id >= max_num_cqs (out of bounds).
+	 */
 	unsigned int		max_num_cqs;
-	struct gdma_queue	**cq_table;
+	/* Both the base pointer and each entry are RCU-managed.  The fast
+	 * path (mana_gd_process_eqe) reads the base via rcu_dereference()
+	 * under rcu_read_lock(), so the table is freed with
+	 * rcu_assign_pointer(NULL) + synchronize_rcu() and an in-flight
+	 * reader can never observe freed memory.
+	 *
+	 * The slow paths -- mana_gd_destroy_cq() and the CQ install/remove
+	 * callers (mana_create_txq/_rxq, mana_ib_install/remove_cq_cb) --
+	 * instead read the base with rcu_dereference_protected(cq_table,
+	 * true).  The bare "true" asserts teardown/bring-up ordering, not a
+	 * lock: the base table is allocated in mana_hwc_establish_channel()
+	 * and replaced+freed only by mana_hwc_destroy_channel() (via
+	 * mana_gd_cleanup_device()) and the create-time reinit.  The reinit
+	 * runs before either consumer is probed, and cleanup_device() runs
+	 * after mana_remove() / mana_rdma_remove() have detached the ports
+	 * under RTNL and drained the IB device, so no install/remove caller
+	 * is running when the base is freed.  This is an ordering argument
+	 * about when cleanup_device() runs: suspend and shutdown keep the
+	 * netdev registered, so it does not rely on unregister_netdevice()
+	 * having run on every path.  mana_hwc_destroy_channel() itself reads
+	 * cq_table (mana_hwc_destroy_cq()) before it replaces and vfree()s
+	 * the base, so that access is ordered ahead of the free by program
+	 * order.
+	 */
+	struct gdma_queue	__rcu * __rcu *cq_table;
 
 	/* Protect eq_test_event and test_event_eq_id  */
 	struct mutex		eq_test_event_mutex;
@@ -496,6 +526,12 @@ int mana_gd_create_mana_wq_cq(struct gdma_dev *gd,
 
 void mana_gd_destroy_queue(struct gdma_context *gc, struct gdma_queue *queue);
 
+/* Clear a CQ's cq_table slot without waiting for a grace period.  Batched
+ * teardown paths clear several slots and then take a single synchronize_rcu();
+ * single-CQ callers use mana_gd_destroy_cq() instead, which also waits.
+ */
+bool mana_gd_unpublish_cq(struct gdma_context *gc, struct gdma_queue *queue);
+
 int mana_gd_poll_cq(struct gdma_queue *cq, struct gdma_comp *comp, int num_cqe);
 
 void mana_gd_ring_cq(struct gdma_queue *cq, u8 arm_bit);
diff --git a/include/net/mana/hw_channel.h b/include/net/mana/hw_channel.h
index 16feb39616c1b..c275150baf490 100644
--- a/include/net/mana/hw_channel.h
+++ b/include/net/mana/hw_channel.h
@@ -171,8 +171,25 @@ struct hwc_caller_ctx {
 	void *output_buf;
 	u32 output_buflen;
 
-	u32 error; /* Linux error code */
+	int error; /* Linux error code (negative errno or 0) */
 	u32 status_code;
+
+	/* Protects output_buf against concurrent access from
+	 * handle_resp() (CQ interrupt) and the sender timeout path.
+	 */
+	spinlock_t lock;
+
+	/* Tracks sender + handle_resp ownership.  The last put
+	 * (refcount reaches 0) releases the bitmap slot.
+	 */
+	refcount_t refcnt;
+	u16 msg_id;
+
+	/* Set under lock by the first handle_resp() for this slot so a
+	 * duplicate or replayed response is dropped instead of consuming
+	 * the response-side reference a second time.
+	 */
+	bool responded;
 };
 
 struct hw_channel_context {
@@ -181,10 +198,12 @@ struct hw_channel_context {
 
 	u16 num_inflight_msg;
 	u32 max_req_msg_size;
+	u32 max_resp_msg_size;
 
 	u16 hwc_init_q_depth_max;
 	u32 hwc_init_max_req_msg_size;
 	u32 hwc_init_max_resp_msg_size;
+	u32 hwc_init_max_num_cqs;
 
 	struct completion hwc_init_eqe_comp;
 
@@ -192,13 +211,34 @@ struct hw_channel_context {
 	struct hwc_wq *txq;
 	struct hwc_cq *cq;
 
-	struct semaphore sema;
 	struct gdma_resource inflight_msg_res;
+	/* Waitqueue for senders blocked on a full inflight bitmap. */
+	wait_queue_head_t msg_waitq;
 
 	u32 pf_dest_vrq_id;
 	u32 pf_dest_vrcq_id;
 	u32 hwc_timeout;
 
+	/* Count of RX WQEs deliberately not reposted after an untrusted SGE
+	 * (see mana_hwc_rx_leak_wqe()); once it reaches the RQ depth the
+	 * channel can no longer receive responses.
+	 */
+	u32 rx_leaked_wqe;
+
+	/* Set on first HWC timeout.  Causes get_msg_index() to return
+	 * -ETIMEDOUT instead of waiting, draining all queued senders.
+	 */
+	bool hwc_timed_out;
+
+	/* Set after mana_smc_setup_hwc() succeeds (hardware has active
+	 * MST entries).  Cleared only after mana_smc_teardown_hwc()
+	 * succeeds, on both the recoverable establish_channel path and the
+	 * terminal destroy_channel path.  If teardown fails it stays set:
+	 * establish_channel() skips its retry and destroy_channel() leaks
+	 * the HWC rather than free buffers the device may still DMA into.
+	 */
+	bool setup_active;
+
 	struct hwc_caller_ctx *caller_ctx;
 };
 

3/2 2026/08/09 19:08 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 19516
							output: 39
							thoughts: 648
						

Thoughts:
**Analyzing a Kernel Patch Series: MANA Driver and Syzkaller**

Okay, so I've got this patch series applied to the kernel, and it touches a few key files: `drivers/infiniband/hw/mana/cq.c`, `drivers/net/ethernet/microsoft/mana/...`. This is the Microsoft Azure Network Adapter (MANA) driver. My initial thought is, is this even *reachable* in a virtualized environment like QEMU or GCE? These are the typical environments for something like Syzkaller, which is often what trips up on these vendor-specific drivers.

MANA is a PCIe device, and usually found in Azure VMs. But then I remember: is MANA *emulated* in QEMU? No, it's a SmartNIC/hardware device, but it is Microsoft Azure Network Adapter, so it might be present in Azure VMs. I'm trying to remember if this is directly present in GCE. No, GCE uses gve (Google Virtual NIC).

Aha, wait a minute, the commit author is listed as `syz-cluster <triage@syzkaller.com>`! That's a red flag – or, rather, a green flag! This means Syzkaller probably found a bug or is actively fuzzing this driver. Now, the prompt stresses to avoid internal knowledge, and instead actively use code access tools. This means I need to confirm assumptions by looking at the source.

So, I need to look into this more deeply. Can Syzkaller fuzz it? Can Syzkaller fuzz a PCI device using `syz_pci_...` if it's enabled, but it requires the device to be probed? I know Syzkaller can inject PCI config space and MMIO. However, the prompt specifically says to be cautious about vendor-specific drivers. But what about the `vhci` interface?

The prompt states: "Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed, ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU." Is MANA included in that list? I need to check the Kconfig, so let's check `drivers/net/ethernet/microsoft/mana/Kconfig`.



4/2 2026/08/09 19:08 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "config MICROSOFT_MANA",
  "PathPrefix": "drivers/net/ethernet/microsoft/mana/Kconfig"
}

Results:
{
  "error": "no matches"
}

5/2 2026/08/09 19:08 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 20713
							output: 37
							thoughts: 21
						

Thoughts:
Here's a summary of my thought process, as requested:

**Kconfig Inspection: Microsoft Ethernet Driver**

Okay, time to dive in. My immediate thought is to zero in on the `Kconfig` file, specifically the one located within the `drivers/net/ethernet/microsoft/` directory. That's the starting point. I need to understand the configuration options available for this specific driver. What are the key features it supports? What build-time dependencies exist? Are there any specific hardware variants or configurations controlled via Kconfig symbols? My initial goal is to get a handle on the overall configuration landscape for this Microsoft Ethernet driver. This `Kconfig` file will provide the roadmap for the next stage of investigation.



6/2 2026/08/09 19:08 tool grepper
0m Args:
{
  "Expression": "config MICROSOFT_MANA",
  "PathPrefix": "drivers/net/ethernet/microsoft/Kconfig"
}

Results:
{
  "Output": "drivers/net/ethernet/microsoft/Kconfig=16=if NET_VENDOR_MICROSOFT\ndrivers/net/ethernet/microsoft/Kconfig-17-\ndrivers/net/ethernet/microsoft/Kconfig:18:config MICROSOFT_MANA\ndrivers/net/ethernet/microsoft/Kconfig-19-\ttristate \"Microsoft Azure Network Adapter (MANA) support\"\n"
}

7/2 2026/08/09 19:08 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 21026
							output: 38
							thoughts: 13
						

Thoughts:
Here's my attempt at summarizing the thought process, tailored for an expert audience:

**Analyzing MICROSOFT_MANA Dependencies**

Alright, let's dive in. My immediate focus is on understanding the dependencies of `MICROSOFT_MANA`. Given my experience, I'm thinking beyond just the obvious imports and library calls. I need to map out the *entire* dependency graph, from the foundational infrastructure it leverages – perhaps including specific OS versions, hardware configurations, or internal APIs – all the way up to its interaction with other high-level services or applications within the Microsoft ecosystem. I want to uncover the core building blocks it *relies* on, and their respective version constraints, to accurately gauge potential risks or areas of optimization. I will also be considering the implications of any third-party components it integrates with, and their associated licenses and security profiles. From a security perspective, I must understand if `MICROSOFT_MANA` trusts components, or if the components validate `MICROSOFT_MANA`.



8/2 2026/08/09 19:08 tool read-file
0m Args:
{
  "File": "drivers/net/ethernet/microsoft/Kconfig",
  "FirstLine": 16,
  "LineCount": 20
}

Results:
{
  "Contents": "  16:\tif NET_VENDOR_MICROSOFT\n  17:\t\n  18:\tconfig MICROSOFT_MANA\n  19:\t\ttristate \"Microsoft Azure Network Adapter (MANA) support\"\n  20:\t\tdepends on PCI_MSI\n  21:\t\tdepends on X86_64 || (ARM64 \u0026\u0026 !CPU_BIG_ENDIAN)\n  22:\t\tdepends on PCI_HYPERV\n  23:\t\tselect AUXILIARY_BUS\n  24:\t\tselect PAGE_POOL\n  25:\t\tselect NET_SHAPER\n  26:\t\thelp\n  27:\t\t  This driver supports Microsoft Azure Network Adapter (MANA).\n  28:\t\t  So far, the driver is only supported on X86_64.\n  29:\t\n  30:\t\t  To compile this driver as a module, choose M here.\n  31:\t\t  The module will be called mana.\n  32:\t\n  33:\tendif #NET_VENDOR_MICROSOFT\n"
}

9/2 2026/08/09 19:08 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 21543
							output: 23
							thoughts: 287
						

Thoughts:
**MANA Driver Fuzzability Assessment**

Okay, so the fuzzability of this MANA driver code really hinges on `PCI_HYPERV`, doesn't it? My initial thought is that `PCI_HYPERV` is probably Hyper-V specific, and therefore not easily fuzzed in a standard QEMU or Google Compute Engine environment. These Hyper-V PCI devices are typically tied to Azure environments.

Let's see if syzkaller has any luck with it. The prompt specifically highlights code that needs physical PCIe cards that aren't emulated in *standard* QEMU. Things like vendor-specific PCIe switch code and SmartNIC drivers. The prompt lists `mlxsw`, `pds_core`, `qed`, `ionic`, and `amdgpu` as examples. And what do you know? MANA is a SmartNIC driver for Azure. It explicitly *requires* `PCI_HYPERV`.

Hold on... the prompt actually *says* it's targeting code paths impossible to reach in virtualized environments like GCE or standard QEMU, even with software-emulated hardware! And it again brings up vendor-specific PCIe switch code, SmartNICs, and GPUs that need physical PCIe cards not emulated in standard QEMU. That's a perfect description of MANA! It's vendor-specific (Microsoft) and a SmartNIC.

So, am I right? Is MANA emulated in standard QEMU? No way! Therefore, by the prompt's definition, this code is *impossible* to reach in standard QEMU or GCE.

Alright, based on the prompt's criteria, I'm going to set `WorthFuzzing=false`.

I will however, quickly double check to make sure no software emulation is provided, just to be sure!



10/2 2026/08/09 19:08 tool grepper
0m Args:
{
  "Expression": "mana",
  "PathPrefix": "tools/"
}

Results:
{
  "Output": "\nFull output is too long, showing 500 out of 1093 lines.\nUse more precise expression if possible.\n\ntools/arch/x86/kcpuid/cpuid.csv-152-# Leaf 6H\ntools/arch/x86/kcpuid/cpuid.csv:153:# Thermal and power management\ntools/arch/x86/kcpuid/cpuid.csv-154-\n--\ntools/arch/x86/kcpuid/cpuid.csv-159-       0x6,         0,  eax,       5,    ecmd                   , Clock modulation duty cycle extension\ntools/arch/x86/kcpuid/cpuid.csv:160:       0x6,         0,  eax,       6,    pts                    , Package thermal management\ntools/arch/x86/kcpuid/cpuid.csv-161-       0x6,         0,  eax,       7,    hwp                    , HWP (Hardware P-states) base registers\n--\ntools/arch/x86/kcpuid/cpuid.csv-356-       0xd,         0,  eax,      12,    xcr0_cet_s             , XCR0.CET_S: CET supervisor state\ntools/arch/x86/kcpuid/cpuid.csv:357:       0xd,         0,  eax,      17,    xcr0_tileconfig        , XCR0.TILECONFIG: AMX can manage TILECONFIG\ntools/arch/x86/kcpuid/cpuid.csv:358:       0xd,         0,  eax,      18,    xcr0_tiledata          , XCR0.TILEDATA: AMX can manage TILEDATA\ntools/arch/x86/kcpuid/cpuid.csv-359-       0xd,         0,  ebx,    31:0,    xsave_sz_xcr0          , XSAVE/XRSTOR area byte size, for XCR0 enabled features\n--\ntools/arch/x86/kcpuid/cpuid.csv-443-      0x12,         1,  ecx,       9,    xfrm_pkru              , Enclave XFRM.PKRU (XSAVE PKRU registers)\ntools/arch/x86/kcpuid/cpuid.csv:444:      0x12,         1,  ecx,      17,    xfrm_tileconfig        , Enclave XFRM.TILECONFIG (AMX can manage TILECONFIG)\ntools/arch/x86/kcpuid/cpuid.csv:445:      0x12,         1,  ecx,      18,    xfrm_tiledata          , Enclave XFRM.TILEDATA (AMX can manage TILEDATA)\ntools/arch/x86/kcpuid/cpuid.csv-446-      0x12,      31:2,  eax,     3:0,    subleaf_type           , Subleaf type\n--\ntools/arch/x86/kcpuid/cpuid.csv-787-# Leaf 80000007H\ntools/arch/x86/kcpuid/cpuid.csv:788:# CPU power management (mostly AMD) and AMD RAS\ntools/arch/x86/kcpuid/cpuid.csv-789-\n--\ntools/arch/x86/kcpuid/cpuid.csv-1112-0x80860001,         0,  edx,       0,    recovery               , Recovery CMS is active (after bad flush)\ntools/arch/x86/kcpuid/cpuid.csv:1113:0x80860001,         0,  edx,       1,    longrun                , LongRun power management capabilities\ntools/arch/x86/kcpuid/cpuid.csv-1114-0x80860001,         0,  edx,       3,    lrti                   , LongRun Table Interface\n--\ntools/bpf/bpftool/Documentation/bpftool-gen.rst=51=bpftool gen skeleton *FILE*\n--\ntools/bpf/bpftool/Documentation/bpftool-gen.rst-71-    links will be automatically destroyed on BPF skeleton destruction. This\ntools/bpf/bpftool/Documentation/bpftool-gen.rst:72:    eliminates the need for users to manage links manually and rely on libbpf\ntools/bpf/bpftool/Documentation/bpftool-gen.rst-73-    support to detach programs and free up resources.\n--\ntools/certs/print-cert-tbs-hash.sh-19-#\ntools/certs/print-cert-tbs-hash.sh:20:# Exemple on a managed system:\ntools/certs/print-cert-tbs-hash.sh-21-# keyctl padd blacklist \"$(\u003c hash0.txt)\" %:.blacklist \u003c hash0.p7s\n--\ntools/docs/kdoc_diff=398=def main():\n--\ntools/docs/kdoc_diff-503-    if not args.regression:\ntools/docs/kdoc_diff:504:        diff_manager = DiffManager()\ntools/docs/kdoc_diff:505:        diff_manager.diff_directories(old_cache, new_cache)\ntools/docs/kdoc_diff-506-\n--\ntools/docs/sphinx-pre-install=258=class MissingCheckers(AncillaryMethods):\n--\ntools/docs/sphinx-pre-install-260-    Contains some ancillary checkers for different types of binaries and\ntools/docs/sphinx-pre-install:261:    package managers.\ntools/docs/sphinx-pre-install-262-    \"\"\"\n--\ntools/docs/sphinx-pre-install=565=class SphinxDependencyChecker(MissingCheckers):\n--\ntools/docs/sphinx-pre-install-788-                    \"\\tsudo dnf install -y epel-release\\n\" \\\ntools/docs/sphinx-pre-install:789:                    \"\\tsudo dnf config-manager --set-enabled crb\\n\" \\\ntools/docs/sphinx-pre-install-790-                    \"Yet, some may have other required repositories. Those commands could be useful:\\n\" \\\n--\ntools/docs/sphinx-pre-install-792-                    \"\\tsudo dnf repoquery --available --info \u003cpkgs\u003e\\n\" \\\ntools/docs/sphinx-pre-install:793:                    \"\\tsudo dnf config-manager --set-enabled '*' # enable all - probably not what you want\"\ntools/docs/sphinx-pre-install-794-\n--\ntools/docs/sphinx-pre-install-1115-        OS-specific hints logic. Seeks for a hinter. If found, use it to\ntools/docs/sphinx-pre-install:1116:        provide package-manager specific install commands.\ntools/docs/sphinx-pre-install-1117-\n--\ntools/hv/vmbus_bufring.h=43=struct vmbus_bufring {\n--\ntools/hv/vmbus_bufring.h-62-\t * Win8 uses some of the reserved bits to implement\ntools/hv/vmbus_bufring.h:63:\t * interrupt driven flow management. On the send side\ntools/hv/vmbus_bufring.h-64-\t * we can request that the receiver interrupt the sender\n--\ntools/include/linux/livepatch_external.h=45=struct klp_callbacks {\n--\ntools/include/linux/livepatch_external.h-60- * simplify livepatch's interface as well as its data structure lifetime\ntools/include/linux/livepatch_external.h:61: * management.\ntools/include/linux/livepatch_external.h-62- */\n--\ntools/include/uapi/linux/bpf.h=132=union bpf_iter_link_info {\n--\ntools/include/uapi/linux/bpf.h-648- *\ntools/include/uapi/linux/bpf.h:649: *\t\tTwo opaque values are used to manage batch operations,\ntools/include/uapi/linux/bpf.h-650- *\t\t*in_batch* and *out_batch*. Initially, *in_batch* must be set\n--\ntools/include/uapi/linux/bpf.h-792- *\t\t*attach_type* hook and return a file descriptor handle for\ntools/include/uapi/linux/bpf.h:793: *\t\tmanaging the link.\ntools/include/uapi/linux/bpf.h-794- *\n--\ntools/include/uapi/linux/if_link.h=1548=enum {\n--\ntools/include/uapi/linux/if_link.h-1563-\ntools/include/uapi/linux/if_link.h:1564:/* SR-IOV virtual function management section */\ntools/include/uapi/linux/if_link.h-1565-\n--\ntools/include/uapi/linux/if_link.h=1680=struct ifla_vf_trust {\n--\ntools/include/uapi/linux/if_link.h-1684-\ntools/include/uapi/linux/if_link.h:1685:/* VF ports management section\ntools/include/uapi/linux/if_link.h-1686- *\n--\ntools/include/uapi/linux/neighbour.h=18=enum {\n--\ntools/include/uapi/linux/neighbour.h-87- *\ntools/include/uapi/linux/neighbour.h:88: * NTF_EXT_MANAGED flagged neigbor entries are managed by the kernel on behalf\ntools/include/uapi/linux/neighbour.h-89- * of a user space control plane, and automatically refreshed so that (if\n--\ntools/include/uapi/linux/prctl.h=134=struct prctl_mm_map {\n--\ntools/include/uapi/linux/prctl.h-371-\ntools/include/uapi/linux/prctl.h:372:/* FUTEX hash management */\ntools/include/uapi/linux/prctl.h-373-#define PR_FUTEX_HASH\t\t\t78\n--\ntools/kvm/kvm_stat/kvm_stat=468=class Event(object):\ntools/kvm/kvm_stat/kvm_stat:469:    \"\"\"Represents a performance event and manages its life cycle.\"\"\"\ntools/kvm/kvm_stat/kvm_stat-470-    def __init__(self, name, group, trace_cpu, trace_pid, trace_point,\n--\ntools/lib/bpf/hashmap.h=108=enum hashmap_insert_strategy {\n--\ntools/lib/bpf/hashmap.h-126- * through old_key and old_value to allow calling code do proper memory\ntools/lib/bpf/hashmap.h:127: * management.\ntools/lib/bpf/hashmap.h-128- */\n--\ntools/lib/bpf/libbpf.c=677=struct elf_state {\n--\ntools/lib/bpf/libbpf.c-697-\ntools/lib/bpf/libbpf.c:698:struct usdt_manager;\ntools/lib/bpf/libbpf.c-699-\n--\ntools/lib/bpf/libbpf.c=706=struct bpf_object {\n--\ntools/lib/bpf/libbpf.c-760-\ntools/lib/bpf/libbpf.c:761:\tstruct usdt_manager *usdt_man;\ntools/lib/bpf/libbpf.c-762-\n--\ntools/lib/bpf/libbpf.c=9575=void bpf_object__close(struct bpf_object *obj)\n--\ntools/lib/bpf/libbpf.c-9588-\ntools/lib/bpf/libbpf.c:9589:\tusdt_manager_free(obj-\u003eusdt_man);\ntools/lib/bpf/libbpf.c-9590-\tobj-\u003eusdt_man = NULL;\n--\ntools/lib/bpf/libbpf.c=13356=struct bpf_link *bpf_program__attach_usdt(const struct bpf_program *prog,\n--\ntools/lib/bpf/libbpf.c-13388-\ntools/lib/bpf/libbpf.c:13389:\t/* USDT manager is instantiated lazily on first USDT attach. It will\ntools/lib/bpf/libbpf.c-13390-\t * be destroyed together with BPF object in bpf_object__close().\n--\ntools/lib/bpf/libbpf.c-13394-\tif (!obj-\u003eusdt_man) {\ntools/lib/bpf/libbpf.c:13395:\t\tobj-\u003eusdt_man = usdt_manager_new(obj);\ntools/lib/bpf/libbpf.c-13396-\t\tif (IS_ERR(obj-\u003eusdt_man))\n--\ntools/lib/bpf/libbpf.c-13400-\tusdt_cookie = OPTS_GET(opts, usdt_cookie, 0);\ntools/lib/bpf/libbpf.c:13401:\tlink = usdt_manager_attach_usdt(obj-\u003eusdt_man, prog, pid, binary_path,\ntools/lib/bpf/libbpf.c-13402-\t\t\t\t\tusdt_provider, usdt_name, usdt_cookie);\n--\ntools/lib/bpf/libbpf.c=14598=int perf_buffer__poll(struct perf_buffer *pb, int timeout_ms)\n--\ntools/lib/bpf/libbpf.c-14618-/* Return number of PERF_EVENT_ARRAY map slots set up by this perf_buffer\ntools/lib/bpf/libbpf.c:14619: * manager.\ntools/lib/bpf/libbpf.c-14620- */\n--\ntools/lib/bpf/libbpf.h=1474=LIBBPF_API int ring_buffer__epoll_fd(const struct ring_buffer *rb);\n--\ntools/lib/bpf/libbpf.h-1477- * @brief **ring_buffer__ring()** returns the ringbuffer object inside a given\ntools/lib/bpf/libbpf.h:1478: * ringbuffer manager representing a single BPF_MAP_TYPE_RINGBUF map instance.\ntools/lib/bpf/libbpf.h-1479- *\ntools/lib/bpf/libbpf.h:1480: * @param rb A ringbuffer manager object.\ntools/lib/bpf/libbpf.h-1481- * @param idx An index into the ringbuffers contained within the ringbuffer\ntools/lib/bpf/libbpf.h:1482: * manager object. The index is 0-based and corresponds to the order in which\ntools/lib/bpf/libbpf.h-1483- * ring_buffer__add was called.\n--\ntools/lib/bpf/libbpf.h=1679=struct perf_buffer_opts {\n--\ntools/lib/bpf/libbpf.h-1686-/**\ntools/lib/bpf/libbpf.h:1687: * @brief **perf_buffer__new()** creates BPF perfbuf manager for a specified\ntools/lib/bpf/libbpf.h-1688- * BPF_PERF_EVENT_ARRAY map\n--\ntools/lib/bpf/libbpf.h=1744=LIBBPF_API int perf_buffer__buffer_fd(const struct perf_buffer *pb, size_t buf_idx);\n--\ntools/lib/bpf/libbpf.h-1749- * The ring buffer starts with the *struct perf_event_mmap_page*, which\ntools/lib/bpf/libbpf.h:1750: * holds the ring buffer management fields, when accessing the header\ntools/lib/bpf/libbpf.h-1751- * structure it's important to be SMP aware.\n--\ntools/lib/bpf/libbpf_internal.h=726=void bpf_core_free_cands(struct bpf_core_cand_list *cands);\ntools/lib/bpf/libbpf_internal.h-727-\ntools/lib/bpf/libbpf_internal.h:728:struct usdt_manager *usdt_manager_new(struct bpf_object *obj);\ntools/lib/bpf/libbpf_internal.h:729:void usdt_manager_free(struct usdt_manager *man);\ntools/lib/bpf/libbpf_internal.h:730:struct bpf_link * usdt_manager_attach_usdt(struct usdt_manager *man,\ntools/lib/bpf/libbpf_internal.h-731-\t\t\t\t\t   const struct bpf_program *prog,\n--\ntools/lib/bpf/ringbuf.c=60=static void ringbuf_free_ring(struct ring_buffer *rb, struct ring *r)\n--\ntools/lib/bpf/ringbuf.c-73-\ntools/lib/bpf/ringbuf.c:74:/* Add extra RINGBUF maps to this ring buffer manager */\ntools/lib/bpf/ringbuf.c-75-int ring_buffer__add(struct ring_buffer *rb, int map_fd,\n--\ntools/lib/bpf/usdt.c-26- * usdt.bpf.h header library. User-space state is encapsulated by struct\ntools/lib/bpf/usdt.c:27: * usdt_manager and all the supporting code centered around usdt_manager.\ntools/lib/bpf/usdt.c-28- *\ntools/lib/bpf/usdt.c:29: * usdt.bpf.h defines two BPF maps that usdt_manager expects: USDT spec map\ntools/lib/bpf/usdt.c-30- * and IP-to-spec-ID map, which is auxiliary map necessary for kernels that\n--\ntools/lib/bpf/usdt.c-40- * attach (or, equivalently, through generic bpf_program__attach() call). At\ntools/lib/bpf/usdt.c:41: * this point, libbpf will instantiate and initialize struct usdt_manager and\ntools/lib/bpf/usdt.c:42: * store it in bpf_object. USDT manager is per-BPF object construct, as each\ntools/lib/bpf/usdt.c-43- * independent BPF object might or might not have USDT programs, and thus all\n--\ntools/lib/bpf/usdt.c-88- * \"activated\", an application can avoid paying those costs unnecessarily.\ntools/lib/bpf/usdt.c:89: * Recent enough kernel has built-in support for automatically managing this\ntools/lib/bpf/usdt.c-90- * refcount, which libbpf expects and relies on. If USDT is defined without\n--\ntools/lib/bpf/usdt.c-142- * so that they can be used as keys in array BPF map (for performance reasons).\ntools/lib/bpf/usdt.c:143: * Spec ID allocation and accounting is big part of what usdt_manager is\ntools/lib/bpf/usdt.c-144- * about. This state has to be maintained per-BPF object and coordinate\n--\ntools/lib/bpf/usdt.c=246=struct usdt_target {\n--\ntools/lib/bpf/usdt.c-253-\ntools/lib/bpf/usdt.c:254:struct usdt_manager {\ntools/lib/bpf/usdt.c-255-\tstruct bpf_map *specs_map;\n--\ntools/lib/bpf/usdt.c-267-\ntools/lib/bpf/usdt.c:268:struct usdt_manager *usdt_manager_new(struct bpf_object *obj)\ntools/lib/bpf/usdt.c-269-{\ntools/lib/bpf/usdt.c-270-\tstatic const char *ref_ctr_sysfs_path = \"/sys/bus/event_source/devices/uprobe/format/ref_ctr_offset\";\ntools/lib/bpf/usdt.c:271:\tstruct usdt_manager *man;\ntools/lib/bpf/usdt.c-272-\tstruct bpf_map *specs_map, *ip_to_spec_id_map;\n--\ntools/lib/bpf/usdt.c-314-\ntools/lib/bpf/usdt.c:315:void usdt_manager_free(struct usdt_manager *man)\ntools/lib/bpf/usdt.c-316-{\n--\ntools/lib/bpf/usdt.c=617=static bool has_nop_combo(int fd, long off)\n--\ntools/lib/bpf/usdt.c-622-\ntools/lib/bpf/usdt.c:623:static int collect_usdt_targets(struct usdt_manager *man, struct elf_fd *elf_fd, const char *path,\ntools/lib/bpf/usdt.c-624-\t\t\t\tpid_t pid, const char *usdt_provider, const char *usdt_name,\n--\ntools/lib/bpf/usdt.c=862=struct bpf_link_usdt {\n--\ntools/lib/bpf/usdt.c-864-\ntools/lib/bpf/usdt.c:865:\tstruct usdt_manager *usdt_man;\ntools/lib/bpf/usdt.c-866-\n--\ntools/lib/bpf/usdt.c=879=static int bpf_link_usdt_detach(struct bpf_link *link)\n--\ntools/lib/bpf/usdt.c-881-\tstruct bpf_link_usdt *usdt_link = container_of(link, struct bpf_link_usdt, link);\ntools/lib/bpf/usdt.c:882:\tstruct usdt_manager *man = usdt_link-\u003eusdt_man;\ntools/lib/bpf/usdt.c-883-\tint i;\n--\ntools/lib/bpf/usdt.c-903-\ntools/lib/bpf/usdt.c:904:\t/* try to return the list of previously used spec IDs to usdt_manager\ntools/lib/bpf/usdt.c-905-\t * for future reuse for subsequent USDT attaches\n--\ntools/lib/bpf/usdt.c-922-\t\t * concerns, probably.\ntools/lib/bpf/usdt.c:923:\t\t * So just do our best here to return those IDs to usdt_manager.\ntools/lib/bpf/usdt.c-924-\t\t * Another edge case when we can legitimately get NULL is when\n--\ntools/lib/bpf/usdt.c=953=static bool specs_equal_fn(long key1, long key2, void *ctx)\n--\ntools/lib/bpf/usdt.c-957-\ntools/lib/bpf/usdt.c:958:static int allocate_spec_id(struct usdt_manager *man, struct hashmap *specs_hash,\ntools/lib/bpf/usdt.c-959-\t\t\t    struct bpf_link_usdt *link, struct usdt_target *target,\n--\ntools/lib/bpf/usdt.c-973-\t/* otherwise it's a new ID that needs to be set up in specs map and\ntools/lib/bpf/usdt.c:974:\t * returned back to usdt_manager when USDT link is detached\ntools/lib/bpf/usdt.c-975-\t */\n--\ntools/lib/bpf/usdt.c-1012-\ntools/lib/bpf/usdt.c:1013:struct bpf_link *usdt_manager_attach_usdt(struct usdt_manager *man, const struct bpf_program *prog,\ntools/lib/bpf/usdt.c-1014-\t\t\t\t\t  pid_t pid, const char *path,\n--\ntools/memory-model/Documentation/litmus-tests.txt=241=Line 12 gives a hash of the contents for the litmus-test file, and is used\ntools/memory-model/Documentation/litmus-tests.txt:242:by tooling that manages litmus tests and their output.  This tooling is\ntools/memory-model/Documentation/litmus-tests.txt-243-used by people modifying LKMM itself, and among other things lets such\n--\ntools/perf/Documentation/perf-arm-spe.txt=71=Why Sampling?\n--\ntools/perf/Documentation/perf-arm-spe.txt-73-\ntools/perf/Documentation/perf-arm-spe.txt:74: - Sampling, rather than tracing, cuts down the profiling problem to something more manageable for\ntools/perf/Documentation/perf-arm-spe.txt-75- hardware. Only one sampled operation is in flight at a time.\n--\ntools/perf/Documentation/perf-buildid-cache.txt=13=DESCRIPTION\ntools/perf/Documentation/perf-buildid-cache.txt-14------------\ntools/perf/Documentation/perf-buildid-cache.txt:15:This command manages the build-id cache. It can add, remove, update and purge\ntools/perf/Documentation/perf-buildid-cache.txt-16-files to/from the cache. In the future it should as well set upper limits for\n--\ntools/perf/Documentation/perf-config.txt=15=DESCRIPTION\ntools/perf/Documentation/perf-config.txt-16------------\ntools/perf/Documentation/perf-config.txt:17:You can manage variables in a configuration file with this command.\ntools/perf/Documentation/perf-config.txt-18-\n--\ntools/perf/Documentation/perf-intel-pt.txt=1741=contains a type field to identify one of the following:\n--\ntools/perf/Documentation/perf-intel-pt.txt-1744-\t 2\tIRET\t\tinterrupt return\ntools/perf/Documentation/perf-intel-pt.txt:1745:\t 3\tSMI\t\tsystem management interrupt\ntools/perf/Documentation/perf-intel-pt.txt:1746:\t 4\tRSM\t\tresume from system management mode\ntools/perf/Documentation/perf-intel-pt.txt-1747-\t 5\tSIPI\t\tstartup interprocessor interrupt\n--\ntools/perf/builtin-probe.c-37-\ntools/perf/builtin-probe.c:38:/* Session management structure */\ntools/perf/builtin-probe.c-39-static struct {\n--\ntools/perf/builtin-trace.c=1080=static size_t trace__btf_scnprintf(struct trace *trace, struct syscall_arg *arg, char *bf,\n--\ntools/perf/builtin-trace.c-1092-\ntools/perf/builtin-trace.c:1093:\t// Did we manage to find a BTF type for the syscall/tracepoint argument?\ntools/perf/builtin-trace.c-1094-\tif (arg_fmt-\u003etype == NULL)\n--\ntools/perf/builtin-trace.c=2423=static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,\n--\ntools/perf/builtin-trace.c-2500-\t\t/*\ntools/perf/builtin-trace.c:2501:\t\t * If we managed to read the tracepoint /format file, then we\ntools/perf/builtin-trace.c-2502-\t\t * may end up not having any args, like with gettid(), so only\ntools/perf/builtin-trace.c:2503:\t\t * print the raw args when we didn't manage to read it.\ntools/perf/builtin-trace.c-2504-\t\t */\n--\ntools/perf/design.txt=406=Notification of new events is possible through poll()/select()/epoll() and\ntools/perf/design.txt:407:fcntl() managing signals.\ntools/perf/design.txt-408-\n--\ntools/perf/pmu-events/arch/powerpc/power10/metrics.json-363-    {\ntools/perf/pmu-events/arch/powerpc/power10/metrics.json:364:        \"BriefDescription\": \"Average cycles per completed instruction when the NTC instruction was held at dispatch because of power managem...\ntools/perf/pmu-events/arch/powerpc/power10/metrics.json-365-        \"MetricExpr\": \"PM_DISP_STALL_HELD_HALT_CYC / PM_RUN_INST_CMPL\",\n--\ntools/perf/pmu-events/arch/powerpc/power10/pipeline.json-74-    \"EventName\": \"PM_DISP_STALL_HELD_HALT_CYC\",\ntools/perf/pmu-events/arch/powerpc/power10/pipeline.json:75:    \"BriefDescription\": \"Cycles in which the next-to-complete (NTC) instruction is held at dispatch because of power management.\"\ntools/perf/pmu-events/arch/powerpc/power10/pipeline.json-76-  },\n--\ntools/perf/pmu-events/arch/x86/broadwell/bdw-metrics.json-77-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/broadwell/bdw-metrics.json:78:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) with...\ntools/perf/pmu-events/arch/x86/broadwell/bdw-metrics.json-79-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/broadwellde/bdwde-metrics.json-77-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/broadwellde/bdwde-metrics.json:78:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) ...\ntools/perf/pmu-events/arch/x86/broadwellde/bdwde-metrics.json-79-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/broadwellx/bdx-metrics.json-279-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/broadwellx/bdx-metrics.json:280:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) wi...\ntools/perf/pmu-events/arch/x86/broadwellx/bdx-metrics.json-281-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/cascadelakex/clx-metrics.json-316-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/cascadelakex/clx-metrics.json:317:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) ...\ntools/perf/pmu-events/arch/x86/cascadelakex/clx-metrics.json-318-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/clearwaterforest/cache.json-14-        \"EventName\": \"L2_REJECT_XQ.ANY\",\ntools/perf/pmu-events/arch/x86/clearwaterforest/cache.json:15:        \"PublicDescription\": \"Counts the number of demand and prefetch transactions that the External Queue (XQ) rejects due to a full or ...\ntools/perf/pmu-events/arch/x86/clearwaterforest/cache.json-16-        \"SampleAfterValue\": \"1000003\"\n--\ntools/perf/pmu-events/arch/x86/haswell/hsw-metrics.json-77-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/haswell/hsw-metrics.json:78:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) with a...\ntools/perf/pmu-events/arch/x86/haswell/hsw-metrics.json-79-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/haswellx/hsx-metrics.json-279-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/haswellx/hsx-metrics.json:280:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) with...\ntools/perf/pmu-events/arch/x86/haswellx/hsx-metrics.json-281-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/icelake/icl-metrics.json-91-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/icelake/icl-metrics.json:92:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) with a...\ntools/perf/pmu-events/arch/x86/icelake/icl-metrics.json-93-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/icelakex/icx-metrics.json-367-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/icelakex/icx-metrics.json:368:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) with...\ntools/perf/pmu-events/arch/x86/icelakex/icx-metrics.json-369-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/ivybridge/ivb-metrics.json-77-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/ivybridge/ivb-metrics.json:78:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) with...\ntools/perf/pmu-events/arch/x86/ivybridge/ivb-metrics.json-79-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/ivytown/ivt-metrics.json-77-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/ivytown/ivt-metrics.json:78:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) with a...\ntools/perf/pmu-events/arch/x86/ivytown/ivt-metrics.json-79-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/pantherlake/cache.json-146-        \"EventName\": \"L2_REJECT_XQ.ANY\",\ntools/perf/pmu-events/arch/x86/pantherlake/cache.json:147:        \"PublicDescription\": \"Counts the number of demand and prefetch transactions that the External Queue (XQ) rejects due to a full or near...\ntools/perf/pmu-events/arch/x86/pantherlake/cache.json-148-        \"SampleAfterValue\": \"1000003\",\n--\ntools/perf/pmu-events/arch/x86/rocketlake/rkl-metrics.json-91-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/rocketlake/rkl-metrics.json:92:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) wit...\ntools/perf/pmu-events/arch/x86/rocketlake/rkl-metrics.json-93-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/skylake/skl-metrics.json-77-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/skylake/skl-metrics.json:78:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) with a...\ntools/perf/pmu-events/arch/x86/skylake/skl-metrics.json-79-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json-298-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json:299:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) with...\ntools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json-300-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/pmu-events/arch/x86/tigerlake/tgl-metrics.json-91-        \"MetricThreshold\": \"tma_4k_aliasing \u003e 0.2 \u0026 (tma_l1_bound \u003e 0.1 \u0026 (tma_memory_bound \u003e 0.2 \u0026 tma_backend_bound \u003e 0.2))\",\ntools/perf/pmu-events/arch/x86/tigerlake/tgl-metrics.json:92:        \"PublicDescription\": \"This metric estimates how often memory load accesses were aliased by preceding stores (in program order) with...\ntools/perf/pmu-events/arch/x86/tigerlake/tgl-metrics.json-93-        \"ScaleUnit\": \"100%\"\n--\ntools/perf/tests/bp_signal.c=165=static int test__bp_signal(struct test_suite *test __maybe_unused, int subtest __maybe_unused)\n--\ntools/perf/tests/bp_signal.c-234-\t *   exception being triggered recursively due to\ntools/perf/tests/bp_signal.c:235:\t *   the wrong RF EFLAG management\ntools/perf/tests/bp_signal.c-236-\t *\ntools/perf/tests/bp_signal.c-237-\t * - we never trigger the sig_handler breakpoint due\ntools/perf/tests/bp_signal.c:238:\t *   to the wrong RF EFLAG management\ntools/perf/tests/bp_signal.c-239-\t *\n--\ntools/perf/tests/code-reading.c=378=static int read_object_code(u64 addr, size_t len, u8 cpumode,\n--\ntools/perf/tests/code-reading.c-437-\t * Some architectures (ex: powerpc) have stubs (trampolines) in kernel\ntools/perf/tests/code-reading.c:438:\t * modules to manage long jumps. Check if the ip offset falls in stubs\ntools/perf/tests/code-reading.c-439-\t * sections for kernel modules. And skip module address after text end\nBinary file tools/perf/tests/pe-file.exe matches\nBinary file tools/perf/tests/pe-file.exe.debug matches\n--\ntools/perf/tests/workloads/code_with_type.c=18=static int code_with_type(int argc, const char **argv)\n--\ntools/perf/tests/workloads/code_with_type.c-33-\t/*\ntools/perf/tests/workloads/code_with_type.c:34:\t * Rust doesn't have signal management in the standard library. To\ntools/perf/tests/workloads/code_with_type.c-35-\t * not deal with any external crates, offload signal handling to the\n--\ntools/perf/trace/beauty/include/linux/socket.h=197=struct ucred {\n--\ntools/perf/trace/beauty/include/linux/socket.h-219-#define AF_SECURITY\t14\t/* Security callback pseudo AF */\ntools/perf/trace/beauty/include/linux/socket.h:220:#define AF_KEY\t\t15      /* PF_KEY key management API */\ntools/perf/trace/beauty/include/linux/socket.h-221-#define AF_NETLINK\t16\n--\ntools/perf/trace/beauty/include/uapi/drm/drm.h=1073=extern \"C\" {\n--\ntools/perf/trace/beauty/include/uapi/drm/drm.h-1094- * GEM handles are not reference-counted by the kernel. User-space is\ntools/perf/trace/beauty/include/uapi/drm/drm.h:1095: * responsible for managing their lifetime. For example, if user-space imports\ntools/perf/trace/beauty/include/uapi/drm/drm.h-1096- * the same memory object twice on the same DRM file description, the same GEM\n--\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h=847=typedef struct drm_i915_setparam {\n--\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-851-\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h:852:/* A memory manager for regions of shared memory:\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-853- */\n--\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h=868=typedef struct drm_i915_mem_init_heap {\n--\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-873-\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h:874:/* Allow memory manager to be torn down and re-initialized (eg on\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-875- * rotate):\n--\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h=902=struct drm_i915_gem_init {\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-903-\t/**\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h:904:\t * Beginning offset in the GTT to be managed by the DRM memory\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h:905:\t * manager.\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-906-\t */\n--\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-908-\t/**\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h:909:\t * Ending offset in the GTT to be managed by the DRM memory\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h:910:\t * manager.\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-911-\t */\n--\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h=1239=struct drm_i915_gem_exec_object2 {\n--\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-1290- *\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h:1291: * The kernel maintains the implicit tracking in order to manage resources\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-1292- * used by the GPU - this flag only disables the synchronisation prior to\n--\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h=1742=struct drm_i915_gem_set_tiling {\n--\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-1753-\t * The tiling mode may be demoted to I915_TILING_NONE when the system\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h:1754:\t * has bit 6 swizzling that can't be managed correctly by GEM.\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-1755-\t *\n--\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h=3895=struct drm_i915_gem_create_ext_set_pat {\n--\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-3908-\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h:3909:/* ID of the protected content session managed by i915 when PXP is active */\ntools/perf/trace/beauty/include/uapi/drm/i915_drm.h-3910-#define I915_PROTECTED_CONTENT_DEFAULT_SESSION 0xf\n--\ntools/perf/trace/beauty/include/uapi/linux/prctl.h=134=struct prctl_mm_map {\n--\ntools/perf/trace/beauty/include/uapi/linux/prctl.h-383-\ntools/perf/trace/beauty/include/uapi/linux/prctl.h:384:/* FUTEX hash management */\ntools/perf/trace/beauty/include/uapi/linux/prctl.h-385-#define PR_FUTEX_HASH\t\t\t78\n--\ntools/perf/trace/beauty/include/uapi/sound/asound.h=1085=typedef int __bitwise snd_ctl_elem_iface_t;\n--\ntools/perf/trace/beauty/include/uapi/sound/asound.h-1110-\ntools/perf/trace/beauty/include/uapi/sound/asound.h:1111:/* for further details see the ACPI and PCI power management specification */\ntools/perf/trace/beauty/include/uapi/sound/asound.h-1112-#define SNDRV_CTL_POWER_D0\t\t0x0000\t/* full On */\n--\ntools/perf/ui/stdio/hist.c=113=static size_t __callchain__fprintf_graph(FILE *fp, struct rb_root *root,\n--\ntools/perf/ui/stdio/hist.c-139-\t\t/*\ntools/perf/ui/stdio/hist.c:140:\t\t * The depth mask manages the output of pipes that show\ntools/perf/ui/stdio/hist.c-141-\t\t * the depth. We don't want to keep the pipes of the current\n--\ntools/perf/util/bpf_counter.c=426=static int bperf_check_target(struct evsel *evsel,\n--\ntools/perf/util/bpf_counter.c-431-\tif (evsel-\u003ecore.leader-\u003enr_members \u003e 1) {\ntools/perf/util/bpf_counter.c:432:\t\tpr_err(\"bpf managed perf events do not yet support groups.\\n\");\ntools/perf/util/bpf_counter.c-433-\t\treturn -1;\n--\ntools/perf/util/bpf_counter.c-449-\t} else {\ntools/perf/util/bpf_counter.c:450:\t\tpr_err(\"bpf managed perf events do not yet support these targets.\\n\");\ntools/perf/util/bpf_counter.c-451-\t\treturn -1;\n--\ntools/perf/util/cs-etm-decoder/cs-etm-decoder.c=99=int cs_etm_decoder__get_packet(struct cs_etm_packet_queue *packet_queue,\n--\ntools/perf/util/cs-etm-decoder/cs-etm-decoder.c-110-\t * increments the tail *before* using it.  This is somewhat counter\ntools/perf/util/cs-etm-decoder/cs-etm-decoder.c:111:\t * intuitive but it has the advantage of centralizing tail management\ntools/perf/util/cs-etm-decoder/cs-etm-decoder.c-112-\t * at a single location.  Because of that we need to follow the same\n--\ntools/perf/util/data.c=337=static int open_dir(struct perf_data *data)\n\n"
}

11/2 2026/08/09 19:08 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 35411
							output: 42
							thoughts: 993
						

Thoughts:
**MANA Driver Analysis for Fuzzing Worthiness**

Okay, here's the breakdown. The question is whether to mark this patch as "WorthFuzzing=false". The key is the "vendor-specific PCIe switch, SmartNIC, or GPU drivers" clause and if it is emulated in standard QEMU.

First, I need to figure out if `PCI_HYPERV` (which I assume is associated with MANA) is even fuzzable. The prompt lists specific scenarios to avoid, so let's check those. The syzkaller authorship (triage@syzkaller.com) gives me pause – it implies some level of testing or bug discovery. Syzkaller *can* fuzz PCI devices via injected config space and MMIO using the `syz_pci_...` pseudo-syscalls. This is important to remember!

The prompt explicitly excludes vendor-specific SmartNIC drivers that need *physical* PCIe cards not emulated in *standard* QEMU. MANA (Microsoft Azure Network Adapter) *is* a SmartNIC driver, or at least a network adapter. The description "Microsoft Azure Network Adapter (MANA) support" confirms this. Now, the critical question: is it emulated in *standard* QEMU? No, it's not. I'm pretty sure it's a virtual NIC, specifically a SR-IOV VF on Azure, but that is not the same as standard QEMU emulation.

The prompt’s "GCE or QEMU" reference is also relevant. Syzkaller *mostly* runs on GCE for its main instances, but I am aware that Syzkaller *can* fuzz PCI devices by injecting PCI config space and MMIO. The prompt seems to cover this case.

The commit author is 'syz-cluster <triage@syzkaller.com>', which *does* indicate a syzkaller test patch. But even if syzkaller is testing it, it doesn't change the core question. Syzkaller can fuzz PCI devices.

Okay, let me re-evaluate based on the prompt's exclusion criteria: MANA is a vendor-specific SmartNIC (Microsoft Azure Network Adapter). It requires hardware features not emulated in standard QEMU. Therefore, I must conclude that `WorthFuzzing=false`. The fact that Syzkaller found something is potentially misleading, but it's not enough to change my conclusion. I need to make sure to check the MANA code to confirm it is not supported in the standard QEMU setup and mark it as such.



12/2 2026/08/09 19:08 tool read-file
0m Args:
{
  "File": "drivers/net/ethernet/microsoft/mana/mana_en.c",
  "FirstLine": 1,
  "LineCount": 50
}

Results:
{
  "Contents": "   1:\t// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause\n   2:\t/* Copyright (c) 2021, Microsoft Corporation. */\n   3:\t\n   4:\t#include \u003cuapi/linux/bpf.h\u003e\n   5:\t\n   6:\t#include \u003clinux/debugfs.h\u003e\n   7:\t#include \u003clinux/inetdevice.h\u003e\n   8:\t#include \u003clinux/etherdevice.h\u003e\n   9:\t#include \u003clinux/ethtool.h\u003e\n  10:\t#include \u003clinux/filter.h\u003e\n  11:\t#include \u003clinux/mm.h\u003e\n  12:\t#include \u003clinux/pci.h\u003e\n  13:\t#include \u003clinux/export.h\u003e\n  14:\t#include \u003clinux/skbuff.h\u003e\n  15:\t\n  16:\t#include \u003cnet/checksum.h\u003e\n  17:\t#include \u003cnet/ip6_checksum.h\u003e\n  18:\t#include \u003cnet/netdev_lock.h\u003e\n  19:\t#include \u003cnet/page_pool/helpers.h\u003e\n  20:\t#include \u003cnet/xdp.h\u003e\n  21:\t\n  22:\t#include \u003cnet/mana/mana.h\u003e\n  23:\t#include \u003cnet/mana/mana_auxiliary.h\u003e\n  24:\t#include \u003cnet/mana/hw_channel.h\u003e\n  25:\t\n  26:\tstatic DEFINE_IDA(mana_adev_ida);\n  27:\t\n  28:\tstatic int mana_adev_idx_alloc(void)\n  29:\t{\n  30:\t\treturn ida_alloc(\u0026mana_adev_ida, GFP_KERNEL);\n  31:\t}\n  32:\t\n  33:\tstatic void mana_adev_idx_free(int idx)\n  34:\t{\n  35:\t\tida_free(\u0026mana_adev_ida, idx);\n  36:\t}\n  37:\t\n  38:\tstatic ssize_t mana_dbg_q_read(struct file *filp, char __user *buf, size_t count,\n  39:\t\t\t\t       loff_t *pos)\n  40:\t{\n  41:\t\tstruct gdma_queue *gdma_q = filp-\u003eprivate_data;\n  42:\t\n  43:\t\treturn simple_read_from_buffer(buf, count, pos, gdma_q-\u003equeue_mem_ptr,\n  44:\t\t\t\t\t       gdma_q-\u003equeue_size);\n  45:\t}\n  46:\t\n  47:\tstatic const struct file_operations mana_dbg_q_fops = {\n  48:\t\t.owner  = THIS_MODULE,\n  49:\t\t.open   = simple_open,\n  50:\t\t.read   = mana_dbg_q_read,\n"
}

13/2 2026/08/09 19:08 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 37728
							output: 25
							thoughts: 1077
						

Thoughts:
**Fuzzing MANA: A Deep Dive**

Okay, so MANA. It's a PCI device driver, which immediately makes me think, "syzkaller?" Does syzkaller hit it? There's that `syz_pci_...` pseudo-syscall, a dedicated PCI fuzzer in syzkaller. The prompt is giving me some serious pause though. It explicitly mentions drivers like mlxsw, pds_core, qed, ionic, and amdgpu – essentially SmartNIC, PCIe switch, or GPU drivers that *need* actual physical hardware, which isn't emulated in standard QEMU. Is MANA even in that category?

Wait, MANA is a virtual NIC, an SR-IOV VF provided by Azure. It's not a physical card. That changes things. If it's virtual, can syzkaller's PCI fuzzer get to it? Yes, it *should* be able to. Syzkaller fuzzer is designed to target any PCI device by matching the vendor/device ID and injecting PCI config space and MMIO accesses. It doesn't need a specific physical card, that's the whole point.

The prompt further complicates things, though. It states to exclude code paths that are "impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware". Since MANA is *not* emulated in QEMU, the PCI fuzzer seems to be the only way to reach it. But, is the PCI fuzzer itself considered "software-emulated hardware"? No, syzkaller's PCI fuzzer is a fuzzing tool, not a hardware emulator.

However, the prompt seems to want me to exclude it. It says, "Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed, ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU."

MANA *is* a SmartNIC driver, a Microsoft Azure Network Adapter. Am I supposed to consider it a SmartNIC and exclude it?

Wait a second, let me check the patch. This patch fixes bugs in `mana_ib_install_cq_cb`, `mana_hwc_send_request`, and `mana_hwc_rx_event_handler`. These bugs were likely discovered by syzkaller. The author is `syz-cluster <triage@syzkaller.com>`.

"syz-cluster: applied patch under review"! That's it! If syzkaller found a bug, that means syzkaller *is* fuzzing it. I need to figure out *how*. Could syzkaller be running on Azure? Yep, syzkaller has an Azure backend!

Now, the prompt stated the opposite: "impossible to reach in virtualized environments like GCE or QEMU". If it can be reached on Azure, is Azure somehow being ignored by the prompt as an option? But, the prompt *does* say "like GCE or QEMU".

Okay, back to the basics: "Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed, ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU." MANA is a virtual NIC in Azure, *not* a "physical PCIe hardware card."

The commit confirms syzkaller is fuzzing it! "syz-cluster: applied patch under review". So, syzbot found a bug in it, which means it must be fuzzing it via the `syz_pci_...` pseudo-syscall.

Therefore, WorthFuzzing=true.



14/2 2026/08/09 19:09 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "mana",
  "PathPrefix": "sys/linux/"
}

Results:
{
  "error": "no matches"
}

15/2 2026/08/09 19:09 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 39656
							output: 105
							thoughts: 1893
						

Thoughts:
**Fuzzing Decision for the MANA Driver**

Okay, let's break this down. The prompt is very specific about excluding certain code paths. The key phrase is "vendor-specific PCIe switch, SmartNIC, or GPU drivers... that require physical PCIe hardware cards not emulated in standard QEMU." Right away, I see this is about a MANA driver and immediately my first thought is to check if it's considered a PCI device, which it is. Given that I can't look through `syz/linux/` I need to start reasoning about the nature of this device.

The immediate thought is that MANA is a SmartNIC. Given my background, I understand that SmartNICs often have very specific hardware dependencies, and that's the red flag. If it's a SmartNIC, then it almost certainly falls into the prompt's exclusion criteria. If syzkaller can hit it, it means that this device must be reachable in *some* way. The obvious thought is that syzkaller on Azure reaches it, or maybe through PCI fuzzer, which injects random data into the PCI config space and MMIO. Even if it can be reached via a PCI fuzzer, my thinking shifts to the fact the fuzzer doesn't emulate the device completely. Instead, it provides random responses to MMIO reads.

The prompt very explicitly says that even if there's a fuzzer that *can* reach it via the PCI bus, I still need to return WorthFuzzing=false. Because in this case, the PCI fuzzer is likely exposing shallow issues, but not providing any meaningful fuzzing of core logic.

I think back to my knowledge and understanding of other drivers that are known to be difficult to fuzz and recall the list `mlxsw, pds_core, qed, ionic, amdgpu`. I know that these are all either actual hardware or SR-IOV VFs. And MANA is the exact same type of device.

Looking at the patch itself, I can see that the changes are only in the `mana/` directory, specifically in the `drivers/infiniband` and `drivers/net/ethernet/microsoft` parts. This confirms it’s a vendor-specific SmartNIC driver. No other subsystems are touched, so I can be sure that this patch exclusively modifies the Microsoft Azure Network Adapter (MANA) driver.

I check QEMU's supported devices and realize that MANA is not emulated in QEMU.

Given that it's a vendor-specific SmartNIC driver that requires the MANA hardware (or its SR-IOV VF), which is not emulated in standard QEMU, and while it might be reachable by syzkaller's PCI fuzzer, deep functional fuzzing is impossible without the actual physical hardware or a dedicated emulator. Therefore, I need to follow the instructions and return `WorthFuzzing=false`.



16/2 2026/08/09 19:09 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch exclusively modifies the Microsoft Azure Network Adapter (MANA) driver, which is a vendor-specific SmartNIC driver. This hardware is not emulated in standard QEMU or GCE environments. Following the instructions to exclude vendor-specific SmartNIC drivers that require physical PCIe hardware not emulated in standard QEMU, this patch is not worth fuzzing.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch exclusively modifies the Microsoft Azure Network Adapter (MANA) driver, which is a vendor-specific SmartNIC driver. This hardware is not emulated in standard QEMU or GCE environments. Following the instructions to exclude vendor-specific SmartNIC drivers that require physical PCIe hardware not emulated in standard QEMU, this patch is not worth fuzzing.",
  "WorthFuzzing": false
}

17/1 2026/08/09 19:09 action If
0m Args:
{
  "WorthFuzzing": false
}

Results:
null

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)