stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] usbip: vudc synchronize sysfs code paths" failed to apply to 4.14-stable tree
@ 2021-04-11  7:20 gregkh
  2021-04-23 19:44 ` Sudip Mukherjee
  0 siblings, 1 reply; 5+ messages in thread
From: gregkh @ 2021-04-11  7:20 UTC (permalink / raw)
  To: skhan, gregkh; +Cc: stable


The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From bd8b82042269a95db48074b8bb400678dbac1815 Mon Sep 17 00:00:00 2001
From: Shuah Khan <skhan@linuxfoundation.org>
Date: Mon, 29 Mar 2021 19:36:50 -0600
Subject: [PATCH] usbip: vudc synchronize sysfs code paths

Fuzzing uncovered race condition between sysfs code paths in usbip
drivers. Device connect/disconnect code paths initiated through
sysfs interface are prone to races if disconnect happens during
connect and vice versa.

Use sysfs_lock to protect sysfs paths in vudc.

Cc: stable@vger.kernel.org
Reported-and-tested-by: syzbot+a93fba6d384346a761e3@syzkaller.appspotmail.com
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/caabcf3fc87bdae970509b5ff32d05bb7ce2fb15.1616807117.git.skhan@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
index c8eeabdd9b56..2bc428f2e261 100644
--- a/drivers/usb/usbip/vudc_dev.c
+++ b/drivers/usb/usbip/vudc_dev.c
@@ -572,6 +572,7 @@ static int init_vudc_hw(struct vudc *udc)
 	init_waitqueue_head(&udc->tx_waitq);
 
 	spin_lock_init(&ud->lock);
+	mutex_init(&ud->sysfs_lock);
 	ud->status = SDEV_ST_AVAILABLE;
 	ud->side = USBIP_VUDC;
 
diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
index 7383a543c6d1..f7633ee655a1 100644
--- a/drivers/usb/usbip/vudc_sysfs.c
+++ b/drivers/usb/usbip/vudc_sysfs.c
@@ -112,6 +112,7 @@ static ssize_t usbip_sockfd_store(struct device *dev,
 		dev_err(dev, "no device");
 		return -ENODEV;
 	}
+	mutex_lock(&udc->ud.sysfs_lock);
 	spin_lock_irqsave(&udc->lock, flags);
 	/* Don't export what we don't have */
 	if (!udc->driver || !udc->pullup) {
@@ -187,6 +188,8 @@ static ssize_t usbip_sockfd_store(struct device *dev,
 
 		wake_up_process(udc->ud.tcp_rx);
 		wake_up_process(udc->ud.tcp_tx);
+
+		mutex_unlock(&udc->ud.sysfs_lock);
 		return count;
 
 	} else {
@@ -207,6 +210,7 @@ static ssize_t usbip_sockfd_store(struct device *dev,
 	}
 
 	spin_unlock_irqrestore(&udc->lock, flags);
+	mutex_unlock(&udc->ud.sysfs_lock);
 
 	return count;
 
@@ -216,6 +220,7 @@ static ssize_t usbip_sockfd_store(struct device *dev,
 	spin_unlock_irq(&udc->ud.lock);
 unlock:
 	spin_unlock_irqrestore(&udc->lock, flags);
+	mutex_unlock(&udc->ud.sysfs_lock);
 
 	return ret;
 }


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: FAILED: patch "[PATCH] usbip: vudc synchronize sysfs code paths" failed to apply to 4.14-stable tree
  2021-04-11  7:20 FAILED: patch "[PATCH] usbip: vudc synchronize sysfs code paths" failed to apply to 4.14-stable tree gregkh
@ 2021-04-23 19:44 ` Sudip Mukherjee
  2021-04-23 19:59   ` Shuah Khan
  0 siblings, 1 reply; 5+ messages in thread
From: Sudip Mukherjee @ 2021-04-23 19:44 UTC (permalink / raw)
  To: gregkh; +Cc: skhan, stable

Hi Greg,

On Sun, Apr 11, 2021 at 09:20:12AM +0200, gregkh@linuxfoundation.org wrote:
> 
> The patch below does not apply to the 4.14-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
> 
> thanks,
> 
> greg k-h
> 
> ------------------ original commit in Linus's tree ------------------
> 
> From bd8b82042269a95db48074b8bb400678dbac1815 Mon Sep 17 00:00:00 2001

Just wondering if you have missed this one as I am not seeing it in your
queue for 4.14-stable but can see in 4.9-stable queue. And this will apply
directly on top of your 4.14-stable queue.


--
Regards
Sudip

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: FAILED: patch "[PATCH] usbip: vudc synchronize sysfs code paths" failed to apply to 4.14-stable tree
  2021-04-23 19:44 ` Sudip Mukherjee
