AI Trajectory


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

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the Microsoft Azure Network Adapter (MANA) driver, which is a vendor-specific PCIe SmartNIC/virtual function driver. This hardware is not emulated in standard QEMU or GCE environments, making the code unreachable during standard fuzzing.",
  "WorthFuzzing": false
}

1/1 2026/08/04 00:04 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit fb5e43f1a00a30b95cd2ceb79d0c4b010c82f1e8\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Tue Aug 4 00:04:26 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..fa6fcc2475c1a 100644\n--- a/drivers/net/ethernet/microsoft/mana/gdma_main.c\n+++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c\n@@ -732,6 +732,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 +744,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@@ -1053,15 +1055,28 @@ static void mana_gd_create_cq(const struct gdma_queue_spec *spec,\n static void mana_gd_destroy_cq(struct gdma_context *gc,\n \t\t\t       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/* No rcu_read_lock() here: mana_gd_destroy_cq() 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;\n \n-\tif (!gc-\u003ecq_table[id])\n+\tif (!rcu_access_pointer(cq_table[id]))\n \t\treturn;\n \n-\tgc-\u003ecq_table[id] = NULL;\n+\trcu_assign_pointer(cq_table[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 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..d92032b466af2 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,52 @@\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\trefcount_set(\u0026ctx-\u003erefcnt, 1);\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   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 (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 +59,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 +115,17 @@ 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/* Validate msg_id is in range before using it to index bitmap\n+\t * and caller_ctx array.  Malicious firmware could send\n+\t * out-of-range msg_id causing out-of-bounds access.\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 +133,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-\t/* Must post rx wqe before complete(), otherwise the next rx may\n-\t * hit no_wqe error.\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/* Only overwrite error if the sender hasn't timed out\n+\t\t * or been force-completed by destroy.  When output_buf\n+\t\t * is NULL, a terminal error (-ENODEV or timeout) has\n+\t\t * already been set — preserve it so the sender doesn't\n+\t\t * see a spurious success.\n+\t\t */\n+\t\tctx-\u003eerror = err;\n+\t}\n+\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@@ -192,7 +269,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@@ -261,19 +343,69 @@ static void mana_hwc_rx_event_handler(void *ctx, u32 gdma_rxq_id,\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-\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+\t/* inline_oob_size_div4 is read from the WQE in device-accessible RQ\n+\t * memory, so a malicious host in a CVM (or buggy firmware) could set\n+\t * it to push the SGE past the RQ buffer.  Bounds-check the SGE it\n+\t * locates before dereferencing sge-\u003eaddress below.  A validly posted\n+\t * WQE keeps the SGE inside the ring (worst case ends exactly at the\n+\t * buffer boundary); reject anything that would read past it.  The\n+\t * slot cannot be trusted here, so leak this RX WQE rather than repost\n+\t * the wrong one -- as in the SGE-address mismatch path below.\n+\t */\n+\tif ((u8 *)(sge + 1) \u003e (u8 *)rq-\u003equeue_mem_ptr + rq-\u003equeue_size) {\n+\t\tdev_err(hwc-\u003edev, \"HWC RX: SGE past RQ buffer, oob_div4=%u\\n\",\n+\t\t\tdma_oob-\u003einline_oob_size_div4);\n+\t\treturn;\n+\t}\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+\t/* Recover the originating RX slot from the SGE address.  Of the three\n+\t * terms here only sge-\u003eaddress lives in device-accessible RQ memory;\n+\t * rq_base_addr and max_resp_msg_size are driver-private constants.  An\n+\t * in-range but wrong/unaligned SGE (corrupted WQE, or a malicious host\n+\t * in a CVM) would otherwise truncate onto a neighbouring slot, letting\n+\t * us read a stale response that could complete the wrong, reused\n+\t * in-flight request.  Require the index to be in range AND the address\n+\t * to exactly match the value the driver posted for that slot.\n+\t */\n+\trq_base_addr = hwc_rxq-\u003emsg_buf-\u003emem_info.dma_handle;\n+\trx_req_idx = (sge-\u003eaddress - rq_base_addr) / hwc-\u003emax_resp_msg_size;\n+\n+\tif (rx_req_idx \u003e= hwc_rxq-\u003equeue_depth) {\n+\t\t/* Cannot trust which WQE this is, so we cannot safely repost\n+\t\t * it; leak one RX WQE and bail.  An out-of-range index means\n+\t\t * a corrupted SGE from hardware (or host tampering), an\n+\t\t * unrecoverable device error.\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\treturn;\n \t}\n \n \trx_req = \u0026hwc_rxq-\u003emsg_buf-\u003ereqs[rx_req_idx];\n+\tif (sge-\u003eaddress != (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-\u003eaddress, rx_req_idx);\n+\t\treturn;\n+\t}\n+\n \tresp = (struct gdma_resp_hdr *)rx_req-\u003ebuf_va;\n \n+\t/* Validate resp_len covers the response header before reading\n+\t * hwc_msg_id.  A short response leaves stale data from the\n+\t * previous buffer occupant, which could match a live slot and\n+\t * complete the wrong request.\n+\t */\n+\tif (rx_oob-\u003etx_oob_data_size \u003c sizeof(*resp)) {\n+\t\tdev_err(hwc-\u003edev, \"HWC RX: short resp_len=%u\\n\",\n+\t\t\trx_oob-\u003etx_oob_data_size);\n+\t\tmana_hwc_post_rx_wqe(hwc_rxq, rx_req);\n+\t\treturn;\n+\t}\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@@ -281,6 +413,7 @@ static void mana_hwc_rx_event_handler(void *ctx, u32 gdma_rxq_id,\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 +517,20 @@ 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-\n \tif (hwc_cq-\u003egdma_cq)\n \t\tmana_gd_destroy_queue(gc, hwc_cq-\u003egdma_cq);\n \n+\t/* comp_buf is reached only by mana_hwc_comp_event(), which the\n+\t * EQ handler invokes via cq_table[id].  The CQ destroy above\n+\t * already cleared that slot and ran synchronize_rcu(), so no\n+\t * handler can reach comp_buf once it returns.  Destroying the EQ\n+\t * here additionally tears down the IRQ (defense in depth) before\n+\t * comp_buf and hwc_cq are freed below.\n+\t */\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 +766,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 +796,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 +810,15 @@ 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 \tint err;\n \n \tinit_completion(\u0026hwc-\u003ehwc_init_eqe_comp);\n@@ -687,24 +832,51 @@ static int mana_hwc_establish_channel(struct gdma_context *gc, u16 *q_depth,\n \tif (err)\n \t\treturn err;\n \n-\tif (!wait_for_completion_timeout(\u0026hwc-\u003ehwc_init_eqe_comp, 60 * HZ))\n-\t\treturn -ETIMEDOUT;\n+\t/* setup_hwc activated MST entries — hardware can now DMA into\n+\t * our queue buffers.  If anything below fails, we must tear\n+\t * down before returning so the caller doesn't need to track\n+\t * whether setup_hwc succeeded.\n+\t */\n+\thwc-\u003esetup_active = true;\n+\n+\tif (!wait_for_completion_timeout(\u0026hwc-\u003ehwc_init_eqe_comp, 60 * HZ)) {\n+\t\terr = -ETIMEDOUT;\n+\t\tgoto teardown;\n+\t}\n \n \t*q_depth = hwc-\u003ehwc_init_q_depth_max;\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\treturn -EPROTO;\n+\tif (WARN_ON(cq-\u003eid \u003e= gc-\u003emax_num_cqs)) {\n+\t\terr = -EPROTO;\n+\t\tgoto teardown;\n+\t}\n \n-\tgc-\u003ecq_table = vcalloc(gc-\u003emax_num_cqs, sizeof(struct gdma_queue *));\n-\tif (!gc-\u003ecq_table)\n-\t\treturn -ENOMEM;\n+\tcq_table = vcalloc(gc-\u003emax_num_cqs, sizeof(*cq_table));\n+\tif (!cq_table) {\n+\t\terr = -ENOMEM;\n+\t\tgoto teardown;\n+\t}\n \n-\tgc-\u003ecq_table[cq-\u003eid] = cq;\n+\trcu_assign_pointer(cq_table[cq-\u003eid], 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+teardown:\n+\t{\n+\t\tint td_err = mana_smc_teardown_hwc(\u0026gc-\u003eshm_channel, false);\n+\n+\t\tif (!td_err)\n+\t\t\thwc-\u003esetup_active = false;\n+\n+\t\treturn td_err ? td_err : err;\n+\t}\n }\n \n static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth,\n@@ -716,6 +888,15 @@ static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth,\n \tif (err)\n \t\treturn err;\n \n+\t/* Set the queue dimensions before creating the CQ: doing so\n+\t * registers mana_hwc_rx_event_handler(), which divides by\n+\t * hwc-\u003emax_resp_msg_size and range-checks hwc-\u003enum_inflight_msg.\n+\t * They must be valid before any RX completion can be delivered.\n+\t */\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 \t/* CQ is shared by SQ and RQ, so CQ's queue depth is the sum of SQ\n \t * queue depth and RQ queue depth.\n \t */\n@@ -728,23 +909,20 @@ 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 \t\tgoto out;\n \t}\n \n-\thwc-\u003enum_inflight_msg = q_depth;\n-\thwc-\u003emax_req_msg_size = max_req_msg_size;\n-\n \treturn 0;\n out:\n \t/* mana_hwc_create_channel() will do the cleanup.*/\n@@ -811,27 +989,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 +1049,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 +1062,17 @@ 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 \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 +1084,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,8 +1104,14 @@ 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/* Take handle_resp's ref before posting — hardware can respond\n+\t * immediately after the doorbell ring.\n+\t */\n+\trefcount_inc(\u0026ctx-\u003erefcnt);\n+\n \terr = mana_hwc_post_tx_wqe(txq, tx_wr, dest_vrq, dest_vrcq, false);\n \tif (err) {\n+\t\trefcount_dec(\u0026ctx-\u003erefcnt);\n \t\tdev_err(hwc-\u003edev, \"HWC: Failed to post send WQE: %d\\n\", err);\n \t\tgoto out;\n \t}\n@@ -907,31 +1122,86 @@ 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\thwc-\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: no WQE was submitted so handle_resp()\n+\t * cannot race here.  refcount is 1 (no second ref taken).\n+\t */\n+\tctx = hwc-\u003ecaller_ctx + msg_id;\n+\tspin_lock_irqsave(\u0026ctx-\u003elock, flags);\n+\tctx-\u003eoutput_buf = NULL;\n+\tspin_unlock_irqrestore(\u0026ctx-\u003elock, flags);\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..65b025e8f211c 100644\n--- a/drivers/net/ethernet/microsoft/mana/mana_en.c\n+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c\n@@ -2496,6 +2496,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 +2597,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@@ -2821,6 +2828,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 +2913,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 \ndiff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h\nindex 0c395917b2144..74eccc80cf6b4 100644\n--- a/include/net/mana/gdma.h\n+++ b/include/net/mana/gdma.h\n@@ -416,9 +416,34 @@ 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\" is justified by teardown ordering, not by\n+\t * a lock: the base table is replaced+freed only by\n+\t * mana_hwc_destroy_channel() (and the create-time reinit), and every\n+\t * teardown path first runs mana_remove() + mana_rdma_remove(), which\n+\t * synchronously drain the netdev and the IB device\n+\t * (unregister_netdevice / ib_unregister_device) that bound all\n+\t * install/remove callers; the reinit case runs before either\n+\t * consumer is probed.  So no slow-path caller can run while the base\n+\t * table is being freed.\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;\ndiff --git a/include/net/mana/hw_channel.h b/include/net/mana/hw_channel.h\nindex 16feb39616c1b..5a55cedf0607a 100644\n--- a/include/net/mana/hw_channel.h\n+++ b/include/net/mana/hw_channel.h\n@@ -173,6 +173,23 @@ struct hwc_caller_ctx {\n \n \tu32 error; /* Linux error code */\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,6 +198,7 @@ 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@@ -192,13 +210,28 @@ 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/* 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/04 00:04 agent patch-evaluator
0m Model:
best-expensive

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the Microsoft Azure Network Adapter (MANA) driver, which is a vendor-specific PCIe SmartNIC/virtual function driver. This hardware is not emulated in standard QEMU or GCE environments, making the code unreachable during standard 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 fb5e43f1a00a30b95cd2ceb79d0c4b010c82f1e8
Author: syz-cluster <triage@syzkaller.com>
Date:   Tue Aug 4 00:04:26 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..fa6fcc2475c1a 100644
--- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
+++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
@@ -732,6 +732,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 +744,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;
 
@@ -1053,15 +1055,28 @@ static void mana_gd_create_cq(const struct gdma_queue_spec *spec,
 static void mana_gd_destroy_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)
+	/* No rcu_read_lock() here: mana_gd_destroy_cq() 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;
 
-	if (!gc->cq_table[id])
+	if (!rcu_access_pointer(cq_table[id]))
 		return;
 
-	gc->cq_table[id] = NULL;
+	rcu_assign_pointer(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..d92032b466af2 100644
--- a/drivers/net/ethernet/microsoft/mana/hw_channel.c
+++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c
@@ -4,27 +4,52 @@
 #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);
+			refcount_set(&ctx->refcnt, 1);
+			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,
+			   hwc->hwc_timed_out ||
+			   !bitmap_full(r->map, r->size));
 
-	spin_unlock_irqrestore(&r->lock, flags);
+		if (hwc->hwc_timed_out)
+			return -ETIMEDOUT;
+	}
 
 	*msg_id = index;
-
 	return 0;
 }
 
@@ -34,10 +59,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 +115,17 @@ static void mana_hwc_handle_resp(struct hw_channel_context *hwc, u32 resp_len,
 	struct hwc_caller_ctx *ctx;
 	int err;
 
+	/* Validate msg_id is in range before using it to index bitmap
+	 * and caller_ctx array.  Malicious firmware could send
+	 * out-of-range msg_id causing out-of-bounds access.
+	 */
+	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 +133,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;
 
-	/* Must post rx wqe before complete(), otherwise the next rx may
-	 * hit no_wqe error.
+	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) {
+		/* Only overwrite error if the sender hasn't timed out
+		 * or been force-completed by destroy.  When output_buf
+		 * is NULL, a terminal error (-ENODEV or timeout) has
+		 * already been set — preserve it so the sender doesn't
+		 * see a spurious success.
+		 */
+		ctx->error = err;
+	}
+
+	/* 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,
@@ -192,7 +269,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:
@@ -261,19 +343,69 @@ static void mana_hwc_rx_event_handler(void *ctx, u32 gdma_rxq_id,
 
 	sge = (struct gdma_sge *)(wqe + 8 + dma_oob->inline_oob_size_div4 * 4);
 
-	/* Select the RX work request for virtual address and for reposting. */
-	rq_base_addr = hwc_rxq->msg_buf->mem_info.dma_handle;
-	rx_req_idx = (sge->address - rq_base_addr) / hwc->max_req_msg_size;
+	/* inline_oob_size_div4 is read from the WQE in device-accessible RQ
+	 * memory, so a malicious host in a CVM (or buggy firmware) could set
+	 * it to push the SGE past the RQ buffer.  Bounds-check the SGE it
+	 * locates before dereferencing sge->address below.  A validly posted
+	 * WQE keeps the SGE inside the ring (worst case ends exactly at the
+	 * buffer boundary); reject anything that would read past it.  The
+	 * slot cannot be trusted here, so leak this RX WQE rather than repost
+	 * the wrong one -- as in the SGE-address mismatch path below.
+	 */
+	if ((u8 *)(sge + 1) > (u8 *)rq->queue_mem_ptr + rq->queue_size) {
+		dev_err(hwc->dev, "HWC RX: SGE past RQ buffer, oob_div4=%u\n",
+			dma_oob->inline_oob_size_div4);
+		return;
+	}
 
-	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);
+	/* Recover the originating RX slot from the SGE address.  Of the three
+	 * terms here only sge->address lives in device-accessible RQ memory;
+	 * rq_base_addr and max_resp_msg_size are driver-private constants.  An
+	 * in-range but wrong/unaligned SGE (corrupted WQE, or a malicious host
+	 * in a CVM) 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 to be in range AND the address
+	 * to exactly match the value the driver posted for that slot.
+	 */
+	rq_base_addr = hwc_rxq->msg_buf->mem_info.dma_handle;
+	rx_req_idx = (sge->address - rq_base_addr) / hwc->max_resp_msg_size;
+
+	if (rx_req_idx >= hwc_rxq->queue_depth) {
+		/* Cannot trust which WQE this is, so we cannot safely repost
+		 * it; leak one RX WQE and bail.  An out-of-range index means
+		 * a corrupted SGE from hardware (or host tampering), an
+		 * unrecoverable device error.
+		 */
+		dev_err(hwc->dev, "HWC RX: SGE idx %llu out of range\n",
+			rx_req_idx);
 		return;
 	}
 
 	rx_req = &hwc_rxq->msg_buf->reqs[rx_req_idx];
+	if (sge->address != (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->address, rx_req_idx);
+		return;
+	}
+
 	resp = (struct gdma_resp_hdr *)rx_req->buf_va;
 
+	/* Validate resp_len covers the response header before reading
+	 * hwc_msg_id.  A short response leaves stale data from the
+	 * previous buffer occupant, which could match a live slot and
+	 * complete the wrong request.
+	 */
+	if (rx_oob->tx_oob_data_size < sizeof(*resp)) {
+		dev_err(hwc->dev, "HWC RX: short resp_len=%u\n",
+			rx_oob->tx_oob_data_size);
+		mana_hwc_post_rx_wqe(hwc_rxq, rx_req);
+		return;
+	}
+
 	/* Read msg_id once from DMA buffer to prevent TOCTOU:
 	 * DMA memory is shared/unencrypted in CVMs - host can
 	 * modify it between reads.
@@ -281,6 +413,7 @@ static void mana_hwc_rx_event_handler(void *ctx, u32 gdma_rxq_id,
 	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 +517,20 @@ 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);
-
 	if (hwc_cq->gdma_cq)
 		mana_gd_destroy_queue(gc, hwc_cq->gdma_cq);
 
+	/* comp_buf is reached only by mana_hwc_comp_event(), which the
+	 * EQ handler invokes via cq_table[id].  The CQ destroy above
+	 * already cleared that slot and ran synchronize_rcu(), so no
+	 * handler can reach comp_buf once it returns.  Destroying the EQ
+	 * here additionally tears down the IRQ (defense in depth) before
+	 * comp_buf and hwc_cq are freed below.
+	 */
 	if (hwc_cq->gdma_eq)
 		mana_gd_destroy_queue(gc, hwc_cq->gdma_eq);
 
+	kfree(hwc_cq->comp_buf);
 	kfree(hwc_cq);
 }
 
@@ -627,7 +766,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 +796,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 +810,15 @@ 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;
 	int err;
 
 	init_completion(&hwc->hwc_init_eqe_comp);
@@ -687,24 +832,51 @@ static int mana_hwc_establish_channel(struct gdma_context *gc, u16 *q_depth,
 	if (err)
 		return err;
 
-	if (!wait_for_completion_timeout(&hwc->hwc_init_eqe_comp, 60 * HZ))
-		return -ETIMEDOUT;
+	/* setup_hwc activated MST entries — hardware can now DMA into
+	 * our queue buffers.  If anything below fails, we must tear
+	 * down before returning so the caller doesn't need to track
+	 * whether setup_hwc succeeded.
+	 */
+	hwc->setup_active = true;
+
+	if (!wait_for_completion_timeout(&hwc->hwc_init_eqe_comp, 60 * HZ)) {
+		err = -ETIMEDOUT;
+		goto teardown;
+	}
 
 	*q_depth = hwc->hwc_init_q_depth_max;
 	*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))
