Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1026292yba; Thu, 4 Apr 2019 02:43:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzK8ddzXlDApGCi1yBlZG4ssZE/QnBjBNHaIVy6q8su6qP/udhOZw/80JiyYytzx/z/26UE X-Received: by 2002:a63:3f8d:: with SMTP id m135mr4654499pga.228.1554371021227; Thu, 04 Apr 2019 02:43:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554371021; cv=none; d=google.com; s=arc-20160816; b=VjzgEKjHEaJtigczqGMTc1+ud/IKU1I7N3fbiGryNgDpfa8wuDA9hiN/wZXoG1CFZd IaYcXSYQu4hp1XqSVpgCXoqyF9K902RW1Uv2VHBj+omz+nr4y72lD3eiy4wBT1GWvpqp JfkM15Ok1ozhD5M8cqrRlFk0QArCzih0FxsIM687A3tcvD90qPG5UybZbj3RJQynqNb2 ZJrrO+2FhK0EYvFv9MYNIT1hWpCiWhhM5e8FzkFWpWxi+q+4C1Jsb3E7eGLzvZvrMs/M WmGA6ojIVUksGm1TodFZWYUoFQ7xV8q/YtrUdVO7q7YJLLLJwpRdnXMnW8QcC0fBDeIL K4jA== 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=63VX6CNsc+YAneXCkYDhMF0WTzrK5wofg+LRGlZztSg=; b=cxY9sa7JakiApKbPL9WYKAiNFRu7cVCZo2/tNAT/nfo4Q7Y5bljWCg+TIKrTHY2h1A ZhE2iRuJc4mnT+zZhOs/VR7pvpMbrKOVXw7OO61Y0jgnStCkqsRikrmNI+uIVkuTA+Bz f0ZnahIFC6pQNXhuVe+o8OIwgVfon0f3L2XoGIX330cMtl37Z9rAOo2s/RH038gpzL8G zl0DIjYHIh6aG6vva8XI/OEeRDsdHAtCoxXVPpwZaNUX9zMYRTyx78b2kHuT3K8bbMoV WZcDWPTOwuJlEWS26vkCMu7L7hSyk8EXVU+GfQ/yH9k4KIQlTkxPvyExJeILcSpEAAfv KpNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="tT/CyHL2"; 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 j7si6559227plk.221.2019.04.04.02.43.25; Thu, 04 Apr 2019 02:43:41 -0700 (PDT) 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="tT/CyHL2"; 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 S1731358AbfDDJBG (ORCPT + 99 others); Thu, 4 Apr 2019 05:01:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:37982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731135AbfDDJBB (ORCPT ); Thu, 4 Apr 2019 05:01:01 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 3E7DA218C3; Thu, 4 Apr 2019 09:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368460; bh=wP5XRujaHrcdehCyXyr/80KZW4O6WIWQjjvV1vFpdiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tT/CyHL2ymUphdGyErjA3+2EPsRap6yaOksY5oO9V4kmj32x6zILKr5uP2O8LvIry EsHQhUJnRASYJ1dH2nRltTy/LNMJ6O41QC3PpYAzQTDvs/+KWXIz4ynDcCjYyS1xRG TFEuvFPWB6kzDiTuh4alWuLyXooONLBDseencqF4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexei Avshalom Lazar , Maya Erez , Kalle Valo , Sasha Levin Subject: [PATCH 4.19 048/187] wil6210: check null pointer in _wil_cfg80211_merge_extra_ies Date: Thu, 4 Apr 2019 10:46:25 +0200 Message-Id: <20190404084605.333760569@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@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: 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. ------------------ [ Upstream commit de77a53c2d1e8fb3621e63e8e1f0f0c9a1a99ff7 ] ies1 or ies2 might be null when code inside _wil_cfg80211_merge_extra_ies access them. Add explicit check for null and make sure ies1/ies2 are not accessed in such a case. spos might be null and be accessed inside _wil_cfg80211_merge_extra_ies. Add explicit check for null in the while condition statement and make sure spos is not accessed in such a case. Signed-off-by: Alexei Avshalom Lazar Signed-off-by: Maya Erez Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/wil6210/cfg80211.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c b/drivers/net/wireless/ath/wil6210/cfg80211.c index f79c337105cb..2daf33342b23 100644 --- a/drivers/net/wireless/ath/wil6210/cfg80211.c +++ b/drivers/net/wireless/ath/wil6210/cfg80211.c @@ -1420,6 +1420,12 @@ static int _wil_cfg80211_merge_extra_ies(const u8 *ies1, u16 ies1_len, u8 *buf, *dpos; const u8 *spos; + if (!ies1) + ies1_len = 0; + + if (!ies2) + ies2_len = 0; + if (ies1_len == 0 && ies2_len == 0) { *merged_ies = NULL; *merged_len = 0; @@ -1429,17 +1435,19 @@ static int _wil_cfg80211_merge_extra_ies(const u8 *ies1, u16 ies1_len, buf = kmalloc(ies1_len + ies2_len, GFP_KERNEL); if (!buf) return -ENOMEM; - memcpy(buf, ies1, ies1_len); + if (ies1) + memcpy(buf, ies1, ies1_len); dpos = buf + ies1_len; spos = ies2; - while (spos + 1 < ies2 + ies2_len) { + while (spos && (spos + 1 < ies2 + ies2_len)) { /* IE tag at offset 0, length at offset 1 */ u16 ielen = 2 + spos[1]; if (spos + ielen > ies2 + ies2_len) break; if (spos[0] == WLAN_EID_VENDOR_SPECIFIC && - !_wil_cfg80211_find_ie(ies1, ies1_len, spos, ielen)) { + (!ies1 || !_wil_cfg80211_find_ie(ies1, ies1_len, + spos, ielen))) { memcpy(dpos, spos, ielen); dpos += ielen; } -- 2.19.1