[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b6e8a921-686c-46a6-b6b5-5e88e9b9c114@suswa.mountain>
Date: Thu, 19 Jun 2025 05:35:14 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Dan Williams <dan.j.williams@...el.com>
Cc: Marc Herbert <marc.herbert@...ux.intel.com>,
Greg KH <gregkh@...uxfoundation.org>,
Miguel Ojeda <ojeda@...nel.org>, Benjamin.Cheatham@....com,
Jonathan.Cameron@...wei.com, dakr@...nel.org,
linux-acpi@...r.kernel.org, linux-cxl@...r.kernel.org,
linux-kernel@...r.kernel.org, rafael.j.wysocki@...el.com,
rafael@...nel.org, sudeep.holla@....com,
Kees Cook <kees@...nel.org>
Subject: Re: [PATCH] driver core: faux: fix Undefined Behavior in
faux_device_destroy()
On Wed, Jun 18, 2025 at 05:23:10PM -0700, Dan Williams wrote:
> Marc Herbert wrote:
> [..]
> > In other words, by turning this off unconditionally at the global level,
> > the kernel could actually lose (surprise!) some performance.
>
> I expect the answer is that any compiler that does fail to convert this
> to defined behavior is not suitable for compiling the kernel.
>
> The issue is not "oh hey, this fixup in this case is tiny", it is
> "changing this precedent implicates a large flag day audit". I am
> certain this is one of many optimizations that the kernel is willing to
> sacrifice.
>
> Otherwise, the massive effort to remove undefined behavior from the
> kernel and allow for complier optimzations around that removal is called
> the "Rust for Linux" project.
We turned it off because of the tun.c bug. CVE-2009-1897. It was a fun
story:
https://lwn.net/Articles/342330/
https://lwn.net/Articles/342420/
I would say that if having the compiler automatically delete nonsensical
NULL checks leads to a performance improvement in your code then you're
doing something wrong. Potentially there could be nonsense NULL checks
embedded inside macros, I guess.
But, again, this is a totally different thing from what the patch does.
The faux_device_destroy() code is not doing a dereference, it's doing
pointer math.
regards,
dan carpenter
Powered by blists - more mailing lists