-		return -EPROTO;
+	if (WARN_ON(cq->id >= gc->max_num_cqs)) {
+		err = -EPROTO;
+		goto teardown;
+	}
 
-	gc->cq_table = vcalloc(gc->max_num_cqs, sizeof(struct gdma_queue *));
-	if (!gc->cq_table)
-		return -ENOMEM;
+	cq_table = vcalloc(gc->max_num_cqs, sizeof(*cq_table));
+	if (!cq_table) {
+		err = -ENOMEM;
+		goto teardown;
+	}
 
-	gc->cq_table[cq->id] = cq;
+	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;
+
+teardown:
+	{
+		int td_err = mana_smc_teardown_hwc(&gc->shm_channel, false);
+
+		if (!td_err)
+			hwc->setup_active = false;
+
+		return td_err ? td_err : err;
+	}
 }
 
 static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth,
@@ -716,6 +888,15 @@ static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth,
 	if (err)
 		return err;
 
+	/* Set the queue dimensions before creating the CQ: doing so
+	 * registers mana_hwc_rx_event_handler(), which divides by
+	 * hwc->max_resp_msg_size and range-checks hwc->num_inflight_msg.
+	 * They must be valid before any RX completion can be delivered.
+	 */
+	hwc->num_inflight_msg = q_depth;
+	hwc->max_req_msg_size = max_req_msg_size;
+	hwc->max_resp_msg_size = max_resp_msg_size;
+
 	/* CQ is shared by SQ and RQ, so CQ's queue depth is the sum of SQ
 	 * queue depth and RQ queue depth.
 	 */
@@ -728,23 +909,20 @@ 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);
 		goto out;
 	}
 
-	hwc->num_inflight_msg = q_depth;
-	hwc->max_req_msg_size = max_req_msg_size;
-
 	return 0;
 out:
 	/* mana_hwc_create_channel() will do the cleanup.*/
@@ -811,27 +989,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 +1049,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 +1062,17 @@ 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;
 	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 +1084,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,8 +1104,14 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,
 		dest_vrcq = hwc->pf_dest_vrcq_id;
 	}
 
+	/* Take handle_resp's ref before posting — hardware can respond
+	 * immediately after the doorbell ring.
+	 */
+	refcount_inc(&ctx->refcnt);
+
 	err = mana_hwc_post_tx_wqe(txq, tx_wr, dest_vrq, dest_vrcq, false);
 	if (err) {
+		refcount_dec(&ctx->refcnt);
 		dev_err(hwc->dev, "HWC: Failed to post send WQE: %d\n", err);
 		goto out;
 	}
@@ -907,31 +1122,86 @@ 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);
+		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: no WQE was submitted so handle_resp()
+	 * cannot race here.  refcount is 1 (no second ref taken).
+	 */
+	ctx = hwc->caller_ctx + msg_id;
+	spin_lock_irqsave(&ctx->lock, flags);
+	ctx->output_buf = NULL;
+	spin_unlock_irqrestore(&ctx->lock, flags);
+	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..65b025e8f211c 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -2496,6 +2496,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 +2597,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);
 
