From: Greg KH <gregkh@linuxfoundation.org>
To: Marc Herbert <marc.herbert@linux.intel.com>
Cc: Miguel Ojeda <ojeda@kernel.org>,
Benjamin.Cheatham@amd.com, Jonathan.Cameron@huawei.com,
dakr@kernel.org, dan.j.williams@intel.com,
linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org,
linux-kernel@vger.kernel.org, rafael.j.wysocki@intel.com,
rafael@kernel.org, sudeep.holla@arm.com,
Dan Carpenter <dan.carpenter@linaro.org>,
Kees Cook <kees@kernel.org>
Subject: Re: [PATCH] driver core: faux: fix Undefined Behavior in faux_device_destroy()
Date: Sun, 15 Jun 2025 23:35:10 -0400 [thread overview]
Message-ID: <2025061546-exile-baggage-c231@gregkh> (raw)
In-Reply-To: <a3a08e5d-bfea-4569-8d13-ed0a42d81b2a@linux.intel.com>
On Sat, Jun 14, 2025 at 07:53:34AM -0700, Marc Herbert wrote:
> > the kernel relies on this not being "optimized away" by the compiler
> > in many places.
>
> I think "undefined behavior" is the more general topic, more important
> than null pointer checks specifically?
Is this really "undefined behaviour"? There are a lot of things that
the kernel requires for a compiler to be able to build it, and this is
one of those things, it can't do this type of "optimization" and expect
the output to actually work properly.
> > the kernel relies on the compiler to be sane :)
>
> Undefined behavior is... insane by essence? I'm afraid a few custom
> compiler options can never fully address that. While we might get away
> with -fno-delete-null-pointer-checks right here right now, who knows
> what else could happen in some future compiler version or future
> combination of flags. No one: that's why it's called "undefined"
> behavior!
Again, that's not the issue here. The issue is that we rely on this
type of optimization to not happen in order to work properly. So no
need to "fix" anything here except perhaps the compiler for not
attempting to do foolish things like this :)
> > If "tooling" trips over stuff like this, then we should fix the tooling
>
> Because of its old age, many quirks and limitations, C needs and has a
> pretty large number of external "tools": static and run-time analyzers,
> coding rules (CERT, MISRA,...) and what not. It's not realistic to "fix"
> them all so they all "support" undefined behaviors like this one.
If they wish to analize Linux, then yes, they do need to be fixed to
recognize that this is not an issue for us. There is no requirement
that we have that _all_ tools must be able to parse our source code.
thanks,
greg k-h
next prev parent reply other threads:[~2025-06-16 3:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-13 19:15 [PATCH] driver core: faux: fix Undefined Behavior in faux_device_destroy() marc.herbert
2025-06-13 20:20 ` Miguel Ojeda
2025-06-14 0:33 ` Greg KH
2025-06-14 10:50 ` Miguel Ojeda
2025-06-14 11:53 ` Greg KH
2025-06-14 14:53 ` Marc Herbert
2025-06-16 3:35 ` Greg KH [this message]
2025-06-16 14:02 ` Alice Ryhl
2025-06-18 23:43 ` Marc Herbert
2025-06-19 0:23 ` Dan Williams
2025-06-19 2:35 ` Dan Carpenter
2025-06-19 3:33 ` Marc Herbert
2025-06-19 4:02 ` Dan Carpenter
2025-06-26 0:55 ` Kent Overstreet
2025-06-30 23:24 ` Marc Herbert
2025-06-25 15:20 ` Dan Carpenter
2025-06-25 22:30 ` Marc Herbert
2025-06-25 23:18 ` Dan Carpenter
2025-06-25 15:21 ` Dan Carpenter
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=2025061546-exile-baggage-c231@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=Benjamin.Cheatham@amd.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=dakr@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=dan.j.williams@intel.com \
--cc=kees@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.herbert@linux.intel.com \
--cc=ojeda@kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=sudeep.holla@arm.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