@ 2021-04-23 19:59   ` Shuah Khan
  2021-04-24 14:45     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Shuah Khan @ 2021-04-23 19:59 UTC (permalink / raw)
  To: Sudip Mukherjee, gregkh; +Cc: stable, Tom Seewald, Shuah Khan

On 4/23/21 1:44 PM, Sudip Mukherjee wrote:
> Hi Greg,
> 
> On Sun, Apr 11, 2021 at 09:20:12AM +0200, gregkh@linuxfoundation.org wrote:
>>
>> The patch below does not apply to the 4.14-stable tree.
>> If someone wants it applied there, or to any other stable or longterm
>> tree, then please email the backport, including the original git commit
>> id to <stable@vger.kernel.org>.
>>
>> thanks,
>>
>> greg k-h
>>
>> ------------------ original commit in Linus's tree ------------------
>>
>>  From bd8b82042269a95db48074b8bb400678dbac1815 Mon Sep 17 00:00:00 2001
> 
> Just wondering if you have missed this one as I am not seeing it in your
> queue for 4.14-stable but can see in 4.9-stable queue. And this will apply
> directly on top of your 4.14-stable queue.
> 
> 
This patch needed some work. Tom sent in the patch.

https://lore.kernel.org/stable/d2cc4517-4790-b3a7-eec0-16fe06ea22eb@linuxfoundation.org/

thanks,
-- Shuah


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: FAILED: patch "[PATCH] usbip: vudc synchronize sysfs code paths" failed to apply to 4.14-stable tree
  2021-04-23 19:59   ` Shuah Khan
@ 2021-04-24 14:45     ` Greg KH
  2021-04-26 15:39       ` Shuah Khan
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2021-04-24 14:45 UTC (permalink / raw)
  To: Shuah Khan; +Cc: Sudip Mukherjee, stable, Tom Seewald

On Fri, Apr 23, 2021 at 01:59:18PM -0600, Shuah Khan wrote:
> On 4/23/21 1:44 PM, Sudip Mukherjee wrote:
> > Hi Greg,
> > 
> > On Sun, Apr 11, 2021 at 09:20:12AM +0200, gregkh@linuxfoundation.org wrote:
> > > 
> > > The patch below does not apply to the 4.14-stable tree.
> > > If someone wants it applied there, or to any other stable or longterm
> > > tree, then please email the backport, including the original git commit
> > > id to <stable@vger.kernel.org>.
> > > 
> > > thanks,
> > > 
> > > greg k-h
> > > 
> > > ------------------ original commit in Linus's tree ------------------
> > > 
> > >  From bd8b82042269a95db48074b8bb400678dbac1815 Mon Sep 17 00:00:00 2001
> > 
> > Just wondering if you have missed this one as I am not seeing it in your
> > queue for 4.14-stable but can see in 4.9-stable queue. And this will apply
> > directly on top of your 4.14-stable queue.
> > 
> > 
> This patch needed some work. Tom sent in the patch.
> 
> https://lore.kernel.org/stable/d2cc4517-4790-b3a7-eec0-16fe06ea22eb@linuxfoundation.org/

Ok, I missed that.

Can I get a set of patches just for 4.14.y now?  Mixing them in the
series like that is a guarantee that someone will mess up.  And I did.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: FAILED: patch "[PATCH] usbip: vudc synchronize sysfs code paths" failed to apply to 4.14-stable tree
  2021-04-24 14:45     ` Greg KH
@ 2021-04-26 15:39       ` Shuah Khan
  0 siblings, 0 replies; 5+ messages in thread
From: Shuah Khan @ 2021-04-26 15:39 UTC (permalink / raw)
  To: Greg KH, Tom Seewald; +Cc: Sudip Mukherjee, stable, Shuah Khan

On 4/24/21 8:45 AM, Greg KH wrote:
> On Fri, Apr 23, 2021 at 01:59:18PM -0600, Shuah Khan wrote:
>> On 4/23/21 1:44 PM, Sudip Mukherjee wrote:
>>> Hi Greg,
>>>
>>> On Sun, Apr 11, 2021 at 09:20:12AM +0200, gregkh@linuxfoundation.org wrote:
>>>>
>>>> The patch below does not apply to the 4.14-stable tree.
>>>> If someone wants it applied there, or to any other stable or longterm
>>>> tree, then please email the backport, including the original git commit
>>>> id to <stable@vger.kernel.org>.
>>>>
>>>> thanks,
>>>>
>>>> greg k-h
>>>>
>>>> ------------------ original commit in Linus's tree ------------------
>>>>
>>>>   From bd8b82042269a95db48074b8bb400678dbac1815 Mon Sep 17 00:00:00 2001
>>>
>>> Just wondering if you have missed this one as I am not seeing it in your
>>> queue for 4.14-stable but can see in 4.9-stable queue. And this will apply
>>> directly on top of your 4.14-stable queue.
>>>
>>>
>> This patch needed some work. Tom sent in the patch.
>>
>> https://lore.kernel.org/stable/d2cc4517-4790-b3a7-eec0-16fe06ea22eb@linuxfoundation.org/
> 
> Ok, I missed that.
> 
> Can I get a set of patches just for 4.14.y now?  Mixing them in the
> series like that is a guarantee that someone will mess up.  And I did.
> 

Yes. My bad asking Tom to send this as a series. :(

Thanks Sudip for catching this.

Tom, Please resend this patch tagging it for 4.14.y

https://lore.kernel.org/stable/d2cc4517-4790-b3a7-eec0-16fe06ea22eb@linuxfoundation.org/

This is the only patch that needed back-port for 4.14.x. Others are
already in 4.14.y.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-04-26 15:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-11  7:20 FAILED: patch "[PATCH] usbip: vudc synchronize sysfs code paths" failed to apply to 4.14-stable tree gregkh
2021-04-23 19:44 ` Sudip Mukherjee
2021-04-23 19:59   ` Shuah Khan
2021-04-24 14:45     ` Greg KH
2021-04-26 15:39       ` Shuah Khan

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).