All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Griffin Kroah-Hartman" <griffin@kroah.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2 1/3] Input: xpad - add out-of-bounds checks for xpadone
Date: Wed, 05 Aug 2026 10:10:45 +0000	[thread overview]
Message-ID: <20260805101046.D225D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805-xpadone_length_checks-v2-1-f3e925e0280b@kroah.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The xpadone_process_packet function processes GIP_CMD_ANNOUNCE packets by directly calling xpad_start_input() from within the atomic xpad_irq_in URB completion handler, causing a kernel panic due to blocking operations.
--

--- Patch [1]: [PATCH v2 1/3] Input: xpad - add out-of-bounds checks for xpadone ---
commit d812a96c06a9e629fcf6e5c81511be2d91b754b4
Author: Griffin Kroah-Hartman <griffin@kroah.com>

Input: xpad - add out-of-bounds checks for xpadone
    
This commit adds size checks for the "len" variable in xpadone_process_packet().
It prevents out-of-bounds accesses to the "data" buffer by ensuring the packet
length is sufficient for various commands.

> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> index feb8f368f834e..9ce792503b3a4 100644
> --- a/drivers/input/joystick/xpad.c
> +++ b/drivers/input/joystick/xpad.c
[ ... ]
> @@ -1079,9 +1087,13 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
>  					 error);
>  		}

[Severity: High]
This is a pre-existing issue, but does calling xpad_start_input() here cause
a deadlock or scheduling while atomic bug?

In the preceding GIP_CMD_ANNOUNCE block (shown partially in the context above),
xpad_start_input() is called from xpadone_process_packet():

drivers/input/joystick/xpad.c:xpadone_process_packet() {
    ...
    } else if (data[0] == GIP_CMD_ANNOUNCE) {
        ...
        error = xpad_start_input(xpad);
    ...
}

Since xpadone_process_packet() is called from the atomic URB completion handler
(xpad_irq_in), wouldn't this execution context be atomic?

Looking at xpad_start_input(), it uses GFP_KERNEL and can call usb_kill_urb()
on xpad->irq_in if xpad_start_xbox_one() fails:

drivers/input/joystick/xpad.c:xpad_start_input() {
    if (usb_submit_urb(xpad->irq_in, GFP_KERNEL))
        return -EIO;

    if (xpad->xtype == XTYPE_XBOXONE) {
        error = xpad_start_xbox_one(xpad);
        if (error) {
            usb_kill_urb(xpad->irq_in);
            return error;
        }
    }
    ...
}

Could the GFP_KERNEL allocation cause scheduling while atomic? Also, if an error
occurs, wouldn't usb_kill_urb(xpad->irq_in) wait on the very URB handler that is
currently executing, leading to a deadlock?

>  	} else if (data[0] == GIP_CMD_INPUT) { /* The main valid packet type for inputs */
> +		if (len < 18)
> +			return;
>  		/* menu/view buttons */
>  		input_report_key(dev, BTN_START,  data[4] & BIT(2));
>  		input_report_key(dev, BTN_SELECT, data[4] & BIT(3));

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-xpadone_length_checks-v2-0-f3e925e0280b@kroah.com?part=1

  reply	other threads:[~2026-08-05 10:10 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 [this message]
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

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=20260805101046.D225D1F000E9@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.