From: Jarkko Sakkinen <jarkko@kernel.org>
To: Miguel Ojeda <ojeda@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
Kees Cook <keescook@chromium.org>, Petr Mladek <pmladek@suse.com>,
Alex Gaynor <alex.gaynor@gmail.com>,
Wedson Almeida Filho <wedsonaf@google.com>,
Gary Guo <gary@garyguo.net>, Boqun Feng <boqun.feng@gmail.com>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Jiri Kosina <jikos@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
Joe Lawrence <joe.lawrence@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
live-patching@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v7 03/25] kallsyms: increase maximum kernel symbol length to 512
Date: Mon, 23 May 2022 23:31:29 +0300 [thread overview]
Message-ID: <YovvIQeN3lmOYzJO@kernel.org> (raw)
In-Reply-To: <20220523020209.11810-4-ojeda@kernel.org>
On Mon, May 23, 2022 at 04:01:16AM +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.
There's no description what the patch does.
>
> Reviewed-by: Kees Cook <keescook@chromium.org>
> Reviewed-by: Petr Mladek <pmladek@suse.com>
> 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>
> ---
> This is a prerequisite patch, independently submitted at:
>
> https://lore.kernel.org/lkml/20220506203443.24721-4-ojeda@kernel.org/
>
> include/linux/kallsyms.h | 2 +-
> kernel/livepatch/core.c | 4 ++--
> scripts/kallsyms.c | 4 ++--
> tools/include/linux/kallsyms.h | 2 +-
> tools/lib/perf/include/perf/event.h | 2 +-
> tools/lib/symbol/kallsyms.h | 2 +-
> 6 files changed, 8 insertions(+), 8 deletions(-)
>
> 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
> #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s %s]") + \
> (KSYM_NAME_LEN - 1) + \
> 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + \
> diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> index bc475e62279d..ec06ce59d728 100644
> --- 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);
>
> relas = (Elf_Rela *) relasec->sh_addr;
> /* For each rela in this klp relocation section */
> @@ -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",
> sym_objname, sym_name, &sympos);
> if (cnt != 3) {
> pr_err("symbol %s has an incorrectly formatted name\n",
> diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
> index 7e99799aa7b9..275044b840dc 100644
> --- 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
>
> /* A substantially bigger size than the current maximum. */
> -#define KSYM_NAME_LEN_BUFFER 512
> +#define KSYM_NAME_LEN_BUFFER 2048
> _Static_assert(
> KSYM_NAME_LEN_BUFFER == KSYM_NAME_LEN * 4,
> "Please keep KSYM_NAME_LEN_BUFFER in sync with KSYM_NAME_LEN"
> diff --git a/tools/include/linux/kallsyms.h b/tools/include/linux/kallsyms.h
> index efb6c3f5f2a9..5a37ccbec54f 100644
> --- 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
>
> struct module;
>
> diff --git a/tools/lib/perf/include/perf/event.h b/tools/lib/perf/include/perf/event.h
> index e7758707cadd..116a80c31675 100644
> --- 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
> #endif
>
> struct perf_record_ksymbol {
> diff --git a/tools/lib/symbol/kallsyms.h b/tools/lib/symbol/kallsyms.h
> index 72ab9870454b..542f9b059c3b 100644
> --- 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
> #endif
>
> static inline u8 kallsyms2elf_binding(char type)
> --
> 2.36.1
>
BR, Jarkko
next prev parent reply other threads:[~2022-05-23 20:33 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-23 2:01 [PATCH v7 00/25] Rust support Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 01/25] kallsyms: avoid hardcoding the buffer size Miguel Ojeda
2022-05-23 19:45 ` Jarkko Sakkinen
2022-05-23 19:55 ` Jarkko Sakkinen
2022-05-24 16:21 ` Miguel Ojeda
2022-05-26 4:54 ` Jarkko Sakkinen
2022-05-23 2:01 ` [PATCH v7 02/25] kallsyms: support "big" kernel symbols Miguel Ojeda
2022-05-23 20:30 ` Jarkko Sakkinen
2022-05-23 2:01 ` [PATCH v7 03/25] kallsyms: increase maximum kernel symbol length to 512 Miguel Ojeda
2022-05-23 20:31 ` Jarkko Sakkinen [this message]
2022-05-24 18:07 ` Miguel Ojeda
2022-05-27 16:25 ` Jarkko Sakkinen
2022-05-30 13:01 ` Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 04/25] kunit: take `kunit_assert` as `const` Miguel Ojeda
2022-05-23 17:15 ` Daniel Latypov
2022-05-23 18:14 ` Shuah Khan
2022-05-24 12:37 ` Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 05/25] rust: add C helpers Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 06/25] rust: add `compiler_builtins` crate Miguel Ojeda
2022-05-23 18:37 ` Nick Desaulniers
2022-05-23 23:41 ` Gary Guo
2022-05-25 21:29 ` Nick Desaulniers
2022-05-24 12:29 ` Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 07/25] rust: import upstream `alloc` crate Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 08/25] rust: adapt `alloc` crate to the kernel Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 09/25] rust: add `build_error` crate Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 10/25] rust: add `macros` crate Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 11/25] rust: add `kernel` crate's `sync` module Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 12/25] rust: add `kernel` crate Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 13/25] rust: export generated symbols Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 14/25] vsprintf: add new `%pA` format specifier Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 15/25] scripts: checkpatch: diagnose uses of `%pA` in the C side Miguel Ojeda
2022-05-23 2:17 ` Joe Perches
2022-05-24 16:35 ` Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 16/25] scripts: checkpatch: enable language-independent checks for Rust Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 17/25] scripts: add `rustdoc_test_{builder,gen}.py` scripts Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 18/25] scripts: add `generate_rust_analyzer.py` scripts Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 19/25] scripts: decode_stacktrace: demangle Rust symbols Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 20/25] docs: add Rust documentation Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 21/25] Kbuild: add Rust support Miguel Ojeda
2022-05-23 18:44 ` Nick Desaulniers
2022-05-24 15:12 ` Miguel Ojeda
2022-05-25 22:25 ` Nick Desaulniers
2022-05-30 13:39 ` Miguel Ojeda
2022-07-16 8:21 ` Masahiro Yamada
2022-07-16 8:57 ` Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 22/25] samples: add Rust examples Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 23/25] MAINTAINERS: Rust Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 24/25] [RFC] drivers: gpio: PrimeCell PL061 in Rust Miguel Ojeda
2022-05-23 2:01 ` [PATCH v7 25/25] [RFC] drivers: android: Binder IPC " Miguel Ojeda
2022-07-16 12:42 ` [PATCH v7 00/25] Rust support Conor Dooley
2022-07-16 13:36 ` Miguel Ojeda
2022-07-16 13:51 ` Conor.Dooley
2022-07-16 13:56 ` Miguel Ojeda
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=YovvIQeN3lmOYzJO@kernel.org \
--to=jarkko@kernel.org \
--cc=acme@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jolsa@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mbenes@suse.cz \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=wedsonaf@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).