Re: [PATCH 6.6.y] Compiler Attributes: disable __counted_by for clang < 19.1.3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[ Sasha's backport helper bot ]

Hi,

The upstream commit SHA1 provided is correct: f06e108a3dc53c0f5234d18de0bd224753db5019


Status in newer kernel trees:
6.12.y | Not found
6.11.y | Not found
6.6.y | Not found

Note: The patch differs from the upstream commit:
---
1:  f06e108a3dc53 ! 1:  22bf799c95105 Compiler Attributes: disable __counted_by for clang < 19.1.3
    @@ Metadata
      ## Commit message ##
         Compiler Attributes: disable __counted_by for clang < 19.1.3
     
    +    commit f06e108a3dc53c0f5234d18de0bd224753db5019 upstream.
    +
         This patch disables __counted_by for clang versions < 19.1.3 because
         of the two issues listed below. It does this by introducing
         CONFIG_CC_HAS_COUNTED_BY.
    @@ Commit message
         Reviewed-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
         Link: https://lore.kernel.org/r/20241029140036.577804-2-kernel@xxxxxxxx
         Signed-off-by: Kees Cook <kees@xxxxxxxxxx>
    +    (cherry picked from commit f06e108a3dc53c0f5234d18de0bd224753db5019)
    +    Signed-off-by: Jan Hendrik Farr <kernel@xxxxxxxx>
     
      ## drivers/misc/lkdtm/bugs.c ##
     @@ drivers/misc/lkdtm/bugs.c: static void lkdtm_FAM_BOUNDS(void)
    @@ drivers/misc/lkdtm/bugs.c: static void lkdtm_FAM_BOUNDS(void)
      	pr_err("FAIL: survived access of invalid flexible array member index!\n");
      
     -	if (!__has_attribute(__counted_by__))
    +-		pr_warn("This is expected since this %s was built a compiler supporting __counted_by\n",
     +	if (!IS_ENABLED(CONFIG_CC_HAS_COUNTED_BY))
    - 		pr_warn("This is expected since this %s was built with a compiler that does not support __counted_by\n",
    ++		pr_warn("This is expected since this %s was built with a compiler that does not support __counted_by\n",
      			lkdtm_kernel_info);
      	else if (IS_ENABLED(CONFIG_UBSAN_BOUNDS))
    + 		pr_expected_config(CONFIG_UBSAN_TRAP);
     
      ## include/linux/compiler_attributes.h ##
     @@
    @@ include/linux/compiler_attributes.h
      #endif
      
     -/*
    -- * Optional: only supported since gcc >= 15
    +- * Optional: only supported since gcc >= 14
     - * Optional: only supported since clang >= 18
     - *
     - *   gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
    -- * clang: https://github.com/llvm/llvm-project/pull/76348
    +- * clang: https://reviews.llvm.org/D148381
     - */
     -#if __has_attribute(__counted_by__)
     -# define __counted_by(member)		__attribute__((__counted_by__(member)))
    @@ include/linux/compiler_types.h: struct ftrace_likely_data {
     +# define __counted_by(member)
     +#endif
     +
    - /*
    -  * Apply __counted_by() when the Endianness matches to increase test coverage.
    -  */
    + /* Section for code which can't be instrumented at all */
    + #define __noinstr_section(section)					\
    + 	noinline notrace __attribute((__section__(section)))		\
     
      ## init/Kconfig ##
     @@ init/Kconfig: config CC_HAS_ASM_INLINE
    @@ init/Kconfig: config CC_HAS_ASM_INLINE
      config PAHOLE_VERSION
      	int
      	default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
    -
    - ## lib/overflow_kunit.c ##
    -@@ lib/overflow_kunit.c: static void DEFINE_FLEX_test(struct kunit *test)
    - {
    - 	/* Using _RAW_ on a __counted_by struct will initialize "counter" to zero */
    - 	DEFINE_RAW_FLEX(struct foo, two_but_zero, array, 2);
    --#if __has_attribute(__counted_by__)
    -+#ifdef CONFIG_CC_HAS_COUNTED_BY
    - 	int expected_raw_size = sizeof(struct foo);
    - #else
    - 	int expected_raw_size = sizeof(struct foo) + 2 * sizeof(s16);
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.6.y        |  Success    |  Success   |




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux