Root Cause Analysis
The lockdep report shows a circular dependency across three lock classes:
fs_reclaim -> sk_lock-AF_INET6 -> k-sk_lock-AF_INET6 -> fs_reclaim
This cycle arises from two issues that together cause lockdep class aliasing across unrelated AF_INET6 sockets:
-
Silent failure to reclassify NBD sockets (drivers/block/nbd.c):
-
MPTCP nesting (net/mptcp/sockopt.c) and RDS-TCP GFP_KERNEL allocation under lock_sock() (net/rds/tcp_recv.c):
- In
mptcp_setsockopt_first_sf_only() (net/mptcp/sockopt.c:797-804), MPTCP holds the userspace MPTCP socket lock (sk_lock-AF_INET6) and calls tcp_setsockopt(ssk, ...) -> do_tcp_setsockopt() (net/ipv4/tcp.c:3977), acquiring the subflow kernel socket lock (k-sk_lock-AF_INET6, assigned to all AF_INET6 sockets created via sock_create_kern() in net/core/sock.c:2220-2226). This establishes sk_lock-AF_INET6 -> k-sk_lock-AF_INET6.
- In
rds_tcp_recv_path() (net/rds/tcp_recv.c:304-306), called during rds_tcp_conn_path_shutdown() (net/rds/tcp_connect.c:269), RDS holds lock_sock(sock->sk) (k-sk_lock-AF_INET6, since RDS-TCP sockets are created with sock_create_kern(PF_INET6, ...) in rds_tcp_conn_path_connect() without a custom lockdep class) and calls rds_tcp_read_sock(cp, GFP_KERNEL).
rds_tcp_read_sock() invokes tcp_read_sock() -> rds_tcp_data_recv() (net/rds/tcp_recv.c:174, 219, 246), which performs GFP_KERNEL allocations (kmem_cache_alloc(rds_tcp_incoming_slab, arg->gfp), pskb_extract(), and rds_recv_incoming()), acquiring fs_reclaim while holding k-sk_lock-AF_INET6 (despite net/rds/tcp.c:573-576 noting that GFP_KERNEL allocations under lock_sock() trigger fs_reclaim and create a circular lock dependency with the socket lock).
Why the Cycle Is Triggered
nbd_reclassify_socket() fails to enforce reclassification (or reject a contended socket with -EBUSY), leaving an NBD AF_INET6 socket in sk_lock-AF_INET6 and linking fs_reclaim -> sk_lock-AF_INET6.
mptcp_setsockopt_first_sf_only() links sk_lock-AF_INET6 -> k-sk_lock-AF_INET6.
rds_tcp_recv_path() links k-sk_lock-AF_INET6 -> fs_reclaim by allocating with GFP_KERNEL while holding lock_sock(sock->sk).
Note that at the object level, NBD only accepts IPPROTO_TCP / AF_UNIX userspace sockets (sk_is_tcp() in nbd_get_socket()), MPTCP sockets use IPPROTO_MPTCP, and RDS-TCP sockets are internal kernel sockets not exposed to NBD or fs_reclaim, so the three subsystems operate on disjoint struct sock instances. Fixing either nbd_reclassify_socket() (rejecting sockets where !sock_allow_reclassification(sk) or retrying/locking safely before reclassification) and/or rds_tcp_recv_path() (using GFP_NOIO/memalloc_noio_save() or a dedicated RDS lockdep class) breaks the false-positive cycle.