Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1645659pxp; Thu, 17 Mar 2022 13:30:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIEpxOOqSgUQw6xuyYnsGykNS8CxZmc8wh1QvYEP2CfnsBnXlwIbQuvCrVOfdQz/dIXeor X-Received: by 2002:aa7:8ec2:0:b0:4f7:4a9:7fcd with SMTP id b2-20020aa78ec2000000b004f704a97fcdmr6917085pfr.26.1647549015494; Thu, 17 Mar 2022 13:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647549015; cv=none; d=google.com; s=arc-20160816; b=nio4qJBGmps4aG1TteGxd7fqBW9YHZ60MLZ/o8nBFXPDStkB6L8Pbi2OQyhBbDZOE1 tkhlbra2uTeOxigKewb572PLwGYz0br+t1gOkhg5s7nBXs+nCkMdStUtUr91RrGbBX28 VtuSEWAhDq0j1/B0gBY4PjKfQ1OU1gstbkyZgbksMhFib7slYext1hGgSwUjAnng5+Yb E6/SIjGdCK2PlEOZalyediaU8+P35FFl+2ASFRvYIzeUB0M4o3uooZU7zB+vLhVv+d36 Cku2/m2wAU57IbZfl8XjdejVs6FwSR5mKhhaX74nNTDNN7Q5R61KwM4I1qdVWjPRtX1b aurQ== 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=LnuWdkI44Erp4GiOLHdNQylhy/HzTnjkMBUUEPVaSxuecDvGx94TO0ObwtbDRdhoPa oG4SFt56PTFSOq0dXmHM8Ge3a/yyYkrJVEtVmLqezo37kieGF3k8YnrlDF2CKJ9VxJGH dZ9H6aCVkFLPXuK8tzaG3rvQr8p5fHBLZwRS0r77lUawkzNKCjkAoo4xKQ+BYsLkdV/g 5K8V+XxFFfY4/ufFSTSv3Qcy7XYUZpHNsPP9NesV9LRMNt8KU1/tCId2qt4CqB5z625k SS/SvoubEnfaqqtjhnPyjyuofTYtKworQDlaT4aeOOWh4/0PcHn4vV/W3oupdEZc978r sUTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L893+o2l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c196-20020a621ccd000000b004f6ec464c79si5120851pfc.203.2022.03.17.13.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 13:30:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L893+o2l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 48CEA2CB18B; Thu, 17 Mar 2022 13:05:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237282AbiCQSMu (ORCPT + 99 others); Thu, 17 Mar 2022 14:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237258AbiCQSMk (ORCPT ); Thu, 17 Mar 2022 14:12:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CD9A21F746; Thu, 17 Mar 2022 11:11:22 -0700 (PDT) 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 1439161645; Thu, 17 Mar 2022 18:11:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA26BC340E9; Thu, 17 Mar 2022 18:11:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647540681; bh=yiz4DbQ/9AlF3A85iP89O9KMYTiZPJew/nsawP2NfBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L893+o2ljsfCRylywGRyYrRrHTudGE3CcdUspKLIMZyCSRvMx1kdjnZntHTdJSnha nhJa7MaOxXADHLJDUlGe3PdKvFz9ryoCwLbHM16Hhdo3XZcrYNxmvofLr2MePZ1jNU RgqrpS5HUr/oClVOZxfb6abPWFcbJn0Ue7eouL97zAZdpr3kluIh3am8j8PcaONoz9 853kqVhqSTWQjux7z3aserj1R4uBGgQSkCohO5+2LyCOt+xor6x22/3KJYo0NxtRmE 0uS6fBbD7um5m10gq81yduPJ0iY7O76H84VbDa+Yf4MvXTqmW05dtaMlbzkI2V7nlB g6EMZpg9hXS5A== 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 v5 02/20] kallsyms: increase maximum kernel symbol length to 512 Date: Thu, 17 Mar 2022 19:09:50 +0100 Message-Id: <20220317181032.15436-3-ojeda@kernel.org> In-Reply-To: <20220317181032.15436-1-ojeda@kernel.org> References: <20220317181032.15436-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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