CVE-2025-23143
JSON

5.5medium

net: Fix null-ptr-deref by sock_lock_init_class_and_name() and rmmod.

Severity
5.5medium CVSS:3.1 by NVD
Exploit likelihood
0.27% (higher than 20% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
Linux

Description

In the Linux kernel, the following vulnerability has been resolved: net: Fix null-ptr-deref by sock_lock_init_class_and_name() and rmmod. When I ran the repro [0] and waited a few seconds, I observed two LOCKDEP splats: a warning immediately followed by a null-ptr-deref. [1] Reproduction Steps: 1) Mount CIFS 2) Add an iptables rule to drop incoming FIN packets for CIFS 3) Unmount CIFS 4) Unload the CIFS module 5) Remove the iptables rule At step 3), the CIFS module calls sock_release() for the underlying TCP socket, and it returns quickly. However, the socket remains in FIN_WAIT_1 because incoming FIN packets are dropped. At this point, the module's refcnt is 0 while the socket is still alive, so the following rmmod command succeeds. # ss -tan State Recv-Q Send-Q Local Address:Port Peer Address:Port FIN-WAIT-1 0 477 10.0.2.15:51062 10.0.0.137:445 # lsmod | grep cifs cifs 1159168 0 This highlights a discrepancy between the lifetime of the CIFS module and the underlying TCP socket. Even after CIFS calls sock_release() and it returns, the TCP socket does not die immediately in order to close the connection gracefully. While this is generally fine, it causes an issue with LOCKDEP because CIFS assigns a different lock class to the TCP socket's sk->sk_lock using sock_lock_init_class_and_name(). Once an incoming packet is processed for the socket or a timer fires, sk->sk_lock is acquired. Then, LOCKDEP checks the lock context in check_wait_context(), where hlock_class() is called to retrieve the lock class. However, since the module has already been unloaded, hlock_class() logs a warning and returns NULL, triggering the null-ptr-deref. If LOCKDEP is enabled, we must ensure that a module calling sock_lock_init_class_and_name() (CIFS, NFS, etc) cannot be unloaded while such a socket is still alive to prevent this issue. Let's hold the module reference in sock_lock_init_class_and_name() and release it when the socket is freed in sk_prot_free(). Note that sock_lock_init() clears sk->sk_owner for svc_create_socket() that calls sock_lock_init_class_and_name() for a listening socket, which clones a socket by sk_clone_lock() without GFP_ZERO. [0]: CIFS_SERVER="10.0.0.137" CIFS_PATH="//${CIFS_SERVER}/Users/Administrator/Desktop/CIFS_TEST" DEV="enp0s3" CRED="/root/WindowsCredential.txt" MNT=$(mktemp -d /tmp/XXXXXX) mount -t cifs ${CIFS_PATH} ${MNT} -o vers=3.0,credentials=${CRED},cache=none,echo_interval=1 iptables -A INPUT -s ${CIFS_SERVER} -j DROP for i in $(seq 10); do umount ${MNT} rmmod cifs sleep 1 done rm -r ${MNT} iptables -D INPUT -s ${CIFS_SERVER} -j DROP [1]: DEBUG_LOCKS_WARN_ON(1) WARNING: CPU: 10 PID: 0 at kernel/locking/lockdep.c:234 hlock_class (kernel/locking/lockdep.c:234 kernel/locking/lockdep.c:223) Modules linked in: cifs_arc4 nls_ucs2_utils cifs_md4 [last unloaded: cifs] CPU: 10 UID: 0 PID: 0 Comm: swapper/10 Not tainted 6.14.0 #36 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:hlock_class (kernel/locking/lockdep.c:234 kernel/locking/lockdep.c:223) ... Call Trace: <IRQ> __lock_acquire (kernel/locking/lockdep.c:4853 kernel/locking/lockdep.c:5178) lock_acquire (kernel/locking/lockdep.c:469 kernel/locking/lockdep.c:5853 kernel/locking/lockdep.c:5816) _raw_spin_lock_nested (kernel/locking/spinlock.c:379) tcp_v4_rcv (./include/linux/skbuff.h:1678 ./include/net/tcp.h:2547 net/ipv4/tcp_ipv4.c:2350) ... BUG: kernel NULL pointer dereference, address: 00000000000000c4 PF: supervisor read access in kernel mode PF: error_code(0x0000) - not-present page PGD 0 Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI CPU: 10 UID: 0 PID: 0 Comm: swapper/10 Tainted: G W 6.14.0 #36 Tainted: [W]=WARN Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:__lock_acquire (kernel/ ---truncated---

