Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5596261img; Wed, 27 Mar 2019 11:22:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaSVflKkbFmcm1yMV1XOhwsF3RCKj0szJcEnVSjJA6QYWZa2BpmtVPymKKL/yWDnU6FAsY X-Received: by 2002:a17:902:f01:: with SMTP id 1mr38009004ply.41.1553710936423; Wed, 27 Mar 2019 11:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710936; cv=none; d=google.com; s=arc-20160816; b=x+Ay6Hp0xJwGto0fjbrOUWa+jDOBTrItZ7iUCdyr1cjuTGRB/I2RxxU252qGXWDSwW ltu8UJ0Mvoj62lxG+Wd1SFS3gJd7iH1Fc7CXD/bJDQmf4W4I1tDVFbbTcXDcL2bIU0B7 8spP1OSwrohQIpv9QKXkRFmwJ3zgRU5qSwouwHRrxZvPO/ISda0HOrCAWvvuNip0pfZD +RQF6ldxvWt9CX3wMpgunK5KNpSN5ZdAxF1E6QIz6pava4ZwG7virDpR+QS2+4d38Ssy qSEXlGp6XHyZIzpRguO/cOxIf7NkmjvhM/+yfOKGrKMQw5l7ZnFWQW6h602jjE4OROL2 tMOg== 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=Y3pJrajuvhZf3X7a2ca7ZvQHgYyBKitqB7eBTfJpERs=; b=oIU1OdpSRnvqbJ7ZFVWwVjWDxrt4N3M1jTSRA0iZumDMvBHvzyEZda/RLWKtiDY0ng 5q6h+dHx2YbcQxqI2irTx/cD4HmidpfV9M9YmQ7/gBxaOQt0bdCDi6lEBVPdUt142P93 k2JdTogIj6ebksRzN8syEJTffpXuB3H91+PDtim1Vz90i3ZX8FLQ2HhjfpIA6mJa3SOf Z9CfXpXsNuzJ5eWlU2H/zr/yBL+sMaUAtfjqPBD9pZkz6eT98XgpcoQTaa0pUYITGnec Dud6l0KA5w2+0ft4ADea6vu7V43rpCHGJkGLySrlhDvFMppGyM9u6TDgD9hHnjtpqAfm dVTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="gsNzh6/O"; 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 b7si20585025pla.195.2019.03.27.11.22.00; Wed, 27 Mar 2019 11:22:16 -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="gsNzh6/O"; 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 S2391165AbfC0SVZ (ORCPT + 99 others); Wed, 27 Mar 2019 14:21:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:39224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391145AbfC0SVW (ORCPT ); Wed, 27 Mar 2019 14:21:22 -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 8D1C72147C; Wed, 27 Mar 2019 18:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710881; bh=62NBNnPu9SNnmesvvyF6HAsOH7LdsagTCki+Evg2+HA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gsNzh6/OdF4NPphrCF46p4xmmYjcBT0JFkbK9vdOMK8yf4nDb7QVwn7KLsWMv+gED jkCUsAneTEjH2EPc689LfiG8FTsharjwccu4fxvaA6LpNN6I3P2Wyf4rxLQxGBXk+m 5cA6Rhiw84ygAQKdEJAtcpreg4riXOnT3Skr/F3c= 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 4.9 24/87] wil6210: check null pointer in _wil_cfg80211_merge_extra_ies Date: Wed, 27 Mar 2019 14:19:37 -0400 Message-Id: <20190327182040.17444-24-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-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 d117240d9a73..b8eeaef17edc 100644 --- a/drivers/net/wireless/ath/wil6210/cfg80211.c +++ b/drivers/net/wireless/ath/wil6210/cfg80211.c @@ -1005,6 +1005,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; @@ -1014,17 +1020,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