Received: by 10.192.165.148 with SMTP id m20csp4159760imm; Mon, 30 Apr 2018 12:55:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrHM8uCf8qme3xwEiwrQLIS/IRDQr8aWhkW4FNSEz+c7V1ySMOvtP3ovMQJoCObbthcJSyv X-Received: by 2002:a17:902:7146:: with SMTP id u6-v6mr13373925plm.289.1525118125930; Mon, 30 Apr 2018 12:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525118125; cv=none; d=google.com; s=arc-20160816; b=gw6jBQ9DXf58XJCe89I3+bztD93a+UyS/awrcSRsDqbI0CPIq7/dVAypTq9wFvNgQb oIFVNVdkLe4E3cRtWxSyvs+/hxcTkRWCw7XY70VRaYhZjYx9aHTKvU+HsNuF8spQ5aAd /FRl44Dt+DY3oPD0albplsTiYpTt95ZhTCxuJtRKsDe9GPxaWNvu8oMxQU+BBMliCx85 tuAfKKOrV5dQZcct0/m8mc48/NN83O6kGhkXlFGPAncfbap+c6Tl1AF322t23kStoeDT Fv98EL3IsvEN6RLZZ8so9fBBF0YbFP+NZA+nj4J1TE7s2ZXIGJMQbvdS5JHsxJy0mK6z 2ODg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=4BvKCxUUuwNII4hAb+Hr0NCQXngDG0WhSsLf4Ksas10=; b=DjULv5bi6wauNBhMj+z4RAAEf/y495JLu7bW3qnFN6nQHDA6e3jo8vohhShCmkrwAm wsnJtFvHIpP6a0xhkUBAAjjkYNmPlueHaNMQLCoiVvsgOueS5UWnFJNORCs5pumaqeu0 cZvHTAatDQXNeyPLUzWarTjLzbOfI93WbIJYqVW0ry++3xIooO28hmMu97xk174xMVLk K/SPM+rhaL+NDxzzbJoxie1dG8MPcW2A9foGbC2q3vOJbqBWjtDVLTk/7d6g8GY8u5WQ 0RGzL5+KDAUmGE8zTFUW5cT3wx9w8XhQ93VFmRVxTUvQUgGUgv2zHl15j234oW8/XM/8 B6fg== 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 r74si7987386pfe.168.2018.04.30.12.55.11; Mon, 30 Apr 2018 12:55:25 -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 S1756171AbeD3TzC (ORCPT + 99 others); Mon, 30 Apr 2018 15:55:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:35014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756044AbeD3T1y (ORCPT ); Mon, 30 Apr 2018 15:27:54 -0400 Received: from localhost (unknown [104.132.1.102]) (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 2227822DBF; Mon, 30 Apr 2018 19:27:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2227822DBF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuah Khan Subject: [PATCH 4.16 012/113] usbip: vhci_hcd: check rhport before using in vhci_hub_control() Date: Mon, 30 Apr 2018 12:23:43 -0700 Message-Id: <20180430184015.592900904@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shuah Khan commit 5b22f676118ff25049382041da0db8012e57c9e8 upstream. Validate !rhport < 0 before using it to access port_status array. Signed-off-by: Shuah Khan Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usbip/vhci_hcd.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -354,6 +354,8 @@ static int vhci_hub_control(struct usb_h usbip_dbg_vhci_rh(" ClearHubFeature\n"); break; case ClearPortFeature: + if (rhport < 0) + goto error; switch (wValue) { case USB_PORT_FEAT_SUSPEND: if (hcd->speed == HCD_USB3) { @@ -511,11 +513,16 @@ static int vhci_hub_control(struct usb_h goto error; } + if (rhport < 0) + goto error; + vhci_hcd->port_status[rhport] |= USB_PORT_STAT_SUSPEND; break; case USB_PORT_FEAT_POWER: usbip_dbg_vhci_rh( " SetPortFeature: USB_PORT_FEAT_POWER\n"); + if (rhport < 0) + goto error; if (hcd->speed == HCD_USB3) vhci_hcd->port_status[rhport] |= USB_SS_PORT_STAT_POWER; else @@ -524,6 +531,8 @@ static int vhci_hub_control(struct usb_h case USB_PORT_FEAT_BH_PORT_RESET: usbip_dbg_vhci_rh( " SetPortFeature: USB_PORT_FEAT_BH_PORT_RESET\n"); + if (rhport < 0) + goto error; /* Applicable only for USB3.0 hub */ if (hcd->speed != HCD_USB3) { pr_err("USB_PORT_FEAT_BH_PORT_RESET req not " @@ -534,6 +543,8 @@ static int vhci_hub_control(struct usb_h case USB_PORT_FEAT_RESET: usbip_dbg_vhci_rh( " SetPortFeature: USB_PORT_FEAT_RESET\n"); + if (rhport < 0) + goto error; /* if it's already enabled, disable */ if (hcd->speed == HCD_USB3) { vhci_hcd->port_status[rhport] = 0; @@ -554,6 +565,8 @@ static int vhci_hub_control(struct usb_h default: usbip_dbg_vhci_rh(" SetPortFeature: default %d\n", wValue); + if (rhport < 0) + goto error; if (hcd->speed == HCD_USB3) { if ((vhci_hcd->port_status[rhport] & USB_SS_PORT_STAT_POWER) != 0) {