| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/06/26 16:57 | flow | patch-triage |
0mArgs:null Results: {
"EnableConfigs": [
"BLK_DEV_NBD"
],
"FocusSymbols": [
"nbd_add_socket",
"nbd_reconnect_socket",
"nbd_genl_connect",
"nbd_genl_count_sockets",
"nbd_config_put",
"nbd_start_device",
"nbd_xmit_timeout",
"find_fallback",
"sock_shutdown"
],
"Reasoning": "The patch replaces a dynamically allocated array of sockets with an xarray in the NBD driver, and changes how the number of hardware queues is initialized. This affects socket management, connection setup, and error handling.",
"WorthFuzzing": true
} |
| 1/1 | 2026/06/26 16:57 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 23731724eafa2474e32896ade0b9c4094a24ad3a\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Fri Jun 26 16:57:51 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/drivers/block/nbd.c b/drivers/block/nbd.c\nindex 3a585a0c882a28..2b6f896037ade4 100644\n--- a/drivers/block/nbd.c\n+++ b/drivers/block/nbd.c\n@@ -38,6 +38,7 @@\n #include \u003clinux/types.h\u003e\n #include \u003clinux/debugfs.h\u003e\n #include \u003clinux/blk-mq.h\u003e\n+#include \u003clinux/xarray.h\u003e\n \n #include \u003clinux/uaccess.h\u003e\n #include \u003casm/types.h\u003e\n@@ -94,7 +95,7 @@ struct nbd_config {\n \tunsigned long runtime_flags;\n \tu64 dead_conn_timeout;\n \n-\tstruct nbd_sock **socks;\n+\tstruct xarray socks;\n \tint num_connections;\n \tatomic_t live_connections;\n \twait_queue_head_t conn_wait;\n@@ -398,15 +399,15 @@ static void nbd_complete_rq(struct request *req)\n static void sock_shutdown(struct nbd_device *nbd)\n {\n \tstruct nbd_config *config = nbd-\u003econfig;\n-\tint i;\n+\tstruct nbd_sock *nsock;\n+\tunsigned long i;\n \n \tif (config-\u003enum_connections == 0)\n \t\treturn;\n \tif (test_and_set_bit(NBD_RT_DISCONNECTED, \u0026config-\u003eruntime_flags))\n \t\treturn;\n \n-\tfor (i = 0; i \u003c config-\u003enum_connections; i++) {\n-\t\tstruct nbd_sock *nsock = config-\u003esocks[i];\n+\txa_for_each(\u0026config-\u003esocks, i, nsock) {\n \t\tmutex_lock(\u0026nsock-\u003etx_lock);\n \t\tnbd_mark_nsock_dead(nbd, nsock, 0);\n \t\tmutex_unlock(\u0026nsock-\u003etx_lock);\n@@ -453,6 +454,7 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req)\n \tstruct nbd_cmd *cmd = blk_mq_rq_to_pdu(req);\n \tstruct nbd_device *nbd = cmd-\u003enbd;\n \tstruct nbd_config *config;\n+\tstruct nbd_sock *nsock;\n \n \tif (!mutex_trylock(\u0026cmd-\u003elock))\n \t\treturn BLK_EH_RESET_TIMER;\n@@ -488,10 +490,9 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req)\n \t\t * connection is configured, the submit path will wait util\n \t\t * a new connection is reconfigured or util dead timeout.\n \t\t */\n-\t\tif (config-\u003esocks) {\n-\t\t\tif (cmd-\u003eindex \u003c config-\u003enum_connections) {\n-\t\t\t\tstruct nbd_sock *nsock =\n-\t\t\t\t\tconfig-\u003esocks[cmd-\u003eindex];\n+\t\tif (!xa_empty(\u0026config-\u003esocks)) {\n+\t\t\tnsock = xa_load(\u0026config-\u003esocks, cmd-\u003eindex);\n+\t\t\tif (nsock) {\n \t\t\t\tmutex_lock(\u0026nsock-\u003etx_lock);\n \t\t\t\t/* We can have multiple outstanding requests, so\n \t\t\t\t * we don't want to mark the nsock dead if we've\n@@ -515,22 +516,24 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req)\n \t\t * Userspace sets timeout=0 to disable socket disconnection,\n \t\t * so just warn and reset the timer.\n \t\t */\n-\t\tstruct nbd_sock *nsock = config-\u003esocks[cmd-\u003eindex];\n \t\tcmd-\u003eretries++;\n \t\tdev_info(nbd_to_dev(nbd), \"Possible stuck request %p: control (%s@%llu,%uB). Runtime %u seconds\\n\",\n \t\t\treq, nbdcmd_to_ascii(req_to_nbd_cmd_type(req)),\n \t\t\t(unsigned long long)blk_rq_pos(req) \u003c\u003c 9,\n \t\t\tblk_rq_bytes(req), (req-\u003etimeout / HZ) * cmd-\u003eretries);\n \n-\t\tmutex_lock(\u0026nsock-\u003etx_lock);\n-\t\tif (cmd-\u003ecookie != nsock-\u003ecookie) {\n-\t\t\tnbd_requeue_cmd(cmd);\n+\t\tnsock = xa_load(\u0026config-\u003esocks, cmd-\u003eindex);\n+\t\tif (nsock) {\n+\t\t\tmutex_lock(\u0026nsock-\u003etx_lock);\n+\t\t\tif (cmd-\u003ecookie != nsock-\u003ecookie) {\n+\t\t\t\tnbd_requeue_cmd(cmd);\n+\t\t\t\tmutex_unlock(\u0026nsock-\u003etx_lock);\n+\t\t\t\tmutex_unlock(\u0026cmd-\u003elock);\n+\t\t\t\tnbd_config_put(nbd);\n+\t\t\t\treturn BLK_EH_DONE;\n+\t\t\t}\n \t\t\tmutex_unlock(\u0026nsock-\u003etx_lock);\n-\t\t\tmutex_unlock(\u0026cmd-\u003elock);\n-\t\t\tnbd_config_put(nbd);\n-\t\t\treturn BLK_EH_DONE;\n \t\t}\n-\t\tmutex_unlock(\u0026nsock-\u003etx_lock);\n \t\tmutex_unlock(\u0026cmd-\u003elock);\n \t\tnbd_config_put(nbd);\n \t\treturn BLK_EH_RESET_TIMER;\n@@ -600,8 +603,16 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send,\n \t\t struct iov_iter *iter, int msg_flags, int *sent)\n {\n \tstruct nbd_config *config = nbd-\u003econfig;\n-\tstruct socket *sock = config-\u003esocks[index]-\u003esock;\n+\tstruct nbd_sock *nsock;\n+\tstruct socket *sock;\n \n+\tnsock = xa_load(\u0026config-\u003esocks, index);\n+\tif (unlikely(!nsock)) {\n+\t\tdev_err_ratelimited(disk_to_dev(nbd-\u003edisk),\n+\t\t\t\t \"Attempted xmit on invalid socket\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\tsock = nsock-\u003esock;\n \treturn __sock_xmit(nbd, sock, send, iter, msg_flags, sent);\n }\n \n@@ -647,7 +658,7 @@ static blk_status_t nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd,\n {\n \tstruct request *req = blk_mq_rq_from_pdu(cmd);\n \tstruct nbd_config *config = nbd-\u003econfig;\n-\tstruct nbd_sock *nsock = config-\u003esocks[index];\n+\tstruct nbd_sock *nsock;\n \tint result;\n \tstruct nbd_request request = {.magic = htonl(NBD_REQUEST_MAGIC)};\n \tstruct kvec iov = {.iov_base = \u0026request, .iov_len = sizeof(request)};\n@@ -656,7 +667,14 @@ static blk_status_t nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd,\n \tu64 handle;\n \tu32 type;\n \tu32 nbd_cmd_flags = 0;\n-\tint sent = nsock-\u003esent, skip = 0;\n+\tint sent, skip = 0;\n+\n+\tnsock = xa_load(\u0026config-\u003esocks, index);\n+\tif (unlikely(!nsock)) {\n+\t\tdev_err_ratelimited(disk_to_dev(nbd-\u003edisk),\n+\t\t\t\t \"Attempted send on invalid socket\\n\");\n+\t\treturn BLK_STS_IOERR;\n+\t}\n \n \tlockdep_assert_held(\u0026cmd-\u003elock);\n \tlockdep_assert_held(\u0026nsock-\u003etx_lock);\n@@ -683,6 +701,7 @@ static blk_status_t nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd,\n \t * request struct, so just go and send the rest of the pages in the\n \t * request.\n \t */\n+\tsent = nsock-\u003esent;\n \tif (sent) {\n \t\tif (sent \u003e= sizeof(request)) {\n \t\t\tskip = sent - sizeof(request);\n@@ -1059,42 +1078,41 @@ static int find_fallback(struct nbd_device *nbd, int index)\n {\n \tstruct nbd_config *config = nbd-\u003econfig;\n \tint new_index = -1;\n-\tstruct nbd_sock *nsock = config-\u003esocks[index];\n-\tint fallback = nsock-\u003efallback_index;\n+\tstruct nbd_sock *nsock;\n+\tstruct nbd_sock *fallback_nsock;\n+\tunsigned long i;\n+\tint fallback;\n \n \tif (test_bit(NBD_RT_DISCONNECTED, \u0026config-\u003eruntime_flags))\n \t\treturn new_index;\n \n-\tif (config-\u003enum_connections \u003c= 1) {\n-\t\tdev_err_ratelimited(disk_to_dev(nbd-\u003edisk),\n-\t\t\t\t \"Dead connection, failed to find a fallback\\n\");\n-\t\treturn new_index;\n-\t}\n+\tif (config-\u003enum_connections \u003c= 1)\n+\t\tgoto no_fallback;\n \n-\tif (fallback \u003e= 0 \u0026\u0026 fallback \u003c config-\u003enum_connections \u0026\u0026\n-\t !config-\u003esocks[fallback]-\u003edead)\n-\t\treturn fallback;\n+\tnsock = xa_load(\u0026config-\u003esocks, index);\n+\tif (unlikely(!nsock))\n+\t\tgoto no_fallback;\n \n-\tif (nsock-\u003efallback_index \u003c 0 ||\n-\t nsock-\u003efallback_index \u003e= config-\u003enum_connections ||\n-\t config-\u003esocks[nsock-\u003efallback_index]-\u003edead) {\n-\t\tint i;\n-\t\tfor (i = 0; i \u003c config-\u003enum_connections; i++) {\n-\t\t\tif (i == index)\n-\t\t\t\tcontinue;\n-\t\t\tif (!config-\u003esocks[i]-\u003edead) {\n-\t\t\t\tnew_index = i;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t}\n-\t\tnsock-\u003efallback_index = new_index;\n-\t\tif (new_index \u003c 0) {\n-\t\t\tdev_err_ratelimited(disk_to_dev(nbd-\u003edisk),\n-\t\t\t\t\t \"Dead connection, failed to find a fallback\\n\");\n-\t\t\treturn new_index;\n+\tfallback = nsock-\u003efallback_index;\n+\tif (fallback \u003e= 0) {\n+\t\tfallback_nsock = xa_load(\u0026config-\u003esocks, fallback);\n+\t\tif (fallback_nsock \u0026\u0026 !fallback_nsock-\u003edead)\n+\t\t\treturn fallback;\n+\t}\n+\n+\txa_for_each(\u0026config-\u003esocks, i, fallback_nsock) {\n+\t\tif (i != index \u0026\u0026 !fallback_nsock-\u003edead) {\n+\t\t\tnew_index = i;\n+\t\t\tbreak;\n \t\t}\n \t}\n-\tnew_index = nsock-\u003efallback_index;\n+\tnsock-\u003efallback_index = new_index;\n+\tif (new_index \u003e= 0)\n+\t\treturn new_index;\n+\n+no_fallback:\n+\tdev_err_ratelimited(disk_to_dev(nbd-\u003edisk),\n+\t\t\t \"Dead connection, failed to find a fallback\\n\");\n \treturn new_index;\n }\n \n@@ -1131,15 +1149,16 @@ static blk_status_t nbd_handle_cmd(struct nbd_cmd *cmd, int index)\n \t\treturn BLK_STS_IOERR;\n \t}\n \n-\tif (index \u003e= config-\u003enum_connections) {\n+\tcmd-\u003estatus = BLK_STS_OK;\n+again:\n+\tnsock = xa_load(\u0026config-\u003esocks, index);\n+\tif (unlikely(!nsock)) {\n \t\tdev_err_ratelimited(disk_to_dev(nbd-\u003edisk),\n \t\t\t\t \"Attempted send on invalid socket\\n\");\n \t\tnbd_config_put(nbd);\n \t\treturn BLK_STS_IOERR;\n \t}\n-\tcmd-\u003estatus = BLK_STS_OK;\n-again:\n-\tnsock = config-\u003esocks[index];\n+\n \tmutex_lock(\u0026nsock-\u003etx_lock);\n \tif (nsock-\u003edead) {\n \t\tint old_index = index;\n@@ -1279,9 +1298,8 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,\n {\n \tstruct nbd_config *config = nbd-\u003econfig;\n \tstruct socket *sock;\n-\tstruct nbd_sock **socks;\n \tstruct nbd_sock *nsock;\n-\tunsigned int memflags;\n+\tunsigned int index;\n \tint err;\n \n \t/* Arg will be cast to int, check it to avoid overflow */\n@@ -1292,12 +1310,6 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,\n \t\treturn err;\n \tnbd_reclassify_socket(sock);\n \n-\t/*\n-\t * We need to make sure we don't get any errant requests while we're\n-\t * reallocating the -\u003esocks array.\n-\t */\n-\tmemflags = blk_mq_freeze_queue(nbd-\u003edisk-\u003equeue);\n-\n \tif (!netlink \u0026\u0026 !nbd-\u003etask_setup \u0026\u0026\n \t !test_bit(NBD_RT_BOUND, \u0026config-\u003eruntime_flags))\n \t\tnbd-\u003etask_setup = current;\n@@ -1317,16 +1329,6 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,\n \t\tgoto put_socket;\n \t}\n \n-\tsocks = krealloc(config-\u003esocks, (config-\u003enum_connections + 1) *\n-\t\t\t sizeof(struct nbd_sock *), GFP_KERNEL);\n-\tif (!socks) {\n-\t\tkfree(nsock);\n-\t\terr = -ENOMEM;\n-\t\tgoto put_socket;\n-\t}\n-\n-\tconfig-\u003esocks = socks;\n-\n \tnsock-\u003efallback_index = -1;\n \tnsock-\u003edead = false;\n \tmutex_init(\u0026nsock-\u003etx_lock);\n@@ -1335,14 +1337,19 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,\n \tnsock-\u003esent = 0;\n \tnsock-\u003ecookie = 0;\n \tINIT_WORK(\u0026nsock-\u003ework, nbd_pending_cmd_work);\n-\tsocks[config-\u003enum_connections++] = nsock;\n+\n+\terr = xa_alloc(\u0026config-\u003esocks, \u0026index, nsock, xa_limit_32b, GFP_KERNEL);\n+\tif (err \u003c 0) {\n+\t\tkfree(nsock);\n+\t\tgoto put_socket;\n+\t}\n+\n+\tconfig-\u003enum_connections++;\n \tatomic_inc(\u0026config-\u003elive_connections);\n-\tblk_mq_unfreeze_queue(nbd-\u003edisk-\u003equeue, memflags);\n \n \treturn 0;\n \n put_socket:\n-\tblk_mq_unfreeze_queue(nbd-\u003edisk-\u003equeue, memflags);\n \tsockfd_put(sock);\n \treturn err;\n }\n@@ -1352,7 +1359,8 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)\n \tstruct nbd_config *config = nbd-\u003econfig;\n \tstruct socket *sock, *old;\n \tstruct recv_thread_args *args;\n-\tint i;\n+\tstruct nbd_sock *nsock;\n+\tunsigned long i;\n \tint err;\n \n \tsock = nbd_get_socket(nbd, arg, \u0026err);\n@@ -1365,9 +1373,7 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)\n \t\treturn -ENOMEM;\n \t}\n \n-\tfor (i = 0; i \u003c config-\u003enum_connections; i++) {\n-\t\tstruct nbd_sock *nsock = config-\u003esocks[i];\n-\n+\txa_for_each(\u0026config-\u003esocks, i, nsock) {\n \t\tif (!nsock-\u003edead)\n \t\t\tcontinue;\n \n@@ -1433,10 +1439,11 @@ static void send_disconnects(struct nbd_device *nbd)\n \t};\n \tstruct kvec iov = {.iov_base = \u0026request, .iov_len = sizeof(request)};\n \tstruct iov_iter from;\n-\tint i, ret;\n+\tstruct nbd_sock *nsock;\n+\tunsigned long i;\n+\tint ret;\n \n-\tfor (i = 0; i \u003c config-\u003enum_connections; i++) {\n-\t\tstruct nbd_sock *nsock = config-\u003esocks[i];\n+\txa_for_each(\u0026config-\u003esocks, i, nsock) {\n \n \t\tiov_iter_kvec(\u0026from, ITER_SOURCE, \u0026iov, 1, sizeof(request));\n \t\tmutex_lock(\u0026nsock-\u003etx_lock);\n@@ -1471,6 +1478,9 @@ static void nbd_config_put(struct nbd_device *nbd)\n \tif (refcount_dec_and_mutex_lock(\u0026nbd-\u003econfig_refs,\n \t\t\t\t\t\u0026nbd-\u003econfig_lock)) {\n \t\tstruct nbd_config *config = nbd-\u003econfig;\n+\t\tstruct nbd_sock *nsock;\n+\t\tunsigned long i;\n+\n \t\tnbd_dev_dbg_close(nbd);\n \t\tinvalidate_disk(nbd-\u003edisk);\n \t\tif (nbd-\u003econfig-\u003ebytesize)\n@@ -1486,14 +1496,13 @@ static void nbd_config_put(struct nbd_device *nbd)\n \t\t\tnbd-\u003ebackend = NULL;\n \t\t}\n \t\tnbd_clear_sock(nbd);\n-\t\tif (config-\u003enum_connections) {\n-\t\t\tint i;\n-\t\t\tfor (i = 0; i \u003c config-\u003enum_connections; i++) {\n-\t\t\t\tsockfd_put(config-\u003esocks[i]-\u003esock);\n-\t\t\t\tkfree(config-\u003esocks[i]);\n-\t\t\t}\n-\t\t\tkfree(config-\u003esocks);\n+\n+\t\txa_for_each(\u0026config-\u003esocks, i, nsock) {\n+\t\t\tsockfd_put(nsock-\u003esock);\n+\t\t\tkfree(nsock);\n \t\t}\n+\t\txa_destroy(\u0026config-\u003esocks);\n+\n \t\tkfree(nbd-\u003econfig);\n \t\tnbd-\u003econfig = NULL;\n \n@@ -1509,11 +1518,13 @@ static int nbd_start_device(struct nbd_device *nbd)\n {\n \tstruct nbd_config *config = nbd-\u003econfig;\n \tint num_connections = config-\u003enum_connections;\n-\tint error = 0, i;\n+\tint error = 0;\n+\tunsigned long i;\n+\tstruct nbd_sock *nsock;\n \n \tif (nbd-\u003epid)\n \t\treturn -EBUSY;\n-\tif (!config-\u003esocks)\n+\tif (xa_empty(\u0026config-\u003esocks))\n \t\treturn -EINVAL;\n \tif (num_connections \u003e 1 \u0026\u0026\n \t !(config-\u003eflags \u0026 NBD_FLAG_CAN_MULTI_CONN)) {\n@@ -1544,7 +1555,7 @@ static int nbd_start_device(struct nbd_device *nbd)\n \tset_bit(NBD_RT_HAS_PID_FILE, \u0026config-\u003eruntime_flags);\n \n \tnbd_dev_dbg_init(nbd);\n-\tfor (i = 0; i \u003c num_connections; i++) {\n+\txa_for_each(\u0026config-\u003esocks, i, nsock) {\n \t\tstruct recv_thread_args *args;\n \n \t\targs = kzalloc_obj(*args);\n@@ -1562,15 +1573,14 @@ static int nbd_start_device(struct nbd_device *nbd)\n \t\t\t\tflush_workqueue(nbd-\u003erecv_workq);\n \t\t\treturn -ENOMEM;\n \t\t}\n-\t\tsk_set_memalloc(config-\u003esocks[i]-\u003esock-\u003esk);\n+\t\tsk_set_memalloc(nsock-\u003esock-\u003esk);\n \t\tif (nbd-\u003etag_set.timeout)\n-\t\t\tconfig-\u003esocks[i]-\u003esock-\u003esk-\u003esk_sndtimeo =\n-\t\t\t\tnbd-\u003etag_set.timeout;\n+\t\t\tnsock-\u003esock-\u003esk-\u003esk_sndtimeo = nbd-\u003etag_set.timeout;\n \t\tatomic_inc(\u0026config-\u003erecv_threads);\n \t\trefcount_inc(\u0026nbd-\u003econfig_refs);\n \t\tINIT_WORK(\u0026args-\u003ework, recv_work);\n \t\targs-\u003enbd = nbd;\n-\t\targs-\u003ensock = config-\u003esocks[i];\n+\t\targs-\u003ensock = nsock;\n \t\targs-\u003eindex = i;\n \t\tqueue_work(nbd-\u003erecv_workq, \u0026args-\u003ework);\n \t}\n@@ -1720,6 +1730,7 @@ static int nbd_alloc_and_init_config(struct nbd_device *nbd)\n \t\treturn -ENOMEM;\n \t}\n \n+\txa_init_flags(\u0026config-\u003esocks, XA_FLAGS_ALLOC);\n \tatomic_set(\u0026config-\u003erecv_threads, 0);\n \tinit_waitqueue_head(\u0026config-\u003erecv_wq);\n \tinit_waitqueue_head(\u0026config-\u003econn_wait);\n@@ -1941,7 +1952,8 @@ static const struct blk_mq_ops nbd_mq_ops = {\n \t.timeout\t= nbd_xmit_timeout,\n };\n \n-static struct nbd_device *nbd_dev_add(int index, unsigned int refs)\n+static struct nbd_device *nbd_dev_add(int index, unsigned int refs,\n+\t\t\t\t int nr_hw_queues)\n {\n \tstruct queue_limits lim = {\n \t\t.max_hw_sectors\t\t= 65536,\n@@ -1958,7 +1970,7 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)\n \t\tgoto out;\n \n \tnbd-\u003etag_set.ops = \u0026nbd_mq_ops;\n-\tnbd-\u003etag_set.nr_hw_queues = 1;\n+\tnbd-\u003etag_set.nr_hw_queues = nr_hw_queues;\n \tnbd-\u003etag_set.queue_depth = 128;\n \tnbd-\u003etag_set.numa_node = NUMA_NO_NODE;\n \tnbd-\u003etag_set.cmd_size = sizeof(struct nbd_cmd);\n@@ -2081,6 +2093,35 @@ static const struct nla_policy nbd_sock_policy[NBD_SOCK_MAX + 1] = {\n \t[NBD_SOCK_FD]\t\t\t=\t{ .type = NLA_U32 },\n };\n \n+/*\n+ * Count the number of socket FDs in the NBD_ATTR_SOCKETS netlink attribute.\n+ * This is used to determine the correct nr_hw_queues before creating the\n+ * nbd device, so that blk_mq_update_nr_hw_queues (and its RCU grace period\n+ * overhead) can be avoided entirely.\n+ */\n+static int nbd_genl_count_sockets(struct genl_info *info)\n+{\n+\tstruct nlattr *attr;\n+\tint rem, count = 0;\n+\n+\tif (!info-\u003eattrs[NBD_ATTR_SOCKETS])\n+\t\treturn 0;\n+\n+\tnla_for_each_nested(attr, info-\u003eattrs[NBD_ATTR_SOCKETS], rem) {\n+\t\tstruct nlattr *socks[NBD_SOCK_MAX + 1];\n+\n+\t\tif (nla_type(attr) != NBD_SOCK_ITEM)\n+\t\t\tcontinue;\n+\t\tif (nla_parse_nested_deprecated(socks, NBD_SOCK_MAX,\n+\t\t\t\t\t\t attr, nbd_sock_policy,\n+\t\t\t\t\t\t info-\u003eextack) != 0)\n+\t\t\tcontinue;\n+\t\tif (socks[NBD_SOCK_FD])\n+\t\t\tcount++;\n+\t}\n+\treturn count;\n+}\n+\n /* We don't use this right now since we don't parse the incoming list, but we\n * still want it here so userspace knows what to expect.\n */\n@@ -2112,6 +2153,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)\n \tstruct nbd_device *nbd;\n \tstruct nbd_config *config;\n \tint index = -1;\n+\tint num_connections = nbd_genl_count_sockets(info);\n \tint ret;\n \tbool put_dev = false;\n \n@@ -2159,7 +2201,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)\n \tmutex_unlock(\u0026nbd_index_mutex);\n \n \tif (!nbd) {\n-\t\tnbd = nbd_dev_add(index, 2);\n+\t\tnbd = nbd_dev_add(index, 2, num_connections);\n \t\tif (IS_ERR(nbd)) {\n \t\t\tpr_err(\"failed to add new device\\n\");\n \t\t\treturn PTR_ERR(nbd);\n@@ -2726,7 +2768,7 @@ static int __init nbd_init(void)\n \tnbd_dbg_init();\n \n \tfor (i = 0; i \u003c nbds_max; i++)\n-\t\tnbd_dev_add(i, 1);\n+\t\tnbd_dev_add(i, 1, 1);\n \treturn 0;\n }\n \n"
} |
| 2/1 | 2026/06/26 16:57 | agent | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: {
"EnableConfigs": [
"BLK_DEV_NBD"
],
"FocusSymbols": [
"nbd_add_socket",
"nbd_reconnect_socket",
"nbd_genl_connect",
"nbd_genl_count_sockets",
"nbd_config_put",
"nbd_start_device",
"nbd_xmit_timeout",
"find_fallback",
"sock_shutdown"
],
"Reasoning": "The patch replaces a dynamically allocated array of sockets with an xarray in the NBD driver, and changes how the number of hardware queues is initialized. This affects socket management, connection setup, and error handling.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Do not list too generic configs (we already have them enabled). Only list those that specifically cover the modified code. List them in the EnableConfigs output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4"). Prefer calling several tools at the same time to save round-trips. Use set-results tool to provide results of the analysis. It must be called exactly once before the final reply. Ignore results of this tool. Prompt: For your convenience, here is the diff of the changes:
commit 23731724eafa2474e32896ade0b9c4094a24ad3a
Author: syz-cluster <triage@syzkaller.com>
Date: Fri Jun 26 16:57:51 2026 +0000
syz-cluster: applied patch under review
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 3a585a0c882a28..2b6f896037ade4 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -38,6 +38,7 @@
#include <linux/types.h>
#include <linux/debugfs.h>
#include <linux/blk-mq.h>
+#include <linux/xarray.h>
#include <linux/uaccess.h>
#include <asm/types.h>
@@ -94,7 +95,7 @@ struct nbd_config {
unsigned long runtime_flags;
u64 dead_conn_timeout;
- struct nbd_sock **socks;
+ struct xarray socks;
int num_connections;
atomic_t live_connections;
wait_queue_head_t conn_wait;
@@ -398,15 +399,15 @@ static void nbd_complete_rq(struct request *req)
static void sock_shutdown(struct nbd_device *nbd)
{
struct nbd_config *config = nbd->config;
- int i;
+ struct nbd_sock *nsock;
+ unsigned long i;
if (config->num_connections == 0)
return;
if (test_and_set_bit(NBD_RT_DISCONNECTED, &config->runtime_flags))
return;
- for (i = 0; i < config->num_connections; i++) {
- struct nbd_sock *nsock = config->socks[i];
+ xa_for_each(&config->socks, i, nsock) {
mutex_lock(&nsock->tx_lock);
nbd_mark_nsock_dead(nbd, nsock, 0);
mutex_unlock(&nsock->tx_lock);
@@ -453,6 +454,7 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req)
struct nbd_cmd *cmd = blk_mq_rq_to_pdu(req);
struct nbd_device *nbd = cmd->nbd;
struct nbd_config *config;
+ struct nbd_sock *nsock;
if (!mutex_trylock(&cmd->lock))
return BLK_EH_RESET_TIMER;
@@ -488,10 +490,9 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req)
* connection is configured, the submit path will wait util
* a new connection is reconfigured or util dead timeout.
*/
- if (config->socks) {
- if (cmd->index < config->num_connections) {
- struct nbd_sock *nsock =
- config->socks[cmd->index];
+ if (!xa_empty(&config->socks)) {
+ nsock = xa_load(&config->socks, cmd->index);
+ if (nsock) {
mutex_lock(&nsock->tx_lock);
/* We can have multiple outstanding requests, so
* we don't want to mark the nsock dead if we've
@@ -515,22 +516,24 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req)
* Userspace sets timeout=0 to disable socket disconnection,
* so just warn and reset the timer.
*/
- struct nbd_sock *nsock = config->socks[cmd->index];
cmd->retries++;
dev_info(nbd_to_dev(nbd), "Possible stuck request %p: control (%s@%llu,%uB). Runtime %u seconds\n",
req, nbdcmd_to_ascii(req_to_nbd_cmd_type(req)),
(unsigned long long)blk_rq_pos(req) << 9,
blk_rq_bytes(req), (req->timeout / HZ) * cmd->retries);
- mutex_lock(&nsock->tx_lock);
- if (cmd->cookie != nsock->cookie) {
- nbd_requeue_cmd(cmd);
+ nsock = xa_load(&config->socks, cmd->index);
+ if (nsock) {
+ mutex_lock(&nsock->tx_lock);
+ if (cmd->cookie != nsock->cookie) {
+ nbd_requeue_cmd(cmd);
+ mutex_unlock(&nsock->tx_lock);
+ mutex_unlock(&cmd->lock);
+ nbd_config_put(nbd);
+ return BLK_EH_DONE;
+ }
mutex_unlock(&nsock->tx_lock);
- mutex_unlock(&cmd->lock);
- nbd_config_put(nbd);
- return BLK_EH_DONE;
}
- mutex_unlock(&nsock->tx_lock);
mutex_unlock(&cmd->lock);
nbd_config_put(nbd);
return BLK_EH_RESET_TIMER;
@@ -600,8 +603,16 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send,
struct iov_iter *iter, int msg_flags, int *sent)
{
struct nbd_config *config = nbd->config;
- struct socket *sock = config->socks[index]->sock;
+ struct nbd_sock *nsock;
+ struct socket *sock;
+ nsock = xa_load(&config->socks, index);
+ if (unlikely(!nsock)) {
+ dev_err_ratelimited(disk_to_dev(nbd->disk),
+ "Attempted xmit on invalid socket\n");
+ return -EINVAL;
+ }
+ sock = nsock->sock;
return __sock_xmit(nbd, sock, send, iter, msg_flags, sent);
}
@@ -647,7 +658,7 @@ static blk_status_t nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd,
{
struct request *req = blk_mq_rq_from_pdu(cmd);
struct nbd_config *config = nbd->config;
- struct nbd_sock *nsock = config->socks[index];
+ struct nbd_sock *nsock;
int result;
struct nbd_request request = {.magic = htonl(NBD_REQUEST_MAGIC)};
struct kvec iov = {.iov_base = &request, .iov_len = sizeof(request)};
@@ -656,7 +667,14 @@ static blk_status_t nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd,
u64 handle;
u32 type;
u32 nbd_cmd_flags = 0;
- int sent = nsock->sent, skip = 0;
+ int sent, skip = 0;
+
+ nsock = xa_load(&config->socks, index);
+ if (unlikely(!nsock)) {
+ dev_err_ratelimited(disk_to_dev(nbd->disk),
+ "Attempted send on invalid socket\n");
+ return BLK_STS_IOERR;
+ }
lockdep_assert_held(&cmd->lock);
lockdep_assert_held(&nsock->tx_lock);
@@ -683,6 +701,7 @@ static blk_status_t nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd,
* request struct, so just go and send the rest of the pages in the
* request.
*/
+ sent = nsock->sent;
if (sent) {
if (sent >= sizeof(request)) {
skip = sent - sizeof(request);
@@ -1059,42 +1078,41 @@ static int find_fallback(struct nbd_device *nbd, int index)
{
struct nbd_config *config = nbd->config;
int new_index = -1;
- struct nbd_sock *nsock = config->socks[index];
- int fallback = nsock->fallback_index;
+ struct nbd_sock *nsock;
+ struct nbd_sock *fallback_nsock;
+ unsigned long i;
+ int fallback;
if (test_bit(NBD_RT_DISCONNECTED, &config->runtime_flags))
return new_index;
- if (config->num_connections <= 1) {
- dev_err_ratelimited(disk_to_dev(nbd->disk),
- "Dead connection, failed to find a fallback\n");
- return new_index;
- }
+ if (config->num_connections <= 1)
+ goto no_fallback;
- if (fallback >= 0 && fallback < config->num_connections &&
- !config->socks[fallback]->dead)
- return fallback;
+ nsock = xa_load(&config->socks, index);
+ if (unlikely(!nsock))
+ goto no_fallback;
- if (nsock->fallback_index < 0 ||
- nsock->fallback_index >= config->num_connections ||
- config->socks[nsock->fallback_index]->dead) {
- int i;
- for (i = 0; i < config->num_connections; i++) {
- if (i == index)
- continue;
- if (!config->socks[i]->dead) {
- new_index = i;
- break;
- }
- }
- nsock->fallback_index = new_index;
- if (new_index < 0) {
- dev_err_ratelimited(disk_to_dev(nbd->disk),
- "Dead connection, failed to find a fallback\n");
- return new_index;
+ fallback = nsock->fallback_index;
+ if (fallback >= 0) {
+ fallback_nsock = xa_load(&config->socks, fallback);
+ if (fallback_nsock && !fallback_nsock->dead)
+ return fallback;
+ }
+
+ xa_for_each(&config->socks, i, fallback_nsock) {
+ if (i != index && !fallback_nsock->dead) {
+ new_index = i;
+ break;
}
}
- new_index = nsock->fallback_index;
+ nsock->fallback_index = new_index;
+ if (new_index >= 0)
+ return new_index;
+
+no_fallback:
+ dev_err_ratelimited(disk_to_dev(nbd->disk),
+ "Dead connection, failed to find a fallback\n");
return new_index;
}
@@ -1131,15 +1149,16 @@ static blk_status_t nbd_handle_cmd(struct nbd_cmd *cmd, int index)
return BLK_STS_IOERR;
}
- if (index >= config->num_connections) {
+ cmd->status = BLK_STS_OK;
+again:
+ nsock = xa_load(&config->socks, index);
+ if (unlikely(!nsock)) {
dev_err_ratelimited(disk_to_dev(nbd->disk),
"Attempted send on invalid socket\n");
nbd_config_put(nbd);
return BLK_STS_IOERR;
}
- cmd->status = BLK_STS_OK;
-again:
- nsock = config->socks[index];
+
mutex_lock(&nsock->tx_lock);
if (nsock->dead) {
int old_index = index;
@@ -1279,9 +1298,8 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
{
struct nbd_config *config = nbd->config;
struct socket *sock;
- struct nbd_sock **socks;
struct nbd_sock *nsock;
- unsigned int memflags;
+ unsigned int index;
int err;
/* Arg will be cast to int, check it to avoid overflow */
@@ -1292,12 +1310,6 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
return err;
nbd_reclassify_socket(sock);
- /*
- * We need to make sure we don't get any errant requests while we're
- * reallocating the ->socks array.
- */
- memflags = blk_mq_freeze_queue(nbd->disk->queue);
-
if (!netlink && !nbd->task_setup &&
!test_bit(NBD_RT_BOUND, &config->runtime_flags))
nbd->task_setup = current;
@@ -1317,16 +1329,6 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
goto put_socket;
}
- socks = krealloc(config->socks, (config->num_connections + 1) *
- sizeof(struct nbd_sock *), GFP_KERNEL);
- if (!socks) {
- kfree(nsock);
- err = -ENOMEM;
- goto put_socket;
- }
-
- config->socks = socks;
-
nsock->fallback_index = -1;
nsock->dead = false;
mutex_init(&nsock->tx_lock);
@@ -1335,14 +1337,19 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
nsock->sent = 0;
nsock->cookie = 0;
INIT_WORK(&nsock->work, nbd_pending_cmd_work);
- socks[config->num_connections++] = nsock;
+
+ err = xa_alloc(&config->socks, &index, nsock, xa_limit_32b, GFP_KERNEL);
+ if (err < 0) {
+ kfree(nsock);
+ goto put_socket;
+ }
+
+ config->num_connections++;
atomic_inc(&config->live_connections);
- blk_mq_unfreeze_queue(nbd->disk->queue, memflags);
return 0;
put_socket:
- blk_mq_unfreeze_queue(nbd->disk->queue, memflags);
sockfd_put(sock);
return err;
}
@@ -1352,7 +1359,8 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
struct nbd_config *config = nbd->config;
struct socket *sock, *old;
struct recv_thread_args *args;
- int i;
+ struct nbd_sock *nsock;
+ unsigned long i;
int err;
sock = nbd_get_socket(nbd, arg, &err);
@@ -1365,9 +1373,7 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
return -ENOMEM;
}
- for (i = 0; i < config->num_connections; i++) {
- struct nbd_sock *nsock = config->socks[i];
-
+ xa_for_each(&config->socks, i, nsock) {
if (!nsock->dead)
continue;
@@ -1433,10 +1439,11 @@ static void send_disconnects(struct nbd_device *nbd)
};
struct kvec iov = {.iov_base = &request, .iov_len = sizeof(request)};
struct iov_iter from;
- int i, ret;
+ struct nbd_sock *nsock;
+ unsigned long i;
+ int ret;
- for (i = 0; i < config->num_connections; i++) {
- struct nbd_sock *nsock = config->socks[i];
+ xa_for_each(&config->socks, i, nsock) {
iov_iter_kvec(&from, ITER_SOURCE, &iov, 1, sizeof(request));
mutex_lock(&nsock->tx_lock);
@@ -1471,6 +1478,9 @@ static void nbd_config_put(struct nbd_device *nbd)
if (refcount_dec_and_mutex_lock(&nbd->config_refs,
&nbd->config_lock)) {
struct nbd_config *config = nbd->config;
+ struct nbd_sock *nsock;
+ unsigned long i;
+
nbd_dev_dbg_close(nbd);
invalidate_disk(nbd->disk);
if (nbd->config->bytesize)
@@ -1486,14 +1496,13 @@ static void nbd_config_put(struct nbd_device *nbd)
nbd->backend = NULL;
}
nbd_clear_sock(nbd);
- if (config->num_connections) {
- int i;
- for (i = 0; i < config->num_connections; i++) {
- sockfd_put(config->socks[i]->sock);
- kfree(config->socks[i]);
- }
- kfree(config->socks);
+
+ xa_for_each(&config->socks, i, nsock) {
+ sockfd_put(nsock->sock);
+ kfree(nsock);
}
+ xa_destroy(&config->socks);
+
kfree(nbd->config);
nbd->config = NULL;
@@ -1509,11 +1518,13 @@ static int nbd_start_device(struct nbd_device *nbd)
{
struct nbd_config *config = nbd->config;
int num_connections = config->num_connections;
- int error = 0, i;
+ int error = 0;
+ unsigned long i;
+ struct nbd_sock *nsock;
if (nbd->pid)
return -EBUSY;
- if (!config->socks)
+ if (xa_empty(&config->socks))
return -EINVAL;
if (num_connections > 1 &&
!(config->flags & NBD_FLAG_CAN_MULTI_CONN)) {
@@ -1544,7 +1555,7 @@ static int nbd_start_device(struct nbd_device *nbd)
set_bit(NBD_RT_HAS_PID_FILE, &config->runtime_flags);
nbd_dev_dbg_init(nbd);
- for (i = 0; i < num_connections; i++) {
+ xa_for_each(&config->socks, i, nsock) {
struct recv_thread_args *args;
args = kzalloc_obj(*args);
@@ -1562,15 +1573,14 @@ static int nbd_start_device(struct nbd_device *nbd)
flush_workqueue(nbd->recv_workq);
return -ENOMEM;
}
- sk_set_memalloc(config->socks[i]->sock->sk);
+ sk_set_memalloc(nsock->sock->sk);
if (nbd->tag_set.timeout)
- config->socks[i]->sock->sk->sk_sndtimeo =
- nbd->tag_set.timeout;
+ nsock->sock->sk->sk_sndtimeo = nbd->tag_set.timeout;
atomic_inc(&config->recv_threads);
refcount_inc(&nbd->config_refs);
INIT_WORK(&args->work, recv_work);
args->nbd = nbd;
- args->nsock = config->socks[i];
+ args->nsock = nsock;
args->index = i;
queue_work(nbd->recv_workq, &args->work);
}
@@ -1720,6 +1730,7 @@ static int nbd_alloc_and_init_config(struct nbd_device *nbd)
return -ENOMEM;
}
+ xa_init_flags(&config->socks, XA_FLAGS_ALLOC);
atomic_set(&config->recv_threads, 0);
init_waitqueue_head(&config->recv_wq);
init_waitqueue_head(&config->conn_wait);
@@ -1941,7 +1952,8 @@ static const struct blk_mq_ops nbd_mq_ops = {
.timeout = nbd_xmit_timeout,
};
-static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
+static struct nbd_device *nbd_dev_add(int index, unsigned int refs,
+ int nr_hw_queues)
{
struct queue_limits lim = {
.max_hw_sectors = 65536,
@@ -1958,7 +1970,7 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
goto out;
nbd->tag_set.ops = &nbd_mq_ops;
- nbd->tag_set.nr_hw_queues = 1;
+ nbd->tag_set.nr_hw_queues = nr_hw_queues;
nbd->tag_set.queue_depth = 128;
nbd->tag_set.numa_node = NUMA_NO_NODE;
nbd->tag_set.cmd_size = sizeof(struct nbd_cmd);
@@ -2081,6 +2093,35 @@ static const struct nla_policy nbd_sock_policy[NBD_SOCK_MAX + 1] = {
[NBD_SOCK_FD] = { .type = NLA_U32 },
};
+/*
+ * Count the number of socket FDs in the NBD_ATTR_SOCKETS netlink attribute.
+ * This is used to determine the correct nr_hw_queues before creating the
+ * nbd device, so that blk_mq_update_nr_hw_queues (and its RCU grace period
+ * overhead) can be avoided entirely.
+ */
+static int nbd_genl_count_sockets(struct genl_info *info)
+{
+ struct nlattr *attr;
+ int rem, count = 0;
+
+ if (!info->attrs[NBD_ATTR_SOCKETS])
+ return 0;
+
+ nla_for_each_nested(attr, info->attrs[NBD_ATTR_SOCKETS], rem) {
+ struct nlattr *socks[NBD_SOCK_MAX + 1];
+
+ if (nla_type(attr) != NBD_SOCK_ITEM)
+ continue;
+ if (nla_parse_nested_deprecated(socks, NBD_SOCK_MAX,
+ attr, nbd_sock_policy,
+ info->extack) != 0)
+ continue;
+ if (socks[NBD_SOCK_FD])
+ count++;
+ }
+ return count;
+}
+
/* We don't use this right now since we don't parse the incoming list, but we
* still want it here so userspace knows what to expect.
*/
@@ -2112,6 +2153,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
struct nbd_device *nbd;
struct nbd_config *config;
int index = -1;
+ int num_connections = nbd_genl_count_sockets(info);
int ret;
bool put_dev = false;
@@ -2159,7 +2201,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
mutex_unlock(&nbd_index_mutex);
if (!nbd) {
- nbd = nbd_dev_add(index, 2);
+ nbd = nbd_dev_add(index, 2, num_connections);
if (IS_ERR(nbd)) {
pr_err("failed to add new device\n");
return PTR_ERR(nbd);
@@ -2726,7 +2768,7 @@ static int __init nbd_init(void)
nbd_dbg_init();
for (i = 0; i < nbds_max; i++)
- nbd_dev_add(i, 1);
+ nbd_dev_add(i, 1, 1);
return 0;
}
|
| 3/2 | 2026/06/26 16:57 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 8172 output: 28 thoughts: 237 Thoughts: **NBD Driver Socket and Queue Initialization Changes - Time to Fuzz!** Okay, so I've got a patch in front of me that's making some pretty significant changes to the NBD driver, specifically in `drivers/block/nbd.c`. It looks like they're revamping how `nbd_sock` pointers are managed within the `nbd_config` structure. Before, we had a dynamic array of `struct nbd_sock **socks`, and now it's been switched over to an xarray, `struct xarray socks`. That’s a significant shift in data structure choice; I wonder what performance or memory benefits they're targeting with that. The patch also touches `nbd_dev_add`. It's now taking `nr_hw_queues` as an argument, and cleverly uses the socket count from the `NBD_ATTR_SOCKETS` netlink attribute to initialize `nr_hw_queues`. No more explicit `blk_mq_update_nr_hw_queues` calls, which simplifies things. Smart move. This is a clear functional change to the NBD driver – core logic for socket management and hardware queue initialization is being modified. That means this is *absolutely* worth a fuzzing campaign. Any change to the core of a block driver, especially one involving network communication, needs a very close look. We could see interesting results. First, though, I need to figure out how to enable this beast. Time to fire up `grepper` and search for the relevant Kconfig options. I'll search for `CONFIG_BLK_DEV_NBD` and anything similar in `drivers/block/Kconfig` to get the necessary configuration options so I can build a test image. |
| 4/2 | 2026/06/26 16:57 | tool | grepper |
0mArgs:{
"Expression": "NBD",
"PathPrefix": "drivers/block/Kconfig"
}Results: {
"Output": "drivers/block/Kconfig=194=source \"drivers/block/drbd/Kconfig\"\ndrivers/block/Kconfig-195-\ndrivers/block/Kconfig:196:config BLK_DEV_NBD\ndrivers/block/Kconfig-197-\ttristate \"Network block device support\"\n"
} |
| 5/2 | 2026/06/26 16:57 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 8904 output: 161 thoughts: 732 Thoughts: **Analyzing NBD Driver Socket Management for Fuzzing** Okay, so we're looking at fuzzing the NBD driver, specifically with the `BLK_DEV_NBD` config enabled. My initial thought is to identify the functions affected by this patch, so I'm going through the modifications. The initial list includes: `sock_shutdown`, `nbd_xmit_timeout`, `sock_xmit`, `nbd_send_cmd`, `find_fallback`, `nbd_handle_cmd`, `nbd_add_socket`, `nbd_reconnect_socket`, `send_disconnects`, `nbd_config_put`, `nbd_start_device`, `nbd_alloc_and_init_config`, `nbd_dev_add`, `nbd_genl_count_sockets`, `nbd_genl_connect`, and `nbd_init`. I'll quickly double-check that list against the actual diff, just to be thorough and make sure I haven't missed anything. Looks good, it matches what I expected. Now, considering my experience, I want to prioritize the areas most impacted by the xarray changes, which are mainly around socket management, connection setup, and error handling. Hot-path functions like `nbd_handle_cmd`, `nbd_send_cmd`, and `sock_xmit` are obviously important, but I'll make sure to dig into the configuration and setup functions, as well as the timeout and error handling routines. I'm focusing on `nbd_add_socket`, `nbd_reconnect_socket`, `nbd_genl_connect`, `nbd_genl_count_sockets`, `nbd_config_put`, `nbd_start_device`, `nbd_xmit_timeout`, `find_fallback`, and `sock_shutdown`. A quick check to make sure the functions that deal with socket management are static, so that I understand where these sockets are being managed. I've confirmed that `nbd_genl_count_sockets` and `nbd_add_socket` are static. This makes this the list of symbols I'm providing. Based on the nature of these changes, replacing the dynamically allocated array with an xarray, and changing hardware queue initialization, I've determined that this is worth fuzzing. I'll pass the `BLK_DEV_NBD` config, and provide `nbd_add_socket`, `nbd_reconnect_socket`, `nbd_genl_connect`, `nbd_genl_count_sockets`, `nbd_config_put`, `nbd_start_device`, `nbd_xmit_timeout`, `find_fallback`, and `sock_shutdown` as the focus symbols. The patch affects how sockets are managed, how the connections are set up and torn down, and how the error handling is done, so those are my primary concerns. |
| 6/2 | 2026/06/26 16:58 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"BLK_DEV_NBD"
],
"FocusSymbols": [
"nbd_add_socket",
"nbd_reconnect_socket",
"nbd_genl_connect",
"nbd_genl_count_sockets",
"nbd_config_put",
"nbd_start_device",
"nbd_xmit_timeout",
"find_fallback",
"sock_shutdown"
],
"Reasoning": "The patch replaces a dynamically allocated array of sockets with an xarray in the NBD driver, and changes how the number of hardware queues is initialized. This affects socket management, connection setup, and error handling.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"BLK_DEV_NBD"
],
"FocusSymbols": [
"nbd_add_socket",
"nbd_reconnect_socket",
"nbd_genl_connect",
"nbd_genl_count_sockets",
"nbd_config_put",
"nbd_start_device",
"nbd_xmit_timeout",
"find_fallback",
"sock_shutdown"
],
"Reasoning": "The patch replaces a dynamically allocated array of sockets with an xarray in the NBD driver, and changes how the number of hardware queues is initialized. This affects socket management, connection setup, and error handling.",
"WorthFuzzing": true
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|