public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [GIT PULL] kmalloc_obj treewide refactor for v7.0-rc1
Date: Sat, 21 Feb 2026 14:43:36 -0800	[thread overview]
Message-ID: <202602211442.1BE76271@keescook> (raw)
In-Reply-To: <CAHk-=whEd020BYzGTzYrENjD9Z5_82xx6h8HsQvH5xDSnv0=Hw@mail.gmail.com>

On Sat, Feb 21, 2026 at 02:33:16PM -0800, Linus Torvalds wrote:
> it it has decided that the flush_backlogs_alloc() call should result
> in an unconditional WARN_ON(). The string associated with that
> WARN_ON() is
> 
>      overflows_flex_counter_type(typeof(struct flush_backlogs), w, __count)
> 
> which I guess is not surprising: that's exactly what that
> 
>         kmalloc_flex(struct flush_backlogs, w, nr_cpu_ids, GFP_KERNEL);
> 
> change would do.
> 
> So in clang's world, the code that follows - that sets
> 'dev_boot_phase' to zero among other things - never happens, because
> that kmalloc_flex() unconditionally returns NULL after the warning.

UUUuuuuggh.

> I do not think this is fixable. I complained about the overly
> complicated macros earlier, and suggested you only do the minimal and
> obvious kmalloc_obj() without any of the flex crap.

How about this, then?

diff --git a/include/linux/slab.h b/include/linux/slab.h
index c5fde8740281..1270320b59c8 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -1003,11 +1003,7 @@ void *kmalloc_nolock_noprof(size_t size, gfp_t gfp_flags, int node);
 ({									\
 	const size_t __count = (COUNT);					\
 	const size_t __obj_size = struct_size_t(TYPE, FAM, __count);	\
-	TYPE *__obj_ptr;						\
-	if (WARN_ON_ONCE(overflows_flex_counter_type(TYPE, FAM,	__count))) \
-		__obj_ptr = NULL;					\
-	else								\
-		__obj_ptr = KMALLOC(__obj_size, GFP);			\
+	TYPE *__obj_ptr = KMALLOC(__obj_size, GFP);			\
 	if (__obj_ptr)							\
 		__set_flex_counter(__obj_ptr->FAM, __count);		\
 	__obj_ptr;							\


I'll go see if that helps.

-Kees

-- 
Kees Cook

  reply	other threads:[~2026-02-21 22:43 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 [this message]
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
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=202602211442.1BE76271@keescook \
    --to=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