Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4002368ybg; Fri, 25 Oct 2019 11:57:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXHOipo4OryEK95k+O10uAmWkV8DrnaZeVbAirDiOnS9riX9+rd8o1oiUSYrJh+xLgvm55 X-Received: by 2002:a50:d7c9:: with SMTP id m9mr5726331edj.93.1572029828710; Fri, 25 Oct 2019 11:57:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572029828; cv=none; d=google.com; s=arc-20160816; b=DtjLWUoF6LJQ/T3E/hLE+TrL5609bhF6znN5lSW+1g+QLZ0TQtICZXe9HMKnVnOaxC I2/taTMaV5OarTSWa4VVpZ5iio4EcVk6/HhczWnsk3HPI12vEsaituuvTxhIdg1+5fjY tWKIcVHycIpebJ8wrQ8elcW99rAdg7lJLkMuB3tHwkKrD6KM0PboOQbLXU45DG/EAchA i9Hzx0co6Quw1oJooVMeAHEPLr4Ly0sSmBLN37LVXtaxUWmy6BzwR8axgIVr3nu0q9PL ow0ijvp+fcfY1+ZKoRcGchQz/gwwLtUzu+zwL7oBigG3PjtSDrH1EEoonGPSmec4Q93t +9Bg== 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=W8VSceHplZNRCuG+onWyNivkQdAlHs47rKR8ie1qaac=; b=SQci1Q0WFtQ+sOgfCxHwAm6sIEeMHIDxp5VTHzjQmPpVEIFjsm5jwGdOzVoQiz09WB gqjDFnDx+uy5+1a/U1ReFVCTQglpN0uQB3yunlu2soN4kiLTBtM+bMSDfd21feEeFsWr sjnv5ISGT/1PhioTI+UteTbkclyYb8bW6+cf/GFsKjwujnc9320zjaxP73ovn8kDTW1n qhPqjr08mlQQqf+QGxO4b3ByKdIbZIFPwjAxmyLPGc59l628DYAqZQU2AtwNaDyUpkK2 QEl8Ia7CRsF77TxPPZ41im8jubQiGxaiOXh+ycyVGJ+gAcDM6M84BYNx1haILBLIbkgh D6aw== 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 s21si1885294edm.311.2019.10.25.11.56.45; Fri, 25 Oct 2019 11:57:08 -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 S2437226AbfJXTRT (ORCPT + 99 others); Thu, 24 Oct 2019 15:17:19 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:59946 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S2437179AbfJXTRS (ORCPT ); Thu, 24 Oct 2019 15:17:18 -0400 Received: (qmail 6262 invoked by uid 2102); 24 Oct 2019 15:17:18 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 24 Oct 2019 15:17:18 -0400 Date: Thu, 24 Oct 2019 15:17:18 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Andrey Konovalov cc: syzbot , "Jacky . Cao @ sony . com" , Felipe Balbi , Chunfeng Yun , Greg Kroah-Hartman , LKML , USB list , syzkaller-bugs Subject: Re: divide error in dummy_timer In-Reply-To: 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, Andrey Konovalov wrote: > 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. It doesn't make any sense to have an endpoint with maxpacket = 0 -- either real or emulated. The USB spec doesn't prohibit them (probably an oversight), but such endpoints would be useless since it would not be possible to transfer any data to/from them. And as you surmised, it wouldn't be at all surprising for UDC drivers to crash (much like dummy-hcd does) when faced with an endpoint having maxpacket = 0. Best to rule out the possibility entirely. Alan Stern