All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: dmitry.torokhov@gmail.com
Cc: jkosina@suse.com, linux-input@vger.kernel.org,
	Alan Stern <stern@rowland.harvard.edu>,
	USB list <linux-usb@vger.kernel.org>
Subject: doubts concerning locking and signals in input_register_device()
Date: Mon, 20 Jun 2022 14:48:01 +0200	[thread overview]
Message-ID: <d7f6c510-d367-718c-64b2-e368ef5486fc@suse.com> (raw)

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?

	Regards
		Oliver

             reply	other threads:[~2022-06-20 12:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 12:48 Oliver Neukum [this message]
2022-06-24  0:46 ` doubts concerning locking and signals in input_register_device() Dmitry Torokhov
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=d7f6c510-d367-718c-64b2-e368ef5486fc@suse.com \
    --to=oneukum@suse.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jkosina@suse.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --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 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.