Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1371874pxb; Fri, 21 Jan 2022 16:49:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmLKrOu4K1OFUCAPxI63MDZ9yMgRZu51gExcZOx5S59RF6tEx6p7705KQddxub7bVD3EEc X-Received: by 2002:a17:902:7c97:b0:14a:62ed:c296 with SMTP id y23-20020a1709027c9700b0014a62edc296mr5865516pll.42.1642812591503; Fri, 21 Jan 2022 16:49:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642812591; cv=none; d=google.com; s=arc-20160816; b=tSt6BExH2PoEvWB0xsQVVQD5V8MUwNfVCOJJCCJZJnPKOVqY2YBLdfaj6zBfpTyKLj nWRCKtjc+m+pEDjMF/92rVX5QbkENpTahIHR5xuhPuIpmlaB+EtIvsuhHmyinZM7V7du NdYwkAuZ0gswOXlXU1Yv2+vBf832xNwdzUsGlHpq8b2Le4cICPfAjKhR0x5gm7IPBfMP QOqybzJJE9NKEO6rI2c6zGRscw/RmJlCbldZXL6GBQrtMM3zg/61TSmOj/WN/d10gkFw 9I9Pc0AmyTABztZZ1PYQsOpy+J7Jdk6vdZuKsHLOwUI/0/qvuuy9N2bLylg4uy3s4aO3 MRTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=JAxdv7kT4Nsxroz5r4YBbjTvlv2EcfNPQL0h6dbIX0s=; b=0fN1xxKG2zkr32tDuVNRXWvwg0wR0OoQtDcUpnHcdoURaMXCESTZazd+/EVVGX4+/r YQwXCMFMeFf0AxAqXanMT1cvwwncg1YZnAKRhz4CWbvZu1r1adzYLv4+QsvglVWF9xLg k1UYeR1zyHXaEBhNKVc4jqjt5PJqOK5nIcH9/2oBYZDv1Cpe0ua9ek3IoeTNRu50uvT7 tYEOXB1gNF6K89Ml5MiDDuwvwbP/IHRAkndIvl69wZau7Pdv8QflHMUZux9zygEVmeLC 4MFU2eLgtCy/9De9Qnu7V4r8kVBRLVFS8SP+yFhDM9FtaCZbBxnzMemmWlHW61F0Hmff kwOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b="MF8KcM/1"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k1si2562003pgn.306.2022.01.21.16.49.42; Fri, 21 Jan 2022 16:49:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b="MF8KcM/1"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380116AbiAULWN (ORCPT + 70 others); Fri, 21 Jan 2022 06:22:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380056AbiAULWL (ORCPT ); Fri, 21 Jan 2022 06:22:11 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BDD2C061574; Fri, 21 Jan 2022 03:22:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=JAxdv7kT4Nsxroz5r4YBbjTvlv2EcfNPQL0h6dbIX0s=; t=1642764130; x=1643973730; b=MF8KcM/1G8nFzVjt2ZtHTdJlwTNPtIeOR+oErjQVqTOXiyf MLQZuVJJQPLfd5tCiCq4WzJqarFQ5I9AJlhTxLjDKCMhdtXWyyl4w5uvMv4IKDiMabv/mGMO6B4ka YDx5iKvzFcbRsFosXgkvp4sQMbOv7fa9pYiHjkzhtGa4KsSFg/MWXQJFoCoJ+Ktmd6vV7NeSM5LLj uirdqrH7aObdRRk7SLcTLsK8AbJH8miOxSqKqvpZoA7rnod1AZ7fesj51TdJvDhZjjU1ZGmgLU9gB GqPauMgzOUD+slN7HZ0UUNyr9Q6goJFz4rviUcQhCaM/QSLUPhY9Snrt/yF5ZOkg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.95) (envelope-from ) id 1nArza-008Ti6-G8; Fri, 21 Jan 2022 12:22:06 +0100 Message-ID: <2d33846961e5d5fed80b94696c27be60ecbb11c8.camel@sipsolutions.net> Subject: Re: [PATCH] iwlwifi: mvm: Fix potential NULL dereference for sta From: Johannes Berg To: Takashi Iwai , Luca Coelho Cc: Oliver Neukum , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 21 Jan 2022 12:22:05 +0100 In-Reply-To: <20220121111418.9144-1-tiwai@suse.de> References: <20220121111418.9144-1-tiwai@suse.de> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.2 (3.42.2-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, 2022-01-21 at 12:14 +0100, Takashi Iwai wrote: > The recent fix for NULL sta in iwl_mvm_get_tx_rate() may still hit a > potential NULL dereference, as iwl_mvm_sta_from_mac80211() is called > unconditionally (although this doesn't seem happening, practically > seen, thanks to the compiler optimization). > No objection to the patch, but I think the description isn't quite right? static inline struct iwl_mvm_sta * iwl_mvm_sta_from_mac80211(struct ieee80211_sta *sta) { return (void *)sta->drv_priv; } looks like a dereference, but I _think_ struct ieee80211_sta { [...] /* must be last */ u8 drv_priv[] __aligned(sizeof(void *)); }; means it's just an address calculation, i.e. the same as if we had return (void *)((u8 *)sta + offsetof(typeof(*sta), drv_priv)); no? I guess technically it's still UB doing calculations on a NULL pointer, but practically that's going to work. Anyway, no objections :) johannes