Skip to content

Conversation

@roxanan1996
Copy link
Contributor

DESCRIPTION

Commit

vsock: Fix transport_* TOCTOU

is the CVE fix and it was cherry picked cleanly.

vsock: fix lock inversion in vsock_assign_transport()

This is a cve-bf dependency.

NOTES

  1. First commit
vsock: reset socket state when de-assigning the transport

was added to make the last patch diff the same. otherwise it would
have been 2 separate hunks, even though the changes were the same.
Moreover, this fixes

c0cfa2d8a788 ("vsock: add multi-transports support")

The same commit that the CVE fix addresses. So it's also a bug fix.
It was added as cve-pre because in mainline is before

vsock: Fix transport_* TOCTOU
  1. Last commit
vsock: fix lock inversion in vsock_assign_transport()

was not a clean cherry pick because of missing SEQPACKET
support. I went down that road of adding it but it turned out
to be a lot of code refactor.
Moreover, even though the kernel version is not the same,
it follows the same approach as stable v5.10
https://lore.kernel.org/stable/[email protected]/

COMMITS

vsock: reset socket state when de-assigning the transport

jira VULN-80680
cve-pre CVE-2025-38461
commit-author Stefano Garzarella <[email protected]>
commit a24009bc9be60242651a21702609381b5092459e
vsock: Fix transport_* TOCTOU

jira VULN-80680
cve CVE-2025-38461
commit-author Michal Luczaj <[email protected]>
commit 687aa0c5581b8d4aa87fd92973e4ee576b550cdf
vsock: fix lock inversion in vsock_assign_transport()

jira VULN-80680
cve-bf CVE-2025-38461
commit-author Michal Luczaj <[email protected]>
commit f7c877e7535260cc7a21484c994e8ce7e8cb6780

TESTING

BUILD

> grep -E -B 5 -A 5 '\[TIMER\]|^Starting Build' /home/rnicolescu/ciq/kernels/lts-8.6/kernel-build-after.log
/home/rnicolescu/ciq/kernels/lts-8.6_CVE-2025-38461/kernel-src-tree
Running make mrproper...
[TIMER]{MRPROPER}: 4s
x86_64 architecture detected, copying config
'configs/kernel-x86_64.config' -> '.config'
Setting Local Version for build
CONFIG_LOCALVERSION="-rnicolescu_ciqlts8_6_CVE-2025-38461-76cac62feeef"
Making olddefconfig
--
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf  --olddefconfig Kconfig
#
# configuration written to .config
#
Starting Build
scripts/kconfig/conf  --syncconfig Kconfig
  SYSTBL  arch/x86/include/generated/asm/syscalls_32.h
  SYSHDR  arch/x86/include/generated/asm/unistd_32_ia32.h
  SYSTBL  arch/x86/include/generated/asm/syscalls_64.h
  HYPERCALLS arch/x86/include/generated/asm/xen-hypercalls.h
--
  LD [M]  sound/usb/usx2y/snd-usb-usx2y.ko
  LD [M]  sound/virtio/virtio_snd.ko
  LD [M]  sound/x86/snd-hdmi-lpe-audio.ko
  LD [M]  sound/xen/snd_xen_front.ko
  LD [M]  virt/lib/irqbypass.ko
[TIMER]{BUILD}: 1420s
Making Modules
  INSTALL arch/x86/crypto/blowfish-x86_64.ko
  INSTALL arch/x86/crypto/camellia-aesni-avx-x86_64.ko
  INSTALL arch/x86/crypto/camellia-aesni-avx2.ko
  INSTALL arch/x86/crypto/camellia-x86_64.ko
--
  INSTALL sound/virtio/virtio_snd.ko
  INSTALL sound/x86/snd-hdmi-lpe-audio.ko
  INSTALL sound/xen/snd_xen_front.ko
  INSTALL virt/lib/irqbypass.ko
  DEPMOD  4.18.0-rnicolescu_ciqlts8_6_CVE-2025-38461-76cac62feeef+
[TIMER]{MODULES}: 10s
Making Install
sh ./arch/x86/boot/install.sh 4.18.0-rnicolescu_ciqlts8_6_CVE-2025-38461-76cac62feeef+ arch/x86/boot/bzImage \
	System.map "/boot"
[TIMER]{INSTALL}: 15s
Checking kABI
kABI check passed
Setting Default Kernel to /boot/vmlinuz-4.18.0-rnicolescu_ciqlts8_6_CVE-2025-38461-76cac62feeef+ and Index to 2
The default is /boot/loader/entries/5b498e8d58534bd5b017cfd4107dedaf-4.18.0-rnicolescu_ciqlts8_6_CVE-2025-38461-76cac62feeef+.conf with index 2 and kernel /boot/vmlinuz-4.18.0-rnicolescu_ciqlts8_6_CVE-2025-38461-76cac62feeef+
The default is /boot/loader/entries/5b498e8d58534bd5b017cfd4107dedaf-4.18.0-rnicolescu_ciqlts8_6_CVE-2025-38461-76cac62feeef+.conf with index 2 and kernel /boot/vmlinuz-4.18.0-rnicolescu_ciqlts8_6_CVE-2025-38461-76cac62feeef+
Generating grub configuration file ...
done
Hopefully Grub2.0 took everything ... rebooting after time metrices
[TIMER]{MRPROPER}: 4s
[TIMER]{BUILD}: 1420s
[TIMER]{MODULES}: 10s
[TIMER]{INSTALL}: 15s
[TIMER]{TOTAL} 1454s
Rebooting in 10 seconds

kernel-build-after.log
kernel-build-before.log

Kselftests

> /home/rnicolescu/ciq/kernel-tools/kselftest-diff.sh /home/rnicolescu/ciq/kernels/lts-8.6_CVE-2025-38461
/home/rnicolescu/ciq/kernels/lts-8.6_CVE-2025-38461/kselftest-before.log
212
/home/rnicolescu/ciq/kernels/lts-8.6_CVE-2025-38461/kselftest-after.log
212
Before: /home/rnicolescu/ciq/kernels/lts-8.6_CVE-2025-38461/kselftest-before.log
After: /home/rnicolescu/ciq/kernels/lts-8.6_CVE-2025-38461/kselftest-after.log
Diff:
No differences found.

kselftest-after.log
kselftest-before.log

Check_kernel_commits including interdiff

> python3 /home/rnicolescu/ciq/kernel-src-tree-tools/check_kernel_commits.py --repo /home/rnicolescu/ciq/kernels/lts-8.6_CVE-2025-38461/kernel-src-tree --pr_branch {rnicolescu}_ciqlts8_6_CVE-2025-38461 --base_branch origin/ciqlts8_6
All referenced commits exist upstream and have no Fixes: tags.

jira VULN-80680
cve-pre CVE-2025-38461
commit-author Stefano Garzarella <[email protected]>
commit a24009b

Transport's release() and destruct() are called when de-assigning the
vsock transport. These callbacks can touch some socket state like
sock flags, sk_state, and peer_shutdown.

Since we are reassigning the socket to a new transport during
vsock_connect(), let's reset these fields to have a clean state with
the new transport.

Fixes: c0cfa2d ("vsock: add multi-transports support")
	Cc: [email protected]
	Signed-off-by: Stefano Garzarella <[email protected]>
	Reviewed-by: Luigi Leonardi <[email protected]>
	Signed-off-by: Paolo Abeni <[email protected]>

(cherry picked from commit a24009b)
	Signed-off-by: Roxana Nicolescu <[email protected]>
jira VULN-80680
cve CVE-2025-38461
commit-author Michal Luczaj <[email protected]>
commit 687aa0c

Transport assignment may race with module unload. Protect new_transport
from becoming a stale pointer.

This also takes care of an insecure call in vsock_use_local_transport();
add a lockdep assert.

BUG: unable to handle page fault for address: fffffbfff8056000
Oops: Oops: 0000 [#1] SMP KASAN
RIP: 0010:vsock_assign_transport+0x366/0x600
Call Trace:
 vsock_connect+0x59c/0xc40
 __sys_connect+0xe8/0x100
 __x64_sys_connect+0x6e/0xc0
 do_syscall_64+0x92/0x1c0
 entry_SYSCALL_64_after_hwframe+0x4b/0x53

Fixes: c0cfa2d ("vsock: add multi-transports support")
	Reviewed-by: Stefano Garzarella <[email protected]>
	Signed-off-by: Michal Luczaj <[email protected]>
Link: https://patch.msgid.link/[email protected]
	Signed-off-by: Jakub Kicinski <[email protected]>
(cherry picked from commit 687aa0c)
	Signed-off-by: Roxana Nicolescu <[email protected]>
jira VULN-80680
cve-bf CVE-2025-38461
commit-author Michal Luczaj <[email protected]>
commit f7c877e
upstream-diff |
	Adjusted context due to missing SEQPACKET support

Syzbot reported a potential lock inversion deadlock between
vsock_register_mutex and sk_lock-AF_VSOCK when vsock_linger() is called.

The issue was introduced by commit 687aa0c ("vsock: Fix
transport_* TOCTOU") which added vsock_register_mutex locking in
vsock_assign_transport() around the transport->release() call, that can
call vsock_linger(). vsock_assign_transport() can be called with sk_lock
held. vsock_linger() calls sk_wait_event() that temporarily releases and
re-acquires sk_lock. During this window, if another thread hold
vsock_register_mutex while trying to acquire sk_lock, a circular
dependency is created.

Fix this by releasing vsock_register_mutex before calling
transport->release() and vsock_deassign_transport(). This is safe
because we don't need to hold vsock_register_mutex while releasing the
old transport, and we ensure the new transport won't disappear by
obtaining a module reference first via try_module_get().

	Reported-by: [email protected]
	Tested-by: [email protected]
Fixes: 687aa0c ("vsock: Fix transport_* TOCTOU")
	Cc: [email protected]
	Cc: [email protected]
	Signed-off-by: Stefano Garzarella <[email protected]>
Link: https://patch.msgid.link/[email protected]
	Signed-off-by: Paolo Abeni <[email protected]>

(cherry picked from commit f7c877e)
	Signed-off-by: Roxana Nicolescu <[email protected]>
Copy link
Collaborator

@bmastbergen bmastbergen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥌

Copy link
Collaborator

@PlaidCat PlaidCat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@roxanan1996 roxanan1996 merged commit c9a24e2 into ciqlts8_6 Nov 17, 2025
3 checks passed
@roxanan1996 roxanan1996 deleted the {rnicolescu}_ciqlts8_6_CVE-2025-38461 branch November 18, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants