]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: cdc-acm: Fix handling of oversized fragments
authorJann Horn <jannh@google.com>
Wed, 12 Feb 2025 18:15:16 +0000 (19:15 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Feb 2025 13:01:32 +0000 (14:01 +0100)
commita5b205ceefa5e4d62c63f50fa4ee923ce66fdba2
tree37425202afe87cf23574f9e4495caa16bd2f536a
parentf64079bef6a8a7823358c3f352ea29a617844636
usb: cdc-acm: Fix handling of oversized fragments

commit 12e712964f41d05ae034989892de445781c46730 upstream.

If we receive an initial fragment of size 8 bytes which specifies a wLength
of 1 byte (so the reassembled message is supposed to be 9 bytes long), and
we then receive a second fragment of size 9 bytes (which is not supposed to
happen), we currently wrongly bypass the fragment reassembly code but still
pass the pointer to the acm->notification_buffer to
acm_process_notification().

Make this less wrong by always going through fragment reassembly when we
expect more fragments.

Before this patch, receiving an overlong fragment could lead to `newctrl`
in acm_process_notification() being uninitialized data (instead of data
coming from the device).

Cc: stable <stable@kernel.org>
Fixes: ea2583529cd1 ("cdc-acm: reassemble fragmented notifications")
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/cdc-acm.c