From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23A83C43387 for ; Fri, 11 Jan 2019 15:10:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E989D20874 for ; Fri, 11 Jan 2019 15:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547219457; bh=FqKdZNRdhRi9TSBWqS9rWA947f/yQGtPTHjvc+A3W3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=y8epQxju+XLYKrygHrshG8zjsaMEImiaKEvH9xvW0fwG8zSaWehBL/PsZ+V1Uqsg1 3+0AyjGHdn7Yai/n80wb1f37wOU8KW1B1Gr8rgL/Kq4Xfn1dI6fVCjKXapMo00nssh cQ56nFJB7vZsnZ7CtpxL85BuzFo4nZ9scBHxB+Jc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725790AbfAKOQg (ORCPT ); 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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 */