Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4487113ybx; Mon, 4 Nov 2019 14:14:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxQvIgDkuuDbg1efu6svPesxfyojOkgnNceM3At3jUbssscTZjwuOgRe/vZMM9zRCuSBkZW X-Received: by 2002:a17:906:ecf5:: with SMTP id qt21mr25943772ejb.295.1572905658681; Mon, 04 Nov 2019 14:14:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905658; cv=none; d=google.com; s=arc-20160816; b=d+kO9tgLPoqhBrpi9s8iTvcgfMLcrdgroX6yVrh6zzjZuQ64F35gpBLWg1X1T1lwl5 MosODwL1diMMXPnc7lyFo9vL0vTew6tVObFLltvMfZfeJvPLmDJEINsBm6RivTwOqf66 sj56xYYUZfsqIYIwa1in602Aqvh5FjI4CJdYTo9xkFCa+zxQkdVtipu2CztVo7AAEHFo sAGws9Anmfgbp3pwjJ9Q6C1VzNu7jw4xXx9Qj2DCHiOAUFbH/Arzs6DDAooTWBlLPCs9 y6wA7LabmXX6FlnW2M1aY2baHLrDj+rcbZqu7xnKYiJuZH/SuO0gr9pMyxUajElA265z 9k9g== 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=5mZxPOls4dUgP2AWLX7z7BcGmLWlOlQy5rS5ALOKpSw=; b=x0lz8i7iMQInPJ0xcU5kSELOkw7Hav1uKJI+7Zjj+4vq8+Y1BF4iaHVZ6xMTvCyQxM qlLWTMwdrztJXQHxktN4s0rahCrb7XmXcUqDHzn2Sg3GguRk7mUbudzckEZUb7JoyUtF QH2bKmwxw847LCaX/Z5ZV46YJ2QAXVfJNNNram/POX0G6+2SeuyT38Ps4dbeyGyomlNO WEOEFkj6ThNZ0Hqc0i+gZkfK0snMqcGtfKSyRiBMaztShWX5gJy+RXAJo0lwhpKiGXEV Jyvt3rl//K5uF60VMSGA3wNdHc+jdYiqNHH3LhljePR7HD8hs6KFhtyTOkp+2lotF4uz hDDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YpoH09B0; 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 bi17si9512626edb.430.2019.11.04.14.13.55; Mon, 04 Nov 2019 14:14:18 -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=YpoH09B0; 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 S2390490AbfKDWKE (ORCPT + 99 others); Mon, 4 Nov 2019 17:10:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:43190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387458AbfKDWKC (ORCPT ); Mon, 4 Nov 2019 17:10:02 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (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 19AC7205C9; Mon, 4 Nov 2019 22:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905401; bh=NQVZ6s6H1xwJK/ZO3ammWuvgpSD8GLRnPoedXMtSxMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YpoH09B0j00nEc/PeBYy9ueWcoGye/fNplbxwz7nXN9Cs4nJFHVJyizcMd4JtRBcu kpPRna97mTqn8oUUJR41+iXNRPCVbceqZXZDsU2YK3+nQO/PmfjFw1DBCPc4CAQ3MV GoVtea/CPNgGkLrQ3Yhb3tXBmkiac7ep3u8zW1Cw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Waisman , Laura Abbott , Ping-Ke Shih , Kalle Valo Subject: [PATCH 5.3 131/163] rtlwifi: Fix potential overflow on P2P code Date: Mon, 4 Nov 2019 22:45:21 +0100 Message-Id: <20191104212149.821168769@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Laura Abbott commit 8c55dedb795be8ec0cf488f98c03a1c2176f7fb1 upstream. 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 Acked-by: Ping-Ke Shih Signed-off-by: Kalle Valo Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/realtek/rtlwifi/ps.c | 6 ++++++ 1 file changed, 6 insertions(+) --- 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 ieee80 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 iee 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 ==