AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/10/30 15:01 flow patch-triage
8m Args:
null

Results:
{
  "EnableConfigs": [
    "IO_URING",
    "SMB_SERVER",
    "SMB_SERVER_SMBDIRECT",
    "SMBDIRECT",
    "INFINIBAND",
    "INFINIBAND_ADDR_TRANS",
    "HID_SENSOR_ALS",
    "HID_SENSOR_HUB"
  ],
  "FocusSymbols": [
    "create_io_thread",
    "begin_new_exec",
    "queue_ksmbd_work",
    "ksmbd_server_process_request",
    "smbdirect_socket_accept",
    "smbdirect_accept_connect_request",
    "smbdirect_listen_orphan_socket",
    "smbdirect_listen_purge_orphaned_work",
    "smbdirect_socket_destroy",
    "als_read_raw",
    "als_parse_report"
  ],
  "KMSANReasoning": "The patch series consists of changes across several subsystems:\n1. drivers/iio/light/hid-sensor-als.c: Converts scalar scale properties into per-channel arrays and adds bounds checking on chan-\u003escan_index. The device state struct als_state is zero-allocated via devm_iio_device_alloc() (kzalloc), and present channels are explicitly initialized with hid_sensor_format_scale().\n2. drivers/platform/cznic/turris-omnia-mcu-base.c: Adds MODULE_DEVICE_TABLE(of, ...).\n3. fs/exec.c: Moves io_uring_task_cancel() before de_thread() in begin_new_exec() to avoid race conditions with io-wq workers.\n4. fs/smb/server/server.c: Adds wait_event() in queue_ksmbd_work() during negotiation to serialize connection ops modification.\n5. fs/smb/smbdirect/*: Fixes RDMA connection accept error handling, connection teardown races, and orphan socket cleanup using kfree_rcu(). All involved structures are zero-initialized via kzalloc_obj(), and no uninitialized memory is read or copied to userspace.\n6. kernel/fork.c: Rejects create_io_thread() if current task has PF_SIGNALED or PF_POSTCOREDUMP.\n7. scripts/link-vmlinux.sh: Adjusts kallsyms object comparison logic during kernel link.\n\nNone of these modifications create paths where uninitialized memory could be evaluated in conditional logic or leaked to userspace. Potential concurrency, lifetime, or memory safety issues are covered by KASAN and LOCKDEP. Thus, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false,
  "Reasoning": "The patch series touches several reachable subsystems in the kernel:\n1. Core process lifecycle and io_uring interaction (fs/exec.c and kernel/fork.c): moves io_uring_task_cancel() before de_thread() in begin_new_exec() and adds checks against PF_SIGNALED / PF_POSTCOREDUMP in create_io_thread() to prevent worker thread creation races during thread group termination.\n2. SMB server (ksmbd in fs/smb/server/server.c): introduces wait_event() synchronization during SMB negotiation requests in queue_ksmbd_work() before handling subsequent PDUs.\n3. SMBDirect RDMA transport (fs/smb/smbdirect/): refactors connection accept logic, fixes race conditions during socket error/teardown, adds orphan socket tracking with RCU protection for listeners, and adjusts socket destruction flows.\n4. IIO light sensor (drivers/iio/light/hid-sensor-als.c): adjusts channel scale storage into per-channel arrays and adds channel scan index validation in als_read_raw().\n\nThese modifications alter concurrency, state machines, and data structures in reachable code paths, making them prime targets for fuzzing.",
  "WorthFuzzing": true
}

1/1 2026/10/30 15:01 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 55ad28754d38c302656f2ed3b6efd93f91f3868d\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Fri Oct 30 15:01:28 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c\nindex 6bf1bc9a38fe6e..8f2affb226a35a 100644\n--- a/drivers/iio/light/hid-sensor-als.c\n+++ b/drivers/iio/light/hid-sensor-als.c\n@@ -33,9 +33,9 @@ struct als_state {\n \t\tu32 illum[CHANNEL_SCAN_INDEX_MAX];\n \t\taligned_s64 timestamp;\n \t} scan;\n-\tint scale_pre_decml;\n-\tint scale_post_decml;\n-\tint scale_precision;\n+\tint scale_pre_decml[CHANNEL_SCAN_INDEX_MAX];\n+\tint scale_post_decml[CHANNEL_SCAN_INDEX_MAX];\n+\tint scale_precision[CHANNEL_SCAN_INDEX_MAX];\n \tint value_offset;\n \tint num_channels;\n \ts64 timestamp;\n@@ -175,9 +175,11 @@ static int als_read_raw(struct iio_dev *indio_dev,\n \t\tret_type = IIO_VAL_INT;\n \t\tbreak;\n \tcase IIO_CHAN_INFO_SCALE:\n-\t\t*val = als_state-\u003escale_pre_decml;\n-\t\t*val2 = als_state-\u003escale_post_decml;\n-\t\tret_type = als_state-\u003escale_precision;\n+\t\tif (chan-\u003escan_index \u003e= CHANNEL_SCAN_INDEX_MAX)\n+\t\t\treturn -EINVAL;\n+\t\t*val = als_state-\u003escale_pre_decml[chan-\u003escan_index];\n+\t\t*val2 = als_state-\u003escale_post_decml[chan-\u003escan_index];\n+\t\tret_type = als_state-\u003escale_precision[chan-\u003escan_index];\n \t\tbreak;\n \tcase IIO_CHAN_INFO_OFFSET:\n \t\t*val = als_state-\u003evalue_offset;\n@@ -331,6 +333,10 @@ static int als_parse_report(struct platform_device *pdev,\n \t\t};\n \t\t++index;\n \n+\t\tst-\u003escale_precision[i] = hid_sensor_format_scale(usage_id,\n+\t\t\t\t\t\u0026st-\u003eals[i], \u0026st-\u003escale_pre_decml[i],\n+\t\t\t\t\t\u0026st-\u003escale_post_decml[i]);\n+\n \t\tdev_dbg(\u0026pdev-\u003edev, \"als %x:%x\\n\", st-\u003eals[i].index,\n \t\t\tst-\u003eals[i].report_id);\n \t}\n@@ -340,10 +346,6 @@ static int als_parse_report(struct platform_device *pdev,\n \tif (index)\n \t\tret = 0;\n \n-\tst-\u003escale_precision = hid_sensor_format_scale(usage_id,\n-\t\t\t\t\u0026st-\u003eals[CHANNEL_SCAN_INDEX_INTENSITY],\n-\t\t\t\t\u0026st-\u003escale_pre_decml, \u0026st-\u003escale_post_decml);\n-\n \treturn ret;\n }\n \ndiff --git a/drivers/platform/cznic/turris-omnia-mcu-base.c b/drivers/platform/cznic/turris-omnia-mcu-base.c\nindex e8fc0d7b334342..f0416302a1f3c1 100644\n--- a/drivers/platform/cznic/turris-omnia-mcu-base.c\n+++ b/drivers/platform/cznic/turris-omnia-mcu-base.c\n@@ -403,6 +403,7 @@ static const struct of_device_id of_omnia_mcu_match[] = {\n \t{ .compatible = \"cznic,turris-omnia-mcu\" },\n \t{}\n };\n+MODULE_DEVICE_TABLE(of, of_omnia_mcu_match);\n \n static struct i2c_driver omnia_mcu_driver = {\n \t.probe\t\t= omnia_mcu_probe,\ndiff --git a/fs/exec.c b/fs/exec.c\nindex a598d48b5ffccb..bd3e3aac90efda 100644\n--- a/fs/exec.c\n+++ b/fs/exec.c\n@@ -1145,6 +1145,13 @@ int begin_new_exec(struct linux_binprm * bprm)\n \t */\n \tbprm-\u003epoint_of_no_return = true;\n \n+\t/*\n+\t * Cancel any io_uring activity across execve. This runs task work\n+\t * that may still create an io-wq worker, so do it while de_thread()\n+\t * can still zap it.\n+\t */\n+\tio_uring_task_cancel();\n+\n \t/* Make this the only thread in the thread group */\n \tretval = de_thread(me);\n \tif (retval)\n@@ -1161,10 +1168,6 @@ int begin_new_exec(struct linux_binprm * bprm)\n \n \t/* see the comment in check_unsafe_exec() */\n \tcurrent-\u003efs-\u003ein_exec = 0;\n-\t/*\n-\t * Cancel any io_uring activity across execve\n-\t */\n-\tio_uring_task_cancel();\n \n \t/* Ensure the files table is not shared. */\n \tretval = unshare_files();\ndiff --git a/fs/smb/server/server.c b/fs/smb/server/server.c\nindex e113b23d96f94e..e36e82b94a047c 100644\n--- a/fs/smb/server/server.c\n+++ b/fs/smb/server/server.c\n@@ -371,6 +371,7 @@ static void handle_ksmbd_work(struct work_struct *wk)\n static int queue_ksmbd_work(struct ksmbd_conn *conn)\n {\n \tstruct ksmbd_work *work;\n+\tbool wait_for_neg = ksmbd_conn_new(conn) || ksmbd_conn_need_negotiate(conn);\n \tint err;\n \n \terr = ksmbd_init_smb_server(conn);\n@@ -393,6 +394,10 @@ static int queue_ksmbd_work(struct ksmbd_conn *conn)\n \tconn-\u003elast_active = jiffies;\n \tINIT_WORK(\u0026work-\u003ework, handle_ksmbd_work);\n \tksmbd_queue_work(work);\n+\t/* Negotiation can change conn-\u003eops, finish it before reading another PDU. */\n+\tif (wait_for_neg)\n+\t\twait_event(conn-\u003ereq_running_q,\n+\t\t\t   atomic_read(\u0026conn-\u003ereq_running) == 0);\n \treturn 0;\n }\n \ndiff --git a/fs/smb/smbdirect/accept.c b/fs/smb/smbdirect/accept.c\nindex 039c9bfbd8acda..d1bc08ac975756 100644\n--- a/fs/smb/smbdirect/accept.c\n+++ b/fs/smb/smbdirect/accept.c\n@@ -19,15 +19,33 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,\n \t\t\t\t     const struct rdma_conn_param *param)\n {\n \tstruct smbdirect_socket_parameters *sp = \u0026sc-\u003eparameters;\n-\tstruct smbdirect_recv_io *recv_io;\n+\tstruct smbdirect_recv_io *recv_io = NULL;\n \tu8 peer_initiator_depth;\n \tu8 peer_responder_resources;\n \tstruct rdma_conn_param conn_param;\n \t__be32 ird_ord_hdr[2];\n \tint ret;\n \n-\tif (SMBDIRECT_CHECK_STATUS_WARN(sc, SMBDIRECT_SOCKET_CREATED))\n-\t\treturn -EINVAL;\n+\t/*\n+\t * Install the real event handler (and the event we expect next)\n+\t * before anything that can fail. On an early error the caller\n+\t * (smbdirect_listen_connect_request()) only schedules our deferred\n+\t * cleanup and returns 0 to the rdma_cm core, which keeps the cm_id, so\n+\t * the cm_id must already carry smbdirect_accept_rdma_event_handler():\n+\t * it turns any unexpected event (e.g. RDMA_CM_EVENT_DEVICE_REMOVAL)\n+\t * into a clean smbdirect_socket_schedule_cleanup(). Otherwise the\n+\t * placeholder smbdirect_socket_rdma_event_handler() installed by\n+\t * smbdirect_socket_init_accepting() stays in place and returns -ESTALE,\n+\t * which makes the rdma_cm core destroy the cm_id behind the back of our\n+\t * pending teardown.\n+\t */\n+\tsc-\u003erdma.expected_event = RDMA_CM_EVENT_ESTABLISHED;\n+\tsc-\u003erdma.cm_id-\u003eevent_handler = smbdirect_accept_rdma_event_handler;\n+\n+\tif (SMBDIRECT_CHECK_STATUS_WARN(sc, SMBDIRECT_SOCKET_CREATED)) {\n+\t\tret = -EINVAL;\n+\t\tgoto cleanup;\n+\t}\n \n \t/*\n \t * First set what the we as server are able to support\n@@ -47,7 +65,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,\n \t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,\n \t\t\t\"smbdirect_accept_init_params() failed %1pe\\n\",\n \t\t\tSMBDIRECT_DEBUG_ERR_PTR(ret));\n-\t\tgoto init_params_failed;\n+\t\tgoto cleanup;\n \t}\n \n \tret = smbdirect_connection_create_qp(sc);\n@@ -55,7 +73,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,\n \t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,\n \t\t\t\"smbdirect_connection_create_qp() failed %1pe\\n\",\n \t\t\tSMBDIRECT_DEBUG_ERR_PTR(ret));\n-\t\tgoto create_qp_failed;\n+\t\tgoto cleanup;\n \t}\n \n \tret = smbdirect_connection_create_mem_pools(sc);\n@@ -63,7 +81,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,\n \t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,\n \t\t\t\"smbdirect_connection_create_mem_pools() failed %1pe\\n\",\n \t\t\tSMBDIRECT_DEBUG_ERR_PTR(ret));\n-\t\tgoto create_mem_failed;\n+\t\tgoto cleanup;\n \t}\n \n \trecv_io = smbdirect_connection_get_recv_io(sc);\n@@ -72,7 +90,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,\n \t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,\n \t\t\t\"smbdirect_connection_get_recv_io() failed %1pe\\n\",\n \t\t\tSMBDIRECT_DEBUG_ERR_PTR(ret));\n-\t\tgoto get_recv_io_failed;\n+\t\tgoto cleanup;\n \t}\n \trecv_io-\u003ecqe.done = smbdirect_accept_negotiate_recv_done;\n \n@@ -86,7 +104,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,\n \t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,\n \t\t\t\"smbdirect_connection_post_recv_io() failed %1pe\\n\",\n \t\t\tSMBDIRECT_DEBUG_ERR_PTR(ret));\n-\t\tgoto post_recv_io_failed;\n+\t\tgoto cleanup;\n \t}\n \t/*\n \t * From here recv_io is known to the RDMA QP and needs ib_drain_qp and\n@@ -122,14 +140,12 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,\n \t/* explicitly set above */\n \tWARN_ON_ONCE(sc-\u003estatus != SMBDIRECT_SOCKET_RDMA_CONNECT_NEEDED);\n \tsc-\u003estatus = SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING;\n-\tsc-\u003erdma.expected_event = RDMA_CM_EVENT_ESTABLISHED;\n-\tsc-\u003erdma.cm_id-\u003eevent_handler = smbdirect_accept_rdma_event_handler;\n \tret = rdma_accept(sc-\u003erdma.cm_id, \u0026conn_param);\n \tif (ret) {\n \t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,\n \t\t\t\"rdma_accept() failed %1pe\\n\",\n \t\t\tSMBDIRECT_DEBUG_ERR_PTR(ret));\n-\t\tgoto rdma_accept_failed;\n+\t\tgoto cleanup;\n \t}\n \n \t/*\n@@ -143,31 +159,25 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,\n \n \treturn 0;\n \n-rdma_accept_failed:\n+cleanup:\n \t/*\n-\t * The recv_io posted above is now owned by the QP (recv_io was set to\n-\t * NULL after a successful post).  smbdirect_connection_destroy_qp()\n-\t * calls ib_drain_qp(), whose completion\n-\t * (smbdirect_accept_negotiate_recv_done) returns the recv_io to the\n-\t * free list via smbdirect_connection_put_recv_io().  It therefore MUST\n-\t * run BEFORE smbdirect_connection_destroy_mem_pools(): otherwise the\n-\t * posted recv_io is still outstanding when kmem_cache_destroy() runs\n-\t * (\"Slab cache still has objects\") and is later freed into an\n-\t * already-destroyed mempool (mempool_free_bulk NULL-ptr-deref).\n+\t * No RDMA state is torn down here, and in particular sc is not\n+\t * released: the caller (smbdirect_listen_connect_request()) owns that\n+\t * decision and schedules sc's teardown via\n+\t * smbdirect_socket_schedule_cleanup() on a non-zero return. All of the\n+\t * RDMA state - the QP, the memory pools and the cm_id itself - is then\n+\t * torn down asynchronously by smbdirect_socket_cleanup_work() -\u003e\n+\t * smbdirect_socket_release() -\u003e smbdirect_socket_destroy(), which\n+\t * drains the QP (returning any posted recv_io to the pool) before\n+\t * destroying the memory pools and destroys the cm_id with\n+\t * rdma_destroy_id(), all in the correct order.\n+\t *\n+\t * The only resource not reachable by that teardown is a recv_io that\n+\t * was taken from the pool but not yet posted to the QP (recv_io is set\n+\t * to NULL after a successful post), so hand it back here.\n \t */\n-\tsmbdirect_connection_destroy_qp(sc);\n-\tsmbdirect_connection_destroy_mem_pools(sc);\n-\treturn ret;\n-post_recv_io_failed:\n-\t/* post failed: recv_io was not accepted by the QP, still in hand */\n \tif (recv_io)\n \t\tsmbdirect_connection_put_recv_io(recv_io);\n-get_recv_io_failed:\n-\tsmbdirect_connection_destroy_mem_pools(sc);\n-create_mem_failed:\n-\tsmbdirect_connection_destroy_qp(sc);\n-create_qp_failed:\n-init_params_failed:\n \treturn ret;\n }\n \n@@ -301,6 +311,7 @@ static void smbdirect_accept_negotiate_recv_work(struct work_struct *work)\n \tstruct smbdirect_socket *sc =\n \t\tcontainer_of(work, struct smbdirect_socket, connect.work);\n \tstruct smbdirect_socket_parameters *sp = \u0026sc-\u003eparameters;\n+\tstruct smbdirect_socket *lsc;\n \tstruct smbdirect_recv_io *recv_io;\n \tstruct smbdirect_negotiate_req *nreq;\n \tunsigned long flags;\n@@ -463,29 +474,55 @@ static void smbdirect_accept_negotiate_recv_work(struct work_struct *work)\n \t */\n \tsp-\u003emax_fragmented_send_size = max_fragmented_size;\n \n-\tif (sc-\u003eaccept.listener) {\n-\t\tstruct smbdirect_socket *lsc = sc-\u003eaccept.listener;\n-\t\tunsigned long flags;\n+\t/*\n+\t * Every accepting socket was created by\n+\t * smbdirect_listen_connect_request() and has a\n+\t * listener. If it's already cleared, the listener\n+\t * (or its purge_orphaned_work) is responsible for\n+\t * releasing us, so we must not send a negotiate\n+\t * response.\n+\t *\n+\t * The memory of the listener is freed via kfree_rcu(),\n+\t * see smbdirect_listen_orphan_socket().\n+\t */\n+\trcu_read_lock();\n+\tlsc = READ_ONCE(sc-\u003eaccept.listener);\n+\tif (!lsc) {\n+\t\trcu_read_unlock();\n+\t\treturn;\n+\t}\n \n-\t\tspin_lock_irqsave(\u0026lsc-\u003elisten.lock, flags);\n-\t\tlist_del(\u0026sc-\u003eaccept.list);\n-\t\tlist_add_tail(\u0026sc-\u003eaccept.list, \u0026lsc-\u003elisten.ready);\n+\tspin_lock_irqsave(\u0026lsc-\u003elisten.lock, flags);\n+\t/*\n+\t * The listener (or its purge_orphaned_work)\n+\t * may have cleared sc-\u003eaccept.listener in the\n+\t * meantime and is responsible for releasing us.\n+\t *\n+\t * If we already failed, we're either\n+\t * already on the orphaned list or\n+\t * smbdirect_socket_cleanup_work() will\n+\t * move us there.\n+\t *\n+\t * In both cases we must not move us\n+\t * to the ready list.\n+\t */\n+\tif (sc-\u003eaccept.listener == lsc \u0026\u0026 !READ_ONCE(sc-\u003efirst_error)) {\n+\t\tlist_move_tail(\u0026sc-\u003eaccept.list, \u0026lsc-\u003elisten.ready);\n \t\twake_up(\u0026lsc-\u003elisten.wait_queue);\n-\t\tspin_unlock_irqrestore(\u0026lsc-\u003elisten.lock, flags);\n-\n-\t\t/*\n-\t\t * smbdirect_socket_accept() will call\n-\t\t * smbdirect_accept_negotiate_finish(nsc, 0);\n-\t\t *\n-\t\t * So that we don't send the negotiation\n-\t\t * response that grants credits to the peer\n-\t\t * before the socket is accepted by the\n-\t\t * application.\n-\t\t */\n-\t\treturn;\n \t}\n+\tspin_unlock_irqrestore(\u0026lsc-\u003elisten.lock, flags);\n+\trcu_read_unlock();\n \n-\tntstatus = le32_to_cpu(STATUS_SUCCESS);\n+\t/*\n+\t * smbdirect_socket_accept() will call\n+\t * smbdirect_accept_negotiate_finish(nsc, 0);\n+\t *\n+\t * So that we don't send the negotiation\n+\t * response that grants credits to the peer\n+\t * before the socket is accepted by the\n+\t * application.\n+\t */\n+\treturn;\n \n not_supported:\n \tsmbdirect_accept_negotiate_finish(sc, ntstatus);\n@@ -798,7 +835,11 @@ static long smbdirect_socket_wait_for_accept(struct smbdirect_socket *lsc, long\n \tif (ret \u003c 0)\n \t\treturn ret;\n \n-\treturn 0;\n+\t/*\n+\t * Return the remaining timeout, so the caller can carry it\n+\t * over to the next smbdirect_socket_wait_for_accept() call.\n+\t */\n+\treturn ret;\n }\n \n struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,\n@@ -808,6 +849,7 @@ struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,\n \tstruct smbdirect_socket *nsc;\n \tunsigned long flags;\n \n+again:\n \tif (lsc-\u003estatus != SMBDIRECT_SOCKET_LISTENING) {\n \t\targ-\u003eerr = -EINVAL;\n \t\treturn NULL;\n@@ -819,7 +861,7 @@ struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,\n \t}\n \n \tif (list_empty_careful(\u0026lsc-\u003elisten.ready)) {\n-\t\tint ret;\n+\t\tlong ret;\n \n \t\tif (timeo == 0) {\n \t\t\targ-\u003eerr = -EAGAIN;\n@@ -827,25 +869,78 @@ struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,\n \t\t}\n \n \t\tret = smbdirect_socket_wait_for_accept(lsc, timeo);\n-\t\tif (ret) {\n+\t\tif (ret \u003c 0) {\n \t\t\targ-\u003eerr = ret;\n \t\t\treturn NULL;\n \t\t}\n+\t\t/*\n+\t\t * Carry the remaining timeout over, so that a stream of\n+\t\t * failed connections that we orphan and skip (goto again)\n+\t\t * can't reset the caller's timeout and wait forever.\n+\t\t */\n+\t\ttimeo = ret;\n \t}\n \n \tspin_lock_irqsave(\u0026lsc-\u003elisten.lock, flags);\n-\tnsc = list_first_entry_or_null(\u0026lsc-\u003elisten.ready,\n-\t\t\t\t       struct smbdirect_socket,\n-\t\t\t\t       accept.list);\n+\t/*\n+\t * Recheck under the lock.\n+\t */\n+\tif (lsc-\u003estatus != SMBDIRECT_SOCKET_LISTENING) {\n+\t\targ-\u003eerr = -EINVAL;\n+\t\tspin_unlock_irqrestore(\u0026lsc-\u003elisten.lock, flags);\n+\t\treturn NULL;\n+\t}\n+\tif (lsc-\u003efirst_error) {\n+\t\targ-\u003eerr = lsc-\u003efirst_error;\n+\t\tspin_unlock_irqrestore(\u0026lsc-\u003elisten.lock, flags);\n+\t\treturn NULL;\n+\t}\n+\n+\twhile ((nsc = list_first_entry_or_null(\u0026lsc-\u003elisten.ready,\n+\t\t\t\t\t       struct smbdirect_socket,\n+\t\t\t\t\t       accept.list))) {\n+\t\t/*\n+\t\t * nsc may have failed after it was moved\n+\t\t * to the ready list, e.g. RDMA_CM_EVENT_DISCONNECTED\n+\t\t * already moved it to SMBDIRECT_SOCKET_DISCONNECTED.\n+\t\t * We must not overwrite that with\n+\t\t * SMBDIRECT_SOCKET_CONNECTED and hand\n+\t\t * out an already disconnected socket.\n+\t\t *\n+\t\t * Doing this under listen.lock means nsc\n+\t\t * still belongs to us, so we can just move\n+\t\t * a failed socket to the orphaned list,\n+\t\t * like smbdirect_listen_orphan_socket() does,\n+\t\t * and try the next one.\n+\t\t */\n+\t\tif (!READ_ONCE(nsc-\u003efirst_error) \u0026\u0026\n+\t\t    cmpxchg(\u0026nsc-\u003estatus,\n+\t\t\t    SMBDIRECT_SOCKET_NEGOTIATE_RUNNING,\n+\t\t\t    SMBDIRECT_SOCKET_CONNECTED) ==\n+\t\t    SMBDIRECT_SOCKET_NEGOTIATE_RUNNING)\n+\t\t\tbreak;\n+\n+\t\tsmbdirect_log_rdma_event(nsc, SMBDIRECT_LOG_INFO,\n+\t\t\t\"orphaning failed socket status=%s first_error=%1pe\\n\",\n+\t\t\tsmbdirect_socket_status_string(nsc-\u003estatus),\n+\t\t\tSMBDIRECT_DEBUG_ERR_PTR(nsc-\u003efirst_error));\n+\t\tlist_move_tail(\u0026nsc-\u003eaccept.list, \u0026lsc-\u003elisten.orphaned);\n+\t\tqueue_work(lsc-\u003eworkqueues.cleanup, \u0026lsc-\u003elisten.purge_orphaned_work);\n+\t}\n \tif (nsc) {\n-\t\tnsc-\u003eaccept.listener = NULL;\n+\t\tWRITE_ONCE(nsc-\u003eaccept.listener, NULL);\n \t\tlist_del_init_careful(\u0026nsc-\u003eaccept.list);\n \t\targ-\u003eis_empty = list_empty_careful(\u0026lsc-\u003elisten.ready);\n \t}\n \tspin_unlock_irqrestore(\u0026lsc-\u003elisten.lock, flags);\n \tif (!nsc) {\n-\t\targ-\u003eerr = -EAGAIN;\n-\t\treturn NULL;\n+\t\t/*\n+\t\t * If we only found failed sockets or no socket,\n+\t\t * we wait for the next one.\n+\t\t *\n+\t\t * A possible -EAGAIN/-ETIMEOUT is handled above.\n+\t\t */\n+\t\tgoto again;\n \t}\n \n \t/*\n@@ -854,12 +949,14 @@ struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,\n \t * so it didn't grant any credits to us.\n \t *\n \t * The caller expects a connected socket\n-\t * now as there are no credits anyway.\n+\t * now as there are no credits anyway,\n+\t * above we already changed to SMBDIRECT_SOCKET_CONNECTED\n+\t * under the lsc-\u003elisten.lock and with cmpxchg.\n \t *\n-\t * Then we send the negotiation response in\n-\t * order to grant credits to the peer.\n+\t * Now we send the negotiation response in\n+\t * order to grant credits to the peer,\n+\t * as the socket is now visible to the application layer.\n \t */\n-\tnsc-\u003estatus = SMBDIRECT_SOCKET_CONNECTED;\n \tsmbdirect_accept_negotiate_finish(nsc, 0);\n \n \treturn nsc;\ndiff --git a/fs/smb/smbdirect/connection.c b/fs/smb/smbdirect/connection.c\nindex fe99537207176e..32327f96a03ab1 100644\n--- a/fs/smb/smbdirect/connection.c\n+++ b/fs/smb/smbdirect/connection.c\n@@ -83,9 +83,9 @@ static int smbdirect_connection_rdma_event_handler(struct rdma_cm_id *id,\n \t\t * smbdirect_socket_schedule_cleanup[_status]() =\u003e\n \t\t * smbdirect_socket_cleanup_work().\n \t\t *\n-\t\t * As otherwise we'd set SMBDIRECT_SOCKET_DISCONNECTING,\n-\t\t * but never ever get RDMA_CM_EVENT_DISCONNECTED and\n-\t\t * never reach SMBDIRECT_SOCKET_DISCONNECTED.\n+\t\t * As otherwise we'd set SMBDIRECT_SOCKET_DISCONNECTING\n+\t\t * and call rdma_disconnect(), but never ever get\n+\t\t * RDMA_CM_EVENT_DISCONNECTED.\n \t\t */\n \t\tif (event-\u003eevent == RDMA_CM_EVENT_DEVICE_REMOVAL)\n \t\t\tsmbdirect_socket_schedule_cleanup_status(sc,\n@@ -113,9 +113,9 @@ static int smbdirect_connection_rdma_event_handler(struct rdma_cm_id *id,\n \t\t * smbdirect_socket_schedule_cleanup_status() =\u003e\n \t\t * smbdirect_socket_cleanup_work().\n \t\t *\n-\t\t * As otherwise we'd set SMBDIRECT_SOCKET_DISCONNECTING,\n-\t\t * but never ever get RDMA_CM_EVENT_DISCONNECTED and\n-\t\t * never reach SMBDIRECT_SOCKET_DISCONNECTED.\n+\t\t * As otherwise we'd set SMBDIRECT_SOCKET_DISCONNECTING\n+\t\t * and call rdma_disconnect(), but never ever get\n+\t\t * RDMA_CM_EVENT_DISCONNECTED.\n \t\t *\n \t\t * This is also a normal disconnect so\n \t\t * SMBDIRECT_LOG_INFO should be good enough\ndiff --git a/fs/smb/smbdirect/internal.h b/fs/smb/smbdirect/internal.h\nindex e9959e6dc13ae8..69d0c9f899deca 100644\n--- a/fs/smb/smbdirect/internal.h\n+++ b/fs/smb/smbdirect/internal.h\n@@ -74,6 +74,8 @@ void __smbdirect_socket_schedule_cleanup(struct smbdirect_socket *sc,\n \n void smbdirect_socket_destroy_sync(struct smbdirect_socket *sc);\n \n+void smbdirect_listen_orphan_socket(struct smbdirect_socket *sc);\n+\n int smbdirect_socket_wait_for_credits(struct smbdirect_socket *sc,\n \t\t\t\t      enum smbdirect_socket_status expected_status,\n \t\t\t\t      int unexpected_errno,\ndiff --git a/fs/smb/smbdirect/listen.c b/fs/smb/smbdirect/listen.c\nindex 2f78bcaedbf82e..3c91f00d95ce4a 100644\n--- a/fs/smb/smbdirect/listen.c\n+++ b/fs/smb/smbdirect/listen.c\n@@ -10,6 +10,78 @@\n static int smbdirect_listen_rdma_event_handler(struct rdma_cm_id *id,\n \t\t\t\t\t       struct rdma_cm_event *event);\n \n+/*\n+ * This is called by a socket that failed while it\n+ * is still on the pending or ready list of its\n+ * listener, typically at the end of\n+ * smbdirect_socket_cleanup_work(), when the\n+ * disconnect was already started.\n+ *\n+ * It moves itself to the orphaned list and\n+ * lets smbdirect_listen_purge_orphaned_work()\n+ * release it. Otherwise it would stay on the\n+ * pending or ready list until the listener is\n+ * destroyed and fill up the backlog, so that\n+ * no new connections would be accepted.\n+ *\n+ * It's fine to call this more than once.\n+ */\n+void smbdirect_listen_orphan_socket(struct smbdirect_socket *sc)\n+{\n+\tstruct smbdirect_socket *lsc;\n+\tunsigned long flags;\n+\n+\t/*\n+\t * The memory of the listener is freed via\n+\t * kfree_rcu(), so it's safe to dereference it\n+\t * under rcu_read_lock(), even if sc-\u003eaccept.listener\n+\t * is cleared and the listener is released concurrently.\n+\t */\n+\trcu_read_lock();\n+\tlsc = READ_ONCE(sc-\u003eaccept.listener);\n+\tif (!lsc) {\n+\t\trcu_read_unlock();\n+\t\treturn;\n+\t}\n+\n+\tspin_lock_irqsave(\u0026lsc-\u003elisten.lock, flags);\n+\tif (sc-\u003eaccept.listener == lsc) {\n+\t\tlist_move_tail(\u0026sc-\u003eaccept.list, \u0026lsc-\u003elisten.orphaned);\n+\t\tqueue_work(lsc-\u003eworkqueues.cleanup, \u0026lsc-\u003elisten.purge_orphaned_work);\n+\t}\n+\tspin_unlock_irqrestore(\u0026lsc-\u003elisten.lock, flags);\n+\trcu_read_unlock();\n+}\n+\n+static void smbdirect_listen_purge_orphaned_work(struct work_struct *work)\n+{\n+\tstruct smbdirect_socket *lsc =\n+\t\tcontainer_of(work, struct smbdirect_socket, listen.purge_orphaned_work);\n+\tstruct smbdirect_socket *psc, *tsc;\n+\tLIST_HEAD(orphaned_list);\n+\tunsigned long flags;\n+\n+\t/*\n+\t * Clearing accept.listener under listen.lock\n+\t * makes us responsible for releasing them.\n+\t */\n+\tspin_lock_irqsave(\u0026lsc-\u003elisten.lock, flags);\n+\tlist_splice_tail_init(\u0026lsc-\u003elisten.orphaned, \u0026orphaned_list);\n+\tlist_for_each_entry(psc, \u0026orphaned_list, accept.list)\n+\t\tWRITE_ONCE(psc-\u003eaccept.listener, NULL);\n+\tspin_unlock_irqrestore(\u0026lsc-\u003elisten.lock, flags);\n+\n+\t/*\n+\t * We don't hold the listener's rdma_lock_handler()\n+\t * lock here, see smbdirect_socket_destroy()\n+\t * for why that's important.\n+\t */\n+\tlist_for_each_entry_safe(psc, tsc, \u0026orphaned_list, accept.list) {\n+\t\tlist_del_init(\u0026psc-\u003eaccept.list);\n+\t\tsmbdirect_socket_release(psc);\n+\t}\n+}\n+\n int smbdirect_socket_listen(struct smbdirect_socket *sc, int backlog)\n {\n \tint ret;\n@@ -47,6 +119,9 @@ int smbdirect_socket_listen(struct smbdirect_socket *sc, int backlog)\n \tsc-\u003erdma.cm_id-\u003eevent_handler = smbdirect_listen_rdma_event_handler;\n \trdma_unlock_handler(sc-\u003erdma.cm_id);\n \n+\tINIT_WORK(\u0026sc-\u003elisten.purge_orphaned_work,\n+\t\t  smbdirect_listen_purge_orphaned_work);\n+\n \tret = rdma_listen(sc-\u003erdma.cm_id, backlog);\n \tif (ret) {\n \t\tsc-\u003efirst_error = ret;\n@@ -214,6 +289,7 @@ static int smbdirect_listen_connect_request(struct smbdirect_socket *lsc,\n \tsize_t backlog = max_t(size_t, 1, lsc-\u003elisten.backlog);\n \tsize_t psockets;\n \tsize_t rsockets;\n+\tsize_t osockets;\n \tint ret;\n \n \tif (!smbdirect_frwr_is_supported(\u0026new_id-\u003edevice-\u003eattrs)) {\n@@ -254,14 +330,21 @@ static int smbdirect_listen_connect_request(struct smbdirect_socket *lsc,\n \tspin_lock_irqsave(\u0026lsc-\u003elisten.lock, flags);\n \tpsockets = list_count_nodes(\u0026lsc-\u003elisten.pending);\n \trsockets = list_count_nodes(\u0026lsc-\u003elisten.ready);\n+\t/*\n+\t * Orphaned sockets still count against\n+\t * the backlog until they are released by\n+\t * smbdirect_listen_purge_orphaned_work().\n+\t */\n+\tosockets = list_count_nodes(\u0026lsc-\u003elisten.orphaned);\n \tspin_unlock_irqrestore(\u0026lsc-\u003elisten.lock, flags);\n \n \tif (psockets \u003e backlog ||\n \t    rsockets \u003e backlog ||\n-\t    (psockets + rsockets) \u003e backlog) {\n+\t    osockets \u003e backlog ||\n+\t    (psockets + rsockets + osockets) \u003e backlog) {\n \t\tsmbdirect_log_rdma_event(lsc, SMBDIRECT_LOG_ERR,\n-\t\t\t\"Backlog[%d][%zu] full pending[%zu] ready[%zu]\\n\",\n-\t\t\tlsc-\u003elisten.backlog, backlog, psockets, rsockets);\n+\t\t\t\"Backlog[%d][%zu] full pending[%zu] ready[%zu] orphaned[%zu]\\n\",\n+\t\t\tlsc-\u003elisten.backlog, backlog, psockets, rsockets, osockets);\n \t\treturn -EBUSY;\n \t}\n \n@@ -279,22 +362,54 @@ static int smbdirect_listen_connect_request(struct smbdirect_socket *lsc,\n \tif (ret)\n \t\tgoto set_settings_failed;\n \n+\t/*\n+\t * Publish nsc on the pending list with accept.listener set before\n+\t * smbdirect_accept_connect_request() calls rdma_accept(). Once the\n+\t * connection can establish, smbdirect_accept_negotiate_recv_work()\n+\t * may run and it must observe accept.listener, otherwise nsc would\n+\t * be left stranded on the pending list forever.\n+\t *\n+\t * The listener's handler_mutex is held while we're called, so\n+\t * smbdirect_socket_destroy() of the listener can't reach nsc on the\n+\t * pending list before we're done.\n+\t *\n+\t * From here nsc is published on the pending list: on failure of\n+\t * smbdirect_accept_connect_request() below we schedule nsc's teardown,\n+\t * which orphans nsc off the listener so\n+\t * smbdirect_listen_purge_orphaned_work() -\u003e smbdirect_socket_release()\n+\t * releases it.\n+\t */\n \tspin_lock_irqsave(\u0026lsc-\u003elisten.lock, flags);\n \tlist_add_tail(\u0026nsc-\u003eaccept.list, \u0026lsc-\u003elisten.pending);\n-\tnsc-\u003eaccept.listener = lsc;\n+\tWRITE_ONCE(nsc-\u003eaccept.listener, lsc);\n \tspin_unlock_irqrestore(\u0026lsc-\u003elisten.lock, flags);\n \n \tret = smbdirect_accept_connect_request(nsc, \u0026event-\u003eparam.conn);\n-\tif (ret)\n-\t\tgoto accept_connect_failed;\n+\tif (ret) {\n+\t\t/*\n+\t\t * The rdma_cm core holds both the listener's and nsc's\n+\t\t * id_priv-\u003ehandler_mutex across this CONNECT_REQUEST handler,\n+\t\t * so neither can go away under us here and nsc cannot receive\n+\t\t * any rdma event: it is safe to hand nsc to its teardown.\n+\t\t *\n+\t\t * That teardown must be deferred though: nsc-\u003erdma.cm_id\n+\t\t * (= new_id) has its handler_mutex held by us, so it cannot be\n+\t\t * destroyed synchronously from here.\n+\t\t * smbdirect_socket_schedule_cleanup() only queues work;\n+\t\t * smbdirect_socket_cleanup_work() then orphans nsc off the\n+\t\t * listener and smbdirect_listen_purge_orphaned_work() releases\n+\t\t * it, destroying nsc's cm_id with rdma_destroy_id().\n+\t\t */\n+\t\tsmbdirect_socket_schedule_cleanup(nsc, ret);\n+\t}\n \n+\t/*\n+\t * Always return 0 so the rdma_cm core keeps new_id: nsc owns it now.\n+\t * On success it stays connected; on failure its deferred teardown\n+\t * above destroys it.\n+\t */\n \treturn 0;\n \n-accept_connect_failed:\n-\tspin_lock_irqsave(\u0026lsc-\u003elisten.lock, flags);\n-\tlist_del_init(\u0026nsc-\u003eaccept.list);\n-\tnsc-\u003eaccept.listener = NULL;\n-\tspin_unlock_irqrestore(\u0026lsc-\u003elisten.lock, flags);\n set_settings_failed:\n set_params_failed:\n \t/*\ndiff --git a/fs/smb/smbdirect/socket.c b/fs/smb/smbdirect/socket.c\nindex bb02df6158b97e..e270e36b3145e1 100644\n--- a/fs/smb/smbdirect/socket.c\n+++ b/fs/smb/smbdirect/socket.c\n@@ -319,6 +319,15 @@ void __smbdirect_socket_schedule_cleanup(struct smbdirect_socket *sc,\n \t * (smbdirect_socket_destroy) to reap.\n \t */\n \tif (sc-\u003elisten.backlog != -1) { /* was a listener */\n+\t\t/*\n+\t\t * We don't move them to the orphaned list here,\n+\t\t * each child does that itself at the end of its\n+\t\t * smbdirect_socket_cleanup_work(), see\n+\t\t * smbdirect_listen_orphan_socket(). Only that checks\n+\t\t * accept.listener, which is still NULL for a child\n+\t\t * that smbdirect_listen_connect_request() is still\n+\t\t * setting up and will release itself on failure.\n+\t\t */\n \t\tspin_lock_irqsave(\u0026sc-\u003elisten.lock, flags);\n \t\tlist_splice_init(\u0026sc-\u003elisten.ready, \u0026sc-\u003elisten.pending);\n \t\tlist_for_each_entry_safe(psc, tsc, \u0026sc-\u003elisten.pending, accept.list)\n@@ -427,6 +436,15 @@ static void smbdirect_socket_cleanup_work(struct work_struct *work)\n \t * instances of one class -- harmless, but lockdep cannot tell).\n \t */\n \tif (sc-\u003elisten.backlog != -1) { /* was a listener */\n+\t\t/*\n+\t\t * We don't move them to the orphaned list here,\n+\t\t * each child does that itself at the end of its\n+\t\t * smbdirect_socket_cleanup_work(), see\n+\t\t * smbdirect_listen_orphan_socket(). Only that checks\n+\t\t * accept.listener, which is still NULL for a child\n+\t\t * that smbdirect_listen_connect_request() is still\n+\t\t * setting up and will release itself on failure.\n+\t\t */\n \t\tspin_lock_irqsave(\u0026sc-\u003elisten.lock, flags);\n \t\tlist_splice_init(\u0026sc-\u003elisten.ready, \u0026sc-\u003elisten.pending);\n \t\tlist_for_each_entry_safe(psc, tsc, \u0026sc-\u003elisten.pending, accept.list)\n@@ -486,6 +504,18 @@ static void smbdirect_socket_cleanup_work(struct work_struct *work)\n \t * in order to notice the broken connection.\n \t */\n \tsmbdirect_socket_wake_up_all(sc);\n+\n+\t/*\n+\t * If we're still on the pending or ready list\n+\t * of a listener, we started the disconnect\n+\t * as far as possible above, so we move ourself\n+\t * to the orphaned list of the listener,\n+\t * which will release us.\n+\t *\n+\t * This is a no-op internally if\n+\t * sc-\u003eaccept.listener is NULL.\n+\t */\n+\tsmbdirect_listen_orphan_socket(sc);\n }\n \n static void smbdirect_socket_destroy(struct smbdirect_socket *sc)\n@@ -511,7 +541,13 @@ static void smbdirect_socket_destroy(struct smbdirect_socket *sc)\n \tif (sc-\u003estatus == SMBDIRECT_SOCKET_DESTROYED)\n \t\treturn;\n \n-\tWARN_ONCE(sc-\u003estatus != SMBDIRECT_SOCKET_DISCONNECTED,\n+\t/*\n+\t * smbdirect_socket_destroy_sync() doesn't wait\n+\t * for RDMA_CM_EVENT_DISCONNECTED, so we may still\n+\t * be in SMBDIRECT_SOCKET_DISCONNECTING\n+\t * (or already reached SMBDIRECT_SOCKET_DISCONNECTED)\n+\t */\n+\tWARN_ONCE(sc-\u003estatus \u003c SMBDIRECT_SOCKET_DISCONNECTING,\n \t\t  \"status=%s first_error=%1pe\",\n \t\t  smbdirect_socket_status_string(sc-\u003estatus),\n \t\t  SMBDIRECT_DEBUG_ERR_PTR(sc-\u003efirst_error));\n@@ -538,10 +574,37 @@ static void smbdirect_socket_destroy(struct smbdirect_socket *sc)\n \tdisable_work_sync(\u0026sc-\u003erecv_io.posted.refill_work);\n \tdisable_work_sync(\u0026sc-\u003eidle.immediate_work);\n \tdisable_delayed_work_sync(\u0026sc-\u003eidle.timer_work);\n+\tdisable_work_sync(\u0026sc-\u003elisten.purge_orphaned_work);\n \n \tif (sc-\u003erdma.cm_id)\n \t\trdma_lock_handler(sc-\u003erdma.cm_id);\n \n+\t/*\n+\t * We hold the handler lock, so the rdma event\n+\t * handlers can't change the status anymore.\n+\t *\n+\t * If RDMA_CM_EVENT_DISCONNECTED didn't arrive yet,\n+\t * we just stop waiting for it here.\n+\t *\n+\t * We already disabled disconnect_work above\n+\t * and before we call rdma_unlock_handler below\n+\t * we call smbdirect_connection_destroy_qp which\n+\t * sets sc-\u003eib.qp = NULL.\n+\t *\n+\t * Between rdma_unlock_handler() and\n+\t * rdma_destroy_id() below there's a small\n+\t * windows where RDMA_CM_EVENT_DISCONNECTED\n+\t * could still arrive.\n+\t *\n+\t * But smbdirect_connection_rdma_event_handler\n+\t * will be a noop when calling smbdirect_socket_schedule_cleanup*\n+\t * ib_drain_qp() also won't be called.\n+\t */\n+\tif (sc-\u003estatus \u003c SMBDIRECT_SOCKET_DISCONNECTED) {\n+\t\tsc-\u003estatus = SMBDIRECT_SOCKET_DISCONNECTED;\n+\t\tsmbdirect_socket_wake_up_all(sc);\n+\t}\n+\n \tif (sc-\u003eib.qp) {\n \t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,\n \t\t\t\"drain qp\\n\");\n@@ -575,6 +638,19 @@ static void smbdirect_socket_destroy(struct smbdirect_socket *sc)\n \tspin_lock_irqsave(\u0026sc-\u003elisten.lock, flags);\n \tlist_splice_tail_init(\u0026sc-\u003elisten.ready, \u0026pending_list);\n \tlist_splice_tail_init(\u0026sc-\u003elisten.pending, \u0026pending_list);\n+\t/*\n+\t * purge_orphaned_work is already disabled above,\n+\t * so we also need to release the orphaned sockets.\n+\t *\n+\t * Clearing accept.listener under listen.lock\n+\t * makes us responsible for releasing them and\n+\t * prevents them from moving themselves to\n+\t * the orphaned list via\n+\t * smbdirect_listen_orphan_socket().\n+\t */\n+\tlist_splice_tail_init(\u0026sc-\u003elisten.orphaned, \u0026pending_list);\n+\tlist_for_each_entry(psc, \u0026pending_list, accept.list)\n+\t\tWRITE_ONCE(psc-\u003eaccept.listener, NULL);\n \tspin_unlock_irqrestore(\u0026sc-\u003elisten.lock, flags);\n \n \t/* It's not possible for upper layer to get to reassembly */\n@@ -618,7 +694,6 @@ static void smbdirect_socket_destroy(struct smbdirect_socket *sc)\n \t\t\t\"release %zu pending sockets\\n\", psockets);\n \tlist_for_each_entry_safe(psc, tsc, \u0026pending_list, accept.list) {\n \t\tlist_del_init(\u0026psc-\u003eaccept.list);\n-\t\tpsc-\u003eaccept.listener = NULL;\n \t\tsmbdirect_socket_release(psc);\n \t}\n \tif (sc-\u003elisten.backlog != -1) /* was a listener */\n@@ -679,17 +754,21 @@ void smbdirect_socket_destroy_sync(struct smbdirect_socket *sc)\n \t\t\"destroying rdma session\\n\");\n \tif (sc-\u003estatus \u003c SMBDIRECT_SOCKET_DISCONNECTING)\n \t\tsmbdirect_socket_cleanup_work(\u0026sc-\u003edisconnect_work);\n-\tif (sc-\u003estatus \u003c SMBDIRECT_SOCKET_DISCONNECTED) {\n-\t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,\n-\t\t\t\"wait for transport being disconnected\\n\");\n-\t\twait_event(sc-\u003estatus_wait, sc-\u003estatus == SMBDIRECT_SOCKET_DISCONNECTED);\n-\t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,\n-\t\t\t\"waited for transport being disconnected\\n\");\n-\t}\n \n \t/*\n-\t * Once we reached SMBDIRECT_SOCKET_DISCONNECTED,\n-\t * we should call smbdirect_socket_destroy()\n+\t * We don't wait for RDMA_CM_EVENT_DISCONNECTED,\n+\t * rdma_disconnect() was already called by\n+\t * smbdirect_socket_cleanup_work() if needed\n+\t * and smbdirect_socket_destroy() drains the qp,\n+\t * destroys it and calls rdma_destroy_id(), which\n+\t * only waits for a currently running event handler\n+\t * and makes sure no further events are delivered.\n+\t * The rest of the disconnect protocol is handled\n+\t * by the rdma core asynchronously.\n+\t *\n+\t * Waiting for RDMA_CM_EVENT_DISCONNECTED could\n+\t * take very long or forever, e.g. if the peer\n+\t * just disappeared.\n \t */\n \tsmbdirect_socket_destroy(sc);\n \tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,\n@@ -741,7 +820,17 @@ static void smbdirect_socket_release_destroy(struct kref *kref)\n \t * in DESTROYED state, before we free the memory.\n \t */\n \tsmbdirect_socket_destroy_sync(sc);\n-\tkfree(sc);\n+\n+\t/*\n+\t * Only a listener (backlog != -1) is ever dereferenced\n+\t * via sc-\u003eaccept.listener under rcu_read_lock(), see\n+\t * smbdirect_listen_orphan_socket(). Other sockets can be\n+\t * freed immediately.\n+\t */\n+\tif (sc-\u003elisten.backlog != -1) /* was a listener */\n+\t\tkfree_rcu(sc, refs.rcu);\n+\telse\n+\t\tkfree(sc);\n }\n \n void smbdirect_socket_release(struct smbdirect_socket *sc)\ndiff --git a/fs/smb/smbdirect/socket.h b/fs/smb/smbdirect/socket.h\nindex c09eddd8ad16d5..14114a2567a2ec 100644\n--- a/fs/smb/smbdirect/socket.h\n+++ b/fs/smb/smbdirect/socket.h\n@@ -151,6 +151,12 @@ struct smbdirect_socket {\n \t\t * the disconnect refcount.\n \t\t */\n \t\tstruct kref destroy;\n+\n+\t\t/*\n+\t\t * smbdirect_socket_release_destroy() uses\n+\t\t * kfree_rcu(), see accept.listener.\n+\t\t */\n+\t\tstruct rcu_head rcu;\n \t} refs;\n \n \t/* RDMA related */\n@@ -216,6 +222,16 @@ struct smbdirect_socket {\n \t\t * only be \u003e 0.\n \t\t */\n \t\tint backlog;\n+\t\t/*\n+\t\t * Sockets on pending or ready that failed\n+\t\t * move themselves to orphaned and queue\n+\t\t * purge_orphaned_work, which releases them.\n+\t\t * So that they are freed while the listener\n+\t\t * is still alive. They still count against\n+\t\t * the backlog until they are released.\n+\t\t */\n+\t\tstruct list_head orphaned;\n+\t\tstruct work_struct purge_orphaned_work;\n \t} listen;\n \n \t/*\n@@ -226,7 +242,30 @@ struct smbdirect_socket {\n \t * connection.\n \t */\n \tstruct {\n+\t\t/*\n+\t\t * This is only set, protected by\n+\t\t * listener-\u003elisten.lock, while the socket\n+\t\t * is owned by the listener (on its pending,\n+\t\t * ready or orphaned list). The one who clears\n+\t\t * it is responsible for releasing the socket.\n+\t\t *\n+\t\t * The memory of a struct smbdirect_socket is\n+\t\t * freed via kfree_rcu(), so the listener\n+\t\t * can be dereferenced under rcu_read_lock(),\n+\t\t * even if accept.listener is cleared and\n+\t\t * the listener is released concurrently.\n+\t\t */\n \t\tstruct smbdirect_socket *listener;\n+\t\t/*\n+\t\t * Linkage on one of the listener's\n+\t\t * listen.{pending,ready,orphaned} lists.\n+\t\t *\n+\t\t * accept.list and accept.listener are set\n+\t\t * together under listener-\u003elisten.lock before\n+\t\t * smbdirect_accept_connect_request() is called,\n+\t\t * so whenever the socket is on one of those lists\n+\t\t * accept.listener is that listener (never NULL).\n+\t\t */\n \t\tstruct list_head list;\n \t} accept;\n \n@@ -588,6 +627,9 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)\n \tspin_lock_init(\u0026sc-\u003elisten.lock);\n \tINIT_LIST_HEAD(\u0026sc-\u003elisten.pending);\n \tINIT_LIST_HEAD(\u0026sc-\u003elisten.ready);\n+\tINIT_LIST_HEAD(\u0026sc-\u003elisten.orphaned);\n+\tINIT_WORK(\u0026sc-\u003elisten.purge_orphaned_work, __smbdirect_socket_disabled_work);\n+\tdisable_work_sync(\u0026sc-\u003elisten.purge_orphaned_work);\n \tsc-\u003elisten.backlog = -1; /* not a listener */\n \tinit_waitqueue_head(\u0026sc-\u003elisten.wait_queue);\n \ndiff --git a/kernel/fork.c b/kernel/fork.c\nindex 854448152696b2..a62477ec06b005 100644\n--- a/kernel/fork.c\n+++ b/kernel/fork.c\n@@ -2686,6 +2686,10 @@ struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node)\n \t\t.user_worker\t= 1,\n \t};\n \n+\t/* A creator past its fatal signal or its coredump point gets no thread. */\n+\tif (current-\u003eflags \u0026 (PF_SIGNALED | PF_POSTCOREDUMP))\n+\t\treturn ERR_PTR(-EINTR);\n+\n \treturn copy_process(NULL, 0, node, \u0026args);\n }\n \ndiff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh\nindex f99e196abeea4c..a032560eda0e8e 100755\n--- a/scripts/link-vmlinux.sh\n+++ b/scripts/link-vmlinux.sh\n@@ -106,6 +106,18 @@ vmlinux_link()\n \t\t${kallsymso} ${btf_vmlinux_bin_o} ${arch_vmlinux_o} ${ldlibs}\n }\n \n+# Check if kallsymso_prev and kallsymso differ\n+# If symbol sizes within ${kallsymso} change, any symbols within vmlinux are\n+# likely to shift, invalidating ${kallsymso}.\n+# Since file size can remain unchanged even if symbol sizes change, compare the\n+# actual symbols instead of relying on file size only.\n+kallsymso_changed()\n+{\n+\t${NM} -n \"${kallsymso_prev}\" \u003e \"${kallsymso_prev}.sym\"\n+\t${NM} -n \"${kallsymso}\" \u003e \"${kallsymso}.sym\"\n+\t! cmp -s \"${kallsymso_prev}.sym\" \"${kallsymso}.sym\"\n+}\n+\n # Create ${2}.o file with all symbols from the ${1} object file\n kallsyms()\n {\n@@ -126,6 +138,7 @@ kallsyms()\n \t${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} \\\n \t      ${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} -c -o \"${2}.o\" \"${2}.S\"\n \n+\tkallsymso_prev=\"${kallsymso:-}\"\n \tkallsymso=${2}.o\n }\n \n@@ -255,7 +268,12 @@ if is_enabled CONFIG_KALLSYMS; then\n \tsysmap_and_kallsyms .tmp_vmlinux2\n \tsize2=$(${CONFIG_SHELL} \"${srctree}/scripts/file-size.sh\" ${kallsymso})\n \n-\tif [ $size1 -ne $size2 ] || [ -n \"${KALLSYMS_EXTRA_PASS}\" ]; then\n+\t# Due to alignment, file size of the kallsymso object file might remain\n+\t# unchanged even if individual symbols within change size. Changed\n+\t# symbol sizes can still shift other symbols, though. Therefore, don't\n+\t# rely on file size alone.\n+\tif [ $size1 -ne $size2 ] || kallsymso_changed || \\\n+\t\t\t[ -n \"${KALLSYMS_EXTRA_PASS}\" ]; then\n \t\tvmlinux_link .tmp_vmlinux3\n \t\tsysmap_and_kallsyms .tmp_vmlinux3\n \tfi\n"
}

2/1 2026/10/30 15:01 agent patch-evaluator
4m Model:
core

Args:
null

Results:
{
  "EnableConfigs": [
    "IO_URING",
    "SMB_SERVER",
    "SMB_SERVER_SMBDIRECT",
    "SMBDIRECT",
    "INFINIBAND",
    "INFINIBAND_ADDR_TRANS",
    "HID_SENSOR_ALS",
    "HID_SENSOR_HUB"
  ],
  "FocusSymbols": [
    "create_io_thread",
    "begin_new_exec",
    "queue_ksmbd_work",
    "ksmbd_server_process_request",
    "smbdirect_socket_accept",
    "smbdirect_accept_connect_request",
    "smbdirect_listen_orphan_socket",
    "smbdirect_listen_purge_orphaned_work",
    "smbdirect_socket_destroy",
    "als_read_raw",
    "als_parse_report"
  ],
  "Reasoning": "The patch series touches several reachable subsystems in the kernel:\n1. Core process lifecycle and io_uring interaction (fs/exec.c and kernel/fork.c): moves io_uring_task_cancel() before de_thread() in begin_new_exec() and adds checks against PF_SIGNALED / PF_POSTCOREDUMP in create_io_thread() to prevent worker thread creation races during thread group termination.\n2. SMB server (ksmbd in fs/smb/server/server.c): introduces wait_event() synchronization during SMB negotiation requests in queue_ksmbd_work() before handling subsequent PDUs.\n3. SMBDirect RDMA transport (fs/smb/smbdirect/): refactors connection accept logic, fixes race conditions during socket error/teardown, adds orphan socket tracking with RCU protection for listeners, and adjusts socket destruction flows.\n4. IIO light sensor (drivers/iio/light/hid-sensor-als.c): adjusts channel scale storage into per-channel arrays and adds channel scan index validation in als_read_raw().\n\nThese modifications alter concurrency, state machines, and data structures in reachable code paths, making them prime targets for fuzzing.",
  "WorthFuzzing": true
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any '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:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 55ad28754d38c302656f2ed3b6efd93f91f3868d
Author: syz-cluster <triage@syzkaller.com>
Date:   Fri Oct 30 15:01:28 2026 +0000

    syz-cluster: applied patch under review

diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 6bf1bc9a38fe6e..8f2affb226a35a 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -33,9 +33,9 @@ struct als_state {
 		u32 illum[CHANNEL_SCAN_INDEX_MAX];
 		aligned_s64 timestamp;
 	} scan;
-	int scale_pre_decml;
-	int scale_post_decml;
-	int scale_precision;
+	int scale_pre_decml[CHANNEL_SCAN_INDEX_MAX];
+	int scale_post_decml[CHANNEL_SCAN_INDEX_MAX];
+	int scale_precision[CHANNEL_SCAN_INDEX_MAX];
 	int value_offset;
 	int num_channels;
 	s64 timestamp;
@@ -175,9 +175,11 @@ static int als_read_raw(struct iio_dev *indio_dev,
 		ret_type = IIO_VAL_INT;
 		break;
 	case IIO_CHAN_INFO_SCALE:
-		*val = als_state->scale_pre_decml;
-		*val2 = als_state->scale_post_decml;
-		ret_type = als_state->scale_precision;
+		if (chan->scan_index >= CHANNEL_SCAN_INDEX_MAX)
+			return -EINVAL;
+		*val = als_state->scale_pre_decml[chan->scan_index];
+		*val2 = als_state->scale_post_decml[chan->scan_index];
+		ret_type = als_state->scale_precision[chan->scan_index];
 		break;
 	case IIO_CHAN_INFO_OFFSET:
 		*val = als_state->value_offset;
@@ -331,6 +333,10 @@ static int als_parse_report(struct platform_device *pdev,
 		};
 		++index;
 
+		st->scale_precision[i] = hid_sensor_format_scale(usage_id,
+					&st->als[i], &st->scale_pre_decml[i],
+					&st->scale_post_decml[i]);
+
 		dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index,
 			st->als[i].report_id);
 	}
@@ -340,10 +346,6 @@ static int als_parse_report(struct platform_device *pdev,
 	if (index)
 		ret = 0;
 
-	st->scale_precision = hid_sensor_format_scale(usage_id,
-				&st->als[CHANNEL_SCAN_INDEX_INTENSITY],
-				&st->scale_pre_decml, &st->scale_post_decml);
-
 	return ret;
 }
 
diff --git a/drivers/platform/cznic/turris-omnia-mcu-base.c b/drivers/platform/cznic/turris-omnia-mcu-base.c
index e8fc0d7b334342..f0416302a1f3c1 100644
--- a/drivers/platform/cznic/turris-omnia-mcu-base.c
+++ b/drivers/platform/cznic/turris-omnia-mcu-base.c
@@ -403,6 +403,7 @@ static const struct of_device_id of_omnia_mcu_match[] = {
 	{ .compatible = "cznic,turris-omnia-mcu" },
 	{}
 };
+MODULE_DEVICE_TABLE(of, of_omnia_mcu_match);
 
 static struct i2c_driver omnia_mcu_driver = {
 	.probe		= omnia_mcu_probe,
diff --git a/fs/exec.c b/fs/exec.c
index a598d48b5ffccb..bd3e3aac90efda 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1145,6 +1145,13 @@ int begin_new_exec(struct linux_binprm * bprm)
 	 */
 	bprm->point_of_no_return = true;
 
+	/*
+	 * Cancel any io_uring activity across execve. This runs task work
+	 * that may still create an io-wq worker, so do it while de_thread()
+	 * can still zap it.
+	 */
+	io_uring_task_cancel();
+
 	/* Make this the only thread in the thread group */
 	retval = de_thread(me);
 	if (retval)
@@ -1161,10 +1168,6 @@ int begin_new_exec(struct linux_binprm * bprm)
 
 	/* see the comment in check_unsafe_exec() */
 	current->fs->in_exec = 0;
-	/*
-	 * Cancel any io_uring activity across execve
-	 */
-	io_uring_task_cancel();
 
 	/* Ensure the files table is not shared. */
 	retval = unshare_files();
diff --git a/fs/smb/server/server.c b/fs/smb/server/server.c
index e113b23d96f94e..e36e82b94a047c 100644
--- a/fs/smb/server/server.c
+++ b/fs/smb/server/server.c
@@ -371,6 +371,7 @@ static void handle_ksmbd_work(struct work_struct *wk)
 static int queue_ksmbd_work(struct ksmbd_conn *conn)
 {
 	struct ksmbd_work *work;
+	bool wait_for_neg = ksmbd_conn_new(conn) || ksmbd_conn_need_negotiate(conn);
 	int err;
 
 	err = ksmbd_init_smb_server(conn);
@@ -393,6 +394,10 @@ static int queue_ksmbd_work(struct ksmbd_conn *conn)
 	conn->last_active = jiffies;
 	INIT_WORK(&work->work, handle_ksmbd_work);
 	ksmbd_queue_work(work);
+	/* Negotiation can change conn->ops, finish it before reading another PDU. */
+	if (wait_for_neg)
+		wait_event(conn->req_running_q,
+			   atomic_read(&conn->req_running) == 0);
 	return 0;
 }
 
diff --git a/fs/smb/smbdirect/accept.c b/fs/smb/smbdirect/accept.c
index 039c9bfbd8acda..d1bc08ac975756 100644
--- a/fs/smb/smbdirect/accept.c
+++ b/fs/smb/smbdirect/accept.c
@@ -19,15 +19,33 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 				     const struct rdma_conn_param *param)
 {
 	struct smbdirect_socket_parameters *sp = &sc->parameters;
-	struct smbdirect_recv_io *recv_io;
+	struct smbdirect_recv_io *recv_io = NULL;
 	u8 peer_initiator_depth;
 	u8 peer_responder_resources;
 	struct rdma_conn_param conn_param;
 	__be32 ird_ord_hdr[2];
 	int ret;
 
-	if (SMBDIRECT_CHECK_STATUS_WARN(sc, SMBDIRECT_SOCKET_CREATED))
-		return -EINVAL;
+	/*
+	 * Install the real event handler (and the event we expect next)
+	 * before anything that can fail. On an early error the caller
+	 * (smbdirect_listen_connect_request()) only schedules our deferred
+	 * cleanup and returns 0 to the rdma_cm core, which keeps the cm_id, so
+	 * the cm_id must already carry smbdirect_accept_rdma_event_handler():
+	 * it turns any unexpected event (e.g. RDMA_CM_EVENT_DEVICE_REMOVAL)
+	 * into a clean smbdirect_socket_schedule_cleanup(). Otherwise the
+	 * placeholder smbdirect_socket_rdma_event_handler() installed by
+	 * smbdirect_socket_init_accepting() stays in place and returns -ESTALE,
+	 * which makes the rdma_cm core destroy the cm_id behind the back of our
+	 * pending teardown.
+	 */
+	sc->rdma.expected_event = RDMA_CM_EVENT_ESTABLISHED;
+	sc->rdma.cm_id->event_handler = smbdirect_accept_rdma_event_handler;
+
+	if (SMBDIRECT_CHECK_STATUS_WARN(sc, SMBDIRECT_SOCKET_CREATED)) {
+		ret = -EINVAL;
+		goto cleanup;
+	}
 
 	/*
 	 * First set what the we as server are able to support
@@ -47,7 +65,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
 			"smbdirect_accept_init_params() failed %1pe\n",
 			SMBDIRECT_DEBUG_ERR_PTR(ret));
-		goto init_params_failed;
+		goto cleanup;
 	}
 
 	ret = smbdirect_connection_create_qp(sc);
@@ -55,7 +73,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
 			"smbdirect_connection_create_qp() failed %1pe\n",
 			SMBDIRECT_DEBUG_ERR_PTR(ret));
-		goto create_qp_failed;
+		goto cleanup;
 	}
 
 	ret = smbdirect_connection_create_mem_pools(sc);
@@ -63,7 +81,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
 			"smbdirect_connection_create_mem_pools() failed %1pe\n",
 			SMBDIRECT_DEBUG_ERR_PTR(ret));
-		goto create_mem_failed;
+		goto cleanup;
 	}
 
 	recv_io = smbdirect_connection_get_recv_io(sc);
@@ -72,7 +90,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
 			"smbdirect_connection_get_recv_io() failed %1pe\n",
 			SMBDIRECT_DEBUG_ERR_PTR(ret));
-		goto get_recv_io_failed;
+		goto cleanup;
 	}
 	recv_io->cqe.done = smbdirect_accept_negotiate_recv_done;
 
@@ -86,7 +104,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
 			"smbdirect_connection_post_recv_io() failed %1pe\n",
 			SMBDIRECT_DEBUG_ERR_PTR(ret));
-		goto post_recv_io_failed;
+		goto cleanup;
 	}
 	/*
 	 * From here recv_io is known to the RDMA QP and needs ib_drain_qp and
@@ -122,14 +140,12 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 	/* explicitly set above */
 	WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RDMA_CONNECT_NEEDED);
 	sc->status = SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING;
-	sc->rdma.expected_event = RDMA_CM_EVENT_ESTABLISHED;
-	sc->rdma.cm_id->event_handler = smbdirect_accept_rdma_event_handler;
 	ret = rdma_accept(sc->rdma.cm_id, &conn_param);
 	if (ret) {
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
 			"rdma_accept() failed %1pe\n",
 			SMBDIRECT_DEBUG_ERR_PTR(ret));
-		goto rdma_accept_failed;
+		goto cleanup;
 	}
 
 	/*
@@ -143,31 +159,25 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 
 	return 0;
 
-rdma_accept_failed:
+cleanup:
 	/*
-	 * The recv_io posted above is now owned by the QP (recv_io was set to
-	 * NULL after a successful post).  smbdirect_connection_destroy_qp()
-	 * calls ib_drain_qp(), whose completion
-	 * (smbdirect_accept_negotiate_recv_done) returns the recv_io to the
-	 * free list via smbdirect_connection_put_recv_io().  It therefore MUST
-	 * run BEFORE smbdirect_connection_destroy_mem_pools(): otherwise the
-	 * posted recv_io is still outstanding when kmem_cache_destroy() runs
-	 * ("Slab cache still has objects") and is later freed into an
-	 * already-destroyed mempool (mempool_free_bulk NULL-ptr-deref).
+	 * No RDMA state is torn down here, and in particular sc is not
+	 * released: the caller (smbdirect_listen_connect_request()) owns that
+	 * decision and schedules sc's teardown via
+	 * smbdirect_socket_schedule_cleanup() on a non-zero return. All of the
+	 * RDMA state - the QP, the memory pools and the cm_id itself - is then
+	 * torn down asynchronously by smbdirect_socket_cleanup_work() ->
+	 * smbdirect_socket_release() -> smbdirect_socket_destroy(), which
+	 * drains the QP (returning any posted recv_io to the pool) before
+	 * destroying the memory pools and destroys the cm_id with
+	 * rdma_destroy_id(), all in the correct order.
+	 *
+	 * The only resource not reachable by that teardown is a recv_io that
+	 * was taken from the pool but not yet posted to the QP (recv_io is set
+	 * to NULL after a successful post), so hand it back here.
 	 */
