]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Input: pegasus-notetaker - fix potential out-of-bounds access
authorSeungjin Bae <eeodqql09@gmail.com>
Fri, 17 Oct 2025 22:36:31 +0000 (15:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Dec 2025 10:43:23 +0000 (11:43 +0100)
commit 69aeb507312306f73495598a055293fa749d454e upstream.

In the pegasus_notetaker driver, the pegasus_probe() function allocates
the URB transfer buffer using the wMaxPacketSize value from
the endpoint descriptor. An attacker can use a malicious USB descriptor
to force the allocation of a very small buffer.

Subsequently, if the device sends an interrupt packet with a specific
pattern (e.g., where the first byte is 0x80 or 0x42),
the pegasus_parse_packet() function parses the packet without checking
the allocated buffer size. This leads to an out-of-bounds memory access.

Fixes: 1afca2b66aac ("Input: add Pegasus Notetaker tablet driver")
Signed-off-by: Seungjin Bae <eeodqql09@gmail.com>
Link: https://lore.kernel.org/r/20251007214131.3737115-2-eeodqql09@gmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/input/tablet/pegasus_notetaker.c

index a68da2988f9cd828942b5a23eed5efd5576cb7f5..26ab9924a7ae5437c29234ce8de2dae7880bd589 100644 (file)
@@ -63,6 +63,9 @@
 #define BUTTON_PRESSED                 0xb5
 #define COMMAND_VERSION                        0xa9
 
+/* 1 Status + 1 Color + 2 X + 2 Y = 6 bytes */
+#define NOTETAKER_PACKET_SIZE          6
+
 /* in xy data packet */
 #define BATTERY_NO_REPORT              0x40
 #define BATTERY_LOW                    0x41
@@ -303,6 +306,12 @@ static int pegasus_probe(struct usb_interface *intf,
        }
 
        pegasus->data_len = usb_maxpacket(dev, pipe);
+       if (pegasus->data_len < NOTETAKER_PACKET_SIZE) {
+               dev_err(&intf->dev, "packet size is too small (%d)\n",
+                       pegasus->data_len);
+               error = -EINVAL;
+               goto err_free_mem;
+       }
 
        pegasus->data = usb_alloc_coherent(dev, pegasus->data_len, GFP_KERNEL,
                                           &pegasus->data_dma);