Skip to content

Commit a8d32d0

Browse files
thejhjfvogel
authored andcommitted
usb: cdc-acm: Fix handling of oversized fragments
commit 12e7129 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: ea25835 ("cdc-acm: reassemble fragmented notifications") Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit a5b205ceefa5e4d62c63f50fa4ee923ce66fdba2) Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
1 parent dd23879 commit a8d32d0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/usb/class/cdc-acm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ static void acm_ctrl_irq(struct urb *urb)
416416
expected_size = sizeof(struct usb_cdc_notification) +
417417
le16_to_cpu(dr->wLength);
418418

419-
if (current_size < expected_size) {
419+
if (acm->nb_index != 0 || current_size < expected_size) {
420420
/* notification is transmitted fragmented, reassemble */
421421
if (acm->nb_size < expected_size) {
422422
u8 *new_buffer;

0 commit comments

Comments
 (0)