Skip to content

[fips-8.6] nvme-tcp: fix potential memory corruption in nvme_tcp_recv_pdu() - #260

Merged
bmastbergen merged 1 commit into
fips-8-compliant/4.18.0-553.16.1from
bmastbergen_fips-8-compliant/4.18.0-553.16.1/VULN-56026
May 14, 2025
Merged

[fips-8.6] nvme-tcp: fix potential memory corruption in nvme_tcp_recv_pdu()#260
bmastbergen merged 1 commit into
fips-8-compliant/4.18.0-553.16.1from
bmastbergen_fips-8-compliant/4.18.0-553.16.1/VULN-56026

Conversation

@bmastbergen

Copy link
Copy Markdown
Collaborator

jira VULN-56026
cve CVE-2025-21927

commit-author Maurizio Lombardi <mlombard@redhat.com> commit ad95bab0cd28ed77c2c0d0b6e76e03e031391064
upstream-diff Removed `nvme_tcp_c2h_term' case from
`nvme_tcp_recv_pdu_supported' for the sake of consistency of
`nvme_tcp_recv_pdu''s behavior relative to the upstream
version, between the cases of proper and improper
header. (What could be considered as "`c2h_term' type support"
started with 84e009042d0f3dfe91bec60bcd208ee3f866cbcd commit,
not included in `ciqlts9_2''s history, so
`nvme_tcp_recv_pdu_supported' in `ciqlts9_2' shouldn't report
the `nvme_tcp_c2h_term' type as supported.)
nvme_tcp_recv_pdu() doesn't check the validity of the header length. When header digests are enabled, a target might send a packet with an invalid header length (e.g. 255), causing nvme_tcp_verify_hdgst() to access memory outside the allocated area and cause memory corruptions by overwriting it with the calculated digest.
Fix this by rejecting packets with an unexpected header length.
Fixes: 3f2304f8c6d6 ("nvme-tcp: add NVMe over TCP host driver")
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>
(cherry picked from commit ad95bab0cd28ed77c2c0d0b6e76e03e031391064)
Signed-off-by: Brett Mastbergen <bmastbergen@ciq.com>

Same as #238

Build Log

/home/brett/kernel-src-tree
CLEAN scripts/basic
CLEAN scripts/kconfig
CLEAN include/config include/generated arch/x86/include/generated
CLEAN .config .config.old
[TIMER]{MRPROPER}: 12s
x86_64 architecture detected, copying config
'configs/kernel-x86_64.config' -> '.config'
Setting Local Version for build
CONFIG_LOCALVERSION="-b_f-8-c_4.18.0-553.16.1_VULN-56026-d34226e4b585"
Making olddefconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
YACC scripts/kconfig/zconf.tab.c
LEX scripts/kconfig/zconf.lex.c
HOSTCC scripts/kconfig/zconf.tab.o
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_64_x32.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
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
WRAP arch/x86/include/generated/uapi/asm/bpf_perf_event.h
WRAP arch/x86/include/generated/uapi/asm/poll.h
WRAP arch/x86/include/generated/uapi/asm/socket.h
UPD include/config/kernel.release
UPD include/generated/uapi/linux/version.h
UPD include/generated/utsrelease.h
DESCEND objtool
DESCEND bpf/resolve_btfids
MKDIR /home/brett/kernel-src-tree/tools/bpf/resolve_btfids//libbpf
MKDIR /home/brett/kernel-src-tree/tools/bpf/resolve_btfids//libsubcmd
HOSTCC /home/brett/kernel-src-tree/tools/objtool/fixdep.o
HOSTCC /home/brett/kernel-src-tree/tools/bpf/resolve_btfids/fixdep.o
GEN /home/brett/kernel-src-tree/tools/bpf/resolve_btfids/libbpf/bpf_helper_defs.h
HOSTLD /home/brett/kernel-src-tree/tools/objtool/fixdep-in.o
LINK /home/brett/kernel-src-tree/tools/objtool/fixdep
HOSTLD /home/brett/kernel-src-tree/tools/bpf/resolve_btfids/fixdep-in.o
LINK /home/brett/kernel-src-tree/tools/bpf/resolve_btfids/fixdep
MKDIR /home/brett/kernel-src-tree/tools/bpf/resolve_btfids/libbpf/staticobjs/
CC /home/brett/kernel-src-tree/tools/bpf/resolve_btfids/libbpf/staticobjs/libbpf.o
MKDIR /home/brett/kernel-src-tree/tools/objtool/arch/x86/lib/
MKDIR /home/brett/kernel-src-tree/tools/bpf/resolve_btfids/libbpf/staticobjs/
CC /home/brett/kernel-src-tree/tools/bpf/resolve_btfids/libbpf/staticobjs/nlattr.o
CC /home/brett/kernel-src-tree/tools/objtool/builtin-check.o
GEN /home/brett/kernel-src-tree/tools/objtool/arch/x86/lib/inat-tables.c
CC /home/brett/kernel-src-tree/tools/bpf/resolve_btfids/main.o
CC /home/brett/kernel-src-tree/tools/bpf/resolve_btfids/libbpf/staticobjs/btf.o
CC /home/brett/kernel-src-tree/tools/bpf/resolve_btfids/libbpf/staticobjs/bpf.o
CC /home/brett/kernel-src-tree/tools/objtool/builtin-orc.o
CC /home/brett/kernel-src-tree/tools/objtool/check.o
[SNIP]
INSTALL sound/soc/sof/intel/snd-sof-intel-hda-mlink.ko
INSTALL sound/soc/sof/intel/snd-sof-intel-hda.ko
INSTALL sound/soc/sof/intel/snd-sof-pci-intel-apl.ko
INSTALL sound/soc/sof/intel/snd-sof-pci-intel-cnl.ko
INSTALL sound/soc/sof/intel/snd-sof-pci-intel-icl.ko
INSTALL sound/soc/sof/intel/snd-sof-pci-intel-mtl.ko
INSTALL sound/soc/sof/intel/snd-sof-pci-intel-tgl.ko
INSTALL sound/soc/sof/intel/snd-sof-pci-intel-tng.ko
INSTALL sound/soc/sof/snd-sof-acpi.ko
INSTALL sound/soc/sof/snd-sof-pci.ko
INSTALL sound/soc/sof/snd-sof-probes.ko
INSTALL sound/soc/sof/snd-sof-utils.ko
INSTALL sound/soc/sof/snd-sof.ko
INSTALL sound/soc/sof/xtensa/snd-sof-xtensa-dsp.ko
INSTALL sound/soundcore.ko
INSTALL sound/synth/emux/snd-emux-synth.ko
INSTALL sound/synth/snd-util-mem.ko
INSTALL sound/usb/6fire/snd-usb-6fire.ko
INSTALL sound/usb/bcd2000/snd-bcd2000.ko
INSTALL sound/usb/caiaq/snd-usb-caiaq.ko
INSTALL sound/usb/hiface/snd-usb-hiface.ko
INSTALL sound/usb/line6/snd-usb-line6.ko
INSTALL sound/usb/line6/snd-usb-pod.ko
INSTALL sound/usb/line6/snd-usb-podhd.ko
INSTALL sound/usb/line6/snd-usb-toneport.ko
INSTALL sound/usb/misc/snd-ua101.ko
INSTALL sound/usb/line6/snd-usb-variax.ko
INSTALL sound/usb/snd-usb-audio.ko
INSTALL sound/usb/snd-usbmidi-lib.ko
INSTALL sound/usb/usx2y/snd-usb-us122l.ko
INSTALL sound/usb/usx2y/snd-usb-usx2y.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-b_f-8-c_4.18.0-553.16.1_VULN-56026-d34226e4b585+
[TIMER]{MODULES}: 13s
Making Install
sh ./arch/x86/boot/install.sh 4.18.0-b_f-8-c_4.18.0-553.16.1_VULN-56026-d34226e4b585+ arch/x86/boot/bzImage \
System.map "/boot"
[TIMER]{INSTALL}: 106s
Checking kABI
Checking kABI
kABI check passed
Setting Default Kernel to /boot/vmlinuz-4.18.0-b_f-8-c_4.18.0-553.16.1_VULN-56026-d34226e4b585+ and Index to 2
Hopefully Grub2.0 took everything ... rebooting after time metrices
[TIMER]{MRPROPER}: 12s
[TIMER]{BUILD}: 1048s
[TIMER]{MODULES}: 13s
[TIMER]{INSTALL}: 106s
[TIMER]{TOTAL} 1196s
Rebooting in 10 seconds

Testing

kselftests were run before and after applying the fix

selftest-4.18.0-553.16.1.el8_6.ciqfips.0.7.1.x86_64.log

selftest-4.18.0-b_f-8-c_4.18.0-553.16.1_VULN-56026-d34226e4b585+.log

brett@lycia ~/ciq/vuln-56026 % grep ^ok selftest-4.18.0-553.16.1.el8_6.ciqfips.0.7.1.x86_64.log | wc -l
231
brett@lycia ~/ciq/vuln-56026 % grep ^ok selftest-4.18.0-b_f-8-c_4.18.0-553.16.1_VULN-56026-d34226e4b585+.log | wc -l
233
brett@lycia ~/ciq/vuln-56026 %

jira VULN-56026
cve CVE-2025-21927
commit-author Maurizio Lombardi <mlombard@redhat.com>
commit ad95bab
upstream-diff Removed `nvme_tcp_c2h_term' case from
`nvme_tcp_recv_pdu_supported' for the sake of consistency of
`nvme_tcp_recv_pdu''s behavior relative to the upstream
version, between the cases of proper and improper
header. (What could be considered as "`c2h_term' type support"
started with 84e0090 commit,
not included in `ciqlts9_2''s history, so
`nvme_tcp_recv_pdu_supported' in `ciqlts9_2' shouldn't report
the `nvme_tcp_c2h_term' type as supported.)
nvme_tcp_recv_pdu() doesn't check the validity of the header length.
When header digests are enabled, a target might send a packet with an
invalid header length (e.g. 255), causing nvme_tcp_verify_hdgst()
to access memory outside the allocated area and cause memory corruptions
by overwriting it with the calculated digest.
Fix this by rejecting packets with an unexpected header length.
Fixes: 3f2304f ("nvme-tcp: add NVMe over TCP host driver")
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>
(cherry picked from commit ad95bab)
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:

@thefossguy-ciqthefossguy-ciq left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚤

@bmastbergen
bmastbergen merged commit 44e2b63 into fips-8-compliant/4.18.0-553.16.1May 14, 2025
@bmastbergen
bmastbergen deleted the bmastbergen_fips-8-compliant/4.18.0-553.16.1/VULN-56026 branch May 14, 2025 12:44
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>
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 d1a783d
Add various tests to check maximum number of supported programs
being attached:
# ./vmtest.sh -- ./test_progs -t tc_opts
[...]
./test_progs -t tc_opts
[ 1.185325] bpf_testmod: loading out-of-tree module taints kernel.
[ 1.186826] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel
[ 1.270123] tsc: Refined TSC clocksource calibration: 3407.988 MHz
[ 1.272428] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fc932722, max_idle_ns: 440795381586 ns
[ 1.276408] clocksource: Switched to clocksource tsc
ctrliq#252 tc_opts_after:OK
ctrliq#253 tc_opts_append:OK
ctrliq#254 tc_opts_basic:OK
ctrliq#255 tc_opts_before:OK
ctrliq#256 tc_opts_chain_classic:OK
ctrliq#257 tc_opts_chain_mixed:OK
ctrliq#258 tc_opts_delete_empty:OK
ctrliq#259 tc_opts_demixed:OK
ctrliq#260 tc_opts_detach:OK
ctrliq#261 tc_opts_detach_after:OK
ctrliq#262 tc_opts_detach_before:OK
ctrliq#263 tc_opts_dev_cleanup:OK
ctrliq#264 tc_opts_invalid:OK
ctrliq#265 tc_opts_max:OK <--- (new test)
ctrliq#266 tc_opts_mixed:OK
ctrliq#267 tc_opts_prepend:OK
ctrliq#268 tc_opts_replace:OK
ctrliq#269 tc_opts_revision:OK
Summary: 18/0 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230929204121.20305-2-daniel@iogearbox.net
(cherry picked from commit d1a783d)
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 f9b0879
Add a new test case which performs double query of the bpf_mprog through
libbpf API, but also via raw bpf(2) syscall. This is testing to gather
first the count and then in a subsequent probe the full information with
the program array without clearing passed structs in between.
# ./vmtest.sh -- ./test_progs -t tc_opts
[...]
./test_progs -t tc_opts
[ 1.398818] tsc: Refined TSC clocksource calibration: 3407.999 MHz
[ 1.400263] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fd336761, max_idle_ns: 440795243819 ns
[ 1.402734] clocksource: Switched to clocksource tsc
[ 1.426639] bpf_testmod: loading out-of-tree module taints kernel.
[ 1.428112] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel
ctrliq#252 tc_opts_after:OK
ctrliq#253 tc_opts_append:OK
ctrliq#254 tc_opts_basic:OK
ctrliq#255 tc_opts_before:OK
ctrliq#256 tc_opts_chain_classic:OK
ctrliq#257 tc_opts_chain_mixed:OK
ctrliq#258 tc_opts_delete_empty:OK
ctrliq#259 tc_opts_demixed:OK
ctrliq#260 tc_opts_detach:OK
ctrliq#261 tc_opts_detach_after:OK
ctrliq#262 tc_opts_detach_before:OK
ctrliq#263 tc_opts_dev_cleanup:OK
ctrliq#264 tc_opts_invalid:OK
ctrliq#265 tc_opts_max:OK
ctrliq#266 tc_opts_mixed:OK
ctrliq#267 tc_opts_prepend:OK
ctrliq#268 tc_opts_query:OK <--- (new test)
ctrliq#269 tc_opts_replace:OK
ctrliq#270 tc_opts_revision:OK
Summary: 19/0 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20231006220655.1653-4-daniel@iogearbox.net
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
(cherry picked from commit f9b0879)
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 685446b
Add a new test case to query on an empty bpf_mprog and pass the revision
directly into expected_revision for attachment to assert that this does
succeed.
./test_progs -t tc_opts
[ 1.406778] tsc: Refined TSC clocksource calibration: 3407.990 MHz
[ 1.408863] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fcaf6eb0, max_idle_ns: 440795321766 ns
[ 1.412419] clocksource: Switched to clocksource tsc
[ 1.428671] bpf_testmod: loading out-of-tree module taints kernel.
[ 1.430260] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel
ctrliq#252 tc_opts_after:OK
ctrliq#253 tc_opts_append:OK
ctrliq#254 tc_opts_basic:OK
ctrliq#255 tc_opts_before:OK
ctrliq#256 tc_opts_chain_classic:OK
ctrliq#257 tc_opts_chain_mixed:OK
ctrliq#258 tc_opts_delete_empty:OK
ctrliq#259 tc_opts_demixed:OK
ctrliq#260 tc_opts_detach:OK
ctrliq#261 tc_opts_detach_after:OK
ctrliq#262 tc_opts_detach_before:OK
ctrliq#263 tc_opts_dev_cleanup:OK
ctrliq#264 tc_opts_invalid:OK
ctrliq#265 tc_opts_max:OK
ctrliq#266 tc_opts_mixed:OK
ctrliq#267 tc_opts_prepend:OK
ctrliq#268 tc_opts_query:OK
ctrliq#269 tc_opts_query_attach:OK <--- (new test)
ctrliq#270 tc_opts_replace:OK
ctrliq#271 tc_opts_revision:OK
Summary: 20/0 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20231006220655.1653-6-daniel@iogearbox.net
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
(cherry picked from commit 685446b)
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 2451630
Add several new test cases which assert corner cases on the mprog query
mechanism, for example, around passing in a too small or a larger array
than the current count.
./test_progs -t tc_opts
ctrliq#252 tc_opts_after:OK
ctrliq#253 tc_opts_append:OK
ctrliq#254 tc_opts_basic:OK
ctrliq#255 tc_opts_before:OK
ctrliq#256 tc_opts_chain_classic:OK
ctrliq#257 tc_opts_chain_mixed:OK
ctrliq#258 tc_opts_delete_empty:OK
ctrliq#259 tc_opts_demixed:OK
ctrliq#260 tc_opts_detach:OK
ctrliq#261 tc_opts_detach_after:OK
ctrliq#262 tc_opts_detach_before:OK
ctrliq#263 tc_opts_dev_cleanup:OK
ctrliq#264 tc_opts_invalid:OK
ctrliq#265 tc_opts_max:OK
ctrliq#266 tc_opts_mixed:OK
ctrliq#267 tc_opts_prepend:OK
ctrliq#268 tc_opts_query:OK
ctrliq#269 tc_opts_query_attach:OK
ctrliq#270 tc_opts_replace:OK
ctrliq#271 tc_opts_revision:OK
Summary: 20/0 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Link: https://lore.kernel.org/bpf/20231017081728.24769-1-daniel@iogearbox.net
(cherry picked from commit 2451630)
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.

4 participants

@bmastbergen@kerneltoast@PlaidCat@thefossguy-ciq