History

kallsyms: increase maximum kernel symbol length to 512

Rust symbols can become quite long due to namespacing introduced by modules, types, traits, generics, etc. For instance, the following code: pub mod my_module { pub struct MyType; pub struct MyGenericType<T>(T); pub trait MyTrait { fn my_method() -> u32; } impl MyTrait for MyGenericType<MyType> { fn my_method() -> u32 { 42 } } } generates a symbol of length 96 when using the upcoming v0 mangling scheme: _RNvXNtCshGpAVYOtgW1_7example9my_moduleINtB2_13MyGenericTypeNtB2_6MyTypeENtB2_7MyTrait9my_method At the moment, Rust symbols may reach up to 300 in length. Setting 512 as the maximum seems like a reasonable choice to keep some headroom.

Miguel Ojeda committed 5 years ago

Commit b8a94bf1 parent 73bbb946 files · +8 −8Browse files

Showing the changes to kernel/livepatch (1 of 6 files). Show all

Unified · Split

kernel/livepatch/core.c+2−2
@@ -213,7 +213,7 @@ static int klp_resolve_symbols(Elf_Shdr *sechdrs, const char *strtab, · 212 unmodified lines
213213 * we use the smallest/strictest upper bound possible (56, based on
214214 * the current definition of MODULE_NAME_LEN) to prevent overflows.
215215 */
216− BUILD_BUG_ON(MODULE_NAME_LEN < 56 || KSYM_NAME_LEN != 128);
216+ BUILD_BUG_ON(MODULE_NAME_LEN < 56 || KSYM_NAME_LEN != 512);
217217
218218 relas = (Elf_Rela *) relasec->sh_addr;
219219 /* For each rela in this klp relocation section */
@@ -227,7 +227,7 @@ static int klp_resolve_symbols(Elf_Shdr *sechdrs, const char *strtab, · 7 unmodified lines
227227
228228 /* Format: .klp.sym.sym_objname.sym_name,sympos */
229229 cnt = sscanf(strtab + sym->st_name,
230− ".klp.sym.%55[^.].%127[^,],%lu",
230+ ".klp.sym.%55[^.].%511[^,],%lu",
231231 sym_objname, sym_name, &sympos);
232232 if (cnt != 3) {
233233 pr_err("symbol %s has an incorrectly formatted name\n",

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t