Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp357188pxb; Wed, 14 Apr 2021 17:43:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzklYBBJcKfhdDpLkT3zTd9LwNpa3d4Esy+fKXeBbCONNE/hFJKmNIb5VwcCwzzre/HW8nc X-Received: by 2002:aa7:ca0f:: with SMTP id y15mr72935eds.384.1618447391129; Wed, 14 Apr 2021 17:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618447391; cv=none; d=google.com; s=arc-20160816; b=iNiRnMokQpLXUDg5zjX0FIJToC6KxIT/6fJ8I6CXu58CKQ4Qf9PA9in5vi+V+Cn8CA AjM0AUF2RBL8pEKQ3eP/w2iwrkmu417R85cv30o7vfCf/zEsJO7ZwsgStCnOBwWtPsbQ UtFLP/PCNd0WPJqYPyeyI45DAinLt8xNd92e9u3BIFVf2vHomV3uvZq1O1Sfebrctif9 CULwCBFfNOlovSHvcP4NOi6txFZ2M1ohk7mq4wYLm92YoF8UJSsBxtET5wcR793ha/e+ KYqglnlMScrZWNUTIRabvJh7a+vmQ2Jn8Jz4oN3htPdo/g704tG9+ULnPxU1ytRMwo7w cT1g== 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=zIMurb+iLEKGYBNQzq5dO/ffI/ntMdJiuI8W4Mu13Hs=; b=JF5s/vBhV3gxBWQ4A9L7MtKB94sYqLW+9nSKBSyJMZxLhmx6cNOmddEnp4wtWFQupU o4XvQ/F8edWn9alVIL7yrc+2nQ+ylCXStX9dcjM9JlkGPyoJnAEARD1aIFPupv+233t4 ikYrQjX/CXqEtun3m6cCVuj/PcT4PoappZcMQHkWasKNY1jxIJiErJh3uRHrM7nKTEkH e/ksx7D3pJTBhaYmtXNIaPt1xfuwe8EoK22K9bIp7mgm0e1eoLvzOEeiRSP8DBMhW7zO Kc5U6sISudCRGWyXaO0N/cX5+xk/xOWVKYqpFjmJKaAbfpLePXzbkyxWoK5XR/vPOiF0 IxdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cPiWN9LV; 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 g16si748101ejm.310.2021.04.14.17.42.48; Wed, 14 Apr 2021 17:43:11 -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=@kernel.org header.s=k20201202 header.b=cPiWN9LV; 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 S1353060AbhDNSrC (ORCPT + 99 others); Wed, 14 Apr 2021 14:47:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:49122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353030AbhDNSqz (ORCPT ); Wed, 14 Apr 2021 14:46:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E096661132; Wed, 14 Apr 2021 18:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618425993; bh=nWjRnE5Troygiekp2/iziJp1V4JrtXjO8NzGFia3R6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cPiWN9LVTn4IO54L5Lr8B4O8cpzJC+8OjGC1pcjyvVRxcbGObAxTzhp7zkI1Y7DCz 64OdIg7Xvp4sZwJwn6GHR3QBwz5Wp5XJDFtUBT9aV5pIJSexIVGV8xGNQ2A45Z+BYK +rzNBWwoYOpC1onNlvvrl7S8ZZs6zW8K1gU0IiTf8AYKh/b3TrM2JclAAh1vzo8jL5 YqgM/zUV/LCGyPnIbo4iYzVnFjAWWOD9iWeqJ04NcBXsk7N6Hq7SGxfZai76FMhTul VTK5zZCPZNvKxZbGyMSEY3bHszAF5vLdJMnXi4HOx38nwLVrQGWUJs1CpjSongaS8x cw5qKk3+hVgQw== From: ojeda@kernel.org 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 , Geoffrey Thomas , Finn Behrens , Adam Bratschi-Kaye , Wedson Almeida Filho Subject: [PATCH 02/13] kallsyms: Increase maximum kernel symbol length to 512 Date: Wed, 14 Apr 2021 20:45:53 +0200 Message-Id: <20210414184604.23473-3-ojeda@kernel.org> In-Reply-To: <20210414184604.23473-1-ojeda@kernel.org> References: <20210414184604.23473-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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