Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1372724pxb; Fri, 21 Jan 2022 16:51:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJww6asabPa4EOJuPaU5X3wFnAKFX8X8z/yG53E/fn2dpOj6UynAsekopaMqzJ2R9/ToSTqq X-Received: by 2002:a05:6a00:21c2:b0:4bc:fb2d:4b6f with SMTP id t2-20020a056a0021c200b004bcfb2d4b6fmr5750823pfj.62.1642812699637; Fri, 21 Jan 2022 16:51:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642812699; cv=none; d=google.com; s=arc-20160816; b=zgPQJR29whUzFae7MhElP7hWz/2B5T6esiYlDEtSXvkSdC11Y4Mhpk6HpEnHi1RmIV ARnezK8AGZaX5KSNEiWab/pvTwvp25iS1ttwFPjWDB0VUnQYpgMxzEEwHIact/KV6h2J rl7cASZNdaRo+CG1cIQEIVBWJemBYGVhFx0dHULOgfcTO0E5mK25Q9XdRKCt07O964Sr CLlF9g7cDQw+VDwUHMt5cZYE/YYyNdFr8Yhod989rIOOnGNN27kIWm1W58JXBpxrFCQO LxJ01CoimQLeZOJrN7IxjutivW8fbh+VL+qxU6UGeZY3dAGJ0HAegyodiWe4L0vopV8y 3qEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=C6fOV9ZnCp87a8aU1KBASPck9Kn8tEpnXYSHq3YJkx4=; b=g2K9yk9UsGiUX4IdlIr+ENl7eBWfQICOXU5ck8sko24l/y7MSDuc9MUNI7UDza+8LS VLj6mAF8iL2CEf6RNgaghkwxgBeqsCrISp6t1156JOvyCj4aZ2RuqDJ9K2jvrK095n4Q ftqLHWdURcxTe82wdzozEDHGbHEs4q6s9o1rUdeJhtANf+kBDaCX20ppcAwVT/AWwe+J OUKtxdbC6kRoJy8hu9zBIsGkYP00tAJ4HUSAXhrzwuihohnaqbWYfgdXX2NUHw35B6oM l9VJ/MKD69mYzxgn+949l1qDoP5VxUamUhGuAjeQrBAZ58/wuU4wg5O1+ldr0bkJwvgy kiLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Gwh0q+0m; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r14si7179369pgj.814.2022.01.21.16.51.31; Fri, 21 Jan 2022 16:51:39 -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=@suse.de header.s=susede2_rsa header.b=Gwh0q+0m; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380157AbiAULaP (ORCPT + 70 others); Fri, 21 Jan 2022 06:30:15 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:56636 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349905AbiAULaO (ORCPT ); Fri, 21 Jan 2022 06:30:14 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A1BA521128; Fri, 21 Jan 2022 11:30:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1642764612; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=C6fOV9ZnCp87a8aU1KBASPck9Kn8tEpnXYSHq3YJkx4=; b=Gwh0q+0mHFtM4/ElbA0Y0h9l6UDT7Wj9XO0em89nA6XWn2Mt8D3X579Su/ISX6PrYv6ldt d7FrF4rel2j438FNxTy/5CVia40V8e/qBeTebG9JdAlVxWNnNHW+fZ7+Lc/aJnGMCPNrMs T+TqiGI+yNm1ZF/bGgL9gOEUXN6gQFo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1642764612; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=C6fOV9ZnCp87a8aU1KBASPck9Kn8tEpnXYSHq3YJkx4=; b=d+Y9s/i6xaCp21NKL13zHZzoZArTDbWjBMBrnRQrISuAfsFP52yWc2a853pWbavP/lEQZu +bgwdF+VuZJ2RZBg== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 90352A3B83; Fri, 21 Jan 2022 11:30:12 +0000 (UTC) Date: Fri, 21 Jan 2022 12:30:12 +0100 Message-ID: From: Takashi Iwai To: Johannes Berg Cc: Takashi Iwai , Luca Coelho , Oliver Neukum , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iwlwifi: mvm: Fix potential NULL dereference for sta In-Reply-To: <2d33846961e5d5fed80b94696c27be60ecbb11c8.camel@sipsolutions.net> References: <20220121111418.9144-1-tiwai@suse.de> <2d33846961e5d5fed80b94696c27be60ecbb11c8.camel@sipsolutions.net> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, 21 Jan 2022 12:22:05 +0100, Johannes Berg wrote: > > 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? Yeah, indeed, that won't access the member. > I guess technically it's still UB doing calculations on a NULL pointer, > but practically that's going to work. > > Anyway, no objections :) OK, I'll submit v2 with rephrasing for avoid confusion. Takashi