Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1032567yba; Thu, 4 Apr 2019 02:53:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXQrC5qr+6eAc6WnP3TzVjnwV6x6M1p4ssWBwK6bU1p4WxZGOvTlTIfA90cbOn3TdJB13d X-Received: by 2002:a65:518b:: with SMTP id h11mr4910796pgq.41.1554371606502; Thu, 04 Apr 2019 02:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554371606; cv=none; d=google.com; s=arc-20160816; b=XFjRlq1Wkq++WYMggJ6NGQ620/aC+s5Z9HdesrkNymX5I/r8RFcThfd37VyqQOMxZ0 Qt5HgC1iOMBD7gTnZp/6N8U4yCXCod2AHNA5wTQx74eOifRDN91aXNnwZsmvFME+fPvv H4+7WElKv27Jc8gTgvaexeNPzFO6I81+PX9yXQq8VPK89M4hgOr0KOFxOU3So4rOKsYg vRdgCY3Mh4MDHMpdw5bf/aCL5/es39l6iOllBCCtANnjgU60Zwj/wpzSJW6wpoRhNBSd sBAKptUJGzC+jUnkwCCvZAChqn8HSEEIQ7IMUaoZc4rhB56wLxEV1WMbPVd55NrBxA+i Ld8g== 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=YQ7svk24qLGBADQ0s4j3UYbz3Q7snVSagNbrgjGZXo8=; b=ve2LZRGVhS5rLEu4QoefJlChyFLs61D2XR6cuKNxDKW1nPVKcsaGgRcnsFyRsonU1U R27+avWBI6+gSkDZ9BTMK1fGzm6n8xucpMf3uMVbXxgHMozShkMK3qPew3zPglKlDWZE lKywjLDvG6E2JGxKHWJ/CnVgsAL4XKU5z8igEMOWoyyPh5ZxgfIKL5gpey1hgQRhmIL1 Nqq1bY1IVh9148CHfRROHgmqe9AVzv8S6EFh0cLz3QWstZAje2aNces9n9nG5ffNGTZO n5ewNu0zNckbeBPMdADux2YvxbI1yu1Hyka3teLm4N5xariXLToK1U/bv/mIROmJ+wZ9 A1Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ltp3pFVr; 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 h8si527534pgg.573.2019.04.04.02.53.11; Thu, 04 Apr 2019 02:53:26 -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=ltp3pFVr; 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 S1730398AbfDDJv0 (ORCPT + 99 others); Thu, 4 Apr 2019 05:51:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:57784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730155AbfDDIzA (ORCPT ); Thu, 4 Apr 2019 04:55:00 -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 2E81020693; Thu, 4 Apr 2019 08:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368099; bh=v7I6ciQfvTlvvf5jL4azmw9jcynwdPjFOVEzmLvj1fI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ltp3pFVrHCiY+YuiP9oG4JGstg0QoHSeA40b9Y7GqGJ0fuAgfp8Yo2AL9pOHBFQg6 M9ftKdCJtuDxvVB7g6N0jXIdG8y9Wecy+hSGwx/85mEbcCYmyw5CQMHephpkSPQ6Fv v8kSJgR9ghDxxyiqx+Zw7+1W7v+NMKJvcXUdfV7s= 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.14 037/121] wil6210: check null pointer in _wil_cfg80211_merge_extra_ies Date: Thu, 4 Apr 2019 10:47:05 +0200 Message-Id: <20190404084547.323916592@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084545.245659903@linuxfoundation.org> References: <20190404084545.245659903@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.14-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 85d5c04618eb..c374ed311520 100644 --- a/drivers/net/wireless/ath/wil6210/cfg80211.c +++ b/drivers/net/wireless/ath/wil6210/cfg80211.c @@ -1224,6 +1224,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; @@ -1233,17 +1239,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