Skip to content

Selftests for kernel symbol name length limitation #504

@fbq

Description

@fbq

Rust support enlarged the length limitation of kernel symbols. We should provide selftests showing the longest name is supported, a simple one would be like:

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 4067564ec59f..e356a10bcb51 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -865,8 +865,22 @@ static const struct proc_ops kallsyms_proc_ops = {
        .proc_release   = seq_release_private,
 };

+#define DI(name) n##name##name
+#define DDI(name) DI(n##name##name)
+#define DDDI(name) DDI(n##name##name)
+#define DDDDI(name) DDDI(n##name##name)
+#define DDDDDI(name) DDDDI(n##name##name)
+
+/* Generate a symbol whose name length is 511 */
+#define LONGEST_NAME DDDDDI(g1h2i3j4k5l6m7n)
+
+extern int LONGEST_NAME(void) { return 0; }
+
 static int __init kallsyms_init(void)
 {
+       /* Showing that the longest name is supported */
+       BUG_ON(!kallsyms_lookup_name(__stringify(LONGEST_NAME)));
+
        proc_create("kallsyms", 0444, NULL, &kallsyms_proc_ops);
        return 0;
 }

However, we may want something better as suggested by @ojeda . Therefore create this issue to track work on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    • kbuildRelated to building the kernel, `make`, `Kbuild`, `Kconfig` options...

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions