Skip to content

[lts-94] vsock fixes for CVE-2025-21756 - #244

Merged
bmastbergen merged 2 commits into
ciqlts9_4from
bmastbergen_ciqlts9_4/VULN-53609
May 6, 2025
Merged

[lts-94] vsock fixes for CVE-2025-21756#244
bmastbergen merged 2 commits into
ciqlts9_4from
bmastbergen_ciqlts9_4/VULN-53609

Conversation

@bmastbergen

Copy link
Copy Markdown
Collaborator

VULN-53609
CVE-2025-21756

This ended up being two commits: The initial fix and a fix for that fix.

Build Log

/home/brett/kernel-src-tree
no .config file found, moving on
[TIMER]{MRPROPER}: 0s
x86_64 architecture detected, copying config
'configs/kernel-x86_64-rhel.config' -> '.config'
Setting Local Version for build
CONFIG_LOCALVERSION="-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc"
Making olddefconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
LEX scripts/kconfig/lexer.lex.c
YACC scripts/kconfig/parser.tab.[ch]
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/menu.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTCC scripts/kconfig/util.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
Starting Build
SYSHDR arch/x86/include/generated/uapi/asm/unistd_32.h
SYSHDR arch/x86/include/generated/uapi/asm/unistd_64.h
SYSHDR arch/x86/include/generated/uapi/asm/unistd_x32.h
SYSTBL arch/x86/include/generated/asm/syscalls_32.h
SYSHDR arch/x86/include/generated/asm/unistd_32_ia32.h
SYSHDR arch/x86/include/generated/asm/unistd_64_x32.h
SYSTBL arch/x86/include/generated/asm/syscalls_64.h
[SNIP]
STRIP /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/usb/snd-usbmidi-lib.ko
STRIP /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/usb/usx2y/snd-usb-us122l.ko
INSTALL /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/virtio/virtio_snd.ko
STRIP /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/usb/usx2y/snd-usb-usx2y.ko
SIGN /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/usb/misc/snd-ua101.ko
INSTALL /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/xen/snd_xen_front.ko
INSTALL /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/x86/snd-hdmi-lpe-audio.ko
INSTALL /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/virt/lib/irqbypass.ko
SIGN /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/usb/usx2y/snd-usb-us122l.ko
SIGN /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/usb/snd-usb-audio.ko
SIGN /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/usb/snd-usbmidi-lib.ko
STRIP /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/virtio/virtio_snd.ko
SIGN /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/usb/usx2y/snd-usb-usx2y.ko
STRIP /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/x86/snd-hdmi-lpe-audio.ko
STRIP /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/xen/snd_xen_front.ko
STRIP /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/virt/lib/irqbypass.ko
SIGN /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/virt/lib/irqbypass.ko
SIGN /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/x86/snd-hdmi-lpe-audio.ko
SIGN /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/xen/snd_xen_front.ko
SIGN /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+/kernel/sound/virtio/virtio_snd.ko
DEPMOD /lib/modules/5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+
[TIMER]{MODULES}: 8s
Making Install
sh ./arch/x86/boot/install.sh 5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+ \
arch/x86/boot/bzImage System.map "/boot"
[TIMER]{INSTALL}: 64s
Checking kABI
Checking kABI
kABI check passed
Setting Default Kernel to /boot/vmlinuz-5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+ and Index to 2
Hopefully Grub2.0 took everything ... rebooting after time metrices
[TIMER]{MRPROPER}: 0s
[TIMER]{BUILD}: 1721s
[TIMER]{MODULES}: 8s
[TIMER]{INSTALL}: 64s
[TIMER]{TOTAL} 1810s
Rebooting in 10 seconds

Testing

kselfests were run before and after applying the fixes

selftests-5.14.0-427.42.1.el9_4.94ciq_lts.2.1.x86_64.log

selftests-5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+.log

brett@lycia ~/ciq/vuln-53609 % grep ^ok selftests-5.14.0-427.42.1.el9_4.94ciq_lts.2.1.x86_64.log | wc -l
308
brett@lycia ~/ciq/vuln-53609 % grep ^ok selftests-5.14.0-bmastbergen_ciqlts9_4_VULN-53609-9547bbd702bc+.log | wc -l
349
brett@lycia ~/ciq/vuln-53609 %

jira VULN-53609
cve CVE-2025-21756
commit-author Michal Luczaj <mhal@rbox.co>
commit fcdd224
upstream-diff Indentation is different from upstream change because
this kernel lacks 135ffc7 ("bpf, vsock: Invoke
proto::close on close()"). Otherwise the change
content is the same.
Preserve sockets bindings; this includes both resulting from an explicit
bind() and those implicitly bound through autobind during connect().
Prevents socket unbinding during a transport reassignment, which fixes a
use-after-free:
1. vsock_create() (refcnt=1) calls vsock_insert_unbound() (refcnt=2)
2. transport->release() calls vsock_remove_bound() without checking if
sk was bound and moved to bound list (refcnt=1)
3. vsock_bind() assumes sk is in unbound list and before
__vsock_insert_bound(vsock_bound_sockets()) calls
__vsock_remove_bound() which does:
list_del_init(&vsk->bound_table); // nop
sock_put(&vsk->sk); // refcnt=0
BUG: KASAN: slab-use-after-free in __vsock_bind+0x62e/0x730
Read of size 4 at addr ffff88816b46a74c by task a.out/2057
dump_stack_lvl+0x68/0x90
print_report+0x174/0x4f6
kasan_report+0xb9/0x190
__vsock_bind+0x62e/0x730
vsock_bind+0x97/0xe0
__sys_bind+0x154/0x1f0
__x64_sys_bind+0x6e/0xb0
do_syscall_64+0x93/0x1b0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Allocated by task 2057:
kasan_save_stack+0x1e/0x40
kasan_save_track+0x10/0x30
__kasan_slab_alloc+0x85/0x90
kmem_cache_alloc_noprof+0x131/0x450
sk_prot_alloc+0x5b/0x220
sk_alloc+0x2c/0x870
__vsock_create.constprop.0+0x2e/0xb60
vsock_create+0xe4/0x420
__sock_create+0x241/0x650
__sys_socket+0xf2/0x1a0
__x64_sys_socket+0x6e/0xb0
do_syscall_64+0x93/0x1b0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Freed by task 2057:
kasan_save_stack+0x1e/0x40
kasan_save_track+0x10/0x30
kasan_save_free_info+0x37/0x60
__kasan_slab_free+0x4b/0x70
kmem_cache_free+0x1a1/0x590
__sk_destruct+0x388/0x5a0
__vsock_bind+0x5e1/0x730
vsock_bind+0x97/0xe0
__sys_bind+0x154/0x1f0
__x64_sys_bind+0x6e/0xb0
do_syscall_64+0x93/0x1b0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
refcount_t: addition on 0; use-after-free.
WARNING: CPU: 7 PID: 2057 at lib/refcount.c:25 refcount_warn_saturate+0xce/0x150
RIP: 0010:refcount_warn_saturate+0xce/0x150
__vsock_bind+0x66d/0x730
vsock_bind+0x97/0xe0
__sys_bind+0x154/0x1f0
__x64_sys_bind+0x6e/0xb0
do_syscall_64+0x93/0x1b0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
refcount_t: underflow; use-after-free.
WARNING: CPU: 7 PID: 2057 at lib/refcount.c:28 refcount_warn_saturate+0xee/0x150
RIP: 0010:refcount_warn_saturate+0xee/0x150
vsock_remove_bound+0x187/0x1e0
__vsock_release+0x383/0x4a0
vsock_release+0x90/0x120
__sock_release+0xa3/0x250
sock_close+0x14/0x20
__fput+0x359/0xa80
task_work_run+0x107/0x1d0
do_exit+0x847/0x2560
do_group_exit+0xb8/0x250
__x64_sys_exit_group+0x3a/0x50
x64_sys_call+0xfec/0x14f0
do_syscall_64+0x93/0x1b0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Fixes: c0cfa2d ("vsock: add multi-transports support")
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://patch.msgid.link/20250128-vsock-transport-vs-autobind-v3-1-1cf57065b770@rbox.co
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit fcdd224)
Signed-off-by: Brett Mastbergen <bmastbergen@ciq.com>
jira VULN-53609
cve CVE-2025-21756
commit-author Michal Luczaj <mhal@rbox.co>
commit 78dafe1
upstream-diff Indentation is different from upstream change because
this kernel lacks 135ffc7 ("bpf, vsock: Invoke
proto::close on close()"). Otherwise the change
content is the same.
During socket release, sock_orphan() is called without considering that it
sets sk->sk_wq to NULL. Later, if SO_LINGER is enabled, this leads to a
null pointer dereferenced in virtio_transport_wait_close().
Orphan the socket only after transport release.
Partially reverts the 'Fixes:' commit.
KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f]
lock_acquire+0x19e/0x500
_raw_spin_lock_irqsave+0x47/0x70
add_wait_queue+0x46/0x230
virtio_transport_release+0x4e7/0x7f0
__vsock_release+0xfd/0x490
vsock_release+0x90/0x120
__sock_release+0xa3/0x250
sock_close+0x14/0x20
__fput+0x35e/0xa90
__x64_sys_close+0x78/0xd0
do_syscall_64+0x93/0x1b0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Reported-by: syzbot+9d55b199192a4be7d02c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=9d55b199192a4be7d02c
Fixes: fcdd224 ("vsock: Keep the binding until socket destruction")
Tested-by: Luigi Leonardi <leonardi@redhat.com>
Reviewed-by: Luigi Leonardi <leonardi@redhat.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://patch.msgid.link/20250210-vsock-linger-nullderef-v3-1-ef6244d02b54@rbox.co
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 78dafe1)
Signed-off-by: Brett Mastbergen <bmastbergen@ciq.com>

