Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp45287imu; Thu, 8 Nov 2018 14:29:16 -0800 (PST) X-Google-Smtp-Source: AJdET5eHZ6hZEit62yk+ixFZTI00rpJCVS+eISglVycr5R38vBupyjUQXhycqx9x3fpIw7afS5yO X-Received: by 2002:a17:902:8b8c:: with SMTP id ay12-v6mr6101699plb.69.1541716156669; Thu, 08 Nov 2018 14:29:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541716156; cv=none; d=google.com; s=arc-20160816; b=n5b8j1va+tKUIBAsKv+TLZyMqNK4XE9/kJRmGd2PlTNOWubBof1vUp2mcPlBYeiWuf aVzNycXyglkQx9PNHLMwW7pqocsRziYonmyNg6FlBv5ukkad2JNG7DQU9ONVx1w8AxuQ iCTfqnQfYbYX037hbrtb3nBRbnJfIXKVRQLpe6oBdbDwXp6pdJHj68uuhKNij6agSbNl ZyzR2Yhw8ceNP5xjMUeY60RmOba9A9MOoWpuW6genQX5YhwQAJ11RDrviKZJg3MEgx2h jLnx7jhLOsq+/uVK83Q0LJRIdjijE7XoA6ok+pGsv4/PfAlbJocG3mJQMTDADaeX0x38 8Isw== 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=rc8IXrjMKBmmCAEmed6p339k7l+2I0Yy2rAYSIYzJ0o=; b=O0OPGcw4IDrFDp9lIF+xDhp+9uWSMRx23UvGlmHggoPoNcKrR/NZb4jk6FwFYMOAM1 FJTd7uuu3IOtBkBGnWtkwZukeV6ASFoA/LHNyyAZ9mTV8ijH7hELLyb/AaqpiTlBiuvX QQhEyyPRtkSBX6yiA7Q5ovmctVvie9BcbcKrsnaP4zv8tR/Fj96PbpEK/kEohdXrfxc0 jnAoZafyoIu3w/y7HYGPrrffdEMYZJ4Y4OPyKCV1fk+Yv7ORD4+hvFZDnrjprK3ljr5p X/R7aLZJfEeT7SHBopRisfuLqi4ew1HyU8GUUFUtjCKDBfVOzayep4OWPR8HBzOQwbiV qveQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xMe6QqoP; 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 v38-v6si4499000pgl.539.2018.11.08.14.29.01; Thu, 08 Nov 2018 14:29:16 -0800 (PST) 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=xMe6QqoP; 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 S1729925AbeKIHjJ (ORCPT + 99 others); Fri, 9 Nov 2018 02:39:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:58674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728280AbeKIHjF (ORCPT ); Fri, 9 Nov 2018 02:39:05 -0500 Received: from localhost (unknown [208.72.13.198]) (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 2B4AA208E3; Thu, 8 Nov 2018 22:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714496; bh=E77qEt1x4esV8l1fmL/i5gj+JpVF3UYh+ZgSWJH8oZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xMe6QqoPBV7vgf1jSVpwR22dVdesa3KYfxUspmNzVZydZrAlN2mM6B0TPfgwJCgR4 5TYohZo542xhwcNsqVPLA/mNoaxzjJUUd9Rq0DwhgzTPmOZy4WMKjYyf0O2wgYrzgA wtlsaTe6ZusLLvJ/S1We7PRO4U3hXU+XcQ10PNVE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Oliver Neukum Subject: [PATCH 4.4 110/114] USB: fix the usbfs flag sanitization for control transfers Date: Thu, 8 Nov 2018 13:52:05 -0800 Message-Id: <20181108215110.702707778@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215059.051093652@linuxfoundation.org> References: <20181108215059.051093652@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alan Stern commit 665c365a77fbfeabe52694aedf3446d5f2f1ce42 upstream. Commit 7a68d9fb8510 ("USB: usbdevfs: sanitize flags more") checks the transfer flags for URBs submitted from userspace via usbfs. However, the check for whether the USBDEVFS_URB_SHORT_NOT_OK flag should be allowed for a control transfer was added in the wrong place, before the code has properly determined the direction of the control transfer. (Control transfers are special because for them, the direction is set by the bRequestType byte of the Setup packet rather than direction bit of the endpoint address.) This patch moves code which sets up the allow_short flag for control transfers down after is_in has been set to the correct value. Signed-off-by: Alan Stern Reported-and-tested-by: syzbot+24a30223a4b609bb802e@syzkaller.appspotmail.com Fixes: 7a68d9fb8510 ("USB: usbdevfs: sanitize flags more") CC: Oliver Neukum CC: Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/devio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1329,8 +1329,6 @@ static int proc_do_submiturb(struct usb_ u = 0; switch (uurb->type) { case USBDEVFS_URB_TYPE_CONTROL: - if (is_in) - allow_short = true; if (!usb_endpoint_xfer_control(&ep->desc)) return -EINVAL; /* min 8 byte setup packet */ @@ -1360,6 +1358,8 @@ static int proc_do_submiturb(struct usb_ is_in = 0; uurb->endpoint &= ~USB_DIR_IN; } + if (is_in) + allow_short = true; snoop(&ps->dev->dev, "control urb: bRequestType=%02x " "bRequest=%02x wValue=%04x " "wIndex=%04x wLength=%04x\n",