From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F90915C83 for ; Mon, 5 Dec 2022 19:24:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89142C433C1; Mon, 5 Dec 2022 19:24:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1670268286; bh=KpwyfLtPyW45xWAgdIDGpA3Yd//6SRULFvhWO3w+PCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HYNWtwxXK9QqaTg6PR/GwWtA0abqH3x8j8CDwiljgm1FWgqpMh0HZL9dTGmJTC1DA Rse5JDtsytyzI/+1GYlPj8chYjpHL+ZRZax6n5UptpyZiETJ7MJlYtTSjWnp/fK9AT URr55WhVgeOyFtgeoQyRhSM2dsXgOgsxea5tTpQw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johannes Berg , Sasha Levin , =?UTF-8?q?S=C3=B6nke=20Huster?= Subject: [PATCH 6.0 047/124] wifi: cfg80211: fix buffer overflow in elem comparison Date: Mon, 5 Dec 2022 20:09:13 +0100 Message-Id: <20221205190809.775226894@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221205190808.422385173@linuxfoundation.org> References: <20221205190808.422385173@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Johannes Berg [ Upstream commit 9f16b5c82a025cd4c864737409234ddc44fb166a ] For vendor elements, the code here assumes that 5 octets are present without checking. Since the element itself is already checked to fit, we only need to check the length. Reported-and-tested-by: Sönke Huster Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- net/wireless/scan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 9067e4b70855..56db0f12ca7c 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -330,7 +330,8 @@ static size_t cfg80211_gen_new_ie(const u8 *ie, size_t ielen, * determine if they are the same ie. */ if (tmp_old[0] == WLAN_EID_VENDOR_SPECIFIC) { - if (!memcmp(tmp_old + 2, tmp + 2, 5)) { + if (tmp_old[1] >= 5 && tmp[1] >= 5 && + !memcmp(tmp_old + 2, tmp + 2, 5)) { /* same vendor ie, copy from * subelement */ -- 2.35.1