From: sashiko-bot@kernel.org
To: "Griffin Kroah-Hartman" <griffin@kroah.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v2 3/3] Input: xpad - add size checks to xpad360 packet processing
Date: Wed, 05 Aug 2026 10:08:57 +0000 [thread overview]
Message-ID: <20260805100857.D8AD01F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260805-xpadone_length_checks-v2-3-f3e925e0280b@kroah.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] Logical out-of-bounds read due to incorrect order of length check.
Pre-existing issues:
- [High] Use-After-Free or NULL Pointer Dereference in error logging path.
--
--- Patch [3]: [PATCH v2 3/3] Input: xpad - add size checks to xpad360 packet processing ---
commit 2a90e36a133f256901ec08114f8164654060dd73
Author: Griffin Kroah-Hartman <griffin@kroah.com>
Input: xpad - add size checks to xpad360 packet processing
This commit adds size checks to xbox360_process_packet() and
xbox360w_process_packet() to prevent out-of-bounds reads with the data array.
> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> index 83bc361b15f76..6f15eafc64775 100644
> --- a/drivers/input/joystick/xpad.c
> +++ b/drivers/input/joystick/xpad.c
> @@ -870,10 +870,10 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
> */
>
> static void xpad360_process_packet(struct usb_xpad *xpad, struct input_dev *dev,
> - u16 cmd, unsigned char *data)
> + u16 cmd, unsigned char *data, u32 len)
> {
> /* valid pad data */
> - if (data[0] != 0x00)
> + if (data[0] != 0x00 || len < 14)
[Severity: Medium]
Will this evaluate data[0] before checking len? C logical OR short-circuits
from left to right, meaning data[0] could be read from the DMA buffer
before we verify len is large enough to contain it.
If we receive a zero-length packet (ZLP) where urb->actual_length is 0,
could this result in an out-of-bounds read of the data array?
[ ... ]
[Severity: High]
This is a pre-existing issue and was not introduced by the patch under review,
but I noticed a potential use-after-free or NULL pointer dereference in the
error logging path when xpad_init_input() fails.
If input_allocate_device() fails, xpad->dev remains NULL:
drivers/input/joystick/xpad.c:xpad_init_input() {
...
input_dev = input_allocate_device();
if (!input_dev)
return -ENOMEM;
xpad->dev = input_dev;
...
}
Or if a later initialization step fails, xpad_init_input() frees input_dev
but leaves xpad->dev pointing to the freed memory:
drivers/input/joystick/xpad.c:xpad_init_input() {
...
err_free_input:
input_free_device(input_dev);
return error;
}
If xpad_init_input() returns an error, xpad_presence_work() logs it:
drivers/input/joystick/xpad.c:xpad_presence_work() {
...
dev_err(&xpad->dev->dev,
"unable to init device: %d\n", error);
...
}
Could this dev_err() call dereference the NULL or dangling xpad->dev pointer?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-xpadone_length_checks-v2-0-f3e925e0280b@kroah.com?part=3
prev parent reply other threads:[~2026-08-05 10:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 9:56 [PATCH v2 0/3] xpad packet size checks Griffin Kroah-Hartman
2026-08-05 9:56 ` [PATCH v2 1/3] Input: xpad - add out-of-bounds checks for xpadone Griffin Kroah-Hartman
2026-08-05 10:10 ` sashiko-bot
2026-08-05 9:56 ` [PATCH v2 2/3] Input: xpad - add packet length check for xpad_process_packet() Griffin Kroah-Hartman
2026-08-05 10:11 ` sashiko-bot
2026-08-05 9:56 ` [PATCH v2 3/3] Input: xpad - add size checks to xpad360 packet processing Griffin Kroah-Hartman
2026-08-05 10:08 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260805100857.D8AD01F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=griffin@kroah.com \
--cc=linux-input@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox