From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 500C6C43461 for ; Thu, 17 Sep 2020 16:46:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EA5C21D7B for ; Thu, 17 Sep 2020 16:46:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600361164; bh=BxOPoOLZKwVlHnGJLNJtaYLxkgb9UrvfmZmQ3jzrPMQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=vFDA+7fjO4RuwmoEKDzLzhlaKKYVvo5+d5vMQIZXrrsNIHBQCZrWSFg1VGdMJo7j+ tVNorVE+x673mKbryJ/dmkzi95wmLhX5O20wt9fWzMPj8ccg69nRi7bYliJM21bjbh Q07yl3XfyvOTa75lfLwhJw2LSKvigIsqUmlAR2vA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728641AbgIQQpg (ORCPT ); Thu, 17 Sep 2020 12:45:36 -0400 Received: from forward2-smtp.messagingengine.com ([66.111.4.226]:47541 "EHLO forward2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728633AbgIQQpR (ORCPT ); Thu, 17 Sep 2020 12:45:17 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailforward.nyi.internal (Postfix) with ESMTP id 5F4121940046; Thu, 17 Sep 2020 12:44:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 17 Sep 2020 12:44:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=vM7MZw Jd3AhFbuG6zI5+IZRnlUM1rthnW5NePpx7/oo=; b=XIE1mikRfM1szwDc4nNYCM t5DxZOjdZeJFyZrbsuh9jzuugXkpew1YmJ7rQM+6aVQDKsfKo5NlDqEfZsc2K92x 46dsdKJM2m4x8v4L+28ujC0DRVVuERuXRJobSS+uCgFJYSAlBl7a2e+wUnjPMxrt rlXZwS4Dx90JZLJQYypMahF05gGOr2Hg/q20nR9b4k+0XpAINskYNvgCmuCOq1TX LpDRPP18dZYlVQVMq6eOEz2eh8cDf7wsuSVaXQ+Lbt/Mbi8eBfejvUo6s0eAvJbC fpQxS2Utl3E66gsyYUJeNkxBLu6cy/kEVEEFpp6gPskqLx5aFAa8hHYgm+bYmF8Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrtdeggddutdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefirhgvghcu mffjuceoghhrvghgmffjsehlihhnuhigfhhouhhnuggrthhiohhnrdhorhhgqeenucggtf frrghtthgvrhhnpeetvdelgeffgfdutdelvddvtdetffejtefgveevueeggfellefhveev feduueduvdenucfkphepkeefrdekiedrjeegrdeigeenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgrhgvgheskhhrohgrhhdrtghomh X-ME-Proxy: Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) by mail.messagingengine.com (Postfix) with ESMTPA id AA1BF3280065; Thu, 17 Sep 2020 12:44:54 -0400 (EDT) Date: Thu, 17 Sep 2020 18:45:27 +0200 From: Greg KH To: Oliver Neukum Cc: linux-usb@vger.kernel.org Subject: Re: [PATCH] usblp: fix race between disconnect() and read() Message-ID: <20200917164527.GA723130@kroah.com> References: <20200917103427.15740-1-oneukum@suse.com> <20200917114347.GA3436799@kroah.com> <1600344191.2424.44.camel@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1600344191.2424.44.camel@suse.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Thu, Sep 17, 2020 at 02:03:11PM +0200, Oliver Neukum wrote: > Am Donnerstag, den 17.09.2020, 13:43 +0200 schrieb Greg KH: > > On Thu, Sep 17, 2020 at 12:34:27PM +0200, Oliver Neukum wrote: > > > read() needs to check whether the device has been > > > disconnected before it tries to talk to the device. > > > > > > Signed-off-by: Oliver Neukum > > > Reported-by: syzbot+be5b5f86a162a6c281e6@syzkaller.appspotmail.com > > > --- > > > drivers/usb/class/usblp.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c > > > index 084c48c5848f..67cbd42421be 100644 > > > --- a/drivers/usb/class/usblp.c > > > +++ b/drivers/usb/class/usblp.c > > > @@ -827,6 +827,11 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo > > > if (rv < 0) > > > return rv; > > > > > > + if (!usblp->present) { > > > + count = -ENODEV; > > > + goto done; > > > + } > > > + > > > > What prevents ->present from not being changed right after this test? > > Hi, > > the mutex taken in > > rv = usblp_rwait_and_lock(usblp, !!(file->f_flags & O_NONBLOCK)); Ah, missed that, thanks. greg k-h