@@ -2821,6 +2828,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 +2913,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);
 
diff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h
index 0c395917b2144..74eccc80cf6b4 100644
--- a/include/net/mana/gdma.h
+++ b/include/net/mana/gdma.h
@@ -416,9 +416,34 @@ 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" is justified by teardown ordering, not by
+	 * a lock: the base table is replaced+freed only by
+	 * mana_hwc_destroy_channel() (and the create-time reinit), and every
+	 * teardown path first runs mana_remove() + mana_rdma_remove(), which
+	 * synchronously drain the netdev and the IB device
+	 * (unregister_netdevice / ib_unregister_device) that bound all
+	 * install/remove callers; the reinit case runs before either
+	 * consumer is probed.  So no slow-path caller can run while the base
+	 * table is being freed.
+	 */
+	struct gdma_queue	__rcu * __rcu *cq_table;
 
 	/* Protect eq_test_event and test_event_eq_id  */
 	struct mutex		eq_test_event_mutex;
diff --git a/include/net/mana/hw_channel.h b/include/net/mana/hw_channel.h
index 16feb39616c1b..5a55cedf0607a 100644
--- a/include/net/mana/hw_channel.h
+++ b/include/net/mana/hw_channel.h
@@ -173,6 +173,23 @@ struct hwc_caller_ctx {
 
 	u32 error; /* Linux error code */
 	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,6 +198,7 @@ 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;
@@ -192,13 +210,28 @@ 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;
 
+	/* 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/04 00:04 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 15258
							output: 23
							thoughts: 346
						

Thoughts:
**Fuzzing Feasibility of the MANA Driver Patch**

Okay, so I've got this patch and I need to figure out if it introduces functional changes in the kernel that warrant fuzzing. The patch is touching the `mana` driver, which from what I can see is a driver for the Microsoft Azure Network Adapter (MANA), specifically within the `drivers/infiniband/hw/mana/` and `drivers/net/ethernet/microsoft/mana/` directories. It appears to be adding RCU protection to `cq_table`, some bounds checking, and handling of timeouts and duplicate responses in the hardware channel (HWC). That's definitely interesting, as all of those have the potential to introduce subtle bugs.

The key question is, can this be *reached* in a fuzzing environment? MANA is a PCI device, Azure-specific hardware. My immediate thought is, "does this show up in common virtualized environments like GCE or QEMU?". Probably not, it's specific hardware. I need to make sure though. It's a SmartNIC or virtual function provided by Azure. My previous experience suggests that's pretty much a "no" for standard QEMU. It's pretty likely, this relies on Azure's Hyper-V environment or specific hardware.

Right, the prompt says the following:
"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 fits the description of a vendor-specific SmartNIC, right? Microsoft Azure Network Adapter, so yeah, that's it. It's not something standard QEMU is going to emulate.

And that's important because syzkaller, by default, doesn't run on Azure. Unless there's been some configuration, but the standard setup uses QEMU/GCE, which likely isn't going to have this particular hardware.

So, is it worth fuzzing this thing? It probably won't be easily, so I need to check the emulation again, but so far the answer looks like no. It's a vendor-specific PCI device. It looks like it. Okay, no standard QEMU emulation.

Let's do a double check on the emulation situation, but my gut says it's not going to be easy.



4/2 2026/08/04 00:04 tool grepper
0m Args:
{
  "Expression": "mana_probe",
  "PathPrefix": ""
}

Results:
{
  "Output": "drivers/net/ethernet/microsoft/mana/gdma_main.c=177=static int mana_gd_query_max_resources(struct pci_dev *pdev)\n--\ndrivers/net/ethernet/microsoft/mana/gdma_main.c-261-\ndrivers/net/ethernet/microsoft/mana/gdma_main.c:262:\t/* Cap to the same limit used by mana_probe() for port instantiation,\ndrivers/net/ethernet/microsoft/mana/gdma_main.c-263-\t * so MSI-X and queue budgeting matches the actual port count.\n--\ndrivers/net/ethernet/microsoft/mana/gdma_main.c=2317=static int mana_gd_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n--\ndrivers/net/ethernet/microsoft/mana/gdma_main.c-2372-\ndrivers/net/ethernet/microsoft/mana/gdma_main.c:2373:\terr = mana_probe(\u0026gc-\u003emana, false);\ndrivers/net/ethernet/microsoft/mana/gdma_main.c-2374-\tif (err)\n--\ndrivers/net/ethernet/microsoft/mana/gdma_main.c-2411-\t * Hardware could be in recovery mode and the HWC returns TIMEDOUT or\ndrivers/net/ethernet/microsoft/mana/gdma_main.c:2412:\t * EPROTO from mana_gd_setup(), mana_probe() or mana_rdma_probe(), or\ndrivers/net/ethernet/microsoft/mana/gdma_main.c-2413-\t * we received a hardware reset event over HWC interrupt. In this case,\n--\ndrivers/net/ethernet/microsoft/mana/gdma_main.c=2475=int mana_gd_resume(struct pci_dev *pdev)\n--\ndrivers/net/ethernet/microsoft/mana/gdma_main.c-2483-\ndrivers/net/ethernet/microsoft/mana/gdma_main.c:2484:\terr = mana_probe(\u0026gc-\u003emana, true);\ndrivers/net/ethernet/microsoft/mana/gdma_main.c-2485-\tif (err)\n--\ndrivers/net/ethernet/microsoft/mana/mana_en.c=3536=int mana_detach(struct net_device *ndev, bool from_close)\n--\ndrivers/net/ethernet/microsoft/mana/mana_en.c-3572-\ndrivers/net/ethernet/microsoft/mana/mana_en.c:3573:static int mana_probe_port(struct mana_context *ac, int port_idx,\ndrivers/net/ethernet/microsoft/mana/mana_en.c-3574-\t\t\t   struct net_device **ndev_storage)\n--\ndrivers/net/ethernet/microsoft/mana/mana_en.c=3803=static void mana_gf_stats_work_handler(struct work_struct *work)\n--\ndrivers/net/ethernet/microsoft/mana/mana_en.c-3825-\ndrivers/net/ethernet/microsoft/mana/mana_en.c:3826:int mana_probe(struct gdma_dev *gd, bool resuming)\ndrivers/net/ethernet/microsoft/mana/mana_en.c-3827-{\n--\ndrivers/net/ethernet/microsoft/mana/mana_en.c-3900-\t\tfor (i = 0; i \u003c ac-\u003enum_ports; i++) {\ndrivers/net/ethernet/microsoft/mana/mana_en.c:3901:\t\t\terr = mana_probe_port(ac, i, \u0026ac-\u003eports[i]);\ndrivers/net/ethernet/microsoft/mana/mana_en.c-3902-\t\t\t/* Log the port for which the probe failed, stop probing\n--\ninclude/net/mana/mana.h=607=int mana_detach(struct net_device *ndev, bool from_close);\ninclude/net/mana/mana.h-608-\ninclude/net/mana/mana.h:609:int mana_probe(struct gdma_dev *gd, bool resuming);\ninclude/net/mana/mana.h-610-void mana_remove(struct gdma_dev *gd, bool suspending);\n"
}

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

Args:
null

Results:
null

Tokens:
							input: 17231
							output: 84
							thoughts: 183
						

Thoughts:
**MANA Driver Evaluation**

Okay, let's break this down. The target is the driver for the Microsoft Azure Network Adapter, MANA. My initial thought is to assess its fuzzability. I know this is a PCI device driver, which is a good starting point for potential vulnerabilities.

The prompt specifically highlights vendor-specific PCIe switch, SmartNIC, or GPU drivers and indicates they require physical PCIe hardware cards that aren't emulated in standard QEMU. That's the crux of it. Considering that MANA is *definitely* a vendor-specific SmartNIC/virtual function, and it's also clear that this adapter *requires* specific hardware or the Azure Hyper-V environment to function, I can definitively say that standard QEMU or even GCE environments won't suffice.

Therefore, my assessment is that this specific driver is *not* worth fuzzing within the constraints of what's described. I'll return `WorthFuzzing=false`, and the reasoning is that it's a vendor-specific PCIe driver specifically for the Microsoft Azure Network Adapter, and therefore requires hardware not emulated in standard QEMU.



6/2 2026/08/04 00:04 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the Microsoft Azure Network Adapter (MANA) driver, which is a vendor-specific PCIe SmartNIC/virtual function driver. This hardware is not emulated in standard QEMU or GCE environments, making the code unreachable during standard fuzzing.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the Microsoft Azure Network Adapter (MANA) driver, which is a vendor-specific PCIe SmartNIC/virtual function driver. This hardware is not emulated in standard QEMU or GCE environments, making the code unreachable during standard fuzzing.",
  "WorthFuzzing": false
}

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)