Skip to content

disable __counted_by for clang < 19.1.3

Jan Hendrik Farr linux-hardening lkml llvm stable 1 version Applied

Status from this message: Applied to for-next/hardening, thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest1 patch 6 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/1Compiler Attributes: disable __counted_by for clang < 19.1.3drivers/misc/lkdtm/bugs.c include/linux/compiler_attributes.h include/linux/compiler_types.h +2 more+30 -156 replies

Reviews trailers per patch

The patch has a Reviewed-by or Acked-by.

PatchNathan ChancellorMiguel OjedaThorsten Blum
1/1R-b T-b R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 0/1] disable __counted_by for clang < 19.1.3

Hi Kees,

Bill's PR to disable __counted_by for "whole struct" __bdos cases has now been merged into 19.1.3 [1], so here's the patch to disable __counted_by for clang versions < 19.1.3 in the kernel.

Hopefully in the near future __counted_by for whole struct __bdos can be enabled once again in coordination between the kernel, gcc, and clang. There has been recent progress on this in [2] thanks to Tavian.

Also see previous discussion on the mailing list [3]

Thanks to everyone for moving this issue along. In particular, Bill for his PR to clang/llvm, Kees and Thorsten for reproducers of the two issues, Nathan for Kconfig-ifying this patch, and Miguel for reviewing.

Info for the stable team:

This patch should be backported to kernels >= 6.6 to make sure that those build correctly with the effected clang versions. This patch cherry-picks cleanly onto linux-6.11.y. For linux-6.6.y three prerequiste commits are neded:

16c31dd7fdf6: Compiler Attributes: counted_by: bump min gcc version 2993eb7a8d34: Compiler Attributes: counted_by: fixup clang URL 231dc3f0c936: lkdtm/bugs: Improve warning message for compilers without counted_by support

There are still two merge conflicts even with those prerequistes. Here's the correct resolution:

1. include/linux/compiler_types.h:
use the incoming change until before (but not including) the "Apply __counted_by() when the Endianness matches to increase test coverage." comment

2. lib/overflow_kunit.c:
HEAD is correct

[1] https://github.com/llvm/llvm-project/pull/112786
[2] https://github.com/llvm/llvm-project/pull/112636
[3] https://lore.kernel.org/lkml/[email protected]/T/#m204c09f63c076586a02d194b87dffc7e81b8de7b

Best Regards
Jan

Jan Hendrik Farr (1):
Compiler Attributes: disable __counted_by for clang < 19.1.3

 drivers/misc/lkdtm/bugs.c           |  2 +-
 include/linux/compiler_attributes.h | 13 -------------
 include/linux/compiler_types.h      | 19 +++++++++++++++++++
 init/Kconfig                        |  9 +++++++++
 lib/overflow_kunit.c                |  2 +-
 5 files changed, 30 insertions(+), 15 deletions(-)
Signature · 1 line
2.47.0