From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38121477E43 for ; Tue, 20 Jan 2026 19:15:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768936548; cv=none; b=TUhhHzMPyWjjBuLaZX6XwX5av7yLDq+GaV/2nQMUzyrAPdXc6VVO3eaJrVfJpXrPW1ZoEZkeM6hOR0JpHr/0vHdPQ14E3YVFioZboufcwa1oLbJbsrRTR+H2tq5sg1gPSwIZr/ATpeCZdgH4RX5Po9pFafIuhIU3PCCOnPKx3nc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768936548; c=relaxed/simple; bh=1N7H+yfpk2NLIOr7BO59rbs9SEWHKeyOlq2YvA8BBU8=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NH1PUY0k2/WpAAd6ZRI6YUF5lHo5FdqqZpVIypbcSXAwgmy/Ny9EmymC94RjBrJpdHgEt3eROBtjkOD3gcNoHA762r5fvYkxp1LnzurjjaNDulbQ3Fa3asO6B7juPv9+oy8ao3FE457qEh2Ly2eKPQW5vA0cs6XlQUZxjrbaCzY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=a8XFpMP0; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a8XFpMP0" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-47edd6111b4so52765005e9.1 for ; Tue, 20 Jan 2026 11:15:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768936543; x=1769541343; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=C0qoWHj+Pupz+7dBvH/HjJvQAh+/X6Q7iQzogpkXbi8=; b=a8XFpMP07xNVWkfxaeWpj5YXch3RTYsxN627l0CQBozCisd2qH4lzpn3k/K7D76qL2 ndiLURYa5r1Y7sONFTj+MTrr6IllG1TQhfTfmJ0Wsx3i7m+TB+daeFLv2Z/LDwQAiWTX Hs2rpO7OwYe67nACT2OwpbXjEQV96LYewDxJbpShDo4/g5QoZKVLzntGB8l7LESa488M p108QmWEkC78bwLP+bpyfd/SI2gzhTIO6Awfk0b49Xhn8lQxPuuF8pNPV9SHuENOYDj7 ig551/XA3aIUjZiiJ7ynSZEHAQloG0Kd3p7fO3VEBzIGpyuLjGfoXIITGy6ebJYfpK1L lgrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768936543; x=1769541343; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=C0qoWHj+Pupz+7dBvH/HjJvQAh+/X6Q7iQzogpkXbi8=; b=vYnJRXj3Tdr9IrLxRj7N+gRRiSKfBGgDWzpZTY11Lp+GHsuBteLIWvKhLl37XwvOHs 99nJ1Kp0+P3cx4/8VcGvKb0Ne7byusqwP9vAEn5XdOfLQC/fsOSc18GmzDNdmhFFRr9J OyzBVZY21L2QDGjynmNtd1hSpQD+S4nGGG+sdXT7+wtuS5GuBfk+xsCedmkzhiW3tQdm Whp4I0quUAchrztbI2vJj4zH94CdWFpIvXIGCC9c6g5iNEloCquzZxx2m+pU7fFKbBak kZEVo/FPM+tN7zt0zHvWeJ76W9P+cvEBdESu0uc4x8gELFo6ZWQy0RBZG2vGZseJx03X kR3A== X-Forwarded-Encrypted: i=1; AJvYcCVL6ZctZ8noiOpSws9+Mj6KbfSPZ86UYqPyuPBFn8hh6BVi2+PXHlNL2eA4P6irjHQwFBa3tNawR4tmyQk=@vger.kernel.org X-Gm-Message-State: AOJu0YxT3zD6ZWHX1PkS8yuYxThWygcyAEAgIlUF1J70EqO55MEE4hOm FRbhJLvDqbF26MqZlr+iahf1YdrfBowLv8RsBsECGuUcTNhQC6voQb/3 X-Gm-Gg: AY/fxX59JHisPJ+XwOuXHJSR98GMJdu6EEnscfPgiPG8AL335nGD4lycNtF2Gcy6+tw 5Zd9MYKsTT+z0rxfgvJqu1E7RWjtmKCwiaItEX4cjyp7z0iu77FMA9vC6j19mD1Xdid+Ey2fPmm ht2LbLW/rdBEZ09FIMSNmniGi6wU5bJhMdnlLH/PXRWbGsZPED+UPpOAlMk23wJ/LNN8ZUKpcrp lFXPKzpJm59uOoIW5ww6hMENmWkuzyHROeMzJ9iuQHwSOqgQDNAye3sHuYiO+BsRjSFIr0LXR02 gN/mtn3POHm0R1onPtMYBuzGUnQFJp/mfGgKQr/dDi+ygHLyRT8vvb/TNpg45dNAYcEvtPF2K0r PuXowkhEcz09a8bcJL+RGgS8DlwenMliSxUi3LxRZycPWQhjG7FVGEoq7pivuIOhSuLR8Kxr3kj VWCOS65U+m4j448plWCqEvDu7l2i/ahhsyUfmxholDpyGemyAR7eXD X-Received: by 2002:a05:600c:8816:b0:479:1ac2:f9b8 with SMTP id 5b1f17b1804b1-4801e334379mr176102295e9.21.1768936543196; Tue, 20 Jan 2026 11:15:43 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48042694e77sm1172165e9.12.2026.01.20.11.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 11:15:42 -0800 (PST) Date: Tue, 20 Jan 2026 19:15:40 +0000 From: David Laight To: Bill Wendling Cc: Kees Cook , "Gustavo A. R. Silva" , Nathan Chancellor , Nick Desaulniers , Justin Stitt , Miguel Ojeda , Peter Zijlstra , Andrew Morton , Heiko Carstens , Marc Herbert , Uros Bizjak , Tejun Heo , Jeff Xu , Michal =?UTF-8?B?S291dG7DvQ==?= , Shakeel Butt , Thomas =?UTF-8?B?V2Vpw59zY2h1aA==?= , John Stultz , Christian Brauner , Randy Dunlap , Brian Gerst , Masahiro Yamada , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev, Nicolas Schier , Tamir Duberstein , Steven Rostedt , "Jason A. Donenfeld" , "H. Peter Anvin" , Naman Jain , Simon Horman , Jakub Kicinski , Paolo Abeni , Ingo Molnar , Thomas Gleixner , Douglas Anderson , linux-kbuild@vger.kernel.org Subject: Re: [PATCH v4 1/2] Compiler Attributes: Add __counted_by_ptr macro Message-ID: <20260120191540.50a22ba8@pumpkin> In-Reply-To: References: <20260114193716.1740684-1-morbo@google.com> <20260116005838.2419118-1-morbo@google.com> <20260116095318.46a149fb@pumpkin> <202601171106.90E508A9D4@keescook> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, 20 Jan 2026 10:12:34 -0800 Bill Wendling wrote: > On Sat, Jan 17, 2026 at 11:07=E2=80=AFAM Kees Cook wrot= e: > > > > On Fri, Jan 16, 2026 at 09:53:18AM +0000, David Laight wrote: =20 > > > On Fri, 16 Jan 2026 00:57:57 +0000 > > > Bill Wendling wrote: > > > =20 > > > > Introduce __counted_by_ptr(), which works like __counted_by(), but = for > > > > pointer struct members. > > > > > > > > struct foo { > > > > int a, b, c; > > > > char *buffer __counted_by_ptr(bytes); > > > > short nr_bars; > > > > struct bar *bars __counted_by_ptr(nr_bars); > > > > size_t bytes; > > > > }; > > > > > > > > Because "counted_by" can only be applied to pointer members in very > > > > recent compiler versions, its application ends up needing to be dis= tinct > > > > from flexibe array "counted_by" annotations, hence a separate macro= . =20 > > > ... =20 > > > > diff --git a/Makefile b/Makefile > > > > index 9d38125263fb..6b029f694bc2 100644 > > > > --- a/Makefile > > > > +++ b/Makefile > > > > @@ -952,6 +952,12 @@ KBUILD_CFLAGS +=3D $(CC_AUTO_VAR_INIT_ZERO_EN= ABLER) > > > > endif > > > > endif > > > > > > > > +ifdef CONFIG_CC_IS_CLANG > > > > +ifdef CONFIG_CC_HAS_COUNTED_BY_PTR > > > > +KBUILD_CFLAGS +=3D -fexperimental-late-parse-attributes > > > > +endif > > > > +endif =20 > > > > > > Will that still be needed for clang 22? =20 > > > > AFAIK, yes. AIUI, this flag will remain while -fbounds-safety continues > > to be upstreamed into LLVM. > > =20 > > > Looks a bit like a temporary flag to avoid regressions. > > > Probably ought to at least have a comment that it won't be needed > > > by some future clang version so that it gets tidied up. =20 > > > > Once it's no longer needed, yes, I will want it removed from the > > Makefile. > > =20 > Would it be good to 'fixup' a comment in the Makefile for that? Wrap with: # Update version when no longer required ifneq ($(call clang-min-version, 999999),y) Although you might one day need the -f option for something entirely differ= ent. So perhaps the logic that enables CC_HAS_COUNTER_BY_PTR need to do the extra version check and set something so that -fexperimental-late-parse-att= ributes is added here (so it only added once if needed by multiple things). David