Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp361147pxb; Wed, 14 Apr 2021 17:51:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpOqM3ORerv84GFUVAUbDHqyjZJ3uuWKxInyKtTUpEPGLEGXNVY+iT3ngTI7fF1wIk3QpP X-Received: by 2002:a17:90a:eb04:: with SMTP id j4mr890363pjz.156.1618447874674; Wed, 14 Apr 2021 17:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618447874; cv=none; d=google.com; s=arc-20160816; b=Z9POES7OJA0MRGLQaemSuRmotcO1MulYM4zejwkngRqaLenFuhpa7D4wn5iht2F6Hn Eb1di8a6EBqMJTPUBU9ujmOjPhcqufFlfv0RffjoiQfXYjKGyU/5auBckiHr0VcOkV/C D18p4m4/X7FrxrPZUBla4HPEupJFgcqI3gMDI8OiLQNkwHUqmrIpQ1kHDRJosdldjxEa xfcMmxzaW8s3qOLxwGznkxDDyK7CALpCDe+E2ipqKM3YJkQOIgiYZ92KfY+h9AiqMHQD OW38COtoag2RxtSBYexAmj1453FKzL6SnXpwGhy0xVOj+ZQh3yHaaBiCWhMVL5xuYuYx Ot1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=sYrhQ+L0KHq4tveN5clEASWcQ37/wtC32tCYh0nBGLo=; b=hVvY3l1dejldyiyadxGg1gE/G6dFGlaAnkycrEyaK2cJRr5OYl1ODqP0znVOLa3Psy EXdOIS5RprjYuR/rdSg57vwxBLeRqWU19u0az9VYa0uqC0T26R5NF9+nhZW07yMmlpZF pukEqyRm/pQSUsstLHyUe0ko55pRpQRl05nW7RIN7pQWEhoHeymg7Wrq68/y1O3TxF51 YZ7dXuXyuiPtR5NKxbPjwyh2sstNflMxEsFqwcYz6QPLDX2/7fdiZXorXPwE73KG2eqz KgtC0Nte7onb027AQLrhGldHZAxM5jhdM1ADBJuYyeph0ooWnwVdapQJcnt3tXVRt8tf a3zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oVcontEv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s12si1267624pgg.7.2021.04.14.17.51.03; Wed, 14 Apr 2021 17:51:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oVcontEv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229750AbhDNXtP (ORCPT + 99 others); Wed, 14 Apr 2021 19:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229968AbhDNXtI (ORCPT ); Wed, 14 Apr 2021 19:49:08 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64E53C061756 for ; Wed, 14 Apr 2021 16:48:45 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id u20so25077070lja.13 for ; Wed, 14 Apr 2021 16:48:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sYrhQ+L0KHq4tveN5clEASWcQ37/wtC32tCYh0nBGLo=; b=oVcontEvK+/+8MA7Pe0KxzkdxdTY9uAw/triIXdClbgN0AqR9y8J3vDKWQGZQognij Dv00nHR4pwZKbHwSELVW5MrGADWTow2YAHFxLyIaZMUVnYn+HgFQ8m6I4nxQIIa6oaxR vZ1zOvsFHhQpoJofcGiYwlm0N3C7yvAyenfpmab9wAukwMa/kcYewOhykPReLODnnHdD B/UdliM0FMyAu1rYPLtGw/OMmDtd0yatWxtt6mS1EiYKE4B+p79g4b6MjsuD0Gv3Y+C0 z7Zo437En5Rw8m6Tf0iCuERtCSm0c+tBNu9xHU8I+jVxM5wFKHnusyAReqAdFalPdrTB RNWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sYrhQ+L0KHq4tveN5clEASWcQ37/wtC32tCYh0nBGLo=; b=QlMRStuueP0H/P+1REATnEcUSM7umhzwltNmgI9N3ww4hfIXZ0PqZ2ROEi32ls9cbg qPwriWH4XnpKwaN/9823fsDXoBgjaoe51kPujRr0i2XAEP7h9QkFYulp57H4RyGm4DzN ZWjVktgWT/6kcDQNN/zgB3QjpLUvjHA16z/fQf09n7NAIQ3kEqSPiVYthcm5BIoBd3cl rfuxIxKPHCJd0U24nv8f0aM64FfpAykb2hJUXXgBoK1LrErUhkqoodJpz0rUmG2LXTZ8 vsdck1TI/BL/6mo5yhfuCF7WfqTztYQt0IjVAGQfgldR02pB8QhXD/pcal2oq7iS18u/ hs8g== X-Gm-Message-State: AOAM533xxi+3KCnTMsGPDRxyv+UbpMB8JoksII+p609bh2pwZSiDW4Fg csuDqeBV24jy6aWw6o6FZI4q1ELv3IYg23vKXVQjaw== X-Received: by 2002:a2e:5716:: with SMTP id l22mr239987ljb.244.1618444123676; Wed, 14 Apr 2021 16:48:43 -0700 (PDT) MIME-Version: 1.0 References: <20210414184604.23473-1-ojeda@kernel.org> <20210414184604.23473-3-ojeda@kernel.org> In-Reply-To: <20210414184604.23473-3-ojeda@kernel.org> From: Nick Desaulniers Date: Wed, 14 Apr 2021 16:48:31 -0700 Message-ID: Subject: Re: [PATCH 02/13] kallsyms: Increase maximum kernel symbol length to 512 To: Miguel Ojeda Cc: Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, Linux Kbuild mailing list , Linux Doc Mailing List , LKML , Alex Gaynor , Geoffrey Thomas , Finn Behrens , Adam Bratschi-Kaye , Wedson Almeida Filho Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 14, 2021 at 11:48 AM wrote: > > From: Miguel Ojeda > > Rust symbols can become quite long due to namespacing introduced > by modules, types, traits, generics, etc. For instance, for: > > pub mod my_module { > pub struct MyType; > pub struct MyGenericType(T); > > pub trait MyTrait { > fn my_method() -> u32; > } > > impl MyTrait for MyGenericType { > 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. What are the implications of this change for someone not using Rust? Does it change the binary size of vmlinux for a defconfig build, for example? > > Co-developed-by: Alex Gaynor > Signed-off-by: Alex Gaynor > Co-developed-by: Geoffrey Thomas > Signed-off-by: Geoffrey Thomas > Co-developed-by: Finn Behrens > Signed-off-by: Finn Behrens > Co-developed-by: Adam Bratschi-Kaye > Signed-off-by: Adam Bratschi-Kaye > Co-developed-by: Wedson Almeida Filho > Signed-off-by: Wedson Almeida Filho > Signed-off-by: Miguel Ojeda > --- > include/linux/kallsyms.h | 2 +- > kernel/livepatch/core.c | 4 ++-- > scripts/kallsyms.c | 2 +- > tools/include/linux/kallsyms.h | 2 +- > tools/include/linux/lockdep.h | 2 +- > tools/lib/perf/include/perf/event.h | 2 +- > tools/lib/symbol/kallsyms.h | 2 +- > 7 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h > index 465060acc981..5cdc6903abca 100644 > --- a/include/linux/kallsyms.h > +++ b/include/linux/kallsyms.h > @@ -14,7 +14,7 @@ > > #include > > -#define KSYM_NAME_LEN 128 > +#define KSYM_NAME_LEN 512 > #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ > 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1) > > diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c > index 335d988bd811..73874e5edfda 100644 > --- a/kernel/livepatch/core.c > +++ b/kernel/livepatch/core.c > @@ -213,7 +213,7 @@ static int klp_resolve_symbols(Elf64_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(Elf64_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 bcdabee13aab..9bab5f55ade3 100644 > --- a/scripts/kallsyms.c > +++ b/scripts/kallsyms.c > @@ -27,7 +27,7 @@ > > #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) > > -#define KSYM_NAME_LEN 128 > +#define KSYM_NAME_LEN 512 > > struct sym_entry { > unsigned long long addr; > 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 > #include > > -#define KSYM_NAME_LEN 128 > +#define KSYM_NAME_LEN 512 > > struct module; > > diff --git a/tools/include/linux/lockdep.h b/tools/include/linux/lockdep.h > index e56997288f2b..d9c163f3ab24 100644 > --- a/tools/include/linux/lockdep.h > +++ b/tools/include/linux/lockdep.h > @@ -47,7 +47,7 @@ static inline int debug_locks_off(void) > > #define task_pid_nr(tsk) ((tsk)->pid) > > -#define KSYM_NAME_LEN 128 > +#define KSYM_NAME_LEN 512 > #define printk(...) dprintf(STDOUT_FILENO, __VA_ARGS__) > #define pr_err(format, ...) fprintf (stderr, format, ## __VA_ARGS__) > #define pr_warn pr_err > diff --git a/tools/lib/perf/include/perf/event.h b/tools/lib/perf/include/perf/event.h > index d82054225fcc..f5c40325b441 100644 > --- a/tools/lib/perf/include/perf/event.h > +++ b/tools/lib/perf/include/perf/event.h > @@ -93,7 +93,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 > > #ifndef KSYM_NAME_LEN > -#define KSYM_NAME_LEN 256 > +#define KSYM_NAME_LEN 512 > #endif > > static inline u8 kallsyms2elf_binding(char type) > -- > 2.17.1 > -- Thanks, ~Nick Desaulniers