Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1049418ybp; Thu, 17 Oct 2019 07:20:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyY53erxXoMfFppxDGrIRvK1Nj5neEFeVdVsxQqZi9iZ5egHfiWtR6lowRmYPIeTAog0btm X-Received: by 2002:aa7:d908:: with SMTP id a8mr4061216edr.49.1571322054856; Thu, 17 Oct 2019 07:20:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571322054; cv=none; d=google.com; s=arc-20160816; b=KHor9be5pob5JqjmpxBMLy+GBVWBzQUtB8SzeLkzUtuqVi9XTAtCSsJIJMdhN1RKdy QxAbtaUp95sj0KL5PfRHgvfw2VTRhr9fDtYAi17ntJ5/5S1ei65y4qWMhOpLzKL6OhIV du1pMhJ2mUdRcoXaToenqngk8Gda1oY6FcoLM5EAsj3qkA0xNnI7B1+YXl4fwVTw0yB0 lJ5VEgljAerUi4jmddXNiAtRoPWiyoDVJriql+taMmAw5LVvYx4EuSYFmTaaJ8NatMyz rryyaPPqheKj5C6pv4w8IPDYEh8wm695UZikIUR0UVqDNfaR8tTvIEPaycj/WACudxEG KaEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TOYRrKOhjlU+F8bSwhxgeBxOgEphAbdJyyM0Yc8SoSw=; b=TJZOXh+4k3dSZn3FE9qn0snK+aaMQtK5HYhgrLzcc5oz3WZ4v8hox4C0rDNYb/Hi64 B7IuU+1L2z6FU5Mnb17MNsGiMTxVQuW/PFYyZTrWXUgMvJi9ap9kvKwDh4XGG1L8/Q4a cEg+6rXdS0aJZuqWyZ3b02r2Eu3EbLt6A/6i7tE5OsVAijPxCSCipqm/DjA9iy3GvSbT PBVb9grqKeM46tb/VI3EDLjxHtdOKtJ1GfECpM/9EZi5atniDjduS08jNJttI43e9g3i iX2YwrPFk4EHpyPt+jxTnj40gCagqOTl/M7ewx/itXOliY30UIqC8XBOA4BKM9ah89q8 gZxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r5hphM52; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w14si1546783edx.197.2019.10.17.07.20.30; Thu, 17 Oct 2019 07:20:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r5hphM52; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395073AbfJPVys (ORCPT + 99 others); Wed, 16 Oct 2019 17:54:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:44614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395025AbfJPVyf (ORCPT ); Wed, 16 Oct 2019 17:54:35 -0400 Received: from localhost (unknown [192.55.54.58]) (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 7B3C421A4C; Wed, 16 Oct 2019 21:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571262874; bh=fruldeb33iN9zTBskPGOhUUlHhwi0U+9Kdn0xTmWzyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r5hphM52kbgoEOYe0FCm3l4ObRII5BD9Ih+0ZQNuR4hKGzICLiyVMRbQSmshGCjrK yICEqJe0vBUUTH0Wbb8itFPfracbMbkSQG6Tk2q8mle4nB04of2JT9OMBAvB6NzAlr 2cdOqcpYNuRMLCVYyJTXrWf+8kZQ3e8dIz4ne0pQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Tomoki Sekiyama , syzbot+b24d736f18a1541ad550@syzkaller.appspotmail.com Subject: [PATCH 4.9 38/92] USB: yurex: Dont retry on unexpected errors Date: Wed, 16 Oct 2019 14:50:11 -0700 Message-Id: <20191016214829.499578660@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214759.600329427@linuxfoundation.org> References: <20191016214759.600329427@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alan Stern commit 32a0721c6620b77504916dac0cea8ad497c4878a upstream. According to Greg KH, it has been generally agreed that when a USB driver encounters an unknown error (or one it can't handle directly), it should just give up instead of going into a potentially infinite retry loop. The three codes -EPROTO, -EILSEQ, and -ETIME fall into this category. They can be caused by bus errors such as packet loss or corruption, attempting to communicate with a disconnected device, or by malicious firmware. Nowadays the extent of packet loss or corruption is negligible, so it should be safe for a driver to give up whenever one of these errors occurs. Although the yurex driver handles -EILSEQ errors in this way, it doesn't do the same for -EPROTO (as discovered by the syzbot fuzzer) or other unrecognized errors. This patch adjusts the driver so that it doesn't log an error message for -EPROTO or -ETIME, and it doesn't retry after any errors. Reported-and-tested-by: syzbot+b24d736f18a1541ad550@syzkaller.appspotmail.com Signed-off-by: Alan Stern CC: Tomoki Sekiyama CC: Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.1909171245410.1590-100000@iolanthe.rowland.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/yurex.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/usb/misc/yurex.c +++ b/drivers/usb/misc/yurex.c @@ -136,6 +136,7 @@ static void yurex_interrupt(struct urb * switch (status) { case 0: /*success*/ break; + /* The device is terminated or messed up, give up */ case -EOVERFLOW: dev_err(&dev->interface->dev, "%s - overflow with length %d, actual length is %d\n", @@ -144,12 +145,13 @@ static void yurex_interrupt(struct urb * case -ENOENT: case -ESHUTDOWN: case -EILSEQ: - /* The device is terminated, clean up */ + case -EPROTO: + case -ETIME: return; default: dev_err(&dev->interface->dev, "%s - unknown status received: %d\n", __func__, status); - goto exit; + return; } /* handle received message */ @@ -181,7 +183,6 @@ static void yurex_interrupt(struct urb * break; } -exit: retval = usb_submit_urb(dev->urb, GFP_ATOMIC); if (retval) { dev_err(&dev->interface->dev, "%s - usb_submit_urb failed: %d\n",