@PlaidCatPlaidCat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:shipit:

@bmastbergen
bmastbergen merged commit be2f55f into ciqlts9_4May 6, 2025
@bmastbergen
bmastbergen deleted the bmastbergen_ciqlts9_4/VULN-53609 branch May 6, 2025 19:51
bmastbergen pushed a commit to bmastbergen/kernel-src-tree that referenced this pull request Aug 29, 2025
jira LE-1907
Rebuild_History Non-Buildable kernel-5.14.0-427.18.1.el9_4
commit-author Daniel Borkmann <daniel@iogearbox.net>
commit cd13c91
Add a big batch of test coverage to assert all aspects of the tcx opts
attach, detach and query API:
# ./vmtest.sh -- ./test_progs -t tc_opts
[...]
ctrliq#238 tc_opts_after:OK
ctrliq#239 tc_opts_append:OK
ctrliq#240 tc_opts_basic:OK
ctrliq#241 tc_opts_before:OK
ctrliq#242 tc_opts_chain_classic:OK
ctrliq#243 tc_opts_demixed:OK
ctrliq#244 tc_opts_detach:OK
ctrliq#245 tc_opts_detach_after:OK
ctrliq#246 tc_opts_detach_before:OK
ctrliq#247 tc_opts_dev_cleanup:OK
ctrliq#248 tc_opts_invalid:OK
ctrliq#249 tc_opts_mixed:OK
ctrliq#250 tc_opts_prepend:OK
ctrliq#251 tc_opts_replace:OK
ctrliq#252 tc_opts_revision:OK
Summary: 15/0 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20230719140858.13224-8-daniel@iogearbox.net
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
(cherry picked from commit cd13c91)
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
bmastbergen pushed a commit to bmastbergen/kernel-src-tree that referenced this pull request Aug 29, 2025
jira LE-1907
Rebuild_History Non-Buildable kernel-5.14.0-427.18.1.el9_4
commit-author Daniel Borkmann <daniel@iogearbox.net>
commit 21ce6ab
Add a detachment test case with miniq present to assert that with and
without the miniq we get the same error.
# ./test_progs -t tc_opts
ctrliq#244 tc_opts_after:OK
ctrliq#245 tc_opts_append:OK
ctrliq#246 tc_opts_basic:OK
ctrliq#247 tc_opts_before:OK
ctrliq#248 tc_opts_chain_classic:OK
ctrliq#249 tc_opts_delete_empty:OK
ctrliq#250 tc_opts_demixed:OK
ctrliq#251 tc_opts_detach:OK
ctrliq#252 tc_opts_detach_after:OK
ctrliq#253 tc_opts_detach_before:OK
ctrliq#254 tc_opts_dev_cleanup:OK
ctrliq#255 tc_opts_invalid:OK
ctrliq#256 tc_opts_mixed:OK
ctrliq#257 tc_opts_prepend:OK
ctrliq#258 tc_opts_replace:OK
ctrliq#259 tc_opts_revision:OK
Summary: 16/0 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20230804131112.11012-2-daniel@iogearbox.net
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
(cherry picked from commit 21ce6ab)
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
bmastbergen pushed a commit to bmastbergen/kernel-src-tree that referenced this pull request Aug 29, 2025
jira LE-1907
Rebuild_History Non-Buildable kernel-5.14.0-427.18.1.el9_4
commit-author Daniel Borkmann <daniel@iogearbox.net>
commit ccd9a8b
Add several new tcx test cases to improve test coverage. This also includes
a few new tests with ingress instead of clsact qdisc, to cover the fix from
commit dc644b5 ("tcx: Fix splat in ingress_destroy upon tcx_entry_free").
# ./test_progs -t tc
[...]
ctrliq#234 tc_links_after:OK
ctrliq#235 tc_links_append:OK
ctrliq#236 tc_links_basic:OK
ctrliq#237 tc_links_before:OK
ctrliq#238 tc_links_chain_classic:OK
ctrliq#239 tc_links_chain_mixed:OK
ctrliq#240 tc_links_dev_cleanup:OK
ctrliq#241 tc_links_dev_mixed:OK
ctrliq#242 tc_links_ingress:OK
ctrliq#243 tc_links_invalid:OK
ctrliq#244 tc_links_prepend:OK
ctrliq#245 tc_links_replace:OK
ctrliq#246 tc_links_revision:OK
ctrliq#247 tc_opts_after:OK
ctrliq#248 tc_opts_append:OK
ctrliq#249 tc_opts_basic:OK
ctrliq#250 tc_opts_before:OK
ctrliq#251 tc_opts_chain_classic:OK
ctrliq#252 tc_opts_chain_mixed:OK
ctrliq#253 tc_opts_delete_empty:OK
ctrliq#254 tc_opts_demixed:OK
ctrliq#255 tc_opts_detach:OK
ctrliq#256 tc_opts_detach_after:OK
ctrliq#257 tc_opts_detach_before:OK
ctrliq#258 tc_opts_dev_cleanup:OK
ctrliq#259 tc_opts_invalid:OK
ctrliq#260 tc_opts_mixed:OK
ctrliq#261 tc_opts_prepend:OK
ctrliq#262 tc_opts_replace:OK
ctrliq#263 tc_opts_revision:OK
[...]
Summary: 44/38 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/8699efc284b75ccdc51ddf7062fa2370330dc6c0.1692029283.git.daniel@iogearbox.net
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
(cherry picked from commit ccd9a8b)
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
Sign up for freeto 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.

3 participants

@bmastbergen@kerneltoast@PlaidCat