From patchwork Wed Dec 20 11:41:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13498662 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 39554381A1 for ; Tue, 19 Dec 2023 17:41:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Oa0Qwmh2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703007699; x=1734543699; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KXQyt1jc1mVsBdrfXw9RuYec/PY+btKgN31FA0aoVJA=; b=Oa0Qwmh2GM6pUkjZbDpqLzd973vJRMKFrfcQUJhk1p9bBmUwoBvrPrtM K4Pak+09FddyaxQmlQCsyvmoQ6QQO4D2fF8QsNTwTPtXN2V4Y4j5IkVgd OPCxF12fjkUelxBRhxtTiTGblQt3y5Op9CWuUPoboQ0qkuKyI+atKK7jd 45VrEvrMWYXrhJqKnswgs+RftELPOL7NAV0vJhhV4AxwpnDW+axglQKim +9K+6CHL0HFSb780uYilobhZcjt0ZZsCPBHQ3Tb1ID+07Z4MLoey5JgPx G1CQXQmvdDCWlptm3oNdVX3Srm1xzc5JZf+zJwX0ERjiotbiJtCX7GzXf A==; X-IronPort-AV: E=McAfee;i="6600,9927,10929"; a="2790525" X-IronPort-AV: E=Sophos;i="6.04,289,1695711600"; d="scan'208";a="2790525" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2023 09:41:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10929"; a="894370271" X-IronPort-AV: E=Sophos;i="6.04,289,1695711600"; d="scan'208";a="894370271" Received: from unknown (HELO WEIS0040.iil.intel.com) ([10.12.217.108]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2023 09:41:37 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Benjamin Berg , Johannes Berg Subject: [PATCH v2 10/13] wifi: cfg80211: avoid double free if updating BSS fails Date: Wed, 20 Dec 2023 13:41:43 +0200 Message-Id: <20231220133549.8891edb28d51.Id09c5145363e990ff5237decd58296302e2d53c8@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231220133549.bdfb8a9c7c54.I973563562969a27fea8ec5685b96a3a47afe142f@changeid> References: <20231220133549.bdfb8a9c7c54.I973563562969a27fea8ec5685b96a3a47afe142f@changeid> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Benjamin Berg cfg80211_update_known_bss will always consume the passed IEs. As such, cfg80211_update_assoc_bss_entry also needs to always set the pointers to NULL so that no double free can occur. Note that hitting this would probably require being connected to a hidden BSS which is then doing a channel switch while also switching to be not hidden anymore at the same time. Signed-off-by: Benjamin Berg Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- v2: Fix wrong email addresses --- net/wireless/scan.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/wireless/scan.c b/net/wireless/scan.c index f7fd7ea0e935..cf2131671eb6 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -3194,10 +3194,9 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev, if (new) { /* to save time, update IEs for transmitting bss only */ - if (cfg80211_update_known_bss(rdev, cbss, new, false)) { - new->pub.proberesp_ies = NULL; - new->pub.beacon_ies = NULL; - } + cfg80211_update_known_bss(rdev, cbss, new, false); + new->pub.proberesp_ies = NULL; + new->pub.beacon_ies = NULL; list_for_each_entry_safe(nontrans_bss, tmp, &new->pub.nontrans_list,