Linux USB
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Niels Dossche <dossche.niels@gmail.com>, linux-usb@vger.kernel.org
Cc: Valentina Manea <valentina.manea.m@gmail.com>,
	Shuah Khan <shuah@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] usb: usbip: add missing device lock on tweak configuration cmd
Date: Tue, 12 Apr 2022 14:07:20 -0600	[thread overview]
Message-ID: <24cca71b-cce7-74ea-7a64-975baa2f1be9@linuxfoundation.org> (raw)
In-Reply-To: <0fccca9a-c11b-fc26-0d01-606c2fa60dc9@gmail.com>

On 4/12/22 2:01 PM, Niels Dossche wrote:
> On 4/12/22 21:45, Shuah Khan wrote:
>> On 4/12/22 10:50 AM, Niels Dossche wrote:
>>> The function documentation of usb_set_configuration says that its
>>> callers should hold the device lock. This lock is held for all
>>> callsites except tweak_set_configuration_cmd. The code path can be
>>> executed for example when attaching a remote USB device.
>>> The solution is to surround the call by the device lock.
>>>
>>> This bug was found using my experimental own-developed static analysis
>>> tool, which reported the missing lock on v5.17.2. I manually verified
>>> this bug report by doing code review as well. I runtime checked that
>>> the required lock is not held. I compiled and runtime tested this on
>>> x86_64 with a USB mouse. After applying this patch, my analyser no
>>> longer reports this potential bug.
>>>
>>
>> How did you run-time check that the lock isn't held? Also x86_64 with a
>> USB mouse - did you test it over loopback?
> 
> I checked the lock isn't held with lockdep_assert_not_held and also by
> checking the return value of usb_trylock_device to be equal to 1 in my testing.
> I checked my USB mouse over loopback yes, binding the mouse for remote use and
> attaching on loopback.
> 

Great. Thank you for a detailed answer.

> 
>>
>>> Fixes: 2c8c98158946 ("staging: usbip: let client choose device configuration")
>>> Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
>>> ---
>>>

>>
>> Looks good to me with the above questions answered.
>>
>> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
>>
>> Greg, please pick this patch up.
>>

thanks,
-- Shuah


      reply	other threads:[~2022-04-12 20:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 16:50 [PATCH] usb: usbip: add missing device lock on tweak configuration cmd Niels Dossche
2022-04-12 19:45 ` Shuah Khan
2022-04-12 20:01   ` Niels Dossche
2022-04-12 20:07     ` Shuah Khan [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=24cca71b-cce7-74ea-7a64-975baa2f1be9@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=dossche.niels@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=valentina.manea.m@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox