From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Oliver Neukum <oneukum@suse.com>
Cc: jkosina@suse.com, linux-input@vger.kernel.org,
Alan Stern <stern@rowland.harvard.edu>,
USB list <linux-usb@vger.kernel.org>
Subject: Re: doubts concerning locking and signals in input_register_device()
Date: Thu, 23 Jun 2022 17:46:34 -0700 [thread overview]
Message-ID: <YrUJagnenN9Zv88n@google.com> (raw)
In-Reply-To: <d7f6c510-d367-718c-64b2-e368ef5486fc@suse.com>
Hi Oliver,
On Mon, Jun 20, 2022 at 02:48:01PM +0200, Oliver Neukum wrote:
> Hi,
>
> I am looking at this code in input_register_device():
>
> error = mutex_lock_interruptible(&input_mutex);
> if (error)
> goto err_device_del;
>
> The problem is not the scope of the locking, but how the
> lock is taken.
> AFAICT this code will be called in the context of an
> ordinary task when you set a configuration through usbfs.
> usb_set_configuration() has to probe all interfaces
> of a device under its new configuration and does not
> handle -EINTR, which input_register_device() will
> return when a signal interrupts taking the mutex.
>
> Hence there is a window for a race during which a
> mistimed harmless signal will cause a failure of probe()
>
> Now, as this is fairly core code I'd rather ask what
> you think before I make the simple fix of taking
> the mutex with uninterruptible sleep. What is to be done?
The reason I believe we should be using interruptible or killable
versions of locking is to give a chance to bail (with Ctrl-C or kill or
whatever) in case the system is wedged for some reason.
Where would this mistimed harmless signal come from unless user actually
tries to interrupt module loading/driver binding/sysfs access?
Thanks.
--
Dmitry
next prev parent reply other threads:[~2022-06-24 0:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 12:48 doubts concerning locking and signals in input_register_device() Oliver Neukum
2022-06-24 0:46 ` Dmitry Torokhov [this message]
2022-07-06 8:54 ` Oliver Neukum
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=YrUJagnenN9Zv88n@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=jkosina@suse.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=stern@rowland.harvard.edu \
/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;
as well as URLs for NNTP newsgroup(s).