Netdev List
 help / color / mirror / Atom feed
From: Qingfang Deng <qingfang.deng@linux.dev>
To: Kees Cook <kees@kernel.org>, Jakub Kicinski <kuba@kernel.org>
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
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	[thread overview]
Message-ID: <6d16da53-0917-45cb-a5eb-5b85de5e2fb1@linux.dev> (raw)
In-Reply-To: <20261015165959.i.798-kees@kernel.org>

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,

      parent reply	other threads:[~2026-10-16 15:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 17:00 [PATCH net-next net] netdev: Hide the netdev_priv() origin from GCC in netdev_from_priv() Kees Cook
2026-10-15 17:07 ` Kees Cook
2026-10-15 17:34   ` Jakub Kicinski
2026-10-15 17:58     ` Kees Cook
2026-10-16 15:19 ` Qingfang Deng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6d16da53-0917-45cb-a5eb-5b85de5e2fb1@linux.dev \
    --to=qingfang.deng@linux.dev \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gustavoars@kernel.org \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=morbo@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pageexec@gmail.com \
    --cc=spender@grsecurity.net \
    --cc=stable@vger.kernel.org \
    --cc=yeswanth@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox