All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Vicki Pfau <vi@endrift.com>
Cc: linux-input@vger.kernel.org
Subject: Re: [PATCH 2/2] Input: uinput - Release mutex while unregistering input device
Date: Fri, 8 Dec 2023 19:58:28 +0000	[thread overview]
Message-ID: <ZXN1ZFYZBekXryha@google.com> (raw)
In-Reply-To: <20231207063406.556770-3-vi@endrift.com>

Hi Vicki,

On Wed, Dec 06, 2023 at 10:34:06PM -0800, Vicki Pfau wrote:
> Any pending requests may be holding a mutex from its own subsystem, e.g.
> evdev, while waiting to be able to claim the uinput device mutex.
> However, unregistering the device may try to claim that mutex, leading
> to a deadlock. To prevent this from happening, we need to temporarily
> give up the lock before calling input_unregister_device.

I do not think we can simply give up the lock, the whole thing with
UI_DEV_DESTROY allowing reusing connection to create a new input device
was a huge mistake because if you try to do UI_DEV_CREATE again on
the same fd you'll end up reusing whatever is in udev instance,
including the state and the mutex, and will make a huge mess.

I think the only reasonable way forward is change the driver so that no
ioctls are accepted after UI_DEV_DESTROY and then start untangling the
locking issues (possibly by dropping the lock on destroy after setting
the status - I think you will not observe the lockups you mention if
your application will stop using UI_DEV_DESTROY and simply closes the
fd).

> 
> Fixes: e8b95728f724 ("Input: uinput - avoid FF flush when destroying device")

This is not the commit that introduced the problem, it has been there
since forever.

Thanks.

-- 
Dmitry

  reply	other threads:[~2023-12-08 19:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07  6:34 [PATCH 0/2] Input: uinput - Multiple concurrency fixes in ff request handling Vicki Pfau
2023-12-07  6:34 ` [PATCH 1/2] Input: uinput - Allow uinput_request_submit wait interrupting Vicki Pfau
2023-12-08 19:32   ` Dmitry Torokhov
2023-12-09  3:24     ` Vicki Pfau
2023-12-15  3:04       ` Vicki Pfau
2024-01-12  1:37         ` Vi Pfau
2024-01-22  4:03         ` Dmitry Torokhov
2025-12-10  3:37           ` Vicki Pfau
2023-12-07  6:34 ` [PATCH 2/2] Input: uinput - Release mutex while unregistering input device Vicki Pfau
2023-12-08 19:58   ` Dmitry Torokhov [this message]
2023-12-09  3:24     ` Vicki Pfau

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=ZXN1ZFYZBekXryha@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=vi@endrift.com \
    /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.