From patchwork Mon Sep 21 16:28:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "gregkh@linuxfoundation.org" X-Patchwork-Id: 309480 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 82467C43466 for ; Mon, 21 Sep 2020 16:36:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44AE92399C for ; Mon, 21 Sep 2020 16:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706202; bh=nytHhs1yA1AvcsTxj5uamZxrJnbcOkR2fIPjetwmxlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=2VzbnszDSSszIodhOCwWqUNRSeQr+DKMTGlSGxT1Q1WMEoZdSrkayYMABCYmhgHZq Sv0BPG8zAWqOuqHuihMNSP/LsxgCXkdTot0pJ8amxP2dfhmGO0KVETZDFIOjQeu4zy hGCfGm2SRAVLKOVntMkldu6FWkWZddFu8LoT0+zM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728379AbgIUQgl (ORCPT ); Mon, 21 Sep 2020 12:36:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:36406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728988AbgIUQge (ORCPT ); Mon, 21 Sep 2020 12:36:34 -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 B40C1206B7; Mon, 21 Sep 2020 16:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706194; bh=nytHhs1yA1AvcsTxj5uamZxrJnbcOkR2fIPjetwmxlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=En6Wk2jM8hrsZsTq/LcR8lv1MKsgMJXB1+oKSOJs1if0npEY/fKyva+3KVZvMFPWI FSpqvE09r5vB9gSMe2sm5kVGH3RSIwj3tlWUVi/hRMM9ErfLvt2mMLmdirpxl9wXtB A0zXovUYJKzMg5G0Hz9VK2rT+pbaoHDA6Jcj++Jg= 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 4.9 65/70] usblp: fix race between disconnect() and read() Date: Mon, 21 Sep 2020 18:28:05 +0200 Message-Id: <20200921162038.103213836@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162035.136047591@linuxfoundation.org> References: <20200921162035.136047591@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 @@ -840,6 +840,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);