Affected

Product or packageVersionsReported by
Linux Linuxfrom ed07536ed6731775219c1df7fa26a7588753e693 before 83083c5fc7cf9b0f136a42f26aba60da380f3601, from ed07536ed6731775219c1df7fa26a7588753e693 before b7489b753667bc9245958a4896c9419743083c27, from ed07536ed6731775219c1df7fa26a7588753e693 before d51e47e2ab6ef10a317d576075cf625cdbf96426, from ed07536ed6731775219c1df7fa26a7588753e693 before feda73ad44a5cc80f6bf796bb1099a3fe71576d4, from ed07536ed6731775219c1df7fa26a7588753e693 before 905d43b8ad2436c240f844acb3ebcc7a99b8ebf1, from ed07536ed6731775219c1df7fa26a7588753e693 before 5f7f6abd92b6c8dc8f19625ef93c3a18549ede04, from ed07536ed6731775219c1df7fa26a7588753e693 before c11247a21aab4b50a23c8b696727d7483de2f1e1, from ed07536ed6731775219c1df7fa26a7588753e693 before 2155802d3313d7b8365935c6b8d6edc0ddd7eb94 and 2 more
Not affected: before 2.6.20, from 5.4.300 up to 5.4.*, from 5.10.245 up to 5.10.*, from 5.15.194 up to 5.15.*, from 6.1.153 up to 6.1.*, from 6.6.107 up to 6.6.*
CVE List
linux linux_kernelfrom 2.6.20 before 5.4.300, from 5.5 before 5.10.245, from 5.11 before 5.15.194, from 5.16 before 6.1.153, from 6.2 before 6.6.107, from 6.7 before 6.12.24, from 6.13 before 6.13.12, from 6.14 before 6.14.3 and 1 moreNVD
debian debian_linux11.0NVD

Classification

CWE-476

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

In the Linux kernel, the following vulnerability has been resolved: net: Fix null-ptr-deref by sock_lock_init_class_and_name() and rmmod. When I ran the repro [0] and waited a few seconds, I observed two LOCKDEP splats: a warning immediately followed by a null-ptr-deref. [1] Reproduction Steps: 1) Mount CIFS 2) Add an iptables rule to drop incoming FIN packets for CIFS 3) Unmount CIFS 4) Unload the CIFS module 5) Remove the iptables rule At step 3), the CIFS module calls sock_release() for the underlying TCP socket, and it returns quickly. However, the socket remains in FIN_WAIT_1 because incoming FIN packets are dropped. At this point, the module's refcnt is 0 while the socket is still alive, so the following rmmod command succeeds. # ss -tan State Recv-Q Send-Q Local Address:Port Peer Address:Port FIN-WAIT-1 0 477 10.0.2.15:51062 10.0.0.137:445 # lsmod | grep cifs cifs 1159168 0 This highlights a discrepancy between the lifetime of the CIFS module and the underlying TCP socket. Even after CIFS calls sock_release() and it returns, the TCP socket does not die immediately in order to close the connection gracefully. While this is generally fine, it causes an issue with LOCKDEP because CIFS assigns a different lock class to the TCP socket's sk->sk_lock using sock_lock_init_class_and_name(). Once an incoming packet is processed for the socket or a timer fires, sk->sk_lock is acquired. Then, LOCKDEP checks the lock context in check_wait_context(), where hlock_class() is called to retrieve the lock class. However, since the module has already been unloaded, hlock_class() logs a warning and returns NULL, triggering the null-ptr-deref. If LOCKDEP is enabled, we must ensure that a module calling sock_lock_init_class_and_name() (CIFS, NFS, etc) cannot be unloaded while such a socket is still alive to prevent this issue. Let's hold the module reference in sock_lock_init_class_and_name() and release it when the socket is freed in sk_prot_free(). Note that sock_lock_init() clears sk->sk_owner for svc_create_socket() that calls sock_lock_init_class_and_name() for a listening socket, which clones a socket by sk_clone_lock() without GFP_ZERO. [0]: CIFS_SERVER="10.0.0.137" CIFS_PATH="//${CIFS_SERVER}/Users/Administrator/Desktop/CIFS_TEST" DEV="enp0s3" CRED="/root/WindowsCredential.txt" MNT=$(mktemp -d /tmp/XXXXXX) mount -t cifs ${CIFS_PATH} ${MNT} -o vers=3.0,credentials=${CRED},cache=none,echo_interval=1 iptables -A INPUT -s ${CIFS_SERVER} -j DROP for i in $(seq 10); do umount ${MNT} rmmod cifs sleep 1 done rm -r ${MNT} iptables -D INPUT -s ${CIFS_SERVER} -j DROP [1]: DEBUG_LOCKS_WARN_ON(1) WARNING: CPU: 10 PID: 0 at kernel/locking/lockdep.c:234 hlock_class (kernel/locking/lockdep.c:234 kernel/locking/lockdep.c:223) Modules linked in: cifs_arc4 nls_ucs2_utils cifs_md4 [last unloaded: cifs] CPU: 10 UID: 0 PID: 0 Comm: swapper/10 Not tainted 6.14.0 #36 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:hlock_class (kernel/locking/lockdep.c:234 kernel/locking/lockdep.c:223) ... Call Trace: <IRQ> __lock_acquire (kernel/locking/lockdep.c:4853 kernel/locking/lockdep.c:5178) lock_acquire (kernel/locking/lockdep.c:469 kernel/locking/lockdep.c:5853 kernel/locking/lockdep.c:5816) _raw_spin_lock_nested (kernel/locking/spinlock.c:379) tcp_v4_rcv (./include/linux/skbuff.h:1678 ./include/net/tcp.h:2547 net/ipv4/tcp_ipv4.c:2350) ... BUG: kernel NULL pointer dereference, address: 00000000000000c4 PF: supervisor read access in kernel mode PF: error_code(0x0000) - not-present page PGD 0 Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI CPU: 10 UID: 0 PID: 0 Comm: swapper/10 Tainted: G W 6.14.0 #36 Tainted: [W]=WARN Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:__lock_acquire (kernel/ ---truncated---

