From patchwork Fri Jun 16 06:53:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Greenman, Gregory" X-Patchwork-Id: 13282114 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 511AAEB64D7 for ; Fri, 16 Jun 2023 06:55:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231452AbjFPGy7 (ORCPT ); Fri, 16 Jun 2023 02:54:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243313AbjFPGyq (ORCPT ); Fri, 16 Jun 2023 02:54:46 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27C9B1FE8 for ; Thu, 15 Jun 2023 23:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686898485; x=1718434485; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bSiwSDUtBRojHisQFABP50ysAph75Bvd/nyXMbVHAQY=; b=H73B5ZJZtPtNPol67L2CGerJPHd5j1HCCZQCbKDN0Wj5tz5GWZyKR/RN FMLabMW2stwRriCMPo4hVfcEOKfmpw9xggej7nCLc3u8Z3eW6nUpQ0hv8 28TwkORUSwo+9fMnoammdyQ4dW+Tj8qRTfMMaXim5Z69CezJWXDo/yqRO SbizW1z0Mh5stGCcJe/3K3k3pan/TS8/G3DicW21M1Yq3tGK0y+n7yZ7E N/Vpvvbta55jGta8NIWX4w7lc/XHWz+TQCjeX+LljOEaj9jyzfOc3Vsz1 rlFwbOPFbYFwKddEPXBp7am0REavhXVXittfAikIBjcoDEF2bbsSzzW4g A==; X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="425078859" X-IronPort-AV: E=Sophos;i="6.00,246,1681196400"; d="scan'208";a="425078859" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 23:54:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="802720061" X-IronPort-AV: E=Sophos;i="6.00,246,1681196400"; d="scan'208";a="802720061" Received: from ereznaim-mobl.ger.corp.intel.com (HELO ggreenma-mobl2.intel.com) ([10.214.237.118]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 23:54:38 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Anjaneyulu , Gregory Greenman Subject: [PATCH 07/20] wifi: mac80211: add consistency check for compat chandef Date: Fri, 16 Jun 2023 09:53:56 +0300 Message-Id: <20230616094948.ae0f10dfd36b.Iea98c74aeb87bf6ef49f6d0c8687bba0dbea2abd@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230616065409.633290-1-gregory.greenman@intel.com> References: <20230616065409.633290-1-gregory.greenman@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Anjaneyulu Add NULL check for compat variable to avoid crash in cfg80211_chandef_compatible() if it got called with some mixed up channel context where not all the users compatible with each other, which shouldn't happen. Signed-off-by: Anjaneyulu Signed-off-by: Gregory Greenman --- net/mac80211/chan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 168bf3edd4b4..68952752b599 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -802,6 +802,11 @@ void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local, } } + if (WARN_ON_ONCE(!compat)) { + rcu_read_unlock(); + return; + } + /* TDLS peers can sometimes affect the chandef width */ list_for_each_entry_rcu(sta, &local->sta_list, list) { if (!sta->uploaded ||