mbox series

[0/1] disable __counted_by for clang < 19.1.3

Message ID 20241029140036.577804-1-kernel@jfarr.cc (mailing list archive)
Headers show
Series disable __counted_by for clang < 19.1.3 | expand

Message

Jan Hendrik Farr Oct. 29, 2024, 2 p.m. UTC
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/3E304FB2-799D-478F-889A-CDFC1A52DCD8@toblux.com/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(-)