Kunit to check the longest symbol length
v2 cover Kunit to check the longest symbol length
Hello,
Please consider this series for 6.6.y
This patch series backports two patches that implement a test to verify that a symbol with KSYM_NAME_LEN of 512 can be read.
The first patch implements the test. This commit also includes a fix for the test x86/insn_decoder_test. In the case a symbol exceeds the symbol length limit, an error will happen:
arch/x86/tools/insn_decoder_test: error: malformed line 1152000:
tBb_+0xf2>..which overflowed by 10 characters reading this line:
ffffffff81458193: 74 3d je
ffffffff814581d2 <_RNvXse_NtNtNtCshGpAVYOtgW1_4core4iter8adapters7flattenINtB5_13FlattenCompatINtNtB7_3map3MapNtNtNtBb_3str4iter5CharsNtB1v_17CharEscapeDefaultENtNtBb_4char13EscapeDefaultENtNtBb_3fmt5Debug3fmtBb_+0xf2>
The fix was proposed in [1] and initially mentioned at [2].
The second patch fixes a warning when building with clang because there was a definition of unlikely from compiler.h in tools/include/linux, which conflicted with the one in the instruction decoder selftest.
[1] https://lore.kernel.org/lkml/Y9ES4UKl%[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
---
Changes in v2: sign-off patch 2/2
---
Nathan Chancellor (1):
x86/tools: Drop duplicate unlikely() definition in insn_decoder_test.c
Sergio González Collado (1):
Kunit to check the longest symbol length
arch/x86/tools/insn_decoder_test.c | 5 +- lib/Kconfig.debug | 9 ++++ lib/Makefile | 2 + lib/longest_symbol_kunit.c | 82 ++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 lib/longest_symbol_kunit.c
base-commit: 6282921b6825fef6a1243e1c80063421d41e2576
Signature · 1 line
2.39.2
PATCH v2 1/2 Kunit to check the longest symbol length
commit c104c16073b7fdb3e4eae18f66f4009f6b073d6f upstream.
The longest length of a symbol (KSYM_NAME_LEN) was increased to 512 in the reference [1]. This patch adds kunit test suite to check the longest symbol length. These tests verify that the longest symbol length defined is supported.
This test can also help other efforts for longer symbol length, like [2].
The test suite defines one symbol with the longest possible length.
The first test verify that functions with names of the created symbol, can be called or not.
The second test, verify that the symbols are created (or not) in the kernel symbol table.
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
--- arch/x86/tools/insn_decoder_test.c | 3 +- lib/Kconfig.debug | 9 ++++ lib/Makefile | 2 + lib/longest_symbol_kunit.c | 82 ++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 lib/longest_symbol_kunit.c
arch/x86/tools/insn_decoder_test.c +2 -1
@@ -10,6 +10,7 @@#include <assert.h> #include <unistd.h> #include <stdarg.h> +#include <linux/kallsyms.h> #define unlikely (cond) (cond)
@@ -106,7 +107,7 @@ static void parse_args(int argc, char **argv) } } -#define BUFSIZE 256 +#define BUFSIZE (256 + KSYM_NAME_LEN)int main (int argc,char **argv) {
lib/Kconfig.debug +9 -0
@@ -2747,6 +2747,15 @@ config FORTIFY_KUNIT_TEST by the str*() and mem*() family of functions. For testing runtime traps of FORTIFY_SOURCE, see LKDTM's "FORTIFY_*" tests. +config LONGEST_SYM_KUNIT_TEST + tristate "Test the longest symbol possible" if !KUNIT_ALL_TESTS + depends on KUNIT && KPROBES + default KUNIT_ALL_TESTS + help + Tests the longest symbol possible + + If unsure, say N. + config HW_BREAKPOINT_KUNIT_TEST bool "Test hw_breakpoint constraints accounting" if !KUNIT_ALL_TESTS depends on HAVE_HW_BREAKPOINT
lib/Makefile +2 -0
@@ -402,6 +402,8 @@ obj-$(CONFIG_FORTIFY_KUNIT_TEST) += fortify_kunit.o obj-$(CONFIG_STRCAT_KUNIT_TEST) += strcat_kunit.o obj-$(CONFIG_STRSCPY_KUNIT_TEST) += strscpy_kunit.o obj-$(CONFIG_SIPHASH_KUNIT_TEST) += siphash_kunit.o +obj-$(CONFIG_LONGEST_SYM_KUNIT_TEST) += longest_symbol_kunit.o +CFLAGS_longest_symbol_kunit.o += $(call cc-disable-warning, missing-prototypes) obj-$(CONFIG_GENERIC_LIB_DEVMEM_IS_ALLOWED) += devmem_is_allowed.o
lib/longest_symbol_kunit.c new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
2.39.2
Quoted 9 lines · Sergio González Collado
Reviewed-by Shuah Khan <[email protected]>Reviewed-by Rae Moar <[email protected]>Signed-off-by Sergio González Collado <[email protected]>Reviewed-by Rae Moar <[email protected]>Acked-by David Gow <[email protected]>Signed-off-by Shuah Khan <[email protected]>
I would have also signed this one again at the bottom, even if it originally came from you. But the stable team may be fine with it.
(The SoBs are a "list", not a "set", if that makes sense, i.e. it is supposed to reflect how the patch was handled.)
Cheers,
Miguel
Sasha Levin
maintainer[ Sasha's backport helper bot ]
Hi,
Summary of potential issues:
⚠️ Found follow-up fixes in mainline
The upstream commit SHA1 provided is correct: c104c16073b7fdb3e4eae18f66f4009f6b073d6f
Status in newer kernel trees:
6.15.y | Present (exact SHA1)
6.12.y | Present (different SHA1: 27f827e7cc03)
Found fixes commits:f710202b2a45 x86/tools: Drop duplicate unlikely() definition in insn_decoder_test.c
Note: The patch differs from the upstream commit:
---
1: c104c16073b7f ! 1: 5dd11c4ab0f50 Kunit to check the longest symbol length
@@ Metadata
## Commit message ##
Kunit to check the longest symbol length
+ commit c104c16073b7fdb3e4eae18f66f4009f6b073d6f upstream.
+
The longest length of a symbol (KSYM_NAME_LEN) was increased to 512 in the reference [1]. This patch adds kunit test suite to check the longest symbol length. These tests verify that the longest symbol length defined
@@ lib/Kconfig.debug: config FORTIFY_KUNIT_TEST
## lib/Makefile ##
@@ lib/Makefile: obj-$(CONFIG_FORTIFY_KUNIT_TEST) += fortify_kunit.o
- obj-$(CONFIG_CRC_KUNIT_TEST) += crc_kunit.o
+ obj-$(CONFIG_STRCAT_KUNIT_TEST) += strcat_kunit.o
+ obj-$(CONFIG_STRSCPY_KUNIT_TEST) += strscpy_kunit.o obj-$(CONFIG_SIPHASH_KUNIT_TEST) += siphash_kunit.o
- obj-$(CONFIG_USERCOPY_KUNIT_TEST) += usercopy_kunit.o +obj-$(CONFIG_LONGEST_SYM_KUNIT_TEST) += longest_symbol_kunit.o +CFLAGS_longest_symbol_kunit.o += $(call cc-disable-warning, missing-prototypes)
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.6.y | Success | Success |
PATCH v2 2/2 x86/tools: Drop duplicate unlikely() definition in insn_decoder_test.c
In reply to Sergio González ColladoFrom: Nathan Chancellor <[email protected]>
commit f710202b2a45addea3dcdcd862770ecbaf6597ef upstream.
After commit c104c16073b7 ("Kunit to check the longest symbol length"), there is a warning when building with clang because there is now a definition of unlikely from compiler.h in tools/include/linux, which conflicts with the one in the instruction decoder selftest:
arch/x86/tools/insn_decoder_test.c:15:9: warning: 'unlikely' macro redefined [-Wmacro-redefined]
Remove the second unlikely() definition, as it is no longer necessary, clearing up the warning.
--- arch/x86/tools/insn_decoder_test.c | 2 -- 1 file changed, 2 deletions(-)
arch/x86/tools/insn_decoder_test.c +0 -2
@@ -12,8 +12,6 @@#include <stdarg.h> #include <linux/kallsyms.h> -#define unlikely (cond) (cond) -#include <asm/insn.h> #include <inat.c> #include <insn.c>
Signature · 1 line
2.39.2
Re: [PATCH v2 6.6.y 2/2] x86/tools: Drop duplicate unlikely() definition in insn_decoder_test.c
[ Sasha's backport helper bot ]
Hi,
✅ All tests passed successfully. No issues detected. No action required from the submitter.
The upstream commit SHA1 provided is correct: f710202b2a45addea3dcdcd862770ecbaf6597ef
WARNING: Author mismatch between patch and upstream commit:
Backport author: <[email protected]>
Commit author: Nathan Chancellor<[email protected]>
Status in newer kernel trees:
6.15.y | Present (exact SHA1)
6.12.y | Present (different SHA1: ebd352672790)
Note: The patch differs from the upstream commit:
---
1: f710202b2a45a ! 1: defa6b7af5a11 x86/tools: Drop duplicate unlikely() definition in insn_decoder_test.c
@@ Metadata
## Commit message ##
x86/tools: Drop duplicate unlikely() definition in insn_decoder_test.c
+ commit f710202b2a45addea3dcdcd862770ecbaf6597ef upstream.
+
After commit c104c16073b7 ("Kunit to check the longest symbol length"), there is a warning when building with clang because there is now a definition of unlikely from compiler.h in tools/include/linux, which
@@ Commit message
+ Signed-off-by: Sergio González Collado <[email protected]>
## arch/x86/tools/insn_decoder_test.c ##
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.12.y | Success | Success |