| 0/0 |
2026/09/23 00:01 |
flow |
assessment-security |
1h14m
Results: map[DenialOfService:true Explanation:The bug is a deadlock/hung task involving the NBD (Network Block Device) driver.
Here is the sequence of events that leads to the hung tasks:
1. The syzkaller reproducer (running with root privileges) sends an
`NBD_CMD_CONNECT` netlink message to configure an NBD device. It provides a
socket but does not specify a timeout (`NBD_ATTR_TIMEOUT`). As a result, the
device's timeout is left at its default value of 0 (no timeout).
2. The configuration sets the device size, which triggers a kernel uevent.
3. `udevd` receives the uevent, opens the block device, and attempts to read the
partition table. It submits a read bio to the NBD device.
4. The NBD driver queues the request to the provided socket. However, since
there is no actual NBD server listening on the other end of the socket pair, the
request receives no reply.
5. Because the device timeout is 0, the block layer's timeout handler
(`nbd_xmit_timeout`) continuously returns `BLK_EH_RESET_TIMER`, causing the
request to remain in-flight indefinitely.
6. The syzkaller reproducer then sends an `NBD_CMD_RECONFIGURE` netlink message
to change the device size.
7. This calls `queue_limits_commit_update_frozen()`, which attempts to freeze
the block queue and waits for all in-flight requests to complete (i.e., waits
for `q_usage_counter` to drop to 0).
8. Since the read request from `udevd` is stuck forever, the queue freeze
operation blocks indefinitely, causing the syzkaller task to hang in
`blk_mq_freeze_queue_wait`.
9. Meanwhile, `udevd` attempts to submit the next bio for the partition table
read, but blocks in `bio_queue_enter()` because the queue is now in a freezing
state.
10. Both tasks hang for more than 143 seconds, triggering the kernel's hung task
watchdog.
**Security Impact:**
- The netlink commands `NBD_CMD_CONNECT` and `NBD_CMD_RECONFIGURE` both strictly
require `CAP_SYS_ADMIN` in the initial user namespace (enforced by
`netlink_capable(skb, CAP_SYS_ADMIN)`).
- Therefore, this bug cannot be triggered by unprivileged users or from within
unprivileged user namespaces.
- It is not exploitable for privilege escalation, memory corruption, or
information leaks.
- While it represents a Denial of Service (hung task), it requires root
privileges to trigger. Thus, it is not considered a security vulnerability, but
rather a bug that root can trigger by misconfiguring an NBD device (providing a
socket with no server and no timeout). Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/09/23 00:01 |
action |
syz-repro-to-c-repro |
0m
Results: map[SimplifiedCRepro:// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <arpa/inet.h>
#include <endian.h>
#include <errno.h>
#include <net/if.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/genetlink.h>
#include <linux/if_addr.h>
#include <linux/if_link.h>
#include <linux/in6.h>
#include <linux/neighbour.h>
#include <linux/net.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/veth.h>
#define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off))
#define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len))))
struct nlmsg {
char* pos;
int nesting;
struct nlattr* nested[8];
char buf[4096];
};
static void netlink_init(struct nlmsg* nlmsg, int typ, int flags,
const void* data, int size)
{
memset(nlmsg, 0, sizeof(*nlmsg));
struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf;
hdr->nlmsg_type = typ;
hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags;
memcpy(hdr + 1, data, size);
nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size);
}
static void netlink_attr(struct nlmsg* nlmsg, int typ,
const void* data, int size)
{
struct nlattr* attr = (struct nlattr*)nlmsg->pos;
attr->nla_len = sizeof(*attr) + size;
attr->nla_type = typ;
if (size > 0)
memcpy(attr + 1, data, size);
nlmsg->pos += NLMSG_ALIGN(attr->nla_len);
}
static int netlink_send_ext(struct nlmsg* nlmsg, int sock,
uint16_t reply_type, int* reply_len, bool dofail)
{
if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting)
exit(1);
struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf;
hdr->nlmsg_len = nlmsg->pos - nlmsg->buf;
struct sockaddr_nl addr;
memset(&addr, 0, sizeof(addr));
addr.nl_family = AF_NETLINK;
ssize_t n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr));
if (n != (ssize_t)hdr->nlmsg_len) {
if (dofail)
exit(1);
return -1;
}
n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0);
if (reply_len)
*reply_len = 0;
if (n < 0) {
if (dofail)
exit(1);
return -1;
}
if (n < (ssize_t)sizeof(struct nlmsghdr)) {
errno = EINVAL;
if (dofail)
exit(1);
return -1;
}
if (hdr->nlmsg_type == NLMSG_DONE)
return 0;
if (reply_len && hdr->nlmsg_type == reply_type) {
*reply_len = n;
return 0;
}
if (n < (ssize_t)(sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr))) {
errno = EINVAL;
if (dofail)
exit(1);
return -1;
}
if (hdr->nlmsg_type != NLMSG_ERROR) {
errno = EINVAL;
if (dofail)
exit(1);
return -1;
}
errno = -((struct nlmsgerr*)(hdr + 1))->error;
return -errno;
}
static int netlink_query_family_id(struct nlmsg* nlmsg, int sock, const char* family_name, bool dofail)
{
struct genlmsghdr genlhdr;
memset(&genlhdr, 0, sizeof(genlhdr));
genlhdr.cmd = CTRL_CMD_GETFAMILY;
netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr));
netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, family_name, strnlen(family_name, GENL_NAMSIZ - 1) + 1);
int n = 0;
int err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n, dofail);
if (err < 0) {
return -1;
}
uint16_t id = 0;
struct nlattr* attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr)));
for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) {
if (attr->nla_type == CTRL_ATTR_FAMILY_ID) {
id = *(uint16_t*)(attr + 1);
break;
}
}
if (!id) {
errno = EINVAL;
return -1;
}
recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0);
return id;
}
const int kInitNetNsFd = 201;
static long syz_init_net_socket(volatile long domain, volatile long type, volatile long proto)
{
return syscall(__NR_socket, domain, type, proto);
}
static long syz_genetlink_get_family_id(volatile long name, volatile long sock_arg)
{
int fd = sock_arg;
if (fd < 0) {
fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC);
if (fd == -1) {
return -1;
}
}
struct nlmsg nlmsg_tmp;
int ret = netlink_query_family_id(&nlmsg_tmp, fd, (char*)name, false);
if ((int)sock_arg < 0)
close(fd);
if (ret < 0) {
return -1;
}
return ret;
}
uint64_t r[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_init_net_socket$nl_generic arguments: [
// domain: const = 0x10 (8 bytes)
// type: const = 0x3 (8 bytes)
// proto: const = 0x10 (8 bytes)
// ]
// returns sock_nl_generic_init
res = -1;
res = syz_init_net_socket(/*domain=*/0x10, /*type=*/3, /*proto=*/0x10);
if (res != -1)
r[0] = res;
// syz_init_net_socket$nl_generic arguments: [
// domain: const = 0x10 (8 bytes)
// type: const = 0x3 (8 bytes)
// proto: const = 0x10 (8 bytes)
// ]
// returns sock_nl_generic_init
res = -1;
res = syz_init_net_socket(/*domain=*/0x10, /*type=*/3, /*proto=*/0x10);
if (res != -1)
r[1] = res;
// syz_genetlink_get_family_id$nbd arguments: [
// name: ptr[in, buffer] {
// buffer: {6e 62 64 00} (length 0x4)
// }
// fd: sock_nl_generic_init (resource)
// ]
// returns genl_nbd_family_id
memcpy((void*)0x200000000000, "nbd\000", 4);
res = -1;
res = syz_genetlink_get_family_id(/*name=*/0x200000000000, /*fd=*/-1);
if (res != -1)
r[2] = res;
// socketpair$nbd arguments: [
// domain: const = 0x1 (8 bytes)
// type: const = 0x1 (8 bytes)
// proto: const = 0x0 (4 bytes)
// fds: ptr[out, nbd_sock_pair] {
// nbd_sock_pair {
// client: sock_nbd_client (resource)
// server: sock_nbd_server (resource)
// }
// }
// ]
res = syscall(__NR_socketpair, /*domain=*/1ul, /*type=*/1ul, /*proto=*/0, /*fds=*/0x200000000100ul);
if (res != -1)
r[3] = *(uint32_t*)0x200000000100;
// sendmsg$NBD_CMD_CONNECT arguments: [
// fd: sock_nl_generic_init (resource)
// msg: ptr[in, msghdr_netlink[netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]]] {
// msghdr_netlink[netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]] {
// addr: nil
// addrlen: len = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// vec: ptr[in, iovec[in, netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]]] {
// iovec[in, netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]] {
// addr: ptr[in, netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]] {
// netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy] {
// len: len = 0x38 (4 bytes)
// type: genl_nbd_family_id (resource)
// flags: netlink_msg_flags = 0x1 (2 bytes)
// seq: int32 = 0xfffffffd (4 bytes)
// pid: int32 = 0x0 (4 bytes)
// payload: genlmsghdr_t[NBD_CMD_CONNECT] {
// cmd: const = 0x1 (1 bytes)
// version: const = 0x0 (1 bytes)
// reserved: const = 0x0 (2 bytes)
// }
// attrs: array[nbd_attr_policy] {
// union nbd_attr_policy {
// NBD_ATTR_SOCKETS: nlattr_tt[const[NBD_ATTR_SOCKETS, int16:14], 0, 1, array[nlnest[NBD_SOCK_ITEM, nlattr[NBD_SOCK_FD, sock_nbd_client]]]] {
// nla_len: offsetof = 0x10 (2 bytes)
// nla_type: const = 0x7 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: array[nlattr_tt[const[NBD_SOCK_ITEM, int16:14], 0, 1, nlattr[NBD_SOCK_FD, sock_nbd_client]]] {
// nlattr_tt[const[NBD_SOCK_ITEM, int16:14], 0, 1, nlattr[NBD_SOCK_FD, sock_nbd_client]] {
// nla_len: offsetof = 0xc (2 bytes)
// nla_type: const = 0x1 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: nlattr_t[const[NBD_SOCK_FD, int16], sock_nbd_client] {
// nla_len: offsetof = 0x8 (2 bytes)
// nla_type: const = 0x1 (2 bytes)
// payload: sock_nbd_client (resource)
// size: buffer: {} (length 0x0)
// }
// size: buffer: {} (length 0x0)
// }
// }
// size: buffer: {} (length 0x0)
// }
// }
// union nbd_attr_policy {
// NBD_ATTR_INDEX: nlattr_t[const[NBD_ATTR_INDEX, int16], proc[0, 1, int32]] {
// nla_len: offsetof = 0x8 (2 bytes)
// nla_type: const = 0x1 (2 bytes)
// payload: proc = 0x0 (4 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// union nbd_attr_policy {
// NBD_ATTR_SIZE_BYTES: nlattr_t[const[NBD_ATTR_SIZE_BYTES, int16], int64] {
// nla_len: offsetof = 0xc (2 bytes)
// nla_type: const = 0x2 (2 bytes)
// payload: int64 = 0x7fff (8 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// }
// }
// }
// len: len = 0x38 (8 bytes)
// }
// }
// vlen: const = 0x1 (8 bytes)
// ctrl: const = 0x0 (8 bytes)
// ctrllen: const = 0x0 (8 bytes)
// f: send_flags = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// f: send_flags = 0x20000000 (8 bytes)
// ]
*(uint64_t*)0x200000001ac0 = 0;
*(uint32_t*)0x200000001ac8 = 0;
*(uint64_t*)0x200000001ad0 = 0x200000001a80;
*(uint64_t*)0x200000001a80 = 0x200000000140;
*(uint32_t*)0x200000000140 = 0x38;
*(uint16_t*)0x200000000144 = r[2];
*(uint16_t*)0x200000000146 = 1;
*(uint32_t*)0x200000000148 = 0xfffffffd;
*(uint32_t*)0x20000000014c = 0;
*(uint8_t*)0x200000000150 = 1;
*(uint8_t*)0x200000000151 = 0;
*(uint16_t*)0x200000000152 = 0;
*(uint16_t*)0x200000000154 = 0x10;
STORE_BY_BITMASK(uint16_t, , 0x200000000156, 7, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x200000000157, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x200000000157, 1, 7, 1);
*(uint16_t*)0x200000000158 = 0xc;
STORE_BY_BITMASK(uint16_t, , 0x20000000015a, 1, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x20000000015b, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x20000000015b, 1, 7, 1);
*(uint16_t*)0x20000000015c = 8;
*(uint16_t*)0x20000000015e = 1;
*(uint32_t*)0x200000000160 = r[3];
*(uint16_t*)0x200000000164 = 8;
*(uint16_t*)0x200000000166 = 1;
*(uint32_t*)0x200000000168 = 0;
*(uint16_t*)0x20000000016c = 0xc;
*(uint16_t*)0x20000000016e = 2;
*(uint64_t*)0x200000000170 = 0x7fff;
*(uint64_t*)0x200000001a88 = 0x38;
*(uint64_t*)0x200000001ad8 = 1;
*(uint64_t*)0x200000001ae0 = 0;
*(uint64_t*)0x200000001ae8 = 0;
*(uint32_t*)0x200000001af0 = 0;
syscall(__NR_sendmsg, /*fd=*/r[1], /*msg=*/0x200000001ac0ul, /*f=MSG_FASTOPEN*/0x20000000ul);
// sendmsg$NBD_CMD_RECONFIGURE arguments: [
// fd: sock_nl_generic_init (resource)
// msg: ptr[in, msghdr_netlink[netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_RECONFIGURE], nbd_attr_policy]]] {
// msghdr_netlink[netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_RECONFIGURE], nbd_attr_policy]] {
// addr: nil
// addrlen: len = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// vec: ptr[in, iovec[in, netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_RECONFIGURE], nbd_attr_policy]]] {
// iovec[in, netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_RECONFIGURE], nbd_attr_policy]] {
// addr: ptr[in, netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_RECONFIGURE], nbd_attr_policy]] {
// netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_RECONFIGURE], nbd_attr_policy] {
// len: len = 0x48 (4 bytes)
// type: genl_nbd_family_id (resource)
// flags: netlink_msg_flags = 0x503 (2 bytes)
// seq: int32 = 0x70bd28 (4 bytes)
// pid: int32 = 0x25dfdbff (4 bytes)
// payload: genlmsghdr_t[NBD_CMD_RECONFIGURE] {
// cmd: const = 0x3 (1 bytes)
// version: const = 0x0 (1 bytes)
// reserved: const = 0x0 (2 bytes)
// }
// attrs: array[nbd_attr_policy] {
// union nbd_attr_policy {
// NBD_ATTR_INDEX: nlattr_t[const[NBD_ATTR_INDEX, int16], proc[0, 1, int32]] {
// nla_len: offsetof = 0x8 (2 bytes)
// nla_type: const = 0x1 (2 bytes)
// payload: proc = 0x0 (4 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// union nbd_attr_policy {
// NBD_ATTR_DEAD_CONN_TIMEOUT: nlattr_t[const[NBD_ATTR_DEAD_CONN_TIMEOUT, int16], int64] {
// nla_len: offsetof = 0xc (2 bytes)
// nla_type: const = 0x8 (2 bytes)
// payload: int64 = 0x3 (8 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// union nbd_attr_policy {
// NBD_ATTR_SIZE_BYTES: nlattr_t[const[NBD_ATTR_SIZE_BYTES, int16], int64] {
// nla_len: offsetof = 0xc (2 bytes)
// nla_type: const = 0x2 (2 bytes)
// payload: int64 = 0x7 (8 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// union nbd_attr_policy {
// NBD_ATTR_SOCKETS: nlattr_tt[const[NBD_ATTR_SOCKETS, int16:14], 0, 1, array[nlnest[NBD_SOCK_ITEM, nlattr[NBD_SOCK_FD, sock_nbd_client]]]] {
// nla_len: offsetof = 0x10 (2 bytes)
// nla_type: const = 0x7 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: array[nlattr_tt[const[NBD_SOCK_ITEM, int16:14], 0, 1, nlattr[NBD_SOCK_FD, sock_nbd_client]]] {
// nlattr_tt[const[NBD_SOCK_ITEM, int16:14], 0, 1, nlattr[NBD_SOCK_FD, sock_nbd_client]] {
// nla_len: offsetof = 0xc (2 bytes)
// nla_type: const = 0x1 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: nlattr_t[const[NBD_SOCK_FD, int16], sock_nbd_client] {
// nla_len: offsetof = 0x8 (2 bytes)
// nla_type: const = 0x1 (2 bytes)
// payload: sock_nbd_client (resource)
// size: buffer: {} (length 0x0)
// }
// size: buffer: {} (length 0x0)
// }
// }
// size: buffer: {} (length 0x0)
// }
// }
// union nbd_attr_policy {
// NBD_ATTR_SOCKETS: nlattr_tt[const[NBD_ATTR_SOCKETS, int16:14], 0, 1, array[nlnest[NBD_SOCK_ITEM, nlattr[NBD_SOCK_FD, sock_nbd_client]]]] {
// nla_len: offsetof = 0x4 (2 bytes)
// nla_type: const = 0x7 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: array[nlattr_tt[const[NBD_SOCK_ITEM, int16:14], 0, 1, nlattr[NBD_SOCK_FD, sock_nbd_client]]] {
// }
// size: buffer: {} (length 0x0)
// }
// }
// }
// }
// }
// len: len = 0x48 (8 bytes)
// }
// }
// vlen: const = 0x1 (8 bytes)
// ctrl: const = 0x0 (8 bytes)
// ctrllen: const = 0x0 (8 bytes)
// f: send_flags = 0x40 (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// f: send_flags = 0x40080 (8 bytes)
// ]
*(uint64_t*)0x200000000280 = 0;
*(uint32_t*)0x200000000288 = 0;
*(uint64_t*)0x200000000290 = 0x200000000240;
*(uint64_t*)0x200000000240 = 0x200000000140;
*(uint32_t*)0x200000000140 = 0x48;
*(uint16_t*)0x200000000144 = r[2];
*(uint16_t*)0x200000000146 = 0x503;
*(uint32_t*)0x200000000148 = 0x70bd28;
*(uint32_t*)0x20000000014c = 0x25dfdbff;
*(uint8_t*)0x200000000150 = 3;
*(uint8_t*)0x200000000151 = 0;
*(uint16_t*)0x200000000152 = 0;
*(uint16_t*)0x200000000154 = 8;
*(uint16_t*)0x200000000156 = 1;
*(uint32_t*)0x200000000158 = 0;
*(uint16_t*)0x20000000015c = 0xc;
*(uint16_t*)0x20000000015e = 8;
*(uint64_t*)0x200000000160 = 3;
*(uint16_t*)0x200000000168 = 0xc;
*(uint16_t*)0x20000000016a = 2;
*(uint64_t*)0x20000000016c = 7;
*(uint16_t*)0x200000000174 = 0x10;
STORE_BY_BITMASK(uint16_t, , 0x200000000176, 7, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x200000000177, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x200000000177, 1, 7, 1);
*(uint16_t*)0x200000000178 = 0xc;
STORE_BY_BITMASK(uint16_t, , 0x20000000017a, 1, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x20000000017b, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x20000000017b, 1, 7, 1);
*(uint16_t*)0x20000000017c = 8;
*(uint16_t*)0x20000000017e = 1;
*(uint32_t*)0x200000000180 = -1;
*(uint16_t*)0x200000000184 = 4;
STORE_BY_BITMASK(uint16_t, , 0x200000000186, 7, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x200000000187, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x200000000187, 1, 7, 1);
*(uint64_t*)0x200000000248 = 0x48;
*(uint64_t*)0x200000000298 = 1;
*(uint64_t*)0x2000000002a0 = 0;
*(uint64_t*)0x2000000002a8 = 0;
*(uint32_t*)0x2000000002b0 = 0x40;
syscall(__NR_sendmsg, /*fd=*/r[0], /*msg=*/0x200000000280ul, /*f=MSG_BATCH|MSG_EOR*/0x40080ul);
return 0;
}
]
|
| 2/1 |
2026/09/23 00:01 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/4fac6065e2a1a24062faf12f51093d17091eb97b]
|
| 3/1 |
2026/09/23 00:01 |
action |
kernel-builder |
30m
Results: map[KernelObj:/app/workdir/cache/build/8bd2410b84b0368ffb5a84ac79502c3bed07baf5]
|
| 4/1 |
2026/09/23 00:32 |
action |
codesearch-prepare |
22m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/09/23 00:55 |
agent |
expert |
20m
Model:
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Instruction: You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by grepping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption, elevated privileges, or an information leak.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completely wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control transfers, that also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitability depends on how exactly the uninit value
is used in the code, and what it affects.
Information leaks are exploitable on their own and should be classified as such. A bug that copies kernel
memory contents to userspace (e.g. an out-of-bounds read whose result is returned to the caller, or
uninitialized stack/heap bytes written to a user buffer) is exploitable: it can reveal kernel pointer
values and defeat KASLR, expose sensitive data such as cryptographic keys or other processes' memory, and
serves as a necessary building block in most modern kernel privilege-escalation exploit chains. Do not classify
an information leak as non-exploitable solely because it does not directly cause a memory write or control-flow
hijack; the leak itself is the exploit primitive.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidential Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
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:
The kernel bug report is:
INFO: task udevd:5676 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:udevd state:D stack:25736 pid:5676 tgid:5676 ppid:4984 task_flags:0x400140 flags:0x00080000
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5526 [inline]
__schedule+0x17db/0x58f0 kernel/sched/core.c:7277
__schedule_loop kernel/sched/core.c:7354 [inline]
schedule+0x164/0x2b0 kernel/sched/core.c:7369
__bio_queue_enter+0x369/0x7f0 block/blk-core.c:396
bio_queue_enter block/blk.h:99 [inline]
blk_mq_submit_bio+0x776/0x2a70 block/blk-mq.c:3127
__submit_bio_noacct_mq block/blk-core.c:756 [inline]
submit_bio_noacct_nocheck+0x2f4/0xa40 block/blk-core.c:790
bh_submit fs/buffer.c:1146 [inline]
block_read_full_folio+0x581/0x810 fs/buffer.c:2359
filemap_read_folio+0x12c/0x3a0 mm/filemap.c:2520
do_read_cache_folio+0x354/0x590 mm/filemap.c:4156
read_mapping_folio include/linux/pagemap.h:1015 [inline]
read_part_sector+0xb6/0x2b0 block/partitions/core.c:724
adfspart_check_ICS+0xb1/0x960 block/partitions/acorn.c:357
check_partition block/partitions/core.c:143 [inline]
blk_add_partitions block/partitions/core.c:591 [inline]
bdev_disk_changed+0x851/0x17a0 block/partitions/core.c:695
blkdev_get_whole+0x372/0x510 block/bdev.c:793
bdev_open+0x324/0xd70 block/bdev.c:1002
blkdev_open+0x461/0x600 block/fops.c:674
do_dentry_open+0x816/0x1380 fs/open.c:996
vfs_open+0x3b/0x340 fs/open.c:1101
do_open fs/namei.c:4837 [inline]
path_openat+0x1443/0x1d60 fs/namei.c:5000
do_file_open+0x23e/0x4a0 fs/namei.c:5029
do_sys_openat2+0x115/0x200 fs/open.c:1417
do_sys_open fs/open.c:1423 [inline]
__do_sys_openat fs/open.c:1439 [inline]
__se_sys_openat fs/open.c:1434 [inline]
__x64_sys_openat+0x138/0x170 fs/open.c:1434
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f77b02a7407
RSP: 002b:00007ffe9ad1c750 EFLAGS: 00000202 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f77b0965880 RCX: 00007f77b02a7407
RDX: 00000000000a0800 RSI: 000055a197e52f80 RDI: ffffffffffffff9c
RBP: 000055a197e39910 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 000055a197e4dba0
R13: 000055a197e47190 R14: 0000000000000000 R15: 000055a197e4dba0
</TASK>
INFO: task syz.0.17:5845 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.0.17 state:D stack:24640 pid:5845 tgid:5844 ppid:5783 task_flags:0x480140 flags:0x00080002
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5526 [inline]
__schedule+0x17db/0x58f0 kernel/sched/core.c:7277
__schedule_loop kernel/sched/core.c:7354 [inline]
schedule+0x164/0x2b0 kernel/sched/core.c:7369
blk_mq_freeze_queue_wait+0x101/0x180 block/blk-mq.c:191
blk_mq_freeze_queue include/linux/blk-mq.h:956 [inline]
queue_limits_commit_update_frozen+0x55/0xd0 block/blk-settings.c:590
nbd_set_size+0x4c5/0x7d0 drivers/block/nbd.c:383
nbd_genl_size_set drivers/block/nbd.c:2111 [inline]
nbd_genl_reconfigure+0x7e1/0x1040 drivers/block/nbd.c:2444
genl_family_rcv_msg_doit+0x233/0x340 net/netlink/genetlink.c:1114
genl_family_rcv_msg net/netlink/genetlink.c:1194 [inline]
genl_rcv_msg+0x614/0x7a0 net/netlink/genetlink.c:1209
netlink_rcv_skb+0x226/0x4a0 net/netlink/af_netlink.c:2575
genl_rcv+0x28/0x40 net/netlink/genetlink.c:1218
netlink_unicast_kernel net/netlink/af_netlink.c:1338 [inline]
netlink_unicast+0x7bd/0x940 net/netlink/af_netlink.c:1364
netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1919
sock_sendmsg_nosec+0x13a/0x180 net/socket.c:800
__sock_sendmsg net/socket.c:815 [inline]
____sys_sendmsg+0x54e/0x850 net/socket.c:2713
___sys_sendmsg+0x2a5/0x360 net/socket.c:2767
__sys_sendmsg net/socket.c:2799 [inline]
__do_sys_sendmsg net/socket.c:2804 [inline]
__se_sys_sendmsg net/socket.c:2802 [inline]
__x64_sys_sendmsg+0x1b1/0x290 net/socket.c:2802
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5d2239e159
RSP: 002b:00007f5d232a7028 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f5d22625fa0 RCX: 00007f5d2239e159
RDX: 0000000000040080 RSI: 0000200000000280 RDI: 0000000000000004
RBP: 00007f5d2243506b R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f5d22626038 R14: 00007f5d22625fa0 R15: 00007fff9d2e9788
</TASK>
Showing all locks held in the system:
locks held by khungtaskd/31: 1, last CPU#0:
#0: ffffffff8ed5c8e0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:309 [inline]
#0: ffffffff8ed5c8e0 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
#0: ffffffff8ed5c8e0 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x2e/0x180 kernel/locking/lockdep.c:6871
locks held by getty/5374: 2, on CPU#1:
#0: ffff88803565e0a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x25/0x70 drivers/tty/tty_ldisc.c:243
#1: ffffc9000322b2e8 (&ldata->atomic_read_lock){+.+.}-{4:4}, at: n_tty_read+0x45a/0x1360 drivers/tty/n_tty.c:2211
locks held by udevd/5676: 1, on CPU#0:
#0: ffff888025b18350 (&disk->open_mutex){+.+.}-{4:4}, at: bdev_open+0xde/0xd70 block/bdev.c:990
locks held by syz.0.17/5845: 6, on CPU#0:
#0: ffffffff902c4448 (cb_lock){++++}-{4:4}, at: genl_rcv+0x19/0x40 net/netlink/genetlink.c:1217
#1: ffffffff902c4280 (genl_mutex){+.+.}-{4:4}, at: genl_lock net/netlink/genetlink.c:35 [inline]
#1: ffffffff902c4280 (genl_mutex){+.+.}-{4:4}, at: genl_op_lock net/netlink/genetlink.c:60 [inline]
#1: ffffffff902c4280 (genl_mutex){+.+.}-{4:4}, at: genl_rcv_msg+0x10b/0x7a0 net/netlink/genetlink.c:1208
#2: ffff888025a59260 (&nbd->config_lock){+.+.}-{4:4}, at: nbd_genl_reconfigure+0x4a6/0x1040 drivers/block/nbd.c:2435
#3: ffff888025c90fe8 (&q->limits_lock){+.+.}-{4:4}, at: queue_limits_start_update include/linux/blkdev.h:1101 [inline]
#3: ffff888025c90fe8 (&q->limits_lock){+.+.}-{4:4}, at: nbd_set_size+0x284/0x7d0 drivers/block/nbd.c:375
#4: ffff888025c909b0 (&q->q_usage_counter(io)#49){++++}-{0:0}, at: blk_mq_freeze_queue include/linux/blk-mq.h:956 [inline]
#4: ffff888025c909b0 (&q->q_usage_counter(io)#49){++++}-{0:0}, at: queue_limits_commit_update_frozen+0x55/0xd0 block/blk-settings.c:590
#5: ffff888025c909e8 (&q->q_usage_counter(queue)#33){+.+.}-{0:0}, at: blk_mq_freeze_queue include/linux/blk-mq.h:956 [inline]
#5: ffff888025c909e8 (&q->q_usage_counter(queue)#33){+.+.}-{0:0}, at: queue_limits_commit_update_frozen+0x55/0xd0 block/blk-settings.c:590
locks held by syz-executor/5847: 2, on CPU#1:
#0: ffffffff902c4448 (cb_lock){++++}-{4:4}, at: genl_rcv+0x19/0x40 net/netlink/genetlink.c:1217
#1: ffffffff902c4280 (genl_mutex){+.+.}-{4:4}, at: genl_lock net/netlink/genetlink.c:35 [inline]
#1: ffffffff902c4280 (genl_mutex){+.+.}-{4:4}, at: genl_op_lock net/netlink/genetlink.c:60 [inline]
#1: ffffffff902c4280 (genl_mutex){+.+.}-{4:4}, at: genl_rcv_msg+0x10b/0x7a0 net/netlink/genetlink.c:1208
locks held by syz-executor/5871: 2, on CPU#1:
#0: ffffffff902c4448 (cb_lock){++++}-{4:4}, at: genl_rcv+0x19/0x40 net/netlink/genetlink.c:1217
#1: ffffffff902c4280 (genl_mutex){+.+.}-{4:4}, at: genl_lock net/netlink/genetlink.c:35 [inline]
#1: ffffffff902c4280 (genl_mutex){+.+.}-{4:4}, at: genl_op_lock net/netlink/genetlink.c:60 [inline]
#1: ffffffff902c4280 (genl_mutex){+.+.}-{4:4}, at: genl_rcv_msg+0x10b/0x7a0 net/netlink/genetlink.c:1208
locks held by syz-executor/5897: 2, on CPU#1:
#0: ffffffff902c4448 (cb_lock){++++}-{4:4}, at: genl_rcv+0x19/0x40 net/netlink/genetlink.c:1217
#1: ffffffff902c4280 (genl_mutex){+.+.}-{4:4}, at: genl_lock net/netlink/genetlink.c:35 [inline]
#1: ffffffff902c4280 (genl_mutex){+.+.}-{4:4}, at: genl_op_lock net/netlink/genetlink.c:60 [inline]
#1: ffffffff902c4280 (genl_mutex){+.+.}-{4:4}, at: genl_rcv_msg+0x10b/0x7a0 net/netlink/genetlink.c:1208
=============================================
NMI backtrace for cpu 0
CPU: 0 UID: 0 PID: 31 Comm: khungtaskd Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
nmi_cpu_backtrace+0x274/0x2d0 lib/nmi_backtrace.c:123
nmi_trigger_cpumask_backtrace+0x17d/0x390 lib/nmi_backtrace.c:66
trigger_all_cpu_backtrace include/linux/nmi.h:164 [inline]
__sys_info lib/sys_info.c:157 [inline]
sys_info+0x135/0x170 lib/sys_info.c:165
check_hung_uninterruptible_tasks kernel/hung_task.c:353 [inline]
watchdog+0xfd7/0x1030 kernel/hung_task.c:561
kthread+0x38b/0x480 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Sending NMI from CPU 0 to CPUs 1:
NMI backtrace for cpu 1
CPU: 1 UID: 0 PID: 0 Comm: swapper/1 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
RIP: 0010:pv_native_safe_halt+0xf/0x20 arch/x86/kernel/paravirt.c:64
Code: ac 88 02 c3 cc cc cc cc cc cc cc 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 66 90 0f 00 2d b3 c1 23 00 fb f4 <e9> 8c 08 03 00 cc cc cc cc cc cc cc cc cc cc cc cc 90 90 90 90 90
RSP: 0018:ffffc900001a7e40 EFLAGS: 00000246
RAX: 00000000000caff3 RBX: ffffffff819bb370 RCX: 8000000000000001
RDX: 0000000000000001 RSI: ffffffff8e4140f9 RDI: ffffffff8c6da080
RBP: ffffc900001a7f10 R08: ffff8880b8733a1b R09: 1ffff110170e6743
R10: dffffc0000000000 R11: ffffed10170e6744 R12: 0000000000000000
R13: 1ffff11003cd1bb8 R14: 1ffff92000034fd0 R15: dffffc0000000000
FS: 0000000000000000(0000) GS:ffff888124dce000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fb7e3889e9c CR3: 000000000eb48000 CR4: 00000000003526f0
Call Trace:
<TASK>
arch_safe_halt arch/x86/kernel/process.c:767 [inline]
default_idle+0x9/0x20 arch/x86/kernel/process.c:768
default_idle_call+0x72/0xb0 kernel/sched/idle.c:122
cpuidle_idle_call kernel/sched/idle.c:199 [inline]
do_idle+0x2e0/0x540 kernel/sched/idle.c:355
cpu_startup_entry+0x43/0x60 kernel/sched/idle.c:454
start_secondary+0x101/0x110 arch/x86/kernel/smpboot.c:312
common_startup_64+0x13e/0x157
</TASK>
It is reproducible with the followint program.
Keep in mind that it may lack the precise threading, sandboxing, and some arguments of a working reproducer.
But it should give an idea of the involved syscalls.
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <arpa/inet.h>
#include <endian.h>
#include <errno.h>
#include <net/if.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/genetlink.h>
#include <linux/if_addr.h>
#include <linux/if_link.h>
#include <linux/in6.h>
#include <linux/neighbour.h>
#include <linux/net.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/veth.h>
#define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off))
#define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len))))
struct nlmsg {
char* pos;
int nesting;
struct nlattr* nested[8];
char buf[4096];
};
static void netlink_init(struct nlmsg* nlmsg, int typ, int flags,
const void* data, int size)
{
memset(nlmsg, 0, sizeof(*nlmsg));
struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf;
hdr->nlmsg_type = typ;
hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags;
memcpy(hdr + 1, data, size);
nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size);
}
static void netlink_attr(struct nlmsg* nlmsg, int typ,
const void* data, int size)
{
struct nlattr* attr = (struct nlattr*)nlmsg->pos;
attr->nla_len = sizeof(*attr) + size;
attr->nla_type = typ;
if (size > 0)
memcpy(attr + 1, data, size);
nlmsg->pos += NLMSG_ALIGN(attr->nla_len);
}
static int netlink_send_ext(struct nlmsg* nlmsg, int sock,
uint16_t reply_type, int* reply_len, bool dofail)
{
if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting)
exit(1);
struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf;
hdr->nlmsg_len = nlmsg->pos - nlmsg->buf;
struct sockaddr_nl addr;
memset(&addr, 0, sizeof(addr));
addr.nl_family = AF_NETLINK;
ssize_t n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr));
if (n != (ssize_t)hdr->nlmsg_len) {
if (dofail)
exit(1);
return -1;
}
n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0);
if (reply_len)
*reply_len = 0;
if (n < 0) {
if (dofail)
exit(1);
return -1;
}
if (n < (ssize_t)sizeof(struct nlmsghdr)) {
errno = EINVAL;
if (dofail)
exit(1);
return -1;
}
if (hdr->nlmsg_type == NLMSG_DONE)
return 0;
if (reply_len && hdr->nlmsg_type == reply_type) {
*reply_len = n;
return 0;
}
if (n < (ssize_t)(sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr))) {
errno = EINVAL;
if (dofail)
exit(1);
return -1;
}
if (hdr->nlmsg_type != NLMSG_ERROR) {
errno = EINVAL;
if (dofail)
exit(1);
return -1;
}
errno = -((struct nlmsgerr*)(hdr + 1))->error;
return -errno;
}
static int netlink_query_family_id(struct nlmsg* nlmsg, int sock, const char* family_name, bool dofail)
{
struct genlmsghdr genlhdr;
memset(&genlhdr, 0, sizeof(genlhdr));
genlhdr.cmd = CTRL_CMD_GETFAMILY;
netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr));
netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, family_name, strnlen(family_name, GENL_NAMSIZ - 1) + 1);
int n = 0;
int err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n, dofail);
if (err < 0) {
return -1;
}
uint16_t id = 0;
struct nlattr* attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr)));
for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) {
if (attr->nla_type == CTRL_ATTR_FAMILY_ID) {
id = *(uint16_t*)(attr + 1);
break;
}
}
if (!id) {
errno = EINVAL;
return -1;
}
recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0);
return id;
}
const int kInitNetNsFd = 201;
static long syz_init_net_socket(volatile long domain, volatile long type, volatile long proto)
{
return syscall(__NR_socket, domain, type, proto);
}
static long syz_genetlink_get_family_id(volatile long name, volatile long sock_arg)
{
int fd = sock_arg;
if (fd < 0) {
fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC);
if (fd == -1) {
return -1;
}
}
struct nlmsg nlmsg_tmp;
int ret = netlink_query_family_id(&nlmsg_tmp, fd, (char*)name, false);
if ((int)sock_arg < 0)
close(fd);
if (ret < 0) {
return -1;
}
return ret;
}
uint64_t r[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_init_net_socket$nl_generic arguments: [
// domain: const = 0x10 (8 bytes)
// type: const = 0x3 (8 bytes)
// proto: const = 0x10 (8 bytes)
// ]
// returns sock_nl_generic_init
res = -1;
res = syz_init_net_socket(/*domain=*/0x10, /*type=*/3, /*proto=*/0x10);
if (res != -1)
r[0] = res;
// syz_init_net_socket$nl_generic arguments: [
// domain: const = 0x10 (8 bytes)
// type: const = 0x3 (8 bytes)
// proto: const = 0x10 (8 bytes)
// ]
// returns sock_nl_generic_init
res = -1;
res = syz_init_net_socket(/*domain=*/0x10, /*type=*/3, /*proto=*/0x10);
if (res != -1)
r[1] = res;
// syz_genetlink_get_family_id$nbd arguments: [
// name: ptr[in, buffer] {
// buffer: {6e 62 64 00} (length 0x4)
// }
// fd: sock_nl_generic_init (resource)
// ]
// returns genl_nbd_family_id
memcpy((void*)0x200000000000, "nbd\000", 4);
res = -1;
res = syz_genetlink_get_family_id(/*name=*/0x200000000000, /*fd=*/-1);
if (res != -1)
r[2] = res;
// socketpair$nbd arguments: [
// domain: const = 0x1 (8 bytes)
// type: const = 0x1 (8 bytes)
// proto: const = 0x0 (4 bytes)
// fds: ptr[out, nbd_sock_pair] {
// nbd_sock_pair {
// client: sock_nbd_client (resource)
// server: sock_nbd_server (resource)
// }
// }
// ]
res = syscall(__NR_socketpair, /*domain=*/1ul, /*type=*/1ul, /*proto=*/0, /*fds=*/0x200000000100ul);
if (res != -1)
r[3] = *(uint32_t*)0x200000000100;
// sendmsg$NBD_CMD_CONNECT arguments: [
// fd: sock_nl_generic_init (resource)
// msg: ptr[in, msghdr_netlink[netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]]] {
// msghdr_netlink[netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]] {
// addr: nil
// addrlen: len = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// vec: ptr[in, iovec[in, netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]]] {
// iovec[in, netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]] {
// addr: ptr[in, netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]] {
// netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy] {
// len: len = 0x38 (4 bytes)
// type: genl_nbd_family_id (resource)
// flags: netlink_msg_flags = 0x1 (2 bytes)
// seq: int32 = 0xfffffffd (4 bytes)
// pid: int32 = 0x0 (4 bytes)
// payload: genlmsghdr_t[NBD_CMD_CONNECT] {
// cmd: const = 0x1 (1 bytes)
// version: const = 0x0 (1 bytes)
// reserved: const = 0x0 (2 bytes)
// }
// attrs: array[nbd_attr_policy] {
// union nbd_attr_policy {
// NBD_ATTR_SOCKETS: nlattr_tt[const[NBD_ATTR_SOCKETS, int16:14], 0, 1, array[nlnest[NBD_SOCK_ITEM, nlattr[NBD_SOCK_FD, sock_nbd_client]]]] {
// nla_len: offsetof = 0x10 (2 bytes)
// nla_type: const = 0x7 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: array[nlattr_tt[const[NBD_SOCK_ITEM, int16:14], 0, 1, nlattr[NBD_SOCK_FD, sock_nbd_client]]] {
// nlattr_tt[const[NBD_SOCK_ITEM, int16:14], 0, 1, nlattr[NBD_SOCK_FD, sock_nbd_client]] {
// nla_len: offsetof = 0xc (2 bytes)
// nla_type: const = 0x1 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: nlattr_t[const[NBD_SOCK_FD, int16], sock_nbd_client] {
// nla_len: offsetof = 0x8 (2 bytes)
// nla_type: const = 0x1 (2 bytes)
// payload: sock_nbd_client (resource)
// size: buffer: {} (length 0x0)
// }
// size: buffer: {} (length 0x0)
// }
// }
// size: buffer: {} (length 0x0)
// }
// }
// union nbd_attr_policy {
// NBD_ATTR_INDEX: nlattr_t[const[NBD_ATTR_INDEX, int16], proc[0, 1, int32]] {
// nla_len: offsetof = 0x8 (2 bytes)
// nla_type: const = 0x1 (2 bytes)
// payload: proc = 0x0 (4 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// union nbd_attr_policy {
// NBD_ATTR_SIZE_BYTES: nlattr_t[const[NBD_ATTR_SIZE_BYTES, int16], int64] {
// nla_len: offsetof = 0xc (2 bytes)
// nla_type: const = 0x2 (2 bytes)
// payload: int64 = 0x7fff (8 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// }
// }
// }
// len: len = 0x38 (8 bytes)
// }
// }
// vlen: const = 0x1 (8 bytes)
// ctrl: const = 0x0 (8 bytes)
// ctrllen: const = 0x0 (8 bytes)
// f: send_flags = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// f: send_flags = 0x20000000 (8 bytes)
// ]
*(uint64_t*)0x200000001ac0 = 0;
*(uint32_t*)0x200000001ac8 = 0;
*(uint64_t*)0x200000001ad0 = 0x200000001a80;
*(uint64_t*)0x200000001a80 = 0x200000000140;
*(uint32_t*)0x200000000140 = 0x38;
*(uint16_t*)0x200000000144 = r[2];
*(uint16_t*)0x200000000146 = 1;
*(uint32_t*)0x200000000148 = 0xfffffffd;
*(uint32_t*)0x20000000014c = 0;
*(uint8_t*)0x200000000150 = 1;
*(uint8_t*)0x200000000151 = 0;
*(uint16_t*)0x200000000152 = 0;
*(uint16_t*)0x200000000154 = 0x10;
STORE_BY_BITMASK(uint16_t, , 0x200000000156, 7, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x200000000157, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x200000000157, 1, 7, 1);
*(uint16_t*)0x200000000158 = 0xc;
STORE_BY_BITMASK(uint16_t, , 0x20000000015a, 1, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x20000000015b, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x20000000015b, 1, 7, 1);
*(uint16_t*)0x20000000015c = 8;
*(uint16_t*)0x20000000015e = 1;
*(uint32_t*)0x200000000160 = r[3];
*(uint16_t*)0x200000000164 = 8;
*(uint16_t*)0x200000000166 = 1;
*(uint32_t*)0x200000000168 = 0;
*(uint16_t*)0x20000000016c = 0xc;
*(uint16_t*)0x20000000016e = 2;
*(uint64_t*)0x200000000170 = 0x7fff;
*(uint64_t*)0x200000001a88 = 0x38;
*(uint64_t*)0x200000001ad8 = 1;
*(uint64_t*)0x200000001ae0 = 0;
*(uint64_t*)0x200000001ae8 = 0;
*(uint32_t*)0x200000001af0 = 0;
syscall(__NR_sendmsg, /*fd=*/r[1], /*msg=*/0x200000001ac0ul, /*f=MSG_FASTOPEN*/0x20000000ul);
// sendmsg$NBD_CMD_RECONFIGURE arguments: [
// fd: sock_nl_generic_init (resource)
// msg: ptr[in, msghdr_netlink[netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_RECONFIGURE], nbd_attr_policy]]] {
// msghdr_netlink[netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_RECONFIGURE], nbd_attr_policy]] {
// addr: nil
// addrlen: len = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// vec: ptr[in, iovec[in, netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_RECONFIGURE], nbd_attr_policy]]] {
// iovec[in, netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_RECONFIGURE], nbd_attr_policy]] {
// addr: ptr[in, netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_RECONFIGURE], nbd_attr_policy]] {
// netlink_msg_t[genl_nbd_family_id, genlmsghdr_t[NBD_CMD_RECONFIGURE], nbd_attr_policy] {
// len: len = 0x48 (4 bytes)
// type: genl_nbd_family_id (resource)
// flags: netlink_msg_flags = 0x503 (2 bytes)
// seq: int32 = 0x70bd28 (4 bytes)
// pid: int32 = 0x25dfdbff (4 bytes)
// payload: genlmsghdr_t[NBD_CMD_RECONFIGURE] {
// cmd: const = 0x3 (1 bytes)
// version: const = 0x0 (1 bytes)
// reserved: const = 0x0 (2 bytes)
// }
// attrs: array[nbd_attr_policy] {
// union nbd_attr_policy {
// NBD_ATTR_INDEX: nlattr_t[const[NBD_ATTR_INDEX, int16], proc[0, 1, int32]] {
// nla_len: offsetof = 0x8 (2 bytes)
// nla_type: const = 0x1 (2 bytes)
// payload: proc = 0x0 (4 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// union nbd_attr_policy {
// NBD_ATTR_DEAD_CONN_TIMEOUT: nlattr_t[const[NBD_ATTR_DEAD_CONN_TIMEOUT, int16], int64] {
// nla_len: offsetof = 0xc (2 bytes)
// nla_type: const = 0x8 (2 bytes)
// payload: int64 = 0x3 (8 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// union nbd_attr_policy {
// NBD_ATTR_SIZE_BYTES: nlattr_t[const[NBD_ATTR_SIZE_BYTES, int16], int64] {
// nla_len: offsetof = 0xc (2 bytes)
// nla_type: const = 0x2 (2 bytes)
// payload: int64 = 0x7 (8 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// union nbd_attr_policy {
// NBD_ATTR_SOCKETS: nlattr_tt[const[NBD_ATTR_SOCKETS, int16:14], 0, 1, array[nlnest[NBD_SOCK_ITEM, nlattr[NBD_SOCK_FD, sock_nbd_client]]]] {
// nla_len: offsetof = 0x10 (2 bytes)
// nla_type: const = 0x7 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: array[nlattr_tt[const[NBD_SOCK_ITEM, int16:14], 0, 1, nlattr[NBD_SOCK_FD, sock_nbd_client]]] {
// nlattr_tt[const[NBD_SOCK_ITEM, int16:14], 0, 1, nlattr[NBD_SOCK_FD, sock_nbd_client]] {
// nla_len: offsetof = 0xc (2 bytes)
// nla_type: const = 0x1 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: nlattr_t[const[NBD_SOCK_FD, int16], sock_nbd_client] {
// nla_len: offsetof = 0x8 (2 bytes)
// nla_type: const = 0x1 (2 bytes)
// payload: sock_nbd_client (resource)
// size: buffer: {} (length 0x0)
// }
// size: buffer: {} (length 0x0)
// }
// }
// size: buffer: {} (length 0x0)
// }
// }
// union nbd_attr_policy {
// NBD_ATTR_SOCKETS: nlattr_tt[const[NBD_ATTR_SOCKETS, int16:14], 0, 1, array[nlnest[NBD_SOCK_ITEM, nlattr[NBD_SOCK_FD, sock_nbd_client]]]] {
// nla_len: offsetof = 0x4 (2 bytes)
// nla_type: const = 0x7 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: array[nlattr_tt[const[NBD_SOCK_ITEM, int16:14], 0, 1, nlattr[NBD_SOCK_FD, sock_nbd_client]]] {
// }
// size: buffer: {} (length 0x0)
// }
// }
// }
// }
// }
// len: len = 0x48 (8 bytes)
// }
// }
// vlen: const = 0x1 (8 bytes)
// ctrl: const = 0x0 (8 bytes)
// ctrllen: const = 0x0 (8 bytes)
// f: send_flags = 0x40 (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// f: send_flags = 0x40080 (8 bytes)
// ]
*(uint64_t*)0x200000000280 = 0;
*(uint32_t*)0x200000000288 = 0;
*(uint64_t*)0x200000000290 = 0x200000000240;
*(uint64_t*)0x200000000240 = 0x200000000140;
*(uint32_t*)0x200000000140 = 0x48;
*(uint16_t*)0x200000000144 = r[2];
*(uint16_t*)0x200000000146 = 0x503;
*(uint32_t*)0x200000000148 = 0x70bd28;
*(uint32_t*)0x20000000014c = 0x25dfdbff;
*(uint8_t*)0x200000000150 = 3;
*(uint8_t*)0x200000000151 = 0;
*(uint16_t*)0x200000000152 = 0;
*(uint16_t*)0x200000000154 = 8;
*(uint16_t*)0x200000000156 = 1;
*(uint32_t*)0x200000000158 = 0;
*(uint16_t*)0x20000000015c = 0xc;
*(uint16_t*)0x20000000015e = 8;
*(uint64_t*)0x200000000160 = 3;
*(uint16_t*)0x200000000168 = 0xc;
*(uint16_t*)0x20000000016a = 2;
*(uint64_t*)0x20000000016c = 7;
*(uint16_t*)0x200000000174 = 0x10;
STORE_BY_BITMASK(uint16_t, , 0x200000000176, 7, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x200000000177, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x200000000177, 1, 7, 1);
*(uint16_t*)0x200000000178 = 0xc;
STORE_BY_BITMASK(uint16_t, , 0x20000000017a, 1, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x20000000017b, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x20000000017b, 1, 7, 1);
*(uint16_t*)0x20000000017c = 8;
*(uint16_t*)0x20000000017e = 1;
*(uint32_t*)0x200000000180 = -1;
*(uint16_t*)0x200000000184 = 4;
STORE_BY_BITMASK(uint16_t, , 0x200000000186, 7, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x200000000187, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x200000000187, 1, 7, 1);
*(uint64_t*)0x200000000248 = 0x48;
*(uint64_t*)0x200000000298 = 1;
*(uint64_t*)0x2000000002a0 = 0;
*(uint64_t*)0x2000000002a8 = 0;
*(uint32_t*)0x2000000002b0 = 0x40;
syscall(__NR_sendmsg, /*fd=*/r[0], /*msg=*/0x200000000280ul, /*f=MSG_BATCH|MSG_EOR*/0x40080ul);
return 0;
}
Reply: The bug is a deadlock/hung task involving the NBD (Network Block Device) driver.
Here is the sequence of events that leads to the hung tasks:
1. The syzkaller reproducer (running with root privileges) sends an `NBD_CMD_CONNECT` netlink message to configure an NBD device. It provides a socket but does not specify a timeout (`NBD_ATTR_TIMEOUT`). As a result, the device's timeout is left at its default value of 0 (no timeout).
2. The configuration sets the device size, which triggers a kernel uevent.
3. `udevd` receives the uevent, opens the block device, and attempts to read the partition table. It submits a read bio to the NBD device.
4. The NBD driver queues the request to the provided socket. However, since there is no actual NBD server listening on the other end of the socket pair, the request receives no reply.
5. Because the device timeout is 0, the block layer's timeout handler (`nbd_xmit_timeout`) continuously returns `BLK_EH_RESET_TIMER`, causing the request to remain in-flight indefinitely.
6. The syzkaller reproducer then sends an `NBD_CMD_RECONFIGURE` netlink message to change the device size.
7. This calls `queue_limits_commit_update_frozen()`, which attempts to freeze the block queue and waits for all in-flight requests to complete (i.e., waits for `q_usage_counter` to drop to 0).
8. Since the read request from `udevd` is stuck forever, the queue freeze operation blocks indefinitely, causing the syzkaller task to hang in `blk_mq_freeze_queue_wait`.
9. Meanwhile, `udevd` attempts to submit the next bio for the partition table read, but blocks in `bio_queue_enter()` because the queue is now in a freezing state.
10. Both tasks hang for more than 143 seconds, triggering the kernel's hung task watchdog.
**Security Impact:**
- The netlink commands `NBD_CMD_CONNECT` and `NBD_CMD_RECONFIGURE` both strictly require `CAP_SYS_ADMIN` in the initial user namespace (enforced by `netlink_capable(skb, CAP_SYS_ADMIN)`).
- Therefore, this bug cannot be triggered by unprivileged users or from within unprivileged user namespaces.
- It is not exploitable for privilege escalation, memory corruption, or information leaks.
- While it represents a Denial of Service (hung task), it requires root privileges to trigger. Thus, it is not considered a security vulnerability, but rather a bug that root can trigger by misconfiguring an NBD device (providing a socket with no server and no timeout).
|
| 6/2 |
2026/09/23 00:55 |
llm |
expert |
0m
Model:
Tokens:
input: 20520
output: 30
thoughts: 272
Thoughts: **Analyzing a Deadlock in the NBD Driver**
Okay, so I've got a problem. I'm looking at a hung task, specifically in `udevd` and `syz.0.17`. My initial thought is it's related to the Network Block Device (NBD) driver. I see `udevd` is blocked deep within the block layer, in `blk_mq_submit_bio` leading through `bio_queue_enter`, `__bio_queue_enter`, and ultimately hitting `schedule`. It's essentially trying to submit a block I/O request, but the queue is stalled, so it's waiting, which is why it's hung.
On the other side, `syz.0.17` is also blocked in a similar fashion, but in `nbd_genl_reconfigure`. Itβs caught up in `nbd_set_size`, and then through `queue_limits_commit_update_frozen`, `blk_mq_freeze_queue`, finally resulting in `blk_mq_freeze_queue_wait` and a `schedule` call. It looks like it's trying to freeze the queue, but it's waiting for something.
My instinct tells me this is a deadlock. I need to understand what's happening during the `nbd_genl_reconfigure` function. This seems like a good place to start my investigation. It appears this function handles the `NBD_CMD_RECONFIGURE` netlink command. I remember the reproducer I used sends `NBD_CMD_CONNECT` followed by `NBD_CMD_RECONFIGURE`. I'm starting to put the pieces together. Now I need to dive into the source code for both `nbd_set_size` and `nbd_genl_reconfigure` to figure out what they're doing and find the conflict. I need to understand how the queue freezing interacts with the bio submission.
|
| 7/2 |
2026/09/23 00:55 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile: Name:nbd_set_size]
Results: map[SourceCode: 355: static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, loff_t blksize)
356: {
357: struct queue_limits lim;
358: int error;
359:
360: if (!blksize)
361: blksize = 1u << NBD_DEF_BLKSIZE_BITS;
362:
363: if (blk_validate_block_size(blksize))
364: return -EINVAL;
365:
366: if (bytesize < 0)
367: return -EINVAL;
368:
369: nbd->config->bytesize = bytesize;
370: nbd->config->blksize_bits = __ffs(blksize);
371:
372: if (!nbd->pid)
373: return 0;
374:
375: lim = queue_limits_start_update(nbd->disk->queue);
376: nbd_apply_limits(&lim, nbd->config->flags);
377: lim.logical_block_size = blksize;
378: lim.physical_block_size = blksize;
379: /* No need freeze with 0 capacity and write cache disabled */
380: if (!get_capacity(nbd->disk) && !blk_queue_write_cache(nbd->disk->queue))
381: error = queue_limits_commit_update(nbd->disk->queue, &lim);
382: else
383: error = queue_limits_commit_update_frozen(nbd->disk->queue, &lim);
384: if (error)
385: return error;
386:
387: if (max_part)
388: set_bit(GD_NEED_PART_SCAN, &nbd->disk->state);
389: if (!set_capacity_and_notify(nbd->disk, bytesize >> 9))
390: kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE);
391: return 0;
392: }
SourceFile:drivers/block/nbd.c]
|
| 8/2 |
2026/09/23 00:55 |
llm |
expert |
0m
Model:
Tokens:
input: 21895
output: 40
thoughts: 753
Thoughts: **Analyzing a Blocking Issue in NBD Driver: A Deep Dive**
Okay, here's what's happening. `nbd_set_size` triggers `queue_limits_commit_update_frozen`, and that's the starting point. I know this function freezes the queue, updates the limits, and then unfreezes it. It waits, naturally, if the queue is frozen. The goal is to flush inflight requests.
Now, I see `udevd` is trying to open the block device, which is causing a blockage. I need to figure out *why*. Let's look at the `udevd` stack trace... it seems it's calling `bdev_open` and then `blkdev_open`.
Aha! `udevd` holds `disk->open_mutex`! The output clearly shows this. And simultaneously, `syz.0.17` is trying to freeze the queue. Now it becomes clearer: `queue_limits_commit_update_frozen` is being initiated while `udevd` is active.
So, here's the key question: Does `udevd` submit a `bio` while holding `disk->open_mutex`? Looks like it does, in the path through `bdev_disk_changed` to `bio_queue_enter`. And that `bio_queue_enter` is probably waiting because of the freeze or at the onset of the freeze!
If `syz.0.17` is freezing the queue, then it should be waiting for any in-flight requests to complete. But `udevd` is attempting to submit a new request, which gets blocked. So, in effect, `udevd` is stuck in `bio_queue_enter` because `syz.0.17` has initiated the freeze.
Now, why is `syz.0.17` blocked? It *should* be waiting for the in-flight requests to finish, right?
But *are* there in-flight requests? Here's the catch: if `udevd` is *submitting* a bio, it *hasn't* entered the queue yet. However, what if `udevd` had already entered the queue with a previous request and is now waiting for this new one? Or could `syz.0.17` be waiting for `udevd` to complete something else? Let me think a second...
Wait... `syz.0.17` holds `&nbd->config_lock`. Does `udevd` need that lock? No, `udevd` is holding `&disk->open_mutex`. Does `syz.0.17` need `&disk->open_mutex`? I need to check `nbd_genl_reconfigure`. Okay...
|
| 9/2 |
2026/09/23 00:55 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/nbd.c Name:nbd_genl_reconfigure]
Results: map[SourceCode:2381: static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
2382: {
2383: struct nbd_device *nbd = NULL;
2384: struct nbd_config *config;
2385: int index;
2386: int ret = 0;
2387: bool put_dev = false;
2388:
2389: if (!netlink_capable(skb, CAP_SYS_ADMIN))
2390: return -EPERM;
2391:
2392: if (GENL_REQ_ATTR_CHECK(info, NBD_ATTR_INDEX)) {
2393: pr_err("must specify a device to reconfigure\n");
2394: return -EINVAL;
2395: }
2396: index = nla_get_u32(info->attrs[NBD_ATTR_INDEX]);
2397: mutex_lock(&nbd_index_mutex);
2398: nbd = idr_find(&nbd_index_idr, index);
2399: if (!nbd) {
2400: mutex_unlock(&nbd_index_mutex);
2401: pr_err("couldn't find a device at index %d\n", index);
2402: return -EINVAL;
2403: }
2404: if (nbd->backend) {
2405: if (info->attrs[NBD_ATTR_BACKEND_IDENTIFIER]) {
2406: if (nla_strcmp(info->attrs[NBD_ATTR_BACKEND_IDENTIFIER],
2407: nbd->backend)) {
2408: mutex_unlock(&nbd_index_mutex);
2409: dev_err(nbd_to_dev(nbd),
2410: "backend image doesn't match with %s\n",
2411: nbd->backend);
2412: return -EINVAL;
2413: }
2414: } else {
2415: mutex_unlock(&nbd_index_mutex);
2416: dev_err(nbd_to_dev(nbd), "must specify backend\n");
2417: return -EINVAL;
2418: }
2419: }
2420: if (!refcount_inc_not_zero(&nbd->refs)) {
2421: mutex_unlock(&nbd_index_mutex);
2422: pr_err("device at index %d is going down\n", index);
2423: return -EINVAL;
2424: }
2425: mutex_unlock(&nbd_index_mutex);
2426:
2427: config = nbd_get_config_unlocked(nbd);
2428: if (!config) {
2429: dev_err(nbd_to_dev(nbd),
2430: "not configured, cannot reconfigure\n");
2431: nbd_put(nbd);
2432: return -EINVAL;
2433: }
2434:
2435: mutex_lock(&nbd->config_lock);
2436: if (!test_bit(NBD_RT_BOUND, &config->runtime_flags) ||
2437: !nbd->pid) {
2438: dev_err(nbd_to_dev(nbd),
2439: "not configured, cannot reconfigure\n");
2440: ret = -EINVAL;
2441: goto out;
2442: }
2443:
2444: ret = nbd_genl_size_set(info, nbd);
2445: if (ret)
2446: goto out;
2447:
2448: if (info->attrs[NBD_ATTR_TIMEOUT])
2449: nbd_set_cmd_timeout(nbd,
2450: nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
2451: if (info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]) {
2452: config->dead_conn_timeout =
2453: nla_get_u64(info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]);
2454: config->dead_conn_timeout *= HZ;
2455: }
2456: if (info->attrs[NBD_ATTR_CLIENT_FLAGS]) {
2457: u64 flags = nla_get_u64(info->attrs[NBD_ATTR_CLIENT_FLAGS]);
2458: if (flags & NBD_CFLAG_DESTROY_ON_DISCONNECT) {
2459: if (!test_and_set_bit(NBD_DESTROY_ON_DISCONNECT,
2460: &nbd->flags))
2461: put_dev = true;
2462: } else {
2463: if (test_and_clear_bit(NBD_DESTROY_ON_DISCONNECT,
2464: &nbd->flags))
2465: refcount_inc(&nbd->refs);
2466: }
2467:
2468: if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) {
2469: set_bit(NBD_RT_DISCONNECT_ON_CLOSE,
2470: &config->runtime_flags);
2471: } else {
2472: clear_bit(NBD_RT_DISCONNECT_ON_CLOSE,
2473: &config->runtime_flags);
2474: }
2475: }
2476:
2477: ret = nbd_genl_foreach_sock(info, nbd_genl_reconnect_sock_cb, nbd);
2478: /* foreach_sock returns a positive count on success; doit must return 0 */
2479: if (ret >= 0)
2480: ret = 0;
2481: out:
2482: mutex_unlock(&nbd->config_lock);
2483: nbd_config_put(nbd);
2484: nbd_put(nbd);
2485: if (put_dev)
2486: nbd_put(nbd);
2487: return ret;
2488: }
SourceFile:drivers/block/nbd.c]
|
| 10/2 |
2026/09/23 00:55 |
llm |
expert |
0m
Model:
Tokens:
input: 25078
output: 39
thoughts: 2048
Thoughts: **Analyzing a Blocked udevd and syz.0.17 Conundrum**
Okay, so I'm looking at this trace, and here's what I'm thinking: `udevd` is blocked in `bio_queue_enter`, and `syz.0.17` is blocked in `blk_mq_freeze_queue_wait`. The latter is waiting for the `q_usage_counter` to hit zero, which tracks the number of active I/O operations. `udevd`'s block in `bio_queue_enter` suggests it's trying to increment this counter, but the queue is frozen. That's the crux.
My initial thought is that if `udevd` is blocked *before* submitting a bio to the queue, the `q_usage_counter` shouldn't have been incremented yet. But, maybe there's a *different* bio that's incremented the counter and is now stalled. I have to look deeper.
The stack trace for `udevd` shows that it's in the middle of reading a partition sector, specifically via `read_part_sector`, down the line to `bdev_open`. That's where I need to focus: it's trying to access the block device. `check_partition` reads sector 0, and then possibly others. If it *had* read sector 0, it would have submitted a bio and waited for its completion. But I need to determine if it is in a "stuck" state.
The key lies in whether there's another request in-flight. Since `udevd` is single-threaded, it can't have its own in-flight request while waiting in `bio_queue_enter`, but it *could* have submitted one earlier, and it's hung. So I see `udevd` has the `disk->open_mutex` lock held, but no other obvious in-flight bio. So, if `udevd` submitted the bio, where is it stuck?
The reproducer using `syzkaller` involves NBD. `NBD_CMD_CONNECT` is critical here; it configures the NBD device. Does this setup initiate a partition scan, and what might this scan be trying to read? Yes, `NBD_CMD_CONNECT` *can* indirectly trigger a `kobject_uevent`, and `udevd` then opens the device, leading to a partition scan and reads via `blk_add_partitions`. But the NBD device is tied to a socket pair.
Ah, the socket pair is key. The reproducer sets up a socket, but importantly, *it doesn't have a server to reply to the NBD requests*.
This explains the deadlock. If `udevd` sends a read request (e.g., for sector 0) to the NBD device, the NBD driver routes it over the socket. Without a server to reply, the request hangs indefinitely.
So here's the kicker: `udevd` is blocked in `bio_queue_enter` *because* `syz.0.17` is running `NBD_CMD_RECONFIGURE` which calls `nbd_set_size`, which in turn calls `queue_limits_commit_update_frozen`, which freezes the queue! So, when `udevd` is trying to submit its read request (for sector 0 or the like), it blocks *because* the queue is frozen. `syz.0.17` is stuck waiting for the queue to drain, but udevd's read is now hanging!
But if the queue is frozen, `udevd` *should* be blocked on `bio_queue_enter` *before* the bio submission occurs. If `syz.0.17` is stuck, it's waiting for the `q_usage_counter` to be zero. Since `udevd` *shouldn't* have submitted a request yet, the counter *should* be zero. Unless there's *another* request in flight which is keeping the queue "busy". Did `NBD_CMD_CONNECT` itself submit a request? I need to check the NBD driver's behavior during `NBD_CMD_CONNECT`. I suspect that is where the counter is incremented, and then hangs when udevd attempts to read, but is blocked by the freeze.
|
| 11/2 |
2026/09/23 00:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/nbd.c Name:nbd_genl_connect]
Results: map[SourceCode:2167: static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
2168: {
2169: struct nbd_device *nbd;
2170: struct nbd_config *config;
2171: int index = -1;
2172: int ret;
2173: bool put_dev = false;
2174:
2175: if (!netlink_capable(skb, CAP_SYS_ADMIN))
2176: return -EPERM;
2177:
2178: if (info->attrs[NBD_ATTR_INDEX]) {
2179: index = nla_get_u32(info->attrs[NBD_ATTR_INDEX]);
2180:
2181: /*
2182: * Too big first_minor can cause duplicate creation of
2183: * sysfs files/links, since index << part_shift might overflow, or
2184: * MKDEV() expect that the max bits of first_minor is 20.
2185: */
2186: if (index < 0 || index > MINORMASK >> part_shift) {
2187: pr_err("illegal input index %d\n", index);
2188: return -EINVAL;
2189: }
2190: }
2191: if (GENL_REQ_ATTR_CHECK(info, NBD_ATTR_SOCKETS)) {
2192: pr_err("must specify at least one socket\n");
2193: return -EINVAL;
2194: }
2195: if (GENL_REQ_ATTR_CHECK(info, NBD_ATTR_SIZE_BYTES)) {
2196: pr_err("must specify a size in bytes for the device\n");
2197: return -EINVAL;
2198: }
2199: again:
2200: mutex_lock(&nbd_index_mutex);
2201: if (index == -1) {
2202: nbd = nbd_find_get_unused();
2203: } else {
2204: nbd = idr_find(&nbd_index_idr, index);
2205: if (nbd) {
2206: if ((test_bit(NBD_DESTROY_ON_DISCONNECT, &nbd->flags) &&
2207: test_bit(NBD_DISCONNECT_REQUESTED, &nbd->flags)) ||
2208: !refcount_inc_not_zero(&nbd->refs)) {
2209: mutex_unlock(&nbd_index_mutex);
2210: pr_err("device at index %d is going down\n",
2211: index);
2212: return -EINVAL;
2213: }
2214: }
2215: }
2216: mutex_unlock(&nbd_index_mutex);
2217:
2218: if (!nbd) {
2219: ret = nbd_genl_foreach_sock(info, NULL, NULL);
2220: if (ret < 0)
2221: return ret;
2222:
2223: nbd = nbd_dev_add(index, 2, ret > 0 ? ret : 1);
2224: if (IS_ERR(nbd)) {
2225: pr_err("failed to add new device\n");
2226: return PTR_ERR(nbd);
2227: }
2228: }
2229:
2230: mutex_lock(&nbd->config_lock);
2231: if (refcount_read(&nbd->config_refs)) {
2232: mutex_unlock(&nbd->config_lock);
2233: nbd_put(nbd);
2234: if (index == -1)
2235: goto again;
2236: pr_err("nbd%d already in use\n", index);
2237: return -EBUSY;
2238: }
2239:
2240: ret = nbd_alloc_and_init_config(nbd);
2241: if (ret) {
2242: mutex_unlock(&nbd->config_lock);
2243: nbd_put(nbd);
2244: pr_err("couldn't allocate config\n");
2245: return ret;
2246: }
2247:
2248: config = nbd->config;
2249: set_bit(NBD_RT_BOUND, &config->runtime_flags);
2250: ret = nbd_genl_size_set(info, nbd);
2251: if (ret)
2252: goto out;
2253:
2254: if (info->attrs[NBD_ATTR_TIMEOUT])
2255: nbd_set_cmd_timeout(nbd,
2256: nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
2257: if (info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]) {
2258: config->dead_conn_timeout =
2259: nla_get_u64(info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]);
2260: config->dead_conn_timeout *= HZ;
2261: }
2262: if (info->attrs[NBD_ATTR_SERVER_FLAGS])
2263: config->flags =
2264: nla_get_u64(info->attrs[NBD_ATTR_SERVER_FLAGS]);
2265: if (info->attrs[NBD_ATTR_CLIENT_FLAGS]) {
2266: u64 flags = nla_get_u64(info->attrs[NBD_ATTR_CLIENT_FLAGS]);
2267: if (flags & NBD_CFLAG_DESTROY_ON_DISCONNECT) {
2268: /*
2269: * We have 1 ref to keep the device around, and then 1
2270: * ref for our current operation here, which will be
2271: * inherited by the config. If we already have
2272: * DESTROY_ON_DISCONNECT set then we know we don't have
2273: * that extra ref already held so we don't need the
2274: * put_dev.
2275: */
2276: if (!test_and_set_bit(NBD_DESTROY_ON_DISCONNECT,
2277: &nbd->flags))
2278: put_dev = true;
2279: } else {
2280: if (test_and_clear_bit(NBD_DESTROY_ON_DISCONNECT,
2281: &nbd->flags))
2282: refcount_inc(&nbd->refs);
2283: }
2284: if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) {
2285: set_bit(NBD_RT_DISCONNECT_ON_CLOSE,
2286: &config->runtime_flags);
2287: }
2288: }
2289:
2290: ret = nbd_genl_foreach_sock(info, nbd_genl_connect_sock_cb, nbd);
2291: if (ret < 0)
2292: goto out;
2293:
2294: if (info->attrs[NBD_ATTR_BACKEND_IDENTIFIER]) {
2295: nbd->backend = nla_strdup(info->attrs[NBD_ATTR_BACKEND_IDENTIFIER],
2296: GFP_KERNEL);
2297: if (!nbd->backend) {
2298: ret = -ENOMEM;
2299: goto out;
2300: }
2301: }
2302: ret = device_create_file(disk_to_dev(nbd->disk), &backend_attr);
2303: if (ret) {
2304: dev_err(disk_to_dev(nbd->disk),
2305: "device_create_file failed for backend!\n");
2306: goto out;
2307: }
2308: set_bit(NBD_RT_HAS_BACKEND_FILE, &config->runtime_flags);
2309:
2310: ret = nbd_start_device(nbd);
2311: out:
2312: if (!ret) {
2313: set_bit(NBD_RT_HAS_CONFIG_REF, &config->runtime_flags);
2314: refcount_inc(&nbd->config_refs);
2315: nbd_connect_reply(info, nbd->index);
2316: }
2317: mutex_unlock(&nbd->config_lock);
2318:
2319: nbd_config_put(nbd);
2320: if (put_dev)
2321: nbd_put(nbd);
2322: return ret;
2323: }
SourceFile:drivers/block/nbd.c]
|
| 12/2 |
2026/09/23 00:56 |
llm |
expert |
0m
Model:
Tokens:
input: 30672
output: 38
thoughts: 40
Thoughts: Here's my thought process, as if I were analyzing this code:
**Diving into the `nbd_start_device` Call**
Okay, so `nbd_genl_connect` is the crucial function here, and I've noticed it calls `nbd_start_device(nbd)`. That's my starting point. I need to understand what happens *within* `nbd_start_device`. I'm going to quickly drill down and see exactly what that function is responsible for. It's likely involved in initializing the device, setting up resources, and potentially even kicking off some background processes for network block device functionality. I'm expecting this to be a key area for managing state and resources. Let's see what's what.
|
| 13/2 |
2026/09/23 00:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/nbd.c Name:nbd_start_device]
Results: map[SourceCode:1512: static int nbd_start_device(struct nbd_device *nbd)
1513: {
1514: struct nbd_config *config = nbd->config;
1515: int num_connections = config->num_connections;
1516: int error = 0, i;
1517:
1518: if (nbd->pid)
1519: return -EBUSY;
1520: if (!config->socks)
1521: return -EINVAL;
1522: if (num_connections > 1 &&
1523: !(config->flags & NBD_FLAG_CAN_MULTI_CONN)) {
1524: dev_err(disk_to_dev(nbd->disk), "server does not support multiple connections per device.\n");
1525: return -EINVAL;
1526: }
1527:
1528: retry:
1529: mutex_unlock(&nbd->config_lock);
1530: blk_mq_update_nr_hw_queues(&nbd->tag_set, num_connections);
1531: mutex_lock(&nbd->config_lock);
1532:
1533: /* if another code path updated nr_hw_queues, retry until succeed */
1534: if (num_connections != config->num_connections) {
1535: num_connections = config->num_connections;
1536: goto retry;
1537: }
1538:
1539: nbd->pid = task_pid_nr(current);
1540:
1541: nbd_parse_flags(nbd);
1542:
1543: error = device_create_file(disk_to_dev(nbd->disk), &pid_attr);
1544: if (error) {
1545: dev_err(disk_to_dev(nbd->disk), "device_create_file failed for pid!\n");
1546: return error;
1547: }
1548: set_bit(NBD_RT_HAS_PID_FILE, &config->runtime_flags);
1549:
1550: nbd_dev_dbg_init(nbd);
1551: for (i = 0; i < num_connections; i++) {
1552: struct recv_thread_args *args;
1553:
1554: args = kzalloc_obj(*args);
1555: if (!args) {
1556: sock_shutdown(nbd);
1557: /*
1558: * If num_connections is m (2 < m),
1559: * and NO.1 ~ NO.n(1 < n < m) kzallocs are successful.
1560: * But NO.(n + 1) failed. We still have n recv threads.
1561: * So, add flush_workqueue here to prevent recv threads
1562: * dropping the last config_refs and trying to destroy
1563: * the workqueue from inside the workqueue.
1564: */
1565: if (i)
1566: flush_workqueue(nbd->recv_workq);
1567: return -ENOMEM;
1568: }
1569: sk_set_memalloc(config->socks[i]->sock->sk);
1570: if (nbd->tag_set.timeout)
1571: config->socks[i]->sock->sk->sk_sndtimeo =
1572: nbd->tag_set.timeout;
1573: atomic_inc(&config->recv_threads);
1574: refcount_inc(&nbd->config_refs);
1575: INIT_WORK(&args->work, recv_work);
1576: args->nbd = nbd;
1577: args->nsock = config->socks[i];
1578: args->index = i;
1579: queue_work(nbd->recv_workq, &args->work);
1580: }
1581: return nbd_set_size(nbd, config->bytesize, nbd_blksize(config));
1582: }
SourceFile:drivers/block/nbd.c]
|
| 14/2 |
2026/09/23 00:56 |
llm |
expert |
0m
Model:
Tokens:
input: 32102
output: 36
thoughts: 888
Thoughts: **Analyzing the NBD Device Freeze**
Okay, let's break this down. `nbd_start_device` calls `nbd_set_size`, which, I now recall, calls `queue_limits_commit_update_frozen` β that's the key. That function freezes the queue, making the whole thing...well, frozen. And `nbd_set_size` also triggers a uevent via `set_capacity_and_notify`. So, the `NBD_CMD_CONNECT` command sets the device size, fires off a uevent, and then returns. `udevd` gets that uevent, opens the device, and begins reading the partition table. Standard stuff.
Then `syz.0.17` comes along with `NBD_CMD_RECONFIGURE`. This calls `nbd_genl_size_set` and, you guessed it, `nbd_set_size`. `nbd_set_size` then, again, calls `queue_limits_commit_update_frozen`, which freezes the queue, potentially while `udevd` is trying to do its partition table reading thing.
Here's the problem. `udevd` submits a bio to the NBD device. This bio goes to the device, and the `recv_work` thread attempts to read from the socket. However, because there is no server to answer, the bio is, essentially, stuck. This in-flight bio keeps the `q_usage_counter` greater than zero.
Now, when `NBD_CMD_RECONFIGURE` calls `queue_limits_commit_update_frozen`, it waits for that `q_usage_counter` to drop to zero before committing the freeze. Because the bio is stuck, `NBD_CMD_RECONFIGURE` blocks indefinitely. But...why is `udevd` blocked in `bio_queue_enter`? If `udevd` had submitted a bio, it would be waiting in `bh_submit` or `wait_on_buffer` for it to complete. But it's not β it's stuck *before* submission!
Let's look at that stack trace of `udevd` again:
`__bio_queue_enter`, `bio_queue_enter`, `blk_mq_submit_bio`, `__submit_bio_noacct_mq`, `submit_bio_noacct_nocheck`, `bh_submit`, and finally `block_read_full_folio`.
That's significant! It means `udevd` is *trying* to submit a bio via `bio_queue_enter`, but the queue is already in the process of freezing! This means that `udevd` hasn't yet submitted the bio.
If that's the case, who submitted the bio that's keeping that `q_usage_counter` high? Was it another bio from `udevd`? If so, why isn't `udevd` waiting for completion? `block_read_full_folio` reads folios and waits!
Ah! Could `block_read_full_folio` submit multiple bios, given a large folio? That could explain the previous behavior. No, `bh_submit` submits one `buffer_head` at a time. However... `block_read_full_folio` loops through the `buffer_heads` inside of a folio, submitting them, *then* waiting on *all* of them.
Okay, let's go back and examine `block_read_full_folio`... that's the next step.
|
| 15/2 |
2026/09/23 00:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/buffer.c Name:block_read_full_folio]
Results: map[SourceCode:2270: /*
2271: * Generic "read_folio" function for block devices that have the normal
2272: * get_block functionality. This is most of the block device filesystems.
2273: * Reads the folio asynchronously --- the unlock_buffer() and
2274: * set/clear_buffer_uptodate() functions propagate buffer state into the
2275: * folio once IO has completed.
2276: */
2277: int block_read_full_folio(struct folio *folio, get_block_t *get_block)
2278: {
2279: struct inode *inode = folio->mapping->host;
2280: sector_t iblock, lblock;
2281: struct buffer_head *bh, *head, *prev = NULL;
2282: size_t blocksize;
2283: int fully_mapped = 1;
2284: bool page_error = false;
2285: loff_t limit = i_size_read(inode);
2286:
2287: /* This is needed for ext4. */
2288: if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode))
2289: limit = inode->i_sb->s_maxbytes;
2290:
2291: head = folio_create_buffers(folio, inode, 0);
2292: blocksize = head->b_size;
2293:
2294: iblock = div_u64(folio_pos(folio), blocksize);
2295: lblock = div_u64(limit + blocksize - 1, blocksize);
2296: bh = head;
2297:
2298: do {
2299: if (buffer_uptodate(bh))
2300: continue;
2301:
2302: if (!buffer_mapped(bh)) {
2303: int err = 0;
2304:
2305: fully_mapped = 0;
2306: if (iblock < lblock) {
2307: WARN_ON(bh->b_size != blocksize);
2308: err = get_block(inode, iblock, bh, 0);
2309: if (err)
2310: page_error = true;
2311: }
2312: if (!buffer_mapped(bh)) {
2313: folio_zero_range(folio, bh_offset(bh),
2314: blocksize);
2315: if (!err)
2316: set_buffer_uptodate(bh);
2317: continue;
2318: }
2319: /*
2320: * get_block() might have updated the buffer
2321: * synchronously
2322: */
2323: if (buffer_uptodate(bh))
2324: continue;
2325: }
2326:
2327: lock_buffer(bh);
2328: if (buffer_uptodate(bh)) {
2329: unlock_buffer(bh);
2330: continue;
2331: }
2332:
2333: /*
2334: * If a folio's buffers are under async readin
2335: * (end_buffer_async_read completion) then there is a
2336: * possibility that another thread of control could lock
2337: * one of the buffers after it has completed but while
2338: * some of the other buffers have not completed. This
2339: * locked buffer would confuse end_buffer_async_read()
2340: * into not unlocking the folio. So the absence of
2341: * BH_Async_Read tells end_buffer_async_read() that this
2342: * buffer is not under async I/O.
2343: *
2344: * The folio comes unlocked when it has no locked
2345: * buffer_async buffers left.
2346: *
2347: * The folio lock prevents anyone starting new async
2348: * I/O reads into any of the buffers.
2349: *
2350: * The writeback flag is used to prevent simultaneous
2351: * writeout of the same folio.
2352: *
2353: * The folio lock prevents anyone from starting writeback
2354: * of a folio which is under read I/O (the writeback
2355: * flag is only ever set on a locked folio).
2356: */
2357: set_buffer_async_read(bh);
2358: if (prev)
2359: bh_submit(prev, REQ_OP_READ, bh_end_async_read);
2360: prev = bh;
2361: } while (iblock++, (bh = bh->b_this_page) != head);
2362:
2363: if (fully_mapped)
2364: folio_set_mappedtodisk(folio);
2365:
2366: /*
2367: * All buffers are uptodate or get_block() returned an error
2368: * when trying to map them - we must finish the read because
2369: * end_buffer_async_read() will never be called on any buffer
2370: * in this folio.
2371: */
2372: if (prev)
2373: bh_submit(prev, REQ_OP_READ, bh_end_async_read);
2374: else
2375: folio_end_read(folio, !page_error);
2376:
2377: return 0;
2378: }
SourceFile:fs/buffer.c]
|
| 16/2 |
2026/09/23 00:56 |
llm |
expert |
0m
Model:
Tokens:
input: 35414
output: 41
thoughts: 484
Thoughts: **Analyzing the Deadlock in the NBD Driver**
Okay, so `block_read_full_folio` is looping through the folio buffers, which makes perfect sense. If the folio is larger than the block size, it's going to submit multiple BIOs, like in this case it's 4 KB folio with 1KB block size, submitting 4 BIOs. The first BIO gets submitted, and that heads straight to the NBD driver, which then queues it to the socket. But, *aha*, there's no server to actually respond to this, so that first BIO is essentially stuck in flight. The `q_usage_counter` gets incremented, as expected.
Then, `syz.0.17` triggers an `NBD_CMD_RECONFIGURE` call, which in turn calls `queue_limits_commit_update_frozen`. And that's where things get interesting. That freezes the queue; sets it to a freezing state, and it waits for `q_usage_counter` to hit zero.
Now, `udevd` comes along to submit the *second* BIO from that folio. It makes its way through `bh_submit`, `submit_bio_noacct_nocheck`, `blk_mq_submit_bio`, and then it hits `bio_queue_enter`. Because the queue is in this freezing state, `bio_queue_enter` blocks! `udevd` is now blocked, waiting for the queue to unfreeze.
But, and this is the crux of it, the queue is *never* going to unfreeze because `syz.0.17` is waiting for `q_usage_counter` to reach zero. And `q_usage_counter` will never hit zero because the first BIO is stuck in the NBD driver, waiting on a reply from the socket which it will never get! No server to respond, so it's a deadlock.
Wait, though, isn't there a timeout for these sorts of requests? I should check to see if there's a timeout configured. The reproducer sets `NBD_ATTR_DEAD_CONN_TIMEOUT` to 3. But it doesn't set `NBD_ATTR_TIMEOUT`. Hmm, does the `NBD_CMD_CONNECT` command set any timeouts? Let's check the reproducer again and see if `NBD_ATTR_TIMEOUT` is set there.
|
| 17/2 |
2026/09/23 00:56 |
tool |
codeexpert |
17m
Args: map[Question:Does the reproducer set NBD_ATTR_TIMEOUT in NBD_CMD_CONNECT or NBD_CMD_RECONFIGURE?]
Results: map[Answer:Based on an analysis of the Linux kernel source code in `drivers/block/nbd.c`:
1. **Kernel Handling in Both Commands:**
Both `NBD_CMD_CONNECT` (`nbd_genl_connect`) and `NBD_CMD_RECONFIGURE` (`nbd_genl_reconfigure`) explicitly support and handle `NBD_ATTR_TIMEOUT`:
```c
if (info->attrs[NBD_ATTR_TIMEOUT])
nbd_set_cmd_timeout(nbd, nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
```
2. **Reproducer Context & Caveats:**
- Standalone reproducer code (e.g., from syzkaller / syzbot bug reports) is not committed directly into the kernel source tree.
- In relevant bug reports and commits involving `NBD_CMD_RECONFIGURE` and timeout bugs (such as commit `acb19e17c513` "nbd: restore default timeout when setting it to zero" and commit `9517b82d8d42` "nbd: defer config put in recv_work" reproducing races between socket clearing and reconfiguring), reproducers testing dynamic timeout changes or socket resets set `NBD_ATTR_TIMEOUT` during `NBD_CMD_RECONFIGURE` (or initially during `NBD_CMD_CONNECT` and subsequent reconfiguration).
- Because the exact external reproducer file was not bundled with the tree, the exact netlink attribute layout of that specific test case cannot be definitively confirmed from the repository alone without the reproducer source itself.]
|
| 18/3 |
2026/09/23 00:56 |
agent |
codeexpert |
17m
Model:
Results: map[Answer:Based on an analysis of the Linux kernel source code in `drivers/block/nbd.c`:
1. **Kernel Handling in Both Commands:**
Both `NBD_CMD_CONNECT` (`nbd_genl_connect`) and `NBD_CMD_RECONFIGURE` (`nbd_genl_reconfigure`) explicitly support and handle `NBD_ATTR_TIMEOUT`:
```c
if (info->attrs[NBD_ATTR_TIMEOUT])
nbd_set_cmd_timeout(nbd, nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
```
2. **Reproducer Context & Caveats:**
- Standalone reproducer code (e.g., from syzkaller / syzbot bug reports) is not committed directly into the kernel source tree.
- In relevant bug reports and commits involving `NBD_CMD_RECONFIGURE` and timeout bugs (such as commit `acb19e17c513` "nbd: restore default timeout when setting it to zero" and commit `9517b82d8d42` "nbd: defer config put in recv_work" reproducing races between socket clearing and reconfiguring), reproducers testing dynamic timeout changes or socket resets set `NBD_ATTR_TIMEOUT` during `NBD_CMD_RECONFIGURE` (or initially during `NBD_CMD_CONNECT` and subsequent reconfiguration).
- Because the exact external reproducer file was not bundled with the tree, the exact netlink attribute layout of that specific test case cannot be definitively confirmed from the repository alone without the reproducer source itself.]
Instruction:
You are a capable Linux kernel developer tasked with researching complex questions
about kernel source code. You will be given a concrete question, and need to provide
a concrete answer.
Research the question using targeted, efficient tool calls. Don't make assumptions,
or rely on your previous knowledge about the kernel source code, use available tools
to access the actual source code. Keep your tool calls focused and limited to the
scope of the question. Do not explore tangential code paths or perform unbounded searches.
Use all available sources of information:
- kernel source code
- documentation in the Documentation dir in the source tree
- git commits descriptions, git blame
Do not guess file names or file paths and attempt to read them without
verifying their existence first using content search or directory listing tools.
If a file, symbol, or directory is not found via content search (grepper) or
directory listing (codesearch-dir-index), treat it as completely absent.
Do not attempt to guess alternative names, extensions, or directories.
Tool Selection Guidelines:
1. For C functions, structs, and variables: Prefer codesearch-definition-source
or codesearch-struct-layout FIRST to retrieve clean, exact definitions
without line-number guessing.
2. If symbol lookup fails (e.g., preprocessor macros, macro-generated code, or
disabled #ifdef branches), fall back to read-file or grepper.
3. For file headers, #include directives, preprocessor macro definitions, and
non-C files (Kconfig, Makefiles, docs): Use read-file or grepper directly.
4. Be concise and targeted. Answer the question as directly and concisely as possible
once you have located the relevant code or definitions. If a symbol or function cannot
be found after targeted searches, conclude with the best available information rather
than continuing repetitive searches.
Do NOT use git-log to search for the presence or existence of files in the
repository. git-log is only for tracing commit history of files that are
already present in the current checkout. If a file does not exist in the
current checkout, it cannot be used for reproduction.
Avoid running broad git-log queries (such as searches on the entire repo)
without a specific 'PathPrefix' to restrict the scope, as these are very
expensive and will time out.
If a git-log tool call times out, do not retry the query with the same broad
scope. You must specify a tighter, narrower 'PathPrefix' for subsequent queries.
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: Does the reproducer set NBD_ATTR_TIMEOUT in NBD_CMD_CONNECT or NBD_CMD_RECONFIGURE?
|
| 19/4 |
2026/09/23 00:56 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 4173
output: 20
thoughts: 255
Thoughts: **Analyzing the Reproducer Question**
Okay, so the user is asking a very specific question: does this reproducerβwhatever that isβset `NBD_ATTR_TIMEOUT` during either `NBD_CMD_CONNECT` or `NBD_CMD_RECONFIGURE`? My immediate thought is, "Wait, what reproducer are we talking about?" I need more context. Is there a specific reproducer file I should be looking at, or is this related to a particular commit, bug report, or something mentioned in the documentation? I need to clarify that before I can provide a useful answer.
Right, so, let's break this down systematically. I need to figure out the context of this question. I'll need to look for any files in the relevant repository that contain the strings `NBD_ATTR_TIMEOUT`, `NBD_CMD_CONNECT`, and `NBD_CMD_RECONFIGURE`. Time to fire up `grepper` (or git logs if that proves more fruitful).
From a risk perspective, this is a pretty low-stakes request. This is likely a question about analyzing existing kernel code, or figuring out how to recreate a particular bug, not generating an exploit or dealing with potentially malicious code. I'm just analyzing the question and the code's behavior. So, let's get searching.
|
| 20/4 |
2026/09/23 00:57 |
tool |
grepper |
0m
Args: map[Expression:NBD_ATTR_TIMEOUT]
Results: map[Output:drivers/block/nbd.c=2072=static const struct nla_policy nbd_attr_policy[NBD_ATTR_MAX + 1] = {
--
drivers/block/nbd.c-2075- [NBD_ATTR_BLOCK_SIZE_BYTES] = { .type = NLA_U64 },
drivers/block/nbd.c:2076: [NBD_ATTR_TIMEOUT] = { .type = NLA_U64 },
drivers/block/nbd.c-2077- [NBD_ATTR_SERVER_FLAGS] = { .type = NLA_U64 },
--
drivers/block/nbd.c=2167=static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
--
drivers/block/nbd.c-2253-
drivers/block/nbd.c:2254: if (info->attrs[NBD_ATTR_TIMEOUT])
drivers/block/nbd.c-2255- nbd_set_cmd_timeout(nbd,
drivers/block/nbd.c:2256: nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
drivers/block/nbd.c-2257- if (info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]) {
--
drivers/block/nbd.c=2381=static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
--
drivers/block/nbd.c-2447-
drivers/block/nbd.c:2448: if (info->attrs[NBD_ATTR_TIMEOUT])
drivers/block/nbd.c-2449- nbd_set_cmd_timeout(nbd,
drivers/block/nbd.c:2450: nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
drivers/block/nbd.c-2451- if (info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]) {
--
include/uapi/linux/nbd-netlink.h=27=enum {
--
include/uapi/linux/nbd-netlink.h-31- NBD_ATTR_BLOCK_SIZE_BYTES,
include/uapi/linux/nbd-netlink.h:32: NBD_ATTR_TIMEOUT,
include/uapi/linux/nbd-netlink.h-33- NBD_ATTR_SERVER_FLAGS,
]
|
| 21/4 |
2026/09/23 00:57 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 5393
output: 29
thoughts: 95
Thoughts: **Investigating NBD_ATTR_TIMEOUT Handling in nbd.c**
Okay, so I'm noticing that `nbd.c` deals with `NBD_ATTR_TIMEOUT` in both `nbd_genl_connect` and `nbd_genl_reconfigure`. My immediate thought is, "Hmm, is there a known issue related to timeout handling in the NBD driver? Has someone recently reported a problem or maybe provided a reproducer concerning `NBD_ATTR_TIMEOUT`?" I need to quickly check if there are any recent commits that touch upon this specific area. The best way to do that is, of course, fire up `git log` and point it at `drivers/block/nbd.c`. I need to get a clear picture of the recent history and see if any related bugs or fixes have been addressed.
|
| 22/4 |
2026/09/23 00:57 |
tool |
git-log |
0m
Args: map[Count:20 PathPrefix:drivers/block/nbd.c]
Results: map[Output:326d49039c10 nbd: add pre_defined_connections module parameter for pre-created devices
a9d414b4a15c nbd: remove queue freeze for newly created nbd from netlink path
f8d21c590e55 nbd: factor out a nbd_genl_foreach_sock
db285268df79 nbd: skip queue freeze when setting size at device startup
285908f554fe nbd: remove queue freeze in nbd_add_socket
0fdee7c5fa88 nbd: clear queue limits on disconnect
04d8fb23e520 nbd: disallow NBD_SET_SOCK on an active device
fe247030f1ce nbd: simplify find_fallback() by removing redundant logic
9280e6edf656 nbd: don't warn when reclassifying a busy socket lock
d532cddb6c60 nbd: Reclassify sockets to avoid lockdep circular dependency
b040a1a4523d block: switch numa_node to int in blk_mq_hw_ctx and init_request
bf4afc53b77a Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
69050f8d6d07 treewide: Replace kmalloc with kmalloc_obj for non-scalar types
1649714b930f nbd: defer config unlock in nbd_genl_connect
9517b82d8d42 nbd: defer config put in recv_work
4601b7923d1b nbd: don't copy kernel creds
81ccca31214e nbd: override creds to kernel when calling sock_{send,recv}msg()
51723bf92679 drivers/block: replace use of system_wq with system_percpu_wq
9f7c02e03157 nbd: restrict sockets to TCP and UDP
8b428f42f3ed nbd: fix lockdep deadlock warning
]
|
| 23/4 |
2026/09/23 00:57 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 6227
output: 42
thoughts: 54
Thoughts: Okay, here's the summary, framed as my internal monologue:
**Investigating the Root Cause**
Hold on a minute, before I dive too deep into debugging, I need to check something crucial! Let's get smart about this. The commit messages! That's the first place I should be looking for clues. My initial instinct is to use `git log` with specific regex filters. I'll need to search the commit messages themselves, employing `MessageRegexps`, and focus on key terms that might be relevant to the issue at hand. Keywords like "reproducer," which would indicate someone explicitly crafted a scenario to reliably recreate the problem, or "NBD_ATTR_TIMEOUT" β that timeout variable is screaming out for attention β and anything similar to them. Alternatively, if that yields too little, I'll switch to the `CodeRegexp` or `MessageRegexps` with expanded searches, to find code changes linked to that timeout. That should quickly zero in on any recent modifications that touch that particular attribute or any related areas of the code base. Let's see if that quick triage uncovers anything immediately actionable.
|
| 24/4 |
2026/09/23 00:57 |
tool |
git-log |
0m
Args: map[Count:20 MessageRegexps:[NBD_ATTR_TIMEOUT] PathPrefix:drivers/block/nbd.c]
Results:
|
| 25/4 |
2026/09/23 00:57 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 6572
output: 44
thoughts: 35
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Analyzing Relevant Network Block Device Commits**
Right, let's dive into this. My initial instinct is to zero in on specific commit activity within the NBD (Network Block Device) codebase. I'm thinking, where are the hotspots for potential changes or modifications around command timeouts, reconfiguration, and connection handling? Therefore, I need to focus my search parameters. I'm going to look for commits where the keywords `nbd_set_cmd_timeout`, `NBD_CMD_RECONFIGURE`, or `NBD_CMD_CONNECT` are explicitly mentioned. These keywords are highly indicative of relevant code sections. This should quickly filter down the massive codebase to reveal changes that touch on the kernel module behavior I'm interested in, allowing me to pinpoint the precise commits I need to analyze for deeper understanding. This targeted approach is far more efficient than a broad search, and will allow me to quickly identify any potential regressions or improvements.
|
| 26/4 |
2026/09/23 00:57 |
tool |
git-log |
0m
Args: map[Count:20 MessageRegexps:[nbd_set_cmd_timeout] PathPrefix:drivers/block/nbd.c]
Results:
|
| 27/4 |
2026/09/23 00:57 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 6883
output: 41
thoughts: 27
Thoughts: Here's a summary of my thought process, as requested:
**Digging into the Network Block Device Codebase**
Okay, so I'm trying to figure out what's going on with this NBD implementation. First thing's first: I need to pinpoint where the connection or reconfiguration logic is handled. Given my understanding of NBD, I'm pretty sure `NBD_CMD_CONNECT` and `NBD_CMD_RECONFIGURE` are going to be key. Time to crack open the git log and see what commits touch those commands. That's usually the best way to get a quick overview of relevant code changes and understand the evolution of this area. Let's see what the history reveals.
|
| 28/4 |
2026/09/23 00:57 |
tool |
git-log |
0m
Args: map[Count:20 MessageRegexps:[NBD_CMD_] PathPrefix:drivers/block/nbd.c]
Results: map[Output:9280e6edf656 nbd: don't warn when reclassifying a busy socket lock
1649714b930f nbd: defer config unlock in nbd_genl_connect
9517b82d8d42 nbd: defer config put in recv_work
c9ea57c91f03 nbd: fix race between timeout and normal completion
09dadb598502 nbd: fix io hung while disconnecting device
2895f1831e91 nbd: don't clear 'NBD_CMD_INFLIGHT' flag if request is not completed
4e6eef5dc25b nbd: don't handle response without a corresponding request message
04cfac4e40b2 nbd: zero from and len fields in NBD_CMD_DISCONNECT.
75f187aba5e7 nbd: support FLUSH requests
]
|
| 29/4 |
2026/09/23 00:57 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 7339
output: 27
thoughts: 145
Thoughts: Okay, let's see. My initial instinct is to jump directly into the code, but hold on a second. First, let's take a look at those top commits. Hmm, interesting...
**Investigating Recent NBD Changes**
Okay, here we go... 1649714b930f: "nbd: defer config unlock in nbd_genl_connect". Then there's 9517b82d8d42: "nbd: defer config put in recv_work". And finally, 9280e6edf656: "nbd: don't warn when reclassifying a busy socket lock". These all look related, and they seem to be focusing on the Network Block Device (NBD) configuration and some kind of locking mechanism. That's a good place to start my investigation.
Right, time to pull up those commits using `git show` and see what's actually changed. I need to understand the specifics of each one to build a complete mental model of what's happening.
|
| 30/4 |
2026/09/23 00:57 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 1649714b930f9ea6233ce0810ba885999da3b5d4
Author: Zheng Qixing <zhengqixing@huawei.com>
Date: Mon Nov 10 20:49:20 2025 +0800
nbd: defer config unlock in nbd_genl_connect
There is one use-after-free warning when running NBD_CMD_CONNECT and
NBD_CLEAR_SOCK:
nbd_genl_connect
nbd_alloc_and_init_config // config_refs=1
nbd_start_device // config_refs=2
set NBD_RT_HAS_CONFIG_REF open nbd // config_refs=3
recv_work done // config_refs=2
NBD_CLEAR_SOCK // config_refs=1
close nbd // config_refs=0
refcount_inc -> uaf
------------[ cut here ]------------
refcount_t: addition on 0; use-after-free.
WARNING: CPU: 24 PID: 1014 at lib/refcount.c:25 refcount_warn_saturate+0x12e/0x290
nbd_genl_connect+0x16d0/0x1ab0
genl_family_rcv_msg_doit+0x1f3/0x310
genl_rcv_msg+0x44a/0x790
The issue can be easily reproduced by adding a small delay before
refcount_inc(&nbd->config_refs) in nbd_genl_connect():
mutex_unlock(&nbd->config_lock);
if (!ret) {
set_bit(NBD_RT_HAS_CONFIG_REF, &config->runtime_flags);
+ printk("before sleep\n");
+ mdelay(5 * 1000);
+ printk("after sleep\n");
refcount_inc(&nbd->config_refs);
nbd_connect_reply(info, nbd->index);
}
Fixes: e46c7287b1c2 ("nbd: add a basic netlink interface")
Signed-off-by: Zheng Qixing <zhengqixing@huawei.com>
Reviewed-by: Yu Kuai <yukuai@fnnas.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 0df7b33af677..bbbafb6e2b33 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -2235,12 +2235,13 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
ret = nbd_start_device(nbd);
out:
- mutex_unlock(&nbd->config_lock);
if (!ret) {
set_bit(NBD_RT_HAS_CONFIG_REF, &config->runtime_flags);
refcount_inc(&nbd->config_refs);
nbd_connect_reply(info, nbd->index);
}
+ mutex_unlock(&nbd->config_lock);
+
nbd_config_put(nbd);
if (put_dev)
nbd_put(nbd);
]
|
| 31/4 |
2026/09/23 00:57 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 8670
output: 28
thoughts: 146
Thoughts: **My Initial Inquiry: Tracing the Origins of "The Reproducer"**
Okay, first things first, I need to understand where this "reproducer" concept is even coming from. It's not immediately obvious. My gut tells me there's something to investigate related to `NBD_ATTR_TIMEOUT`. Where did this originate? Let's begin a targeted search through the git log, looking for mentions of `NBD_ATTR_TIMEOUT` across the kernel's source, maybe within tests, tools, or even the documentation. My immediate hunch is to check the `tools/testing/selftests` directory; it's a likely candidate for timeout-related testing.
Alright, let's cast a wider net. I'm going to run a grep for `NBD_ATTR_TIMEOUT` across *all* files. That should give me a good overview of where this is actually defined and used within the entire codebase.
Hold on... the first grep results are in. It looks like it's primarily confined to: `drivers/block/nbd.c` and `include/uapi/linux/nbd-netlink.h`. Interesting... So, from the initial look, that's it - just those two files in the *entire* kernel source tree.
Okay, let's take a look at the git log, again, but now looking for `NBD_ATTR_TIMEOUT` anywhere in the tree. Maybe that'll give me some context on how these files interact.
|
| 32/4 |
2026/09/23 00:57 |
tool |
git-log |
10m
Error:
Args: map[CodeRegexp:NBD_ATTR_TIMEOUT Count:20]
Results:
|
| 33/4 |
2026/09/23 01:07 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 9199
output: 37
thoughts: 22
Thoughts: Here's a summary of my thought process:
**Diving into Block Device Driver History with `git-log` and `CodeRegexp`**
Okay, time to get my hands dirty. I need to understand the evolution of the block device drivers. My initial approach? Let's leverage `git-log`. This is the go-to tool for tracing code history, and I'll focus on the `drivers/block/` directory specifically. That should narrow the scope considerably and give me a manageable dataset to work with.
Now, simply looking at commit messages might not be enough. I need to be precise, which means I'll use `CodeRegexp`. This will allow me to apply more intricate filters to the logs. I can search for patterns in the code itself, not just the text of the commit. I could be looking for specific changes related to performance, bug fixes, features, or architectural shifts within that area of the kernel. This detailed approach with `CodeRegexp` will provide a far more refined and targeted view of the drivers' development. This should get me the high-level information that I require.
|
| 34/4 |
2026/09/23 01:07 |
tool |
git-log |
0m
Args: map[CodeRegexp:NBD_ATTR_TIMEOUT Count:20 PathPrefix:drivers/block]
Results: map[Output:55313e92bd17 nbd: add set cmd timeout helper
b7aa3d39385d nbd: add a reconfigure netlink command
e46c7287b1c2 nbd: add a basic netlink interface
]
|
| 35/4 |
2026/09/23 01:07 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 9571
output: 26
thoughts: 36
Thoughts: Here's my take on those thoughts, tailored for an expert audience:
**Analyzing a Potential NBD Enhancement**
Hold on a second! I just saw a commit come across the radar: `55313e92bd17`. The title "nbd: add set cmd timeout helper" immediately piqued my interest. My immediate reaction is, let's dive into this commit and see what it's all about. I'm especially curious about how they're handling timeouts at the command level within NBD. Are we talking about improved error handling, more granular control over I/O behavior, or perhaps some attempt to prevent hangs under specific network conditions? I need to understand the design choices made here. I'll need to check the code to see if it's a good approach.
|
| 36/4 |
2026/09/23 01:07 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 55313e92bd17a872b99cfb5f21dd6d3ff1999bce
Author: Mike Christie <mchristi@redhat.com>
Date: Tue Aug 13 11:39:49 2019 -0500
nbd: add set cmd timeout helper
Add a helper to set the cmd timeout. It does not really do a lot now,
but will be more useful in the next patches.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index e21d2ded732b..69d0e5260e1d 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1246,6 +1246,12 @@ static bool nbd_is_valid_blksize(unsigned long blksize)
return true;
}
+static void nbd_set_cmd_timeout(struct nbd_device *nbd, u64 timeout)
+{
+ nbd->tag_set.timeout = timeout * HZ;
+ blk_queue_rq_timeout(nbd->disk->queue, timeout * HZ);
+}
+
/* Must be called with config_lock held */
static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
unsigned int cmd, unsigned long arg)
@@ -1276,10 +1282,8 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
nbd_size_set(nbd, config->blksize, arg);
return 0;
case NBD_SET_TIMEOUT:
- if (arg) {
- nbd->tag_set.timeout = arg * HZ;
- blk_queue_rq_timeout(nbd->disk->queue, arg * HZ);
- }
+ if (arg)
+ nbd_set_cmd_timeout(nbd, arg);
return 0;
case NBD_SET_FLAGS:
@@ -1799,11 +1803,9 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
if (ret)
goto out;
- if (info->attrs[NBD_ATTR_TIMEOUT]) {
- u64 timeout = nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]);
- nbd->tag_set.timeout = timeout * HZ;
- blk_queue_rq_timeout(nbd->disk->queue, timeout * HZ);
- }
+ if (info->attrs[NBD_ATTR_TIMEOUT])
+ nbd_set_cmd_timeout(nbd,
+ nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
if (info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]) {
config->dead_conn_timeout =
nla_get_u64(info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]);
@@ -1971,11 +1973,9 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
if (ret)
goto out;
- if (info->attrs[NBD_ATTR_TIMEOUT]) {
- u64 timeout = nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]);
- nbd->tag_set.timeout = timeout * HZ;
- blk_queue_rq_timeout(nbd->disk->queue, timeout * HZ);
- }
+ if (info->attrs[NBD_ATTR_TIMEOUT])
+ nbd_set_cmd_timeout(nbd,
+ nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
if (info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]) {
config->dead_conn_timeout =
nla_get_u64(info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]);
]
|
| 37/4 |
2026/09/23 01:07 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 10950
output: 44
thoughts: 77
Thoughts: Here's my thought process, as if I were reviewing this:
**Investigating NBD Timeout and Reconfiguration Changes**
Okay, hold on a second. I need to zero in on something here. My spidey-sense is tingling β let's focus on recent commits that directly interact with the Network Block Device (NBD) code, specifically around timeout settings and reconfiguration. I'm thinking about those functions: `nbd_genl_reconfigure`, `nbd_set_cmd_timeout`, and the related `NBD_ATTR_TIMEOUT` attribute. Those are the key areas I want to examine for potential regressions, unintended consequences, or interesting new features.
To do this efficiently, I should really dig into the commit history. I'll pull up the `git log` for the `drivers/block/nbd.c` file and filter it down. My search terms will be `nbd_set_cmd_timeout` and `nbd_genl_reconfigure`. This should give me a very focused view of any changes that have touched these critical functions, letting me quickly assess the context and impact of those modifications. I need to understand what's been happening in these areas recently, to be sure I'm not missing anything important. This will provide context for the code changes.
|
| 38/4 |
2026/09/23 01:07 |
tool |
git-log |
0m
Args: map[CodeRegexp:nbd_set_cmd_timeout Count:20 PathPrefix:drivers/block/nbd.c]
Results: map[Output:2da22da57348 nbd: fix zero cmd timeout handling v2
55313e92bd17 nbd: add set cmd timeout helper
]
|
| 39/4 |
2026/09/23 01:07 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 11400
output: 25
thoughts: 46
Thoughts: Here's my analysis of the provided text, rendered in the first person, assuming an expert user:
**Analyzing Commit 2da22da57348: "nbd: fix zero cmd timeout handling v2"**
Okay, let's dive right in. The commit message itself is pretty clear: "nbd: fix zero cmd timeout handling v2." The "v2" suggests this is a refinement of a previous attempt to address an issue related to Network Block Device (NBD) and its handling of zero command timeouts. My immediate instinct is to check the diff β what specifically changed this time around? I'm expecting to see modifications around timeout calculations, error handling within the NBD client or server code, potentially even modifications to the underlying socket interactions. The "zero" aspect is what grabs my attention; this is likely dealing with a corner case, perhaps an unexpected scenario where a timeout value of zero is received or set, leading to undefined or undesirable behavior. I need to understand the prior context and issues that led to this revision before I'm convinced the v2 is a correct solution.
|
| 40/4 |
2026/09/23 01:07 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 2da22da573481cc4837e246d0eee4d518b3f715e
Author: Mike Christie <mchristi@redhat.com>
Date: Tue Aug 13 11:39:52 2019 -0500
nbd: fix zero cmd timeout handling v2
This fixes a regression added in 4.9 with commit:
commit 0eadf37afc2500e1162c9040ec26a705b9af8d47
Author: Josef Bacik <jbacik@fb.com>
Date: Thu Sep 8 12:33:40 2016 -0700
nbd: allow block mq to deal with timeouts
where before the patch userspace would set the timeout to 0 to disable
it. With the above patch, a zero timeout tells the block layer to use
the default value of 30 seconds. For setups where commands can take a
long time or experience transient issues like network disruptions this
then results in IO errors being sent to the application.
To fix this, the patch still uses the common block layer timeout
framework, but if zero is set, nbd just logs a message and then resets
the timer when it expires.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index ebc98cf76365..98c618e5732c 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -121,6 +121,7 @@ struct nbd_cmd {
struct mutex lock;
int index;
int cookie;
+ int retries;
blk_status_t status;
unsigned long flags;
u32 cmd_cookie;
@@ -407,10 +408,25 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
nbd_config_put(nbd);
return BLK_EH_DONE;
}
- } else {
- dev_err_ratelimited(nbd_to_dev(nbd),
- "Connection timed out\n");
}
+
+ if (!nbd->tag_set.timeout) {
+ /*
+ * Userspace sets timeout=0 to disable socket disconnection,
+ * so just warn and reset the timer.
+ */
+ 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_unlock(&cmd->lock);
+ nbd_config_put(nbd);
+ return BLK_EH_RESET_TIMER;
+ }
+
+ dev_err_ratelimited(nbd_to_dev(nbd), "Connection timed out\n");
set_bit(NBD_TIMEDOUT, &config->runtime_flags);
cmd->status = BLK_STS_IOERR;
mutex_unlock(&cmd->lock);
@@ -531,6 +547,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
}
cmd->index = index;
cmd->cookie = nsock->cookie;
+ cmd->retries = 0;
request.type = htonl(type | nbd_cmd_flags);
if (type != NBD_CMD_FLUSH) {
request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9);
@@ -1254,7 +1271,8 @@ static bool nbd_is_valid_blksize(unsigned long blksize)
static void nbd_set_cmd_timeout(struct nbd_device *nbd, u64 timeout)
{
nbd->tag_set.timeout = timeout * HZ;
- blk_queue_rq_timeout(nbd->disk->queue, timeout * HZ);
+ if (timeout)
+ blk_queue_rq_timeout(nbd->disk->queue, timeout * HZ);
}
/* Must be called with config_lock held */
@@ -1287,8 +1305,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
nbd_size_set(nbd, config->blksize, arg);
return 0;
case NBD_SET_TIMEOUT:
- if (arg)
- nbd_set_cmd_timeout(nbd, arg);
+ nbd_set_cmd_timeout(nbd, arg);
return 0;
case NBD_SET_FLAGS:
]
|
| 41/4 |
2026/09/23 01:07 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 13099
output: 38
thoughts: 37
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience:
**Debugging a "Reproducer" Issue**
Hmm, this "reproducer" terminology is throwing me. Where did that term originate in this context? Let's quickly investigate. My gut tells me it's related to how we're experiencing this issue, so let's start with `drivers/block/nbd.c`, seems like a good place to start, and see if we can find traces of that term in the commit history. I'm going to run a `git log -S "reproducer" drivers/block/nbd.c` right away. Hopefully the git log will provide some insight into the origin or purpose of the reproducer within this block device driver. Perhaps a previous bug report or testing methodology makes use of it.
|
| 42/4 |
2026/09/23 01:07 |
tool |
git-log |
0m
Args: map[Count:50 MessageRegexps:[reproduce] PathPrefix:drivers/block/nbd.c]
Results: map[Output:1649714b930f nbd: defer config unlock in nbd_genl_connect
1de7c3cf48fc nbd: Fix hung when signal interrupts nbd_start_device_ioctl()
e2daec488c57 nbd: Fix hungtask when nbd_config_put
0c98057be9ef nbd: Fix use-after-free in pid_show
b1a811633f73 block: nbd: add sanity check for first_minor
8454d68563d4 nbd: fix possible page fault for nbd disk
4d48a542b427 nbd: fix I/O hang on disconnected nbds
c91192d66d6c nbd: do not allow two clients at the same time
]
|
| 43/4 |
2026/09/23 01:08 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 13565
output: 38
thoughts: 29
Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue:
**Investigating Potential NBD Driver Issues**
Right, time to dig into a potential NBD driver problem. My initial thought is to go straight to the source. Specifically, I need to see what's been happening recently with `drivers/block/nbd.c`. I need to figure out if there have been any recent commits, fixes, or changes in that area, and where best to start searching. My preferred first stop for this sort of driver-level investigation is `syzkaller` and `syzbot`'s git logs. They're usually gold mines for finding commits related to fuzzing and bug reports, which are often the initial traces that lead me to the relevant code. Looking for recent activity there should quickly highlight any recent issues and likely point to the commits to check out further.
|
| 44/4 |
2026/09/23 01:08 |
tool |
git-log |
0m
Args: map[Count:50 MessageRegexps:[syz] PathPrefix:drivers/block/nbd.c]
Results: map[Output:9280e6edf656 nbd: don't warn when reclassifying a busy socket lock
d532cddb6c60 nbd: Reclassify sockets to avoid lockdep circular dependency
9517b82d8d42 nbd: defer config put in recv_work
9f7c02e03157 nbd: restrict sockets to TCP and UDP
8b428f42f3ed nbd: fix lockdep deadlock warning
aa9552438ebf nbd: fix uaf in nbd_genl_connect() error path
844b8cdc6816 nbd: don't allow reconnect after disconnect
78fbb92af27d nbd: always initialize struct msghdr completely
55793ea54d77 nbd: fix incomplete validation of ioctl arg
1de7c3cf48fc nbd: Fix hung when signal interrupts nbd_start_device_ioctl()
7ee656c3ac3d nbd: remove nbd->destroy_complete
b1a811633f73 block: nbd: add sanity check for first_minor
68c9417b193d nbd: do del_gendisk() asynchronously for NBD_DESTROY_ON_DISCONNECT
16ad3db3b24c nbd: fix order of cleaning up the queue and freeing the tagset
c9a2f90f4d6b nbd: handle device refs for DESTROY_ON_DISCONNECT properly
579dd91ab3a5 nbd: Fix memory leak in nbd_add_socket
cf1b2326b734 nbd: verify socket is supported during setup
bc811f05d77f nbd: don't allow invalid blocksize settings
]
|
| 45/4 |
2026/09/23 01:08 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 14269
output: 25
thoughts: 248
Thoughts: **Analyzing Recent syzbot Commits for Potential Reproducers**
Okay, hold on a second! I need to take a closer look at these syzbot commits that were flagged. My initial instinct is to dig into potential reproducer locations, but let's be methodical. First, I'll go through the commit messages to see what's changed and if anything jumps out.
I'm seeing:
1. A "UAF" fix in `nbd_genl_connect()` β interesting, that error path is always a source of issues.
2. Removal of `nbd->destroy_complete`. This could simplify or create new issues with destruction.
3. Fixing the cleanup order of the queue and freeing the tagset β that's a classic race condition fix, worth understanding.
4. Proper handling of device refs for DESTROY_ON_DISCONNECT. This hints at memory management changes around device teardown which often has subtle consequences.
5. A fix to prevent warnings when reclassifying a busy socket lock. It's often worth looking into why those warnings were happening.
6. Reclassifying sockets to avoid a lockdep circular dependency. This indicates a deep-seated locking issue and is important to fully understand as lockdep can be brittle.
7. Deferring config put in `recv_work`. This could be a concurrency optimization or a bug fix that impacts how resources are released.
I need to understand the implications of each of these changes before I spend more time hunting in other areas. Let's see if the commit messages themselves illuminate anything further.
|
| 46/4 |
2026/09/23 01:08 |
tool |
git-show |
0m
Args:
Results: map[Output:commit aa9552438ebf015fc5f9f890dbfe39f0c53cf37e
Author: Zheng Qixing <zhengqixing@huawei.com>
Date: Thu Jun 12 21:24:05 2025 +0800
nbd: fix uaf in nbd_genl_connect() error path
There is a use-after-free issue in nbd:
block nbd6: Receive control failed (result -104)
block nbd6: shutting down sockets
==================================================================
BUG: KASAN: slab-use-after-free in recv_work+0x694/0xa80 drivers/block/nbd.c:1022
Write of size 4 at addr ffff8880295de478 by task kworker/u33:0/67
CPU: 2 UID: 0 PID: 67 Comm: kworker/u33:0 Not tainted 6.15.0-rc5-syzkaller-00123-g2c89c1b655c0 #0 PREEMPT(full)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: nbd6-recv recv_work
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:408 [inline]
print_report+0xc3/0x670 mm/kasan/report.c:521
kasan_report+0xe0/0x110 mm/kasan/report.c:634
check_region_inline mm/kasan/generic.c:183 [inline]
kasan_check_range+0xef/0x1a0 mm/kasan/generic.c:189
instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
atomic_dec include/linux/atomic/atomic-instrumented.h:592 [inline]
recv_work+0x694/0xa80 drivers/block/nbd.c:1022
process_one_work+0x9cc/0x1b70 kernel/workqueue.c:3238
process_scheduled_works kernel/workqueue.c:3319 [inline]
worker_thread+0x6c8/0xf10 kernel/workqueue.c:3400
kthread+0x3c2/0x780 kernel/kthread.c:464
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:153
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
nbd_genl_connect() does not properly stop the device on certain
error paths after nbd_start_device() has been called. This causes
the error path to put nbd->config while recv_work continue to use
the config after putting it, leading to use-after-free in recv_work.
This patch moves nbd_start_device() after the backend file creation.
Reported-by: syzbot+48240bab47e705c53126@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/68227a04.050a0220.f2294.00b5.GAE@google.com/T/
Fixes: 6497ef8df568 ("nbd: provide a way for userspace processes to identify device backends")
Signed-off-by: Zheng Qixing <zhengqixing@huawei.com>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20250612132405.364904-1-zhengqixing@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 7bdc7eb808ea..2592bd19ebc1 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -2198,9 +2198,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
goto out;
}
}
- ret = nbd_start_device(nbd);
- if (ret)
- goto out;
+
if (info->attrs[NBD_ATTR_BACKEND_IDENTIFIER]) {
nbd->backend = nla_strdup(info->attrs[NBD_ATTR_BACKEND_IDENTIFIER],
GFP_KERNEL);
@@ -2216,6 +2214,8 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
goto out;
}
set_bit(NBD_RT_HAS_BACKEND_FILE, &config->runtime_flags);
+
+ ret = nbd_start_device(nbd);
out:
mutex_unlock(&nbd->config_lock);
if (!ret) {
]
|
| 47/4 |
2026/09/23 01:08 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 16394
output: 28
thoughts: 133
Thoughts: **Investigating NBD Timeout and Reconfiguration Issues**
Okay, so I'm trying to figure out this NBD timeout issue. My initial thought is to dive into the usual suspects: let's start with syzbot reports and see if there are any mentions of `NBD_ATTR_TIMEOUT`, `NBD_CMD_CONNECT`, or `NBD_CMD_RECONFIGURE`. Those keywords are likely to be good indicators.
Then, I need to broaden the search. Let's do a comprehensive search for "NBD_ATTR_TIMEOUT" within the entire git log, across absolutely everything. Gotta be thorough.
Ah, right. I remember running into a timeout issue earlier when using `git-log` with the `CodeRegexp` for "NBD_ATTR_TIMEOUT" and an empty `PathPrefix`. That was annoying. Perhaps searching across all commits using `MessageRegexps` would be faster. Searching commit messages is usually pretty quick. Okay, let's give that a shot and see what we find!
|
| 48/4 |
2026/09/23 01:08 |
tool |
git-log |
0m
Args: map[Count:20 MessageRegexps:[NBD_ATTR_TIMEOUT]]
Results:
|
| 49/4 |
2026/09/23 01:08 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 16785
output: 28
thoughts: 24
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Considering MessageRegexps for NBD Command Handling**
Okay, so I'm staring at a mental blank. Just... nothing. Let's see, where to start? My gut feeling is, I need to get some more precise, more granular control over how the Network Block Device commands are parsed. Hmm... Specifically, I'm thinking about those initial connection and reconfiguration commands β `NBD_CMD_CONNECT` and `NBD_CMD_RECONFIGURE`, respectively.
I'm wondering if a more robust approach than what I've got now is needed. Perhaps I should revisit how I'm handling the initial handshakes and changes. My thought is that I can use `MessageRegexps` to handle these specific commands. It might offer a significant improvement in terms of robustness and flexibility, especially if the command format isn't entirely static, or if I need to validate specific components of the connection or reconfiguration request in more detail. That way, I can parse the specific content of those commands more precisely. It's an interesting direction, I should look further into it.
|
| 50/4 |
2026/09/23 01:08 |
tool |
git-log |
0m
Args: map[Count:20 MessageRegexps:[NBD_CMD_CONNECT]]
Results: map[Output:9280e6edf656 nbd: don't warn when reclassifying a busy socket lock
1649714b930f nbd: defer config unlock in nbd_genl_connect
]
|
| 51/4 |
2026/09/23 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 17146
output: 25
thoughts: 17
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Initial Assessment: A Hash Check is Required**
Right, let's see... the mental trigger here is that hex string, `9280e6edf656`. That's screaming "checksum" or "hash value" at me. My first instinct, without any context, is to check it. I need to understand what this represents. Is it an MD5? SHA-1? SHA-256? Something else entirely? What system or file generated this? I need to figure out what algorithm was used to produce that particular hash. Is it related to any known malware, CVEs or attacks? Time to get the forensic tools out. Letβs determine the origin and relevance of this key. My workflow here dictates a preliminary scan to establish context.
|
| 52/4 |
2026/09/23 01:09 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 9280e6edf65662b6aafc8b704ad065b54c08b519
Author: Deepanshu Kartikey <kartikey406@gmail.com>
Date: Mon Jun 22 05:22:55 2026 +0530
nbd: don't warn when reclassifying a busy socket lock
nbd_reclassify_socket() warns via WARN_ON_ONCE() if the socket lock is
held at the point of reclassification. That assertion was copied from
nvme-tcp, where the socket is created internally by the kernel
(sock_create_kern()) and is never visible to user space, so the lock
is guaranteed to be free.
NBD is different: the socket is looked up from a user-supplied fd in
nbd_get_socket(), and user space retains that fd. A concurrent syscall
on the same socket (or softirq processing taking bh_lock_sock() on a
connected TCP socket) can legitimately hold the lock at the instant
NBD reclassifies it. sock_allow_reclassification() then returns false
and the WARN_ON_ONCE() fires, which turns into a crash under
panic_on_warn. This is reachable by simply racing NBD_CMD_CONNECT
against socket activity on the same fd, as reported by syzbot.
Hitting a held lock here is expected for an externally owned socket and
is not a kernel bug, so skip reclassification silently instead of
warning. Reclassification is a lockdep-only annotation, so skipping it
in the rare racing case is harmless.
Reported-by: syzbot+6b85d1e39a5b8ed9a954@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6b85d1e39a5b8ed9a954
Fixes: d532cddb6c60 ("nbd: Reclassify sockets to avoid lockdep circular dependency")
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260621235255.66015-1-kartikey406@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 3a585a0c882a..8f10762e90ef 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1246,7 +1246,7 @@ static void nbd_reclassify_socket(struct socket *sock)
{
struct sock *sk = sock->sk;
- if (WARN_ON_ONCE(!sock_allow_reclassification(sk)))
+ if (!sock_allow_reclassification(sk))
return;
switch (sk->sk_family) {
]
|
| 53/4 |
2026/09/23 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 18192
output: 26
thoughts: 32
Thoughts: Okay, let's see. My first thought is: **Hold on a second!** I need to take a step back and examine the context. There's another commit, specifically the one touching that `reclassify` function, indicated by `d532cddb6c60`. I know that name. It's too specific to ignore. I need to dive deeper into that commit to understand the full picture before I proceed. This is key. Let's inspect it and see what's changed there, and how it relates to this.
|
| 54/4 |
2026/09/23 01:09 |
tool |
git-show |
0m
Args:
Results: map[Output:commit d532cddb6c6049ced414d64d83c6ce7149a6421a
Author: Eric Dumazet <edumazet@google.com>
Date: Sat Jun 13 04:26:19 2026 +0000
nbd: Reclassify sockets to avoid lockdep circular dependency
syzbot reported a possible circular locking dependency in udp_sendmsg()
where fs_reclaim can be triggered while holding sk_lock, and fs_reclaim
can eventually depend on another sk_lock (e.g., if NBD is used for swap
or writeback and NBD uses TLS/TCP which acquires sk_lock).
Since the UDP socket and the NBD TCP/TLS socket are different, this is a
false positive. Fix this by reclassifying NBD sockets to a separate lock
class when they are added to the NBD device.
This is similar to what nvme-tcp and other network block devices do.
Fixes: ffa1e7ada456 ("block: Make request_queue lockdep splats show up earlier")
Reported-by: syzbot+607cdcf978b3e79da878@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/6a2cdafe.428ffe26.258b27.0161.GAE@google.com/T/#u
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260613042619.1108126-1-edumazet@google.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index e2fe9e3308fc..3a585a0c882a 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1238,6 +1238,42 @@ static struct socket *nbd_get_socket(struct nbd_device *nbd, unsigned long fd,
return sock;
}
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+static struct lock_class_key nbd_key[3];
+static struct lock_class_key nbd_slock_key[3];
+
+static void nbd_reclassify_socket(struct socket *sock)
+{
+ struct sock *sk = sock->sk;
+
+ if (WARN_ON_ONCE(!sock_allow_reclassification(sk)))
+ return;
+
+ switch (sk->sk_family) {
+ case AF_INET:
+ sock_lock_init_class_and_name(sk, "slock-AF_INET-NBD",
+ &nbd_slock_key[0],
+ "sk_lock-AF_INET-NBD",
+ &nbd_key[0]);
+ break;
+ case AF_INET6:
+ sock_lock_init_class_and_name(sk, "slock-AF_INET6-NBD",
+ &nbd_slock_key[1],
+ "sk_lock-AF_INET6-NBD",
+ &nbd_key[1]);
+ break;
+ case AF_UNIX:
+ sock_lock_init_class_and_name(sk, "slock-AF_UNIX-NBD",
+ &nbd_slock_key[2],
+ "sk_lock-AF_UNIX-NBD",
+ &nbd_key[2]);
+ break;
+ }
+}
+#else
+static inline void nbd_reclassify_socket(struct socket *sock) {}
+#endif
+
static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
bool netlink)
{
@@ -1254,6 +1290,7 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
sock = nbd_get_socket(nbd, arg, &err);
if (!sock)
return err;
+ nbd_reclassify_socket(sock);
/*
* We need to make sure we don't get any errant requests while we're
]
|
| 55/4 |
2026/09/23 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 19527
output: 27
thoughts: 23
Thoughts: Okay, let's break this down. My initial instinct is to get straight to the point, but hold on a second... let's not be hasty. Before I dive too deep, I need to take a more holistic view. I'm focusing on a specific commit here, and that means I need to look at this whole section with nuance. I'm thinking, "Wait! Look at the commit `9517b82d8d42` as well:" I need to consider it within the bigger picture.
**Deeper Dive Required: The Need to Examine a Related Commit**
Okay, here's what I'm thinking: I can't just fixate on the immediate changes. This indicates a potential interdependence, a related piece of the puzzle that might offer crucial context. I need to understand *why* this specific commit is being flagged in relation to the current one. I'm inferring that examining `9517b82d8d42` is likely to illuminate the rationale, the previous state, or perhaps even an unintended consequence of the earlier changes. It's almost certain that the current situation will require a comparative analysis with that older commit. My expertise tells me that this is a smart, deliberate way to address the current problem, with an eye toward ensuring all components in the system are handled with due diligence.
|
| 56/4 |
2026/09/23 01:09 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 9517b82d8d422d426a988b213fdd45c6b417b86d
Author: Zheng Qixing <zhengqixing@huawei.com>
Date: Sat Nov 8 15:02:02 2025 +0800
nbd: defer config put in recv_work
There is one uaf issue in recv_work when running NBD_CLEAR_SOCK and
NBD_CMD_RECONFIGURE:
nbd_genl_connect // conf_ref=2 (connect and recv_work A)
nbd_open // conf_ref=3
recv_work A done // conf_ref=2
NBD_CLEAR_SOCK // conf_ref=1
nbd_genl_reconfigure // conf_ref=2 (trigger recv_work B)
close nbd // conf_ref=1
recv_work B
config_put // conf_ref=0
atomic_dec(&config->recv_threads); -> UAF
Or only running NBD_CLEAR_SOCK:
nbd_genl_connect // conf_ref=2
nbd_open // conf_ref=3
NBD_CLEAR_SOCK // conf_ref=2
close nbd
nbd_release
config_put // conf_ref=1
recv_work
config_put // conf_ref=0
atomic_dec(&config->recv_threads); -> UAF
Commit 87aac3a80af5 ("nbd: call nbd_config_put() before notifying the
waiter") moved nbd_config_put() to run before waking up the waiter in
recv_work, in order to ensure that nbd_start_device_ioctl() would not
be woken up while nbd->task_recv was still uncleared.
However, in nbd_start_device_ioctl(), after being woken up it explicitly
calls flush_workqueue() to make sure all current works are finished.
Therefore, there is no need to move the config put ahead of the wakeup.
Move nbd_config_put() to the end of recv_work, so that the reference is
held for the whole lifetime of the worker thread. This makes sure the
config cannot be freed while recv_work is still running, even if clear
+ reconfigure interleave.
In addition, we don't need to worry about recv_work dropping the last
nbd_put (which causes deadlock):
path A (netlink with NBD_CFLAG_DESTROY_ON_DISCONNECT):
connect // nbd_refs=1 (trigger recv_work)
open nbd // nbd_refs=2
NBD_CLEAR_SOCK
close nbd
nbd_release
nbd_disconnect_and_put
flush_workqueue // recv_work done
nbd_config_put
nbd_put // nbd_refs=1
nbd_put // nbd_refs=0
queue_work
path B (netlink without NBD_CFLAG_DESTROY_ON_DISCONNECT):
connect // nbd_refs=2 (trigger recv_work)
open nbd // nbd_refs=3
NBD_CLEAR_SOCK // conf_refs=2
close nbd
nbd_release
nbd_config_put // conf_refs=1
nbd_put // nbd_refs=2
recv_work done // conf_refs=0, nbd_refs=1
rmmod // nbd_refs=0
Reported-by: syzbot+56fbf4c7ddf65e95c7cc@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/6907edce.a70a0220.37351b.0014.GAE@google.com/T/
Fixes: 87aac3a80af5 ("nbd: make the config put is called before the notifying the waiter")
Depends-on: e2daec488c57 ("nbd: Fix hungtask when nbd_config_put")
Signed-off-by: Zheng Qixing <zhengqixing@huawei.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 1188f32a5e5e..0df7b33af677 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1018,9 +1018,9 @@ static void recv_work(struct work_struct *work)
nbd_mark_nsock_dead(nbd, nsock, 1);
mutex_unlock(&nsock->tx_lock);
- nbd_config_put(nbd);
atomic_dec(&config->recv_threads);
wake_up(&config->recv_wq);
+ nbd_config_put(nbd);
kfree(args);
}
]
|
| 57/4 |
2026/09/23 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 21175
output: 29
thoughts: 92
Thoughts: Okay, here's my thought process as I digest this...
**Dissecting the NBD Reproducer Query**
Hold on a second. Before jumping in, I need to take a step back and examine the data. Commit messages and syzbot reports are key here, so let's start there. And, I really need to re-read that question carefully. It's a precise question, and I can't afford to misinterpret it. The core is: "Does the reproducer set NBD_ATTR_TIMEOUT in NBD_CMD_CONNECT or NBD_CMD_RECONFIGURE?"
Alright, so the task isn't just about general NBD behavior; it's pinpointing *where* this `NBD_ATTR_TIMEOUT` setting happens in relation to those specific commands. The question talks about "the reproducer", which is crucial - I need to find the source. Is the reproducer detailed in a commit message within the Git history? It's the most likely source of the necessary information, so I need to go look. My plan is to start by searching for `NBD_CMD_RECONFIGURE` across all available commit messages to identify the relevant code, that should provide enough information for me to provide a complete answer.
|
| 58/4 |
2026/09/23 01:09 |
tool |
git-log |
0m
Args: map[Count:20 MessageRegexps:[NBD_CMD_RECONFIGURE]]
Results: map[Output:9517b82d8d42 nbd: defer config put in recv_work
]
|
| 59/4 |
2026/09/23 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 21597
output: 38
thoughts: 70
Thoughts: **Investigating the "NBD_CMD_RECONFIGURE" Commit**
Okay, so I've noticed that only commit `9517b82d8d42` has "NBD_CMD_RECONFIGURE" explicitly in its message. That seems... odd. Is that truly the only instance? I need to be thorough.
My first thought is to broaden the search. What if the message used "RECONFIGURE" without the underscore? Or perhaps a variation of the term entirely? I have to consider the nuances of human language. Also, this term might be present, not just in commit messages, but within the code itself.
To confirm and expand the search, I should focus on the relevant area, so I will now search for "RECONFIGURE" in the commit messages of the `drivers/block/nbd.c` file. This should give me a more complete picture of the situation. I need to understand the full context here.
|
| 60/4 |
2026/09/23 01:09 |
tool |
git-log |
0m
Args: map[Count:20 MessageRegexps:[reconfigure] PathPrefix:drivers/block/nbd.c]
Results: map[Output:f8d21c590e55 nbd: factor out a nbd_genl_foreach_sock
04d8fb23e520 nbd: disallow NBD_SET_SOCK on an active device
9517b82d8d42 nbd: defer config put in recv_work
844b8cdc6816 nbd: don't allow reconnect after disconnect
7ea201f2cc1d nbd: don't clear discard_sectors in nbd_config_put
6497ef8df568 nbd: provide a way for userspace processes to identify device backends
acb19e17c513 nbd: restore default timeout when setting it to zero
2c272542baee nbd: requeue command if the soecket is changed
4ddeaae8903d nbd: add netlink reconfigure resize support
08ba91ee6e2c nbd: Add the nbd NBD_DISCONNECT_ON_CLOSE config flag.
b7aa3d39385d nbd: add a reconfigure netlink command
]
|
| 61/4 |
2026/09/23 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 22192
output: 26
thoughts: 48
Thoughts: Here's my analysis of the provided information, as if these were my internal thoughts:
**Analyzing a Potential Timeout Bug Fix**
Hold on a second! My attention is immediately drawn to this commit: `acb19e17c513 nbd: restore default timeout when setting it to zero`. That looks promising, potentially a critical fix involving how timeouts are handled within the Network Block Device (NBD) module. I need to dive into `acb19e17c513` immediately. Understanding the nuances of NBD timeout behavior is essential for ensuring robust network storage, and a zero timeout usually screams potential for indefinite hangs or unexpected behavior. I need to confirm whether this commit resolves a specific issue, or improves the defensive programming of the timeout logic in general. I'll need to examine the context of the change, previous discussions, related issues, and potential regressions. Let's dig in and figure out the impact!
|
| 62/4 |
2026/09/23 01:09 |
tool |
git-show |
0m
Args:
Results: map[Output:commit acb19e17c5134dd78668c429ecba5b481f038e6a
Author: Hou Pu <houpu@bytedance.com>
Date: Mon Aug 10 08:00:44 2020 -0400
nbd: restore default timeout when setting it to zero
If we configured io timeout of nbd0 to 100s. Later after we
finished using it, we configured nbd0 again and set the io
timeout to 0. We expect it would timeout after 30 seconds
and keep retry. But in fact we could not change the timeout
when we set it to 0. the timeout is still the original 100s.
So change the timeout to default 30s when we set it to zero.
It also behaves same as commit 2da22da57348 ("nbd: fix zero
cmd timeout handling v2").
It becomes more important if we were reconfigure a nbd device
and the io timeout it set to zero. Because it could take 30s
to detect the new socket and thus io could be completed more
quickly compared to 100s.
Signed-off-by: Hou Pu <houpu@bytedance.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 3ff4054d6834..edf8b632e3d2 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1363,6 +1363,8 @@ static void nbd_set_cmd_timeout(struct nbd_device *nbd, u64 timeout)
nbd->tag_set.timeout = timeout * HZ;
if (timeout)
blk_queue_rq_timeout(nbd->disk->queue, timeout * HZ);
+ else
+ blk_queue_rq_timeout(nbd->disk->queue, 30 * HZ);
}
/* Must be called with config_lock held */
]
|
| 63/4 |
2026/09/23 01:09 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 23051
output: 25
thoughts: 43
Thoughts: Okay, let's dive into this. Here's how I'd approach this task, as if these were my internal thoughts:
**Analyzing Commits in the NBD Driver**
Hmm, hold on a second. Before I get too deep into this particular commit, I should zoom out and look at the broader context within the `nbd` driver. I need to understand the evolution of this section of code. Okay, let's trace back. I want to look at the surrounding changes, not just this one.
Specifically, that `2c272542baee` commit catches my eye: "nbd: requeue command if the socket is changed." This seems like a critical fix β a potentially tricky area. I need to understand *why* the socket is changing and what implications that has for the command processing within the NBD driver. This has potential security, performance, and stability implications. Gotta understand the root cause. This *requeue* logic could be crucial for resilience... is this for hotplugging, or network failures, or something else entirely? Time to dig into this specific change in detail.
|
| 64/4 |
2026/09/23 01:10 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 2c272542baee2c3b9e8e3a260db81227ccefe8b5
Author: Hou Pu <houpu.main@gmail.com>
Date: Fri Feb 28 01:40:30 2020 -0500
nbd: requeue command if the soecket is changed
In commit 2da22da5734 (nbd: fix zero cmd timeout handling v2),
it is allowed to reset timer when it fires if tag_set.timeout
is set to zero. If the server is shutdown and a new socket
is reconfigured, the request should be requeued to be processed by
new server instead of waiting for response from the old one.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Hou Pu <houpu@bytedance.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 83070714888b..43cff01a5a67 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -434,12 +434,22 @@ 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);
+ 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;
]
|
| 65/4 |
2026/09/23 01:10 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 24060
output: 26
thoughts: 689
Thoughts: **Hunting for a Reproducer: A Deep Dive into NBD Driver History**
Okay, where else might I find a reproducer for this issue? It suddenly hit me β what about commit messages? Could there be a commit mentioning a C program or syzkaller program related to the reproducer? Let's narrow our focus, specifically the `drivers/block/nbd.c` file. I'm going to search for commits in that file that reference C code, syzkaller programs, or even netlink messages.
First, I'll identify commits in `drivers/block/nbd.c` that mention syzkaller. I need to see all commits mentioning `syzbot` or `syzkaller` to assess the context.
Here's what I've found:
* 9280e6edf656 nbd: don't warn when reclassifying a busy socket lock
* d532cddb6c60 nbd: Reclassify sockets to avoid lockdep circular dependency
* 9517b82d8d42 nbd: defer config put in recv_work
* 9f7c02e03157 nbd: restrict sockets to TCP and UDP
* 8b428f42f3ed nbd: fix lockdep deadlock warning
* aa9552438ebf nbd: fix uaf in nbd_genl_connect() error path
* 844b8cdc6816 nbd: don't allow reconnect after disconnect
* 78fbb92af27d nbd: always initialize struct msghdr completely
* 55793ea54d77 nbd: fix incomplete validation of ioctl arg
* 1de7c3cf48fc nbd: Fix hung when signal interrupts nbd_start_device_ioctl()
* 7ee656c3ac3d nbd: remove nbd->destroy_complete
* b1a811633f73 block: nbd: add sanity check for first_minor
* 68c9417b193d nbd: do del\_gendisk() asynchronously for NBD\_DESTROY\_ON\_DISCONNECT
* 16ad3db3b24c nbd: fix order of cleaning up the queue and freeing the tagset
* c9a2f90f4d6b nbd: handle device refs for DESTROY\_ON\_DISCONNECT properly
* 579dd91ab3a5 nbd: Fix memory leak in nbd\_add\_socket
* cf1b2326b734 nbd: verify socket is supported during setup
* bc811f05d77f nbd: don't allow invalid blocksize settings
Now, the real work begins. I'll need to examine a subset of these, focusing on those most likely to contain reproducer information. Specifically, I'll scrutinize commits `844b8cdc6816`, `7ee656c3ac3d`, `68c9417b193d`, `16ad3db3b24c`, `c9a2f90f4d6b`, `579dd91ab3a5`, `8b428f42f3ed`, and `9f7c02e03157`.
For the sake of illustration, let's look at `8b428f42f3ed` and `9f7c02e03157` specifically. I need to see what these commits were about!
|
| 66/4 |
2026/09/23 01:10 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 8b428f42f3edfd62422aa7ad87049ab232a2eaa9
Author: Ming Lei <ming.lei@redhat.com>
Date: Wed Jul 9 19:17:44 2025 +0800
nbd: fix lockdep deadlock warning
nbd grabs device lock nbd->config_lock for updating nr_hw_queues, this
ways cause the following lock dependency:
-> #2 (&disk->open_mutex){+.+.}-{4:4}:
lock_acquire kernel/locking/lockdep.c:5871 [inline]
lock_acquire+0x1ac/0x448 kernel/locking/lockdep.c:5828
__mutex_lock_common kernel/locking/mutex.c:602 [inline]
__mutex_lock+0x166/0x1292 kernel/locking/mutex.c:747
mutex_lock_nested+0x14/0x1c kernel/locking/mutex.c:799
__del_gendisk+0x132/0xac6 block/genhd.c:706
del_gendisk+0xf6/0x19a block/genhd.c:819
nbd_dev_remove+0x3c/0xf2 drivers/block/nbd.c:268
nbd_dev_remove_work+0x1c/0x26 drivers/block/nbd.c:284
process_one_work+0x96a/0x1f32 kernel/workqueue.c:3238
process_scheduled_works kernel/workqueue.c:3321 [inline]
worker_thread+0x5ce/0xde8 kernel/workqueue.c:3402
kthread+0x39c/0x7d4 kernel/kthread.c:464
ret_from_fork_kernel+0x2a/0xbb2 arch/riscv/kernel/process.c:214
ret_from_fork_kernel_asm+0x16/0x18 arch/riscv/kernel/entry.S:327
-> #1 (&set->update_nr_hwq_lock){++++}-{4:4}:
lock_acquire kernel/locking/lockdep.c:5871 [inline]
lock_acquire+0x1ac/0x448 kernel/locking/lockdep.c:5828
down_write+0x9c/0x19a kernel/locking/rwsem.c:1577
blk_mq_update_nr_hw_queues+0x3e/0xb86 block/blk-mq.c:5041
nbd_start_device+0x140/0xb2c drivers/block/nbd.c:1476
nbd_genl_connect+0xae0/0x1b24 drivers/block/nbd.c:2201
genl_family_rcv_msg_doit+0x206/0x2e6 net/netlink/genetlink.c:1115
genl_family_rcv_msg net/netlink/genetlink.c:1195 [inline]
genl_rcv_msg+0x514/0x78e net/netlink/genetlink.c:1210
netlink_rcv_skb+0x206/0x3be net/netlink/af_netlink.c:2534
genl_rcv+0x36/0x4c net/netlink/genetlink.c:1219
netlink_unicast_kernel net/netlink/af_netlink.c:1313 [inline]
netlink_unicast+0x4f0/0x82c net/netlink/af_netlink.c:1339
netlink_sendmsg+0x85e/0xdd6 net/netlink/af_netlink.c:1883
sock_sendmsg_nosec net/socket.c:712 [inline]
__sock_sendmsg+0xcc/0x160 net/socket.c:727
____sys_sendmsg+0x63e/0x79c net/socket.c:2566
___sys_sendmsg+0x144/0x1e6 net/socket.c:2620
__sys_sendmsg+0x188/0x246 net/socket.c:2652
__do_sys_sendmsg net/socket.c:2657 [inline]
__se_sys_sendmsg net/socket.c:2655 [inline]
__riscv_sys_sendmsg+0x70/0xa2 net/socket.c:2655
syscall_handler+0x94/0x118 arch/riscv/include/asm/syscall.h:112
do_trap_ecall_u+0x396/0x530 arch/riscv/kernel/traps.c:341
handle_exception+0x146/0x152 arch/riscv/kernel/entry.S:197
-> #0 (&nbd->config_lock){+.+.}-{4:4}:
check_noncircular+0x132/0x146 kernel/locking/lockdep.c:2178
check_prev_add kernel/locking/lockdep.c:3168 [inline]
check_prevs_add kernel/locking/lockdep.c:3287 [inline]
validate_chain kernel/locking/lockdep.c:3911 [inline]
__lock_acquire+0x12b2/0x24ea kernel/locking/lockdep.c:5240
lock_acquire kernel/locking/lockdep.c:5871 [inline]
lock_acquire+0x1ac/0x448 kernel/locking/lockdep.c:5828
__mutex_lock_common kernel/locking/mutex.c:602 [inline]
__mutex_lock+0x166/0x1292 kernel/locking/mutex.c:747
mutex_lock_nested+0x14/0x1c kernel/locking/mutex.c:799
refcount_dec_and_mutex_lock+0x60/0xd8 lib/refcount.c:118
nbd_config_put+0x3a/0x610 drivers/block/nbd.c:1423
nbd_release+0x94/0x15c drivers/block/nbd.c:1735
blkdev_put_whole+0xac/0xee block/bdev.c:721
bdev_release+0x3fe/0x600 block/bdev.c:1144
blkdev_release+0x1a/0x26 block/fops.c:684
__fput+0x382/0xa8c fs/file_table.c:465
____fput+0x1c/0x26 fs/file_table.c:493
task_work_run+0x16a/0x25e kernel/task_work.c:227
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
exit_to_user_mode_loop+0x118/0x134 kernel/entry/common.c:114
exit_to_user_mode_prepare include/linux/entry-common.h:330 [inline]
syscall_exit_to_user_mode_work include/linux/entry-common.h:414 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:449 [inline]
do_trap_ecall_u+0x3f0/0x530 arch/riscv/kernel/traps.c:355
handle_exception+0x146/0x152 arch/riscv/kernel/entry.S:197
Also it isn't necessary to require nbd->config_lock, because
blk_mq_update_nr_hw_queues() does grab tagset lock for sync everything.
Fixes the issue by releasing ->config_lock & retry in case of concurrent
updating nr_hw_queues.
Fixes: 98e68f67020c ("block: prevent adding/deleting disk during updating nr_hw_queues")
Reported-by: syzbot+2bcecf3c38cb3e8fdc8d@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/6855034f.a00a0220.137b3.0031.GAE@google.com
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Cc: Nilay Shroff <nilay@linux.ibm.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
Link: https://lore.kernel.org/r/20250709111744.2353050-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 7bdc7eb808ea..709bad75c47b 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1473,7 +1473,17 @@ static int nbd_start_device(struct nbd_device *nbd)
return -EINVAL;
}
- blk_mq_update_nr_hw_queues(&nbd->tag_set, config->num_connections);
+retry:
+ mutex_unlock(&nbd->config_lock);
+ blk_mq_update_nr_hw_queues(&nbd->tag_set, num_connections);
+ mutex_lock(&nbd->config_lock);
+
+ /* if another code path updated nr_hw_queues, retry until succeed */
+ if (num_connections != config->num_connections) {
+ num_connections = config->num_connections;
+ goto retry;
+ }
+
nbd->pid = task_pid_nr(current);
nbd_parse_flags(nbd);
]
|
| 67/4 |
2026/09/23 01:10 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 28367
output: 24
thoughts: 46
Thoughts: Okay, let's see. My initial thought process is kicking in, I'm analyzing this code and considering its history.
**Examining the Commit History for Context**
Wait a second, let me pause and zoom out. Before diving too deep, it's crucial to understand the broader context. What's the change history? I'm going to scan the other commits, and I'm instantly thinking about how previous commits may relate to what's happening now.
Specifically, I need to check something... what was in commit `1649714b930f`? That particular commit might contain valuable information or potential dependencies that shed light on the current situation. I'll need to review that commit's changes carefully.
Hold on a minute, and *now* I need to see what's going on in `1de7c3cf48fc`. Understanding this older change could be the key to understanding the current implications of changes, and how they relate. This might show a pattern or a cause-and-effect relationship that I need to know. Ok, I'm ready to investigate. Let's see...
|
| 68/4 |
2026/09/23 01:10 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 1de7c3cf48fc41cd95adb12bd1ea9033a917798a
Author: Shigeru Yoshida <syoshida@redhat.com>
Date: Thu Sep 8 01:35:02 2022 +0900
nbd: Fix hung when signal interrupts nbd_start_device_ioctl()
syzbot reported hung task [1]. The following program is a simplified
version of the reproducer:
int main(void)
{
int sv[2], fd;
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) < 0)
return 1;
if ((fd = open("/dev/nbd0", 0)) < 0)
return 1;
if (ioctl(fd, NBD_SET_SIZE_BLOCKS, 0x81) < 0)
return 1;
if (ioctl(fd, NBD_SET_SOCK, sv[0]) < 0)
return 1;
if (ioctl(fd, NBD_DO_IT) < 0)
return 1;
return 0;
}
When signal interrupt nbd_start_device_ioctl() waiting the condition
atomic_read(&config->recv_threads) == 0, the task can hung because it
waits the completion of the inflight IOs.
This patch fixes the issue by clearing queue, not just shutdown, when
signal interrupt nbd_start_device_ioctl().
Link: https://syzkaller.appspot.com/bug?id=7d89a3ffacd2b83fdd39549bc4d8e0a89ef21239 [1]
Reported-by: syzbot+38e6c55d4969a14c1534@syzkaller.appspotmail.com
Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20220907163502.577561-1-syoshida@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 2a709daefbc4..2a2a1d996a57 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1413,10 +1413,12 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd)
mutex_unlock(&nbd->config_lock);
ret = wait_event_interruptible(config->recv_wq,
atomic_read(&config->recv_threads) == 0);
- if (ret)
+ if (ret) {
sock_shutdown(nbd);
- flush_workqueue(nbd->recv_workq);
+ nbd_clear_que(nbd);
+ }
+ flush_workqueue(nbd->recv_workq);
mutex_lock(&nbd->config_lock);
nbd_bdev_reset(nbd);
/* user requested, ignore socket errors */
]
|
| 69/4 |
2026/09/23 01:10 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 29570
output: 25
thoughts: 29
Thoughts: Okay, here's my interpretation of that commit message, presented as my own thought process:
**Fixing a Hanging Task in NBD Configuration Cleanup**
Alright, let's dive into this `e2daec488c57` commit. From the title, it sounds like we've got a potential hang situation related to the Network Block Device (NBD) configuration cleanup process, specifically within the `nbd_config_put` function. My spidey-sense is tingling β any time you see "hungtask," that's a signal to take a deep breath and prepare for some thread-related investigation.
The implication here is that under certain circumstances, the cleanup routine isn't completing as expected. This likely means some resource isn't being released, some lock isn't being dropped, or perhaps a task is stuck in a waiting state that it can't escape from. I immediately start mentally considering potential race conditions, deadlocks, or improper synchronization within the NBD subsystem. `nbd_config_put` likely handles releasing resources that were acquired during configuration setup, such as memory allocated for the config itself, file descriptors, or shared data structures. A hang there could be catastrophic, preventing NBD devices from being properly deconfigured, potentially leading to resource exhaustion or system instability.
I need to understand *why* the task is hanging. Is it a simple locking issue? Perhaps a refcount isn't being managed correctly, leading to a premature or delayed resource release? Maybe there's a blocking I/O operation that's not being handled correctly within the shutdown sequence? To truly grasp the scope of the problem, I need to look at the commit itself to see what the fix is. What's changed in the code around `nbd_config_put`? Did it involve a new mutex, a refcount update, or some other synchronization primitive? What's the context around this function call? Is this a race condition, a deadlock, or some other threading issue? Is this happening because of some external resource being unavailable?
Ultimately, this is a critical fix, and it's imperative that I verify that the root cause has been addressed correctly and that this new code doesn't introduce any regressions or performance penalties. Iβll need to test it, and Iβll be thinking deeply about potential edge cases and concurrent scenarios during my review.
|
| 70/4 |
2026/09/23 01:10 |
tool |
git-show |
0m
Args:
Results: map[Output:commit e2daec488c57069a4a431d5b752f50294c4bf273
Author: Ye Bin <yebin10@huawei.com>
Date: Tue Nov 2 09:52:37 2021 +0800
nbd: Fix hungtask when nbd_config_put
I got follow issue:
[ 247.381177] INFO: task kworker/u10:0:47 blocked for more than 120 seconds.
[ 247.382644] Not tainted 4.19.90-dirty #140
[ 247.383502] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 247.385027] Call Trace:
[ 247.388384] schedule+0xb8/0x3c0
[ 247.388966] schedule_timeout+0x2b4/0x380
[ 247.392815] wait_for_completion+0x367/0x510
[ 247.397713] flush_workqueue+0x32b/0x1340
[ 247.402700] drain_workqueue+0xda/0x3c0
[ 247.403442] destroy_workqueue+0x7b/0x690
[ 247.405014] nbd_config_put.cold+0x2f9/0x5b6
[ 247.405823] recv_work+0x1fd/0x2b0
[ 247.406485] process_one_work+0x70b/0x1610
[ 247.407262] worker_thread+0x5a9/0x1060
[ 247.408699] kthread+0x35e/0x430
[ 247.410918] ret_from_fork+0x1f/0x30
We can reproduce issue as follows:
1. Inject memory fault in nbd_start_device
-1244,10 +1248,18 @@ static int nbd_start_device(struct nbd_device *nbd)
nbd_dev_dbg_init(nbd);
for (i = 0; i < num_connections; i++) {
struct recv_thread_args *args;
-
- args = kzalloc(sizeof(*args), GFP_KERNEL);
+
+ if (i == 1) {
+ args = NULL;
+ printk("%s: inject malloc error\n", __func__);
+ }
+ else
+ args = kzalloc(sizeof(*args), GFP_KERNEL);
2. Inject delay in recv_work
-757,6 +760,8 @@ static void recv_work(struct work_struct *work)
blk_mq_complete_request(blk_mq_rq_from_pdu(cmd));
}
+ printk("%s: comm=%s pid=%d\n", __func__, current->comm, current->pid);
+ mdelay(5 * 1000);
nbd_config_put(nbd);
atomic_dec(&config->recv_threads);
wake_up(&config->recv_wq);
3. Create nbd server
nbd-server 8000 /tmp/disk
4. Create nbd client
nbd-client localhost 8000 /dev/nbd1
Then will trigger above issue.
Reason is when add delay in recv_work, lead to release the last reference
of 'nbd->config_refs'. nbd_config_put will call flush_workqueue to make
all work finish. Obviously, it will lead to deadloop.
To solve this issue, according to Josef's suggestion move 'recv_work'
init from start device to nbd_dev_add, then destroy 'recv_work'when
nbd device teardown.
Signed-off-by: Ye Bin <yebin10@huawei.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20211102015237.2309763-5-yebin10@huawei.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index f201c40d1dc9..60751b185e6d 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -260,7 +260,7 @@ static void nbd_dev_remove(struct nbd_device *nbd)
mutex_lock(&nbd_index_mutex);
idr_remove(&nbd_index_idr, nbd->index);
mutex_unlock(&nbd_index_mutex);
-
+ destroy_workqueue(nbd->recv_workq);
kfree(nbd);
}
@@ -1319,10 +1319,6 @@ static void nbd_config_put(struct nbd_device *nbd)
kfree(nbd->config);
nbd->config = NULL;
- if (nbd->recv_workq)
- destroy_workqueue(nbd->recv_workq);
- nbd->recv_workq = NULL;
-
nbd->tag_set.timeout = 0;
nbd->disk->queue->limits.discard_granularity = 0;
nbd->disk->queue->limits.discard_alignment = 0;
@@ -1351,14 +1347,6 @@ static int nbd_start_device(struct nbd_device *nbd)
return -EINVAL;
}
- nbd->recv_workq = alloc_workqueue("knbd%d-recv",
- WQ_MEM_RECLAIM | WQ_HIGHPRI |
- WQ_UNBOUND, 0, nbd->index);
- if (!nbd->recv_workq) {
- dev_err(disk_to_dev(nbd->disk), "Could not allocate knbd recv work queue.\n");
- return -ENOMEM;
- }
-
blk_mq_update_nr_hw_queues(&nbd->tag_set, config->num_connections);
nbd->pid = task_pid_nr(current);
@@ -1784,6 +1772,15 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
}
nbd->disk = disk;
+ nbd->recv_workq = alloc_workqueue("nbd%d-recv",
+ WQ_MEM_RECLAIM | WQ_HIGHPRI |
+ WQ_UNBOUND, 0, nbd->index);
+ if (!nbd->recv_workq) {
+ dev_err(disk_to_dev(nbd->disk), "Could not allocate knbd recv work queue.\n");
+ err = -ENOMEM;
+ goto out_err_disk;
+ }
+
/*
* Tell the block layer that we are not a rotational device
*/
@@ -1814,7 +1811,7 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
disk->first_minor = index << part_shift;
if (disk->first_minor < index || disk->first_minor > MINORMASK) {
err = -EINVAL;
- goto out_err_disk;
+ goto out_free_work;
}
disk->minors = 1 << part_shift;
@@ -1823,7 +1820,7 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
sprintf(disk->disk_name, "nbd%d", index);
err = add_disk(disk);
if (err)
- goto out_err_disk;
+ goto out_free_work;
/*
* Now publish the device.
@@ -1832,6 +1829,8 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
nbd_total_devices++;
return nbd;
+out_free_work:
+ destroy_workqueue(nbd->recv_workq);
out_err_disk:
blk_cleanup_disk(disk);
out_free_idr:
@@ -2087,13 +2086,10 @@ static void nbd_disconnect_and_put(struct nbd_device *nbd)
nbd_disconnect(nbd);
sock_shutdown(nbd);
/*
- * Make sure recv thread has finished, so it does not drop the last
- * config ref and try to destroy the workqueue from inside the work
- * queue. And this also ensure that we can safely call nbd_clear_que()
+ * Make sure recv thread has finished, we can safely call nbd_clear_que()
* to cancel the inflight I/Os.
*/
- if (nbd->recv_workq)
- flush_workqueue(nbd->recv_workq);
+ flush_workqueue(nbd->recv_workq);
nbd_clear_que(nbd);
nbd->task_setup = NULL;
mutex_unlock(&nbd->config_lock);
]
|
| 71/4 |
2026/09/23 01:10 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 32719
output: 35
thoughts: 221
Thoughts: **Investigating NBD_ATTR_TIMEOUT Usage**
Okay, hold on a second! Before I dive too deep, I need to get a broader perspective. Let me check those commit messages and any syzbot reports related to this specific area β always a good starting point. Wait, letβs widen the net, I want to see *every* commit in the git history that touches on `NBD_ATTR_TIMEOUT`.
Hmm, now why did that `git-log` search time out earlier? Oh, right, because I didn't specify a `PathPrefix`. When you search the whole repository it can take a while! Let's narrow this down. Let's try `MessageRegexps` or `CodeRegexp` with `PathPrefix: "drivers/block"` to be more precise.
Ah! Okay, I did that before, right? Let me see⦠yes, `CodeRegexp: "NBD_ATTR_TIMEOUT"` with `PathPrefix: "drivers/block"` returned these commits:
* 55313e92bd17 nbd: add set cmd timeout helper
* b7aa3d39385d nbd: add a reconfigure netlink command
* e46c7287b1c2 nbd: add a basic netlink interface
But wait! "drivers/block" isn't the *only* place this could be defined. What other include files may have this? Let's check the `include/` directory. That's the next logical step.
|
| 72/4 |
2026/09/23 01:10 |
tool |
git-log |
2m
Args: map[CodeRegexp:NBD_ATTR_TIMEOUT Count:20 PathPrefix:include]
Results: map[Output:e46c7287b1c2 nbd: add a basic netlink interface
]
|
| 73/4 |
2026/09/23 01:12 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 33345
output: 35
thoughts: 15
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Considering the Application of External Tools**
Hold on a second! Before I proceed further, I need to take a step back and consider the potential role of external tools in addressing this. My initial inclination was towards a more direct solution, but now I'm thinking I might be overlooking a more efficient or comprehensive approach. I need to make sure I don't "reinvent the wheel" before looking at a few resources. A thorough search of the available tools is in order. Let me go over the `tools/` directory. There might be some existing scripts, libraries, or configurations relevant to the problem at hand. It's a critical step before diving deeper.
|
| 74/4 |
2026/09/23 01:12 |
tool |
git-log |
0m
Args: map[CodeRegexp:NBD_ATTR_TIMEOUT Count:20 PathPrefix:tools]
Results:
|
| 75/4 |
2026/09/23 01:13 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 33564
output: 35
thoughts: 7
Thoughts: Okay, here's my interpretation of that thought, expressed as a first-person summary and tailored for an expert audience:
**Considering the Documentation Directory**
Alright, let's see, what's on the immediate horizon? My train of thought is circling around the overall project structure. My mind keeps circling around to the Documentation directory. Now, what's in there, exactly? It's where the heart of any project's self-description is, isn't it? That directory holds the blueprints for a smooth user experience.
I'm thinking, "Does the `Documentation/` directory have the right kind of structure? Are there READMEs that need attention? What about auto-generated API docs? Are there examples and tutorials in place that are updated? Is it all comprehensive, and easy to navigate? Are the architecture diagrams up-to-date?"
It's a critical touchpoint. Neglecting the documentation is a cardinal sin. This `Documentation/` directory could hold the key to answering many questions.
|
| 76/4 |
2026/09/23 01:13 |
tool |
git-log |
0m
Args: map[CodeRegexp:NBD_ATTR_TIMEOUT Count:20 PathPrefix:Documentation]
Results:
|
| 77/4 |
2026/09/23 01:13 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 33833
output: 18
thoughts: 114
Thoughts: Okay, let me break this down.
**Analyzing the NBD Reproducer Question**
Alright, hold on. Let me re-read the question: "Does the reproducer set `NBD_ATTR_TIMEOUT` in `NBD_CMD_CONNECT` or `NBD_CMD_RECONFIGURE`?" The phrasing is specific, so I need to make sure I grasp the core of the problem. Am I understanding the setup correctly?
Okay, so where to start? Is there a reproducer? My gut feeling tells me there *has* to be some form of reproducer file or test case lurking in the repository somewhere. I should check the `git` status, maybe even just `git ls-files`, to look for files that might contain "repro," or some other related term. And I'll need to expand my search beyond just the current files. A `.c` extension is often used for reproducer tests. Where does that exist?
Okay, a broader search is needed, even in the root directory. To do that, let me leverage `codesearch-dir-index`. That should give me the power to search for these things pretty efficiently.
|
| 78/4 |
2026/09/23 01:14 |
tool |
codesearch-dir-index |
0m
Args:
Results: map[Files:<nil> Subdirs:[Documentation LICENSES arch block certs crypto drivers fs include init io_uring ipc kernel lib mm net rust samples scripts security sound tools usr virt]]
|
| 79/4 |
2026/09/23 01:14 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 34437
output: 375
thoughts: 761
Thoughts: **NBD_ATTR_TIMEOUT in NBD_CMD_CONNECT and NBD_CMD_RECONFIGURE Analysis**
Okay, let's synthesize a response based solely on the in-house information. I've got my research tools disabled, so I'm relying purely on what I've processed so far. The question concerns the `NBD_ATTR_TIMEOUT` attribute within the `NBD_CMD_CONNECT` and `NBD_CMD_RECONFIGURE` commands in the NBD kernel module.
From looking at the relevant code in `drivers/block/nbd.c`, I can confirm a few key facts. `NBD_ATTR_TIMEOUT` is defined in `include/uapi/linux/nbd-netlink.h` and is correctly validated as `NLA_U64`. The code in both `nbd_genl_connect()` and `nbd_genl_reconfigure()` explicitly checks for the presence of the `NBD_ATTR_TIMEOUT` attribute. If present, the value is extracted using `nla_get_u64()` and passed to `nbd_set_cmd_timeout()`. This clearly indicates that both commands are designed to handle timeout configuration via this attribute.
Now, concerning the reproducer itself, that's where I hit a wall. Without the original context, syzbot output, or specific bug report text, I cannot directly analyze the sequence of events. However, based on my understanding of recent activity and related commits (like `acb19e17c513`, `2c272542baee`, `9517b82d8d42` and `1649714b930f`) , I can infer this: reproducers likely involve sequences where setting the timeout to zero, changing the socket, or the race conditions exposed by such configurations during either `NBD_CMD_CONNECT` or `NBD_CMD_RECONFIGURE`, triggered bugs such as Use-After-Free conditions. I will state this as an inference, not a verified fact. The reproducers themselves, as standalone entities, are not something I have directly access to or can readily analyze here.
Therefore, the `set-results` tool should reflect this, emphasizing the well-understood kernel implementation of the timeout attribute and the unverified, inferential nature of any understanding of the reproducer script itself. It will state that the kernel implementation shows that both commands support this setting, but the issue will describe the races that are often reproduced by it.
|
| 80/4 |
2026/09/23 01:14 |
tool |
set-results |
0m
Args: map[Answer:Based on an analysis of the Linux kernel source code in `drivers/block/nbd.c`:
1. **Kernel Handling in Both Commands:**
Both `NBD_CMD_CONNECT` (`nbd_genl_connect`) and `NBD_CMD_RECONFIGURE` (`nbd_genl_reconfigure`) explicitly support and handle `NBD_ATTR_TIMEOUT`:
```c
if (info->attrs[NBD_ATTR_TIMEOUT])
nbd_set_cmd_timeout(nbd, nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
```
2. **Reproducer Context & Caveats:**
- Standalone reproducer code (e.g., from syzkaller / syzbot bug reports) is not committed directly into the kernel source tree.
- In relevant bug reports and commits involving `NBD_CMD_RECONFIGURE` and timeout bugs (such as commit `acb19e17c513` "nbd: restore default timeout when setting it to zero" and commit `9517b82d8d42` "nbd: defer config put in recv_work" reproducing races between socket clearing and reconfiguring), reproducers testing dynamic timeout changes or socket resets set `NBD_ATTR_TIMEOUT` during `NBD_CMD_RECONFIGURE` (or initially during `NBD_CMD_CONNECT` and subsequent reconfiguration).
- Because the exact external reproducer file was not bundled with the tree, the exact netlink attribute layout of that specific test case cannot be definitively confirmed from the repository alone without the reproducer source itself.]
Results: map[Answer:Based on an analysis of the Linux kernel source code in `drivers/block/nbd.c`:
1. **Kernel Handling in Both Commands:**
Both `NBD_CMD_CONNECT` (`nbd_genl_connect`) and `NBD_CMD_RECONFIGURE` (`nbd_genl_reconfigure`) explicitly support and handle `NBD_ATTR_TIMEOUT`:
```c
if (info->attrs[NBD_ATTR_TIMEOUT])
nbd_set_cmd_timeout(nbd, nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
```
2. **Reproducer Context & Caveats:**
- Standalone reproducer code (e.g., from syzkaller / syzbot bug reports) is not committed directly into the kernel source tree.
- In relevant bug reports and commits involving `NBD_CMD_RECONFIGURE` and timeout bugs (such as commit `acb19e17c513` "nbd: restore default timeout when setting it to zero" and commit `9517b82d8d42` "nbd: defer config put in recv_work" reproducing races between socket clearing and reconfiguring), reproducers testing dynamic timeout changes or socket resets set `NBD_ATTR_TIMEOUT` during `NBD_CMD_RECONFIGURE` (or initially during `NBD_CMD_CONNECT` and subsequent reconfiguration).
- Because the exact external reproducer file was not bundled with the tree, the exact netlink attribute layout of that specific test case cannot be definitively confirmed from the repository alone without the reproducer source itself.]
|
| 81/2 |
2026/09/23 01:14 |
llm |
expert |
0m
Model:
Tokens:
input: 36830
output: 42
thoughts: 486
Thoughts: **Analyzing the NBD Protocol Code Snippets**
Okay, let's break this down. The code sniplets provided are clearly attempting to interact with an NBD (Network Block Device) server, specifically focusing on the `NBD_CMD_CONNECT` and `NBD_CMD_RECONFIGURE` commands. The first snippet, the `CONNECT` command, looks like it's setting up some connection attributes, namely `NBD_ATTR_INDEX` and `NBD_ATTR_SIZE_BYTES`. Interesting.
The second part, the `RECONFIGURE` command, also touches on the `NBD_ATTR_SIZE_BYTES`, along with `NBD_ATTR_DEAD_CONN_TIMEOUT`. Now here's where it gets interesting - I don't see any explicit setting of `NBD_ATTR_TIMEOUT` in either code segment. My immediate assumption, based on that observation, is that a default timeout is being employed. The core question now becomes: *What is the default timeout?* It's clearly a crucial piece of information missing from this.
|
| 82/2 |
2026/09/23 01:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/nbd.c Name:nbd_alloc_and_init_config]
Results: map[SourceCode:1711: static int nbd_alloc_and_init_config(struct nbd_device *nbd)
1712: {
1713: struct nbd_config *config;
1714:
1715: if (WARN_ON(nbd->config))
1716: return -EINVAL;
1717:
1718: if (!try_module_get(THIS_MODULE))
1719: return -ENODEV;
1720:
1721: config = kzalloc_obj(struct nbd_config, GFP_NOFS);
1722: if (!config) {
1723: module_put(THIS_MODULE);
1724: return -ENOMEM;
1725: }
1726:
1727: atomic_set(&config->recv_threads, 0);
1728: init_waitqueue_head(&config->recv_wq);
1729: init_waitqueue_head(&config->conn_wait);
1730: config->blksize_bits = NBD_DEF_BLKSIZE_BITS;
1731: atomic_set(&config->live_connections, 0);
1732:
1733: nbd->config = config;
1734: /*
1735: * Order refcount_set(&nbd->config_refs, 1) and nbd->config assignment,
1736: * its pair is the barrier in nbd_get_config_unlocked().
1737: * So nbd_get_config_unlocked() won't see nbd->config as null after
1738: * refcount_inc_not_zero() succeed.
1739: */
1740: smp_mb__before_atomic();
1741: refcount_set(&nbd->config_refs, 1);
1742:
1743: return 0;
1744: }
SourceFile:drivers/block/nbd.c]
|
| 83/2 |
2026/09/23 01:14 |
llm |
expert |
0m
Model:
Tokens:
input: 38141
output: 38
thoughts: 29
Thoughts: Okay, let's see. My mind's buzzing... I'm pretty sure I saw something about `nbd->tag_set.timeout` recently. Now, where was that?
**Decoding the Timeout Variable**
Aha! Right. I need to trace this back. Let's start with `nbd_dev_add`. That function's got to be where this timeout value is being initialized or modified. It's the logical starting point for understanding how this crucial timer is being configured. Time to dive into the code...
|
| 84/2 |
2026/09/23 01:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/nbd.c Name:nbd_dev_add]
Results: map[SourceCode:1948: static struct nbd_device *nbd_dev_add(int index, unsigned int refs,
1949: int nr_hw_queues)
1950: {
1951: struct queue_limits lim = {
1952: .max_hw_sectors = 65536,
1953: .io_opt = 256 << SECTOR_SHIFT,
1954: .max_segments = USHRT_MAX,
1955: .max_segment_size = UINT_MAX,
1956: };
1957: struct nbd_device *nbd;
1958: struct gendisk *disk;
1959: int err = -ENOMEM;
1960:
1961: nbd = kzalloc_obj(struct nbd_device);
1962: if (!nbd)
1963: goto out;
1964:
1965: nbd->tag_set.ops = &nbd_mq_ops;
1966: nbd->tag_set.nr_hw_queues = nr_hw_queues;
1967: nbd->tag_set.queue_depth = 128;
1968: nbd->tag_set.numa_node = NUMA_NO_NODE;
1969: nbd->tag_set.cmd_size = sizeof(struct nbd_cmd);
1970: nbd->tag_set.flags = BLK_MQ_F_BLOCKING;
1971: nbd->tag_set.driver_data = nbd;
1972: INIT_WORK(&nbd->remove_work, nbd_dev_remove_work);
1973: nbd->backend = NULL;
1974:
1975: err = blk_mq_alloc_tag_set(&nbd->tag_set);
1976: if (err)
1977: goto out_free_nbd;
1978:
1979: mutex_lock(&nbd_index_mutex);
1980: if (index >= 0) {
1981: err = idr_alloc(&nbd_index_idr, nbd, index, index + 1,
1982: GFP_KERNEL);
1983: if (err == -ENOSPC)
1984: err = -EEXIST;
1985: } else {
1986: err = idr_alloc(&nbd_index_idr, nbd, 0,
1987: (MINORMASK >> part_shift) + 1, GFP_KERNEL);
1988: if (err >= 0)
1989: index = err;
1990: }
1991: nbd->index = index;
1992: mutex_unlock(&nbd_index_mutex);
1993: if (err < 0)
1994: goto out_free_tags;
1995:
1996: disk = blk_mq_alloc_disk(&nbd->tag_set, &lim, NULL);
1997: if (IS_ERR(disk)) {
1998: err = PTR_ERR(disk);
1999: goto out_free_idr;
2000: }
2001: nbd->disk = disk;
2002:
2003: nbd->recv_workq = alloc_workqueue("nbd%d-recv",
2004: WQ_MEM_RECLAIM | WQ_HIGHPRI |
2005: WQ_UNBOUND, 0, nbd->index);
2006: if (!nbd->recv_workq) {
2007: dev_err(disk_to_dev(nbd->disk), "Could not allocate knbd recv work queue.\n");
2008: err = -ENOMEM;
2009: goto out_err_disk;
2010: }
2011:
2012: mutex_init(&nbd->config_lock);
2013: refcount_set(&nbd->config_refs, 0);
2014: /*
2015: * Start out with a zero references to keep other threads from using
2016: * this device until it is fully initialized.
2017: */
2018: refcount_set(&nbd->refs, 0);
2019: INIT_LIST_HEAD(&nbd->list);
2020: disk->major = NBD_MAJOR;
2021: disk->first_minor = index << part_shift;
2022: disk->minors = 1 << part_shift;
2023: disk->fops = &nbd_fops;
2024: disk->private_data = nbd;
2025: sprintf(disk->disk_name, "nbd%d", index);
2026: err = add_disk(disk);
2027: if (err)
2028: goto out_free_work;
2029:
2030: /*
2031: * Now publish the device.
2032: */
2033: refcount_set(&nbd->refs, refs);
2034: nbd_total_devices++;
2035: return nbd;
2036:
2037: out_free_work:
2038: destroy_workqueue(nbd->recv_workq);
2039: out_err_disk:
2040: put_disk(disk);
2041: out_free_idr:
2042: mutex_lock(&nbd_index_mutex);
2043: idr_remove(&nbd_index_idr, index);
2044: mutex_unlock(&nbd_index_mutex);
2045: out_free_tags:
2046: blk_mq_free_tag_set(&nbd->tag_set);
2047: out_free_nbd:
2048: kfree(nbd);
2049: out:
2050: return ERR_PTR(err);
2051: }
SourceFile:drivers/block/nbd.c]
|
| 85/2 |
2026/09/23 01:14 |
llm |
expert |
0m
Model:
Tokens:
input: 40026
output: 40
thoughts: 68
Thoughts: Here's a summary of my thought process:
**Diving Deep into NBD Device Initialization**
Okay, hold on a second. I'm reviewing the `nbd_dev_add` function, and something's bugging me. I was under the impression that the `nbd->tag_set.timeout` field was explicitly initialized there, but I don't see that happening. That's a potential oversight we need to address. This means the default timeout from `blk_mq_alloc_tag_set` is being used, right? The default for that is usually `30 * HZ`, which is a somewhat generic timeout that might not be optimal for NBD devices, depending on specific configurations and network conditions.
I'd better double-check the code within `blk_mq_alloc_tag_set` to confirm my suspicion about the default value. We need to understand exactly what value that function is using if `nbd->tag_set.timeout` remains unset. Understanding the implications of this timeout is essential for NBD performance and stability.
|
| 86/2 |
2026/09/23 01:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:block/blk-mq.c Name:blk_mq_alloc_tag_set]
Results: map[SourceCode:4828: /*
4829: * Alloc a tag set to be associated with one or more request queues.
4830: * May fail with EINVAL for various error conditions. May adjust the
4831: * requested depth down, if it's too large. In that case, the set
4832: * value will be stored in set->queue_depth.
4833: */
4834: int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
4835: {
4836: int i, ret;
4837:
4838: BUILD_BUG_ON(BLK_MQ_MAX_DEPTH > 1 << BLK_MQ_UNIQUE_TAG_BITS);
4839:
4840: if (!set->nr_hw_queues)
4841: return -EINVAL;
4842: if (!set->queue_depth)
4843: return -EINVAL;
4844: if (set->queue_depth < set->reserved_tags + BLK_MQ_TAG_MIN)
4845: return -EINVAL;
4846:
4847: if (!set->ops->queue_rq)
4848: return -EINVAL;
4849:
4850: if (!set->ops->get_budget ^ !set->ops->put_budget)
4851: return -EINVAL;
4852:
4853: if (set->queue_depth > BLK_MQ_MAX_DEPTH) {
4854: pr_info("blk-mq: reduced tag depth to %u\n",
4855: BLK_MQ_MAX_DEPTH);
4856: set->queue_depth = BLK_MQ_MAX_DEPTH;
4857: }
4858:
4859: if (!set->nr_maps)
4860: set->nr_maps = 1;
4861: else if (set->nr_maps > HCTX_MAX_TYPES)
4862: return -EINVAL;
4863:
4864: /*
4865: * If a crashdump is active, then we are potentially in a very
4866: * memory constrained environment. Limit us to 64 tags to prevent
4867: * using too much memory.
4868: */
4869: if (is_kdump_kernel())
4870: set->queue_depth = min(64U, set->queue_depth);
4871:
4872: /*
4873: * There is no use for more h/w queues than cpus if we just have
4874: * a single map
4875: */
4876: if (set->nr_maps == 1 && set->nr_hw_queues > nr_cpu_ids)
4877: set->nr_hw_queues = nr_cpu_ids;
4878:
4879: if (set->flags & BLK_MQ_F_BLOCKING) {
4880: set->srcu = kmalloc_obj(*set->srcu);
4881: if (!set->srcu)
4882: return -ENOMEM;
4883: ret = init_srcu_struct(set->srcu);
4884: if (ret)
4885: goto out_free_srcu;
4886: }
4887: ret = init_srcu_struct(&set->tags_srcu);
4888: if (ret)
4889: goto out_cleanup_srcu;
4890:
4891: init_rwsem(&set->update_nr_hwq_lock);
4892:
4893: ret = -ENOMEM;
4894: set->tags = kcalloc_node(set->nr_hw_queues,
4895: sizeof(struct blk_mq_tags *), GFP_KERNEL,
4896: set->numa_node);
4897: if (!set->tags)
4898: goto out_cleanup_tags_srcu;
4899:
4900: for (i = 0; i < set->nr_maps; i++) {
4901: set->map[i].mq_map = kcalloc_node(nr_cpu_ids,
4902: sizeof(set->map[i].mq_map[0]),
4903: GFP_KERNEL, set->numa_node);
4904: if (!set->map[i].mq_map)
4905: goto out_free_mq_map;
4906: set->map[i].nr_queues = set->nr_hw_queues;
4907: }
4908:
4909: blk_mq_update_queue_map(set);
4910:
4911: ret = blk_mq_alloc_set_map_and_rqs(set);
4912: if (ret)
4913: goto out_free_mq_map;
4914:
4915: mutex_init(&set->tag_list_lock);
4916: INIT_LIST_HEAD(&set->tag_list);
4917:
4918: return 0;
4919:
4920: out_free_mq_map:
4921: for (i = 0; i < set->nr_maps; i++) {
4922: kfree(set->map[i].mq_map);
4923: set->map[i].mq_map = NULL;
4924: }
4925: kfree(set->tags);
4926: set->tags = NULL;
4927: out_cleanup_tags_srcu:
4928: cleanup_srcu_struct(&set->tags_srcu);
4929: out_cleanup_srcu:
4930: if (set->flags & BLK_MQ_F_BLOCKING)
4931: cleanup_srcu_struct(set->srcu);
4932: out_free_srcu:
4933: if (set->flags & BLK_MQ_F_BLOCKING)
4934: kfree(set->srcu);
4935: return ret;
4936: }
SourceFile:block/blk-mq.c]
|
| 87/2 |
2026/09/23 01:14 |
llm |
expert |
0m
Model:
Tokens:
input: 42115
output: 40
thoughts: 70
Thoughts: Here's my thought process, as requested:
**Debugging Timeout Initialization in Block MQ**
Okay, so I'm digging into this `blk_mq_alloc_tag_set` function, and something's bugging me. Specifically, I was expecting it to handle the `timeout` value. But after a quick scan, it doesn't seem to be setting it at all. That's not where it's happening.
Alright, where else could this be? Let's trace it back. Thinking about the usual suspects... Ah, of course, the `blk_mq_alloc_disk` function. That seems like a logical place to initialize disk-specific parameters.
Let me take a look at the code for that... Ah, there it is! Yup, `q->rq_timeout = 30 * HZ;` β that's the initialization I was looking for. Now it makes sense.
|
| 88/2 |
2026/09/23 01:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:block/blk-mq.c Name:blk_mq_init_allocated_queue]
Results: map[SourceCode:4621: int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
4622: struct request_queue *q)
4623: {
4624: /* mark the queue as mq asap */
4625: q->mq_ops = set->ops;
4626:
4627: /*
4628: * ->tag_set has to be setup before initialize hctx, which cpuphp
4629: * handler needs it for checking queue mapping
4630: */
4631: q->tag_set = set;
4632:
4633: if (blk_mq_alloc_ctxs(q))
4634: goto err_exit;
4635:
4636: /* init q->mq_kobj and sw queues' kobjects */
4637: blk_mq_sysfs_init(q);
4638:
4639: INIT_LIST_HEAD(&q->unused_hctx_list);
4640: spin_lock_init(&q->unused_hctx_lock);
4641:
4642: blk_mq_realloc_hw_ctxs(set, q);
4643: if (!q->nr_hw_queues)
4644: goto err_hctxs;
4645:
4646: INIT_WORK(&q->timeout_work, blk_mq_timeout_work);
4647: blk_queue_rq_timeout(q, set->timeout ? set->timeout : 30 * HZ);
4648:
4649: q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT;
4650:
4651: INIT_DELAYED_WORK(&q->requeue_work, blk_mq_requeue_work);
4652: INIT_LIST_HEAD(&q->flush_list);
4653: INIT_LIST_HEAD(&q->requeue_list);
4654: spin_lock_init(&q->requeue_lock);
4655:
4656: q->nr_requests = set->queue_depth;
4657: q->async_depth = set->queue_depth;
4658:
4659: blk_mq_init_cpu_queues(q, set->nr_hw_queues);
4660: blk_mq_map_swqueue(q);
4661: blk_mq_add_queue_tag_set(set, q);
4662: return 0;
4663:
4664: err_hctxs:
4665: blk_mq_release(q);
4666: err_exit:
4667: q->mq_ops = NULL;
4668: return -ENOMEM;
4669: }
SourceFile:block/blk-mq.c]
|
| 89/2 |
2026/09/23 01:14 |
llm |
expert |
0m
Model:
Tokens:
input: 43218
output: 38
thoughts: 67
Thoughts: Okay, here's my assessment of the situation:
**Investigating a Discrepancy in Timeout Behavior**
Right, so the reported timeout period is supposed to be 30 seconds. That's what's configured, and that's what I'd expect. However, I'm seeing behavior that seems to contradict this. Specifically, I'm looking at a hung task timeout of 143 seconds. Thatβs a significant difference, and it has me wondering β if the *actual* timeout is supposed to be a mere 30 seconds, why am I not seeing the request abort, as I would expect? There's a clear disconnect here. This means I need to dig deeper. I need to understand why the system isn't respecting the configured 30-second timeout. My next move is clear, I need to investigate the mechanisms responsible for handling the timeout. I should start by examining either `nbd_timeout_work` or `nbd_mq_ops.timeout`, these are the likely places to find the discrepancy. This is going to be an interesting one to unravel.
|
| 90/2 |
2026/09/23 01:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/nbd.c Name:nbd_mq_ops]
Results: map[SourceCode:1941: static const struct blk_mq_ops nbd_mq_ops = {
1942: .queue_rq = nbd_queue_rq,
1943: .complete = nbd_complete_rq,
1944: .init_request = nbd_init_request,
1945: .timeout = nbd_xmit_timeout,
1946: };
SourceFile:drivers/block/nbd.c]
|
| 91/2 |
2026/09/23 01:14 |
llm |
expert |
0m
Model:
Tokens:
input: 43698
output: 39
thoughts: 14
Thoughts: Okay, let's dive into this. Here's how I'd approach summarizing the prompt, keeping in mind my own expert understanding:
**Analyzing `nbd_xmit_timeout`**
Alright, so the prompt directs me to consider `nbd_xmit_timeout`. Immediately, my mind starts to churn through related concepts. I'm thinking, "Okay, this is about the Network Block Device (NBD) and specifically, the timeout associated with transmission. This implicates connection reliability, potential buffering issues, and the overall responsiveness of the block device. It's not *just* a single variable; itβs a tuning knob that influences a much broader system interaction." I would then immediately consider the interplay of this setting with other timeout parameters within the NBD subsystem. Are there related timeouts, perhaps on the server-side, that might interact or conflict with this one? I need to analyze the potential implications, depending on whether we're talking about the client-side or server-side NBD setup and consider the architecture as a whole. And, of course, I have to factor in the potential for this parameter to be a major source of either performance bottlenecks or unexpected disconnects, which will require deeper investigations. I'll need to remember the context of any configuration I'm working with. That parameter likely governs the time an NBD client will wait for an acknowledgement from the NBD server. If that acknowledgement isnβt received, the client would then time out. What happens next? How does the system handle a timeout? Does it retry? Does it fail immediately? Does it potentially corrupt data? All of these are relevant questions.
|
| 92/2 |
2026/09/23 01:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/nbd.c Name:nbd_xmit_timeout]
Results: map[SourceCode: 460: static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req)
461: {
462: struct nbd_cmd *cmd = blk_mq_rq_to_pdu(req);
463: struct nbd_device *nbd = cmd->nbd;
464: struct nbd_config *config;
465:
466: if (!mutex_trylock(&cmd->lock))
467: return BLK_EH_RESET_TIMER;
468:
469: /* partial send is handled in nbd_sock's work function */
470: if (test_bit(NBD_CMD_PARTIAL_SEND, &cmd->flags)) {
471: mutex_unlock(&cmd->lock);
472: return BLK_EH_RESET_TIMER;
473: }
474:
475: if (!test_bit(NBD_CMD_INFLIGHT, &cmd->flags)) {
476: mutex_unlock(&cmd->lock);
477: return BLK_EH_DONE;
478: }
479:
480: config = nbd_get_config_unlocked(nbd);
481: if (!config) {
482: cmd->status = BLK_STS_TIMEOUT;
483: __clear_bit(NBD_CMD_INFLIGHT, &cmd->flags);
484: mutex_unlock(&cmd->lock);
485: goto done;
486: }
487:
488: if (config->num_connections > 1 ||
489: (config->num_connections == 1 && nbd->tag_set.timeout)) {
490: dev_err_ratelimited(nbd_to_dev(nbd),
491: "Connection timed out, retrying (%d/%d alive)\n",
492: atomic_read(&config->live_connections),
493: config->num_connections);
494: /*
495: * Hooray we have more connections, requeue this IO, the submit
496: * path will put it on a real connection. Or if only one
497: * connection is configured, the submit path will wait util
498: * a new connection is reconfigured or util dead timeout.
499: */
500: if (config->socks) {
501: if (cmd->index < config->num_connections) {
502: struct nbd_sock *nsock =
503: config->socks[cmd->index];
504: mutex_lock(&nsock->tx_lock);
505: /* We can have multiple outstanding requests, so
506: * we don't want to mark the nsock dead if we've
507: * already reconnected with a new socket, so
508: * only mark it dead if its the same socket we
509: * were sent out on.
510: */
511: if (cmd->cookie == nsock->cookie)
512: nbd_mark_nsock_dead(nbd, nsock, 1);
513: mutex_unlock(&nsock->tx_lock);
514: }
515: nbd_requeue_cmd(cmd);
516: mutex_unlock(&cmd->lock);
517: nbd_config_put(nbd);
518: return BLK_EH_DONE;
519: }
520: }
521:
522: if (!nbd->tag_set.timeout) {
523: /*
524: * Userspace sets timeout=0 to disable socket disconnection,
525: * so just warn and reset the timer.
526: */
527: struct nbd_sock *nsock = config->socks[cmd->index];
528: cmd->retries++;
529: dev_info(nbd_to_dev(nbd), "Possible stuck request %p: control (%s@%llu,%uB). Runtime %u seconds\n",
530: req, nbdcmd_to_ascii(req_to_nbd_cmd_type(req)),
531: (unsigned long long)blk_rq_pos(req) << 9,
532: blk_rq_bytes(req), (req->timeout / HZ) * cmd->retries);
533:
534: mutex_lock(&nsock->tx_lock);
535: if (cmd->cookie != nsock->cookie) {
536: nbd_requeue_cmd(cmd);
537: mutex_unlock(&nsock->tx_lock);
538: mutex_unlock(&cmd->lock);
539: nbd_config_put(nbd);
540: return BLK_EH_DONE;
541: }
542: mutex_unlock(&nsock->tx_lock);
543: mutex_unlock(&cmd->lock);
544: nbd_config_put(nbd);
545: return BLK_EH_RESET_TIMER;
546: }
547:
548: dev_err_ratelimited(nbd_to_dev(nbd), "Connection timed out\n");
549: set_bit(NBD_RT_TIMEDOUT, &config->runtime_flags);
550: cmd->status = BLK_STS_IOERR;
551: __clear_bit(NBD_CMD_INFLIGHT, &cmd->flags);
552: mutex_unlock(&cmd->lock);
553: sock_shutdown(nbd);
554: nbd_config_put(nbd);
555: done:
556: blk_mq_complete_request(req);
557: return BLK_EH_DONE;
558: }
SourceFile:drivers/block/nbd.c]
|
| 93/2 |
2026/09/23 01:14 |
llm |
expert |
0m
Model:
Tokens:
input: 45775
output: 39
thoughts: 828
Thoughts: **Analyzing a Potential NBD Deadlock**
Okay, here's what's going through my head as I dissect this NBD issue. It starts with a simple conditional check: `if (!nbd->tag_set.timeout)`. That immediately grabs my attention. I know the default timeout value isn't explicitly set during device initialization. Hmm, *because* `nbd_dev_add` doesn't set `nbd->tag_set.timeout`, and `NBD_CMD_CONNECT` skips setting the timeout attribute because it was not provided in the command, `nbd_set_cmd_timeout` is never called! So, effectively, `nbd->tag_set.timeout` defaults to zero, right?
If it *is* zero, then `nbd_xmit_timeout` returns `BLK_EH_RESET_TIMER`. And that means the request *never* actually times out! It just keeps resetting the timer, essentially waiting indefinitely. That rings alarm bells, because I know the block layer timeout for the request is set in `blk_mq_alloc_disk` as `q->rq_timeout = set->timeout ? set->timeout : 30 * HZ;`. So we are dealing with a 30 second timeout on *that* level. The block layer calls `nbd_xmit_timeout` when this timeout happens. So every 30 seconds we reset the timer... which takes us back to the start! The request is *stuck*!
But wait, if `NBD_CMD_RECONFIGURE` is invoked, it freezes the queue. This is interesting. When the queue is freezing, the `bio_queue_enter` call blocks. Therefore, `udevd` is then blocked in `bio_queue_enter`. And `syz.0.17` is blocked in `blk_mq_freeze_queue_wait`. And the request is stuck forever because there is no server to reply, and timeout is 0. Ah, this is a classic deadlock or a hung task scenario!
Let's quickly confirm that `nbd->tag_set.timeout` is indeed zero. I need to be absolutely sure. Okay, `nbd_dev_add` uses `kzalloc_obj(struct nbd_device)`, which zero-initializes the structure. It sets some fields in `nbd->tag_set` but *not* `timeout`. So, yes, `timeout` is still zero. `NBD_CMD_CONNECT` then checks `info->attrs[NBD_ATTR_TIMEOUT]`. If it is not present, `nbd_set_cmd_timeout` isn't called. So the timeout *remains* at zero. `nbd_start_device` is called. `udevd` then submits a bio, and this goes onto the socket. Then `NBD_CMD_RECONFIGURE` is called, which calls `nbd_genl_size_set`, `nbd_set_size`, which in turn leads to `queue_limits_commit_update_frozen`. And that freezes the queue.
Since there's a bio in flight, `q_usage_counter` is greater than 0. `blk_mq_freeze_queue_wait` now waits for `q_usage_counter` to reach 0. But the bio is stuck forever because the timeout is 0, so `nbd_xmit_timeout` keeps returning `BLK_EH_RESET_TIMER`. Meanwhile, `udevd` is blocked in `bio_queue_enter` because it's trying to submit the next bio from the folio. The queue is frozen and it waits forever.
Alright, is this a potential privilege escalation? No. It is just a deadlock / hung task. Can an unprivileged user trigger this? Now, let's see which capabilities are required for `NBD_CMD_CONNECT` and `NBD_CMD_RECONFIGURE`...
|
| 94/2 |
2026/09/23 01:15 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/nbd.c Name:nbd_genl_connect]
Results: map[SourceCode:2167: static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
2168: {
2169: struct nbd_device *nbd;
2170: struct nbd_config *config;
2171: int index = -1;
2172: int ret;
2173: bool put_dev = false;
2174:
2175: if (!netlink_capable(skb, CAP_SYS_ADMIN))
2176: return -EPERM;
2177:
2178: if (info->attrs[NBD_ATTR_INDEX]) {
2179: index = nla_get_u32(info->attrs[NBD_ATTR_INDEX]);
2180:
2181: /*
2182: * Too big first_minor can cause duplicate creation of
2183: * sysfs files/links, since index << part_shift might overflow, or
2184: * MKDEV() expect that the max bits of first_minor is 20.
2185: */
2186: if (index < 0 || index > MINORMASK >> part_shift) {
2187: pr_err("illegal input index %d\n", index);
2188: return -EINVAL;
2189: }
2190: }
2191: if (GENL_REQ_ATTR_CHECK(info, NBD_ATTR_SOCKETS)) {
2192: pr_err("must specify at least one socket\n");
2193: return -EINVAL;
2194: }
2195: if (GENL_REQ_ATTR_CHECK(info, NBD_ATTR_SIZE_BYTES)) {
2196: pr_err("must specify a size in bytes for the device\n");
2197: return -EINVAL;
2198: }
2199: again:
2200: mutex_lock(&nbd_index_mutex);
2201: if (index == -1) {
2202: nbd = nbd_find_get_unused();
2203: } else {
2204: nbd = idr_find(&nbd_index_idr, index);
2205: if (nbd) {
2206: if ((test_bit(NBD_DESTROY_ON_DISCONNECT, &nbd->flags) &&
2207: test_bit(NBD_DISCONNECT_REQUESTED, &nbd->flags)) ||
2208: !refcount_inc_not_zero(&nbd->refs)) {
2209: mutex_unlock(&nbd_index_mutex);
2210: pr_err("device at index %d is going down\n",
2211: index);
2212: return -EINVAL;
2213: }
2214: }
2215: }
2216: mutex_unlock(&nbd_index_mutex);
2217:
2218: if (!nbd) {
2219: ret = nbd_genl_foreach_sock(info, NULL, NULL);
2220: if (ret < 0)
2221: return ret;
2222:
2223: nbd = nbd_dev_add(index, 2, ret > 0 ? ret : 1);
2224: if (IS_ERR(nbd)) {
2225: pr_err("failed to add new device\n");
2226: return PTR_ERR(nbd);
2227: }
2228: }
2229:
2230: mutex_lock(&nbd->config_lock);
2231: if (refcount_read(&nbd->config_refs)) {
2232: mutex_unlock(&nbd->config_lock);
2233: nbd_put(nbd);
2234: if (index == -1)
2235: goto again;
2236: pr_err("nbd%d already in use\n", index);
2237: return -EBUSY;
2238: }
2239:
2240: ret = nbd_alloc_and_init_config(nbd);
2241: if (ret) {
2242: mutex_unlock(&nbd->config_lock);
2243: nbd_put(nbd);
2244: pr_err("couldn't allocate config\n");
2245: return ret;
2246: }
2247:
2248: config = nbd->config;
2249: set_bit(NBD_RT_BOUND, &config->runtime_flags);
2250: ret = nbd_genl_size_set(info, nbd);
2251: if (ret)
2252: goto out;
2253:
2254: if (info->attrs[NBD_ATTR_TIMEOUT])
2255: nbd_set_cmd_timeout(nbd,
2256: nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
2257: if (info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]) {
2258: config->dead_conn_timeout =
2259: nla_get_u64(info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]);
2260: config->dead_conn_timeout *= HZ;
2261: }
2262: if (info->attrs[NBD_ATTR_SERVER_FLAGS])
2263: config->flags =
2264: nla_get_u64(info->attrs[NBD_ATTR_SERVER_FLAGS]);
2265: if (info->attrs[NBD_ATTR_CLIENT_FLAGS]) {
2266: u64 flags = nla_get_u64(info->attrs[NBD_ATTR_CLIENT_FLAGS]);
2267: if (flags & NBD_CFLAG_DESTROY_ON_DISCONNECT) {
2268: /*
2269: * We have 1 ref to keep the device around, and then 1
2270: * ref for our current operation here, which will be
2271: * inherited by the config. If we already have
2272: * DESTROY_ON_DISCONNECT set then we know we don't have
2273: * that extra ref already held so we don't need the
2274: * put_dev.
2275: */
2276: if (!test_and_set_bit(NBD_DESTROY_ON_DISCONNECT,
2277: &nbd->flags))
2278: put_dev = true;
2279: } else {
2280: if (test_and_clear_bit(NBD_DESTROY_ON_DISCONNECT,
2281: &nbd->flags))
2282: refcount_inc(&nbd->refs);
2283: }
2284: if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) {
2285: set_bit(NBD_RT_DISCONNECT_ON_CLOSE,
2286: &config->runtime_flags);
2287: }
2288: }
2289:
2290: ret = nbd_genl_foreach_sock(info, nbd_genl_connect_sock_cb, nbd);
2291: if (ret < 0)
2292: goto out;
2293:
2294: if (info->attrs[NBD_ATTR_BACKEND_IDENTIFIER]) {
2295: nbd->backend = nla_strdup(info->attrs[NBD_ATTR_BACKEND_IDENTIFIER],
2296: GFP_KERNEL);
2297: if (!nbd->backend) {
2298: ret = -ENOMEM;
2299: goto out;
2300: }
2301: }
2302: ret = device_create_file(disk_to_dev(nbd->disk), &backend_attr);
2303: if (ret) {
2304: dev_err(disk_to_dev(nbd->disk),
2305: "device_create_file failed for backend!\n");
2306: goto out;
2307: }
2308: set_bit(NBD_RT_HAS_BACKEND_FILE, &config->runtime_flags);
2309:
2310: ret = nbd_start_device(nbd);
2311: out:
2312: if (!ret) {
2313: set_bit(NBD_RT_HAS_CONFIG_REF, &config->runtime_flags);
2314: refcount_inc(&nbd->config_refs);
2315: nbd_connect_reply(info, nbd->index);
2316: }
2317: mutex_unlock(&nbd->config_lock);
2318:
2319: nbd_config_put(nbd);
2320: if (put_dev)
2321: nbd_put(nbd);
2322: return ret;
2323: }
SourceFile:drivers/block/nbd.c]
|
| 95/2 |
2026/09/23 01:15 |
llm |
expert |
0m
Model:
Tokens:
input: 50061
output: 36
thoughts: 94
Thoughts: Here's my understanding of this snippet:
**Analyzing `NBD_CMD_CONNECT`'s Security Check**
Okay, so I'm looking at this bit of code, specifically the `NBD_CMD_CONNECT` command. The first thing I see is this check: `if (!netlink_capable(skb, CAP_SYS_ADMIN)) return -EPERM;`. That immediately tells me that a connection attempt requires the `CAP_SYS_ADMIN` capability. My initial thought is, this permission check is happening because it's required for the init user namespace. But, I need to verify that thought, so I need to check how `netlink_capable` works and the relevant user namespaces. Perhaps it checks against the `init_user_ns` or maybe the net namespace's user namespace. Either way, I'll need to dig into `netlink_capable` to confirm exactly *where* that capability check is being performed, and if my initial hypothesis about `CAP_SYS_ADMIN` and the init namespace is correct.
|
| 96/2 |
2026/09/23 01:15 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/nbd.c Name:netlink_capable]
Results: map[SourceCode: 874: /**
875: * netlink_capable - Netlink global message capability test
876: * @skb: socket buffer holding a netlink command from userspace
877: * @cap: The capability to use
878: *
879: * Test to see if the opener of the socket we received the message
880: * from had when the netlink socket was created and the sender of the
881: * message has the capability @cap in all user namespaces.
882: */
883: bool netlink_capable(const struct sk_buff *skb, int cap)
884: {
885: return netlink_ns_capable(skb, &init_user_ns, cap);
886: }
SourceFile:net/netlink/af_netlink.c]
|
| 97/2 |
2026/09/23 01:15 |
llm |
expert |
0m
Model:
Tokens:
input: 50659
output: 36
thoughts: 1307
Thoughts: **My Analysis of the NBD Device Deadlock Bug**
Okay, let's break this down. First, the initial assessment was correct: `netlink_capable` confirms that the vulnerability's root cause, `init_user_ns`, requires `CAP_SYS_ADMIN` within the init user namespace. This means unprivileged processes and user namespaces are *not* vulnerable. This is NOT a security bug.
The reproducer, however, is run by syzkaller which means it *does* have root privileges in its own VM, and therefore `CAP_SYS_ADMIN`. So, we can't dismiss the bug entirely, because syzkaller can trigger it.
Here's the essence of the problem as I understand it:
1. We have `NBD_CMD_CONNECT` setting up the NBD device and its socket, but crucially, it omits setting `NBD_ATTR_TIMEOUT`.
2. Consequently, `nbd->tag_set.timeout` defaults to zero.
3. The device size is then set by `NBD_CMD_CONNECT`, which in turn triggers a uevent.
4. `udevd` gets the uevent, opens the device, and begins partition table scanning.
5. `udevd` then submits a read request (bio) to the NBD device.
6. The request goes to the socket, but no server is responding.
7. The block layer times out (after 30 seconds), but, because the timeout is 0, `nbd_xmit_timeout` returns `BLK_EH_RESET_TIMER`, thus leaving the request stalled forever.
8. `syz.0.17` then sends `NBD_CMD_RECONFIGURE` to adjust the device size.
9. This invokes `nbd_set_size`, which in turn leads to `queue_limits_commit_update_frozen`.
10. `queue_limits_commit_update_frozen` freezes the queue because it is waiting for `q_usage_counter` to reach 0.
11. The read request is permanently blocked, which, in turn, keeps `q_usage_counter` from dropping to 0.
12. `syz.0.17` then gets stuck forever in `blk_mq_freeze_queue_wait`.
13. Meanwhile, `udevd` is trying to continue the bio on the folio, but the queue is now frozen, which leaves it stuck forever in `bio_queue_enter`.
This results in a Denial of Service (DoS) - a hung task, which requires the root user (or a user with `CAP_SYS_ADMIN`) to trigger it. It's a kernel bug, not a security vulnerability in the sense that it doesn't allow privilege escalation or code execution.
The critical question is, how else can this be triggered? Could a malicious NBD server be used? If a user (root, remember) connects to a malicious, unresponsive NBD server without a timeout configured, the reads will hang. The root user setting up the device *must* have `CAP_SYS_ADMIN`. So, it amounts to root misconfiguration.
If root configures the device without a timeout, and the server hangs, this is expected. It's the expected *consequence* of not configuring a timeout when root is setting up the device, but the real issue is that `udevd` hangs, which possibly prevents the processing of other devices.
Now, let's examine the dimensions:
* Exploitable: No. It is a deadlock / hung task.
* Denial of Service: Yes, causing a hung task, and requires `CAP_SYS_ADMIN`.
* Unprivileged: No.
* User Namespaces: No.
* VM Guest: No.
* VM Host (Confidential Computing): No.
* Ethernet Network: No.
* Other Remote: No.
* Peripheral: No.
* Malicious Filesystem: No.
Could a malicious NBD server (Ethernet Network Trigger) be used? If root connects to a rogue server that deliberately stops responding, the read attempts would hang. Reconfiguration attempts by root would also hang. But this arises from the *user* not setting a timeout when they established the connection.
"Ethernet Network Trigger" implies the attacker can trigger the bug *without* the victim having to do anything, or, at a minimum, just receiving packets. Here, root must proactively initiate the connection and configure the device without setting a timeout. I don't believe this qualifies as a network trigger.
Again, let's recheck if a user namespace can trigger `NBD_CMD_CONNECT`. `netlink_capable
|
| 98/2 |
2026/09/23 01:15 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/nbd.c Name:nbd_ioctl]
Results: map[SourceCode:1681: static int nbd_ioctl(struct block_device *bdev, blk_mode_t mode,
1682: unsigned int cmd, unsigned long arg)
1683: {
1684: struct nbd_device *nbd = bdev->bd_disk->private_data;
1685: struct nbd_config *config = nbd->config;
1686: int error = -EINVAL;
1687:
1688: if (!capable(CAP_SYS_ADMIN))
1689: return -EPERM;
1690:
1691: /* The block layer will pass back some non-nbd ioctls in case we have
1692: * special handling for them, but we don't so just return an error.
1693: */
1694: if (_IOC_TYPE(cmd) != 0xab)
1695: return -EINVAL;
1696:
1697: mutex_lock(&nbd->config_lock);
1698:
1699: /* Don't allow ioctl operations on a nbd device that was created with
1700: * netlink, unless it's DISCONNECT or CLEAR_SOCK, which are fine.
1701: */
1702: if (!test_bit(NBD_RT_BOUND, &config->runtime_flags) ||
1703: (cmd == NBD_DISCONNECT || cmd == NBD_CLEAR_SOCK))
1704: error = __nbd_ioctl(bdev, nbd, cmd, arg);
1705: else
1706: dev_err(nbd_to_dev(nbd), "Cannot use ioctl interface on a netlink controlled device.\n");
1707: mutex_unlock(&nbd->config_lock);
1708: return error;
1709: }
SourceFile:drivers/block/nbd.c]
|
| 99/2 |
2026/09/23 01:15 |
llm |
expert |
0m
Model:
Tokens:
input: 53557
output: 66
thoughts: 1410
Thoughts: **Analysis of the NBD Driver Hung Task Bug**
Okay, so here's what I've got after digging into this NBD issue. It looks like `nbd_ioctl` requires `CAP_SYS_ADMIN`, which means any path to configure or reconfigure NBD demands that level of privilege within the initial namespace. That's the baseline.
My initial thought was to look for alternative paths to freeze the queue. I see that `queue_limits_commit_update_frozen` gets called from `nbd_set_size`. I wondered, are there other callers of `queue_limits_commit_update_frozen`? Yes, there are, but they all require some sort of privileged operation, such as changing sysfs attributes, which are root-owned, or privileged ioctls.
Ah, I think I've got it. The core issue is that `udevd` is getting blocked because the block queue is frozen. The queue is frozen because there's a request that's stuck. And that request is stuck because the `timeout` is 0, and there's no NBD server present. Since all this requires `CAP_SYS_ADMIN` in the init namespace, this isn't a security problem; it's simply a root-triggered DoS.
So, let's step through the questions. Is this exploitable? No. Denial of Service? Yes, but it needs root. Therefore, while it's a DoS, it isn't a security issue. I'll mark it as True for DoS, but False for unprivileged access. No user namespace, VMGuestTrigger, VMHostTrigger, NetworkTrigger, RemoteTrigger, PeripheralTrigger, or FilesystemTrigger either.
Let's double-check how an unprivileged user can trigger this. Can they open `/dev/nbd0`? Usually, it's root:disk with 0660 permissions, so no. Can they send netlink messages to `GENL_ID_CTRL` to get the family ID of `nbd`? Yes, but can they send `NBD_CMD_CONNECT`? No, `netlink_capable(skb, CAP_SYS_ADMIN)` rejects it. An unprivileged user is blocked.
What about user namespaces? `netlink_capable` checks `init_user_ns`, so even if you spawn a new user namespace and get `CAP_SYS_ADMIN` there, `netlink_capable` will block it.
Is there any other way to trigger `nbd_xmit_timeout` returning `BLK_EH_RESET_TIMER`? If `nbd->tag_set.timeout` is 0, it returns `BLK_EH_RESET_TIMER`. Can an unprivileged user cause a request to be sent to an NBD device? If root has already configured the device and it is accessible to an unprivileged user, yes. But, if the NBD server stops responding, that's a root configuration consequence, not an unprivileged user bug trigger.
Therefore, the whole thing hinges on root's actions. No triggers are valid, and unprivileged and UserNamespace are False. Exploitable is False. Denial of Service is True; it's a hung task.
Let me clearly lay out the reasoning:
1. The syzkaller reproducer (root) uses an `NBD_CMD_CONNECT` netlink message to configure an NBD device. It provides a socket but no timeout (`NBD_ATTR_TIMEOUT`), setting the device's timeout to 0.
2. The device size configuration triggers a uevent.
3. `udevd` receives the uevent, opens the device, and attempts to read the partition table, submitting a read bio to the NBD device.
4. The NBD driver queues the request to the socket. But, as there is no real NBD server, the request gets no answer.
5. Because the device timeout is 0, the block layer's timeout handler (`nbd_xmit_timeout`) persistently returns `BLK_EH_RESET_TIMER`, keeping the request in-flight indefinitely.
6. The syzkaller reproducer then sends an `NBD_CMD_RECONFIGURE` netlink message to adjust the device size.
7. This calls `queue_limits_commit_update_frozen()`, freezing the block queue, and waiting for all in-flight requests to complete.
8. Since the `udevd` read request is stuck, the queue freeze blocks forever, hanging the syzkaller task.
9. `udevd` tries to submit the next partition table read bio, but it blocks in `bio_queue_enter()` because the queue is freezing.
10. Both tasks hang, triggering the hung
|
| 100/2 |
2026/09/23 01:15 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 101/2 |
2026/09/23 01:15 |
llm |
expert |
0m
Model:
Tokens:
input: 56122
output: 603
thoughts: 13
Thoughts: Okay, here's the summary, rendered as a first-person thought process, keeping in mind the user is an expert:
**Finalizing the Output**
Alright, the processing is complete. The data has been analyzed, the relationships identified, and the implications considered. Now, it's time to craft the final response. No further manipulation of the parameters is required, and the logical conclusions have been drawn. There's no need for further refinement. The architecture of the output has been determined. I'm satisfied with the structure, the level of detail, and the clarity I've achieved. Let's get this finalized. It's time to generate the answer.
|
| 102/1 |
2026/09/23 01:15 |
action |
format-explanation |
0m
Results: map[Explanation:The bug is a deadlock/hung task involving the NBD (Network Block Device) driver.
Here is the sequence of events that leads to the hung tasks:
1. The syzkaller reproducer (running with root privileges) sends an
`NBD_CMD_CONNECT` netlink message to configure an NBD device. It provides a
socket but does not specify a timeout (`NBD_ATTR_TIMEOUT`). As a result, the
device's timeout is left at its default value of 0 (no timeout).
2. The configuration sets the device size, which triggers a kernel uevent.
3. `udevd` receives the uevent, opens the block device, and attempts to read the
partition table. It submits a read bio to the NBD device.
4. The NBD driver queues the request to the provided socket. However, since
there is no actual NBD server listening on the other end of the socket pair, the
request receives no reply.
5. Because the device timeout is 0, the block layer's timeout handler
(`nbd_xmit_timeout`) continuously returns `BLK_EH_RESET_TIMER`, causing the
request to remain in-flight indefinitely.
6. The syzkaller reproducer then sends an `NBD_CMD_RECONFIGURE` netlink message
to change the device size.
7. This calls `queue_limits_commit_update_frozen()`, which attempts to freeze
the block queue and waits for all in-flight requests to complete (i.e., waits
for `q_usage_counter` to drop to 0).
8. Since the read request from `udevd` is stuck forever, the queue freeze
operation blocks indefinitely, causing the syzkaller task to hang in
`blk_mq_freeze_queue_wait`.
9. Meanwhile, `udevd` attempts to submit the next bio for the partition table
read, but blocks in `bio_queue_enter()` because the queue is now in a freezing
state.
10. Both tasks hang for more than 143 seconds, triggering the kernel's hung task
watchdog.
**Security Impact:**
- The netlink commands `NBD_CMD_CONNECT` and `NBD_CMD_RECONFIGURE` both strictly
require `CAP_SYS_ADMIN` in the initial user namespace (enforced by
`netlink_capable(skb, CAP_SYS_ADMIN)`).
- Therefore, this bug cannot be triggered by unprivileged users or from within
unprivileged user namespaces.
- It is not exploitable for privilege escalation, memory corruption, or
information leaks.
- While it represents a Denial of Service (hung task), it requires root
privileges to trigger. Thus, it is not considered a security vulnerability, but
rather a bug that root can trigger by misconfiguring an NBD device (providing a
socket with no server and no timeout).]
|