* Re: [PATCH v1 3/3] kallsyms: increase maximum kernel symbol length to 512
2022-05-05 19:16 ` [PATCH v1 3/3] kallsyms: increase maximum kernel symbol length to 512 Miguel Ojeda
@ 2022-05-05 23:48 ` Kees Cook
2022-05-06 8:34 ` Petr Mladek
2022-05-06 9:45 ` Geert Stappers
2 siblings, 0 replies; 5+ messages in thread
From: Kees Cook @ 2022-05-05 23:48 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim, Andrew Morton, Sergey Senozhatsky,
Kefeng Wang, Helge Deller, Stephen Boyd, Christophe Leroy,
Masahiro Yamada, Nick Desaulniers, Changbin Du, Nathan Chancellor,
Gustavo A. R. Silva, Andi Kleen, Adrian Hunter, linux-kernel,
live-patching, linux-perf-users, rust-for-linux, Alex Gaynor,
Wedson Almeida Filho, Gary Guo, Boqun Feng
On Thu, May 05, 2022 at 09:16:45PM +0200, Miguel Ojeda wrote:
> 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.
>
> Co-developed-by: Alex Gaynor <alex.gaynor@gmail.com>
> Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
> Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com>
> Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
> Co-developed-by: Gary Guo <gary@garyguo.net>
> Signed-off-by: Gary Guo <gary@garyguo.net>
> Co-developed-by: Boqun Feng <boqun.feng@gmail.com>
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
I look forward to aiming my demangler at /proc/kallsyms. ;)
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v1 3/3] kallsyms: increase maximum kernel symbol length to 512
2022-05-05 19:16 ` [PATCH v1 3/3] kallsyms: increase maximum kernel symbol length to 512 Miguel Ojeda
2022-05-05 23:48 ` Kees Cook
@ 2022-05-06 8:34 ` Petr Mladek
2022-05-06 9:45 ` Geert Stappers
2 siblings, 0 replies; 5+ messages in thread
From: Petr Mladek @ 2022-05-06 8:34 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Joe Lawrence,
Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Andrew Morton, Sergey Senozhatsky, Kefeng Wang, Helge Deller,
Stephen Boyd, Christophe Leroy, Masahiro Yamada, Nick Desaulniers,
Changbin Du, Nathan Chancellor, Gustavo A. R. Silva, Andi Kleen,
Kees Cook, Adrian Hunter, linux-kernel, live-patching,
linux-perf-users, rust-for-linux, Alex Gaynor,
Wedson Almeida Filho, Gary Guo, Boqun Feng
On Thu 2022-05-05 21:16:45, Miguel Ojeda wrote:
> 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.
>
> Co-developed-by: Alex Gaynor <alex.gaynor@gmail.com>
> Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
> Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com>
> Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
> Co-developed-by: Gary Guo <gary@garyguo.net>
> Signed-off-by: Gary Guo <gary@garyguo.net>
> Co-developed-by: Boqun Feng <boqun.feng@gmail.com>
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
I was primary interested into the livepatching code.
But the entire patch looks good:
Reviewed-by: Petr Mladek <pmladek@suse.com>
I just hope that it will not cause stack overflows
somewhere.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v1 3/3] kallsyms: increase maximum kernel symbol length to 512
2022-05-05 19:16 ` [PATCH v1 3/3] kallsyms: increase maximum kernel symbol length to 512 Miguel Ojeda
2022-05-05 23:48 ` Kees Cook
2022-05-06 8:34 ` Petr Mladek
@ 2022-05-06 9:45 ` Geert Stappers
2 siblings, 0 replies; 5+ messages in thread
From: Geert Stappers @ 2022-05-06 9:45 UTC (permalink / raw)
To: Miguel Ojeda, Josh Poimboeuf, Jiri Kosina, Miroslav Benes,
Petr Mladek, Joe Lawrence, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim, Andrew Morton, Sergey Senozhatsky,
Kefeng Wang, Helge Deller, Stephen Boyd, Christophe Leroy,
Masahiro Yamada, Nick Desaulniers, Changbin Du, Nathan Chancellor,
Gustavo A. R. Silva, Andi Kleen, Kees Cook, Adrian Hunter,
linux-kernel, live-patching, linux-perf-users, rust-for-linux,
Alex Gaynor, Wedson Almeida Filho, Gary Guo, Boqun Feng
On Thu, May 05, 2022 at 09:16:45PM +0200, Miguel Ojeda wrote:
>
> 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.
>
> diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
> index ce1bd2fbf23e..e5ad6e31697d 100644
> --- a/include/linux/kallsyms.h
> +++ b/include/linux/kallsyms.h
> @@ -15,7 +15,7 @@
>
> #include <asm/sections.h>
>
> -#define KSYM_NAME_LEN 128
> +#define KSYM_NAME_LEN 512
multiplication factor is four
> --- a/kernel/livepatch/core.c
> +++ b/kernel/livepatch/core.c
> @@ -213,7 +213,7 @@ static int klp_resolve_symbols(Elf_Shdr *sechdrs, const char *strtab,
> * we use the smallest/strictest upper bound possible (56, based on
> * the current definition of MODULE_NAME_LEN) to prevent overflows.
> */
> - BUILD_BUG_ON(MODULE_NAME_LEN < 56 || KSYM_NAME_LEN != 128);
> + BUILD_BUG_ON(MODULE_NAME_LEN < 56 || KSYM_NAME_LEN != 512);
factor four
> @@ -227,7 +227,7 @@ static int klp_resolve_symbols(Elf_Shdr *sechdrs, const char *strtab,
>
> /* Format: .klp.sym.sym_objname.sym_name,sympos */
> cnt = sscanf(strtab + sym->st_name,
> - ".klp.sym.%55[^.].%127[^,],%lu",
> + ".klp.sym.%55[^.].%511[^,],%lu",
4 * ( 127 + 1 ) = 511 + 1
> --- a/scripts/kallsyms.c
> +++ b/scripts/kallsyms.c
> @@ -30,10 +30,10 @@
> #define _stringify_1(x) #x
> #define _stringify(x) _stringify_1(x)
>
> -#define KSYM_NAME_LEN 128
> +#define KSYM_NAME_LEN 512
factor four
> --- a/tools/include/linux/kallsyms.h
> +++ b/tools/include/linux/kallsyms.h
> @@ -6,7 +6,7 @@
> #include <stdio.h>
> #include <unistd.h>
>
> -#define KSYM_NAME_LEN 128
> +#define KSYM_NAME_LEN 512
factor four
> --- a/tools/lib/perf/include/perf/event.h
> +++ b/tools/lib/perf/include/perf/event.h
> @@ -95,7 +95,7 @@ struct perf_record_throttle {
> };
>
> #ifndef KSYM_NAME_LEN
> -#define KSYM_NAME_LEN 256
> +#define KSYM_NAME_LEN 512
Here is the multiplication factor two.
> --- a/tools/lib/symbol/kallsyms.h
> +++ b/tools/lib/symbol/kallsyms.h
> @@ -7,7 +7,7 @@
> #include <linux/types.h>
>
> #ifndef KSYM_NAME_LEN
> -#define KSYM_NAME_LEN 256
> +#define KSYM_NAME_LEN 512
Another "factor two"
It feels good to unify all the KSYM_NAME_LEN to 512.
Thing that feels less good is doubling 256 versus quadrupling 128.
I felt the need to report that.
Feel free to ignore this remark.
Groeten
Geert Stappers
--
Silence is hard to parse
^ permalink raw reply [flat|nested] 5+ messages in thread