From: sashiko-bot@kernel.org
To: "Lee Jones" <lee@kernel.org>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [STABLE v6.1-v5.10 1/1] HID: logitech-hidpp: fix race condition when accessing stale stack pointer
Date: Tue, 22 Sep 2026 08:27:36 +0000 [thread overview]
Message-ID: <20260922082737.33CB91F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260922081615.821827-1-lee@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hid-logitech-hidpp: data race in hidpp_raw_hidpp_event() allows NULL pointer deref
--
commit d3703221a099da6d388bec38af269fe1cd97ac2c
Author: Benoît Sevens <bsevens@google.com>
HID: logitech-hidpp: fix race condition when accessing stale stack pointer
The driver uses a stack-allocated buffer in the synchronous command path but
does not clear the pointer when returning. This patch clears the pointer and
checks for NULL in the event handler to prevent out-of-bounds access.
> diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
> index 8a2aac18dcc51..f584c1007169c 100644
> --- a/drivers/hid/hid-logitech-hidpp.c
> +++ b/drivers/hid/hid-logitech-hidpp.c
> @@ -322,6 +322,7 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp,
> }
>
> exit:
> + hidpp->send_receive_buf = NULL;
> mutex_unlock(&hidpp->send_mutex);
> return ret;
>
[ ... ]
> @@ -3590,6 +3590,12 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
> * previously sent command.
> */
> if (unlikely(mutex_is_locked(&hidpp->send_mutex))) {
> + question = hidpp->send_receive_buf;
> + answer = hidpp->send_receive_buf;
[Severity: High]
Can these sequential lockless reads of hidpp->send_receive_buf allow a data
race?
Because hidpp_raw_hidpp_event() does not hold send_mutex when checking
mutex_is_locked(), another thread running hidpp_send_message_sync() could
modify hidpp->send_receive_buf concurrently.
If hidpp_send_message_sync() executes:
hidpp->send_receive_buf = NULL;
exactly between the assignments to question and answer, could question
receive a non-NULL pointer while answer receives NULL?
> +
> + if (!question)
> + return 0;
> +
If the second read yields NULL for answer, the question check will pass.
Then, if the report matches, the handler will execute:
*answer = *report;
Could this result in a NULL pointer dereference and panic the kernel?
Would it be safer to read hidpp->send_receive_buf exactly once,
perhaps with READ_ONCE(), and assign the result to both question and
answer?
> /*
> * Check for a correct hidpp20 answer or the corresponding
> * error
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260922081615.821827-1-lee@kernel.org?part=1
next prev parent reply other threads:[~2026-09-22 8:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 8:16 [STABLE v6.1-v5.10 1/1] HID: logitech-hidpp: fix race condition when accessing stale stack pointer Lee Jones
2026-09-22 8:27 ` sashiko-bot [this message]
2026-09-22 15:38 ` Sasha Levin
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=20260922082737.33CB91F00898@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=lee@kernel.org \
--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