All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2 3/4] Input: call handler->start() when uninhibiting device
Date: Mon, 03 Aug 2026 01:27:57 +0000	[thread overview]
Message-ID: <20260803012757.BBB1E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803005210.1251102-3-dmitry.torokhov@gmail.com>

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

Pre-existing issues:
- [High] Sysfs uninhibiting a device can race with device unregistration, causing `dev->open()` to be called on a hardware device that is being destroyed.
--

--- Patch [3]: [PATCH v2 3/4] Input: call handler->start() when uninhibiting device ---
commit 7812e6dd22b71b48fc822b6545778a4eb30f8e35
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: call handler->start() when uninhibiting device

When an input device is uninhibited, the driver is re-opened. This patch
ensures that complex handlers are also notified to re-synchronize their
state by calling handler->start() for each open handle.

> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index e4f8c2067b84d..47886a394c6b8 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -1806,6 +1806,7 @@ static int input_inhibit_device(struct input_dev *dev)
>  
>  static int input_uninhibit_device(struct input_dev *dev)
>  {
> +	struct input_handle *handle;
>  	int error;
>  
>  	guard(mutex)(&dev->mutex);

[Severity: High]
This is a pre-existing issue, but does this function open a race condition
with input_unregister_device() by missing a check for dev->going_away?

When a driver calls input_unregister_device(), the core sets
dev->going_away = true in input_disconnect_device() and releases
dev->mutex.

If a concurrent sysfs write to the inhibited attribute executes
input_uninhibit_device(), it acquires dev->mutex here.

Because it lacks a dev->going_away check (unlike input_open_device()), it
proceeds to set dev->inhibited = false and calls dev->open() on a dying
device.

Can this lead to a use-after-free or hardware state corruption if the
driver has already freed its IO mappings or IRQs during unregistration?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260803005210.1251102-1-dmitry.torokhov@gmail.com?part=3

  reply	other threads:[~2026-08-03  1:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03  0:52 [PATCH v2 1/4] Input: ensure device is ready before delivering events Dmitry Torokhov
2026-08-03  0:52 ` [PATCH v2 2/4] Input: clear inhibited flag before re-opening device on uninhibit Dmitry Torokhov
2026-08-03  1:18   ` sashiko-bot
2026-08-03  2:08     ` Dmitry Torokhov
2026-08-03  0:52 ` [PATCH v2 3/4] Input: call handler->start() when uninhibiting device Dmitry Torokhov
2026-08-03  1:27   ` sashiko-bot [this message]
2026-08-03  0:52 ` [PATCH v2 4/4] Input: defer handler's start() until device is opened Dmitry Torokhov

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=20260803012757.BBB1E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --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 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.