public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Kees Cook <kees@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [GIT PULL] kmalloc_obj treewide refactor for v7.0-rc1
Date: Sat, 21 Feb 2026 17:08:47 -0800	[thread overview]
Message-ID: <20260222010847.GA2135@quark> (raw)
In-Reply-To: <202602211508.57394C771A@keescook>

On Sat, Feb 21, 2026 at 03:19:56PM -0800, Kees Cook wrote:
> On Sat, Feb 21, 2026 at 03:01:15PM -0800, Linus Torvalds wrote:
> > But I think I found the real bug:
> > 
> >    #define overflows_flex_counter_type(TYPE, FAM, COUNT)           \
> >            (!overflows_type(COUNT, typeof_flex_counter(((TYPE *)NULL)->FAM)))
> > 
> > WTF is up with that '!' there? That seems entirely bogus. So now
> > overflows_flex_counter_type() will return true in it *doesn't*
> > overflow the type.
> > 
> > So I think clang was not actually the problem. That whole code looks buggy.
> 
> I would agree. This code mutated a few times but the logic and
> docs for this function are in sync ("Returns: true if @COUNT can be
> represented") but I renamed it somewhere along the way in a confusing
> way and then got the above quoted macro's usage wrong.
> 
> > But that actually makes me *less* happy, because it means that this
> > whole patch must have been ENTIRELY untested in any shape or form.
> > 
> > If I read this right, none of this should have successfully booted
> > anywhere if you had actually tested it outside of just compile-testing
> > it.
> 
> Right, I am surprised as well, since I explicitly did boot testing on
> the tree-wide refactor, though I admit the most recent validation over
> the last few weeks has been on the compile testing side due to tracking
> down type mismatches.
> 
> FWIW, I have now been able to reproduce the objtool warning, though,
> using Fedora 42's Clang 20. I'm frustrated that it didn't show with the
> other builds I did, and that 0day never sent a single email about it
> over the weeks that I've had my tree up for testing.

Just spent a while bisecting why the kernel wasn't booting on
8934827db540 with clang 21.1.8 before I noticed Linus's fix (for a pull
request that wasn't Cc'ed to any mailing lists other than linux-kernel).

Do we have a sense of how this made it in?  __flex_counter expands to
'(void *)NULL' for clang versions before 22 (despite the incorrect
comment above it that says clang >= 19), causing typeof_flex_counter to
evaluate to size_t, causing (!overflows_type(COUNT,
typeof_flex_counter(((TYPE *)NULL)->FAM))) to always be true on 64-bit.
So it looks like k*alloc_flex() always returned NULL, unless the kernel
was built with pre-release clang 22.  Not sure what I'm missing.

It looks like the conversions of kmalloc() et al to kmalloc_flex() et al
were never in linux-next, so presumably that was a factor?

- Eric

  reply	other threads:[~2026-02-22  1:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-21  9:18 [GIT PULL] kmalloc_obj treewide refactor for v7.0-rc1 Kees Cook
2026-02-21 19:49 ` Linus Torvalds
2026-02-21 20:16   ` Linus Torvalds
2026-02-21 22:33     ` Linus Torvalds
2026-02-21 22:43       ` Kees Cook
2026-02-21 23:01         ` Linus Torvalds
2026-02-21 23:19           ` Linus Torvalds
2026-02-21 23:19           ` Kees Cook
2026-02-22  1:08             ` Eric Biggers [this message]
2026-02-22 14:50               ` David Laight
2026-02-22 17:34                 ` Kees Cook
2026-02-23  9:19                 ` Geert Uytterhoeven
2026-02-21 22:37     ` Kees Cook
2026-02-21 22:43       ` Linus Torvalds
2026-02-21 22:46   ` Kees Cook
2026-02-22  4:52   ` Linus Torvalds
2026-02-22  7:05     ` Kees Cook
2026-02-22 10:44     ` Julia Lawall
2026-02-22 17:37       ` Kees Cook
2026-02-22 10:38   ` David Laight
2026-02-21 19:55 ` pr-tracker-bot

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=20260222010847.GA2135@quark \
    --to=ebiggers@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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