From patchwork Mon Sep 21 16:31:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309391 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=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 5FF95C43466 for ; Mon, 21 Sep 2020 16:51:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 251F320874 for ; Mon, 21 Sep 2020 16:51:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600707105; bh=V1vuWQoKtYsuwretsQckiGBX277MipPxgMK4O2Srd/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ypMGgYV2FzKsUJLJjS7QgUrY8IWYGSEfFTpqkBJBsP2iwJEgg2hdU2u9NvMCv3+Bh HE8CtKGQHuwHciPo7s6GJtm31Plx619O5Ji6mWvMLMLJ4z/FRnvv14yag1TPRs49HG iqwqqfzd+y5xSSeUe7R4tSm7twB2gK2YvIq09n6s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727517AbgIUQvo (ORCPT ); Mon, 21 Sep 2020 12:51:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:59156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730024AbgIUQuf (ORCPT ); Mon, 21 Sep 2020 12:50:35 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7B54C23718; Mon, 21 Sep 2020 16:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600707035; bh=V1vuWQoKtYsuwretsQckiGBX277MipPxgMK4O2Srd/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XwjeQ11F1bheH9b2Vq8ezlt08RAUJ+DD/F5V8UClla/rVh8mh2CGoFQ5X+hwFKi0+ SwNqpT3TI++4ZQn6MgxoqJaPSHeRdQL5aPBy97u8QdFiTHxA1Hq07JbzZbUCd4AYVz OFRmTVaGLe3cbnCImOEhHQTe93gmZg85V9pvQGLU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum , syzbot+be5b5f86a162a6c281e6@syzkaller.appspotmail.com Subject: [PATCH 5.4 54/72] usblp: fix race between disconnect() and read() Date: Mon, 21 Sep 2020 18:31:33 +0200 Message-Id: <20200921163124.451821295@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921163121.870386357@linuxfoundation.org> References: <20200921163121.870386357@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Oliver Neukum commit 9cdabcb3ef8c24ca3a456e4db7b012befb688e73 upstream. 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 Link: https://lore.kernel.org/r/20200917103427.15740-1-oneukum@suse.com Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/usblp.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -827,6 +827,11 @@ static ssize_t usblp_read(struct file *f if (rv < 0) return rv; + if (!usblp->present) { + count = -ENODEV; + goto done; + } + if ((avail = usblp->rstatus) < 0) { printk(KERN_ERR "usblp%d: error %d reading from printer\n", usblp->minor, (int)avail);