Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2733222pxb; Mon, 17 Jan 2022 04:49:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1bC/cEwLZXN1MpEcN7/2IOpgCnggbJcck+BfXjzKyMkRak5mrVr3NwFNQdVzPHCYPuQgE X-Received: by 2002:a63:9043:: with SMTP id a64mr15373343pge.573.1642423740186; Mon, 17 Jan 2022 04:49:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642423740; cv=none; d=google.com; s=arc-20160816; b=ewBynTDJ+I/XIjC5rCQtHSSOxSynjTIupkJ+eaw5aT72TPwy2aDY/YijUjpfPv/0Ol bS9rWx/2ExDmIr6xkVIZ9S/U5RYkrIgYWcCPN2yBQZgtpIJIJq8ctA85qafpS73LF+9V m15NOqFymFivocA0Zd03qbGQGrjC/2HoHZqhSw7fH8c++J/vXCL3TY+x8IHf4PYmiXua LnT4lggXXJLdiNYUqW6Z9XHIKD7U6xNvZuEtqIAl8Ztsc4vzZ7lfboW8Aj/B1jTEeN+d ZEpSQWS6toLW90VssHmzxXmIFlkFOXwE0opWXCFFPT30UvsD9sd4iESuHsKZPMSRzQk5 Z+6Q== 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=b6Nlk1mw+R0N9S1C16aJXsuLjE7aqC8UW4et4Q9n7eM=; b=K1ifrCnSEdAFIxHzZmiE6VKuJnIXm0V1oO1Zdl/F5ImgaTjrETMqRqNjraKw+GmU4K Fa5i/xlAQWhgJHXIEQzQuPh701ZGkihfpbeRsGDDreRZpO1ViNsp3ZozK9z/mmqKqE9g SzikIybigOwZ+Hs+S7k3UWltFGHZD35o18J/9bo7aigwBX+vRkWf2ATEPKxfdJ/dh4th vsLj4QBMvrV0e9DZs/BBdgCRA6iFxi6JRGCTXcruFmgjN9v5+ArZBsNHebpNBW358ihV U0qru8jzURpf7Vm1lYLAEF6vI/wva/zn70J95Cqve7EUXTOro4S9Bl6fj6GtEYS+p6P+ TBhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="K/uoLq1G"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si15043749pgu.75.2022.01.17.04.48.48; Mon, 17 Jan 2022 04:49:00 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b="K/uoLq1G"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232213AbiAQFe2 (ORCPT + 99 others); Mon, 17 Jan 2022 00:34:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232072AbiAQFeP (ORCPT ); Mon, 17 Jan 2022 00:34:15 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EA45C061574; Sun, 16 Jan 2022 21:34:14 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3218FB80DCF; Mon, 17 Jan 2022 05:34:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E3CCC36AF3; Mon, 17 Jan 2022 05:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642397651; bh=W6rdRtQtw2n6gJ7Dx7Q/ZSpFRdsjm4u2kRrg/IdRSyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K/uoLq1GmBQko8e0CGSNMj2VQ8lCfTSw6LnZRYtuc9uu8k/tfglVPTeySPuy0cfn9 9hxnxkYGA5Yf5eitukoqst6sid3iwZSG/LcWUskSeicaCJghUKsTtBFYfvfq8YM/GW MbNpSMxkUWlksYSm9Jh+L/WbCFLvNN3ledf/zcvGXYieYVKUIm8/4KE8o0J/S/4qV7 ZXmqxlunqV6VWGrlSw5VkB4k4IQGxhwuHBJwkK13N85vNAF2itMW1muTGWVo7aJw8h +QmTiKG9cby69WG9XhHvUrnm40FBf/G9GkkGXesUM0bjoH4T9DmXJJSpRd2oRSm1vv EbBNmQ8T3t96A== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , Boqun Feng Subject: [PATCH v3 02/19] kallsyms: increase maximum kernel symbol length to 512 Date: Mon, 17 Jan 2022 06:33:32 +0100 Message-Id: <20220117053349.6804-3-ojeda@kernel.org> In-Reply-To: <20220117053349.6804-1-ojeda@kernel.org> References: <20220117053349.6804-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 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.34.1