CVE-2025-38154: bpf, sockmap: Avoid using sk_socket after free when sending

Published Jul 3, 2025
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

bpf, sockmap: Avoid using sksocket after free when sending

The sk->sksocket is not locked or referenced in backlog thread, and during the call to skbsendsock(), there is a race condition with the release of sksocket. All types of sockets(tcp/udp/unix/vsock) will be affected.

Race conditions: ''' CPU0 CPU1

backlog::skbsendsock sendmsgunlocked socksendmsg socksendmsgnosec close(fd): ... ops->release() -> sockmapclose() sksocket->ops = NULL free(socket) sock->ops->sendmsg ^ panic here '''

The ref of psock become 0 after sockmapclose() executed. ''' void sockmapclose() { ... if (likely(psock)) { ... // !! here we remove psock and the ref of psock become 0 sockmapremovelinks(sk, psock) psock = skpsockget(sk); if (unlikely(!psock)) goto nopsock; <=== Control jumps here via goto ... canceldelayedworksync(&psock->work); <=== not executed skpsockput(sk, psock); ... } '''

Based on the fact that we already wait for the workqueue to finish in sockmapclose() if psock is held, we simply increase the psock reference count to avoid race conditions.

With this patch, if the backlog thread is running, sockmapclose() will wait for the backlog thread to complete and cancel all pending work.

If no backlog running, any pending work that hasn't started by then will fail when invoked by skpsockget(), as the psock reference count have been zeroed, and skpsockdrop() will cancel all jobs via canceldelayedworksync().

In summary, we require synchronization to coordinate the backlog thread and close() thread.

The panic I catched: ''' Workqueue: events skpsockbacklog RIP: 0010:socksendmsg+0x21d/0x440 RAX: 0000000000000000 RBX: ffffc9000521fad8 RCX: 0000000000000001 ... Call Trace: <TASK> ? dieaddr+0x40/0xa0 ? excgeneralprotection+0x14c/0x230 ? asmexcgeneralprotection+0x26/0x30 ? socksendmsg+0x21d/0x440 ? socksendmsg+0x3e0/0x440 ? pfxsocksendmsg+0x10/0x10 skbsendsock+0x543/0xb70 skpsockbacklog+0x247/0xb80 ... '''

Affected Software

16 affected componentsFixes available
Linux Kernel
Linux Linux kernel>=5.15.162<5.15.186
Linux Linux kernel>=6.1.95<6.1.142
Linux Linux kernel>=6.6.35<6.6.94
Linux Linux kernel>=6.9.6<6.10
Linux Linux kernel>=6.10.1<6.12.34
Linux Linux kernel>=6.13<6.15.3
Linux Linux kernel=6.10
Linux Linux kernel=6.10-rc2
Linux Linux kernel=6.10-rc3
Linux Linux kernel=6.10-rc4
Linux Linux kernel=6.10-rc5
Linux Linux kernel=6.10-rc6
Linux Linux kernel=6.10-rc7
Debian Debian Linux=11.0
debian/linux
6.1.176-16.1.190-16.12.107-16.12.113-17.2.12-17.2.13-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade debian/linux to a version that resolves this vulnerability.

    Fixed in 6.1.176-1Fixed in 6.1.190-1Fixed in 6.12.107-1Fixed in 6.12.113-1Fixed in 7.2.12-1Fixed in 7.2.13-1
  2. Compensating control

    In the Linux kernel BPF sockmap close path, coordinate sock_map_close() with the backlog thread: when a psock is held, increment its reference count, wait for the backlog thread to complete, and cancel all pending work with cancel_delayed_work_sync(&psock->work) before releasing the socket.

Event History

Jul 3, 2025
CVE Published
via MITRE·08:35 AM
Data Sourced
via MITRE·08:35 AM
DescriptionSeverity
Data Sourced
via Red Hat·09:02 AM
DescriptionSeverityAffected Software
Data Sourced
via NVD·09:15 AM
RemedyDescriptionSeverityWeaknessAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Peer vulnerabilities

Found alongside the following vulnerabilities.

Frequently Asked Questions

1

What is the severity of CVE-2025-38154?

The severity of CVE-2025-38154 is classified as high due to its potential to cause a race condition leading to denial of service.

2

How do I fix CVE-2025-38154?

To fix CVE-2025-38154, update your Linux kernel to the latest patched version provided by your distribution.

3

Which versions of the Linux kernel are affected by CVE-2025-38154?

CVE-2025-38154 affects multiple versions of the Linux kernel, particularly those before the fix was implemented in the stable releases.

4

Can CVE-2025-38154 lead to system compromise?

CVE-2025-38154 primarily can lead to denial of service rather than direct system compromise.

5

Is there a workaround for CVE-2025-38154 pending a patch?

Currently, there is no effective workaround for CVE-2025-38154; the best practice is to apply the security patch as soon as it becomes available.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203