Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp623503pxv; Wed, 14 Jul 2021 11:25:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOWhy/wC8In3UhoWZX7EkYu+vKfmIk1nbdx68ydFl72pWLmQa9Y0xXcAs3PB+cU7hug3Nv X-Received: by 2002:a17:907:11c1:: with SMTP id va1mr13709854ejb.365.1626287126070; Wed, 14 Jul 2021 11:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626287126; cv=none; d=google.com; s=arc-20160816; b=YrnPGle1Owmc/ZzKOb0B7hKHXbqNtYMSSirovln0YoSP8VtPM5IKYvMPg9J4pSvw4C 8G3UJwRLaNml4nNGpiufpbMOoWrgxAB8E/HboCNmkIyg8Q1HWY7cSfwK/gUB1a+Sh8zk uBkG7qKfWQdJMupC1c6OdasHTpdYov2cW649eLuBmzCv97YmQ/UwyiH6BkhubN2OEj46 COz4tJYZ/jo7SZw8EU6q0hs9n+Xh+TipCwxYgHKqzRfnSadmx2f+lijyo3367OZF+ror rolnh1HuQuLrasKS22b4DqVFwQYq1jHs5hdCsMNVLRrpxvdp/wWGVF/3Sm4JwuMeTuWv a4JA== 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=YIyhhFVB7lAJhhYlHC8Aypf2fwXB60EEf6/ds0a06qs=; b=BpTF71IMag/6vRp81npeMfr0Er+aeO0QaEEXu7cXxhhdDRyNZOk4Mocfk67IsTM3sM tuvQD4AjCnen2Csbtly9YMBJL737NWKu2nsTP2hqe2/Pv+k3j5h6/CcMC8ZWL6NFDmhY z06uepOyK2E20EZirFicmnK9vIHSozXeV6BFZMSYA+67Gw5VXVpLPZEubOy4am15gkNi reAGOz+0JaGqvPF0J3Mi7J1w85n281KEv+lVX4Veaet91+ikXO7K+xh6Vvc5KAGl2zHO WNUIcc0v2SQjRmEyR47lniI7QJy7jN4QwVQ0cILoNteL38XXzohqVIhP4OvyKg5fuN16 kn2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WjWBbDP+; 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 f7si3207232ejj.375.2021.07.14.11.25.02; Wed, 14 Jul 2021 11:25:26 -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=WjWBbDP+; 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 S229936AbhGNSYu (ORCPT + 99 others); Wed, 14 Jul 2021 14:24:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240039AbhGNSXu (ORCPT ); Wed, 14 Jul 2021 14:23:50 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A21BC061762 for ; Wed, 14 Jul 2021 11:20:58 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id 8so5160304lfp.9 for ; Wed, 14 Jul 2021 11:20:58 -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=YIyhhFVB7lAJhhYlHC8Aypf2fwXB60EEf6/ds0a06qs=; b=WjWBbDP+tcAoBdyhzpem1Lt+enhBtxIdl7M/LZz7pvw2fcnfLkxB9LPDvEnrEoF1d7 cN7vgiiYCkEXNbXuCy8FBQx+2pKOOHn8AUC2EyBSHQD1NnfdhyiW8CQNXiExKTPcfWh5 HHek690m5HL4ZA6zm3mVcPfE3SwmsNv2kAgTEb2QQ8PszDqWMmFrSzSNrigP9XtUcSRA huzgAwiB3oced8ka9MN9OPRc2k8ZBQvS/jcroEw+iI0hJAd6d9S+6F3eaw7fDlQC1//i AVFxM4Us8XoLCmwsvE5u8YxooJy5tSa40XWL6dn57LJ/g0HJtaLFUZejCGKjq/Ebzyz5 mijg== 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=YIyhhFVB7lAJhhYlHC8Aypf2fwXB60EEf6/ds0a06qs=; b=V2QcQBVe/Q4bnHC6T/ls/wVZj4sOWI1GKRPnodkWob5rAZzK9Am+8lH55PAUnXD2vZ hUq+VAbvW3WhPoFtJkzqf6K56qmE6Slg11XeuS5IaOqKLzdJ5qEe2u/U27yyUQY/ypoL NygONEB8L82E/4vaPwKoFaizvuLsxs7Y01K3HbWL+SwkMWFUbragNVbROCF1DsUQs96Q j3b3AniFtupClkueTJEg5dRHIqa1LwKv2scR3DcJiKov5nQCqTRF5sg6WrzeOM/tCUvW RwxbAaCKBRadKsI85gLtZMBWdC29CFMr3y2QJNXVlsTWvT/Clpl8l0+N5rnbHV07MUIV 6ZWA== X-Gm-Message-State: AOAM531UDXC00Hwkm+iPWCmUQTBI+PnU80H6jskEZi+CO9hPYy6w3ZID bjOsTnwK5rj46+CtOSWZmcc/mwVT6yQ9k+mFRB3M3g== X-Received: by 2002:a19:4916:: with SMTP id w22mr9201976lfa.374.1626286856158; Wed, 14 Jul 2021 11:20:56 -0700 (PDT) MIME-Version: 1.0 References: <20210704202756.29107-1-ojeda@kernel.org> <20210704202756.29107-3-ojeda@kernel.org> In-Reply-To: <20210704202756.29107-3-ojeda@kernel.org> From: Nick Desaulniers Date: Wed, 14 Jul 2021 11:20:44 -0700 Message-ID: Subject: Re: [PATCH 02/17] kallsyms: increase maximum kernel symbol length to 512 To: ojeda@kernel.org Cc: Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, 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 Sun, Jul 4, 2021 at 1:28 PM 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 For C++ demangling, we have c++filt. A quick search turned up: https://github.com/luser/rustfilt but if the v0 mangling scheme is upcoming, I doubt a repo that hasn't been updated supports an upcoming scheme. Is there a more official equivalent? Do we demangle rust symbols when printing a trace from a warn/panic? That would be nice. > > 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 > 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 465060acc98..5cdc6903abc 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 335d988bd81..73874e5edfd 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 bcdabee13aa..9bab5f55ade 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 efb6c3f5f2a..5a37ccbec54 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 e56997288f2..d9c163f3ab2 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 4d0c02ba3f7..095d60144a7 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 72ab9870454..542f9b059c3 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.32.0 > -- Thanks, ~Nick Desaulniers