Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1733415ybg; Sat, 19 Oct 2019 01:19:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4jo8N8MAJeKwOy5rg/Ah1pracd4mqtqyYRGh1EDyQxDuYRmm/gbPM/xnxm4CXs2h8mnMz X-Received: by 2002:a17:906:2c5b:: with SMTP id f27mr12150456ejh.239.1571473173764; Sat, 19 Oct 2019 01:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571473173; cv=none; d=google.com; s=arc-20160816; b=ycyFIWX9N+GGmWi0SiGn4fZXAcoxrcEo+NUpt7W4p8d5oWd5ie5QgUHZIpG0PkQuUm fKq1vtj7CfAKycn/bwLbNpVKrrGWU3+XQqY2I/2tPOIxwVVpwE1iRJE2pHthKECVVOYU VETl61EWG4yW4lTEBmu6z4O5p2TTqtgUU+yzXUMPvNBXNAAGcBPyELtXjhAbeDavzL0Z CmQ3EEIPXo/AyUFNDvQmlvkALhqSfNTv4kTrzrVSDeV1F5fCPyYYtQ1DTDmc+sXtxUqf GhIuY24ArtGEAgC3ANkvAOY3KW/Xl433kANpwNp2o0veSrdiqXwFfU9ohfBXIT0kVP1w 917A== 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 :message-id:date:subject:cc:to:from; bh=6Ub6Gl8wiH8cmKTsFrafRHW9fuJ5vrtuEMWyvrQhDdg=; b=CkE7sIVAcMzkuO8C28jlF0Vjett5aOpdsyA/Va6D2S+pJ9c4H9yldRpMvtl7pCuqDc +JkJF5zyVCX8VgBKx7O65+zzp7oHIu2CEH09zPgHLq3ZHKh9UL/iMHsFjA1k9Apu/Mr8 S7h19PgL9OprLl/j6av0Tn46kT2yhnRwkmv5aQTRpLtfsK3nH9Cu6L5xwO9kkB2riAUL 251iVvmzd2kjQ1/ZaD+3VMUw69pcWr+wJ9VV/dYuXg2VDRHuE3nwOPbDLCH/QaygJyh3 ml5mzdoyRAcvSWf9G1QGzFuaNZoswpcxUXzKybvRdbML6PQs7QTHFpAq7GYiqdbeFmZU vy5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12si5665298edb.133.2019.10.19.01.19.08; Sat, 19 Oct 2019 01:19:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404893AbfJRLn0 (ORCPT + 99 others); Fri, 18 Oct 2019 07:43:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47228 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389397AbfJRLn0 (ORCPT ); Fri, 18 Oct 2019 07:43:26 -0400 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0ADFC369AC for ; Fri, 18 Oct 2019 11:43:26 +0000 (UTC) Received: by mail-qk1-f197.google.com with SMTP id g65so5207016qkf.19 for ; Fri, 18 Oct 2019 04:43:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6Ub6Gl8wiH8cmKTsFrafRHW9fuJ5vrtuEMWyvrQhDdg=; b=a46DpZwLcfvYlJ5gPobtL0FDfeO98XwF2IKHbqEobp2fKy41UaZbZyp9fg8UMYu7I5 KuZ1RvTItdX4FFjQZu4EQOB/maPBY85ZZZrCEJdYjR4++6eKuLPJYxOk+CuolQIkSRuZ XRtXxdzi5Ibaq9kgrFwoZAREO3m5S8zF7m++C8Xe8JkBms3fU3bjTxMAAgO15hK/K/ZD aZ0/F6JpyO9cDLKvZR9KmBC0AGDUdwfmtu8Uxj/JL9FVK0yd72FlKJuDWgeKaVBg5vJ8 hcdeL0mCxMllFSI3u3jDWo2+ByKxUnSMLrE/ap3doUrs5WzCsZfmlSkLPUKsoym6NdRE Azog== X-Gm-Message-State: APjAAAWATRaLGRth6+wKRG+ezvUhCEKqEVCHPdrInU7gNWjXWfQBCEk1 fBYIvuj+p2PHMpozdgHWSCbobcFTLaBCsrWogacQXxNsL4b6VbT1ZnGIzc9gmMSqrqSEdUaSys+ 0Zj0GHjBClF/VA/UOkR2pKu0SXIQ= X-Received: by 2002:ac8:141a:: with SMTP id k26mr9417392qtj.372.1571399005322; Fri, 18 Oct 2019 04:43:25 -0700 (PDT) X-Received: by 2002:ac8:141a:: with SMTP id k26mr9417366qtj.372.1571399005006; Fri, 18 Oct 2019 04:43:25 -0700 (PDT) Received: from labbott-redhat.redhat.com (pool-96-235-39-235.pitbpa.fios.verizon.net. [96.235.39.235]) by smtp.gmail.com with ESMTPSA id d205sm3031043qke.96.2019.10.18.04.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2019 04:43:24 -0700 (PDT) From: Laura Abbott To: Ping-Ke Shih , Kalle Valo Cc: Laura Abbott , "David S . Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolas Waisman Subject: [PATCH v2] rtlwifi: Fix potential overflow on P2P code Date: Fri, 18 Oct 2019 07:43:21 -0400 Message-Id: <20191018114321.13131-1-labbott@redhat.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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. Bound noa_num against P2P_MAX_NOA_NUM. Reported-by: Nicolas Waisman Signed-off-by: Laura Abbott --- v2: Use P2P_MAX_NOA_NUM instead of erroring out. --- drivers/net/wireless/realtek/rtlwifi/ps.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/wireless/realtek/rtlwifi/ps.c b/drivers/net/wireless/realtek/rtlwifi/ps.c index 70f04c2f5b17..fff8dda14023 100644 --- a/drivers/net/wireless/realtek/rtlwifi/ps.c +++ b/drivers/net/wireless/realtek/rtlwifi/ps.c @@ -754,6 +754,9 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data, return; } else { noa_num = (noa_len - 2) / 13; + if (noa_num > P2P_MAX_NOA_NUM) + noa_num = P2P_MAX_NOA_NUM; + } noa_index = ie[3]; if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode == @@ -848,6 +851,9 @@ static void rtl_p2p_action_ie(struct ieee80211_hw *hw, void *data, return; } else { noa_num = (noa_len - 2) / 13; + if (noa_num > P2P_MAX_NOA_NUM) + noa_num = P2P_MAX_NOA_NUM; + } noa_index = ie[3]; if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode == -- 2.21.0