Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8398522imu; Fri, 28 Dec 2018 17:32:01 -0800 (PST) X-Google-Smtp-Source: ALg8bN6svGbCGLAtslgJjt95ZlXmz3t3tPKJRwFdHA+VUC/xQw17keUBQt7cGzziUJLDbjbolF8r X-Received: by 2002:a63:b30f:: with SMTP id i15mr28418534pgf.240.1546047121389; Fri, 28 Dec 2018 17:32:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546047121; cv=none; d=google.com; s=arc-20160816; b=mGFK9Coeqc5md5FP3GJTBOhvmSTY52AJc9WDl76TnfTRTmrW9zdZMVp3H6JPBrz6Mm Flu5BW3n8mY2cGY08oB6MQKcvTipgLFU3ZFyMMmTK/TyPUmHahkESM9LYz0olCwRNR2+ L4twT9wBs/rfpomuow08WHgTPO6FXKkr+PvbMPS4Sicm+AkqtxDVYesRLQtqkppUgIqZ uqfGrzu/TMYuk7GmY+GPTHfBmS/3yJjHG7IcILR2ySiZyCYU9IOMSuXtISlwCXA+rMlW r7haFRgTtM5aY6xNvPW5Z29TwirSZ+nMiYkeccDiFp0YJlPxtX9y/TrvvtcfE3JyKh9U ezIw== 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=zIW7QffKQSez3QnGZMPT4Zc42zts2vt175aDZU9m6y4=; b=Nk9cJShnaS0q09VWc6LgwxMXhWdW7UIfQ/UCRj2YdBg0FdEIMsPZ+n2ks699hpsq1T 0GGwAmfZUzexrA/GEa0lVIZe2F3jiVnY2RAxXLOZs2+Bid1dafkANM/Nc6OCwRoLE4k0 tHVPj2b7rPJ+i8fnrpc6AoAK5RzDsGfoO9md3YYc8s+GDG5YqjpeMSIqJfoTolQKtz8R 1dZerh+FfxVU9/I/q5Gv8t8P7sp8jlpH8OdLE8kAMJlOK9CvNYPjtCnMtzml7G1k85H/ KiELS2wguoIsAOMd5u4Uh8jfr6iGZeYKGZCegEy4onqiOI4V/VMy6dVK/KL9NI+kO/74 Ragg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Tsuxr6KM; 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 c37si10460871pgm.156.2018.12.28.17.31.23; Fri, 28 Dec 2018 17:32:01 -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=Tsuxr6KM; 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 S1730393AbeL1MXx (ORCPT + 99 others); Fri, 28 Dec 2018 07:23:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:33394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727544AbeL1MO3 (ORCPT ); Fri, 28 Dec 2018 07:14:29 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 58771218FE; Fri, 28 Dec 2018 12:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545999268; bh=XFud7ChC63ZziDFEK/ufnaKhBY913O5M+FcEyzKTJ8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tsuxr6KMbN5eBeK2TVGN81/kpObtkk96M607vj05pqppw8KJTaTZ+tXvSakGfmZzY pwOTdJTU/e/9TEADKA2/ht8t4u1p9wEIHTEKyZVgIab065fKjpLuqC1sXOxclq/3Cd XXp9416OUKqqlGzX/Dni6LYCcteIYdmyJaJGkEEk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hui Peng , Mathias Payer , Sebastian Andrzej Siewior , "David S. Miller" Subject: [PATCH 4.19 03/46] USB: hso: Fix OOB memory access in hso_probe/hso_get_config_data Date: Fri, 28 Dec 2018 12:51:57 +0100 Message-Id: <20181228113125.104476633@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181228113124.971620049@linuxfoundation.org> References: <20181228113124.971620049@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hui Peng commit 5146f95df782b0ac61abde36567e718692725c89 upstream. The function hso_probe reads if_num from the USB device (as an u8) and uses it without a length check to index an array, resulting in an OOB memory read in hso_probe or hso_get_config_data. Add a length check for both locations and updated hso_probe to bail on error. This issue has been assigned CVE-2018-19985. Reported-by: Hui Peng Reported-by: Mathias Payer Signed-off-by: Hui Peng Signed-off-by: Mathias Payer Reviewed-by: Sebastian Andrzej Siewior Signed-off-by: Greg Kroah-Hartman Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/hso.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -2807,6 +2807,12 @@ static int hso_get_config_data(struct us return -EIO; } + /* check if we have a valid interface */ + if (if_num > 16) { + kfree(config_data); + return -EINVAL; + } + switch (config_data[if_num]) { case 0x0: result = 0; @@ -2877,10 +2883,18 @@ static int hso_probe(struct usb_interfac /* Get the interface/port specification from either driver_info or from * the device itself */ - if (id->driver_info) + if (id->driver_info) { + /* if_num is controlled by the device, driver_info is a 0 terminated + * array. Make sure, the access is in bounds! */ + for (i = 0; i <= if_num; ++i) + if (((u32 *)(id->driver_info))[i] == 0) + goto exit; port_spec = ((u32 *)(id->driver_info))[if_num]; - else + } else { port_spec = hso_get_config_data(interface); + if (port_spec < 0) + goto exit; + } /* Check if we need to switch to alt interfaces prior to port * configuration */