Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp676103imu; Fri, 11 Jan 2019 07:12:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN43Eqpafev35TlMV7oPvJtl8aV8KRi/9Fon4u8KoN8o5eaDA0BNpF4wcl0bq7clzeEjLILM X-Received: by 2002:a17:902:f24:: with SMTP id 33mr15194253ply.65.1547219560369; Fri, 11 Jan 2019 07:12:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547219560; cv=none; d=google.com; s=arc-20160816; b=XoDBI53A0RNXZlCMziRurmPePlnY6u4xc3JtRKeCVlcORWYTCKvU/t5HDfZJBJg7B6 o2dG+SBQelbHw1NJ319jxf7fCpZxeE1FL6yA7yJGsknnz2a2vroY00SqRgyJvjcDUABJ 9ZqdMdymIqLWm3w7pPQrXlwcJEYHQ9f/w3DXLNp00qP1yn7q7hrdSayr93wvLGDJMvpm HkTJ0IkAKDlltRnLBJ2fAO8uCVbcNG3mitH1+eutDg/2gFx5ZrNCL+Zloa8iywBMeceq 758X+Lxoi2EM0abBEfPLp07hnG4PwE9533BFJNsQuuvHsXwVXFh8VG3iG8P1xDpgg4UX eNWw== 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=4SD0y6qPilfGvZI2h8bf1wmATCT8ArBdoRhLrvwjQvQ=; b=ppHNQPYFsfECKaVs5ed1fhFBtOnBbAtQlwnfDUByYPI+8yuxIzvxt7DkndrECWXfrq kmm6+U8vHlcJy0XmeTfAAzG+LT4/tNeGPNKubiTfeIHAdEHmjUXfCyG5RqLMCzF8y4dR fIrjtTorglS46v+dEF1gtMC+SaOUaFbRAdBxcG2Xt7RfMJguxjCe+vK/KwCmPr49CzZ/ 87KkxDp/GIt729WJwgFnPgCEurkw5IGvmKz0HBAn9j8a7+JZn5eseW0d5ZDepsiW2+sd Wqap1ekhfJl8tij1eJ7SOc9IiSWm3xY56BEe2FdUO2sCS1+X+PHSAam+pUj7u8f9mN3v PoHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nYeI8ZUt; 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 b131si60475993pga.394.2019.01.11.07.12.24; Fri, 11 Jan 2019 07:12:40 -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=nYeI8ZUt; 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 S2387669AbfAKOQg (ORCPT + 99 others); Fri, 11 Jan 2019 09:16:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:60988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387656AbfAKOQc (ORCPT ); Fri, 11 Jan 2019 09:16:32 -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 B71EB21783; Fri, 11 Jan 2019 14:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547216192; bh=FqKdZNRdhRi9TSBWqS9rWA947f/yQGtPTHjvc+A3W3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nYeI8ZUtD8kevWB4e6RXqcY2ZJFqy5c/8RBDBqVG8rmEFLVBDDu1NCqoAVZkWy32p UD+9u5Bw+QzFOV48avpPjLGS/IaEuKacSp9wCBQVRWEzwrR8KbAELgfc3r4ZFL+MXA Yo+t+Bzf2/iUmxhBv8gLnGatY7LzQXG4f+SKdRoM= 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.4 01/88] USB: hso: Fix OOB memory access in hso_probe/hso_get_config_data Date: Fri, 11 Jan 2019 15:07:30 +0100 Message-Id: <20190111131046.581337211@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131045.137499039@linuxfoundation.org> References: <20190111131045.137499039@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.4-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 @@ -2825,6 +2825,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; @@ -2895,10 +2901,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 */