Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3999894ybg; Fri, 25 Oct 2019 11:54:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkfE/SPs8Vin7RUprGhgM2ncSUzhURcs4T+Gx/2Y8O72IJItDXbq6wsdbL0pt8PN48VBfW X-Received: by 2002:a05:6402:1acd:: with SMTP id ba13mr5539693edb.141.1572029684283; Fri, 25 Oct 2019 11:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572029684; cv=none; d=google.com; s=arc-20160816; b=O72btH6JYwqrX1iZJL/2FDyoKdD/j7KGy9WcHjobg9UKPMehbZKjjadhUMhxPZepI4 wotPQZxuhulVuXjCWGEhXReS8F7kL2ypV1SATlGGGGJ93xUEBJFXNFEUOukCeQXLaPx1 9cXIJzHAVOckqpehFAVjavYdlvG7EEF6bMocvFH4N2TvZdalmoneZNOyyf7XsOGNL1ck BcQod420dQFKjYEY4HMfL7BsCL+VU2n28HDxEBOYn//ehyHG98aV7VtduOZS4BORiiCC nh8dz8Eu4x5p6L8WznqRHmykN4LJl6LnsLOT+ziGkI+t5bOQGfVcfGS4cSaqm5HxW/4L baMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zIsOYlF+Hfsx0uQ6HDxs/ZLm/Efmg1cPtI+tKoRa+Ng=; b=gsy2vukCqatvPnOQExUIkSgW8XbqVLbGgGSDVqJWxkDutpDAjiyES3GFvktWekzkBJ MPZVwTLnjKA5pvRcDOEZC1PWDdwW8Bsj7oAhfaphj2VWdiBlKFEhdx1uKnH4Z2C1YzOr eeH6iQOqM2MPLWex22Nx467Xd/Hmfkx9yGszel4KrJd3dzGmwmXKhUyYJmL33hV7VY8O H7yuvNVr64C2tRX55p+9HyVIVFZ62pSmK9/LgyoKyyi6I/DP1W83cfMlJL6ai0Ao0S9B Qu2KwBVwIhX0wbkjOqg2G+3l9BhYptkWPO4GntIp63NmJTx1m8pRVrr5uhvElWZEuYEI gI2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fwQs8Hts; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y56si1870768edd.275.2019.10.25.11.54.21; Fri, 25 Oct 2019 11:54:44 -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=@google.com header.s=20161025 header.b=fwQs8Hts; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504196AbfJXS4D (ORCPT + 99 others); Thu, 24 Oct 2019 14:56:03 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46021 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504187AbfJXS4A (ORCPT ); Thu, 24 Oct 2019 14:56:00 -0400 Received: by mail-pg1-f193.google.com with SMTP id r1so14759560pgj.12 for ; Thu, 24 Oct 2019 11:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zIsOYlF+Hfsx0uQ6HDxs/ZLm/Efmg1cPtI+tKoRa+Ng=; b=fwQs8HtsbJC9TUXndyJvvRCSoM3v6KN1oAJTDP4jM6iDp7RiEChmUmkSfgcD9hrL32 dx4RALPc8vlvE5fZ/IQbv0hnM6XhYSw01JxzCQbLwgA0U4VbrnHk7p1AmgcsbwUweSnT FIjrOwiJF5IE7d1++6ArnJN3EZAH9wAePU20+J7wEZYcQUvvMQJPZX/t/m1/TWMAKDoX jvFHVfTgM5DBQG2eLVTWNpVQX4tJoaIP29Oapbf6H3Q+ogUaYIdWv8KQ/loM6fGpi6kt ERDAVhC7vZAsJ+NLuPJFLEkDkdKn0boNcGRQ5CpiNLbMVUBSG7stG68qLSb1aevbFfYI tkrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zIsOYlF+Hfsx0uQ6HDxs/ZLm/Efmg1cPtI+tKoRa+Ng=; b=V6kJCvicRCZaXBFKgzFxsbwc6CM826JjEh1LIg0ybRWHK/QWWx1I0wkWBf74jvF0RM SUixIi0PejUtQtn/dRioyuYKLN3JiHO9V/E4Mggqc/O8Nq9kvmTWmqI4Il8iVGKNTbBN awREPxoAvvLbfYacItuxp3hxdgMoqYLJZTUWr6glKs70vHnuPO0caTJ3bo99sfTmHiLZ Cap1/u6W4whuO6c1MLP3OqlGOAcrU1a6FAzYVmYjDmB+k7IVg2ETfbJ9VC7UopBkosrJ 68k319OaS23N2r6e1E7HTlgG/NQfJVzudpGz4txmN8VwhTHVoxJWBZIlYtlh/GGwEQFO wf6Q== X-Gm-Message-State: APjAAAXYT+kwx+K8OIcEBUrltKQJ43gYhMz5GZ8AyKThfYBWmJWQ7fES DBuVahah+MbBYAre6TiH1NrJp9ONOjCoKvi0La7TCA== X-Received: by 2002:a63:541e:: with SMTP id i30mr18286107pgb.130.1571943359247; Thu, 24 Oct 2019 11:55:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Konovalov Date: Thu, 24 Oct 2019 20:55:48 +0200 Message-ID: Subject: Re: divide error in dummy_timer To: Alan Stern Cc: syzbot , "Jacky . Cao @ sony . com" , Felipe Balbi , Chunfeng Yun , Greg Kroah-Hartman , LKML , USB list , syzkaller-bugs Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 24, 2019 at 7:57 PM Alan Stern wrote: > > On Thu, 24 Oct 2019, Andrey Konovalov wrote: > > > > Is this really the sort of thing we need to catch? It isn't a bug in > > > any existing kernel code, as far as I know. Maybe only gadgetfs and > > > configfs need to worry about it. > > > > Hi Alan, > > > > Do you mean that the gadget driver must ensure that the max packet > > size in the endpoint descriptor is not zero? Do HCDs rely on that? I > > can add this check into the driver we use for USB fuzzing. > > Well, if there are any gadget drivers in the kernel which do set an > endpoint's maxpacket size to 0, they should be fixed. I'm not aware of > any. > > Of course, gadget drivers in userspace are always suspect. That's why > I suggested having gadgetfs and configfs perform this check. Even so > it's not really a _security_ risk, because only the superuser is > allowed to run a userspace gadget driver. (Although obviously it is > better to have a clean failure than to crash the system when a buggy > program runs with superuser privileges.) > > Yes, HCDs do depend on endpoints having reasonable maxpacket values. I > suppose the core should check for this. Currently we check for values > that are too large or invalid in other ways (like high-speed bulk > endpoints with maxpacket != 512), but we don't check for 0. Oh, I think I've confused the terms here. I meant to ask about UDCs. The question is whether it's OK to try and emulate a gadget with maxpacket = 0 on a board with a hardware UDC? Or can it cause issues? The fact that HCDs must ensure correct maxpacket values of course makes sense. > > In fact, that sounds like a much better solution to the problem > overall. Let's see if this patch fixes the bug... > > Alan Stern > > #syz test: https://github.com/google/kasan.git 22be26f7 > > drivers/usb/core/config.c | 5 +++++ > 1 file changed, 5 insertions(+) > > Index: usb-devel/drivers/usb/core/config.c > =================================================================== > --- usb-devel.orig/drivers/usb/core/config.c > +++ usb-devel/drivers/usb/core/config.c > @@ -348,6 +348,11 @@ static int usb_parse_endpoint(struct dev > > /* Validate the wMaxPacketSize field */ > maxp = usb_endpoint_maxp(&endpoint->desc); > + if (maxp == 0) { > + dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has wMaxPacketSize 0, skipping\n", > + cfgno, inum, asnum, d->bEndpointAddress); > + goto skip_to_next_endpoint_or_interface_descriptor; > + } > > /* Find the highest legal maxpacket size for this endpoint */ > i = 0; /* additional transactions per microframe */ >