Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp4851214pxb; Sat, 12 Feb 2022 22:27:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIu/EldPWEjzsTN5o50aSKuwsXsDwlB+lnrEYhy03kmck63frVVP2kdMVZXy//8r6Hfs/O X-Received: by 2002:a17:902:f60a:: with SMTP id n10mr8882114plg.1.1644733655220; Sat, 12 Feb 2022 22:27:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644733655; cv=none; d=google.com; s=arc-20160816; b=wn0tufI3O2rBIFHw3mUmYZB577Szkq6RWO1kfmlLUX6nQKra0ujPQ399aJA/UZCnMS RyRtdK+CAEYOA6Gli8VHbqindBtw1mOyN+zg9PWQkcO5XagZNFIedoQCssbERhrWbZ73 LKY8D+H0Z9U04QJRnmDQ2MeOJplKNWAg3eyNgPOPy3D4632j/MGnMavZskimMsfxGUzl uc8xiRbnra/gir0fAJLCNtGs5vdsLObdlFTdDUhZEVZ1oU2xBWqalFPJu67OhMlQHTNh gZIa5BDyAxSPUKSlvRABNlXGUvAI5Op0iYhCDo4Z2WIGSNl1Att1Rzo23YGa3BIpHSAv 4Cfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jMf/SeCtY5UIO+S+shzPR1d1p6y6xlocBeiuaAFJLXI=; b=B233BIknk48Mk8d9UVh51qgGKh6iAPz2RTk2bp0G1XVAv34x6z0LqK7pm+iHA3KAw1 VKgW8byTXZNQleyQ9PIpeXxIbRkc0tvt7gHKo3XZuoCL3CJ+dGZOIiQ8ksicgPNqhyvg o1Qj/56sZlpwEwlYpkI8mHgWrzmOO2iRP7lc9hQK1ptt3icqdULafZooQL2PNPBsGf6c cCxMmzoLvW8M9517D+EWaoj6nF6XHsDNEPazBfeqmMeMQop+BGY8bQ/jE+sLUvninN2N AzGt2TKr8yJQIa68Rhqjvdrc9v5VVRYhzoBdGnrLlFyjkPlhzWee68sHEUwHPITocAr/ 3BCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hjgQqZcT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p10si8940498pls.262.2022.02.12.22.27.18; Sat, 12 Feb 2022 22:27:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hjgQqZcT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235263AbiBLNFT (ORCPT + 99 others); Sat, 12 Feb 2022 08:05:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235157AbiBLNFQ (ORCPT ); Sat, 12 Feb 2022 08:05:16 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2887526AD9; Sat, 12 Feb 2022 05:05:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BB87660E95; Sat, 12 Feb 2022 13:05:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 447EDC340EB; Sat, 12 Feb 2022 13:05:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644671112; bh=yiz4DbQ/9AlF3A85iP89O9KMYTiZPJew/nsawP2NfBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjgQqZcTVs54Odi7AbrrQ61E0tsUMGzcvI9iA9Gfj1wgYbGtDuu40qzG44M33l6SV kDi+/m48YYmrISM29v1qsKWDqOP/lfvaeWTQK8tDZDuFy6+UfBQ3mW0u93ngzaRd54 O7jBU1Fbc0Acxa6GspCq6AR/YIitL2b2/quJyL3nWg+mwZFxfDUSuuU1UcwpvePFjx YaKT4XW/l9cK5ytmFeWNhuSdiWU2FPoDOASMQ/efz5eAyE5lmK4qlU5bSc7F95V7Ib 7Y/MOYDW6+QniE8ubRnNJMCsLXMT4+pFtSz3BEQ7hkl93HSbeA15NeBl5Ef+YoCOUt c36T/9jBfi6Bg== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , Boqun Feng , 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 , live-patching@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH v4 02/20] kallsyms: increase maximum kernel symbol length to 512 Date: Sat, 12 Feb 2022 14:03:28 +0100 Message-Id: <20220212130410.6901-3-ojeda@kernel.org> In-Reply-To: <20220212130410.6901-1-ojeda@kernel.org> References: <20220212130410.6901-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); 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. Co-developed-by: Alex Gaynor Signed-off-by: Alex Gaynor Co-developed-by: Wedson Almeida Filho Signed-off-by: Wedson Almeida Filho Co-developed-by: Gary Guo Signed-off-by: Gary Guo Co-developed-by: Boqun Feng Signed-off-by: Boqun Feng 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/lib/perf/include/perf/event.h | 2 +- tools/lib/symbol/kallsyms.h | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index 4176c7eca7b5..5fb17dd4b6fa 100644 --- a/include/linux/kallsyms.h +++ b/include/linux/kallsyms.h @@ -15,7 +15,7 @@ #include -#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 585494ec464f..01bfab7fe7c0 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 79b11bb7f07d..72ba0fe4e43b 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/lib/perf/include/perf/event.h b/tools/lib/perf/include/perf/event.h index 75ee385fb078..acc4fa065ec7 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 #ifndef KSYM_NAME_LEN -#define KSYM_NAME_LEN 256 +#define KSYM_NAME_LEN 512 #endif static inline u8 kallsyms2elf_binding(char type) -- 2.35.1