From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Jan Hendrik Farr <kernel@jfarr.cc>, Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH 6.6.y] Compiler Attributes: disable __counted_by for clang < 19.1.3
Date: Mon, 2 Dec 2024 14:15:56 -0500 [thread overview]
Message-ID: <20241202122847-9d04cc548d1b3f9d@stable.kernel.org> (raw)
In-Reply-To: <20241202162307.325302-1-kernel@jfarr.cc>
[ 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@linux.dev>
Link: https://lore.kernel.org/r/20241029140036.577804-2-kernel@jfarr.cc
Signed-off-by: Kees Cook <kees@kernel.org>
+ (cherry picked from commit f06e108a3dc53c0f5234d18de0bd224753db5019)
+ Signed-off-by: Jan Hendrik Farr <kernel@jfarr.cc>
## 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 |
WARNING: multiple messages have this Message-ID (diff)
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Jan Hendrik Farr <kernel@jfarr.cc>, Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH 6.6.y] Compiler Attributes: disable __counted_by for clang < 19.1.3
Date: Tue, 3 Dec 2024 13:13:04 -0500 [thread overview]
Message-ID: <20241202122847-9d04cc548d1b3f9d@stable.kernel.org> (raw)
Message-ID: <20241203181304.O4hsc0mO3DNhOkbAMNlOkDccnk0rO8T1JDpv_SH5KCQ@z> (raw)
In-Reply-To: <20241202162307.325302-1-kernel@jfarr.cc>
[ 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@linux.dev>
Link: https://lore.kernel.org/r/20241029140036.577804-2-kernel@jfarr.cc
Signed-off-by: Kees Cook <kees@kernel.org>
+ (cherry picked from commit f06e108a3dc53c0f5234d18de0bd224753db5019)
+ Signed-off-by: Jan Hendrik Farr <kernel@jfarr.cc>
## 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 |
next prev parent reply other threads:[~2024-12-02 19:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 15:09 FAILED: patch "[PATCH] Compiler Attributes: disable __counted_by for clang < 19.1.3" failed to apply to 6.6-stable tree gregkh
2024-12-02 16:23 ` [PATCH 6.6.y] Compiler Attributes: disable __counted_by for clang < 19.1.3 Jan Hendrik Farr
2024-12-02 19:15 ` Sasha Levin [this message]
2024-12-03 18:13 ` Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241202122847-9d04cc548d1b3f9d@stable.kernel.org \
--to=sashal@kernel.org \
--cc=kernel@jfarr.cc \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.