From patchwork Fri Nov 25 11:36:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 13055790 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DE0EC4332F for ; Fri, 25 Nov 2022 11:37:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbiKYLhI (ORCPT ); Fri, 25 Nov 2022 06:37:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbiKYLhI (ORCPT ); Fri, 25 Nov 2022 06:37:08 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6561D1B9F3 for ; Fri, 25 Nov 2022 03:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=ObEfr3YFJGLp+iu0VZx4A2Vp2Hs0y1gxqaaC/z/LPFY=; t=1669376227; x=1670585827; b=EqZCF8VydxQSpvmmRTUEVEdqNQRqscTZGUbD7QH7nAPsgWhQrnV1bqQ905HsISYStzhhKHAGTr0 YpWAGkg+aqCZaWUtERDTkuFvW7NYREhB+a3nsI+/QtdJSj33oWH66RfGctZj7E8/ctj8pifgpzmvB faiV7CLoFxzk3lPF+1WVzngixDYe+BS9Vtr5nblETArVb5SWqkuZcgmvB96k6GndUaYcLR2FzcGh5 35KzlZwQHmdbLL6iTTiEb25Jj2KNYo7WMka2OFP4izEdh4AKp3OhYPy7lxnRsklZgPUZqiIH13b7+ k1oFeLpngLEGAxe00C20fUt8bhlFCPcfapgQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1oyX0w-008pvO-0m; Fri, 25 Nov 2022 12:37:02 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , =?utf-8?q?S=C3=B6nke_Huster?= Subject: [PATCH 1/2] wifi: cfg80211: fix buffer overflow in elem comparison Date: Fri, 25 Nov 2022 12:36:57 +0100 Message-Id: <20221125123657.44ab63af8fc7.Ib449c5f95120320db924edf5935133467eedc3d2@changeid> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg 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 --- 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 da752b0cc752..4d217798890a 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 */