Skip to content

Commit 8f0f1d0

Browse files
pip-izonyUlrich Hecht
authored andcommitted
Input: pegasus-notetaker - fix potential out-of-bounds access
[ Upstream commit 69aeb507312306f73495598a055293fa749d454e ] 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: 1afca2b ("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: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ulrich Hecht <uli@kernel.org>
1 parent 5bd2717 commit 8f0f1d0

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

drivers/input/tablet/pegasus_notetaker.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
#define BUTTON_PRESSED 0xb5
6363
#define COMMAND_VERSION 0xa9
6464

65+
/* 1 Status + 1 Color + 2 X + 2 Y = 6 bytes */
66+
#define NOTETAKER_PACKET_SIZE 6
67+
6568
/* in xy data packet */
6669
#define BATTERY_NO_REPORT 0x40
6770
#define BATTERY_LOW 0x41
@@ -296,6 +299,12 @@ static int pegasus_probe(struct usb_interface *intf,
296299

297300
pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
298301
pegasus->data_len = usb_maxpacket(dev, pipe);
302+
if (pegasus->data_len < NOTETAKER_PACKET_SIZE) {
303+
dev_err(&intf->dev, "packet size is too small (%d)\n",
304+
pegasus->data_len);
305+
error = -EINVAL;
306+
goto err_free_mem;
307+
}
299308

300309
pegasus->data = usb_alloc_coherent(dev, pegasus->data_len, GFP_KERNEL,
301310
&pegasus->data_dma);

0 commit comments

Comments
 (0)