Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rik van Riel" <riel@surriel.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH] input/evdev: move kill_fasync() outside buffer_lock to fix SOFTIRQ deadlock
Date: Thu, 14 May 2026 07:06:46 +0000	[thread overview]
Message-ID: <20260514070647.3D728C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260513115000.77ec5975@fangorn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Moving kill_fasync() outside of client->buffer_lock does not resolve the lock ordering violation because the function is still executing under dev->event_lock.
--

commit 803cd2c3ce0ada2c1fe4625fcbef594cb58290eb
Author: Rik van Riel <riel@surriel.com>

input/evdev: move kill_fasync() outside buffer_lock to fix SOFTIRQ deadlock

This commit attempts to fix a SOFTIRQ-safe to SOFTIRQ-unsafe lock inversion
by moving the kill_fasync() call outside of the client->buffer_lock.

> diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
> --- a/drivers/input/evdev.c
> +++ b/drivers/input/evdev.c
[ ... ]
> @@ -280,9 +278,11 @@ static void evdev_pass_values(struct evdev_client *client,
>  
>  	spin_unlock(&client->buffer_lock);
>  
> -	if (wakeup)
> +	if (wakeup) {
> +		kill_fasync(&client->fasync, SIGIO, POLL_IN);
>  		wake_up_interruptible_poll(&client->wait,
>  			EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM);
> +	}
>  }

Does this completely resolve the lock ordering violation?

While kill_fasync() is now outside of client->buffer_lock, evdev_pass_values()
is called from evdev_events(), which is invoked by the input core in
input_pass_values().

During this dispatch, the input core strictly holds dev->event_lock:

drivers/input/input.c:input_pass_values() {
    ...
    rcu_read_lock();
    spin_lock_irqsave(&dev->event_lock, flags);
    ...
    handler->events(handle, vals, count);
    ...
    spin_unlock_irqrestore(&dev->event_lock, flags);
}

Since dev->event_lock is also an IRQ/SOFTIRQ-safe spinlock, does this
just shift the problem so we still have a dev->event_lock -> fa_lock
inversion?

Would it make sense to defer the kill_fasync() call entirely outside
the event lock context, perhaps by using irq_work?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260513115000.77ec5975@fangorn?part=1

      parent reply	other threads:[~2026-05-14  7:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 15:50 [PATCH] input/evdev: move kill_fasync() outside buffer_lock to fix SOFTIRQ deadlock Rik van Riel
2026-05-13 20:01 ` Dmitry Torokhov
2026-05-14 13:06   ` Rik van Riel
2026-05-14  7:06 ` 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=20260514070647.3D728C2BCB7@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=riel@surriel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox