Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2566570pxv; Sat, 17 Jul 2021 17:45:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/wd66mVSN3NC0LVoP7jKTIw1j+e47PbOYgZTBG9jLUQJr6vYGcE2MgZYiidGFOBn/Jcme X-Received: by 2002:a17:906:3006:: with SMTP id 6mr20343771ejz.73.1626569155664; Sat, 17 Jul 2021 17:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626569155; cv=none; d=google.com; s=arc-20160816; b=L5xIEdsqultfLNxTNZ2/xL5EW1Toowx+2sx9RUdxA0lk1Ul1JlN2vcSbfnLK+I0f+f zY9/DBguij4ZAoPEf7rNBJD8KylQPU8vdLez0vNgeNl1Yoj2c3b8Fe0vqfAFYyEFJH7V QebcFrU+YnSmsAxhXNHJHJ8Ibo+wrfgHyVeBCPU/HZMQX5mxM+Hy15ZE5tKkkZJ9DLjU U104X0/Ohb69Lv2buyMb8EYrf4jX9FVYz3M8KWGAPc9kk/bgQgNQDpMOAefoR/KfCY8J tXVGa6oXLEAlJeTlYqHg/Lv3gku0SSk43OOCW075Wmxsx7wm1OUFTRr2EcDmcT8nut47 veqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ec0P8mnMmP6aohKtyaSI2vDzkh73S9LeW5dXeTvtJNE=; b=f+EES3eeuS8JztLWi6pr74y3yiRZgHU1y/ZlMMf6/xqdJdIvfqFhzXLtTyQDWvKfwg TiNUHHtEoVBA/a0OyEdTaL1/xJKUhH8qn1wDhJ7XriP6BW6wlFpD92Nxn353VvfnTS9X 8pIw7BXfGCKvl1HsBKb8ds09pnTvi1wXji0+4jFp8ROx5e06eaGkKtdVvbvuEMFBCuir L7J6WzvyvFQgLgOcjF1P6Q/RT1Bw0VlaAggEc1WkFvaU5XJfgTK88ABTTbtZy/mCn2CU +IEJZpZRzieV5iKsXuvK8oXt1/VPv6ogfQduY1nljqojO2AlMt9fFMEcBaQxOZCp0trz M/Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="T/OLmGQB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si19549214ejv.584.2021.07.17.17.45.32; Sat, 17 Jul 2021 17:45:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="T/OLmGQB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233112AbhGRArI (ORCPT + 99 others); Sat, 17 Jul 2021 20:47:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:35576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230259AbhGRArH (ORCPT ); Sat, 17 Jul 2021 20:47:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5863F61153; Sun, 18 Jul 2021 00:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626569050; bh=a7B7C7EZMES8UQL7DNwDMK2KcW1llD9/i0LUiJ1YGLY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=T/OLmGQB8errsV6U1abggA6QQgDSh/V+Y59pDZahYXR7XuKdtfebg6rfIUsMfTDJO zwfQJXZR0loR7tQJKW6RGTIi7daZ8AhDCZN+yMf5KXVvck64T8d4l/Aescy6X+w4ka sPFSdZBzZ8tkM0D0t5oGOdaxxwSRFEIgRfc7CEMwG0As+Gh8xfcNxdBNs/v+vfRueV OL+aXsLvSiLT+X7eOsODUEQJKd+p9oa2VHElMX6oZfkUQpijbw+IF/2O0zV9rCZapb c9+V+W/4FquVyKLumd046YR9zMuzulQvRKErG6PpDkgbxHe1yZLmvSLGdMCOlYQV0F sU8y4/APGlyOg== Date: Sat, 17 Jul 2021 20:44:09 -0400 From: Sasha Levin To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Alan Stern , Johan Hovold , syzbot+7dbcd9ff34dc4ed45240@syzkaller.appspotmail.com, linux-usb@vger.kernel.org Subject: Re: [PATCH AUTOSEL 5.13 062/114] USB: core: Avoid WARNings for 0-length descriptor requests Message-ID: References: <20210710021748.3167666-1-sashal@kernel.org> <20210710021748.3167666-62-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 10, 2021 at 08:23:50AM +0200, Greg Kroah-Hartman wrote: >On Fri, Jul 09, 2021 at 10:16:56PM -0400, Sasha Levin wrote: >> From: Alan Stern >> >> [ Upstream commit 60dfe484cef45293e631b3a6e8995f1689818172 ] >> >> The USB core has utility routines to retrieve various types of >> descriptors. These routines will now provoke a WARN if they are asked >> to retrieve 0 bytes (USB "receive" requests must not have zero >> length), so avert this by checking the size argument at the start. >> >> CC: Johan Hovold >> Reported-and-tested-by: syzbot+7dbcd9ff34dc4ed45240@syzkaller.appspotmail.com >> Reviewed-by: Johan Hovold >> Signed-off-by: Alan Stern >> Link: https://lore.kernel.org/r/20210607152307.GD1768031@rowland.harvard.edu >> Signed-off-by: Greg Kroah-Hartman >> Signed-off-by: Sasha Levin >> --- >> drivers/usb/core/message.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c >> index 30e9e680c74c..4d59d927ae3e 100644 >> --- a/drivers/usb/core/message.c >> +++ b/drivers/usb/core/message.c >> @@ -783,6 +783,9 @@ int usb_get_descriptor(struct usb_device *dev, unsigned char type, >> int i; >> int result; >> >> + if (size <= 0) /* No point in asking for no data */ >> + return -EINVAL; >> + >> memset(buf, 0, size); /* Make sure we parse really received data */ >> >> for (i = 0; i < 3; ++i) { >> @@ -832,6 +835,9 @@ static int usb_get_string(struct usb_device *dev, unsigned short langid, >> int i; >> int result; >> >> + if (size <= 0) /* No point in asking for no data */ >> + return -EINVAL; >> + >> for (i = 0; i < 3; ++i) { >> /* retry on length 0 or stall; some devices are flakey */ >> result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), >> -- >> 2.30.2 >> > >This patch should be dropped from all of the autosel branches it was >picked to, as I do not think the USB core has been fixed up, along with >all of the different drivers that we noticed doing this, in the stable >trees. > >So please drop from everywhere at this time. Will do, thanks! -- Thanks, Sasha