From mboxrd@z Thu Jan 1 00:00:00 1970 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 BCD16C433F5 for ; Fri, 21 Jan 2022 11:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380157AbiAULaP (ORCPT ); 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