Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3998957ybg; Fri, 25 Oct 2019 11:53:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmA1hEY0JDVHrNNG2cTG7vy+gb/9hSzBL3zmgz9Uc/SGeotARCHTzHgut2SahzMyoytwD3 X-Received: by 2002:a17:906:1d45:: with SMTP id o5mr4999268ejh.250.1572029634276; Fri, 25 Oct 2019 11:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572029634; cv=none; d=google.com; s=arc-20160816; b=z3Fv13CjIe32paDi8iKKXghKyua8QQUEwuBa1qUW3OqpruN/8lYiWZmyD8aJ3RR9Cv qzn2IvC1f8t3+lB7ZFY7orbHl/Of6Y2honbQKTysLMHWVO8Y2oGO1WQZgpfdIwlCtAw1 1w/vb5fnotkKT+7ZzsmwpjOGHDy/X06TN/le/4QVaXM7KfaJgX+GMgLEBkE0Q5Sw/CW3 R8qOBehbXPR3HsQqDy88Vgnfkpuo3QpeevVUDkwak+2brWZFXr7ZVl6d3bxuhbgwiPFQ 7B0ZtV8jGYRifdhX2eC0k1a0nJTAeCXj1F4tjt/CneFub/GYj+KG7IP+wJ9x9pnFhUze GH5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=ql+37TFJKJqRfu8XU4Y7CApU8m+Jv3WEXChtxtv2g0o=; b=obaVuBo4YGuYH2kEe+pW8Nh/+b67oBbhB6f4FZp5yrMmK3GbDyK5ubaWdoo8Mp9Uck kkFHGauJ6wG29w5OVbytoFGWfqN9l30w+1BldUtic/xq0roHSVDvTraZCKCUI5Di/kQJ 8w4Wpux6xC0uRnrzWPSRHQtcDYjsXW3aFR7kL1m7KkDCZXfXdgoYTtcvxKV6s2/LOzhq eg8ochzqqt0jU06/ZgSLKTnfWGVLcQnwxF8D0fXOvTzzf+fo8xyNmYJJG7a+eZOefK4a oVhrsD2zplB5Cyv/KOht2iGj6MBTMM1xtlclXljWDLOxutCNXzwAspLuP/rwxN95Dzj0 33zQ== ARC-Authentication-Results: i=1; mx.google.com; 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 g4si1895985edb.41.2019.10.25.11.53.31; Fri, 25 Oct 2019 11:53: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; 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 S2437074AbfJXS6q (ORCPT + 99 others); Thu, 24 Oct 2019 14:58:46 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:59876 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S2390034AbfJXS6p (ORCPT ); Thu, 24 Oct 2019 14:58:45 -0400 Received: (qmail 5995 invoked by uid 2102); 24 Oct 2019 14:58:44 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 24 Oct 2019 14:58:44 -0400 Date: Thu, 24 Oct 2019 14:58:44 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: syzbot cc: Jacky.Cao@sony.com, , , , , Kernel development list , USB list , Subject: Re: divide error in dummy_timer In-Reply-To: <000000000000f6d5ed0595abe964@google.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 Oct 2019, syzbot wrote: > Hello, > > syzbot has tested the proposed patch but the reproducer still triggered > crash: > divide error in dummy_timer > Tested on: > > commit: 22be26f7 usb-fuzzer: main usb gadget fuzzer driver > git tree: https://github.com/google/kasan.git > console output: https://syzkaller.appspot.com/x/log.txt?x=17b3e44ce00000 > kernel config: https://syzkaller.appspot.com/x/.config?x=5fe29bc39eff9627 > dashboard link: https://syzkaller.appspot.com/bug?extid=8ab8bf161038a8768553 > compiler: gcc (GCC) 9.0.0 20181231 (experimental) > patch: https://syzkaller.appspot.com/x/patch.diff?x=15ea0a97600000 Okay, this error has a couple of different aspects. In particular, we don't want endpoints to have maxpacket = 0 on either the host side or the gadget side. (Note that it _is_ possible for the two sides to disagree about the maxpacket value, because the gadget driver can in theory provide different endpoint descriptors to the UDC driver and to the host.) So yes, the core should check the value in the endpoint descriptor, but also we have to watch out for invalid values coming from userspace gadget drivers. And not just in dummy-hcd; all UDCs are vulnerable. So let's try the patch below to handle the gadget side of things. Alan Stern #syz test: https://github.com/google/kasan.git 22be26f7 drivers/usb/gadget/udc/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) Index: usb-devel/drivers/usb/gadget/udc/core.c =================================================================== --- usb-devel.orig/drivers/usb/gadget/udc/core.c +++ usb-devel/drivers/usb/gadget/udc/core.c @@ -98,6 +98,17 @@ int usb_ep_enable(struct usb_ep *ep) if (ep->enabled) goto out; + /* UDC drivers can't handle endpoints with maxpacket size 0 */ + if (usb_endpoint_maxp(ep->desc) == 0) { + /* + * We should log an error message here, but we can't call + * dev_err() because there's no way to find the gadget + * given only ep. + */ + ret = -EINVAL; + goto out; + } + ret = ep->ops->enable(ep, ep->desc); if (ret) goto out;