NVD (es)

En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: net: Fix null-ptr-deref por sock_lock_init_class_and_name() y rmmod. Cuando ejecuté la reproducción [0] y esperé unos segundos, observé dos símbolos LOCKDEP: una advertencia seguida inmediatamente por un null-ptr-deref. [1] Pasos de reproducción: 1) Montar CIFS 2) Agregar una regla de iptables para descartar los paquetes FIN entrantes para CIFS 3) Desmontar CIFS 4) Descargar el módulo CIFS 5) Eliminar la regla de iptables En el paso 3), el módulo CIFS llama a sock_release() para el socket TCP subyacente y regresa rápidamente. Sin embargo, el socket permanece en FIN_WAIT_1 porque los paquetes FIN entrantes se descartan. En este punto, el refcnt del módulo es 0 mientras el socket sigue activo, por lo que el siguiente comando rmmod tiene éxito. # ss -tan State Recv-Q Send-Q Local Address:Port Peer Address:Port FIN-WAIT-1 0 477 10.0.2.15:51062 10.0.0.137:445 # lsmod | grep cifs cifs 1159168 0 Esto indica una discrepancia entre la duración del módulo CIFS y el socket TCP subyacente. Incluso después de que CIFS invoque sock_release() y este regrese, el socket TCP no se cierra inmediatamente para cerrar la conexión correctamente. Si bien esto generalmente funciona bien, causa un problema con LOCKDEP, ya que CIFS asigna una clase de bloqueo diferente al sk-&gt;sk_lock del socket TCP mediante sock_lock_init_class_and_name(). Una vez que se procesa un paquete entrante para el socket o se activa un temporizador, se adquiere sk-&gt;sk_lock. Luego, LOCKDEP verifica el contexto de bloqueo en check_wait_context(), donde se llama a hlock_class() para recuperar la clase de bloqueo. Sin embargo, dado que el módulo ya se ha descargado, hlock_class() registra una advertencia y devuelve NULL, lo que activa la desreferencia null-ptr. Si LOCKDEP está habilitado, debemos asegurarnos de que un módulo que llama a sock_lock_init_class_and_name() (CIFS, NFS, etc.) no pueda descargarse mientras dicho socket siga activo para evitar este problema. Mantendremos la referencia del módulo en sock_lock_init_class_and_name() y la liberaremos cuando el socket se libere en sk_prot_free(). Tenga en cuenta que sock_lock_init() borra sk-&gt;sk_owner para svc_create_socket(), que llama a sock_lock_init_class_and_name() para un socket que escucha, lo que clona un socket mediante sk_clone_lock() sin GFP_ZERO. [0]: CIFS_SERVER="10.0.0.137" CIFS_PATH="//${CIFS_SERVER}/Usuarios/Administrador/Escritorio/CIFS_TEST" DEV="enp0s3" CRED="/root/WindowsCredential.txt" MNT=$(mktemp -d /tmp/XXXXXX) mount -t cifs ${CIFS_PATH} ${MNT} -o vers=3.0,credenciales=${CRED},caché=ninguno,intervalo_de_eco=1 iptables -A INPUT -s ${CIFS_SERVER} -j DROP para i en $(seq 10); Desmontar ${MNT} rmmod cifs sleep 1 hecho rm -r ${MNT} iptables -D INPUT -s ${CIFS_SERVER} -j DROP [1]: DEBUG_LOCKS_WARN_ON(1) ADVERTENCIA: CPU: 10 PID: 0 en kernel/locking/lockdep.c:234 hlock_class (kernel/locking/lockdep.c:234 kernel/locking/lockdep.c:223) Módulos enlazados en: cifs_arc4 nls_ucs2_utils cifs_md4 [última descarga: cifs] CPU: 10 UID: 0 PID: 0 Comm: swapper/10 No contaminado 6.14.0 #36 Nombre del hardware: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 01/04/2014 RIP: 0010:hlock_class (kernel/locking/lockdep.c:234 kernel/locking/lockdep.c:223) ... Rastreo de llamadas: __lock_acquire (kernel/locking/lockdep.c:4853 kernel/locking/lockdep.c:5178) lock_acquire (kernel/locking/lockdep.c:469 kernel/locking/lockdep.c:5853 kernel/locking/lockdep.c:5816) _raw_spin_lock_nested (kernel/locking/spinlock.c:379) tcp_v4_rcv (./include/linux/skbuff.h:1678 ./include/net/tcp.h:2547 net/ipv4/tcp_ipv4.c:2350) ... ERROR: desreferencia de puntero NULL del núcleo, dirección: 00000000000000c4 PF: acceso de lectura del supervisor en modo núcleo PF: error_code(0x0000) - página no presente PGD 0 Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI CPU: 10 UID: 0 PID: 0 Comm: swapper/10 Contaminado: GW 6.14.0 #36 Contaminado: [W]=WARN Nombre del hardware: QEMU Standard PC (i440FX + PIIX, ---truncado---

