From patchwork Fri Oct 18 07:13:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Hicks X-Patchwork-Id: 1179161 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46vchC1bL9z9sPT; Fri, 18 Oct 2019 18:13:31 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1iLMRz-00051C-Mn; Fri, 18 Oct 2019 07:13:27 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iLMRx-00050n-6m for kernel-team@lists.ubuntu.com; Fri, 18 Oct 2019 07:13:25 +0000 Received: from 2.general.tyhicks.us.vpn ([10.172.64.53] helo=sec.work.tihix.com) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iLMRw-0003qu-RE; Fri, 18 Oct 2019 07:13:25 +0000 From: Tyler Hicks To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/1] UBUNTU: SAUCE: rtlwifi: Fix potential overflow on P2P code Date: Fri, 18 Oct 2019 07:13:03 +0000 Message-Id: <20191018071303.32156-2-tyhicks@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191018071303.32156-1-tyhicks@canonical.com> References: <20191018071303.32156-1-tyhicks@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" Nicolas Waisman noticed that even though noa_len is checked for a compatible length it's still possible to overrun the buffers of p2pinfo since there's no check on the upper bound of noa_num. Bounds check noa_num against P2P_MAX_NOA_NUM using the minimum of the two. CVE-2019-17666 Reported-by: Nicolas Waisman Suggested-by: Ping-Ke Shih [tyhicks: Reuse nearly all of a commit message written by Laura Abbott] Signed-off-by: Tyler Hicks Acked-by: Kleber Sacilotto de Souza --- drivers/net/wireless/realtek/rtlwifi/ps.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/ps.c b/drivers/net/wireless/realtek/rtlwifi/ps.c index 70f04c2f5b17..3b79c25bc376 100644 --- a/drivers/net/wireless/realtek/rtlwifi/ps.c +++ b/drivers/net/wireless/realtek/rtlwifi/ps.c @@ -753,7 +753,8 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data, noa_len); return; } else { - noa_num = (noa_len - 2) / 13; + noa_num = min((noa_len - 2) / 13, + P2P_MAX_NOA_NUM); } noa_index = ie[3]; if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode == @@ -847,7 +848,8 @@ static void rtl_p2p_action_ie(struct ieee80211_hw *hw, void *data, noa_len); return; } else { - noa_num = (noa_len - 2) / 13; + noa_num = min((noa_len - 2) / 13, + P2P_MAX_NOA_NUM); } noa_index = ie[3]; if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode ==