Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5654075img; Wed, 27 Mar 2019 12:31:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBEV3XzSWUjPBfaCpt+OwTgQjllQtqiDPamdEpSsaG7KRz2+ZImUcDo+LbUMOv4c0zR5KV X-Received: by 2002:a17:902:7247:: with SMTP id c7mr19578881pll.255.1553715094228; Wed, 27 Mar 2019 12:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553715094; cv=none; d=google.com; s=arc-20160816; b=cg3WSt1SoxW4TY1hXa6lTdkC9F9ylyXT1FNLsTrFu17p+VDyWZuhuaqd2tSEZT5c+h QSgnlQWEEnr6tM19esh91+c6V4PPvg7rcV4/ljZHkGmEndreBYF5MnOhB8/5h9UvbAPz NFBHkEFtVHnbguefrI63L+lL2S82Sdj5tS1tkPJTpJj+8Dbq9f2V8dNdO5EZYgzIo9MI +qA9y4OBnBtIE7ex6a3gAHZZhWx9b32gXi1ZDPkEoxeKQ5uOfso651rFEdGmJAiE9SIP CIYRrQn3znmv4y6Gc8l3L6BVBTuiFh2hU3SEGE+/pxzSAY6VL6DMzcSy7nU81LvJBowo lpSQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5kyRJxkcSjKd8tc78VDj9MoUO8OoqX+469D72xn/xOM=; b=nltH2rH5nf2Pa5pQ4clrVESiU2hxCizRqIpPoL7XJmM72Tdh7OfYUEPN1y0pnp6vpa Rc07iWse7pCUBDDZNPEAZ86S9vvWA+ibmrQ3guh/plELutNsGYyVljLUhpJLJYpFN0IP h8dhy3G+qYnhwhkUOSA6EKe9Vu3u2DrJPhRzlPSCYam56iJlZ4et2x0YjYMc9Z83vnB6 3BxPDFKnUiIiedOS+feTe881tvVd20Bye16Pq5zYaW+UrLvmQdrenqeKSJaE1fwUoibI 1TpSVwvdGAt0IXPEeZSvOFaqsKNZBjYejIjOjTL2TrwTniGpdRMRDiKnhdYg9axrAhbg Yx+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jlAqhPYz; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7si5294069pgp.161.2019.03.27.12.31.19; Wed, 27 Mar 2019 12:31:34 -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=jlAqhPYz; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733294AbfC0T3b (ORCPT + 99 others); Wed, 27 Mar 2019 15:29:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:44264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729654AbfC0SDv (ORCPT ); Wed, 27 Mar 2019 14:03:51 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C76F521738; Wed, 27 Mar 2019 18:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709830; bh=SoVOCdC15/PQPK4a9Q4e0ljyx+ZSSoygdzcp2yAvQQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jlAqhPYz8qb9qe5l7nAuTr8F4pqIlNxVpJCPh1geLFL8966fNX+XU224qcJZOqrkw d9mSGvWeB0jv8J2QVZ4+MqyXETvuMgRbYIRNnXqLavqsOR5OfFSqD5VcajaHy28bq1 yjh9TEvhUuH6XkvfNgELjbpoaYd8B6DoqnHxx1tg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexei Avshalom Lazar , Maya Erez , Kalle Valo , Sasha Levin , linux-wireless@vger.kernel.org, wil6210@qti.qualcomm.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 063/262] wil6210: check null pointer in _wil_cfg80211_merge_extra_ies Date: Wed, 27 Mar 2019 13:58:38 -0400 Message-Id: <20190327180158.10245-63-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexei Avshalom Lazar [ 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 9b2f9f543952..5a44f9d0ff02 100644 --- a/drivers/net/wireless/ath/wil6210/cfg80211.c +++ b/drivers/net/wireless/ath/wil6210/cfg80211.c @@ -1580,6 +1580,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; @@ -1589,17 +1595,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