References

https://git.kernel.org/stable/c/83083c5fc7cf9b0f136a42f26aba60da380f3601patch
https://git.kernel.org/stable/c/b7489b753667bc9245958a4896c9419743083c27patch
https://git.kernel.org/stable/c/d51e47e2ab6ef10a317d576075cf625cdbf96426patch
https://git.kernel.org/stable/c/feda73ad44a5cc80f6bf796bb1099a3fe71576d4patch
https://git.kernel.org/stable/c/905d43b8ad2436c240f844acb3ebcc7a99b8ebf1patch
https://git.kernel.org/stable/c/5f7f6abd92b6c8dc8f19625ef93c3a18549ede04patch
https://git.kernel.org/stable/c/c11247a21aab4b50a23c8b696727d7483de2f1e1patch
https://git.kernel.org/stable/c/2155802d3313d7b8365935c6b8d6edc0ddd7eb94patch
https://git.kernel.org/stable/c/0bb2f7a1ad1f11d861f58e5ee5051c8974ff9569patch
https://lists.debian.org/debian-lts-announce/2025/10/msg00008.htmlmailing-list, third-party-advisory
https://cert-portal.siemens.com/productcert/html/ssa-032379.html
https://cert-portal.siemens.com/productcert/html/ssa-019113.html

Sources

SourceRecordLicence
CVE ListCVE-2025-23143 changed 2026-11-10CVE Terms of Use
NVDCVE-2025-23143 changed 2026-11-10Public domain