Received: by 10.192.165.148 with SMTP id m20csp4179588imm; Mon, 30 Apr 2018 13:18:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqe+sobE2PaYNoLLOOEcha8WNMv9rxu0PlC+NGlYjPEp5ad4p7JrGtMNT1UXUpFXMlxxqXT X-Received: by 10.98.93.20 with SMTP id r20mr13174752pfb.53.1525119482555; Mon, 30 Apr 2018 13:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525119482; cv=none; d=google.com; s=arc-20160816; b=xbEQOk3kn5huvb6qlrv7sIYti6y0cGwbhJohMXnqO6xH9DmX1gRwO9yG68VRPiHsL/ QEXoW3RcSD0BHS2Em7v8VUh5ipU+4iwHJ96BGGyGW4tQTc2KHTvr+Bb76Da1QeR86A0/ G8dUoFXeMDCzUdVvzQJCCgBttPBPW2Oz1tcO9js4d62p4jzdqdx6/ktRqZmkgs1ekpf2 G/pc6+/y4gv0DlKbqUw8HfNHkcDsjOYWMZOd6aiaXubJBEqFse0+pJDvxibr0/yQgEyf RQlOlOfPIxOQsZoK1tUvjpAIOasYF1KfI9TKRUpusvSIb4yHWaDzSzhn6PV405IsvU7F 5Y4A== 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=HXMIXgaSzMIzSKvDiOOP8V/5bHObYly43SKACWb8iB0=; b=pcm8TKn+KMztL+Z243d/vkc0gs5D7hzx9rl8UyfUWnlBE8iEUMzNC9b5aL6efwix3v bSUSxBm2ipupc+paUyEsvgZmRM2LzUt8inbaf0g4xzr35zKRQHGD8tcfkvM4RLThYXOS uDeAmnPinSaMS0sqbwr7szR9yLJJ766Z2f2/i52yio+MHQ1Ki15tbH78DTm3kJ3GHg+d eEJTydgOpEmVZ3kFxnhw5E3JREwmylxlacyq0HwOxBB3U7/zq1qRdWTRHRpAsi1NO75L tMoha3jPfWTI402sCW7G6Cz/sjjUo5yxmugkAxe7ICsGO+DYcK7IYl1YdD/xUlNokUed u+Ww== 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 b12-v6si6570331pge.252.2018.04.30.13.17.48; Mon, 30 Apr 2018 13:18:02 -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 S1755943AbeD3URl (ORCPT + 99 others); Mon, 30 Apr 2018 16:17:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:32942 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755834AbeD3T04 (ORCPT ); Mon, 30 Apr 2018 15:26:56 -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 4A4DB22DC1; Mon, 30 Apr 2018 19:26:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A4DB22DC1 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.14 12/91] usbip: vhci_hcd: check rhport before using in vhci_hub_control() Date: Mon, 30 Apr 2018 12:23:54 -0700 Message-Id: <20180430184004.862563869@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@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.14-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 @@ -368,6 +368,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) { @@ -525,11 +527,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 @@ -538,6 +545,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 " @@ -548,6 +557,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; @@ -568,6 +579,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) {