From: sashiko-bot@kernel.org
To: "Nguyen Ngoc Thang" <ngocthang2710.1999@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH] HID: saitek: don't dereference a NULL hidinput in saitek_event()
Date: Thu, 15 Oct 2026 14:45:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-172986@kernel.org> (raw)
In-Reply-To: <20261015143433.129525-1-ngocthang2710.1999@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hid: UAF in saitek_event() due to dangling field->hidinput on init failure
--
commit c05cbb2256bb191c18315a19fe3d041ae082e349
Author: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
HID: saitek: don't dereference a NULL hidinput in saitek_event()
hid_process_event() calls the driver's ->event() for every usage of a
report, including fields that hidinput did not map to any input device,
e.g. a constant input item. For those fields field->hidinput is NULL,
and saitek_event() loads field->hidinput->input unconditionally:
Closes: https://syzkaller.appspot.com/bug?extid=eba2b3201bd25a97cddf
> diff --git a/drivers/hid/hid-saitek.c b/drivers/hid/hid-saitek.c
> index 6fe7c087c594e..2a9e07a4fc77f 100644
> --- a/drivers/hid/hid-saitek.c
> +++ b/drivers/hid/hid-saitek.c
> @@ -151,7 +151,12 @@ static int saitek_event(struct hid_device *hdev, struct hid_field *field,
> struct hid_usage *usage, __s32 value)
> {
> struct saitek_sc *ssc = hid_get_drvdata(hdev);
> - struct input_dev *input = field->hidinput->input;
> + struct input_dev *input;
> +
> + if (!field->hidinput)
> + return 0;
> +
> + input = field->hidinput->input;
[Severity: High]
Can this still cause a use-after-free if hidinput_connect() fails during
probe?
If hidinput_connect() fails (for example, if input_register_device() fails),
it calls hidinput_disconnect() which frees the hid_input structures:
drivers/hid/hid-input.c:hidinput_disconnect() {
...
list_for_each_entry_safe(hidinput, next, &hid->inputs, list) {
list_del(&hidinput->list);
...
kfree(hidinput);
}
...
}
However, it does not clear the field->hidinput pointers in the report fields.
Because the Saitek driver defines a ->raw_event callback, hid_connect()
tolerates the input connection failure and returns success. The probe sequence
completes successfully and the device becomes active.
When a report arrives, __hid_input_report() processes it and calls the driver's
->event() callback (saitek_event). The newly added check if (!field->hidinput)
will evaluate to false because the pointer is non-NULL but dangling, leading
to a use-after-free when field->hidinput->input is dereferenced.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015143433.129525-1-ngocthang2710.1999@gmail.com?part=1
prev parent reply other threads:[~2026-10-15 14:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 14:34 [PATCH] HID: saitek: don't dereference a NULL hidinput in saitek_event() Nguyen Ngoc Thang
2026-10-15 14:45 ` 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=sashiko-outbox-172986@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=ngocthang2710.1999@gmail.com \
--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.