Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3489777imu; Sun, 11 Nov 2018 16:16:04 -0800 (PST) X-Google-Smtp-Source: AJdET5cWxqdpOzQxlPHlSzMim84tw1mNIDLa4P8tc1VpxbzcvENUUKQhrD0a3lnByx4NvI5G5gCw X-Received: by 2002:a63:a441:: with SMTP id c1-v6mr15741446pgp.49.1541981764233; Sun, 11 Nov 2018 16:16:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981764; cv=none; d=google.com; s=arc-20160816; b=nIHlzlb356/iytcFBgUFe9UbD4CzDC43FOkMY/RMRzw8iyrmT4GuxgpvvmQzz7/wHh RwAIwsBKQ6aDAdG2lFssBlRmqpqf+OrjPJO6+klG+/VlGQMmuQkUdo0OGgz9WAnwrxLp 9bykhzVBKklycQqPAroN+yt9tdiCPe5kRYk97yJyKPc+rDxBqIinTShN5DDvR++Chz7e VGTqmOtH4vkQD0uPe9lj0uyI6i3+BtHR7GSiq/GOfo42Npi3iJ1md3M9c8aNI3xis/ft 1D+YE15HZkD9kwS3ZfCt1GVKvePSAaMGeXHizooQcXnXm+zUHOTVZrC78O57A1D6t/AU w9IA== 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=Q/0dpigovCNNBf6ijF/OycvWEyVOdK0vA125POBFVDQ=; b=HgJOGAYfKRfo6v2XSlugfYkU4ryffcb5+KuYdl9XcgxG3J4NdWNAlScAAu/ap3ErUn xHNbiebkzO4hzH6KIiNgHXE750iIMPxeZpYKpOGM769tVrLDMSEn3IpgOXbRIdXGWnTb sx0L19kg0FfKGQGyl+9j4t/7uQh58bvIn8/dl2FWOwZwcm3oQpPE1piPJWn111pYwWyN HMElHHSepzpy/QYc0Wvgo8d9EHOSw8GDRUXmPHPqxnHx7RqgpIEjLN4jgF14+9Cpu/i6 MGM0mT3X190L7679OBshMMdEeKyPIvZlj94AXdtbx1x9A8EKyjCGHBfF/+MNr/wCnHKN u2DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fPCtgmje; 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 s144-v6si18092536pfc.149.2018.11.11.16.15.49; Sun, 11 Nov 2018 16:16:04 -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=fPCtgmje; 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 S1731461AbeKLKEk (ORCPT + 99 others); Mon, 12 Nov 2018 05:04:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:59948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730390AbeKLIRN (ORCPT ); Mon, 12 Nov 2018 03:17:13 -0500 Received: from localhost (unknown [206.108.79.134]) (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 B528A214F1; Sun, 11 Nov 2018 22:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975237; bh=D0pgE4jWvDwl/FH/X3umVw7y6lLx2jdgocbPehHz2LM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fPCtgmjeWVNpa2hgDnfQ1NZxgi/n/fZ5TuvGkHnWhzcBIO2Xz8K23MWmLW+/YH3wd rze8pCqv7br5UhG/27/Szo60w+NgHkVSGDL/lr53PpF/0MpDo+Zl0QGsrWlpcHm0f6 r3so3dKol/gLUefancG7k31oZ9lzLrn4D8DD28/k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luca Coelho , Sasha Levin Subject: [PATCH 4.19 075/361] iwlwifi: mvm: check for n_profiles validity in EWRD ACPI Date: Sun, 11 Nov 2018 14:17:02 -0800 Message-Id: <20181111221630.564065250@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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: Luca Coelho [ Upstream commit 2e1976bb75263fbad918e82184b16a23bd721546 ] When reading the profiles from the EWRD table in ACPI, we loop over the data and set it into our internal table. We use the number of profiles specified in ACPI without checking its validity, so if the ACPI table is corrupted and the number is larger than our array size, we will try to make an out-of-bounds access. Fix this by making sure the value specified in the ACPI table is valid. Fixes: 6996490501ed ("iwlwifi: mvm: add support for EWRD (Dynamic SAR) ACPI table") Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c @@ -704,8 +704,12 @@ static int iwl_mvm_sar_get_ewrd_table(st enabled = !!(wifi_pkg->package.elements[1].integer.value); n_profiles = wifi_pkg->package.elements[2].integer.value; - /* in case of BIOS bug */ - if (n_profiles <= 0) { + /* + * Check the validity of n_profiles. The EWRD profiles start + * from index 1, so the maximum value allowed here is + * ACPI_SAR_PROFILES_NUM - 1. + */ + if (n_profiles <= 0 || n_profiles >= ACPI_SAR_PROFILE_NUM) { ret = -EINVAL; goto out_free; }