Article View: linux.kernel.netdev
Article #4024Re: [PATCH net-next net] netdev: Hide the netdev_priv() origin from GCC in netdev_from_priv()
From: Qingfang Deng
Date: Fri, 16 Oct 2026 15:19
Date: Fri, 16 Oct 2026 15:19
26 lines
6846 bytes
6846 bytes
Hi,
On 10/16/2026 1:00 AM, Kees Cook wrote:
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2838,6 +2838,13 @@ static inline void *netdev_priv(const struct net_device *dev)
> */
> static inline struct net_device *netdev_from_priv(const void *priv)
> {
> + /*
> + * When GCC can see that @priv came from netdev_priv(), it can
> + * compute an object size of 0 for the net_device and its members,
> + * which makes FORTIFY_SOURCE fail valid accesses through the result:
> + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127875
> + */
> + OPTIMIZER_HIDE_VAR(priv);
If this bug only affects GCC, you may wrap it with a
#ifdef CONFIG_CC_IS_GCC block.
> return container_of(priv, struct net_device, priv);
> }
>
Kind regards,
Technical Details
Message-ID:
<6d16da53-0917-45cb-a5eb-5b85de5e2fb1@linux.dev>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347396-linux-kernel-netdev=dewy.ruReferences:
<20261015165959.i.798-kees@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347396-linux-kernel-netdev=dewy.ru From: qingfang.deng@linux.dev (Qingfang Deng) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next net] netdev: Hide the netdev_priv() origin from GCC in netdev_from_priv() Date: Fri, 16 Oct 2026 23:19:02 +0800 Organization: Usenet Network Message-ID: <6d16da53-0917-45cb-a5eb-5b85de5e2fb1@linux.dev> References: <20261015165959.i.798-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="2801784"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:mvQ4S3479RsqO4KqWT+4iFCxz9Q= sha256:1KiCIqu4cdxrdDjOiyCJfAYt8xp+YDCUqZ7t360MtvI= sha1:FkZt8dC+MeM7BBQzUUWyLSZ1TTY= sha256:tLygGD2K02r8fTo60sYpCPoyPCM2yNBme6MhVkyZORQ= Content-Language: en-US List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 73C6211055B; Fri, 16 Oct 2026 18:34:05 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.05 X-Spam-Status: No, score=-2.05 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qHoUXEpAr8NO; Fri, 16 Oct 2026 18:34:02 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-347396-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id D923B110540; Fri, 16 Oct 2026 18:33:54 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sto.lore.kernel.org (Postfix) with ESMTP id 6FCE46041CD; Fri, 16 Oct 2026 15:19:26 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4958D4DAFB3; Fri, 16 Oct 2026 15:19:19 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="EmSs2cBc" X-Received: from mta1.migadu.com (out-141.mta1.migadu.com [95.215.58.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25AE34772B5 for <netdev@vger.kernel.org>; Fri, 16 Oct 2026 15:19:15 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.141 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792163959; cv=none; b=iqsYwZPzQblk2CbfFZq3V8zSL1VfyTBatYdwclepGv4xurNMHsk9tcWfRjjFXomv+bbunL337Qyqr3rxBVQm7qRF9iSPbdr41R86ontSv/N2Pf6FwTSzJDo9Ma/WNSrwdzQSbUtlJWzYOyYndblr9/93DQUPVoDK0j/umAWKbSo= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792163959; c=relaxed/simple; bh=JgjAGc1yvO+GZR/lMz41Sy+B81/XedX2R7qPQROM1P0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pLdrOvkeo4xtCZ2mkW3u+WdidKNvIj5p/rxMZg7FQRjL+Co+bdqDC5DglxN/WJX0mgB3PRkpxeqHVMhouJKjgbvXUQ0ppGpPO9Fisj5Lno/ZD4eHX2mIXAjP1TZf1IdjG82MynU3+IEWEr1UqB3adGXVBWGqdxBVwHnRfrBeawU= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=EmSs2cBc; arc=none smtp.client-ip=95.215.58.141 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=JgjAGc1yvO+GZR/lMz41Sy+B81/XedX2R7qPQROM1P0=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1792163954; v=1; x=1792768754; b=EmSs2cBcB3doNAIjtpdTkto7UMnK2jB3+G1bdN15msWzaKjPK5kl99gpT7nHePSyOk10YEEG yqY9ITUenWi29PZ/YdZ3rxVvC6+9Djmdyu5DwPG3jC0jXIPYdURLqks/AEXGvFqCPfM80UWv3Ld LsBsfQRVBlBOXiCJN4Lmp0Yo= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 8e118369b878a887; Fri, 16 Oct 2026 15:19:13 +0000 X-Mizu-Trace-ID: 8e118369b878a887 X-Migadu-Flow: FLOW_OUT X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-User-Agent: Mozilla Thunderbird X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Jiri Pirko <jiri@resnulli.us>, Brad Spengler <spender@grsecurity.net>, PaX Team <pageexec@gmail.com>, Bill Wendling <morbo@google.com>, Justin Stitt <justinstitt@google.com>, netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-hardening@vger.kernel.org, Yeswanth Krishna Tellakula <yeswanth@linux.ibm.com>, stable@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261015165959.i.798-kees@kernel.org>