From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CCF3286881 for ; Sat, 21 Feb 2026 22:43:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771713817; cv=none; b=bvvob3eelz22u8XlwzhqjdHRXHvJaWm4lebylLD3rh36ARuWCFv33rcfCF2JYcY0lNSHZHlxxVaEhaJa5QCyNtpEOZ33IDx1eXwttaCdNWXmJGy2lGORktfuuvRgwejabBsFfAXH2i5Z/ij3lqVO+RyjxM/oG2f8hqdOJr3RFvY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771713817; c=relaxed/simple; bh=eyQ6sJ0ZiX7SlU8lJ29ITyQtZDx0efjzsfJPpnPFWjs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nDED6t/+F/T7FeSzuc6F43DB5g21oSAV5a6Wd8GkFyLjN7d21tXpoVPfOyoHqYt9yIyqZT12b0SHgfyyYioLoLk2tPLo47oT2f6X3aFQudl/SBJ/vm59HeDVVbB8Wmoqq/W5Yi2InEwz7Ij0BVZOB2gHMhl2phYErXbs2FubLc4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c+piPLyK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c+piPLyK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE110C4CEF7; Sat, 21 Feb 2026 22:43:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771713817; bh=eyQ6sJ0ZiX7SlU8lJ29ITyQtZDx0efjzsfJPpnPFWjs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c+piPLyKT4DFH/HB2HlFrbz1ZOBVUIIymkDp4yQoEa5cEj7Pbmnyx4F0tr5vKOXqu gkFSd3Ppzz7x63nfZisX8bLw2BgL2lwuo3wzcLSZAODfA6LmezXiLn4bGjRakGs/jT E8Wocakv3OkzkZNzM+2+sVGvXd29lgF+GrNcDFAYp/JpRePaLpgTCrHWMgY5WGaluO H14jT+BIZmpjhfA+4KAJiugH4ZVBkftVVcpa6M7lU2nO7gy+70txiwjL56hl0Dzabv sEh3qYLdfE7FhfcwImofs+qG4qDuYqqzS1RqgpHXJAMlG6nT2C4zkzloFcXHwa/iJq 6TdwioD8+SwSw== Date: Sat, 21 Feb 2026 14:43:36 -0800 From: Kees Cook To: Linus Torvalds Cc: linux-kernel@vger.kernel.org Subject: Re: [GIT PULL] kmalloc_obj treewide refactor for v7.0-rc1 Message-ID: <202602211442.1BE76271@keescook> References: <202602210108.0EABDA1CDD@keescook> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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