From: sashiko-bot@kernel.org
To: "Cen Zhang (Microsoft)" <cenzhang@linux.microsoft.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH] Input: uinput - fix use-after-free of FF requests in ioctl handlers
Date: Tue, 13 Oct 2026 05:28:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-168999@kernel.org> (raw)
In-Reply-To: <20261013051553.71887-1-cenzhang@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] input: uinput: data race on request->retval in submitter
--
commit 8d5b9600ec78cd8cecd500a481ecb1dea1d928da
Author: Cen Zhang (Microsoft) <cenzhang@linux.microsoft.com>
Input: uinput - fix use-after-free of FF requests in ioctl handlers
This commit fixes a use-after-free issue in uinput ioctl handlers by holding
requests_lock during request lookup and usage. It introduces helper functions
such as uinput_ff_request_end() to safely encapsulate the request completion
logic under the spinlock.
Link: https://lore.kernel.org/all/20240521113619.2092-1-hdanton@sina.com/
> diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
> index d32fa4b508fc5..1a294f4e941b8 100644
> --- a/drivers/input/misc/uinput.c
> +++ b/drivers/input/misc/uinput.c
[ ... ]
> +static int uinput_ff_request_end(struct uinput_device *udev,
> + unsigned int id, unsigned int code, int retval)
> +{
> + struct uinput_request *req;
> +
> + guard(spinlock)(&udev->requests_lock);
> +
> + req = uinput_request_find(udev, id);
> + if (!req || req->code != code)
> + return -EINVAL;
> +
> + if (code == UI_FF_UPLOAD && !req->u.upload.effect)
> + return -EINVAL;
> +
> + req->retval = retval;
> + complete(&req->done);
[Severity: Low]
Does this code leave a data race on req->retval with the submitter?
Looking at uinput_request_submit(), the submitter reads request->retval
without holding requests_lock:
drivers/input/misc/uinput.c:uinput_request_submit() {
...
if (!wait_for_completion_timeout(&request->done, 30 * HZ)) {
retval = -ETIMEDOUT;
goto out;
}
retval = request->retval;
...
}
If the completion is triggered by uinput_flush_requests() or if multiple
ioctls race to complete the same request, could the submitter wake up and
read request->retval outside of requests_lock concurrently with this write?
Should this use READ_ONCE()/WRITE_ONCE() or extend the lock to prevent
undefined behavior and KCSAN warnings?
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261013051553.71887-1-cenzhang@linux.microsoft.com?part=1
prev parent reply other threads:[~2026-10-13 5:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 5:15 [PATCH] Input: uinput - fix use-after-free of FF requests in ioctl handlers Cen Zhang (Microsoft)
2026-10-13 5:28 ` 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-168999@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cenzhang@linux.microsoft.com \
--cc=dmitry.torokhov@gmail.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