Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp966084rwb; Tue, 27 Sep 2022 06:53:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5PRqyKRyAvS7QVwMJ0gt2rOPnLusPWMg5wiLpU84mBXgu5M3L3yv2TM2mAC6Gqaut2HyD7 X-Received: by 2002:a17:902:e846:b0:178:64f:a57e with SMTP id t6-20020a170902e84600b00178064fa57emr27152220plg.40.1664286824010; Tue, 27 Sep 2022 06:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664286824; cv=none; d=google.com; s=arc-20160816; b=oRo0bgowI8NGlZ79PFRFehEk4cQMuCdgW1bAVpiov5KlSXosMLtwACXWp20olXsGBq TEzS7jG6yvo8FErf2JtCqN6C7lqWwb+bUWSOieG1Hi4D3+Xm5WGYRcr8okxs4WZLSQ0q 8JtUcaUcthtIo4cgoX3dh2d0PIbOhB9I4qJd3AoeMtv8hYMbhSLFk1Jr6Mh29dgB+Fod XNqGf3fWwJR2Xf2RUe1HQ1LDV412ssyvn/zQTzd4YUH8RcaKfrbVQv/XxqjDhSJB5Z/M 0NGGVgA4vKBw/olMKHO+yqgNf45NDwH3pR1b3KC78c77n7NQG1B7UleDn0eZ1r6yzF20 rauQ== 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=+aqN3kcHTzPaj7BHmjGrM8sLVUgxnQK5Wap8fIDcl5w=; b=mVwJPVcDzwfh2+uZgID6DUDQgWRLDQnIyGgPb6NvvXghpqv1sggih30cL9UFY+iYuV NYKw4yxVqPzM6vCF1IfOL6SrHnJ0OY0o3RK6SQfY5/O7XBNscrAl+MZSKSnW9DXH6bDr /ffzziD2LVFb8M9DHk2UAirSyvC7WevYaPeOLl55taN3WnPVPSCU2Y3GdvRHA8L/Oerq ecFfSZdtv71atCmHUYlqnBrBtoIYxC9S5z36nR2MVMvQEXV8uaxmrtxh8e6OijTOOdFg QfBADfVBlTNhGVz4qqQKGkgSk1HIR0/m3cptFLRWkrEPassFXt7JP1YnWYIhHckSIydF JRTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lfXNrduf; 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 n16-20020aa78a50000000b0054875fd979bsi1882902pfa.216.2022.09.27.06.53.29; Tue, 27 Sep 2022 06:53:43 -0700 (PDT) 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=lfXNrduf; 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 S232613AbiI0NRK (ORCPT + 99 others); Tue, 27 Sep 2022 09:17:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232604AbiI0NQ1 (ORCPT ); Tue, 27 Sep 2022 09:16:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46EF51A81C; Tue, 27 Sep 2022 06:16:13 -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 D682461991; Tue, 27 Sep 2022 13:16:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77843C433C1; Tue, 27 Sep 2022 13:16:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664284571; bh=7gkr1S6E4dSDSrF/vNimKY/tgp0IGdnQL4HLj5SgpZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lfXNrduf0s58T1/6o7/9lCy1u5pxgReY/9RcCwxUkdXo/v1KQZBJSQQ1o5V6tgpKm f65cBd2x/QQZEyR7jhyp9hZDmCZJtnUn9mgKtxdqkpY9hIBGWvsMKsjRZje8KWOlXp msgtzBCPzM3wOEwSlIaR9Gy9CKpQYMi3IIHkymcp4/DStnAu8AxLOSCFxOyzxqklsZ gb0pFUyX7cXoXc+MrqhECSHJ6S2GG+gG+89eOz8jeK+MC4tP4BKhp6SNIMHU95CPA/ t4oBhED4BS+HhQQpF3DfQeELIGCZ774a2lioiO43/0UT4qVLvDKoXJzW/TiDIkVf59 xAyxqI9OCoCzQ== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Miguel Ojeda , Kees Cook , Petr Mladek , Alex Gaynor , Wedson Almeida Filho , Gary Guo , Boqun Feng , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , 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 v10 05/27] kallsyms: increase maximum kernel symbol length to 512 Date: Tue, 27 Sep 2022 15:14:36 +0200 Message-Id: <20220927131518.30000-6-ojeda@kernel.org> In-Reply-To: <20220927131518.30000-1-ojeda@kernel.org> References: <20220927131518.30000-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 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 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. Reviewed-by: Kees Cook Reviewed-by: Petr Mladek 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 | 4 ++-- tools/include/linux/kallsyms.h | 2 +- tools/lib/perf/include/perf/event.h | 2 +- tools/lib/symbol/kallsyms.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index ad39636e0c3f..649faac31ddb 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 bc475e62279d..ec06ce59d728 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -213,7 +213,7 @@ static int klp_resolve_symbols(Elf_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(Elf_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 6502c4001f01..c4793301a27e 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -30,7 +30,7 @@ #define _stringify_1(x) #x #define _stringify(x) _stringify_1(x) -#define KSYM_NAME_LEN 128 +#define KSYM_NAME_LEN 512 /* * A substantially bigger size than the current maximum. @@ -39,7 +39,7 @@ * for the fscanf() format string. Therefore, a _Static_assert() is * used instead to maintain the relationship with KSYM_NAME_LEN. */ -#define KSYM_NAME_LEN_BUFFER 512 +#define KSYM_NAME_LEN_BUFFER 2048 _Static_assert( KSYM_NAME_LEN_BUFFER == KSYM_NAME_LEN * 4, "Please keep KSYM_NAME_LEN_BUFFER in sync with KSYM_NAME_LEN" 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 93bf93a59c99..d8ae4e944467 100644 --- a/tools/lib/perf/include/perf/event.h +++ b/tools/lib/perf/include/perf/event.h @@ -97,7 +97,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.37.3