-	smbdirect_connection_destroy_qp(sc);
-	smbdirect_connection_destroy_mem_pools(sc);
-	return ret;
-post_recv_io_failed:
-	/* post failed: recv_io was not accepted by the QP, still in hand */
 	if (recv_io)
 		smbdirect_connection_put_recv_io(recv_io);
-get_recv_io_failed:
-	smbdirect_connection_destroy_mem_pools(sc);
-create_mem_failed:
-	smbdirect_connection_destroy_qp(sc);
-create_qp_failed:
-init_params_failed:
 	return ret;
 }
 
@@ -301,6 +311,7 @@ static void smbdirect_accept_negotiate_recv_work(struct work_struct *work)
 	struct smbdirect_socket *sc =
 		container_of(work, struct smbdirect_socket, connect.work);
 	struct smbdirect_socket_parameters *sp = &sc->parameters;
+	struct smbdirect_socket *lsc;
 	struct smbdirect_recv_io *recv_io;
 	struct smbdirect_negotiate_req *nreq;
 	unsigned long flags;
@@ -463,29 +474,55 @@ static void smbdirect_accept_negotiate_recv_work(struct work_struct *work)
 	 */
 	sp->max_fragmented_send_size = max_fragmented_size;
 
-	if (sc->accept.listener) {
-		struct smbdirect_socket *lsc = sc->accept.listener;
-		unsigned long flags;
+	/*
+	 * Every accepting socket was created by
+	 * smbdirect_listen_connect_request() and has a
+	 * listener. If it's already cleared, the listener
+	 * (or its purge_orphaned_work) is responsible for
+	 * releasing us, so we must not send a negotiate
+	 * response.
+	 *
+	 * The memory of the listener is freed via kfree_rcu(),
+	 * see smbdirect_listen_orphan_socket().
+	 */
+	rcu_read_lock();
+	lsc = READ_ONCE(sc->accept.listener);
+	if (!lsc) {
+		rcu_read_unlock();
+		return;
+	}
 
-		spin_lock_irqsave(&lsc->listen.lock, flags);
-		list_del(&sc->accept.list);
-		list_add_tail(&sc->accept.list, &lsc->listen.ready);
+	spin_lock_irqsave(&lsc->listen.lock, flags);
+	/*
+	 * The listener (or its purge_orphaned_work)
+	 * may have cleared sc->accept.listener in the
+	 * meantime and is responsible for releasing us.
+	 *
+	 * If we already failed, we're either
+	 * already on the orphaned list or
+	 * smbdirect_socket_cleanup_work() will
+	 * move us there.
+	 *
+	 * In both cases we must not move us
+	 * to the ready list.
+	 */
+	if (sc->accept.listener == lsc && !READ_ONCE(sc->first_error)) {
+		list_move_tail(&sc->accept.list, &lsc->listen.ready);
 		wake_up(&lsc->listen.wait_queue);
-		spin_unlock_irqrestore(&lsc->listen.lock, flags);
-
-		/*
-		 * smbdirect_socket_accept() will call
-		 * smbdirect_accept_negotiate_finish(nsc, 0);
-		 *
-		 * So that we don't send the negotiation
-		 * response that grants credits to the peer
-		 * before the socket is accepted by the
-		 * application.
-		 */
-		return;
 	}
+	spin_unlock_irqrestore(&lsc->listen.lock, flags);
+	rcu_read_unlock();
 
-	ntstatus = le32_to_cpu(STATUS_SUCCESS);
+	/*
+	 * smbdirect_socket_accept() will call
+	 * smbdirect_accept_negotiate_finish(nsc, 0);
+	 *
+	 * So that we don't send the negotiation
+	 * response that grants credits to the peer
+	 * before the socket is accepted by the
+	 * application.
+	 */
+	return;
 
 not_supported:
 	smbdirect_accept_negotiate_finish(sc, ntstatus);
@@ -798,7 +835,11 @@ static long smbdirect_socket_wait_for_accept(struct smbdirect_socket *lsc, long
 	if (ret < 0)
 		return ret;
 
-	return 0;
+	/*
+	 * Return the remaining timeout, so the caller can carry it
+	 * over to the next smbdirect_socket_wait_for_accept() call.
+	 */
+	return ret;
 }
 
 struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,
@@ -808,6 +849,7 @@ struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,
 	struct smbdirect_socket *nsc;
 	unsigned long flags;
 
+again:
 	if (lsc->status != SMBDIRECT_SOCKET_LISTENING) {
 		arg->err = -EINVAL;
 		return NULL;
@@ -819,7 +861,7 @@ struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,
 	}
 
 	if (list_empty_careful(&lsc->listen.ready)) {
-		int ret;
+		long ret;
 
 		if (timeo == 0) {
 			arg->err = -EAGAIN;
@@ -827,25 +869,78 @@ struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,
 		}
 
 		ret = smbdirect_socket_wait_for_accept(lsc, timeo);
-		if (ret) {
+		if (ret < 0) {
 			arg->err = ret;
 			return NULL;
 		}
+		/*
+		 * Carry the remaining timeout over, so that a stream of
+		 * failed connections that we orphan and skip (goto again)
+		 * can't reset the caller's timeout and wait forever.
+		 */
+		timeo = ret;
 	}
 
 	spin_lock_irqsave(&lsc->listen.lock, flags);
-	nsc = list_first_entry_or_null(&lsc->listen.ready,
-				       struct smbdirect_socket,
-				       accept.list);
+	/*
+	 * Recheck under the lock.
+	 */
+	if (lsc->status != SMBDIRECT_SOCKET_LISTENING) {
+		arg->err = -EINVAL;
+		spin_unlock_irqrestore(&lsc->listen.lock, flags);
+		return NULL;
+	}
+	if (lsc->first_error) {
+		arg->err = lsc->first_error;
+		spin_unlock_irqrestore(&lsc->listen.lock, flags);
+		return NULL;
+	}
+
+	while ((nsc = list_first_entry_or_null(&lsc->listen.ready,
+					       struct smbdirect_socket,
+					       accept.list))) {
+		/*
+		 * nsc may have failed after it was moved
+		 * to the ready list, e.g. RDMA_CM_EVENT_DISCONNECTED
+		 * already moved it to SMBDIRECT_SOCKET_DISCONNECTED.
+		 * We must not overwrite that with
+		 * SMBDIRECT_SOCKET_CONNECTED and hand
+		 * out an already disconnected socket.
+		 *
+		 * Doing this under listen.lock means nsc
+		 * still belongs to us, so we can just move
+		 * a failed socket to the orphaned list,
+		 * like smbdirect_listen_orphan_socket() does,
+		 * and try the next one.
+		 */
+		if (!READ_ONCE(nsc->first_error) &&
+		    cmpxchg(&nsc->status,
+			    SMBDIRECT_SOCKET_NEGOTIATE_RUNNING,
+			    SMBDIRECT_SOCKET_CONNECTED) ==
+		    SMBDIRECT_SOCKET_NEGOTIATE_RUNNING)
+			break;
+
+		smbdirect_log_rdma_event(nsc, SMBDIRECT_LOG_INFO,
+			"orphaning failed socket status=%s first_error=%1pe\n",
+			smbdirect_socket_status_string(nsc->status),
+			SMBDIRECT_DEBUG_ERR_PTR(nsc->first_error));
+		list_move_tail(&nsc->accept.list, &lsc->listen.orphaned);
+		queue_work(lsc->workqueues.cleanup, &lsc->listen.purge_orphaned_work);
+	}
 	if (nsc) {
-		nsc->accept.listener = NULL;
+		WRITE_ONCE(nsc->accept.listener, NULL);
 		list_del_init_careful(&nsc->accept.list);
 		arg->is_empty = list_empty_careful(&lsc->listen.ready);
 	}
 	spin_unlock_irqrestore(&lsc->listen.lock, flags);
 	if (!nsc) {
-		arg->err = -EAGAIN;
-		return NULL;
+		/*
+		 * If we only found failed sockets or no socket,
+		 * we wait for the next one.
+		 *
+		 * A possible -EAGAIN/-ETIMEOUT is handled above.
+		 */
+		goto again;
 	}
 
 	/*
@@ -854,12 +949,14 @@ struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,
 	 * so it didn't grant any credits to us.
 	 *
 	 * The caller expects a connected socket
-	 * now as there are no credits anyway.
+	 * now as there are no credits anyway,
+	 * above we already changed to SMBDIRECT_SOCKET_CONNECTED
+	 * under the lsc->listen.lock and with cmpxchg.
 	 *
-	 * Then we send the negotiation response in
-	 * order to grant credits to the peer.
+	 * Now we send the negotiation response in
+	 * order to grant credits to the peer,
+	 * as the socket is now visible to the application layer.
 	 */
-	nsc->status = SMBDIRECT_SOCKET_CONNECTED;
 	smbdirect_accept_negotiate_finish(nsc, 0);
 
 	return nsc;
diff --git a/fs/smb/smbdirect/connection.c b/fs/smb/smbdirect/connection.c
index fe99537207176e..32327f96a03ab1 100644
--- a/fs/smb/smbdirect/connection.c
+++ b/fs/smb/smbdirect/connection.c
@@ -83,9 +83,9 @@ static int smbdirect_connection_rdma_event_handler(struct rdma_cm_id *id,
 		 * smbdirect_socket_schedule_cleanup[_status]() =>
 		 * smbdirect_socket_cleanup_work().
 		 *
-		 * As otherwise we'd set SMBDIRECT_SOCKET_DISCONNECTING,
-		 * but never ever get RDMA_CM_EVENT_DISCONNECTED and
-		 * never reach SMBDIRECT_SOCKET_DISCONNECTED.
+		 * As otherwise we'd set SMBDIRECT_SOCKET_DISCONNECTING
+		 * and call rdma_disconnect(), but never ever get
+		 * RDMA_CM_EVENT_DISCONNECTED.
 		 */
 		if (event->event == RDMA_CM_EVENT_DEVICE_REMOVAL)
 			smbdirect_socket_schedule_cleanup_status(sc,
@@ -113,9 +113,9 @@ static int smbdirect_connection_rdma_event_handler(struct rdma_cm_id *id,
 		 * smbdirect_socket_schedule_cleanup_status() =>
 		 * smbdirect_socket_cleanup_work().
 		 *
-		 * As otherwise we'd set SMBDIRECT_SOCKET_DISCONNECTING,
-		 * but never ever get RDMA_CM_EVENT_DISCONNECTED and
-		 * never reach SMBDIRECT_SOCKET_DISCONNECTED.
+		 * As otherwise we'd set SMBDIRECT_SOCKET_DISCONNECTING
+		 * and call rdma_disconnect(), but never ever get
+		 * RDMA_CM_EVENT_DISCONNECTED.
 		 *
 		 * This is also a normal disconnect so
 		 * SMBDIRECT_LOG_INFO should be good enough
diff --git a/fs/smb/smbdirect/internal.h b/fs/smb/smbdirect/internal.h
index e9959e6dc13ae8..69d0c9f899deca 100644
--- a/fs/smb/smbdirect/internal.h
+++ b/fs/smb/smbdirect/internal.h
@@ -74,6 +74,8 @@ void __smbdirect_socket_schedule_cleanup(struct smbdirect_socket *sc,
 
 void smbdirect_socket_destroy_sync(struct smbdirect_socket *sc);
 
+void smbdirect_listen_orphan_socket(struct smbdirect_socket *sc);
+
 int smbdirect_socket_wait_for_credits(struct smbdirect_socket *sc,
 				      enum smbdirect_socket_status expected_status,
 				      int unexpected_errno,
diff --git a/fs/smb/smbdirect/listen.c b/fs/smb/smbdirect/listen.c
index 2f78bcaedbf82e..3c91f00d95ce4a 100644
--- a/fs/smb/smbdirect/listen.c
+++ b/fs/smb/smbdirect/listen.c
@@ -10,6 +10,78 @@
 static int smbdirect_listen_rdma_event_handler(struct rdma_cm_id *id,
 					       struct rdma_cm_event *event);
 
+/*
+ * This is called by a socket that failed while it
+ * is still on the pending or ready list of its
+ * listener, typically at the end of
+ * smbdirect_socket_cleanup_work(), when the
+ * disconnect was already started.
+ *
+ * It moves itself to the orphaned list and
+ * lets smbdirect_listen_purge_orphaned_work()
+ * release it. Otherwise it would stay on the
+ * pending or ready list until the listener is
+ * destroyed and fill up the backlog, so that
+ * no new connections would be accepted.
+ *
+ * It's fine to call this more than once.
+ */
+void smbdirect_listen_orphan_socket(struct smbdirect_socket *sc)
+{
+	struct smbdirect_socket *lsc;
+	unsigned long flags;
+
+	/*
+	 * The memory of the listener is freed via
+	 * kfree_rcu(), so it's safe to dereference it
+	 * under rcu_read_lock(), even if sc->accept.listener
+	 * is cleared and the listener is released concurrently.
+	 */
+	rcu_read_lock();
+	lsc = READ_ONCE(sc->accept.listener);
+	if (!lsc) {
+		rcu_read_unlock();
+		return;
+	}
+
+	spin_lock_irqsave(&lsc->listen.lock, flags);
+	if (sc->accept.listener == lsc) {
+		list_move_tail(&sc->accept.list, &lsc->listen.orphaned);
+		queue_work(lsc->workqueues.cleanup, &lsc->listen.purge_orphaned_work);
+	}
+	spin_unlock_irqrestore(&lsc->listen.lock, flags);
+	rcu_read_unlock();
+}
+
+static void smbdirect_listen_purge_orphaned_work(struct work_struct *work)
+{
+	struct smbdirect_socket *lsc =
+		container_of(work, struct smbdirect_socket, listen.purge_orphaned_work);
+	struct smbdirect_socket *psc, *tsc;
+	LIST_HEAD(orphaned_list);
+	unsigned long flags;
+
+	/*
+	 * Clearing accept.listener under listen.lock
+	 * makes us responsible for releasing them.
+	 */
+	spin_lock_irqsave(&lsc->listen.lock, flags);
+	list_splice_tail_init(&lsc->listen.orphaned, &orphaned_list);
+	list_for_each_entry(psc, &orphaned_list, accept.list)
+		WRITE_ONCE(psc->accept.listener, NULL);
+	spin_unlock_irqrestore(&lsc->listen.lock, flags);
+
+	/*
+	 * We don't hold the listener's rdma_lock_handler()
+	 * lock here, see smbdirect_socket_destroy()
+	 * for why that's important.
+	 */
+	list_for_each_entry_safe(psc, tsc, &orphaned_list, accept.list) {
+		list_del_init(&psc->accept.list);
+		smbdirect_socket_release(psc);
+	}
+}
+
 int smbdirect_socket_listen(struct smbdirect_socket *sc, int backlog)
 {
 	int ret;
@@ -47,6 +119,9 @@ int smbdirect_socket_listen(struct smbdirect_socket *sc, int backlog)
 	sc->rdma.cm_id->event_handler = smbdirect_listen_rdma_event_handler;
 	rdma_unlock_handler(sc->rdma.cm_id);
 
+	INIT_WORK(&sc->listen.purge_orphaned_work,
+		  smbdirect_listen_purge_orphaned_work);
+
 	ret = rdma_listen(sc->rdma.cm_id, backlog);
 	if (ret) {
 		sc->first_error = ret;
@@ -214,6 +289,7 @@ static int smbdirect_listen_connect_request(struct smbdirect_socket *lsc,
 	size_t backlog = max_t(size_t, 1, lsc->listen.backlog);
 	size_t psockets;
 	size_t rsockets;
+	size_t osockets;
 	int ret;
 
 	if (!smbdirect_frwr_is_supported(&new_id->device->attrs)) {
@@ -254,14 +330,21 @@ static int smbdirect_listen_connect_request(struct smbdirect_socket *lsc,
 	spin_lock_irqsave(&lsc->listen.lock, flags);
 	psockets = list_count_nodes(&lsc->listen.pending);
 	rsockets = list_count_nodes(&lsc->listen.ready);
+	/*
+	 * Orphaned sockets still count against
+	 * the backlog until they are released by
+	 * smbdirect_listen_purge_orphaned_work().
+	 */
+	osockets = list_count_nodes(&lsc->listen.orphaned);
 	spin_unlock_irqrestore(&lsc->listen.lock, flags);
 
 	if (psockets > backlog ||
 	    rsockets > backlog ||
-	    (psockets + rsockets) > backlog) {
+	    osockets > backlog ||
+	    (psockets + rsockets + osockets) > backlog) {
 		smbdirect_log_rdma_event(lsc, SMBDIRECT_LOG_ERR,
-			"Backlog[%d][%zu] full pending[%zu] ready[%zu]\n",
-			lsc->listen.backlog, backlog, psockets, rsockets);
+			"Backlog[%d][%zu] full pending[%zu] ready[%zu] orphaned[%zu]\n",
+			lsc->listen.backlog, backlog, psockets, rsockets, osockets);
 		return -EBUSY;
 	}
 
@@ -279,22 +362,54 @@ static int smbdirect_listen_connect_request(struct smbdirect_socket *lsc,
 	if (ret)
 		goto set_settings_failed;
 
+	/*
+	 * Publish nsc on the pending list with accept.listener set before
+	 * smbdirect_accept_connect_request() calls rdma_accept(). Once the
+	 * connection can establish, smbdirect_accept_negotiate_recv_work()
+	 * may run and it must observe accept.listener, otherwise nsc would
+	 * be left stranded on the pending list forever.
+	 *
+	 * The listener's handler_mutex is held while we're called, so
+	 * smbdirect_socket_destroy() of the listener can't reach nsc on the
+	 * pending list before we're done.
+	 *
+	 * From here nsc is published on the pending list: on failure of
+	 * smbdirect_accept_connect_request() below we schedule nsc's teardown,
+	 * which orphans nsc off the listener so
+	 * smbdirect_listen_purge_orphaned_work() -> smbdirect_socket_release()
+	 * releases it.
+	 */
 	spin_lock_irqsave(&lsc->listen.lock, flags);
 	list_add_tail(&nsc->accept.list, &lsc->listen.pending);
-	nsc->accept.listener = lsc;
+	WRITE_ONCE(nsc->accept.listener, lsc);
 	spin_unlock_irqrestore(&lsc->listen.lock, flags);
 
 	ret = smbdirect_accept_connect_request(nsc, &event->param.conn);
-	if (ret)
-		goto accept_connect_failed;
+	if (ret) {
+		/*
+		 * The rdma_cm core holds both the listener's and nsc's
+		 * id_priv->handler_mutex across this CONNECT_REQUEST handler,
+		 * so neither can go away under us here and nsc cannot receive
+		 * any rdma event: it is safe to hand nsc to its teardown.
+		 *
+		 * That teardown must be deferred though: nsc->rdma.cm_id
+		 * (= new_id) has its handler_mutex held by us, so it cannot be
+		 * destroyed synchronously from here.
+		 * smbdirect_socket_schedule_cleanup() only queues work;
+		 * smbdirect_socket_cleanup_work() then orphans nsc off the
+		 * listener and smbdirect_listen_purge_orphaned_work() releases
+		 * it, destroying nsc's cm_id with rdma_destroy_id().
+		 */
+		smbdirect_socket_schedule_cleanup(nsc, ret);
+	}
 
+	/*
+	 * Always return 0 so the rdma_cm core keeps new_id: nsc owns it now.
+	 * On success it stays connected; on failure its deferred teardown
+	 * above destroys it.
+	 */
 	return 0;
 
-accept_connect_failed:
-	spin_lock_irqsave(&lsc->listen.lock, flags);
-	list_del_init(&nsc->accept.list);
-	nsc->accept.listener = NULL;
-	spin_unlock_irqrestore(&lsc->listen.lock, flags);
 set_settings_failed:
 set_params_failed:
 	/*
diff --git a/fs/smb/smbdirect/socket.c b/fs/smb/smbdirect/socket.c
index bb02df6158b97e..e270e36b3145e1 100644
--- a/fs/smb/smbdirect/socket.c
+++ b/fs/smb/smbdirect/socket.c
@@ -319,6 +319,15 @@ void __smbdirect_socket_schedule_cleanup(struct smbdirect_socket *sc,
 	 * (smbdirect_socket_destroy) to reap.
 	 */
 	if (sc->listen.backlog != -1) { /* was a listener */
+		/*
+		 * We don't move them to the orphaned list here,
+		 * each child does that itself at the end of its
+		 * smbdirect_socket_cleanup_work(), see
+		 * smbdirect_listen_orphan_socket(). Only that checks
+		 * accept.listener, which is still NULL for a child
+		 * that smbdirect_listen_connect_request() is still
+		 * setting up and will release itself on failure.
+		 */
 		spin_lock_irqsave(&sc->listen.lock, flags);
 		list_splice_init(&sc->listen.ready, &sc->listen.pending);
 		list_for_each_entry_safe(psc, tsc, &sc->listen.pending, accept.list)
@@ -427,6 +436,15 @@ static void smbdirect_socket_cleanup_work(struct work_struct *work)
 	 * instances of one class -- harmless, but lockdep cannot tell).
 	 */
 	if (sc->listen.backlog != -1) { /* was a listener */
+		/*
+		 * We don't move them to the orphaned list here,
+		 * each child does that itself at the end of its
+		 * smbdirect_socket_cleanup_work(), see
+		 * smbdirect_listen_orphan_socket(). Only that checks
+		 * accept.listener, which is still NULL for a child
+		 * that smbdirect_listen_connect_request() is still
+		 * setting up and will release itself on failure.
+		 */
 		spin_lock_irqsave(&sc->listen.lock, flags);
 		list_splice_init(&sc->listen.ready, &sc->listen.pending);
 		list_for_each_entry_safe(psc, tsc, &sc->listen.pending, accept.list)
@@ -486,6 +504,18 @@ static void smbdirect_socket_cleanup_work(struct work_struct *work)
 	 * in order to notice the broken connection.
 	 */
 	smbdirect_socket_wake_up_all(sc);
+
+	/*
+	 * If we're still on the pending or ready list
+	 * of a listener, we started the disconnect
+	 * as far as possible above, so we move ourself
+	 * to the orphaned list of the listener,
+	 * which will release us.
+	 *
+	 * This is a no-op internally if
+	 * sc->accept.listener is NULL.
+	 */
+	smbdirect_listen_orphan_socket(sc);
 }
 
 static void smbdirect_socket_destroy(struct smbdirect_socket *sc)
@@ -511,7 +541,13 @@ static void smbdirect_socket_destroy(struct smbdirect_socket *sc)
 	if (sc->status == SMBDIRECT_SOCKET_DESTROYED)
 		return;
 
-	WARN_ONCE(sc->status != SMBDIRECT_SOCKET_DISCONNECTED,
+	/*
+	 * smbdirect_socket_destroy_sync() doesn't wait
+	 * for RDMA_CM_EVENT_DISCONNECTED, so we may still
+	 * be in SMBDIRECT_SOCKET_DISCONNECTING
+	 * (or already reached SMBDIRECT_SOCKET_DISCONNECTED)
+	 */
+	WARN_ONCE(sc->status < SMBDIRECT_SOCKET_DISCONNECTING,
 		  "status=%s first_error=%1pe",
 		  smbdirect_socket_status_string(sc->status),
 		  SMBDIRECT_DEBUG_ERR_PTR(sc->first_error));
@@ -538,10 +574,37 @@ static void smbdirect_socket_destroy(struct smbdirect_socket *sc)
 	disable_work_sync(&sc->recv_io.posted.refill_work);
 	disable_work_sync(&sc->idle.immediate_work);
 	disable_delayed_work_sync(&sc->idle.timer_work);
+	disable_work_sync(&sc->listen.purge_orphaned_work);
 
 	if (sc->rdma.cm_id)
 		rdma_lock_handler(sc->rdma.cm_id);
 
+	/*
+	 * We hold the handler lock, so the rdma event
+	 * handlers can't change the status anymore.
+	 *
+	 * If RDMA_CM_EVENT_DISCONNECTED didn't arrive yet,
+	 * we just stop waiting for it here.
+	 *
+	 * We already disabled disconnect_work above
+	 * and before we call rdma_unlock_handler below
+	 * we call smbdirect_connection_destroy_qp which
+	 * sets sc->ib.qp = NULL.
+	 *
+	 * Between rdma_unlock_handler() and
+	 * rdma_destroy_id() below there's a small
+	 * windows where RDMA_CM_EVENT_DISCONNECTED
+	 * could still arrive.
+	 *
+	 * But smbdirect_connection_rdma_event_handler
+	 * will be a noop when calling smbdirect_socket_schedule_cleanup*
+	 * ib_drain_qp() also won't be called.
+	 */
+	if (sc->status < SMBDIRECT_SOCKET_DISCONNECTED) {
+		sc->status = SMBDIRECT_SOCKET_DISCONNECTED;
+		smbdirect_socket_wake_up_all(sc);
+	}
+
 	if (sc->ib.qp) {
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
 			"drain qp\n");
@@ -575,6 +638,19 @@ static void smbdirect_socket_destroy(struct smbdirect_socket *sc)
 	spin_lock_irqsave(&sc->listen.lock, flags);
 	list_splice_tail_init(&sc->listen.ready, &pending_list);
 	list_splice_tail_init(&sc->listen.pending, &pending_list);
+	/*
+	 * purge_orphaned_work is already disabled above,
+	 * so we also need to release the orphaned sockets.
+	 *
+	 * Clearing accept.listener under listen.lock
+	 * makes us responsible for releasing them and
+	 * prevents them from moving themselves to
+	 * the orphaned list via
+	 * smbdirect_listen_orphan_socket().
+	 */
+	list_splice_tail_init(&sc->listen.orphaned, &pending_list);
+	list_for_each_entry(psc, &pending_list, accept.list)
+		WRITE_ONCE(psc->accept.listener, NULL);
 	spin_unlock_irqrestore(&sc->listen.lock, flags);
 
 	/* It's not possible for upper layer to get to reassembly */
@@ -618,7 +694,6 @@ static void smbdirect_socket_destroy(struct smbdirect_socket *sc)
 			"release %zu pending sockets\n", psockets);
 	list_for_each_entry_safe(psc, tsc, &pending_list, accept.list) {
 		list_del_init(&psc->accept.list);
-		psc->accept.listener = NULL;
 		smbdirect_socket_release(psc);
 	}
 	if (sc->listen.backlog != -1) /* was a listener */
@@ -679,17 +754,21 @@ void smbdirect_socket_destroy_sync(struct smbdirect_socket *sc)
 		"destroying rdma session\n");
 	if (sc->status < SMBDIRECT_SOCKET_DISCONNECTING)
 		smbdirect_socket_cleanup_work(&sc->disconnect_work);
-	if (sc->status < SMBDIRECT_SOCKET_DISCONNECTED) {
-		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
-			"wait for transport being disconnected\n");
-		wait_event(sc->status_wait, sc->status == SMBDIRECT_SOCKET_DISCONNECTED);
-		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
-			"waited for transport being disconnected\n");
-	}
 
 	/*
-	 * Once we reached SMBDIRECT_SOCKET_DISCONNECTED,
-	 * we should call smbdirect_socket_destroy()
+	 * We don't wait for RDMA_CM_EVENT_DISCONNECTED,
+	 * rdma_disconnect() was already called by
+	 * smbdirect_socket_cleanup_work() if needed
+	 * and smbdirect_socket_destroy() drains the qp,
+	 * destroys it and calls rdma_destroy_id(), which
+	 * only waits for a currently running event handler
+	 * and makes sure no further events are delivered.
+	 * The rest of the disconnect protocol is handled
+	 * by the rdma core asynchronously.
+	 *
+	 * Waiting for RDMA_CM_EVENT_DISCONNECTED could
+	 * take very long or forever, e.g. if the peer
+	 * just disappeared.
 	 */
 	smbdirect_socket_destroy(sc);
 	smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
@@ -741,7 +820,17 @@ static void smbdirect_socket_release_destroy(struct kref *kref)
 	 * in DESTROYED state, before we free the memory.
 	 */
 	smbdirect_socket_destroy_sync(sc);
-	kfree(sc);
+
+	/*
+	 * Only a listener (backlog != -1) is ever dereferenced
+	 * via sc->accept.listener under rcu_read_lock(), see
+	 * smbdirect_listen_orphan_socket(). Other sockets can be
+	 * freed immediately.
+	 */
+	if (sc->listen.backlog != -1) /* was a listener */
+		kfree_rcu(sc, refs.rcu);
+	else
+		kfree(sc);
 }
 
 void smbdirect_socket_release(struct smbdirect_socket *sc)
diff --git a/fs/smb/smbdirect/socket.h b/fs/smb/smbdirect/socket.h
index c09eddd8ad16d5..14114a2567a2ec 100644
--- a/fs/smb/smbdirect/socket.h
+++ b/fs/smb/smbdirect/socket.h
@@ -151,6 +151,12 @@ struct smbdirect_socket {
 		 * the disconnect refcount.
 		 */
 		struct kref destroy;
+
+		/*
+		 * smbdirect_socket_release_destroy() uses
+		 * kfree_rcu(), see accept.listener.
+		 */
+		struct rcu_head rcu;
 	} refs;
 
 	/* RDMA related */
@@ -216,6 +222,16 @@ struct smbdirect_socket {
 		 * only be > 0.
 		 */
 		int backlog;
+		/*
+		 * Sockets on pending or ready that failed
+		 * move themselves to orphaned and queue
+		 * purge_orphaned_work, which releases them.
+		 * So that they are freed while the listener
+		 * is still alive. They still count against
+		 * the backlog until they are released.
+		 */
+		struct list_head orphaned;
+		struct work_struct purge_orphaned_work;
 	} listen;
 
 	/*
@@ -226,7 +242,30 @@ struct smbdirect_socket {
 	 * connection.
 	 */
 	struct {
+		/*
+		 * This is only set, protected by
+		 * listener->listen.lock, while the socket
+		 * is owned by the listener (on its pending,
+		 * ready or orphaned list). The one who clears
+		 * it is responsible for releasing the socket.
+		 *
+		 * The memory of a struct smbdirect_socket is
+		 * freed via kfree_rcu(), so the listener
+		 * can be dereferenced under rcu_read_lock(),
+		 * even if accept.listener is cleared and
+		 * the listener is released concurrently.
+		 */
 		struct smbdirect_socket *listener;
+		/*
+		 * Linkage on one of the listener's
+		 * listen.{pending,ready,orphaned} lists.
+		 *
+		 * accept.list and accept.listener are set
+		 * together under listener->listen.lock before
+		 * smbdirect_accept_connect_request() is called,
+		 * so whenever the socket is on one of those lists
+		 * accept.listener is that listener (never NULL).
+		 */
 		struct list_head list;
 	} accept;
 
@@ -588,6 +627,9 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
 	spin_lock_init(&sc->listen.lock);
 	INIT_LIST_HEAD(&sc->listen.pending);
 	INIT_LIST_HEAD(&sc->listen.ready);
+	INIT_LIST_HEAD(&sc->listen.orphaned);
+	INIT_WORK(&sc->listen.purge_orphaned_work, __smbdirect_socket_disabled_work);
+	disable_work_sync(&sc->listen.purge_orphaned_work);
 	sc->listen.backlog = -1; /* not a listener */
 	init_waitqueue_head(&sc->listen.wait_queue);
 
diff --git a/kernel/fork.c b/kernel/fork.c
index 854448152696b2..a62477ec06b005 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2686,6 +2686,10 @@ struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node)
 		.user_worker	= 1,
 	};
 
+	/* A creator past its fatal signal or its coredump point gets no thread. */
+	if (current->flags & (PF_SIGNALED | PF_POSTCOREDUMP))
+		return ERR_PTR(-EINTR);
+
 	return copy_process(NULL, 0, node, &args);
 }
 
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index f99e196abeea4c..a032560eda0e8e 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -106,6 +106,18 @@ vmlinux_link()
 		${kallsymso} ${btf_vmlinux_bin_o} ${arch_vmlinux_o} ${ldlibs}
 }
 
+# Check if kallsymso_prev and kallsymso differ
+# If symbol sizes within ${kallsymso} change, any symbols within vmlinux are
+# likely to shift, invalidating ${kallsymso}.
+# Since file size can remain unchanged even if symbol sizes change, compare the
+# actual symbols instead of relying on file size only.
+kallsymso_changed()
+{
+	${NM} -n "${kallsymso_prev}" > "${kallsymso_prev}.sym"
+	${NM} -n "${kallsymso}" > "${kallsymso}.sym"
+	! cmp -s "${kallsymso_prev}.sym" "${kallsymso}.sym"
+}
+
 # Create ${2}.o file with all symbols from the ${1} object file
 kallsyms()
 {
@@ -126,6 +138,7 @@ kallsyms()
 	${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} \
 	      ${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} -c -o "${2}.o" "${2}.S"
 
+	kallsymso_prev="${kallsymso:-}"
 	kallsymso=${2}.o
 }
 
@@ -255,7 +268,12 @@ if is_enabled CONFIG_KALLSYMS; then
 	sysmap_and_kallsyms .tmp_vmlinux2
 	size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
 
-	if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
+	# Due to alignment, file size of the kallsymso object file might remain
+	# unchanged even if individual symbols within change size. Changed
+	# symbol sizes can still shift other symbols, though. Therefore, don't
+	# rely on file size alone.
+	if [ $size1 -ne $size2 ] || kallsymso_changed || \
+			[ -n "${KALLSYMS_EXTRA_PASS}" ]; then
 		vmlinux_link .tmp_vmlinux3
 		sysmap_and_kallsyms .tmp_vmlinux3
 	fi

3/2 2026/10/30 15:01 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 17118
							output: 42
							thoughts: 1971
						

Thoughts:
**Evaluation of Patch Series for Syzkaller Fuzzing**

Alright, let's break this down. The objective is to determine if this patch series is suitable for fuzzing with syzkaller, and I've got a pretty good feeling about this based on the file modifications. Let's see...

My initial scan reveals changes across several areas: `drivers/iio/light/hid-sensor-als.c`, `drivers/platform/cznic/turris-omnia-mcu-base.c`, `fs/exec.c`, `fs/smb/server/server.c`, `fs/smb/smbdirect/...`, `kernel/fork.c`, and `scripts/link-vmlinux.sh`. The commit title "syz-cluster: applied patch under review" suggests this is a syz-cluster-generated patch series, possibly from Linux-next or similar, which often includes patches flagged for syzkaller investigation.

Immediately, changes in `fs/exec.c`, `kernel/fork.c`, and `fs/smb/server/server.c` grab my attention. These are *core* subsystems: VFS (Virtual File System), process management, and a network-accessible SMB server, respectively. These are all high-value targets for fuzzing.

Let's dive deeper. I want to pinpoint the *exact* impact of each modification, focusing on whether it touches reachable code. The rules say "WorthFuzzing=true whenever the patch touches reachable executable code, including: Core Subsystems: ... VFS, or syscall handling."

1.  `fs/exec.c`: The crucial change is within `begin_new_exec`. Specifically, `io_uring_task_cancel()` has been moved to a different location in the function. This function handles `execve` (executing new programs), and the interaction with `io_uring` is now being tweaked. This is a very interesting change, and any potential issues here could be exploitable through standard system calls. Since it's changing the VFS and how it interacts with `io_uring`, this screams "fuzz me!"

2.  `kernel/fork.c`: We're looking at `create_io_thread`, used by `io_uring`'s "io-wq" workers. A check for `PF_SIGNALED | PF_POSTCOREDUMP` has been added. This impacts how io threads are created in the kernel. Anything interacting with process creation is a potential area for fuzzing. `io_uring` is a known attack surface, and a modification to how it spawns threads warrants investigation. This likely means it will need `CONFIG_IO_URING`, `CONFIG_IO_URING_DEFER_TASK_WORK`, and possibly `CONFIG_IO_URING_FS`.

3.  `fs/smb/server/server.c`: The addition of `wait_for_neg` and the accompanying `wait_event` in `queue_ksmbd_work`. This clearly affects the SMB server's work queue and negotiation process. The SMB server is network-facing, and network-facing code is gold for fuzzing with syzkaller. Expect this to need `CONFIG_SMB_SERVER`, `CONFIG_CIFS`, and possibly other SMB-related configs to be enabled.

4.  `fs/smb/smbdirect/...`: Major refactoring of SMBDirect (SMB over RDMA) code. This includes connection handling, locking, and RCU updates. This one's definitely interesting since it modifies networking code. It's likely related to SMBDirect, so we'll be looking for relevant configs like `CONFIG_SMB_DIRECT` or similar.

5.  `drivers/iio/light/hid-sensor-als.c`: This change is less likely to be immediately critical from a system-wide perspective, but changes to device drivers can still reveal useful fuzzing targets.

6.  `drivers/platform/cznic/turris-omnia-mcu-base.c`: Again, device driver-specific. This adds a module device table, suggesting it might enhance device discovery and loading.

7.  `scripts/link-vmlinux.sh`: Build scripts are not usually targets, but it's important to know what kernel config this series needs.

Therefore, because this touches the core subsystems of exec, process creation, and network-accessible SMB server, I'm confident that this series *warrants fuzzing*.

Based on the nature of these changes, I'll need to focus on these areas:

*   `fs/exec.c` - `begin_new_exec`: Focus on how `io_uring_task_cancel()` affects the execution flow.
*   `kernel/fork.c` -


4/2 2026/10/30 15:01 tool grepper
0m Args:
{
  "Expression": "void io_uring_task_cancel",
  "PathPrefixes": [
    "io_uring",
    "include/linux/io_uring"
  ]
}

Results:
{
  "Output": "no matches"
}

5/2 2026/10/30 15:01 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 20170
							output: 22
							thoughts: 15
						

Thoughts:
Okay, here's my attempt at summarizing that thought process, keeping in mind the user is an expert:

**Locating `io_uring_task_cancel`**

Alright, I need to get my hands on the definition of `io_uring_task_cancel`. It's a critical function for managing asynchronous I/O with io_uring, and understanding its exact behavior and implementation details is key. I'm probably looking at the kernel source, specifically within the io_uring subsystem, maybe somewhere related to task management or cancellation handling. I need to figure out exactly how it interacts with the submission queue and the completion queue and what state transitions it triggers. Depending on the kernel version, the exact location and signature might vary slightly, so I'll need to be mindful of that. Let's dig in and track it down.



6/2 2026/10/30 15:01 tool grepper
0m Args:
{
  "Expression": "io_uring_task_cancel\\("
}

Results:
{
  "Output": "fs/exec.c=1125=int begin_new_exec(struct linux_binprm * bprm)\n--\nfs/exec.c-1152-\t */\nfs/exec.c:1153:\tio_uring_task_cancel();\nfs/exec.c-1154-\n--\ninclude/linux/io_uring.h=17=static inline void io_uring_files_cancel(void)\n--\ninclude/linux/io_uring.h-21-}\ninclude/linux/io_uring.h:22:static inline void io_uring_task_cancel(void)\ninclude/linux/io_uring.h-23-{\n--\ninclude/linux/io_uring.h=32=static inline int io_uring_fork(struct task_struct *tsk)\n--\ninclude/linux/io_uring.h-39-#else\ninclude/linux/io_uring.h:40:static inline void io_uring_task_cancel(void)\ninclude/linux/io_uring.h-41-{\n"
}

7/2 2026/10/30 15:02 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 20648
							output: 36
							thoughts: 21
						

Thoughts:
Okay, let's dive into this. I'm going to start by looking at `include/linux/io_uring.h`, specifically around line 22. My goal here is to get a handle on the foundational structure of the io_uring system. I need to understand the basic building blocks before I can even start to think about the more complex interactions and optimizations. This header file is the logical place to start – it should define the key data structures and possibly lay out the fundamental concepts of how I/O requests are represented and processed within the kernel. I'm expecting to see definitions for things like submission queue entries (SQEs), completion queue entries (CQEs), and the overall io_uring instance itself. I'm looking for the very core of the design philosophy here. The comments in the file, if present, should also be important.



8/2 2026/10/30 15:02 tool read-file
0m Args:
{
  "File": "include/linux/io_uring.h",
  "FirstLine": 15,
  "LineCount": 40
}

Results:
{
  "Contents": "  15:\tint __io_uring_fork(struct task_struct *tsk);\n  16:\t\n  17:\tstatic inline void io_uring_files_cancel(void)\n  18:\t{\n  19:\t\tif (current-\u003eio_uring)\n  20:\t\t\t__io_uring_cancel(false);\n  21:\t}\n  22:\tstatic inline void io_uring_task_cancel(void)\n  23:\t{\n  24:\t\tif (current-\u003eio_uring)\n  25:\t\t\t__io_uring_cancel(true);\n  26:\t}\n  27:\tstatic inline void io_uring_free(struct task_struct *tsk)\n  28:\t{\n  29:\t\tif (tsk-\u003eio_uring || tsk-\u003eio_uring_restrict)\n  30:\t\t\t__io_uring_free(tsk);\n  31:\t}\n  32:\tstatic inline int io_uring_fork(struct task_struct *tsk)\n  33:\t{\n  34:\t\tif (tsk-\u003eio_uring_restrict)\n  35:\t\t\treturn __io_uring_fork(tsk);\n  36:\t\n  37:\t\treturn 0;\n  38:\t}\n  39:\t#else\n  40:\tstatic inline void io_uring_task_cancel(void)\n  41:\t{\n  42:\t}\n  43:\tstatic inline void io_uring_files_cancel(void)\n  44:\t{\n  45:\t}\n  46:\tstatic inline void io_uring_free(struct task_struct *tsk)\n  47:\t{\n  48:\t}\n  49:\tstatic inline const char *io_uring_get_opcode(u8 opcode)\n  50:\t{\n  51:\t\treturn \"\";\n  52:\t}\n  53:\tstatic inline bool io_is_uring_fops(struct file *file)\n  54:\t{\n"
}

9/2 2026/10/30 15:02 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 21390
							output: 19
							thoughts: 117
						

Thoughts:
**Investigating the `io_uring_task_cancel()` Call Flow**

Okay, so I'm digging into how `io_uring_task_cancel()` actually works internally. It looks like it directly calls `__io_uring_cancel(true)`. That's a reasonable starting point, but I need to understand the larger context. My immediate next step is to figure out where that thread is created, because cancellation is most useful when the thread being cancelled can be identified. I need to understand the conditions that might prevent that thread from even being created in the first place.

I see a bit of interesting code in `kernel/fork.c`, within `create_io_thread`. There's this check: `if (current->flags & (PF_SIGNALED | PF_POSTCOREDUMP)) return ERR_PTR(-EINTR);`. That’s relevant! It seems that if the creating process is in a bad state – either it's been signaled or it’s in the process of dumping core – then an IO thread might not even get spawned. That's good to know. It has implications for how robust the cancellation process is when a parent process is in an odd state.

I'm now going to have to find out where `create_io_thread` is actually *called*. I need to see where it sits in the larger io_uring lifecycle. I'll reach for `grepper` and see where that function is referenced across the codebase. That should give me the broader picture I need to understand the full flow and identify potential bottlenecks or areas for optimization regarding thread creation and cancellation.



10/2 2026/10/30 15:02 tool grepper
0m Args:
{
  "Expression": "create_io_thread"
}

Results:
{
  "Output": "include/linux/sched/task.h=99=struct task_struct *copy_process(struct pid *pid, int trace, int node,\ninclude/linux/sched/task.h-100-\t\t\t\t struct kernel_clone_args *args);\ninclude/linux/sched/task.h:101:struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node);\ninclude/linux/sched/task.h-102-struct task_struct *fork_idle(int);\n--\nio_uring/io-wq.c=844=static void create_worker_cont(struct callback_head *cb)\n--\nio_uring/io-wq.c-854-\tacct = io_wq_get_acct(worker);\nio_uring/io-wq.c:855:\ttsk = create_io_thread(io_wq_worker, worker, NUMA_NO_NODE);\nio_uring/io-wq.c-856-\tif (!IS_ERR(tsk)) {\n--\nio_uring/io-wq.c=896=static bool create_io_worker(struct io_wq *wq, struct io_wq_acct *acct)\n--\nio_uring/io-wq.c-919-\nio_uring/io-wq.c:920:\ttsk = create_io_thread(io_wq_worker, worker, NUMA_NO_NODE);\nio_uring/io-wq.c-921-\tif (!IS_ERR(tsk)) {\n--\nio_uring/sqpoll.c=436=__cold int io_sq_offload_create(struct io_ring_ctx *ctx,\n--\nio_uring/sqpoll.c-507-\t\tsqd-\u003etask_tgid = current-\u003etgid;\nio_uring/sqpoll.c:508:\t\ttsk = create_io_thread(io_sq_thread, sqd, NUMA_NO_NODE);\nio_uring/sqpoll.c-509-\t\tif (IS_ERR(tsk)) {\n--\nkernel/fork.c=2651=struct task_struct * __init fork_idle(int cpu)\n--\nkernel/fork.c-2676- */\nkernel/fork.c:2677:struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node)\nkernel/fork.c-2678-{\n"
}

11/2 2026/10/30 15:02 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 22477
							output: 38
							thoughts: 326
						

Thoughts:
**Analyzing io_uring and execve Interaction**

Okay, so I'm diving into this io_uring/io-wq worker thread management, and it looks like `create_io_thread` is a key function. I see it's called from both `io-wq.c` (specifically `create_worker_cont` and `create_io_worker`) and `sqpoll.c` (`io_sq_offload_create`). The interesting bit is how it interacts with `execve`, specifically inside `begin_new_exec`. That comment in `begin_new_exec` really jumps out at me: "Cancel any io_uring activity across execve. This runs task work that may still create an io-wq worker, so do it while de_thread() can still zap it."

Right, that makes the interaction even clearer now, along with the `create_io_thread` check for fatal signals and coredumps: "A creator past its fatal signal or its coredump point gets no thread. if (current->flags & (PF_SIGNALED | PF_POSTCOREDUMP)) return ERR_PTR(-EINTR);". So it seems like we're fixing a race condition or a bug that's happening between the creation of io_uring / io-wq worker threads and when a thread exits (due to execve). We're trying to prevent creating worker threads right before we exit.

Now, let's switch gears a bit. I need to check out what's going on around lines 371-405 in `fs/smb/server/server.c`. Let's dig into that code to see how it's fitting into this overall picture.



12/2 2026/10/30 15:02 tool read-file
0m Args:
{
  "File": "fs/smb/server/server.c",
  "FirstLine": 370,
  "LineCount": 40
}

Results:
{
  "Contents": " 370:\t */\n 371:\tstatic int queue_ksmbd_work(struct ksmbd_conn *conn)\n 372:\t{\n 373:\t\tstruct ksmbd_work *work;\n 374:\t\tbool wait_for_neg = ksmbd_conn_new(conn) || ksmbd_conn_need_negotiate(conn);\n 375:\t\tint err;\n 376:\t\n 377:\t\terr = ksmbd_init_smb_server(conn);\n 378:\t\tif (err)\n 379:\t\t\treturn 0;\n 380:\t\n 381:\t\twork = ksmbd_alloc_work_struct();\n 382:\t\tif (!work) {\n 383:\t\t\tpr_err(\"allocation for work failed\\n\");\n 384:\t\t\treturn -ENOMEM;\n 385:\t\t}\n 386:\t\n 387:\t\twork-\u003econn = conn;\n 388:\t\twork-\u003erequest_buf = conn-\u003erequest_buf;\n 389:\t\tconn-\u003erequest_buf = NULL;\n 390:\t\n 391:\t\tksmbd_conn_enqueue_request(work);\n 392:\t\tksmbd_conn_r_count_inc(conn);\n 393:\t\t/* update activity on connection */\n 394:\t\tconn-\u003elast_active = jiffies;\n 395:\t\tINIT_WORK(\u0026work-\u003ework, handle_ksmbd_work);\n 396:\t\tksmbd_queue_work(work);\n 397:\t\t/* Negotiation can change conn-\u003eops, finish it before reading another PDU. */\n 398:\t\tif (wait_for_neg)\n 399:\t\t\twait_event(conn-\u003ereq_running_q,\n 400:\t\t\t\t   atomic_read(\u0026conn-\u003ereq_running) == 0);\n 401:\t\treturn 0;\n 402:\t}\n 403:\t\n 404:\tstatic int ksmbd_server_process_request(struct ksmbd_conn *conn)\n 405:\t{\n 406:\t\treturn queue_ksmbd_work(conn);\n 407:\t}\n 408:\t\n 409:\tstatic int ksmbd_server_terminate_conn(struct ksmbd_conn *conn)\n"
}

13/2 2026/10/30 15:02 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 23828
							output: 28
							thoughts: 45
						

Thoughts:
Okay, here's the summary, tailored for an expert audience, in the first person, reflecting the described thought process:

**Diving into the SMB Direct Implementation**

Alright, time to dig into the `fs/smb/smbdirect/` directory. That's the logical next step in understanding this subsystem. Hold on...I need to refresh my memory, what exactly is SMB Direct in the context of the Linux kernel? I recall the general concepts, RDMA, efficient network transport, but the specifics are fuzzy.

Okay, best to start with the Kconfig files. Let's see how SMB Direct is configured and conditionally compiled. Examining the Kconfig entries will give me a solid high-level understanding of the feature's dependencies, options, and how it is integrated with the larger SMB stack. From there, I can get a clearer picture of its role and how to proceed with a more in-depth code review.



14/2 2026/10/30 15:03 tool grepper
0m Args:
{
  "Expression": "smbdirect",
  "PathPrefixes": [
    "fs/smb"
  ]
}

Results:
{
  "Output": "\nFull output is too long, showing 200 out of 3818 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (36 files in total):\nfs/smb/Kconfig:1\nfs/smb/Makefile:1\nfs/smb/client/Kconfig:1\nfs/smb/client/Makefile:1\nfs/smb/client/cifs_debug.c:1\nfs/smb/client/cifsglob.h:2\nfs/smb/client/cifssmb.c:1\nfs/smb/client/connect.c:1\nfs/smb/client/file.c:3\nfs/smb/client/smb1transport.c:1\nfs/smb/client/smb2ops.c:3\nfs/smb/client/smb2pdu.c:9\nfs/smb/client/smbdirect.c:42\nfs/smb/client/smbdirect.h:7\nfs/smb/client/transport.c:1\nfs/smb/server/Kconfig:1\nfs/smb/server/connection.c:2\nfs/smb/server/connection.h:5\nfs/smb/server/smb2pdu.c:5\nfs/smb/server/transport_rdma.c:45\nfs/smb/server/transport_rdma.h:1\nfs/smb/smbdirect/Kconfig:1\nfs/smb/smbdirect/Makefile:3\nfs/smb/smbdirect/accept.c:156\nfs/smb/smbdirect/connect.c:160\nfs/smb/smbdirect/connection.c:276\nfs/smb/smbdirect/debug.c:4\nfs/smb/smbdirect/devices.c:45\nfs/smb/smbdirect/internal.h:49\nfs/smb/smbdirect/listen.c:58\nfs/smb/smbdirect/main.c:38\nfs/smb/smbdirect/mr.c:75\nfs/smb/smbdirect/pdu.h:3\nfs/smb/smbdirect/rw.c:31\nfs/smb/smbdirect/socket.c:131\nfs/smb/smbdirect/socket.h:90\n\nfs/smb/Kconfig=6=source \"fs/smb/server/Kconfig\"\nfs/smb/Kconfig:7:source \"fs/smb/smbdirect/Kconfig\"\nfs/smb/Kconfig-8-\n--\nfs/smb/Makefile=3=obj-$(CONFIG_SMBFS)\t\t+= common/\nfs/smb/Makefile:4:obj-$(CONFIG_SMBDIRECT)\t\t+= smbdirect/\nfs/smb/Makefile-5-obj-$(CONFIG_CIFS)\t\t+= client/\n--\nfs/smb/client/Kconfig=2=config CIFS\n--\nfs/smb/client/Kconfig-42-\t  for DFS (hierarchical name space), secure per-user session\nfs/smb/client/Kconfig:43:\t  establishment via Kerberos or NTLMv2, RDMA (smbdirect), advanced\nfs/smb/client/Kconfig-44-\t  security features, per-share encryption, packet-signing, snapshots,\n--\nfs/smb/client/Makefile=29=cifs-$(CONFIG_CIFS_FSCACHE) += fscache.o\nfs/smb/client/Makefile-30-\nfs/smb/client/Makefile:31:cifs-$(CONFIG_CIFS_SMB_DIRECT) += smbdirect.o\nfs/smb/client/Makefile-32-\n--\nfs/smb/client/cifs_debug.c-24-#ifdef CONFIG_CIFS_SMB_DIRECT\nfs/smb/client/cifs_debug.c:25:#include \"smbdirect.h\"\nfs/smb/client/cifs_debug.c-26-#endif\n--\nfs/smb/client/cifsglob.h=1490=struct cifs_io_subrequest {\n--\nfs/smb/client/cifsglob.h-1505-#ifdef CONFIG_CIFS_SMB_DIRECT\nfs/smb/client/cifsglob.h:1506:\tstruct smbdirect_mr_io\t\t*mr;\nfs/smb/client/cifsglob.h-1507-#endif\n--\nfs/smb/client/cifsglob.h=1949=require use of the stronger protocol */\n--\nfs/smb/client/cifsglob.h-2057- *\t\t\t\t-\u003eoplock_break_cancelled\nfs/smb/client/cifsglob.h:2058: * smbdirect_mr-\u003emutex\t\tRDMA memory region management\t(SMBDirect only)\nfs/smb/client/cifsglob.h-2059- * mid_q_entry-\u003emid_lock\tmid_q_entry-\u003ecallback           alloc_mid\n--\nfs/smb/client/cifssmb.c-37-#include \"fscache.h\"\nfs/smb/client/cifssmb.c:38:#include \"smbdirect.h\"\nfs/smb/client/cifssmb.c-39-#ifdef CONFIG_CIFS_DFS_UPCALL\n--\nfs/smb/client/connect.c-44-#include \"smb2proto.h\"\nfs/smb/client/connect.c:45:#include \"smbdirect.h\"\nfs/smb/client/connect.c-46-#include \"dns_resolve.h\"\n--\nfs/smb/client/file.c-33-#include \"fscache.h\"\nfs/smb/client/file.c:34:#include \"smbdirect.h\"\nfs/smb/client/file.c-35-#include \"fs_context.h\"\n--\nfs/smb/client/file.c=46=static void cifs_prepare_write(struct netfs_io_subrequest *subreq)\n--\nfs/smb/client/file.c-99-\tif (server-\u003esmbd_conn) {\nfs/smb/client/file.c:100:\t\tconst struct smbdirect_socket_parameters *sp =\nfs/smb/client/file.c-101-\t\t\tsmbd_get_parameters(server-\u003esmbd_conn);\n--\nfs/smb/client/file.c=153=static int cifs_prepare_read(struct netfs_io_subrequest *subreq)\n--\nfs/smb/client/file.c-193-\tif (server-\u003esmbd_conn) {\nfs/smb/client/file.c:194:\t\tconst struct smbdirect_socket_parameters *sp =\nfs/smb/client/file.c-195-\t\t\tsmbd_get_parameters(server-\u003esmbd_conn);\n--\nfs/smb/client/smb1transport.c-29-#include \"cifs_debug.h\"\nfs/smb/client/smb1transport.c:30:#include \"smbdirect.h\"\nfs/smb/client/smb1transport.c-31-#include \"compress.h\"\n--\nfs/smb/client/smb2ops.c-27-#include \"cifs_ioctl.h\"\nfs/smb/client/smb2ops.c:28:#include \"smbdirect.h\"\nfs/smb/client/smb2ops.c-29-#include \"fscache.h\"\n--\nfs/smb/client/smb2ops.c=508=smb3_negotiate_wsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)\n--\nfs/smb/client/smb2ops.c-517-\tif (server-\u003erdma) {\nfs/smb/client/smb2ops.c:518:\t\tconst struct smbdirect_socket_parameters *sp =\nfs/smb/client/smb2ops.c-519-\t\t\tsmbd_get_parameters(server-\u003esmbd_conn);\n--\nfs/smb/client/smb2ops.c=559=smb3_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)\n--\nfs/smb/client/smb2ops.c-568-\tif (server-\u003erdma) {\nfs/smb/client/smb2ops.c:569:\t\tconst struct smbdirect_socket_parameters *sp =\nfs/smb/client/smb2ops.c-570-\t\t\tsmbd_get_parameters(server-\u003esmbd_conn);\n--\nfs/smb/client/smb2pdu.c-38-#include \"cifs_spnego.h\"\nfs/smb/client/smb2pdu.c:39:#include \"smbdirect.h\"\nfs/smb/client/smb2pdu.c-40-#include \"trace.h\"\n--\nfs/smb/client/smb2pdu.c=4585=smb2_new_read_req(void **buf, unsigned int *total_len,\n--\nfs/smb/client/smb2pdu.c-4624-\t * If we want to do a RDMA write, fill in and append\nfs/smb/client/smb2pdu.c:4625:\t * smbdirect_buffer_descriptor_v1 to the end of read request\nfs/smb/client/smb2pdu.c-4626-\t */\nfs/smb/client/smb2pdu.c-4627-\tif (rdata \u0026\u0026 smb3_use_rdma_offload(io_parms)) {\nfs/smb/client/smb2pdu.c:4628:\t\tstruct smbdirect_buffer_descriptor_v1 *v1;\nfs/smb/client/smb2pdu.c-4629-\t\tbool need_invalidate = server-\u003edialect == SMB30_PROT_ID;\n--\nfs/smb/client/smb2pdu.c-4643-\t\treq-\u003eReadChannelInfoLength =\nfs/smb/client/smb2pdu.c:4644:\t\t\tcpu_to_le16(sizeof(struct smbdirect_buffer_descriptor_v1));\nfs/smb/client/smb2pdu.c:4645:\t\tv1 = (struct smbdirect_buffer_descriptor_v1 *) \u0026req-\u003eBuffer[0];\nfs/smb/client/smb2pdu.c-4646-\t\tsmbd_mr_fill_buffer_descriptor(rdata-\u003emr, v1);\n--\nfs/smb/client/smb2pdu.c=5163=smb2_async_writev(struct cifs_io_subrequest *wdata)\n--\nfs/smb/client/smb2pdu.c-5232-\t * If we want to do a server RDMA read, fill in and append\nfs/smb/client/smb2pdu.c:5233:\t * smbdirect_buffer_descriptor_v1 to the end of write request\nfs/smb/client/smb2pdu.c-5234-\t */\nfs/smb/client/smb2pdu.c-5235-\tif (smb3_use_rdma_offload(io_parms)) {\nfs/smb/client/smb2pdu.c:5236:\t\tstruct smbdirect_buffer_descriptor_v1 *v1;\nfs/smb/client/smb2pdu.c-5237-\t\tbool need_invalidate = server-\u003edialect == SMB30_PROT_ID;\n--\nfs/smb/client/smb2pdu.c-5254-\t\treq-\u003eWriteChannelInfoLength =\nfs/smb/client/smb2pdu.c:5255:\t\t\tcpu_to_le16(sizeof(struct smbdirect_buffer_descriptor_v1));\nfs/smb/client/smb2pdu.c:5256:\t\tv1 = (struct smbdirect_buffer_descriptor_v1 *) \u0026req-\u003eBuffer[0];\nfs/smb/client/smb2pdu.c-5257-\t\tsmbd_mr_fill_buffer_descriptor(wdata-\u003emr, v1);\n--\nfs/smb/client/smbdirect.c-7-\nfs/smb/client/smbdirect.c:8:#include \"smbdirect.h\"\nfs/smb/client/smbdirect.c-9-#include \"cifs_debug.h\"\n--\nfs/smb/client/smbdirect.c=104=MODULE_PARM_DESC(smbd_logging_level,\n--\nfs/smb/client/smbdirect.c-106-\nfs/smb/client/smbdirect.c:107:static bool smbd_logging_needed(struct smbdirect_socket *sc,\nfs/smb/client/smbdirect.c-108-\t\t\t\tvoid *private_ptr,\n--\nfs/smb/client/smbdirect.c-132-\nfs/smb/client/smbdirect.c:133:static void smbd_logging_vaprintf(struct smbdirect_socket *sc,\nfs/smb/client/smbdirect.c-134-\t\t\t\t  const char *func,\n--\nfs/smb/client/smbdirect.c=145=do {\t\t\t\t\t\t\t\t\t\\\n--\nfs/smb/client/smbdirect.c-166-\nfs/smb/client/smbdirect.c:167:static int smbd_post_send_full_iter(struct smbdirect_socket *sc,\nfs/smb/client/smbdirect.c:168:\t\t\t\t    struct smbdirect_send_batch *batch,\nfs/smb/client/smbdirect.c-169-\t\t\t\t    struct iov_iter *iter,\n--\nfs/smb/client/smbdirect.c-174-\t/*\nfs/smb/client/smbdirect.c:175:\t * smbdirect_connection_send_single_iter() respects the\nfs/smb/client/smbdirect.c-176-\t * negotiated max_send_size, so we need to\n--\nfs/smb/client/smbdirect.c-182-\nfs/smb/client/smbdirect.c:183:\t\trc = smbdirect_connection_send_single_iter(sc,\nfs/smb/client/smbdirect.c-184-\t\t\t\t\t\t\t   batch,\n--\nfs/smb/client/smbdirect.c=202=void smbd_destroy(struct TCP_Server_Info *server)\n--\nfs/smb/client/smbdirect.c-210-\nfs/smb/client/smbdirect.c:211:\tsmbdirect_socket_release(info-\u003esocket);\nfs/smb/client/smbdirect.c-212-\n--\nfs/smb/client/smbdirect.c=252=static struct smbd_connection *_smbd_get_connection(\n--\nfs/smb/client/smbdirect.c-256-\tstruct smbd_connection *info;\nfs/smb/client/smbdirect.c:257:\tstruct smbdirect_socket *sc;\nfs/smb/client/smbdirect.c:258:\tstruct smbdirect_socket_parameters init_params = {};\nfs/smb/client/smbdirect.c:259:\tstruct smbdirect_socket_parameters *sp;\nfs/smb/client/smbdirect.c-260-\t__be16 *sport;\n--\nfs/smb/client/smbdirect.c-305-\t\treturn NULL;\nfs/smb/client/smbdirect.c:306:\tret = smbdirect_socket_create_kern(net, \u0026sc);\nfs/smb/client/smbdirect.c-307-\tif (ret)\nfs/smb/client/smbdirect.c-308-\t\tgoto socket_init_failed;\nfs/smb/client/smbdirect.c:309:\tsmbdirect_socket_set_logging(sc, NULL, smbd_logging_needed, smbd_logging_vaprintf);\nfs/smb/client/smbdirect.c:310:\tret = smbdirect_socket_set_initial_parameters(sc, sp);\nfs/smb/client/smbdirect.c-311-\tif (ret)\nfs/smb/client/smbdirect.c-312-\t\tgoto set_params_failed;\nfs/smb/client/smbdirect.c:313:\tret = smbdirect_socket_set_kernel_settings(sc, IB_POLL_SOFTIRQ, GFP_KERNEL);\nfs/smb/client/smbdirect.c-314-\tif (ret)\n--\nfs/smb/client/smbdirect.c-323-\nfs/smb/client/smbdirect.c:324:\tret = smbdirect_connect_sync(sc, dstaddr);\nfs/smb/client/smbdirect.c-325-\tif (ret) {\n--\nfs/smb/client/smbdirect.c-336-set_params_failed:\nfs/smb/client/smbdirect.c:337:\tsmbdirect_socket_release(sc);\nfs/smb/client/smbdirect.c-338-socket_init_failed:\n--\nfs/smb/client/smbdirect.c-342-\nfs/smb/client/smbdirect.c:343:const struct smbdirect_socket_parameters *smbd_get_parameters(struct smbd_connection *conn)\nfs/smb/client/smbdirect.c-344-{\nfs/smb/client/smbdirect.c-345-\tif (unlikely(!conn-\u003esocket)) {\nfs/smb/client/smbdirect.c:346:\t\tstatic const struct smbdirect_socket_parameters zero_params;\nfs/smb/client/smbdirect.c-347-\n--\nfs/smb/client/smbdirect.c-350-\nfs/smb/client/smbdirect.c:351:\treturn smbdirect_socket_get_current_parameters(conn-\u003esocket);\nfs/smb/client/smbdirect.c-352-}\n--\nfs/smb/client/smbdirect.c=354=struct smbd_connection *smbd_get_connection(\n--\nfs/smb/client/smbdirect.c-357-\tstruct smbd_connection *ret;\nfs/smb/client/smbdirect.c:358:\tconst struct smbdirect_socket_parameters *sp;\nfs/smb/client/smbdirect.c-359-\tint port = SMBD_PORT;\n--\nfs/smb/client/smbdirect.c=396=int smbd_recv(struct smbd_connection *info, struct msghdr *msg)\nfs/smb/client/smbdirect.c-397-{\nfs/smb/client/smbdirect.c:398:\tstruct smbdirect_socket *sc = info-\u003esocket;\nfs/smb/client/smbdirect.c-399-\nfs/smb/client/smbdirect.c:400:\tif (!smbdirect_connection_is_connected(sc))\nfs/smb/client/smbdirect.c-401-\t\treturn -ENOTCONN;\nfs/smb/client/smbdirect.c-402-\nfs/smb/client/smbdirect.c:403:\treturn smbdirect_connection_recvmsg(sc, msg, 0);\nfs/smb/client/smbdirect.c-404-}\n--\n\n"
}

15/2 2026/10/30 15:03 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 29153
							output: 37
							thoughts: 17
						

Thoughts:
Here's a summary of my thought process:

**Diving into the `Kconfig` of `fs/smb/smbdirect`**

Okay, time to get started. Let's start by zeroing in on the configuration options for the SMB Direct file system. My immediate instinct is to check the `Kconfig` file within `fs/smb/smbdirect`. This is where all the build-time configuration options and dependencies for this specific subsystem are defined. I expect to find details on enabling/disabling the feature set, dependencies on other kernel components (like RDMA libraries or specific network protocols), and any other configurable aspects of the SMB Direct implementation. Understanding the `Kconfig` will provide a foundational understanding of what's possible and how this part of the kernel is configured. This is always the first logical step, isn't it?



16/2 2026/10/30 15:03 tool read-file
0m Args:
{
  "File": "fs/smb/smbdirect/Kconfig",
  "FirstLine": 1,
  "LineCount": 30
}

Results:
{
  "Contents": "   1:\t# SPDX-License-Identifier: GPL-2.0-or-later\n   2:\t#\n   3:\t# smbdirect configuration\n   4:\t\n   5:\tconfig SMBDIRECT\n   6:\t\tdef_tristate n\n   7:\t\tdepends on INFINIBAND \u0026\u0026 INFINIBAND_ADDR_TRANS\n   8:\t\tdepends on m || INFINIBAND=y\n   9:\t\tselect SG_POOL\n"
}

17/2 2026/10/30 15:03 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 29503
							output: 27
							thoughts: 36
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Investigating the `SMBDIRECT` Dependency**

Right, so `SMBDIRECT` is enabled... but what exactly triggers that selection in the kernel configuration? I need to quickly trace back the dependencies. I'll head straight to the Kconfig files for both the server and client-side SMB implementations. Specifically, I need to check `fs/smb/server/Kconfig` and `fs/smb/client/Kconfig`. Those are the usual suspects. I'm expecting to find either a direct `depends on` clause or a chain of dependencies that ultimately pull in `SMBDIRECT`. No need to dawdle, let's see what the configuration logic reveals. This should be a straightforward cross-reference.



18/2 2026/10/30 15:03 tool grepper
0m Args:
{
  "Expression": "SMBDIRECT",
  "PathPrefixes": [
    "fs/smb"
  ]
}

Results:
{
  "Output": "\nFull output is too long, showing 200 out of 1911 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (23 files in total):\nfs/smb/Makefile:1\nfs/smb/client/Kconfig:1\nfs/smb/client/smbdirect.c:5\nfs/smb/client/smbdirect.h:2\nfs/smb/server/Kconfig:2\nfs/smb/server/Makefile:1\nfs/smb/server/transport_rdma.c:18\nfs/smb/server/transport_rdma.h:1\nfs/smb/smbdirect/Kconfig:1\nfs/smb/smbdirect/Makefile:1\nfs/smb/smbdirect/accept.c:82\nfs/smb/smbdirect/connect.c:101\nfs/smb/smbdirect/connection.c:101\nfs/smb/smbdirect/debug.c:1\nfs/smb/smbdirect/devices.c:1\nfs/smb/smbdirect/internal.h:5\nfs/smb/smbdirect/listen.c:28\nfs/smb/smbdirect/main.c:1\nfs/smb/smbdirect/mr.c:40\nfs/smb/smbdirect/pdu.h:9\nfs/smb/smbdirect/rw.c:3\nfs/smb/smbdirect/socket.c:97\nfs/smb/smbdirect/socket.h:87\n\nfs/smb/Makefile=3=obj-$(CONFIG_SMBFS)\t\t+= common/\nfs/smb/Makefile:4:obj-$(CONFIG_SMBDIRECT)\t\t+= smbdirect/\nfs/smb/Makefile-5-obj-$(CONFIG_CIFS)\t\t+= client/\n--\nfs/smb/client/Kconfig=181=config CIFS_SMB_DIRECT\n--\nfs/smb/client/Kconfig-184-\tdepends on CIFS=m || INFINIBAND=y\nfs/smb/client/Kconfig:185:\tselect SMBDIRECT\nfs/smb/client/Kconfig-186-\thelp\n--\nfs/smb/client/smbdirect.c=107=static bool smbd_logging_needed(struct smbdirect_socket *sc,\n--\nfs/smb/client/smbdirect.c-111-{\nfs/smb/client/smbdirect.c:112:#define BUILD_BUG_SAME(x) BUILD_BUG_ON(x != SMBDIRECT_LOG_ ##x)\nfs/smb/client/smbdirect.c-113-\tBUILD_BUG_SAME(ERR);\n--\nfs/smb/client/smbdirect.c-115-#undef BUILD_BUG_SAME\nfs/smb/client/smbdirect.c:116:#define BUILD_BUG_SAME(x) BUILD_BUG_ON(x != SMBDIRECT_ ##x)\nfs/smb/client/smbdirect.c-117-\tBUILD_BUG_SAME(LOG_OUTGOING);\n--\nfs/smb/client/smbdirect.c=252=static struct smbd_connection *_smbd_get_connection(\n--\nfs/smb/client/smbdirect.c-269-\t\t */\nfs/smb/client/smbdirect.c:270:\t\tport_flags |= SMBDIRECT_FLAG_PORT_RANGE_ONLY_IW;\nfs/smb/client/smbdirect.c-271-\t\tbreak;\n--\nfs/smb/client/smbdirect.c-278-\t\t */\nfs/smb/client/smbdirect.c:279:\t\tport_flags |= SMBDIRECT_FLAG_PORT_RANGE_ONLY_IB;\nfs/smb/client/smbdirect.c-280-\t\tbreak;\n--\nfs/smb/client/smbdirect.c=546=void smbd_debug_proc_show(struct TCP_Server_Info *server, struct seq_file *m)\n--\nfs/smb/client/smbdirect.c-560-\nfs/smb/client/smbdirect.c:561:MODULE_IMPORT_NS(\"SMBDIRECT\");\n--\nfs/smb/client/smbdirect.h-6- */\nfs/smb/client/smbdirect.h:7:#ifndef _SMBDIRECT_H\nfs/smb/client/smbdirect.h:8:#define _SMBDIRECT_H\nfs/smb/client/smbdirect.h-9-\n--\nfs/smb/server/Kconfig=45=if SMB_SERVER\nfs/smb/server/Kconfig-46-\nfs/smb/server/Kconfig:47:config SMB_SERVER_SMBDIRECT\nfs/smb/server/Kconfig-48-\tbool \"Support for SMB Direct protocol\"\n--\nfs/smb/server/Kconfig-50-\tdepends on SMB_SERVER=m || INFINIBAND=y\nfs/smb/server/Kconfig:51:\tselect SMBDIRECT\nfs/smb/server/Kconfig-52-\tdefault n\n--\nfs/smb/server/Makefile=18=$(obj)/ksmbd_spnego_negtokentarg.asn1.o: $(obj)/ksmbd_spnego_negtokentarg.asn1.c $(obj)/ksmbd_spnego_negtokentarg.asn1.h\nfs/smb/server/Makefile-19-\nfs/smb/server/Makefile:20:ksmbd-$(CONFIG_SMB_SERVER_SMBDIRECT) += transport_rdma.o\nfs/smb/server/Makefile-21-ksmbd-$(CONFIG_PROC_FS) += proc.o\n--\nfs/smb/server/transport_rdma.c=93=static bool smb_direct_logging_needed(struct smbdirect_socket *sc,\n--\nfs/smb/server/transport_rdma.c-97-{\nfs/smb/server/transport_rdma.c:98:\tif (lvl \u003c= SMBDIRECT_LOG_ERR)\nfs/smb/server/transport_rdma.c-99-\t\treturn true;\nfs/smb/server/transport_rdma.c-100-\nfs/smb/server/transport_rdma.c:101:\tif (lvl \u003e SMBDIRECT_LOG_INFO)\nfs/smb/server/transport_rdma.c-102-\t\treturn false;\n--\nfs/smb/server/transport_rdma.c-108-\t *\nfs/smb/server/transport_rdma.c:109:\t * SMBDIRECT_LOG_RDMA_MR was not used, but\nfs/smb/server/transport_rdma.c-110-\t * that's client only code and we should\n--\nfs/smb/server/transport_rdma.c-112-\t */\nfs/smb/server/transport_rdma.c:113:\tcase SMBDIRECT_LOG_RDMA_EVENT:\nfs/smb/server/transport_rdma.c:114:\tcase SMBDIRECT_LOG_RDMA_SEND:\nfs/smb/server/transport_rdma.c:115:\tcase SMBDIRECT_LOG_RDMA_RECV:\nfs/smb/server/transport_rdma.c:116:\tcase SMBDIRECT_LOG_WRITE:\nfs/smb/server/transport_rdma.c:117:\tcase SMBDIRECT_LOG_READ:\nfs/smb/server/transport_rdma.c:118:\tcase SMBDIRECT_LOG_NEGOTIATE:\nfs/smb/server/transport_rdma.c:119:\tcase SMBDIRECT_LOG_OUTGOING:\nfs/smb/server/transport_rdma.c:120:\tcase SMBDIRECT_LOG_RDMA_RW:\nfs/smb/server/transport_rdma.c:121:\tcase SMBDIRECT_LOG_RDMA_MR:\nfs/smb/server/transport_rdma.c-122-\t\treturn true;\n--\nfs/smb/server/transport_rdma.c-126-\t */\nfs/smb/server/transport_rdma.c:127:\tcase SMBDIRECT_LOG_KEEP_ALIVE:\nfs/smb/server/transport_rdma.c:128:\tcase SMBDIRECT_LOG_INCOMING:\nfs/smb/server/transport_rdma.c-129-\t\treturn false;\n--\nfs/smb/server/transport_rdma.c=138=static void smb_direct_logging_vaprintf(struct smbdirect_socket *sc,\n--\nfs/smb/server/transport_rdma.c-145-{\nfs/smb/server/transport_rdma.c:146:\tif (lvl \u003c= SMBDIRECT_LOG_ERR)\nfs/smb/server/transport_rdma.c-147-\t\tpr_err(\"%pV\", vaf);\n--\nfs/smb/server/transport_rdma.c=374=static int smb_direct_listen(struct smb_direct_listener *listener,\n--\nfs/smb/server/transport_rdma.c-395-\t\t */\nfs/smb/server/transport_rdma.c:396:\t\tport_flags |= SMBDIRECT_FLAG_PORT_RANGE_ONLY_IW;\nfs/smb/server/transport_rdma.c-397-\t\tbreak;\n--\nfs/smb/server/transport_rdma.c-404-\t\t */\nfs/smb/server/transport_rdma.c:405:\t\tport_flags |= SMBDIRECT_FLAG_PORT_RANGE_ONLY_IB;\nfs/smb/server/transport_rdma.c-406-\t\tbreak;\n--\nfs/smb/server/transport_rdma.c=533=static const struct ksmbd_transport_ops ksmbd_smb_direct_transport_ops = {\n--\nfs/smb/server/transport_rdma.c-542-\nfs/smb/server/transport_rdma.c:543:MODULE_IMPORT_NS(\"SMBDIRECT\");\n--\nfs/smb/server/transport_rdma.h-13-\nfs/smb/server/transport_rdma.h:14:#ifdef CONFIG_SMB_SERVER_SMBDIRECT\nfs/smb/server/transport_rdma.h-15-int ksmbd_rdma_init(void);\n--\nfs/smb/smbdirect/Kconfig-4-\nfs/smb/smbdirect/Kconfig:5:config SMBDIRECT\nfs/smb/smbdirect/Kconfig-6-\tdef_tristate n\n--\nfs/smb/smbdirect/Makefile-5-\nfs/smb/smbdirect/Makefile:6:obj-$(CONFIG_SMBDIRECT) += smbdirect.o\nfs/smb/smbdirect/Makefile-7-\n--\nfs/smb/smbdirect/accept.c=18=int smbdirect_accept_connect_request(struct smbdirect_socket *sc,\n--\nfs/smb/smbdirect/accept.c-44-\nfs/smb/smbdirect/accept.c:45:\tif (SMBDIRECT_CHECK_STATUS_WARN(sc, SMBDIRECT_SOCKET_CREATED)) {\nfs/smb/smbdirect/accept.c-46-\t\tret = -EINVAL;\n--\nfs/smb/smbdirect/accept.c-64-\tif (ret) {\nfs/smb/smbdirect/accept.c:65:\t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,\nfs/smb/smbdirect/accept.c-66-\t\t\t\"smbdirect_accept_init_params() failed %1pe\\n\",\nfs/smb/smbdirect/accept.c:67:\t\t\tSMBDIRECT_DEBUG_ERR_PTR(ret));\nfs/smb/smbdirect/accept.c-68-\t\tgoto cleanup;\n--\nfs/smb/smbdirect/accept.c-72-\tif (ret) {\nfs/smb/smbdirect/accept.c:73:\t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,\nfs/smb/smbdirect/accept.c-74-\t\t\t\"smbdirect_connection_create_qp() failed %1pe\\n\",\nfs/smb/smbdirect/accept.c:75:\t\t\tSMBDIRECT_DEBUG_ERR_PTR(ret));\nfs/smb/smbdirect/accept.c-76-\t\tgoto cleanup;\n--\nfs/smb/smbdirect/accept.c-80-\tif (ret) {\nfs/smb/smbdirect/accept.c:81:\t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,\nfs/smb/smbdirect/accept.c-82-\t\t\t\"smbdirect_connection_create_mem_pools() failed %1pe\\n\",\nfs/smb/smbdirect/accept.c:83:\t\t\tSMBDIRECT_DEBUG_ERR_PTR(ret));\nfs/smb/smbdirect/accept.c-84-\t\tgoto cleanup;\n--\nfs/smb/smbdirect/accept.c-89-\t\tret = -EINVAL;\nfs/smb/smbdirect/accept.c:90:\t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,\nfs/smb/smbdirect/accept.c-91-\t\t\t\"smbdirect_connection_get_recv_io() failed %1pe\\n\",\nfs/smb/smbdirect/accept.c:92:\t\t\tSMBDIRECT_DEBUG_ERR_PTR(ret));\nfs/smb/smbdirect/accept.c-93-\t\tgoto cleanup;\n--\nfs/smb/smbdirect/accept.c-100-\t */\nfs/smb/smbdirect/accept.c:101:\tsc-\u003erecv_io.expected = SMBDIRECT_EXPECT_NEGOTIATE_REQ;\nfs/smb/smbdirect/accept.c-102-\tret = smbdirect_connection_post_recv_io(recv_io);\nfs/smb/smbdirect/accept.c-103-\tif (ret) {\nfs/smb/smbdirect/accept.c:104:\t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,\nfs/smb/smbdirect/accept.c-105-\t\t\t\"smbdirect_connection_post_recv_io() failed %1pe\\n\",\nfs/smb/smbdirect/accept.c:106:\t\t\tSMBDIRECT_DEBUG_ERR_PTR(ret));\nfs/smb/smbdirect/accept.c-107-\t\tgoto cleanup;\n--\nfs/smb/smbdirect/accept.c-114-\nfs/smb/smbdirect/accept.c:115:\t/* already checked with SMBDIRECT_CHECK_STATUS_WARN above */\nfs/smb/smbdirect/accept.c:116:\tWARN_ON_ONCE(sc-\u003estatus != SMBDIRECT_SOCKET_CREATED);\nfs/smb/smbdirect/accept.c:117:\tsc-\u003estatus = SMBDIRECT_SOCKET_RDMA_CONNECT_NEEDED;\nfs/smb/smbdirect/accept.c-118-\n--\nfs/smb/smbdirect/accept.c-135-\t}\nfs/smb/smbdirect/accept.c:136:\tconn_param.retry_count = SMBDIRECT_RDMA_CM_RETRY;\nfs/smb/smbdirect/accept.c:137:\tconn_param.rnr_retry_count = SMBDIRECT_RDMA_CM_RNR_RETRY;\nfs/smb/smbdirect/accept.c-138-\tconn_param.flow_control = 0;\n--\nfs/smb/smbdirect/accept.c-140-\t/* explicitly set above */\nfs/smb/smbdirect/accept.c:141:\tWARN_ON_ONCE(sc-\u003estatus != SMBDIRECT_SOCKET_RDMA_CONNECT_NEEDED);\nfs/smb/smbdirect/accept.c:142:\tsc-\u003estatus = SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING;\nfs/smb/smbdirect/accept.c-143-\tret = rdma_accept(sc-\u003erdma.cm_id, \u0026conn_param);\nfs/smb/smbdirect/accept.c-144-\tif (ret) {\nfs/smb/smbdirect/accept.c:145:\t\tsmbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,\nfs/smb/smbdirect/accept.c-146-\t\t\t\"rdma_accept() failed %1pe\\n\",\nfs/smb/smbdirect/accept.c:147:\t\t\tSMBDIRECT_DEBUG_ERR_PTR(ret));\nfs/smb/smbdirect/accept.c-148-\t\tgoto cleanup;\n--\nfs/smb/smbdirect/accept.c-151-\t/*\nfs/smb/smbdirect/accept.c:152:\t * start with the negotiate timeout and SMBDIRECT_KEEPALIVE_PENDING\nfs/smb/smbdirect/accept.c-153-\t * so that the timer will cause a disconnect.\n--\nfs/smb/smbdirect/accept.c-155-\tINIT_DELAYED_WORK(\u0026sc-\u003eidle.timer_work, smbdirect_connection_idle_timer_work);\nfs/smb/smbdirect/accept.c:156:\tsc-\u003eidle.keepalive = SMBDIRECT_KEEPALIVE_PENDING;\nfs/smb/smbdirect/accept.c-157-\tmod_delayed_work(sc-\u003eworkqueues.idle, \u0026sc-\u003eidle.timer_work,\n--\nfs/smb/smbdirect/accept.c=184=static int smbdirect_accept_init_params(struct smbdirect_socket *sc)\n--\nfs/smb/smbdirect/accept.c-193-\tmax_send_sges = DIV_ROUND_UP(sp-\u003emax_send_size, PAGE_SIZE) + 3;\nfs/smb/smbdirect/accept.c:194:\tif (max_send_sges \u003e SMBDIRECT_SEND_IO_MAX_SGE) {\nfs/smb/smbdirect/accept.c-195-\t\tpr_err(\"max_send_size %d is too large\\n\", sp-\u003emax_send_size);\n--\nfs/smb/smbdirect/accept.c=229=static void smbdirect_accept_negotiate_recv_done(struct ib_cq *cq, struct ib_wc *wc)\n--\nfs/smb/smbdirect/accept.c-237-\t\tif (wc-\u003estatus != IB_WC_WR_FLUSH_ERR)\nfs/smb/smbdirect/accept.c:238:\t\t\tsmbdirect_log_rdma_recv(sc, SMBDIRECT_LOG_ERR,\nfs/smb/smbdirect/accept.c-239-\t\t\t\t\"wc-\u003estatus=%s (%d) wc-\u003eopcode=%d\\n\",\n--\nfs/smb/smbdirect/accept.c-243-\nfs/smb/smbdirect/accept.c:244:\tsmbdirect_log_rdma_recv(sc, SMBDIRECT_LOG_INFO,\nfs/smb/smbdirect/accept.c-245-\t\t\"smbdirect_recv_io completed. status='%s (%d)', opcode=%d\\n\",\n\n"
}

19/2 2026/10/30 15:03 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 34679
							output: 30
							thoughts: 64
						

Thoughts:
Okay, let's dive into these changes.

**Examining the Code Changes**

Alright, time to get to the core of this. Let me see... I need to review these changes. *`drivers/iio/light/hid-sensor-als.c`*... hmm, that filename rings a bell. Wait, let me just pause here. I need to make sure I'm fully up to speed on this. What precisely is *`drivers/iio/light/hid-sensor-als.c`*? I'm drawing a blank. Okay, time to back up for a second. Let me quickly check the relevant Kconfig options. I need to understand if `hid-sensor-als` is enabled or disabled and how it's being configured. Only then can I properly understand these changes.



20/2 2026/10/30 15:03 tool grepper
0m Args:
{
  "Expression": "HID_SENSOR_ALS",
  "PathPrefixes": [
    "drivers/iio"
  ]
}

Results:
{
  "Output": "drivers/iio/light/Kconfig=318=config ISL76682\n--\ndrivers/iio/light/Kconfig-332-\ndrivers/iio/light/Kconfig:333:config HID_SENSOR_ALS\ndrivers/iio/light/Kconfig-334-\tdepends on HID_SENSOR_HUB\n--\ndrivers/iio/light/Makefile=29=obj-$(CONFIG_GP2AP020A00F)\t+= gp2ap020a00f.o\ndrivers/iio/light/Makefile:30:obj-$(CONFIG_HID_SENSOR_ALS)\t+= hid-sensor-als.o\ndrivers/iio/light/Makefile-31-obj-$(CONFIG_HID_SENSOR_PROX)\t+= hid-sensor-prox.o\n"
}

21/2 2026/10/30 15:03 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 35155
							output: 30
							thoughts: 1505
						

Thoughts:
**Fuzzing Worthiness Assessment**

Okay, let's break this down. My initial assessment is that this patch series is definitely worth fuzzing. I see changes in several key areas, all of which are reachable within standard QEMU environments, and thus, syzkaller.

First, I observe modifications to `fs/exec.c` and `kernel/fork.c`, specifically concerning the io_uring lifecycle during `execve`. `begin_new_exec` now cancels any io_uring activity *before* detaching the thread to prevent potential race conditions. Also, `create_io_thread` has been modified to prevent the creation of threads past a fatal signal or core dump point. These are critical changes related to process execution and resource management. `begin_new_exec` is called on *every* `execve` which makes it effectively ubiquitous. It's used on almost every syzkaller test initialization. However, `create_io_thread` is specifically related to `io_uring` worker thread creation, and so warrants special attention. Let's dig deeper to see if we can identify specific target functions. I will need to consider `io_uring_task_cancel` and `__io_uring_cancel` to see which are non-static calls.

Next, the patch includes updates to `fs/smb/server/server.c` regarding `ksmbd` connection handling. The introduction of `wait_for_neg` and the subsequent `wait_event` call within `queue_ksmbd_work` suggests potential concurrency issues during SMB negotiation. This is definitely a focal point. Additionally, the extensive modifications to `fs/smb/smbdirect/*` – including error handling, RCU locking, timeout management, socket lifecycle, and cleanup – scream for fuzzing attention. These changes deal with a fairly complex, and potentially error-prone, area of the kernel. This is a lot of code that is reachable and definitely worth fuzzing.

Finally, the patch touches `drivers/iio/light/hid-sensor-als.c`, making changes to ambient light sensor handling, specifically modifying data scaling and parsing logic. While this might seem less critical than the filesystem or process management changes, it still involves modifications to potentially critical data processing logic, especially if the device can cause kernel operations. Therefore, this warrants fuzzing as well.

The goal is to discover crashes, regressions, exposed latent bugs, and newly triggered assertions. Based on the positive criteria (reachable, executable code, modifications to core subsystems and assertions), WorthFuzzing is definitively `true`.

Now, the challenge is to prevent dilution. I need to select specific focus symbols. I must avoid ubiquitous functions. Given that `begin_new_exec` is a very common function, I need to focus on specific io_uring functions to target the code's changes. The same goes for the rest of the file changes: target the changed function code specifically. This is the code that is changed.



22/2 2026/10/30 15:03 tool grepper
0m Args:
{
  "Expression": "__io_uring_cancel",
  "PathPrefixes": [
    "io_uring"
  ]
}

Results:
{
  "Output": "io_uring/cancel.c=414=bool io_match_task_safe(struct io_kiocb *head, struct io_uring_task *tctx,\n--\nio_uring/cancel.c-436-\nio_uring/cancel.c:437:void __io_uring_cancel(bool cancel_all)\nio_uring/cancel.c-438-{\n"
}

23/2 2026/10/30 15:03 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 37426
							output: 44
							thoughts: 398
						

Thoughts:
**Analyzing Potential Cancellation Paths in io_uring and ksmbd**

Okay, so I'm digging into potential cancellation scenarios, and my mind is racing through different code paths.  First off, I'm focusing on `__io_uring_cancel` within `io_uring/cancel.c`. That's the core implementation for `io_uring_task_cancel`, so understanding it is crucial. I'm also thinking about `create_io_thread` in `kernel/fork.c`, which seems like a key player here.

Now, let's connect the dots. I wonder about the interaction with `io_wq_worker` or `create_io_worker` as well. The question is how these are getting created, since they are being called from a thread context. I should consider how things are cancelled during an `execve` of `io_uring` requests. Seems like when `io_uring_task_cancel()` runs *before* `de_thread()`, `task_work` gets called which *might* use `create_io_worker` to create a new io-wq worker, which then uses `create_io_thread`!

But wait, there's a guard. If the current task has `PF_SIGNALED | PF_POSTCOREDUMP` set, the `create_io_thread` function specifically returns `-EINTR`, so worker creation fails. This `create_io_thread` function is very specific, it's directly modified in the `kernel/fork.c` file!

Alright, shifting gears a bit, I want to see what else might be relevant. My focus is now on `fs/smb/server/server.c`. I'm curious about recent modifications there. I'm particularly interested in `queue_ksmbd_work`, because it stands out.  Is it static? Let me look around lines 371 and 404 in `server.c`. Okay, here's what I see:

```c
static int queue_ksmbd_work(struct ksmbd_conn *conn)
...
static int ksmbd_server_process_request(struct ksmbd_conn *conn)
{
    return queue_ksmbd_work(conn);
}
```

Since `ksmbd_server_process_request` calls `queue_ksmbd_work`, I should also check and see if `queue_ksmbd_work` is inlined as well. Now let me check the callers of both `queue_ksmbd_work` and `ksmbd_server_process_request` to get the full picture.



24/2 2026/10/30 15:03 tool grepper
0m Args:
{
  "Expression": "queue_ksmbd_work|ksmbd_server_process_request",
  "PathPrefixes": [
    "fs/smb/server"
  ]
}

Results:
{
  "Output": "fs/smb/server/server.c=350=static void handle_ksmbd_work(struct work_struct *wk)\n--\nfs/smb/server/server.c-364-/**\nfs/smb/server/server.c:365: * queue_ksmbd_work() - queue a smb request to worker thread queue\nfs/smb/server/server.c-366- *\t\tfor processing smb command and sending response\n--\nfs/smb/server/server.c-370- */\nfs/smb/server/server.c:371:static int queue_ksmbd_work(struct ksmbd_conn *conn)\nfs/smb/server/server.c-372-{\n--\nfs/smb/server/server.c-403-\nfs/smb/server/server.c:404:static int ksmbd_server_process_request(struct ksmbd_conn *conn)\nfs/smb/server/server.c-405-{\nfs/smb/server/server.c:406:\treturn queue_ksmbd_work(conn);\nfs/smb/server/server.c-407-}\n--\nfs/smb/server/server.c=416=static void ksmbd_server_tcp_callbacks_init(void)\n--\nfs/smb/server/server.c-419-\nfs/smb/server/server.c:420:\tops.process_fn = ksmbd_server_process_request;\nfs/smb/server/server.c-421-\tops.terminate_fn = ksmbd_server_terminate_conn;\n"
}

25/2 2026/10/30 15:03 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 38870
							output: 29
							thoughts: 492
						

Thoughts:
**Deep Dive into Kernel SMB and HID Sensor Changes**

Okay, so I'm digging into these kernel changes and here's what's going through my head. First, I noticed `queue_ksmbd_work` in `fs/smb/server/server.c`. It's static, which is interesting, and it seems to only be called by `ksmbd_server_process_request`. I'm immediately wondering if that function is a symbol or if it's been inlined. Could it be both? I need to figure out if both can be included. And, wait, what about `handle_ksmbd_work`? That's the actual work handler that `queue_ksmbd_work` is meant to queue.

Now, let's switch gears and examine the `fs/smb/smbdirect/*` directory. There are several files that have seen modifications. Here's what has been touched in there:
*   `fs/smb/smbdirect/accept.c`: I see modifications to `smbdirect_accept_connect_request`, `smbdirect_accept_negotiate_recv_work`, and `smbdirect_socket_accept`.
*   `fs/smb/smbdirect/listen.c`: This has new functions called `smbdirect_listen_orphan_socket` and `smbdirect_listen_purge_orphaned_work`, and the existing `smbdirect_listen_connect_request` is also modified.
*   `fs/smb/smbdirect/socket.c`: Changes in `smbdirect_socket_cleanup_work`, `smbdirect_socket_destroy`, `smbdirect_socket_destroy_sync`, and `smbdirect_socket_release_destroy`. I see a trend here!

Next, I'm pivoting over to `drivers/iio/light/hid-sensor-als.c`. I see that `als_read_raw` and `als_parse_report` have been modified, so it's a sensor-related change.

Finally, I need to check the required configurations. I'm focusing on the `IO_URING` config. Let me verify: I see that `CONFIG_IO_URING` is a boolean defined in init/Kconfig. Alright, good.



26/2 2026/10/30 15:04 tool grepper
0m Args:
{
  "Expression": "config IO_URING",
  "PathPrefixes": [
    "init/Kconfig"
  ]
}

Results:
{
  "Output": "init/Kconfig=1915=config AIO\n--\ninit/Kconfig-1922-\ninit/Kconfig:1923:config IO_URING\ninit/Kconfig-1924-\tbool \"Enable IO uring support\" if EXPERT\n--\ninit/Kconfig=1932=config GCOV_PROFILE_URING\n--\ninit/Kconfig-1944-\ninit/Kconfig:1945:config IO_URING_MOCK_FILE\ninit/Kconfig-1946-\ttristate \"Enable io_uring mock files (Experimental)\" if EXPERT\n"
}

27/2 2026/10/30 15:04 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 40056
							output: 34
							thoughts: 28
						

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

**Kicking the Tires on ksmbd Configuration**

Okay, so I need to get a handle on the state of the `ksmbd` implementation, and that means starting at the configuration. The first thing I'm going to do is dig into the `Kconfig` file specifically related to the SMB server – `fs/smb/server/Kconfig`. I need to ensure that `CONFIG_SMB_SERVER` is appropriately enabled, configured, and generally understood within the system. This will be the foundational starting point for this effort.



28/2 2026/10/30 15:04 tool grepper
0m Args:
{
  "Expression": "config SMB_SERVER",
  "PathPrefixes": [
    "fs/smb/server/Kconfig"
  ]
}

Results:
{
  "Output": "fs/smb/server/Kconfig:1:config SMB_SERVER\nfs/smb/server/Kconfig-2-\ttristate \"SMB3 server support\"\n--\nfs/smb/server/Kconfig=45=if SMB_SERVER\nfs/smb/server/Kconfig-46-\nfs/smb/server/Kconfig:47:config SMB_SERVER_SMBDIRECT\nfs/smb/server/Kconfig-48-\tbool \"Support for SMB Direct protocol\"\n--\nfs/smb/server/Kconfig=60=endif\nfs/smb/server/Kconfig-61-\nfs/smb/server/Kconfig:62:config SMB_SERVER_CHECK_CAP_NET_ADMIN\nfs/smb/server/Kconfig-63-\tbool \"Enable check network administration capability\"\n--\nfs/smb/server/Kconfig-69-\nfs/smb/server/Kconfig:70:config SMB_SERVER_KERBEROS5\nfs/smb/server/Kconfig-71-\tbool \"Support for Kerberos 5\"\n"
}

29/2 2026/10/30 15:04 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 40519
							output: 35
							thoughts: 21
						

Thoughts:
Here's my thought process, as if I were considering those dependencies:

**Dependency Analysis for SMB_SERVER and SMB_SERVER_SMBDIRECT**

Okay, time to dig into the dependencies for `SMB_SERVER` and `SMB_SERVER_SMBDIRECT`. This isn't just a casual glance; I need to understand the full landscape to ensure everything's stable and optimized. I need to know which components are absolutely critical, which are optional but contribute to performance or features, and if there are any potential conflicts or version incompatibilities lurking. I'll need to drill down into the indirect dependencies too. Those can be the sneaky ones that bite you later. I'll be looking for shared libraries, kernel modules, specific protocol implementations, the whole nine yards. This is where I start building that mental map of the system's architecture, and identify areas of possible risk or opportunity for optimization. Time to make sure nothing is overlooked and I have a clear picture.



30/2 2026/10/30 15:04 tool read-file
0m Args:
{
  "File": "fs/smb/server/Kconfig",
  "FirstLine": 1,
  "LineCount": 60
}

Results:
{
  "Contents": "   1:\tconfig SMB_SERVER\n   2:\t\ttristate \"SMB3 server support\"\n   3:\t\tdepends on INET\n   4:\t\tdepends on MULTIUSER\n   5:\t\tdepends on FILE_LOCKING\n   6:\t\tselect NLS\n   7:\t\tselect NLS_UTF8\n   8:\t\tselect NLS_UCS2_UTILS\n   9:\t\tselect CRYPTO\n  10:\t\tselect CRYPTO_LIB_AES_CBC_MACS\n  11:\t\tselect CRYPTO_LIB_ARC4\n  12:\t\tselect CRYPTO_LIB_MD5\n  13:\t\tselect CRYPTO_LIB_SHA256\n  14:\t\tselect CRYPTO_LIB_SHA512\n  15:\t\tselect CRYPTO_LIB_UTILS\n  16:\t\tselect CRYPTO_AEAD2\n  17:\t\tselect CRYPTO_CCM\n  18:\t\tselect CRYPTO_GCM\n  19:\t\tselect ASN1\n  20:\t\tselect OID_REGISTRY\n  21:\t\tselect CRC32\n  22:\t\tdefault n\n  23:\t\thelp\n  24:\t\t  Choose Y here if you want to allow SMB3 compliant clients\n  25:\t\t  to access files residing on this system using SMB3 protocol.\n  26:\t\t  To compile the SMB3 server support as a module,\n  27:\t\t  choose M here: the module will be called ksmbd.\n  28:\t\n  29:\t\t  You may choose to use a samba server instead, in which\n  30:\t\t  case you can choose N here.\n  31:\t\n  32:\t\t  You also need to install user space programs which can be found\n  33:\t\t  in ksmbd-tools, available from\n  34:\t\t  https://github.com/cifsd-team/ksmbd-tools.\n  35:\t\t  More detail about how to run the ksmbd kernel server is\n  36:\t\t  available via the README file\n  37:\t\t  (https://github.com/cifsd-team/ksmbd-tools/blob/master/README).\n  38:\t\n  39:\t\t  ksmbd kernel server includes support for auto-negotiation,\n  40:\t\t  Secure negotiate, Pre-authentication integrity, oplock/lease,\n  41:\t\t  compound requests, multi-credit, packet signing, RDMA(smbdirect),\n  42:\t\t  smb3 encryption, copy-offload, secure per-user session\n  43:\t\t  establishment via Kerberos or NTLMv2.\n  44:\t\n  45:\tif SMB_SERVER\n  46:\t\n  47:\tconfig SMB_SERVER_SMBDIRECT\n  48:\t\tbool \"Support for SMB Direct protocol\"\n  49:\t\tdepends on SMB_SERVER \u0026\u0026 INFINIBAND \u0026\u0026 INFINIBAND_ADDR_TRANS\n  50:\t\tdepends on SMB_SERVER=m || INFINIBAND=y\n  51:\t\tselect SMBDIRECT\n  52:\t\tdefault n\n  53:\t\n  54:\t\thelp\n  55:\t\t  Enables SMB Direct support for SMB 3.0, 3.02 and 3.1.1.\n  56:\t\n  57:\t\t  SMB Direct allows transferring SMB packets over RDMA. If unsure,\n  58:\t\t  say N.\n  59:\t\n  60:\tendif\n"
}

31/2 2026/10/30 15:04 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 41612
							output: 37
							thoughts: 89
						

Thoughts:
Okay, here's my interpretation of these thoughts, formatted as you requested:

**Navigating the Linux Kernel Configuration Landscape**

Alright, let's break this down. First, `SMB_SERVER`... that points me straight to `fs/smb/server/server.c`. That's the core server component for the Samba implementation within the kernel, I'm already visualizing the code. Now, `SMB_SERVER_SMBDIRECT` (or alternatively, `CIFS_SMB_DIRECT`) – ah, that's the selection for `SMBDIRECT`, right? The RDMA-based implementation. It all makes perfect sense, standard stuff here. But wait, what about `drivers/iio/light/hid-sensor-als.c`? That one is a curveball. That's an IIO (Industrial I/O) driver for an ambient light sensor, likely using HID (Human Interface Device). This isn't connected. Okay, let's backtrack, it must be related. Let me investigate `drivers/iio/light/Kconfig` around line 333 to understand it. Let's see what we can learn about its dependencies or build options, I imagine there's a reason for it being mentioned. That should clear up the connection.



32/2 2026/10/30 15:04 tool read-file
0m Args:
{
  "File": "drivers/iio/light/Kconfig",
  "FirstLine": 330,
  "LineCount": 20
}

Results:
{
  "Contents": " 330:\t\t  To compile this driver as a module, choose M here: the module will be\n 331:\t\t  called isl76682.\n 332:\t\n 333:\tconfig HID_SENSOR_ALS\n 334:\t\tdepends on HID_SENSOR_HUB\n 335:\t\tselect IIO_BUFFER\n 336:\t\tselect HID_SENSOR_IIO_COMMON\n 337:\t\tselect HID_SENSOR_IIO_TRIGGER\n 338:\t\ttristate \"HID ALS\"\n 339:\t\thelp\n 340:\t\t  Say yes here to build support for the HID SENSOR\n 341:\t\t  Ambient light sensor.\n 342:\t\n 343:\t\t  To compile this driver as a module, choose M here: the\n 344:\t\t  module will be called hid-sensor-als.\n 345:\t\n 346:\tconfig HID_SENSOR_PROX\n 347:\t\tdepends on HID_SENSOR_HUB\n 348:\t\tselect IIO_BUFFER\n 349:\t\tselect HID_SENSOR_IIO_COMMON\n"
}

33/2 2026/10/30 15:04 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 42302
							output: 30
							thoughts: 11
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience, and delivered as a first-person summary:

**Digging into `HID_SENSOR_HUB`**

Alright, let's zero in on `HID_SENSOR_HUB`. My initial thought is, "What's the status?" I need to quickly assess its functionality. Is everything running as expected? Any recent changes or reported issues that need immediate attention? I'll probably start by checking the logs for any errors, warnings, or unexpected behavior related to this specific hub. My experience tells me that sensor hubs can be tricky, often involving complex data pipelines and interactions with various drivers and hardware components. So, I'll need to drill down into those interactions. Perhaps I'll review recent commits or configuration changes associated with it. I'll need to get a clear picture of what this component is doing and whether it’s contributing to the system’s overall stability and performance. I need a quick overview before getting too deep, so I can prioritise where to spend my time.



34/2 2026/10/30 15:04 tool grepper
0m Args:
{
  "Expression": "config HID_SENSOR_HUB",
  "PathPrefixes": [
    "drivers/hid"
  ]
}

Results:
{
  "Output": "drivers/hid/Kconfig=1392=config HID_ZYDACRON\n--\ndrivers/hid/Kconfig-1396-\ndrivers/hid/Kconfig:1397:config HID_SENSOR_HUB\ndrivers/hid/Kconfig-1398-\ttristate \"HID Sensors framework support\"\n"
}

35/2 2026/10/30 15:04 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 42651
							output: 40
							thoughts: 4197
						

Thoughts:
**Focus Symbol Selection: A Deep Dive**

Okay, let's break this down. First, I need to revisit `IO_URING`. The code indicates `io_uring_task_cancel()` is conditional on `CONFIG_IO_URING`. Without the configuration, it's a no-op, which is crucial. `create_io_thread`, called by `io-wq.c` and `sqpoll.c`, is dependent on `CONFIG_IO_URING` as well.

Now, on to `fs/smb/smbdirect/*`. Can we actually fuzz this in a standard virtualized environment? Hmm... Does RDMA even function in QEMU or GCE? Fortunately, `rdma_rxe` or `siw` (Soft-RoCE/SoftiWARP) allows RDMA over standard network interfaces!  Good, so syzkaller *might* support it. It has descriptions for `rdma_rxe`, IB CM, and RDMA CM sockets. `SMBDIRECT` is configured with `CONFIG_SMBDIRECT` or `CONFIG_SMB_SERVER_SMBDIRECT`, which is promising.  `SMBDIRECT` depends on `INFINIBAND && INFINIBAND_ADDR_TRANS`.  `SMB_SERVER_SMBDIRECT` also depends on `SMB_SERVER` (ksmbd) and `INFINIBAND`.

Then there's `CONFIG_SMB_SERVER` (ksmbd).  ksmbd uses netlink commands (`KSMBD_CMD_*`), creates sockets, and listens on port 445 – worth considering.

Now, the real question:  FocusSymbols.  I need to follow the guidelines closely.  The primary goal is to target the specific logic being added/altered, avoiding ubiquitous code.

`fs/exec.c` is interesting. The modified function is `begin_new_exec`. Is it ubiquitous, though?  Is `execve` called by "almost every program in the corpus?"  Syzkaller tests are syscall sequences generated by syzkaller.  Most tests don't call `execve` unless they specifically test `execve` or `io_uring`. The syz-executor itself uses `fork()` or `clone` not `execve`. `begin_new_exec` gets hit during an `execve` syscall.

So what's the core change? `io_uring_task_cancel()` was moved from after to before `de_thread()`. And `create_io_thread`.
```c
struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node)
{
	struct kernel_clone_args args = {
		.flags		= CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD |
				  CLONE_IO,
		.exit_signal	= 0,
		.fn		= fn,
		.fn_arg		= arg,
		.io_thread	= 1,
		.user_worker	= 1,
	};

	/* A creator past its fatal signal or its coredump point gets no thread. */
	if (current->flags & (PF_SIGNALED | PF_POSTCOREDUMP))
		return ERR_PTR(-EINTR);

	return copy_process(NULL, 0, node, &args);
}
```
`create_io_thread` is specifically called when io_uring creates an io-wq or sqpoll thread. It's not ubiquitous and it directly contains modified code.  `__io_uring_cancel` is non-static and executed when `io_uring_task_cancel()` runs.

What about `queue_ksmbd_work`? It is static, so let's see if it's inlined.  `ksmbd_server_process_request` calls it.  It's safe to include both.

Now, `fs/smb/smbdirect/`:
1.  `smbdirect_accept_connect_request`
2.  `smbdirect_socket_accept`
3.  `smbdirect_listen_orphan_socket`
4.  `smbdirect_socket_destroy_sync`
5.  `smbdirect_listen_purge_orphaned_work`
6.  `smbdirect_accept_negotiate_recv_work`
7.  `smbdirect_listen_connect_request`
8.  `smbdirect_socket_cleanup_work`
9.  `smbdirect_socket_destroy`

And finally `drivers/iio/light/hid-sensor-als.c`


36/2 2026/10/30 15:05 tool grepper
0m Args:
{
  "Expression": "als_parse_report",
  "PathPrefixes": [
    "drivers/iio/light/hid-sensor-als.c"
  ]
}

Results:
{
  "Output": "drivers/iio/light/hid-sensor-als.c=266=static int als_capture_sample(struct hid_sensor_hub_device *hsdev,\n--\ndrivers/iio/light/hid-sensor-als.c-306-/* Parse report which is specific to an usage id*/\ndrivers/iio/light/hid-sensor-als.c:307:static int als_parse_report(struct platform_device *pdev,\ndrivers/iio/light/hid-sensor-als.c-308-\t\t\t\tstruct hid_sensor_hub_device *hsdev,\n--\ndrivers/iio/light/hid-sensor-als.c=353=static int hid_als_probe(struct platform_device *pdev)\n--\ndrivers/iio/light/hid-sensor-als.c-379-\ndrivers/iio/light/hid-sensor-als.c:380:\tret = als_parse_report(pdev, hsdev,\ndrivers/iio/light/hid-sensor-als.c-381-\t\t\t       hsdev-\u003eusage,\n"
}

37/2 2026/10/30 15:05 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 48189
							output: 458
							thoughts: 1708
						

Thoughts:
**My Analysis of Code Modifications for Fuzzing**

Okay, so here's what I've distilled from these code changes. First, the `hid-sensor-als` driver calls `als_parse_report` during `hid_als_probe`, and `als_read_raw` via sysfs and IIO. Both of these are interesting, so they should be target symbols.

Next, I went through the `EnableConfigs` to determine which configurations are required for the modified code paths. I found:

1.  `fs/exec.c` & `kernel/fork.c`: `IO_URING` is required because `io_uring_task_cancel()` needs it. The call to `create_io_thread` is unconditional, but it's only *called* when `IO_URING` is enabled.
2.  `fs/smb/server/server.c`: This needs `SMB_SERVER` (ksmbd). Its dependencies, `INET`, `MULTIUSER`, and `FILE_LOCKING`, are standard Linux configurations.
3.  `fs/smb/smbdirect/*`:  `SMBDIRECT` (or `SMB_SERVER_SMBDIRECT`, `CIFS_SMB_DIRECT`), `INFINIBAND`, and `INFINIBAND_ADDR_TRANS` are necessary for compiling and enabling `smbdirect`. Note also that `RDMA_RXE` or `INFINIBAND_USER_ACCESS` / `SIW` are typical for virtualized RDMA in QEMU.
4.  `drivers/iio/light/hid-sensor-als.c`: `HID_SENSOR_ALS` and `HID_SENSOR_HUB` are needed.

I checked for other configs, like the `turris-omnia-mcu-base.c` change, but it's just adding MODULE\_DEVICE\_TABLE for an MCU, so I'm not focusing on that.

I've reviewed the required parameters:

*   `WorthFuzzing`: True. These changes touch reachable code in `fs/exec.c`, `kernel/fork.c`, `fs/smb/server/server.c`, `fs/smb/smbdirect/*`, and `drivers/iio/light/hid-sensor-als.c`.
*   `FocusSymbols`: I've identified the key symbols: `create_io_thread`, `begin_new_exec`, `queue_ksmbd_work`, `ksmbd_server_process_request`, `smbdirect_socket_accept`, `smbdirect_accept_connect_request`, `smbdirect_listen_orphan_socket`, `smbdirect_listen_purge_orphaned_work`, `smbdirect_socket_destroy`, `als_read_raw`, and `als_parse_report`.
*   `EnableConfigs`: I need to enable these configs: `IO_URING`, `SMB_SERVER`, `SMB_SERVER_SMBDIRECT`, `SMBDIRECT`, `INFINIBAND`, `INFINIBAND_ADDR_TRANS`, `HID_SENSOR_ALS`, `HID_SENSOR_HUB`. Note that I've stripped the `CONFIG_` prefix.

I've checked the formatting and confirmed that the configs are without `CONFIG_`.

Finally, and this is important, I did a sanity check on `queue_ksmbd_work`. The change introduces a *synchronous* `wait_event` which changes concurrency during ksmbd request handling (potentially leading to deadlocks/races). The changes in `fs/exec.c` and `kernel/fork.c` also alter concurrency during execve, and the smbdirect changes touch connection handling and socket state transitions. The `hid-sensor-als` changes alter scale array access bounds.

All the changes are reachable and relevant, so I'm ready to call `set-results`.



38/2 2026/10/30 15:06 tool set-results
0m Args:
{
  "EnableConfigs": [
    "IO_URING",
    "SMB_SERVER",
    "SMB_SERVER_SMBDIRECT",
    "SMBDIRECT",
    "INFINIBAND",
    "INFINIBAND_ADDR_TRANS",
    "HID_SENSOR_ALS",
    "HID_SENSOR_HUB"
  ],
  "FocusSymbols": [
    "create_io_thread",
    "begin_new_exec",
    "queue_ksmbd_work",
    "ksmbd_server_process_request",
    "smbdirect_socket_accept",
    "smbdirect_accept_connect_request",
    "smbdirect_listen_orphan_socket",
    "smbdirect_listen_purge_orphaned_work",
    "smbdirect_socket_destroy",
    "als_read_raw",
    "als_parse_report"
  ],
  "Reasoning": "The patch series touches several reachable subsystems in the kernel:\n1. Core process lifecycle and io_uring interaction (fs/exec.c and kernel/fork.c): moves io_uring_task_cancel() before de_thread() in begin_new_exec() and adds checks against PF_SIGNALED / PF_POSTCOREDUMP in create_io_thread() to prevent worker thread creation races during thread group termination.\n2. SMB server (ksmbd in fs/smb/server/server.c): introduces wait_event() synchronization during SMB negotiation requests in queue_ksmbd_work() before handling subsequent PDUs.\n3. SMBDirect RDMA transport (fs/smb/smbdirect/): refactors connection accept logic, fixes race conditions during socket error/teardown, adds orphan socket tracking with RCU protection for listeners, and adjusts socket destruction flows.\n4. IIO light sensor (drivers/iio/light/hid-sensor-als.c): adjusts channel scale storage into per-channel arrays and adds channel scan index validation in als_read_raw().\n\nThese modifications alter concurrency, state machines, and data structures in reachable code paths, making them prime targets for fuzzing.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "IO_URING",
    "SMB_SERVER",
    "SMB_SERVER_SMBDIRECT",
    "SMBDIRECT",
    "INFINIBAND",
    "INFINIBAND_ADDR_TRANS",
    "HID_SENSOR_ALS",
    "HID_SENSOR_HUB"
  ],
  "FocusSymbols": [
    "create_io_thread",
    "begin_new_exec",
    "queue_ksmbd_work",
    "ksmbd_server_process_request",
    "smbdirect_socket_accept",
    "smbdirect_accept_connect_request",
    "smbdirect_listen_orphan_socket",
    "smbdirect_listen_purge_orphaned_work",
    "smbdirect_socket_destroy",
    "als_read_raw",
    "als_parse_report"
  ],
  "Reasoning": "The patch series touches several reachable subsystems in the kernel:\n1. Core process lifecycle and io_uring interaction (fs/exec.c and kernel/fork.c): moves io_uring_task_cancel() before de_thread() in begin_new_exec() and adds checks against PF_SIGNALED / PF_POSTCOREDUMP in create_io_thread() to prevent worker thread creation races during thread group termination.\n2. SMB server (ksmbd in fs/smb/server/server.c): introduces wait_event() synchronization during SMB negotiation requests in queue_ksmbd_work() before handling subsequent PDUs.\n3. SMBDirect RDMA transport (fs/smb/smbdirect/): refactors connection accept logic, fixes race conditions during socket error/teardown, adds orphan socket tracking with RCU protection for listeners, and adjusts socket destruction flows.\n4. IIO light sensor (drivers/iio/light/hid-sensor-als.c): adjusts channel scale storage into per-channel arrays and adds channel scan index validation in als_read_raw().\n\nThese modifications alter concurrency, state machines, and data structures in reachable code paths, making them prime targets for fuzzing.",
  "WorthFuzzing": true
}

39/1 2026/10/30 15:06 action If
4m Args:
{
  "WorthFuzzing": true
}

Results:
null

40/2 2026/10/30 15:06 agent kmsan-evaluator
4m Model:
core

Args:
null

Results:
{
  "KMSANReasoning": "The patch series consists of changes across several subsystems:\n1. drivers/iio/light/hid-sensor-als.c: Converts scalar scale properties into per-channel arrays and adds bounds checking on chan-\u003escan_index. The device state struct als_state is zero-allocated via devm_iio_device_alloc() (kzalloc), and present channels are explicitly initialized with hid_sensor_format_scale().\n2. drivers/platform/cznic/turris-omnia-mcu-base.c: Adds MODULE_DEVICE_TABLE(of, ...).\n3. fs/exec.c: Moves io_uring_task_cancel() before de_thread() in begin_new_exec() to avoid race conditions with io-wq workers.\n4. fs/smb/server/server.c: Adds wait_event() in queue_ksmbd_work() during negotiation to serialize connection ops modification.\n5. fs/smb/smbdirect/*: Fixes RDMA connection accept error handling, connection teardown races, and orphan socket cleanup using kfree_rcu(). All involved structures are zero-initialized via kzalloc_obj(), and no uninitialized memory is read or copied to userspace.\n6. kernel/fork.c: Rejects create_io_thread() if current task has PF_SIGNALED or PF_POSTCOREDUMP.\n7. scripts/link-vmlinux.sh: Adjusts kallsyms object comparison logic during kernel link.\n\nNone of these modifications create paths where uninitialized memory could be evaluated in conditional logic or leaked to userspace. Potential concurrency, lifetime, or memory safety issues are covered by KASAN and LOCKDEP. Thus, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

Instruction:
You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.

CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
  a comprehensive suite of debugging tools and sanitizers, including KASAN
  (out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
  (locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
  or page allocations) and kernel-to-user memory info-leaks.

Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.

Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.

Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
   attributes, ioctl output arguments, socket options, or BPF buffers) where fields
   or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
   or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
   could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
   uninitialized bytes of existing buffers.

Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
  dereferences, locking deadlocks, or use-after-free bugs (these are already caught
  by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
  or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.

Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
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:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 55ad28754d38c302656f2ed3b6efd93f91f3868d
Author: syz-cluster <triage@syzkaller.com>
Date:   Fri Oct 30 15:01:28 2026 +0000

    syz-cluster: applied patch under review

diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 6bf1bc9a38fe6e..8f2affb226a35a 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -33,9 +33,9 @@ struct als_state {
 		u32 illum[CHANNEL_SCAN_INDEX_MAX];
 		aligned_s64 timestamp;
 	} scan;
-	int scale_pre_decml;
-	int scale_post_decml;
-	int scale_precision;
+	int scale_pre_decml[CHANNEL_SCAN_INDEX_MAX];
+	int scale_post_decml[CHANNEL_SCAN_INDEX_MAX];
+	int scale_precision[CHANNEL_SCAN_INDEX_MAX];
 	int value_offset;
 	int num_channels;
 	s64 timestamp;
@@ -175,9 +175,11 @@ static int als_read_raw(struct iio_dev *indio_dev,
 		ret_type = IIO_VAL_INT;
 		break;
 	case IIO_CHAN_INFO_SCALE:
-		*val = als_state->scale_pre_decml;
-		*val2 = als_state->scale_post_decml;
-		ret_type = als_state->scale_precision;
+		if (chan->scan_index >= CHANNEL_SCAN_INDEX_MAX)
+			return -EINVAL;
+		*val = als_state->scale_pre_decml[chan->scan_index];
+		*val2 = als_state->scale_post_decml[chan->scan_index];
+		ret_type = als_state->scale_precision[chan->scan_index];
 		break;
 	case IIO_CHAN_INFO_OFFSET:
 		*val = als_state->value_offset;
@@ -331,6 +333,10 @@ static int als_parse_report(struct platform_device *pdev,
 		};
 		++index;
 
+		st->scale_precision[i] = hid_sensor_format_scale(usage_id,
+					&st->als[i], &st->scale_pre_decml[i],
+					&st->scale_post_decml[i]);
+
 		dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index,
 			st->als[i].report_id);
 	}
@@ -340,10 +346,6 @@ static int als_parse_report(struct platform_device *pdev,
 	if (index)
 		ret = 0;
 
-	st->scale_precision = hid_sensor_format_scale(usage_id,
-				&st->als[CHANNEL_SCAN_INDEX_INTENSITY],
-				&st->scale_pre_decml, &st->scale_post_decml);
-
 	return ret;
 }
 
diff --git a/drivers/platform/cznic/turris-omnia-mcu-base.c b/drivers/platform/cznic/turris-omnia-mcu-base.c
index e8fc0d7b334342..f0416302a1f3c1 100644
--- a/drivers/platform/cznic/turris-omnia-mcu-base.c
+++ b/drivers/platform/cznic/turris-omnia-mcu-base.c
@@ -403,6 +403,7 @@ static const struct of_device_id of_omnia_mcu_match[] = {
 	{ .compatible = "cznic,turris-omnia-mcu" },
 	{}
 };
+MODULE_DEVICE_TABLE(of, of_omnia_mcu_match);
 
 static struct i2c_driver omnia_mcu_driver = {
 	.probe		= omnia_mcu_probe,
diff --git a/fs/exec.c b/fs/exec.c
index a598d48b5ffccb..bd3e3aac90efda 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1145,6 +1145,13 @@ int begin_new_exec(struct linux_binprm * bprm)
 	 */
 	bprm->point_of_no_return = true;
 
+	/*
+	 * Cancel any io_uring activity across execve. This runs task work
+	 * that may still create an io-wq worker, so do it while de_thread()
+	 * can still zap it.
+	 */
+	io_uring_task_cancel();
+
 	/* Make this the only thread in the thread group */
 	retval = de_thread(me);
 	if (retval)
@@ -1161,10 +1168,6 @@ int begin_new_exec(struct linux_binprm * bprm)
 
 	/* see the comment in check_unsafe_exec() */
 	current->fs->in_exec = 0;
-	/*
-	 * Cancel any io_uring activity across execve
-	 */
-	io_uring_task_cancel();
 
 	/* Ensure the files table is not shared. */
 	retval = unshare_files();
diff --git a/fs/smb/server/server.c b/fs/smb/server/server.c
index e113b23d96f94e..e36e82b94a047c 100644
--- a/fs/smb/server/server.c
+++ b/fs/smb/server/server.c
@@ -371,6 +371,7 @@ static void handle_ksmbd_work(struct work_struct *wk)
 static int queue_ksmbd_work(struct ksmbd_conn *conn)
 {
 	struct ksmbd_work *work;
+	bool wait_for_neg = ksmbd_conn_new(conn) || ksmbd_conn_need_negotiate(conn);
 	int err;
 
 	err = ksmbd_init_smb_server(conn);
@@ -393,6 +394,10 @@ static int queue_ksmbd_work(struct ksmbd_conn *conn)
 	conn->last_active = jiffies;
 	INIT_WORK(&work->work, handle_ksmbd_work);
 	ksmbd_queue_work(work);
+	/* Negotiation can change conn->ops, finish it before reading another PDU. */
+	if (wait_for_neg)
+		wait_event(conn->req_running_q,
+			   atomic_read(&conn->req_running) == 0);
 	return 0;
 }
 
diff --git a/fs/smb/smbdirect/accept.c b/fs/smb/smbdirect/accept.c
index 039c9bfbd8acda..d1bc08ac975756 100644
--- a/fs/smb/smbdirect/accept.c
+++ b/fs/smb/smbdirect/accept.c
@@ -19,15 +19,33 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 				     const struct rdma_conn_param *param)
 {
 	struct smbdirect_socket_parameters *sp = &sc->parameters;
-	struct smbdirect_recv_io *recv_io;
+	struct smbdirect_recv_io *recv_io = NULL;
 	u8 peer_initiator_depth;
 	u8 peer_responder_resources;
 	struct rdma_conn_param conn_param;
 	__be32 ird_ord_hdr[2];
 	int ret;
 
-	if (SMBDIRECT_CHECK_STATUS_WARN(sc, SMBDIRECT_SOCKET_CREATED))
-		return -EINVAL;
+	/*
+	 * Install the real event handler (and the event we expect next)
+	 * before anything that can fail. On an early error the caller
+	 * (smbdirect_listen_connect_request()) only schedules our deferred
+	 * cleanup and returns 0 to the rdma_cm core, which keeps the cm_id, so
+	 * the cm_id must already carry smbdirect_accept_rdma_event_handler():
+	 * it turns any unexpected event (e.g. RDMA_CM_EVENT_DEVICE_REMOVAL)
+	 * into a clean smbdirect_socket_schedule_cleanup(). Otherwise the
+	 * placeholder smbdirect_socket_rdma_event_handler() installed by
+	 * smbdirect_socket_init_accepting() stays in place and returns -ESTALE,
+	 * which makes the rdma_cm core destroy the cm_id behind the back of our
+	 * pending teardown.
+	 */
+	sc->rdma.expected_event = RDMA_CM_EVENT_ESTABLISHED;
+	sc->rdma.cm_id->event_handler = smbdirect_accept_rdma_event_handler;
+
+	if (SMBDIRECT_CHECK_STATUS_WARN(sc, SMBDIRECT_SOCKET_CREATED)) {
+		ret = -EINVAL;
+		goto cleanup;
+	}
 
 	/*
 	 * First set what the we as server are able to support
@@ -47,7 +65,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
 			"smbdirect_accept_init_params() failed %1pe\n",
 			SMBDIRECT_DEBUG_ERR_PTR(ret));
-		goto init_params_failed;
+		goto cleanup;
 	}
 
 	ret = smbdirect_connection_create_qp(sc);
@@ -55,7 +73,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
 			"smbdirect_connection_create_qp() failed %1pe\n",
 			SMBDIRECT_DEBUG_ERR_PTR(ret));
-		goto create_qp_failed;
+		goto cleanup;
 	}
 
 	ret = smbdirect_connection_create_mem_pools(sc);
@@ -63,7 +81,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
 			"smbdirect_connection_create_mem_pools() failed %1pe\n",
 			SMBDIRECT_DEBUG_ERR_PTR(ret));
-		goto create_mem_failed;
+		goto cleanup;
 	}
 
 	recv_io = smbdirect_connection_get_recv_io(sc);
@@ -72,7 +90,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
 			"smbdirect_connection_get_recv_io() failed %1pe\n",
 			SMBDIRECT_DEBUG_ERR_PTR(ret));
-		goto get_recv_io_failed;
+		goto cleanup;
 	}
 	recv_io->cqe.done = smbdirect_accept_negotiate_recv_done;
 
@@ -86,7 +104,7 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
 			"smbdirect_connection_post_recv_io() failed %1pe\n",
 			SMBDIRECT_DEBUG_ERR_PTR(ret));
-		goto post_recv_io_failed;
+		goto cleanup;
 	}
 	/*
 	 * From here recv_io is known to the RDMA QP and needs ib_drain_qp and
@@ -122,14 +140,12 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 	/* explicitly set above */
 	WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RDMA_CONNECT_NEEDED);
 	sc->status = SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING;
-	sc->rdma.expected_event = RDMA_CM_EVENT_ESTABLISHED;
-	sc->rdma.cm_id->event_handler = smbdirect_accept_rdma_event_handler;
 	ret = rdma_accept(sc->rdma.cm_id, &conn_param);
 	if (ret) {
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
 			"rdma_accept() failed %1pe\n",
 			SMBDIRECT_DEBUG_ERR_PTR(ret));
-		goto rdma_accept_failed;
+		goto cleanup;
 	}
 
 	/*
@@ -143,31 +159,25 @@ int smbdirect_accept_connect_request(struct smbdirect_socket *sc,
 
 	return 0;
 
-rdma_accept_failed:
+cleanup:
 	/*
-	 * The recv_io posted above is now owned by the QP (recv_io was set to
-	 * NULL after a successful post).  smbdirect_connection_destroy_qp()
-	 * calls ib_drain_qp(), whose completion
-	 * (smbdirect_accept_negotiate_recv_done) returns the recv_io to the
-	 * free list via smbdirect_connection_put_recv_io().  It therefore MUST
-	 * run BEFORE smbdirect_connection_destroy_mem_pools(): otherwise the
-	 * posted recv_io is still outstanding when kmem_cache_destroy() runs
-	 * ("Slab cache still has objects") and is later freed into an
-	 * already-destroyed mempool (mempool_free_bulk NULL-ptr-deref).
+	 * No RDMA state is torn down here, and in particular sc is not
+	 * released: the caller (smbdirect_listen_connect_request()) owns that
+	 * decision and schedules sc's teardown via
+	 * smbdirect_socket_schedule_cleanup() on a non-zero return. All of the
+	 * RDMA state - the QP, the memory pools and the cm_id itself - is then
+	 * torn down asynchronously by smbdirect_socket_cleanup_work() ->
+	 * smbdirect_socket_release() -> smbdirect_socket_destroy(), which
+	 * drains the QP (returning any posted recv_io to the pool) before
+	 * destroying the memory pools and destroys the cm_id with
+	 * rdma_destroy_id(), all in the correct order.
+	 *
+	 * The only resource not reachable by that teardown is a recv_io that
+	 * was taken from the pool but not yet posted to the QP (recv_io is set
+	 * to NULL after a successful post), so hand it back here.
 	 */
-	smbdirect_connection_destroy_qp(sc);
-	smbdirect_connection_destroy_mem_pools(sc);
-	return ret;
-post_recv_io_failed:
-	/* post failed: recv_io was not accepted by the QP, still in hand */
 	if (recv_io)
 		smbdirect_connection_put_recv_io(recv_io);
-get_recv_io_failed:
-	smbdirect_connection_destroy_mem_pools(sc);
-create_mem_failed:
-	smbdirect_connection_destroy_qp(sc);
-create_qp_failed:
-init_params_failed:
 	return ret;
 }
 
@@ -301,6 +311,7 @@ static void smbdirect_accept_negotiate_recv_work(struct work_struct *work)
 	struct smbdirect_socket *sc =
 		container_of(work, struct smbdirect_socket, connect.work);
 	struct smbdirect_socket_parameters *sp = &sc->parameters;
+	struct smbdirect_socket *lsc;
 	struct smbdirect_recv_io *recv_io;
 	struct smbdirect_negotiate_req *nreq;
 	unsigned long flags;
@@ -463,29 +474,55 @@ static void smbdirect_accept_negotiate_recv_work(struct work_struct *work)
 	 */
 	sp->max_fragmented_send_size = max_fragmented_size;
 
-	if (sc->accept.listener) {
-		struct smbdirect_socket *lsc = sc->accept.listener;
-		unsigned long flags;
+	/*
+	 * Every accepting socket was created by
+	 * smbdirect_listen_connect_request() and has a
+	 * listener. If it's already cleared, the listener
+	 * (or its purge_orphaned_work) is responsible for
+	 * releasing us, so we must not send a negotiate
+	 * response.
+	 *
+	 * The memory of the listener is freed via kfree_rcu(),
+	 * see smbdirect_listen_orphan_socket().
+	 */
+	rcu_read_lock();
+	lsc = READ_ONCE(sc->accept.listener);
+	if (!lsc) {
+		rcu_read_unlock();
+		return;
+	}
 
-		spin_lock_irqsave(&lsc->listen.lock, flags);
-		list_del(&sc->accept.list);
-		list_add_tail(&sc->accept.list, &lsc->listen.ready);
+	spin_lock_irqsave(&lsc->listen.lock, flags);
+	/*
+	 * The listener (or its purge_orphaned_work)
+	 * may have cleared sc->accept.listener in the
+	 * meantime and is responsible for releasing us.
+	 *
+	 * If we already failed, we're either
+	 * already on the orphaned list or
+	 * smbdirect_socket_cleanup_work() will
+	 * move us there.
+	 *
+	 * In both cases we must not move us
+	 * to the ready list.
+	 */
+	if (sc->accept.listener == lsc && !READ_ONCE(sc->first_error)) {
+		list_move_tail(&sc->accept.list, &lsc->listen.ready);
 		wake_up(&lsc->listen.wait_queue);
-		spin_unlock_irqrestore(&lsc->listen.lock, flags);
-
-		/*
-		 * smbdirect_socket_accept() will call
-		 * smbdirect_accept_negotiate_finish(nsc, 0);
-		 *
-		 * So that we don't send the negotiation
-		 * response that grants credits to the peer
-		 * before the socket is accepted by the
-		 * application.
-		 */
-		return;
 	}
+	spin_unlock_irqrestore(&lsc->listen.lock, flags);
+	rcu_read_unlock();
 
-	ntstatus = le32_to_cpu(STATUS_SUCCESS);
+	/*
+	 * smbdirect_socket_accept() will call
+	 * smbdirect_accept_negotiate_finish(nsc, 0);
+	 *
+	 * So that we don't send the negotiation
+	 * response that grants credits to the peer
+	 * before the socket is accepted by the
+	 * application.
+	 */
+	return;
 
 not_supported:
 	smbdirect_accept_negotiate_finish(sc, ntstatus);
@@ -798,7 +835,11 @@ static long smbdirect_socket_wait_for_accept(struct smbdirect_socket *lsc, long
 	if (ret < 0)
 		return ret;
 
-	return 0;
+	/*
+	 * Return the remaining timeout, so the caller can carry it
+	 * over to the next smbdirect_socket_wait_for_accept() call.
+	 */
+	return ret;
 }
 
 struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,
@@ -808,6 +849,7 @@ struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,
 	struct smbdirect_socket *nsc;
 	unsigned long flags;
 
+again:
 	if (lsc->status != SMBDIRECT_SOCKET_LISTENING) {
 		arg->err = -EINVAL;
 		return NULL;
@@ -819,7 +861,7 @@ struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,
 	}
 
 	if (list_empty_careful(&lsc->listen.ready)) {
-		int ret;
+		long ret;
 
 		if (timeo == 0) {
 			arg->err = -EAGAIN;
@@ -827,25 +869,78 @@ struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,
 		}
 
 		ret = smbdirect_socket_wait_for_accept(lsc, timeo);
-		if (ret) {
+		if (ret < 0) {
 			arg->err = ret;
 			return NULL;
 		}
+		/*
+		 * Carry the remaining timeout over, so that a stream of
+		 * failed connections that we orphan and skip (goto again)
+		 * can't reset the caller's timeout and wait forever.
+		 */
+		timeo = ret;
 	}
 
 	spin_lock_irqsave(&lsc->listen.lock, flags);
-	nsc = list_first_entry_or_null(&lsc->listen.ready,
-				       struct smbdirect_socket,
-				       accept.list);
+	/*
+	 * Recheck under the lock.
+	 */
+	if (lsc->status != SMBDIRECT_SOCKET_LISTENING) {
+		arg->err = -EINVAL;
+		spin_unlock_irqrestore(&lsc->listen.lock, flags);
+		return NULL;
+	}
+	if (lsc->first_error) {
+		arg->err = lsc->first_error;
+		spin_unlock_irqrestore(&lsc->listen.lock, flags);
+		return NULL;
+	}
+
+	while ((nsc = list_first_entry_or_null(&lsc->listen.ready,
+					       struct smbdirect_socket,
+					       accept.list))) {
+		/*
+		 * nsc may have failed after it was moved
+		 * to the ready list, e.g. RDMA_CM_EVENT_DISCONNECTED
+		 * already moved it to SMBDIRECT_SOCKET_DISCONNECTED.
+		 * We must not overwrite that with
+		 * SMBDIRECT_SOCKET_CONNECTED and hand
+		 * out an already disconnected socket.
+		 *
+		 * Doing this under listen.lock means nsc
+		 * still belongs to us, so we can just move
+		 * a failed socket to the orphaned list,
+		 * like smbdirect_listen_orphan_socket() does,
+		 * and try the next one.
+		 */
+		if (!READ_ONCE(nsc->first_error) &&
+		    cmpxchg(&nsc->status,
+			    SMBDIRECT_SOCKET_NEGOTIATE_RUNNING,
+			    SMBDIRECT_SOCKET_CONNECTED) ==
+		    SMBDIRECT_SOCKET_NEGOTIATE_RUNNING)
+			break;
+
+		smbdirect_log_rdma_event(nsc, SMBDIRECT_LOG_INFO,
+			"orphaning failed socket status=%s first_error=%1pe\n",
+			smbdirect_socket_status_string(nsc->status),
+			SMBDIRECT_DEBUG_ERR_PTR(nsc->first_error));
+		list_move_tail(&nsc->accept.list, &lsc->listen.orphaned);
+		queue_work(lsc->workqueues.cleanup, &lsc->listen.purge_orphaned_work);
+	}
 	if (nsc) {
-		nsc->accept.listener = NULL;
+		WRITE_ONCE(nsc->accept.listener, NULL);
 		list_del_init_careful(&nsc->accept.list);
 		arg->is_empty = list_empty_careful(&lsc->listen.ready);
 	}
 	spin_unlock_irqrestore(&lsc->listen.lock, flags);
 	if (!nsc) {
-		arg->err = -EAGAIN;
-		return NULL;
+		/*
+		 * If we only found failed sockets or no socket,
+		 * we wait for the next one.
+		 *
+		 * A possible -EAGAIN/-ETIMEOUT is handled above.
+		 */
+		goto again;
 	}
 
 	/*
@@ -854,12 +949,14 @@ struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,
 	 * so it didn't grant any credits to us.
 	 *
 	 * The caller expects a connected socket
-	 * now as there are no credits anyway.
+	 * now as there are no credits anyway,
+	 * above we already changed to SMBDIRECT_SOCKET_CONNECTED
+	 * under the lsc->listen.lock and with cmpxchg.
 	 *
-	 * Then we send the negotiation response in
-	 * order to grant credits to the peer.
+	 * Now we send the negotiation response in
+	 * order to grant credits to the peer,
+	 * as the socket is now visible to the application layer.
 	 */
-	nsc->status = SMBDIRECT_SOCKET_CONNECTED;
 	smbdirect_accept_negotiate_finish(nsc, 0);
 
 	return nsc;
diff --git a/fs/smb/smbdirect/connection.c b/fs/smb/smbdirect/connection.c
index fe99537207176e..32327f96a03ab1 100644
--- a/fs/smb/smbdirect/connection.c
+++ b/fs/smb/smbdirect/connection.c
@@ -83,9 +83,9 @@ static int smbdirect_connection_rdma_event_handler(struct rdma_cm_id *id,
 		 * smbdirect_socket_schedule_cleanup[_status]() =>
 		 * smbdirect_socket_cleanup_work().
 		 *
-		 * As otherwise we'd set SMBDIRECT_SOCKET_DISCONNECTING,
-		 * but never ever get RDMA_CM_EVENT_DISCONNECTED and
-		 * never reach SMBDIRECT_SOCKET_DISCONNECTED.
+		 * As otherwise we'd set SMBDIRECT_SOCKET_DISCONNECTING
+		 * and call rdma_disconnect(), but never ever get
+		 * RDMA_CM_EVENT_DISCONNECTED.
 		 */
 		if (event->event == RDMA_CM_EVENT_DEVICE_REMOVAL)
 			smbdirect_socket_schedule_cleanup_status(sc,
@@ -113,9 +113,9 @@ static int smbdirect_connection_rdma_event_handler(struct rdma_cm_id *id,
 		 * smbdirect_socket_schedule_cleanup_status() =>
 		 * smbdirect_socket_cleanup_work().
 		 *
-		 * As otherwise we'd set SMBDIRECT_SOCKET_DISCONNECTING,
-		 * but never ever get RDMA_CM_EVENT_DISCONNECTED and
-		 * never reach SMBDIRECT_SOCKET_DISCONNECTED.
+		 * As otherwise we'd set SMBDIRECT_SOCKET_DISCONNECTING
+		 * and call rdma_disconnect(), but never ever get
+		 * RDMA_CM_EVENT_DISCONNECTED.
 		 *
 		 * This is also a normal disconnect so
 		 * SMBDIRECT_LOG_INFO should be good enough
diff --git a/fs/smb/smbdirect/internal.h b/fs/smb/smbdirect/internal.h
index e9959e6dc13ae8..69d0c9f899deca 100644
--- a/fs/smb/smbdirect/internal.h
+++ b/fs/smb/smbdirect/internal.h
@@ -74,6 +74,8 @@ void __smbdirect_socket_schedule_cleanup(struct smbdirect_socket *sc,
 
 void smbdirect_socket_destroy_sync(struct smbdirect_socket *sc);
 
+void smbdirect_listen_orphan_socket(struct smbdirect_socket *sc);
+
 int smbdirect_socket_wait_for_credits(struct smbdirect_socket *sc,
 				      enum smbdirect_socket_status expected_status,
 				      int unexpected_errno,
diff --git a/fs/smb/smbdirect/listen.c b/fs/smb/smbdirect/listen.c
index 2f78bcaedbf82e..3c91f00d95ce4a 100644
--- a/fs/smb/smbdirect/listen.c
+++ b/fs/smb/smbdirect/listen.c
@@ -10,6 +10,78 @@
 static int smbdirect_listen_rdma_event_handler(struct rdma_cm_id *id,
 					       struct rdma_cm_event *event);
 
+/*
+ * This is called by a socket that failed while it
+ * is still on the pending or ready list of its
+ * listener, typically at the end of
+ * smbdirect_socket_cleanup_work(), when the
+ * disconnect was already started.
+ *
+ * It moves itself to the orphaned list and
+ * lets smbdirect_listen_purge_orphaned_work()
+ * release it. Otherwise it would stay on the
+ * pending or ready list until the listener is
+ * destroyed and fill up the backlog, so that
+ * no new connections would be accepted.
+ *
+ * It's fine to call this more than once.
+ */
+void smbdirect_listen_orphan_socket(struct smbdirect_socket *sc)
+{
+	struct smbdirect_socket *lsc;
+	unsigned long flags;
+
+	/*
+	 * The memory of the listener is freed via
+	 * kfree_rcu(), so it's safe to dereference it
+	 * under rcu_read_lock(), even if sc->accept.listener
+	 * is cleared and the listener is released concurrently.
+	 */
+	rcu_read_lock();
+	lsc = READ_ONCE(sc->accept.listener);
+	if (!lsc) {
+		rcu_read_unlock();
+		return;
+	}
+
+	spin_lock_irqsave(&lsc->listen.lock, flags);
+	if (sc->accept.listener == lsc) {
+		list_move_tail(&sc->accept.list, &lsc->listen.orphaned);
+		queue_work(lsc->workqueues.cleanup, &lsc->listen.purge_orphaned_work);
+	}
+	spin_unlock_irqrestore(&lsc->listen.lock, flags);
+	rcu_read_unlock();
+}
+
+static void smbdirect_listen_purge_orphaned_work(struct work_struct *work)
+{
+	struct smbdirect_socket *lsc =
+		container_of(work, struct smbdirect_socket, listen.purge_orphaned_work);
+	struct smbdirect_socket *psc, *tsc;
+	LIST_HEAD(orphaned_list);
+	unsigned long flags;
+
+	/*
+	 * Clearing accept.listener under listen.lock
+	 * makes us responsible for releasing them.
+	 */
+	spin_lock_irqsave(&lsc->listen.lock, flags);
+	list_splice_tail_init(&lsc->listen.orphaned, &orphaned_list);
+	list_for_each_entry(psc, &orphaned_list, accept.list)
+		WRITE_ONCE(psc->accept.listener, NULL);
+	spin_unlock_irqrestore(&lsc->listen.lock, flags);
+
+	/*
+	 * We don't hold the listener's rdma_lock_handler()
+	 * lock here, see smbdirect_socket_destroy()
+	 * for why that's important.
+	 */
+	list_for_each_entry_safe(psc, tsc, &orphaned_list, accept.list) {
+		list_del_init(&psc->accept.list);
+		smbdirect_socket_release(psc);
+	}
+}
+
 int smbdirect_socket_listen(struct smbdirect_socket *sc, int backlog)
 {
 	int ret;
@@ -47,6 +119,9 @@ int smbdirect_socket_listen(struct smbdirect_socket *sc, int backlog)
 	sc->rdma.cm_id->event_handler = smbdirect_listen_rdma_event_handler;
 	rdma_unlock_handler(sc->rdma.cm_id);
 
+	INIT_WORK(&sc->listen.purge_orphaned_work,
+		  smbdirect_listen_purge_orphaned_work);
+
 	ret = rdma_listen(sc->rdma.cm_id, backlog);
 	if (ret) {
 		sc->first_error = ret;
@@ -214,6 +289,7 @@ static int smbdirect_listen_connect_request(struct smbdirect_socket *lsc,
 	size_t backlog = max_t(size_t, 1, lsc->listen.backlog);
 	size_t psockets;
 	size_t rsockets;
+	size_t osockets;
 	int ret;
 
 	if (!smbdirect_frwr_is_supported(&new_id->device->attrs)) {
@@ -254,14 +330,21 @@ static int smbdirect_listen_connect_request(struct smbdirect_socket *lsc,
 	spin_lock_irqsave(&lsc->listen.lock, flags);
 	psockets = list_count_nodes(&lsc->listen.pending);
 	rsockets = list_count_nodes(&lsc->listen.ready);
+	/*
+	 * Orphaned sockets still count against
+	 * the backlog until they are released by
+	 * smbdirect_listen_purge_orphaned_work().
+	 */
+	osockets = list_count_nodes(&lsc->listen.orphaned);
 	spin_unlock_irqrestore(&lsc->listen.lock, flags);
 
 	if (psockets > backlog ||
 	    rsockets > backlog ||
-	    (psockets + rsockets) > backlog) {
+	    osockets > backlog ||
+	    (psockets + rsockets + osockets) > backlog) {
 		smbdirect_log_rdma_event(lsc, SMBDIRECT_LOG_ERR,
-			"Backlog[%d][%zu] full pending[%zu] ready[%zu]\n",
-			lsc->listen.backlog, backlog, psockets, rsockets);
+			"Backlog[%d][%zu] full pending[%zu] ready[%zu] orphaned[%zu]\n",
+			lsc->listen.backlog, backlog, psockets, rsockets, osockets);
 		return -EBUSY;
 	}
 
@@ -279,22 +362,54 @@ static int smbdirect_listen_connect_request(struct smbdirect_socket *lsc,
 	if (ret)
 		goto set_settings_failed;
 
+	/*
+	 * Publish nsc on the pending list with accept.listener set before
+	 * smbdirect_accept_connect_request() calls rdma_accept(). Once the
+	 * connection can establish, smbdirect_accept_negotiate_recv_work()
+	 * may run and it must observe accept.listener, otherwise nsc would
+	 * be left stranded on the pending list forever.
+	 *
+	 * The listener's handler_mutex is held while we're called, so
+	 * smbdirect_socket_destroy() of the listener can't reach nsc on the
+	 * pending list before we're done.
+	 *
+	 * From here nsc is published on the pending list: on failure of
+	 * smbdirect_accept_connect_request() below we schedule nsc's teardown,
+	 * which orphans nsc off the listener so
+	 * smbdirect_listen_purge_orphaned_work() -> smbdirect_socket_release()
+	 * releases it.
+	 */
 	spin_lock_irqsave(&lsc->listen.lock, flags);
 	list_add_tail(&nsc->accept.list, &lsc->listen.pending);
-	nsc->accept.listener = lsc;
+	WRITE_ONCE(nsc->accept.listener, lsc);
 	spin_unlock_irqrestore(&lsc->listen.lock, flags);
 
 	ret = smbdirect_accept_connect_request(nsc, &event->param.conn);
-	if (ret)
-		goto accept_connect_failed;
+	if (ret) {
+		/*
+		 * The rdma_cm core holds both the listener's and nsc's
+		 * id_priv->handler_mutex across this CONNECT_REQUEST handler,
+		 * so neither can go away under us here and nsc cannot receive
+		 * any rdma event: it is safe to hand nsc to its teardown.
+		 *
+		 * That teardown must be deferred though: nsc->rdma.cm_id
+		 * (= new_id) has its handler_mutex held by us, so it cannot be
+		 * destroyed synchronously from here.
+		 * smbdirect_socket_schedule_cleanup() only queues work;
+		 * smbdirect_socket_cleanup_work() then orphans nsc off the
+		 * listener and smbdirect_listen_purge_orphaned_work() releases
+		 * it, destroying nsc's cm_id with rdma_destroy_id().
+		 */
+		smbdirect_socket_schedule_cleanup(nsc, ret);
+	}
 
+	/*
+	 * Always return 0 so the rdma_cm core keeps new_id: nsc owns it now.
+	 * On success it stays connected; on failure its deferred teardown
+	 * above destroys it.
+	 */
 	return 0;
 
-accept_connect_failed:
-	spin_lock_irqsave(&lsc->listen.lock, flags);
-	list_del_init(&nsc->accept.list);
-	nsc->accept.listener = NULL;
-	spin_unlock_irqrestore(&lsc->listen.lock, flags);
 set_settings_failed:
 set_params_failed:
 	/*
diff --git a/fs/smb/smbdirect/socket.c b/fs/smb/smbdirect/socket.c
index bb02df6158b97e..e270e36b3145e1 100644
--- a/fs/smb/smbdirect/socket.c
+++ b/fs/smb/smbdirect/socket.c
@@ -319,6 +319,15 @@ void __smbdirect_socket_schedule_cleanup(struct smbdirect_socket *sc,
 	 * (smbdirect_socket_destroy) to reap.
 	 */
 	if (sc->listen.backlog != -1) { /* was a listener */
+		/*
+		 * We don't move them to the orphaned list here,
+		 * each child does that itself at the end of its
+		 * smbdirect_socket_cleanup_work(), see
+		 * smbdirect_listen_orphan_socket(). Only that checks
+		 * accept.listener, which is still NULL for a child
+		 * that smbdirect_listen_connect_request() is still
+		 * setting up and will release itself on failure.
+		 */
 		spin_lock_irqsave(&sc->listen.lock, flags);
 		list_splice_init(&sc->listen.ready, &sc->listen.pending);
 		list_for_each_entry_safe(psc, tsc, &sc->listen.pending, accept.list)
@@ -427,6 +436,15 @@ static void smbdirect_socket_cleanup_work(struct work_struct *work)
 	 * instances of one class -- harmless, but lockdep cannot tell).
 	 */
 	if (sc->listen.backlog != -1) { /* was a listener */
+		/*
+		 * We don't move them to the orphaned list here,
+		 * each child does that itself at the end of its
+		 * smbdirect_socket_cleanup_work(), see
+		 * smbdirect_listen_orphan_socket(). Only that checks
+		 * accept.listener, which is still NULL for a child
+		 * that smbdirect_listen_connect_request() is still
+		 * setting up and will release itself on failure.
+		 */
 		spin_lock_irqsave(&sc->listen.lock, flags);
 		list_splice_init(&sc->listen.ready, &sc->listen.pending);
 		list_for_each_entry_safe(psc, tsc, &sc->listen.pending, accept.list)
@@ -486,6 +504,18 @@ static void smbdirect_socket_cleanup_work(struct work_struct *work)
 	 * in order to notice the broken connection.
 	 */
 	smbdirect_socket_wake_up_all(sc);
+
+	/*
+	 * If we're still on the pending or ready list
+	 * of a listener, we started the disconnect
+	 * as far as possible above, so we move ourself
+	 * to the orphaned list of the listener,
+	 * which will release us.
+	 *
+	 * This is a no-op internally if
+	 * sc->accept.listener is NULL.
+	 */
+	smbdirect_listen_orphan_socket(sc);
 }
 
 static void smbdirect_socket_destroy(struct smbdirect_socket *sc)
@@ -511,7 +541,13 @@ static void smbdirect_socket_destroy(struct smbdirect_socket *sc)
 	if (sc->status == SMBDIRECT_SOCKET_DESTROYED)
 		return;
 
-	WARN_ONCE(sc->status != SMBDIRECT_SOCKET_DISCONNECTED,
+	/*
+	 * smbdirect_socket_destroy_sync() doesn't wait
+	 * for RDMA_CM_EVENT_DISCONNECTED, so we may still
+	 * be in SMBDIRECT_SOCKET_DISCONNECTING
+	 * (or already reached SMBDIRECT_SOCKET_DISCONNECTED)
+	 */
+	WARN_ONCE(sc->status < SMBDIRECT_SOCKET_DISCONNECTING,
 		  "status=%s first_error=%1pe",
 		  smbdirect_socket_status_string(sc->status),
 		  SMBDIRECT_DEBUG_ERR_PTR(sc->first_error));
@@ -538,10 +574,37 @@ static void smbdirect_socket_destroy(struct smbdirect_socket *sc)
 	disable_work_sync(&sc->recv_io.posted.refill_work);
 	disable_work_sync(&sc->idle.immediate_work);
 	disable_delayed_work_sync(&sc->idle.timer_work);
+	disable_work_sync(&sc->listen.purge_orphaned_work);
 
 	if (sc->rdma.cm_id)
 		rdma_lock_handler(sc->rdma.cm_id);
 
+	/*
+	 * We hold the handler lock, so the rdma event
+	 * handlers can't change the status anymore.
+	 *
+	 * If RDMA_CM_EVENT_DISCONNECTED didn't arrive yet,
+	 * we just stop waiting for it here.
+	 *
+	 * We already disabled disconnect_work above
+	 * and before we call rdma_unlock_handler below
+	 * we call smbdirect_connection_destroy_qp which
+	 * sets sc->ib.qp = NULL.
+	 *
+	 * Between rdma_unlock_handler() and
+	 * rdma_destroy_id() below there's a small
+	 * windows where RDMA_CM_EVENT_DISCONNECTED
+	 * could still arrive.
+	 *
+	 * But smbdirect_connection_rdma_event_handler
+	 * will be a noop when calling smbdirect_socket_schedule_cleanup*
+	 * ib_drain_qp() also won't be called.
+	 */
+	if (sc->status < SMBDIRECT_SOCKET_DISCONNECTED) {
+		sc->status = SMBDIRECT_SOCKET_DISCONNECTED;
+		smbdirect_socket_wake_up_all(sc);
+	}
+
 	if (sc->ib.qp) {
 		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
 			"drain qp\n");
@@ -575,6 +638,19 @@ static void smbdirect_socket_destroy(struct smbdirect_socket *sc)
 	spin_lock_irqsave(&sc->listen.lock, flags);
 	list_splice_tail_init(&sc->listen.ready, &pending_list);
 	list_splice_tail_init(&sc->listen.pending, &pending_list);
+	/*
+	 * purge_orphaned_work is already disabled above,
+	 * so we also need to release the orphaned sockets.
+	 *
+	 * Clearing accept.listener under listen.lock
+	 * makes us responsible for releasing them and
+	 * prevents them from moving themselves to
+	 * the orphaned list via
+	 * smbdirect_listen_orphan_socket().
+	 */
+	list_splice_tail_init(&sc->listen.orphaned, &pending_list);
+	list_for_each_entry(psc, &pending_list, accept.list)
+		WRITE_ONCE(psc->accept.listener, NULL);
 	spin_unlock_irqrestore(&sc->listen.lock, flags);
 
 	/* It's not possible for upper layer to get to reassembly */
@@ -618,7 +694,6 @@ static void smbdirect_socket_destroy(struct smbdirect_socket *sc)
 			"release %zu pending sockets\n", psockets);
 	list_for_each_entry_safe(psc, tsc, &pending_list, accept.list) {
 		list_del_init(&psc->accept.list);
-		psc->accept.listener = NULL;
 		smbdirect_socket_release(psc);
 	}
 	if (sc->listen.backlog != -1) /* was a listener */
@@ -679,17 +754,21 @@ void smbdirect_socket_destroy_sync(struct smbdirect_socket *sc)
 		"destroying rdma session\n");
 	if (sc->status < SMBDIRECT_SOCKET_DISCONNECTING)
 		smbdirect_socket_cleanup_work(&sc->disconnect_work);
-	if (sc->status < SMBDIRECT_SOCKET_DISCONNECTED) {
-		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
-			"wait for transport being disconnected\n");
-		wait_event(sc->status_wait, sc->status == SMBDIRECT_SOCKET_DISCONNECTED);
-		smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
-			"waited for transport being disconnected\n");
-	}
 
 	/*
-	 * Once we reached SMBDIRECT_SOCKET_DISCONNECTED,
-	 * we should call smbdirect_socket_destroy()
+	 * We don't wait for RDMA_CM_EVENT_DISCONNECTED,
+	 * rdma_disconnect() was already called by
+	 * smbdirect_socket_cleanup_work() if needed
+	 * and smbdirect_socket_destroy() drains the qp,
+	 * destroys it and calls rdma_destroy_id(), which
+	 * only waits for a currently running event handler
+	 * and makes sure no further events are delivered.
+	 * The rest of the disconnect protocol is handled
+	 * by the rdma core asynchronously.
+	 *
+	 * Waiting for RDMA_CM_EVENT_DISCONNECTED could
+	 * take very long or forever, e.g. if the peer
+	 * just disappeared.
 	 */
 	smbdirect_socket_destroy(sc);
 	smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
@@ -741,7 +820,17 @@ static void smbdirect_socket_release_destroy(struct kref *kref)
 	 * in DESTROYED state, before we free the memory.
 	 */
 	smbdirect_socket_destroy_sync(sc);
-	kfree(sc);
+
+	/*
+	 * Only a listener (backlog != -1) is ever dereferenced
+	 * via sc->accept.listener under rcu_read_lock(), see
+	 * smbdirect_listen_orphan_socket(). Other sockets can be
+	 * freed immediately.
+	 */
+	if (sc->listen.backlog != -1) /* was a listener */
+		kfree_rcu(sc, refs.rcu);
+	else
+		kfree(sc);
 }
 
 void smbdirect_socket_release(struct smbdirect_socket *sc)
diff --git a/fs/smb/smbdirect/socket.h b/fs/smb/smbdirect/socket.h
index c09eddd8ad16d5..14114a2567a2ec 100644
--- a/fs/smb/smbdirect/socket.h
+++ b/fs/smb/smbdirect/socket.h
@@ -151,6 +151,12 @@ struct smbdirect_socket {
 		 * the disconnect refcount.
 		 */
 		struct kref destroy;
+
+		/*
+		 * smbdirect_socket_release_destroy() uses
+		 * kfree_rcu(), see accept.listener.
+		 */
+		struct rcu_head rcu;
 	} refs;
 
 	/* RDMA related */
@@ -216,6 +222,16 @@ struct smbdirect_socket {
 		 * only be > 0.
 		 */
 		int backlog;
+		/*
+		 * Sockets on pending or ready that failed
+		 * move themselves to orphaned and queue
+		 * purge_orphaned_work, which releases them.
+		 * So that they are freed while the listener
+		 * is still alive. They still count against
+		 * the backlog until they are released.
+		 */
+		struct list_head orphaned;
+		struct work_struct purge_orphaned_work;
 	} listen;
 
 	/*
@@ -226,7 +242,30 @@ struct smbdirect_socket {
 	 * connection.
 	 */
 	struct {
+		/*
+		 * This is only set, protected by
+		 * listener->listen.lock, while the socket
+		 * is owned by the listener (on its pending,
+		 * ready or orphaned list). The one who clears
+		 * it is responsible for releasing the socket.
+		 *
+		 * The memory of a struct smbdirect_socket is
+		 * freed via kfree_rcu(), so the listener
+		 * can be dereferenced under rcu_read_lock(),
+		 * even if accept.listener is cleared and
+		 * the listener is released concurrently.
+		 */
 		struct smbdirect_socket *listener;
+		/*
+		 * Linkage on one of the listener's
+		 * listen.{pending,ready,orphaned} lists.
+		 *
+		 * accept.list and accept.listener are set
+		 * together under listener->listen.lock before
+		 * smbdirect_accept_connect_request() is called,
+		 * so whenever the socket is on one of those lists
+		 * accept.listener is that listener (never NULL).
+		 */
 		struct list_head list;
 	} accept;
 
@@ -588,6 +627,9 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
 	spin_lock_init(&sc->listen.lock);
 	INIT_LIST_HEAD(&sc->listen.pending);
 	INIT_LIST_HEAD(&sc->listen.ready);
+	INIT_LIST_HEAD(&sc->listen.orphaned);
+	INIT_WORK(&sc->listen.purge_orphaned_work, __smbdirect_socket_disabled_work);
+	disable_work_sync(&sc->listen.purge_orphaned_work);
 	sc->listen.backlog = -1; /* not a listener */
 	init_waitqueue_head(&sc->listen.wait_queue);
 
diff --git a/kernel/fork.c b/kernel/fork.c
index 854448152696b2..a62477ec06b005 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2686,6 +2686,10 @@ struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node)
 		.user_worker	= 1,
 	};
 
+	/* A creator past its fatal signal or its coredump point gets no thread. */
+	if (current->flags & (PF_SIGNALED | PF_POSTCOREDUMP))
+		return ERR_PTR(-EINTR);
+
 	return copy_process(NULL, 0, node, &args);
 }
 
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index f99e196abeea4c..a032560eda0e8e 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -106,6 +106,18 @@ vmlinux_link()
 		${kallsymso} ${btf_vmlinux_bin_o} ${arch_vmlinux_o} ${ldlibs}
 }
 
+# Check if kallsymso_prev and kallsymso differ
+# If symbol sizes within ${kallsymso} change, any symbols within vmlinux are
+# likely to shift, invalidating ${kallsymso}.
+# Since file size can remain unchanged even if symbol sizes change, compare the
+# actual symbols instead of relying on file size only.
+kallsymso_changed()
+{
+	${NM} -n "${kallsymso_prev}" > "${kallsymso_prev}.sym"
+	${NM} -n "${kallsymso}" > "${kallsymso}.sym"
+	! cmp -s "${kallsymso_prev}.sym" "${kallsymso}.sym"
+}
+
 # Create ${2}.o file with all symbols from the ${1} object file
 kallsyms()
 {
@@ -126,6 +138,7 @@ kallsyms()
 	${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} \
 	      ${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} -c -o "${2}.o" "${2}.S"
 
+	kallsymso_prev="${kallsymso:-}"
 	kallsymso=${2}.o
 }
 
@@ -255,7 +268,12 @@ if is_enabled CONFIG_KALLSYMS; then
 	sysmap_and_kallsyms .tmp_vmlinux2
 	size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
 
-	if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
+	# Due to alignment, file size of the kallsymso object file might remain
+	# unchanged even if individual symbols within change size. Changed
+	# symbol sizes can still shift other symbols, though. Therefore, don't
+	# rely on file size alone.
+	if [ $size1 -ne $size2 ] || kallsymso_changed || \
+			[ -n "${KALLSYMS_EXTRA_PASS}" ]; then
 		vmlinux_link .tmp_vmlinux3
 		sysmap_and_kallsyms .tmp_vmlinux3
 	fi

41/3 2026/10/30 15:06 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 16330
							output: 38
							thoughts: 946
						

Thoughts:
**KMSAN Fuzzing Session Justification: Analyzing `hid-sensor-als.c`**

Okay, let's break this down. My initial assessment is whether these changes warrant a KMSAN fuzzing session. The diff modifies `drivers/iio/light/hid-sensor-als.c`. The most interesting parts are in `als_read_raw` and `als_parse_report`.  The key changes appear to be around how the scaling factors are handled.  Previously, it looks like there were single scalar variables, now those scalars are being arrayed.

Looking at `als_read_raw`, I need to know how `chan->scan_index` is used, and more importantly, what happens if it is out-of-bounds? Is there sufficient bounds checking?  In the diff, there *is* a check `if (chan->scan_index >= CHANNEL_SCAN_INDEX_MAX)` to handle out-of-bounds access within `als_read_raw`. That's good.

Next, I need to understand how the `als_state` structure `st` is allocated within `als_parse_report`. Is it kzalloc'd? This is important because uninitialized memory is a common source of KMSAN errors. I need to make sure the structure is zero initialized, which would mean that the arrayed scaling values would be pre-initialized. I'll need to check the allocation and initialization. If the `als_state` is *not* initialized (or zeroed), then using `hid_sensor_format_scale` directly on an uninitialized `st` variable could be problematic, especially with a number of arrayed values.

Overall, the changes look relatively contained, but the arrayed scales and the use of the scan index, warrant a deeper look. I need to determine how `als_state` is allocated and initialized and make certain that the index check in `als_read_raw` is sufficient. Let's fire up `read-file` or `grepper` and see how this all hangs together to get the full picture.



42/3 2026/10/30 15:06 tool grepper
0m Args:
{
  "Expression": "als_state",
  "PathPrefixes": [
    "drivers/iio/light/hid-sensor-als.c"
  ]
}

Results:
{
  "Output": "drivers/iio/light/hid-sensor-als.c=16=enum {\n--\ndrivers/iio/light/hid-sensor-als.c-26-\ndrivers/iio/light/hid-sensor-als.c:27:struct als_state {\ndrivers/iio/light/hid-sensor-als.c-28-\tstruct hid_sensor_hub_callbacks callbacks;\n--\ndrivers/iio/light/hid-sensor-als.c=121=static int als_read_raw(struct iio_dev *indio_dev,\n--\ndrivers/iio/light/hid-sensor-als.c-125-{\ndrivers/iio/light/hid-sensor-als.c:126:\tstruct als_state *als_state = iio_priv(indio_dev);\ndrivers/iio/light/hid-sensor-als.c:127:\tstruct hid_sensor_hub_device *hsdev = als_state-\u003ecommon_attributes.hsdev;\ndrivers/iio/light/hid-sensor-als.c-128-\tint report_id = -1;\n--\ndrivers/iio/light/hid-sensor-als.c-139-\t\tcase  CHANNEL_SCAN_INDEX_ILLUM:\ndrivers/iio/light/hid-sensor-als.c:140:\t\t\treport_id = als_state-\u003eals[chan-\u003escan_index].report_id;\ndrivers/iio/light/hid-sensor-als.c:141:\t\t\tmin = als_state-\u003eals[chan-\u003escan_index].logical_minimum;\ndrivers/iio/light/hid-sensor-als.c-142-\t\t\taddress = HID_USAGE_SENSOR_LIGHT_ILLUM;\n--\ndrivers/iio/light/hid-sensor-als.c-144-\t\tcase  CHANNEL_SCAN_INDEX_COLOR_TEMP:\ndrivers/iio/light/hid-sensor-als.c:145:\t\t\treport_id = als_state-\u003eals[chan-\u003escan_index].report_id;\ndrivers/iio/light/hid-sensor-als.c:146:\t\t\tmin = als_state-\u003eals[chan-\u003escan_index].logical_minimum;\ndrivers/iio/light/hid-sensor-als.c-147-\t\t\taddress = HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE;\n--\ndrivers/iio/light/hid-sensor-als.c-149-\t\tcase  CHANNEL_SCAN_INDEX_CHROMATICITY_X:\ndrivers/iio/light/hid-sensor-als.c:150:\t\t\treport_id = als_state-\u003eals[chan-\u003escan_index].report_id;\ndrivers/iio/light/hid-sensor-als.c:151:\t\t\tmin = als_state-\u003eals[chan-\u003escan_index].logical_minimum;\ndrivers/iio/light/hid-sensor-als.c-152-\t\t\taddress = HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X;\n--\ndrivers/iio/light/hid-sensor-als.c-154-\t\tcase  CHANNEL_SCAN_INDEX_CHROMATICITY_Y:\ndrivers/iio/light/hid-sensor-als.c:155:\t\t\treport_id = als_state-\u003eals[chan-\u003escan_index].report_id;\ndrivers/iio/light/hid-sensor-als.c:156:\t\t\tmin = als_state-\u003eals[chan-\u003escan_index].logical_minimum;\ndrivers/iio/light/hid-sensor-als.c-157-\t\t\taddress = HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y;\n--\ndrivers/iio/light/hid-sensor-als.c-163-\t\tif (report_id \u003e= 0) {\ndrivers/iio/light/hid-sensor-als.c:164:\t\t\thid_sensor_power_state(\u0026als_state-\u003ecommon_attributes,\ndrivers/iio/light/hid-sensor-als.c-165-\t\t\t\t\t\ttrue);\n--\ndrivers/iio/light/hid-sensor-als.c-168-\t\t\t\t\tSENSOR_HUB_SYNC, min \u003c 0);\ndrivers/iio/light/hid-sensor-als.c:169:\t\t\thid_sensor_power_state(\u0026als_state-\u003ecommon_attributes,\ndrivers/iio/light/hid-sensor-als.c-170-\t\t\t\t\t\tfalse);\n--\ndrivers/iio/light/hid-sensor-als.c-179-\t\t\treturn -EINVAL;\ndrivers/iio/light/hid-sensor-als.c:180:\t\t*val = als_state-\u003escale_pre_decml[chan-\u003escan_index];\ndrivers/iio/light/hid-sensor-als.c:181:\t\t*val2 = als_state-\u003escale_post_decml[chan-\u003escan_index];\ndrivers/iio/light/hid-sensor-als.c:182:\t\tret_type = als_state-\u003escale_precision[chan-\u003escan_index];\ndrivers/iio/light/hid-sensor-als.c-183-\t\tbreak;\ndrivers/iio/light/hid-sensor-als.c-184-\tcase IIO_CHAN_INFO_OFFSET:\ndrivers/iio/light/hid-sensor-als.c:185:\t\t*val = als_state-\u003evalue_offset;\ndrivers/iio/light/hid-sensor-als.c-186-\t\tret_type = IIO_VAL_INT;\n--\ndrivers/iio/light/hid-sensor-als.c-189-\t\tret_type = hid_sensor_read_samp_freq_value(\ndrivers/iio/light/hid-sensor-als.c:190:\t\t\t\t\u0026als_state-\u003ecommon_attributes, val, val2);\ndrivers/iio/light/hid-sensor-als.c-191-\t\tbreak;\n--\ndrivers/iio/light/hid-sensor-als.c-193-\t\tret_type = hid_sensor_read_raw_hyst_value(\ndrivers/iio/light/hid-sensor-als.c:194:\t\t\t\t\u0026als_state-\u003ecommon_attributes, val, val2);\ndrivers/iio/light/hid-sensor-als.c-195-\t\tbreak;\n--\ndrivers/iio/light/hid-sensor-als.c-197-\t\tret_type = hid_sensor_read_raw_hyst_rel_value(\ndrivers/iio/light/hid-sensor-als.c:198:\t\t\t\t\u0026als_state-\u003ecommon_attributes, val, val2);\ndrivers/iio/light/hid-sensor-als.c-199-\t\tbreak;\n--\ndrivers/iio/light/hid-sensor-als.c=209=static int als_write_raw(struct iio_dev *indio_dev,\n--\ndrivers/iio/light/hid-sensor-als.c-214-{\ndrivers/iio/light/hid-sensor-als.c:215:\tstruct als_state *als_state = iio_priv(indio_dev);\ndrivers/iio/light/hid-sensor-als.c-216-\tint ret = 0;\n--\ndrivers/iio/light/hid-sensor-als.c-220-\t\tret = hid_sensor_write_samp_freq_value(\ndrivers/iio/light/hid-sensor-als.c:221:\t\t\t\t\u0026als_state-\u003ecommon_attributes, val, val2);\ndrivers/iio/light/hid-sensor-als.c-222-\t\tbreak;\n--\ndrivers/iio/light/hid-sensor-als.c-224-\t\tret = hid_sensor_write_raw_hyst_value(\ndrivers/iio/light/hid-sensor-als.c:225:\t\t\t\t\u0026als_state-\u003ecommon_attributes, val, val2);\ndrivers/iio/light/hid-sensor-als.c-226-\t\tbreak;\n--\ndrivers/iio/light/hid-sensor-als.c-228-\t\tret = hid_sensor_write_raw_hyst_rel_value(\ndrivers/iio/light/hid-sensor-als.c:229:\t\t\t\t\u0026als_state-\u003ecommon_attributes, val, val2);\ndrivers/iio/light/hid-sensor-als.c-230-\t\tbreak;\n--\ndrivers/iio/light/hid-sensor-als.c=244=static int als_proc_event(struct hid_sensor_hub_device *hsdev,\n--\ndrivers/iio/light/hid-sensor-als.c-248-\tstruct iio_dev *indio_dev = platform_get_drvdata(priv);\ndrivers/iio/light/hid-sensor-als.c:249:\tstruct als_state *als_state = iio_priv(indio_dev);\ndrivers/iio/light/hid-sensor-als.c-250-\ndrivers/iio/light/hid-sensor-als.c-251-\tdev_dbg(\u0026indio_dev-\u003edev, \"als_proc_event\\n\");\ndrivers/iio/light/hid-sensor-als.c:252:\tif (atomic_read(\u0026als_state-\u003ecommon_attributes.data_ready)) {\ndrivers/iio/light/hid-sensor-als.c:253:\t\tif (!als_state-\u003etimestamp)\ndrivers/iio/light/hid-sensor-als.c:254:\t\t\tals_state-\u003etimestamp = iio_get_time_ns(indio_dev);\ndrivers/iio/light/hid-sensor-als.c-255-\ndrivers/iio/light/hid-sensor-als.c:256:\t\tiio_push_to_buffers_with_ts(indio_dev, \u0026als_state-\u003escan,\ndrivers/iio/light/hid-sensor-als.c:257:\t\t\t\t\t    sizeof(als_state-\u003escan),\ndrivers/iio/light/hid-sensor-als.c:258:\t\t\t\t\t    als_state-\u003etimestamp);\ndrivers/iio/light/hid-sensor-als.c:259:\t\tals_state-\u003etimestamp = 0;\ndrivers/iio/light/hid-sensor-als.c-260-\t}\n--\ndrivers/iio/light/hid-sensor-als.c=266=static int als_capture_sample(struct hid_sensor_hub_device *hsdev,\n--\ndrivers/iio/light/hid-sensor-als.c-271-\tstruct iio_dev *indio_dev = platform_get_drvdata(priv);\ndrivers/iio/light/hid-sensor-als.c:272:\tstruct als_state *als_state = iio_priv(indio_dev);\ndrivers/iio/light/hid-sensor-als.c-273-\tint ret = -EINVAL;\n--\ndrivers/iio/light/hid-sensor-als.c-277-\tcase HID_USAGE_SENSOR_LIGHT_ILLUM:\ndrivers/iio/light/hid-sensor-als.c:278:\t\tals_state-\u003escan.illum[CHANNEL_SCAN_INDEX_INTENSITY] = sample_data;\ndrivers/iio/light/hid-sensor-als.c:279:\t\tals_state-\u003escan.illum[CHANNEL_SCAN_INDEX_ILLUM] = sample_data;\ndrivers/iio/light/hid-sensor-als.c-280-\t\tret = 0;\n--\ndrivers/iio/light/hid-sensor-als.c-282-\tcase HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE:\ndrivers/iio/light/hid-sensor-als.c:283:\t\tals_state-\u003escan.illum[CHANNEL_SCAN_INDEX_COLOR_TEMP] = sample_data;\ndrivers/iio/light/hid-sensor-als.c-284-\t\tret = 0;\n--\ndrivers/iio/light/hid-sensor-als.c-286-\tcase HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X:\ndrivers/iio/light/hid-sensor-als.c:287:\t\tals_state-\u003escan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_X] = sample_data;\ndrivers/iio/light/hid-sensor-als.c-288-\t\tret = 0;\n--\ndrivers/iio/light/hid-sensor-als.c-290-\tcase HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y:\ndrivers/iio/light/hid-sensor-als.c:291:\t\tals_state-\u003escan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_Y] = sample_data;\ndrivers/iio/light/hid-sensor-als.c-292-\t\tret = 0;\n--\ndrivers/iio/light/hid-sensor-als.c-294-\tcase HID_USAGE_SENSOR_TIME_TIMESTAMP:\ndrivers/iio/light/hid-sensor-als.c:295:\t\tals_state-\u003etimestamp = hid_sensor_convert_timestamp(\u0026als_state-\u003ecommon_attributes,\ndrivers/iio/light/hid-sensor-als.c-296-\t\t\t\t\t\t\t\t    *(s64 *)raw_data);\n--\ndrivers/iio/light/hid-sensor-als.c=307=static int als_parse_report(struct platform_device *pdev,\n--\ndrivers/iio/light/hid-sensor-als.c-309-\t\t\t\tunsigned usage_id,\ndrivers/iio/light/hid-sensor-als.c:310:\t\t\t\tstruct als_state *st)\ndrivers/iio/light/hid-sensor-als.c-311-{\n--\ndrivers/iio/light/hid-sensor-als.c=353=static int hid_als_probe(struct platform_device *pdev)\n--\ndrivers/iio/light/hid-sensor-als.c-358-\tstruct iio_dev *indio_dev;\ndrivers/iio/light/hid-sensor-als.c:359:\tstruct als_state *als_state;\ndrivers/iio/light/hid-sensor-als.c-360-\ndrivers/iio/light/hid-sensor-als.c:361:\tindio_dev = devm_iio_device_alloc(\u0026pdev-\u003edev, sizeof(struct als_state));\ndrivers/iio/light/hid-sensor-als.c-362-\tif (!indio_dev)\n--\ndrivers/iio/light/hid-sensor-als.c-365-\ndrivers/iio/light/hid-sensor-als.c:366:\tals_state = iio_priv(indio_dev);\ndrivers/iio/light/hid-sensor-als.c:367:\tals_state-\u003ecommon_attributes.hsdev = hsdev;\ndrivers/iio/light/hid-sensor-als.c:368:\tals_state-\u003ecommon_attributes.pdev = pdev;\ndrivers/iio/light/hid-sensor-als.c-369-\n--\ndrivers/iio/light/hid-sensor-als.c-371-\t\t\t\t\thsdev-\u003eusage,\ndrivers/iio/light/hid-sensor-als.c:372:\t\t\t\t\t\u0026als_state-\u003ecommon_attributes,\ndrivers/iio/light/hid-sensor-als.c-373-\t\t\t\t\tals_sensitivity_addresses,\n--\ndrivers/iio/light/hid-sensor-als.c-381-\t\t\t       hsdev-\u003eusage,\ndrivers/iio/light/hid-sensor-als.c:382:\t\t\t       als_state);\ndrivers/iio/light/hid-sensor-als.c-383-\tif (ret) {\n--\ndrivers/iio/light/hid-sensor-als.c-388-\t/* Add timestamp channel */\ndrivers/iio/light/hid-sensor-als.c:389:\tals_state-\u003echannels[als_state-\u003enum_channels] = als_channels[CHANNEL_SCAN_INDEX_TIMESTAMP];\ndrivers/iio/light/hid-sensor-als.c-390-\ndrivers/iio/light/hid-sensor-als.c-391-\t/* +1 for adding timestamp channel */\ndrivers/iio/light/hid-sensor-als.c:392:\tindio_dev-\u003enum_channels = als_state-\u003enum_channels + 1;\ndrivers/iio/light/hid-sensor-als.c-393-\ndrivers/iio/light/hid-sensor-als.c:394:\tindio_dev-\u003echannels = als_state-\u003echannels;\ndrivers/iio/light/hid-sensor-als.c:395:\tindio_dev-\u003eavailable_scan_masks = als_state-\u003eals_scan_mask;\ndrivers/iio/light/hid-sensor-als.c-396-\n--\ndrivers/iio/light/hid-sensor-als.c-400-\ndrivers/iio/light/hid-sensor-als.c:401:\tatomic_set(\u0026als_state-\u003ecommon_attributes.data_ready, 0);\ndrivers/iio/light/hid-sensor-als.c-402-\ndrivers/iio/light/hid-sensor-als.c-403-\tret = hid_sensor_setup_trigger(indio_dev, name,\ndrivers/iio/light/hid-sensor-als.c:404:\t\t\t\t\u0026als_state-\u003ecommon_attributes);\ndrivers/iio/light/hid-sensor-als.c-405-\tif (ret \u003c 0) {\n--\ndrivers/iio/light/hid-sensor-als.c-415-\ndrivers/iio/light/hid-sensor-als.c:416:\tals_state-\u003ecallbacks.send_event = als_proc_event;\ndrivers/iio/light/hid-sensor-als.c:417:\tals_state-\u003ecallbacks.capture_sample = als_capture_sample;\ndrivers/iio/light/hid-sensor-als.c:418:\tals_state-\u003ecallbacks.pdev = pdev;\ndrivers/iio/light/hid-sensor-als.c:419:\tret = sensor_hub_register_callback(hsdev, hsdev-\u003eusage, \u0026als_state-\u003ecallbacks);\ndrivers/iio/light/hid-sensor-als.c-420-\tif (ret \u003c 0) {\n--\ndrivers/iio/light/hid-sensor-als.c-429-error_remove_trigger:\ndrivers/iio/light/hid-sensor-als.c:430:\thid_sensor_remove_trigger(indio_dev, \u0026als_state-\u003ecommon_attributes);\ndrivers/iio/light/hid-sensor-als.c-431-\treturn ret;\n--\ndrivers/iio/light/hid-sensor-als.c=435=static void hid_als_remove(struct platform_device *pdev)\n--\ndrivers/iio/light/hid-sensor-als.c-438-\tstruct iio_dev *indio_dev = platform_get_drvdata(pdev);\ndrivers/iio/light/hid-sensor-als.c:439:\tstruct als_state *als_state = iio_priv(indio_dev);\ndrivers/iio/light/hid-sensor-als.c-440-\n--\ndrivers/iio/light/hid-sensor-als.c-442-\tiio_device_unregister(indio_dev);\ndrivers/iio/light/hid-sensor-als.c:443:\thid_sensor_remove_trigger(indio_dev, \u0026als_state-\u003ecommon_attributes);\ndrivers/iio/light/hid-sensor-als.c-444-}\n"
}

43/3 2026/10/30 15:06 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 22643
							output: 42
							thoughts: 130
						

Thoughts:
**Analyzing IIO Device Allocation and Report Parsing**

Okay, so I need to understand how this IIO device is being set up. First, I'll refresh my memory on the memory allocation. Right, `devm_iio_device_alloc` uses `kzalloc`. That makes sense. Let's dig deeper and see the specific call within the Industrial I/O core, specifically `iio_device_alloc` in industrialio-core.c. Aha, `kzalloc` is used, and it allocates space for `struct iio_dev_opaque` plus the private data. So, the `als_state` structure, specifically, it's zeroed out initially which is good to know, that'll simplify debugging any issues later. Now, let's look at the report parsing stage. I need to understand how the ALS data is handled. Okay, I need to focus on lines 310-350 within `drivers/iio/light/hid-sensor-als.c` to see how the data reported from the sensor is being parsed and then handled. That should give me the crucial insight I need.



44/3 2026/10/30 15:06 tool read-file
0m Args:
{
  "File": "drivers/iio/light/hid-sensor-als.c",
  "FirstLine": 310,
  "LineCount": 45
}

Results:
{
  "Contents": " 310:\t\t\t\t\tstruct als_state *st)\n 311:\t{\n 312:\t\tstruct iio_chan_spec *channels;\n 313:\t\tint ret, index = 0;\n 314:\t\tint i;\n 315:\t\n 316:\t\tchannels = st-\u003echannels;\n 317:\t\n 318:\t\tfor (i = 0; i \u003c CHANNEL_SCAN_INDEX_MAX; ++i) {\n 319:\t\t\tret = sensor_hub_input_get_attribute_info(hsdev,\n 320:\t\t\t\t\t\t\tHID_INPUT_REPORT,\n 321:\t\t\t\t\t\t\tusage_id,\n 322:\t\t\t\t\t\t\tals_usage_ids[i],\n 323:\t\t\t\t\t\t\t\u0026st-\u003eals[i]);\n 324:\t\t\tif (ret \u003c 0)\n 325:\t\t\t\tcontinue;\n 326:\t\n 327:\t\t\tchannels[index] = als_channels[i];\n 328:\t\t\tst-\u003eals_scan_mask[0] |= BIT(i);\n 329:\t\t\tchannels[index].scan_type = (struct iio_scan_type) {\n 330:\t\t\t\t.format = 's',\n 331:\t\t\t\t.realbits = BYTES_TO_BITS(st-\u003eals[i].size),\n 332:\t\t\t\t.storagebits = BITS_PER_TYPE(u32),\n 333:\t\t\t};\n 334:\t\t\t++index;\n 335:\t\n 336:\t\t\tst-\u003escale_precision[i] = hid_sensor_format_scale(usage_id,\n 337:\t\t\t\t\t\t\u0026st-\u003eals[i], \u0026st-\u003escale_pre_decml[i],\n 338:\t\t\t\t\t\t\u0026st-\u003escale_post_decml[i]);\n 339:\t\n 340:\t\t\tdev_dbg(\u0026pdev-\u003edev, \"als %x:%x\\n\", st-\u003eals[i].index,\n 341:\t\t\t\tst-\u003eals[i].report_id);\n 342:\t\t}\n 343:\t\n 344:\t\tst-\u003enum_channels = index;\n 345:\t\t/* Return success even if one usage id is present */\n 346:\t\tif (index)\n 347:\t\t\tret = 0;\n 348:\t\n 349:\t\treturn ret;\n 350:\t}\n 351:\t\n 352:\t/* Function to initialize the processing for usage id */\n 353:\tstatic int hid_als_probe(struct platform_device *pdev)\n 354:\t{\n"
}

45/3 2026/10/30 15:06 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 23729
							output: 21
							thoughts: 2011
						

Thoughts:
**Analysis of Potential Uninitialized Memory Access and Information Leakage**

Okay, let's break this down. My initial concern was in `hid-sensor-als.c` regarding the array indexing. This patch modifies how scaling factors for ambient light sensors are handled, specifically introducing array indexing for scale precision, pre-decimal, and post-decimal values based on the channel scan index. My initial thought was: "Are we introducing a potential for reading uninitialized memory?"

So, the original code had these scaling values as single integers. This patch changes it to arrays indexed by the scan index. The code now iterates through the channels and the index is used to access the array elements for the scale information.

I've examined the code carefully and I can't find an obvious vulnerability. The `als_read_raw` function is safe: it checks if the `chan->scan_index` is within the valid range before accessing the array elements. The `als_parse_report` function sets the array elements for channels present in the sensor data. The channels array is populated only with existing channels. So, if a channel doesn't exist, its corresponding index won't be used to access the array. Therefore, the values will be either initialized through `hid_sensor_format_scale` or set to zero. Thus, no uninitialized memory.

Next, I looked at the other patches, I quickly realized that the second patch (`drivers/platform/cznic/turris-omnia-mcu-base.c`) is just module export which is simple. The third patch (`fs/exec.c`) looks like a straightforward change. This moves the `io_uring_task_cancel()` call earlier within `begin_new_exec()`. It has to do with cancellation of io_uring tasks during `execve`. It makes sense in relation to thread cancellation and the potential of io-wq worker zapping.

The fourth patch (`fs/smb/server/server.c`) introduces a wait in `queue_ksmbd_work()` to allow negotiation to finish before reading another PDU. This patch looks to be a concurrency fix, which waits for SMB negotiation to finish before processing other requests. This avoids a race condition.

Now, let's look at the changes in the fifth patch (`fs/smb/smbdirect/*`). This is where things get interesting. This patch involves significant changes to `smbdirect`, and potentially involves race conditions and uninitialized values. This patch changes accept/listen logic to better handle orphaned sockets in `smbdirect`. It manages backlog accounting with orphaned sockets, introduces RCU to `refs`, and adds `orphaned` list. Initializing `recv_io = NULL;` is a good practice. There are also changes related to RCU reads, and atomic operations. I'm going to have to look at this much more carefully. This looks like a deep dive for the future.

The sixth patch (`kernel/fork.c`) prevents the creation of io_threads if the creator is exiting. This seems like a sound approach to resource management, preventing unnecessary thread creation if the parent process is terminating.

The seventh patch is just a build script modification.

**In summary**: I believe the first patch is safe. The other patches look good, with the exception of the fifth one (`fs/smb/smbdirect/*`), which is potentially complex. I would want to do a careful code review of that one. The others look reasonable. I don't see any obvious uninitialized memory accesses or information leaks at this point, but `smbdirect` needs further analysis.



46/3 2026/10/30 15:07 tool grepper
0m Args:
{
  "Expression": "hid_sensor_format_scale"
}

Results:
{
  "Output": "drivers/iio/accel/hid-sensor-accel-3d.c=282=static int accel_3d_parse_report(struct platform_device *pdev,\n--\ndrivers/iio/accel/hid-sensor-accel-3d.c-309-\ndrivers/iio/accel/hid-sensor-accel-3d.c:310:\tst-\u003escale_precision = hid_sensor_format_scale(\ndrivers/iio/accel/hid-sensor-accel-3d.c-311-\t\t\t\thsdev-\u003eusage,\n--\ndrivers/iio/common/hid-sensors/hid-sensor-attributes.c=359=static void adjust_exponent_nano(int *val0, int *val1, int scale0,\n--\ndrivers/iio/common/hid-sensors/hid-sensor-attributes.c-405-\ndrivers/iio/common/hid-sensors/hid-sensor-attributes.c:406:int hid_sensor_format_scale(u32 usage_id,\ndrivers/iio/common/hid-sensors/hid-sensor-attributes.c-407-\t\t\tstruct hid_sensor_hub_attribute_info *attr_info,\n--\ndrivers/iio/common/hid-sensors/hid-sensor-attributes.c-429-}\ndrivers/iio/common/hid-sensors/hid-sensor-attributes.c:430:EXPORT_SYMBOL_NS(hid_sensor_format_scale, \"IIO_HID\");\ndrivers/iio/common/hid-sensors/hid-sensor-attributes.c-431-\n--\ndrivers/iio/common/hid-sensors/hid-sensor-attributes.c=500=int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,\n--\ndrivers/iio/common/hid-sensors/hid-sensor-attributes.c-564-\ndrivers/iio/common/hid-sensors/hid-sensor-attributes.c:565:\t\thid_sensor_format_scale(HID_USAGE_SENSOR_TIME_TIMESTAMP,\ndrivers/iio/common/hid-sensors/hid-sensor-attributes.c-566-\t\t\t\t\t\u0026timestamp, \u0026val0, \u0026val1);\n--\ndrivers/iio/gyro/hid-sensor-gyro-3d.c=233=static int gyro_3d_parse_report(struct platform_device *pdev,\n--\ndrivers/iio/gyro/hid-sensor-gyro-3d.c-260-\ndrivers/iio/gyro/hid-sensor-gyro-3d.c:261:\tst-\u003escale_precision = hid_sensor_format_scale(\ndrivers/iio/gyro/hid-sensor-gyro-3d.c-262-\t\t\t\tHID_USAGE_SENSOR_GYRO_3D,\n--\ndrivers/iio/humidity/hid-sensor-humidity.c=160=static int humidity_parse_report(struct platform_device *pdev,\n--\ndrivers/iio/humidity/hid-sensor-humidity.c-176-\ndrivers/iio/humidity/hid-sensor-humidity.c:177:\tst-\u003escale_precision = hid_sensor_format_scale(\ndrivers/iio/humidity/hid-sensor-humidity.c-178-\t\t\t\t\t\tHID_USAGE_SENSOR_HUMIDITY,\n--\ndrivers/iio/light/hid-sensor-als.c=307=static int als_parse_report(struct platform_device *pdev,\n--\ndrivers/iio/light/hid-sensor-als.c-335-\ndrivers/iio/light/hid-sensor-als.c:336:\t\tst-\u003escale_precision[i] = hid_sensor_format_scale(usage_id,\ndrivers/iio/light/hid-sensor-als.c-337-\t\t\t\t\t\u0026st-\u003eals[i], \u0026st-\u003escale_pre_decml[i],\n--\ndrivers/iio/light/hid-sensor-prox.c=219=static int prox_parse_report(struct platform_device *pdev,\n--\ndrivers/iio/light/hid-sensor-prox.c-249-\t\tst-\u003escale_precision[index] =\ndrivers/iio/light/hid-sensor-prox.c:250:\t\t\thid_sensor_format_scale(usage_id, \u0026st-\u003eprox_attr[index],\ndrivers/iio/light/hid-sensor-prox.c-251-\t\t\t\t\t\t\u0026st-\u003escale_pre_decml[index],\n--\ndrivers/iio/magnetometer/hid-sensor-magn-3d.c=338=static int magn_3d_parse_report(struct platform_device *pdev,\n--\ndrivers/iio/magnetometer/hid-sensor-magn-3d.c-430-\ndrivers/iio/magnetometer/hid-sensor-magn-3d.c:431:\tst-\u003emagn_flux_attr.scale_precision = hid_sensor_format_scale(\ndrivers/iio/magnetometer/hid-sensor-magn-3d.c-432-\t\t\t\tHID_USAGE_SENSOR_COMPASS_3D,\n--\ndrivers/iio/magnetometer/hid-sensor-magn-3d.c-436-\tst-\u003erot_attr.scale_precision\ndrivers/iio/magnetometer/hid-sensor-magn-3d.c:437:\t\t= hid_sensor_format_scale(\ndrivers/iio/magnetometer/hid-sensor-magn-3d.c-438-\t\t\tHID_USAGE_SENSOR_ORIENT_COMP_MAGN_NORTH,\n--\ndrivers/iio/orientation/hid-sensor-incl-3d.c=246=static int incl_3d_parse_report(struct platform_device *pdev,\n--\ndrivers/iio/orientation/hid-sensor-incl-3d.c-289-\ndrivers/iio/orientation/hid-sensor-incl-3d.c:290:\tst-\u003escale_precision = hid_sensor_format_scale(\ndrivers/iio/orientation/hid-sensor-incl-3d.c-291-\t\t\t\tHID_USAGE_SENSOR_INCLINOMETER_3D,\n--\ndrivers/iio/orientation/hid-sensor-rotation.c=276=static int dev_rot_parse_report(struct platform_device *pdev,\n--\ndrivers/iio/orientation/hid-sensor-rotation.c-296-\ndrivers/iio/orientation/hid-sensor-rotation.c:297:\tst-\u003escale_precision = hid_sensor_format_scale(\ndrivers/iio/orientation/hid-sensor-rotation.c-298-\t\t\t\thsdev-\u003eusage,\n--\ndrivers/iio/position/hid-sensor-custom-intel-hinge.c=235=static int hinge_parse_report(struct platform_device *pdev,\n--\ndrivers/iio/position/hid-sensor-custom-intel-hinge.c-254-\ndrivers/iio/position/hid-sensor-custom-intel-hinge.c:255:\tst-\u003escale_precision = hid_sensor_format_scale(HID_USAGE_SENSOR_HINGE,\ndrivers/iio/position/hid-sensor-custom-intel-hinge.c-256-\t\t\t\u0026st-\u003ehinge[CHANNEL_SCAN_INDEX_HINGE_ANGLE],\n--\ndrivers/iio/pressure/hid-sensor-press.c=203=static int press_parse_report(struct platform_device *pdev,\n--\ndrivers/iio/pressure/hid-sensor-press.c-225-\ndrivers/iio/pressure/hid-sensor-press.c:226:\tst-\u003escale_precision = hid_sensor_format_scale(\ndrivers/iio/pressure/hid-sensor-press.c-227-\t\t\t\tHID_USAGE_SENSOR_PRESSURE,\n--\ndrivers/iio/temperature/hid-sensor-temperature.c=158=static int temperature_parse_report(struct platform_device *pdev,\n--\ndrivers/iio/temperature/hid-sensor-temperature.c-175-\ndrivers/iio/temperature/hid-sensor-temperature.c:176:\tst-\u003escale_precision = hid_sensor_format_scale(\ndrivers/iio/temperature/hid-sensor-temperature.c-177-\t\t\t\tHID_USAGE_SENSOR_TEMPERATURE,\n--\ninclude/linux/hid-sensor-hub.h=294=int hid_sensor_get_usage_index(struct hid_sensor_hub_device *hsdev,\n--\ninclude/linux/hid-sensor-hub.h-296-\ninclude/linux/hid-sensor-hub.h:297:int hid_sensor_format_scale(u32 usage_id,\ninclude/linux/hid-sensor-hub.h-298-\t\t\t    struct hid_sensor_hub_attribute_info *attr_info,\n"
}

47/3 2026/10/30 15:07 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 28701
							output: 46
							thoughts: 35
						

Thoughts:
Okay, let's dive into this. Here's how I'd approach that query, as if it were my thought process:

**Diving into hid_sensor_format_scale**

Alright, the request is to look at the `hid_sensor_format_scale` implementation. Right, that sounds like a good starting point. I know that's related to HID sensors, so my first instinct is to check the `drivers/iio/common/hid-sensors/` directory. That's where all the HID sensor specific stuff usually lives, right? Makes sense to check `hid-sensor-attributes.c` first. It's a fairly standard name for an attributes file, and it sounds like a likely spot to find how scaling for these sensors is handled. Let's see what's in there. I'll be looking for any hints on how that particular function works, especially how it's used within the broader HID sensor framework. I'll be keeping an eye out for any interactions with the IIO framework or any specific sensor characteristics.



48/3 2026/10/30 15:07 tool read-file
0m Args:
{
  "File": "drivers/iio/common/hid-sensors/hid-sensor-attributes.c",
  "FirstLine": 405,
  "LineCount": 26
}

Results:
{
  "Contents": " 405:\t\n 406:\tint hid_sensor_format_scale(u32 usage_id,\n 407:\t\t\t\tstruct hid_sensor_hub_attribute_info *attr_info,\n 408:\t\t\t\tint *val0, int *val1)\n 409:\t{\n 410:\t\tint i;\n 411:\t\tint exp;\n 412:\t\n 413:\t\t*val0 = 1;\n 414:\t\t*val1 = 0;\n 415:\t\n 416:\t\tfor (i = 0; i \u003c ARRAY_SIZE(unit_conversion); ++i) {\n 417:\t\t\tif (unit_conversion[i].usage_id == usage_id \u0026\u0026\n 418:\t\t\t\tunit_conversion[i].unit == attr_info-\u003eunits) {\n 419:\t\t\t\texp  = hid_sensor_convert_exponent(\n 420:\t\t\t\t\t\t\tattr_info-\u003eunit_expo);\n 421:\t\t\t\tadjust_exponent_nano(val0, val1,\n 422:\t\t\t\t\t\tunit_conversion[i].scale_val0,\n 423:\t\t\t\t\t\tunit_conversion[i].scale_val1, exp);\n 424:\t\t\t\tbreak;\n 425:\t\t\t}\n 426:\t\t}\n 427:\t\n 428:\t\treturn IIO_VAL_INT_PLUS_NANO;\n 429:\t}\n 430:\tEXPORT_SYMBOL_NS(hid_sensor_format_scale, \"IIO_HID\");\n"
}

49/3 2026/10/30 15:07 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 29409
							output: 37
							thoughts: 444
						

Thoughts:
**Analyzing Initialization and Error Handling**

Okay, let's break this down. First, regarding the IIO (Industrial I/O) subsystem, `hid_sensor_format_scale` explicitly initializes `*val0 = 1; *val1 = 0;` and returns `IIO_VAL_INT_PLUS_NANO`.  The `st` variable in `hid-sensor-als.c` is zero-allocated, which is good practice with `devm_iio_device_alloc`. And the code properly checks `chan->scan_index` against `CHANNEL_SCAN_INDEX_MAX`. In the `als_read_raw` function, for the `IIO_CHAN_INFO_SCALE` case, the code verifies the scan index, then retrieves the pre-decimal, post-decimal, and precision values from the `als_state` structure using `chan->scan_index`, and everything's well-defined and fully initialized. There are no obvious initialization issues there.

Now, shifting focus to the `smbdirect` changes, it looks like a similar principle is being applied to make error handling more explicit. In `fs/smb/smbdirect/accept.c`, `struct smbdirect_recv_io *recv_io = NULL;` is declared. The `cleanup:` label is where the `recv_io` is handled with `if (recv_io) smbdirect_connection_put_recv_io(recv_io);`. The change ensures that `recv_io` is always initialized to `NULL` before any possible `goto cleanup;` statements. Previously, it could have been uninitialized. So, setting it to `NULL` explicitly prevents using an uninitialized value if an early error occurs before the `recv_io` is allocated. In `smbdirect_socket_accept`, `nsc` is taken from `list_first_entry_or_null`. `arg->err` and `arg->is_empty` are also set in this scope. I need to make sure I check `arg` in the `smbdirect_socket_accept` function to finish this up.



50/3 2026/10/30 15:07 tool grepper
0m Args:
{
  "Expression": "smbdirect_socket_accept",
  "PathPrefixes": [
    "fs/smb/smbdirect/"
  ]
}

Results:
{
  "Output": "fs/smb/smbdirect/accept.c=309=static void smbdirect_accept_negotiate_recv_work(struct work_struct *work)\n--\nfs/smb/smbdirect/accept.c-516-\t/*\nfs/smb/smbdirect/accept.c:517:\t * smbdirect_socket_accept() will call\nfs/smb/smbdirect/accept.c-518-\t * smbdirect_accept_negotiate_finish(nsc, 0);\n--\nfs/smb/smbdirect/accept.c=820=static long smbdirect_socket_wait_for_accept(struct smbdirect_socket *lsc, long timeo)\n--\nfs/smb/smbdirect/accept.c-844-\nfs/smb/smbdirect/accept.c:845:struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,\nfs/smb/smbdirect/accept.c-846-\t\t\t\t\t\t long timeo,\n--\nfs/smb/smbdirect/accept.c-963-}\nfs/smb/smbdirect/accept.c:964:EXPORT_SYMBOL_GPL(smbdirect_socket_accept);\n--\nfs/smb/smbdirect/connection.c=158=void smbdirect_connection_negotiation_done(struct smbdirect_socket *sc)\n--\nfs/smb/smbdirect/connection.c-165-\t\t * This is the accept case where\nfs/smb/smbdirect/connection.c:166:\t\t * smbdirect_socket_accept() already sets\nfs/smb/smbdirect/connection.c-167-\t\t * SMBDIRECT_SOCKET_CONNECTED\n"
}

51/3 2026/10/30 15:07 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 30802
							output: 21
							thoughts: 25
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Investigating the Caller of `smbdirect_socket_accept`**

Right, let's dive into this. My initial thought is to pinpoint the exact caller of `smbdirect_socket_accept`. Given its name, it's obviously part of the SMB Direct functionality. But where specifically is it being called *from*? The goal here is to establish the complete call path and how this call is integrated in the whole picture. I'm immediately thinking, "Is it in the core `fs/smb/server` directory, or perhaps something higher up in the network stack?" or perhaps somewhere less obvious, such as the RDMA layer? The answer will be critical for understanding its context. Determining that initial call source will give a much better overview, but also provide critical information on how the connection is being established. I need to zero in on that call stack.



52/3 2026/10/30 15:08 tool grepper
0m Args:
{
  "Expression": "smbdirect_socket_accept"
}

Results:
{
  "Output": "fs/smb/server/transport_rdma.c=327=static int smb_direct_listener_kthread_fn(void *p)\n--\nfs/smb/server/transport_rdma.c-337-\t\t\tbreak;\nfs/smb/server/transport_rdma.c:338:\t\tclient_sc = smbdirect_socket_accept(listener-\u003esocket, timeo, \u0026arg);\nfs/smb/server/transport_rdma.c-339-\t\tif (!client_sc \u0026\u0026 arg.err == -EINVAL)\n--\nfs/smb/smbdirect/accept.c=309=static void smbdirect_accept_negotiate_recv_work(struct work_struct *work)\n--\nfs/smb/smbdirect/accept.c-516-\t/*\nfs/smb/smbdirect/accept.c:517:\t * smbdirect_socket_accept() will call\nfs/smb/smbdirect/accept.c-518-\t * smbdirect_accept_negotiate_finish(nsc, 0);\n--\nfs/smb/smbdirect/accept.c=820=static long smbdirect_socket_wait_for_accept(struct smbdirect_socket *lsc, long timeo)\n--\nfs/smb/smbdirect/accept.c-844-\nfs/smb/smbdirect/accept.c:845:struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,\nfs/smb/smbdirect/accept.c-846-\t\t\t\t\t\t long timeo,\n--\nfs/smb/smbdirect/accept.c-963-}\nfs/smb/smbdirect/accept.c:964:EXPORT_SYMBOL_GPL(smbdirect_socket_accept);\n--\nfs/smb/smbdirect/connection.c=158=void smbdirect_connection_negotiation_done(struct smbdirect_socket *sc)\n--\nfs/smb/smbdirect/connection.c-165-\t\t * This is the accept case where\nfs/smb/smbdirect/connection.c:166:\t\t * smbdirect_socket_accept() already sets\nfs/smb/smbdirect/connection.c-167-\t\t * SMBDIRECT_SOCKET_CONNECTED\n--\ninclude/linux/smbdirect.h=159=int smbdirect_socket_listen(struct smbdirect_socket *sc, int backlog);\ninclude/linux/smbdirect.h-160-\ninclude/linux/smbdirect.h:161:struct smbdirect_socket *smbdirect_socket_accept(struct smbdirect_socket *lsc,\ninclude/linux/smbdirect.h-162-\t\t\t\t\t\t long timeo,\n"
}

53/3 2026/10/30 15:08 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 31754
							output: 41
							thoughts: 33
						

Thoughts:
Okay, let's dive into this. Here's my thought process on the matter:

**Analyzing `smb_direct_listener_kthread_fn`**

Right, let's take a look at the `smb_direct_listener_kthread_fn` function. I need to refresh my memory on how the RDMA transport layer in the SMB server operates. I'm going to find this function in `fs/smb/server/transport_rdma.c`. Specifically, I want to understand how this kernel thread (`kthread`) is handling incoming direct SMB connections. I expect this function is responsible for listening on the RDMA transport. What events is it waiting for? What structures are being initialized and managed here? Are there any obvious areas for performance optimization or potential bottlenecks based on my current understanding of the SMB protocol and RDMA integration? Let's get to the code and see. I need to understand this to have any chance of debugging or optimizing it. Let me see...



54/3 2026/10/30 15:08 tool read-file
0m Args:
{
  "File": "fs/smb/server/transport_rdma.c",
  "FirstLine": 330,
  "LineCount": 40
}

Results:
{
  "Contents": " 330:\t\tstruct smbdirect_socket *client_sc = NULL;\n 331:\t\n 332:\t\twhile (!kthread_should_stop()) {\n 333:\t\t\tstruct proto_accept_arg arg = { .err = -EINVAL, };\n 334:\t\t\tlong timeo = MAX_SCHEDULE_TIMEOUT;\n 335:\t\n 336:\t\t\tif (!listener-\u003esocket)\n 337:\t\t\t\tbreak;\n 338:\t\t\tclient_sc = smbdirect_socket_accept(listener-\u003esocket, timeo, \u0026arg);\n 339:\t\t\tif (!client_sc \u0026\u0026 arg.err == -EINVAL)\n 340:\t\t\t\tbreak;\n 341:\t\t\tif (!client_sc)\n 342:\t\t\t\tcontinue;\n 343:\t\n 344:\t\t\tksmbd_debug(CONN, \"connect success: accepted new connection\\n\");\n 345:\t\t\tsmb_direct_new_connection(listener, client_sc);\n 346:\t\t}\n 347:\t\n 348:\t\tksmbd_debug(CONN, \"releasing socket\\n\");\n 349:\t\treturn 0;\n 350:\t}\n 351:\t\n 352:\tstatic void smb_direct_listener_destroy(struct smb_direct_listener *listener)\n 353:\t{\n 354:\t\tint ret;\n 355:\t\n 356:\t\tif (listener-\u003esocket)\n 357:\t\t\tsmbdirect_socket_shutdown(listener-\u003esocket);\n 358:\t\n 359:\t\tif (listener-\u003ethread) {\n 360:\t\t\tret = kthread_stop(listener-\u003ethread);\n 361:\t\t\tif (ret)\n 362:\t\t\t\tpr_err(\"failed to stop forker thread\\n\");\n 363:\t\t\tlistener-\u003ethread = NULL;\n 364:\t\t}\n 365:\t\n 366:\t\tif (listener-\u003esocket) {\n 367:\t\t\tsmbdirect_socket_release(listener-\u003esocket);\n 368:\t\t\tlistener-\u003esocket = NULL;\n 369:\t\t}\n"
}

55/3 2026/10/30 15:08 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 32601
							output: 37
							thoughts: 197
						

Thoughts:
**Analyzing the RDMA Connection Establishment**

Okay, let's break down this `smbdirect` connection flow. First, I'm looking at how errors are handled during an accept. I see the initialization of `struct proto_accept_arg arg = { .err = -EINVAL, };`. In `smbdirect_socket_accept`, `arg->err` gets written to on *every* error path. Excellent. That's a solid defensive programming practice. On the success path, it seems like `arg->is_empty` gets set based on the `list_empty_careful` check, and it's communicating internally within the kernel modules for the SMB server and the transport_rdma layer. This all looks like safe internal kernel communication with no obvious userland interactions or uninitialized reads, which is exactly what I'd expect here.

Now, let's pivot to the initialization. I'll check `smbdirect_socket_init`. Looks like we are initializing lists and workqueues in the `sc->listen` structure. Good. `INIT_LIST_HEAD(&sc->listen.orphaned);`, `INIT_WORK(&sc->listen.purge_orphaned_work, __smbdirect_socket_disabled_work);`, and then `disable_work_sync(&sc->listen.purge_orphaned_work);` Okay, the orphaned list and workqueue are there to manage potentially invalid or disabled connections, I can infer from the names. The workqueue is initially disabled. So, how is this `sc` actually allocated? Need to understand the lifecycle of this structure. I'll check the allocation function, `smbdirect_socket_alloc`.



56/3 2026/10/30 15:08 tool grepper
0m Args:
{
  "Expression": "smbdirect_socket_alloc",
  "PathPrefixes": [
    "fs/smb/smbdirect/"
  ]
}

Results:
{
  "Output": "no matches"
}

57/3 2026/10/30 15:08 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 33209
							output: 37
							thoughts: 17
						

Thoughts:
Okay, here's my summary, tailored for an expert audience, in the first person, reflecting the given thought process:

**Tracing the smbdirect_socket_init Call**

Right, let's get down to brass tacks. I need to pinpoint the entry points for the `smbdirect_socket_init` function. Knowing where this critical initialization routine is invoked is key to understanding its place within the broader framework, and any debugging or performance analysis I plan will hinge on this. I'll need to use my usual tools and techniques, likely starting with the code navigation features in my editor of choice or perhaps good old `grep` with some well-crafted patterns, or even diving into a debugger to set a breakpoint if I have more context to work with. The goal is to identify all the call sites—the specific locations within the code where `smbdirect_socket_init` is called. Once I have the call sites mapped out, I can deduce how it fits into the flow and logic.



58/3 2026/10/30 15:09 tool grepper
0m Args:
{
  "Expression": "smbdirect_socket_init",
  "PathPrefixes": [
    "fs/smb/smbdirect/"
  ]
}

Results:
{
  "Output": "fs/smb/smbdirect/accept.c=18=int smbdirect_accept_connect_request(struct smbdirect_socket *sc,\n--\nfs/smb/smbdirect/accept.c-37-\t * placeholder smbdirect_socket_rdma_event_handler() installed by\nfs/smb/smbdirect/accept.c:38:\t * smbdirect_socket_init_accepting() stays in place and returns -ESTALE,\nfs/smb/smbdirect/accept.c-39-\t * which makes the rdma_cm core destroy the cm_id behind the back of our\n--\nfs/smb/smbdirect/internal.h=39=struct smbdirect_device {\n--\nfs/smb/smbdirect/internal.h-48-\nfs/smb/smbdirect/internal.h:49:int smbdirect_socket_init_new(struct net *net, struct smbdirect_socket *sc);\nfs/smb/smbdirect/internal.h-50-\nfs/smb/smbdirect/internal.h:51:int smbdirect_socket_init_accepting(struct rdma_cm_id *id, struct smbdirect_socket *sc);\nfs/smb/smbdirect/internal.h-52-\n--\nfs/smb/smbdirect/socket.c=27=static int smbdirect_socket_rdma_event_handler(struct rdma_cm_id *id,\n--\nfs/smb/smbdirect/socket.c-53-\nfs/smb/smbdirect/socket.c:54:int smbdirect_socket_init_new(struct net *net, struct smbdirect_socket *sc)\nfs/smb/smbdirect/socket.c-55-{\n--\nfs/smb/smbdirect/socket.c-58-\nfs/smb/smbdirect/socket.c:59:\tsmbdirect_socket_init(sc);\nfs/smb/smbdirect/socket.c-60-\n--\nfs/smb/smbdirect/socket.c=86=int smbdirect_socket_create_kern(struct net *net, struct smbdirect_socket **_sc)\n--\nfs/smb/smbdirect/socket.c-95-\nfs/smb/smbdirect/socket.c:96:\tret = smbdirect_socket_init_new(net, sc);\nfs/smb/smbdirect/socket.c-97-\tif (ret)\n--\nfs/smb/smbdirect/socket.c=110=EXPORT_SYMBOL_GPL(smbdirect_socket_create_kern);\nfs/smb/smbdirect/socket.c-111-\nfs/smb/smbdirect/socket.c:112:int smbdirect_socket_init_accepting(struct rdma_cm_id *id, struct smbdirect_socket *sc)\nfs/smb/smbdirect/socket.c-113-{\nfs/smb/smbdirect/socket.c:114:\tsmbdirect_socket_init(sc);\nfs/smb/smbdirect/socket.c-115-\n--\nfs/smb/smbdirect/socket.c=127=int smbdirect_socket_create_accepting(struct rdma_cm_id *id, struct smbdirect_socket **_sc)\n--\nfs/smb/smbdirect/socket.c-136-\nfs/smb/smbdirect/socket.c:137:\tret = smbdirect_socket_init_accepting(id, sc);\nfs/smb/smbdirect/socket.c-138-\tif (ret)\n--\nfs/smb/smbdirect/socket.h=534=static void __smbdirect_log_printf(struct smbdirect_socket *sc,\n--\nfs/smb/smbdirect/socket.h-590-\nfs/smb/smbdirect/socket.h:591:static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)\nfs/smb/smbdirect/socket.h-592-{\n"
}

59/3 2026/10/30 15:09 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 34530
							output: 39
							thoughts: 37
						

Thoughts:
Okay, let's dive into this. Here's my thought process on this:

**Investigating `sc` Allocation in the SMB Direct Socket Creation**

Right, I need to get a clear picture of how this `sc` is getting allocated. Given the context of SMB Direct, and my understanding of the architecture, I need to pinpoint the exact locations where this critical structure is instantiated. My primary focus is understanding where this allocation originates, because that dictates how it's initialized and how it gets cleaned up. Therefore, my immediate next step is to examine the `smbdirect_socket_create_kern` and `smbdirect_socket_create_accepting` functions. These seem like the most likely candidates, given their names. They're clearly related to socket creation, and it's highly probable that `sc`, the socket context, is being allocated within these functions, or at the very least, called from them. I'll need to dissect the code in those routines. I'll be looking for calls to memory allocation routines (e.g., `kmalloc`, `kzalloc`, or perhaps even something more custom if this part of the stack has custom allocators). I'll also be watching for any associated initialisation of the `sc` struct.



60/3 2026/10/30 15:09 tool read-file
0m Args:
{
  "File": "fs/smb/smbdirect/socket.c",
  "FirstLine": 86,
  "LineCount": 25
}

Results:
{
  "Contents": "  86:\tint smbdirect_socket_create_kern(struct net *net, struct smbdirect_socket **_sc)\n  87:\t{\n  88:\t\tstruct smbdirect_socket *sc;\n  89:\t\tint ret;\n  90:\t\n  91:\t\tret = -ENOMEM;\n  92:\t\tsc = kzalloc_obj(*sc);\n  93:\t\tif (!sc)\n  94:\t\t\tgoto alloc_failed;\n  95:\t\n  96:\t\tret = smbdirect_socket_init_new(net, sc);\n  97:\t\tif (ret)\n  98:\t\t\tgoto init_failed;\n  99:\t\n 100:\t\tkref_init(\u0026sc-\u003erefs.destroy);\n 101:\t\n 102:\t\t*_sc = sc;\n 103:\t\treturn 0;\n 104:\t\n 105:\tinit_failed:\n 106:\t\tkfree(sc);\n 107:\talloc_failed:\n 108:\t\treturn ret;\n 109:\t}\n 110:\tEXPORT_SYMBOL_GPL(smbdirect_socket_create_kern);\n"
}

61/3 2026/10/30 15:09 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 35189
							output: 38
							thoughts: 683
						

Thoughts:
**Analyzing Potential Uninitialized Memory in Kernel Code**

Okay, so I'm diving into this code. The `sc = kzalloc_obj(*sc);` caught my eye first - it's zero-allocated, which is good. That should minimize the risk of uninitialized memory at that point.

Next, I checked `fs/exec.c`, specifically around the `io_uring_task_cancel()` call. Moving that up before `de_thread(me)` is interesting, but it doesn't seem like it directly introduces any uninitialized memory issues. It's more about ordering and preventing race conditions with io-wq workers. Makes sense.

Then I moved on to `fs/smb/server/server.c` and looked at `wait_event(conn->req_running_q, atomic_read(&conn->req_running) == 0);`. This is simply waiting for negotiation to finish so that `conn->ops` is set before processing subsequent requests. No uninitialized memory concerns there either.

I also checked `kernel/fork.c`, focusing on the `create_io_thread()` function. The early check for `PF_SIGNALED` or `PF_POSTCOREDUMP` flags doesn't seem to touch any uninitialized memory. It's just a quick early exit before `copy_process` does its work.

Moving on, `drivers/platform/cznic/turris-omnia-mcu-base.c` with the `MODULE_DEVICE_TABLE` definition... No uninitialized memory issues there either. It's just a table definition.

I skimmed `scripts/link-vmlinux.sh` – a shell script. Not relevant for this kind of check.

Wait, hold on. Let's go back and carefully analyze `drivers/iio/light/hid-sensor-als.c` again. I have a hunch about `als_read_raw()`. Could that potentially be returning uninitialized memory? Let's check the code:

```c
	case IIO_CHAN_INFO_SCALE:
		if (chan->scan_index >= CHANNEL_SCAN_INDEX_MAX)
			return -EINVAL;
		*val = als_state->scale_pre_decml[chan->scan_index];
		*val2 = als_state->scale_post_decml[chan->scan_index];
		ret_type = als_state->scale_precision[chan->scan_index];
		break;
```

Right, that's the key. Where is `als_read_raw` called? Ah, the IIO subsystem. When userspace reads a sysfs attribute like `in_illuminance_scale`, the IIO core calls `read_raw(indio_dev, chan, &val, &val2, mask)`. The core then formats `val` and `val2` into a string based on `ret_type`: something like `IIO_VAL_INT_PLUS_NANO`. It formats and copies that to the sysfs buffer and then to user space. Okay, so is `als_state` initialized correctly?

Looks like `als_state` is allocated using `devm_iio_device_alloc(&pdev->dev, sizeof(struct als_state));`. That's good, but I need to make sure this allocation is done right. Let's verify `iio_device_alloc`'s implementation in `drivers/iio/industrialio-core.c`. I have to be thorough here.



62/3 2026/10/30 15:09 tool grepper
0m Args:
{
  "Expression": "struct iio_dev \\*iio_device_alloc",
  "PathPrefixes": [
    "drivers/iio/"
  ]
}

Results:
{
  "Output": "drivers/iio/industrialio-core.c=1668=const struct device_type iio_device_type = {\n--\ndrivers/iio/industrialio-core.c-1680- */\ndrivers/iio/industrialio-core.c:1681:struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv)\ndrivers/iio/industrialio-core.c-1682-{\n"
}

63/3 2026/10/30 15:09 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 36798
							output: 40
							thoughts: 25
						

Thoughts:
Okay, let's dive into this. Here's my perspective on where we need to focus:

**Analyzing the IIO Core Initialization in `industrialio-core.c`**

Alright, I'm thinking we need to start dissecting the `drivers/iio/industrialio-core.c` file. Specifically, I'm zeroing in on the initialization routines around line 1681. That's usually where the core of the Industrial I/O subsystem gets its legs. We're likely to find the heart of how IIO devices are registered, initialized, and integrated with the broader kernel infrastructure there. I'll need to see how the device structure is populated, what crucial callbacks are assigned, and how everything ties back to the hardware abstraction layer. This is where the magic happens, or fails to happen, depending on the implementation! Time to grab my coffee and dig in. This is going to be good.



64/3 2026/10/30 15:09 tool read-file
0m Args:
{
  "File": "drivers/iio/industrialio-core.c",
  "FirstLine": 1681,
  "LineCount": 20
}

Results:
{
  "Contents": "1681:\tstruct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv)\n1682:\t{\n1683:\t\tstruct iio_dev_opaque *iio_dev_opaque;\n1684:\t\tstruct iio_dev *indio_dev;\n1685:\t\tsize_t alloc_size;\n1686:\t\n1687:\t\tif (sizeof_priv)\n1688:\t\t\talloc_size = ALIGN(sizeof(*iio_dev_opaque), IIO_DMA_MINALIGN) + sizeof_priv;\n1689:\t\telse\n1690:\t\t\talloc_size = sizeof(*iio_dev_opaque);\n1691:\t\n1692:\t\tiio_dev_opaque = kzalloc(alloc_size, GFP_KERNEL);\n1693:\t\tif (!iio_dev_opaque)\n1694:\t\t\treturn NULL;\n1695:\t\n1696:\t\tindio_dev = \u0026iio_dev_opaque-\u003eindio_dev;\n1697:\t\n1698:\t\tif (sizeof_priv)\n1699:\t\t\tACCESS_PRIVATE(indio_dev, priv) = (char *)iio_dev_opaque +\n1700:\t\t\t\tALIGN(sizeof(*iio_dev_opaque), IIO_DMA_MINALIGN);\n"
}

65/3 2026/10/30 15:09 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 37414
							output: 402
							thoughts: 1405
						

Thoughts:
**KMSAN Assessment: No Need for It Here**

Okay, let's break this down from a KMSAN perspective. We're looking for uninitialized memory risks, and I'm not seeing any.

First, the `iio_dev_opaque` in `hid-sensor-als.c` is `kzalloc`'d. This means the entire block, including the private area (`als_state`), is zeroed out. The relevant code, particularly `als_parse_report`, explicitly initializes `scale_precision`, `scale_pre_decml`, and `scale_post_decml` for each channel. If a channel isn't present, the code skips it, and we have a bounds check. Even if somehow read, `als_state` was kzalloc'd so all fields are 0. So, no uninitialized memory there.

The changes in `exec.c` regarding `io_uring` cancellation are timing-related to avoid race conditions during `execve`, but not related to uninitialized memory.

The `fs/smb/server/server.c` change is a synchronization fix, again not involving uninitialized data.

The `fs/smb/smbdirect/*` fixes are all about RDMA connection handling, orphan cleanup, RCU usage, and error handling. However, critically, all relevant data structures (`smbdirect_socket`, etc.) are allocated with `kzalloc_obj` or `kzalloc`. No new paths for uninitialized memory exposure.

The `kernel/fork.c` change prevents io_thread creation for dying tasks. Again, not related to uninitialized memory.

`scripts/link-vmlinux.sh` is a build script.

Now, let's apply the KMSAN criteria:

*   **Kernel structures to userspace:** Nope. The structures are all initialized or zeroed.
*   **Conditional logic on uninitialized variables:** No.
*   **Complex data structure allocation/initialization:** Nope. Everything is being zeroed or explicitly initialized.
*   **Bounds checks/lengths allowing access to uninitialized data:** The bounds check was added to `hid-sensor-als.c` to *prevent* uninitialized memory access.

So, according to the guidelines, the changes primarily address concurrency, synchronization, resource management, and error handling, but *not* uninitialized memory risks. The potential bugs are within the domain of KASAN/LOCKDEP rather than KMSAN.

Therefore, `NeedsKMSAN = false`. Let's run the `set-results` tool and move on.



66/3 2026/10/30 15:10 tool set-results
0m Args:
{
  "KMSANReasoning": "The patch series consists of changes across several subsystems:\n1. drivers/iio/light/hid-sensor-als.c: Converts scalar scale properties into per-channel arrays and adds bounds checking on chan-\u003escan_index. The device state struct als_state is zero-allocated via devm_iio_device_alloc() (kzalloc), and present channels are explicitly initialized with hid_sensor_format_scale().\n2. drivers/platform/cznic/turris-omnia-mcu-base.c: Adds MODULE_DEVICE_TABLE(of, ...).\n3. fs/exec.c: Moves io_uring_task_cancel() before de_thread() in begin_new_exec() to avoid race conditions with io-wq workers.\n4. fs/smb/server/server.c: Adds wait_event() in queue_ksmbd_work() during negotiation to serialize connection ops modification.\n5. fs/smb/smbdirect/*: Fixes RDMA connection accept error handling, connection teardown races, and orphan socket cleanup using kfree_rcu(). All involved structures are zero-initialized via kzalloc_obj(), and no uninitialized memory is read or copied to userspace.\n6. kernel/fork.c: Rejects create_io_thread() if current task has PF_SIGNALED or PF_POSTCOREDUMP.\n7. scripts/link-vmlinux.sh: Adjusts kallsyms object comparison logic during kernel link.\n\nNone of these modifications create paths where uninitialized memory could be evaluated in conditional logic or leaked to userspace. Potential concurrency, lifetime, or memory safety issues are covered by KASAN and LOCKDEP. Thus, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

Results:
{
  "KMSANReasoning": "The patch series consists of changes across several subsystems:\n1. drivers/iio/light/hid-sensor-als.c: Converts scalar scale properties into per-channel arrays and adds bounds checking on chan-\u003escan_index. The device state struct als_state is zero-allocated via devm_iio_device_alloc() (kzalloc), and present channels are explicitly initialized with hid_sensor_format_scale().\n2. drivers/platform/cznic/turris-omnia-mcu-base.c: Adds MODULE_DEVICE_TABLE(of, ...).\n3. fs/exec.c: Moves io_uring_task_cancel() before de_thread() in begin_new_exec() to avoid race conditions with io-wq workers.\n4. fs/smb/server/server.c: Adds wait_event() in queue_ksmbd_work() during negotiation to serialize connection ops modification.\n5. fs/smb/smbdirect/*: Fixes RDMA connection accept error handling, connection teardown races, and orphan socket cleanup using kfree_rcu(). All involved structures are zero-initialized via kzalloc_obj(), and no uninitialized memory is read or copied to userspace.\n6. kernel/fork.c: Rejects create_io_thread() if current task has PF_SIGNALED or PF_POSTCOREDUMP.\n7. scripts/link-vmlinux.sh: Adjusts kallsyms object comparison logic during kernel link.\n\nNone of these modifications create paths where uninitialized memory could be evaluated in conditional logic or leaked to userspace. Potential concurrency, lifetime, or memory safety issues are covered by KASAN and LOCKDEP. Thus, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": 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)