Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2265787ioo; Mon, 23 May 2022 14:18:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz22Ztfya97IWJMnOYHPZwd2L4SFGviX4YcHanSjYkL+DRZsPBJgiFiYUlZ+4dcLMzd8dqG X-Received: by 2002:a17:90a:778c:b0:1df:56a5:8474 with SMTP id v12-20020a17090a778c00b001df56a58474mr976364pjk.63.1653340698527; Mon, 23 May 2022 14:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653340698; cv=none; d=google.com; s=arc-20160816; b=A7FZcc1aqMsY9y3O7pBqYGuc+NppHOESSM2Di7Gsbn31vkCXHk5sT/fO18Tgicao7F lk2QGRd43D+ORAAqOLZTmsQ0srJthW0hQ/+UdQywQAbgYRRyy1kaTLUlVnEH/V0QsDeV 75mZ4gQXXyjU0qdBkHbphWmvy1AZGQzy5Gpay/C48oDnlVVq5vrkVBmNLv5UGOFBdugt fZd6P5fd/Pwg7VDyNAtdcLfpjxYocn80a6F4tHgNuqGxP7mx2k+rUQLV166dDny/XMlL G5/FBYQhUuXylSuxlHz1MUvK0+hxyGuQLEKMv71FRwd8i+QA6ZHx3ftn85vn/asePjqJ ihTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=upt2GbNgAStP8dCYW5MD2bvOwK5gbgSUfI8ulJsBv3o=; b=oXqMRNQSZ2KkuzRdyuh3sYmRDyrWHkCF2xxNTZPZ9P5/wUImcdGUq/JblChCV+u1SO KI+5Xttqv3WIFZweV7SaX9Kmb7c9G+t/cdN5hWWpx/LgTEAl8thGjmrMYc1ff3Nr5EZZ NSq8WMV+Ty3LrVneyZO8byfrxZL50Crpge927m3aCrW/s/Yie1j2rILSxJHAzmracH66 fo5A28iSWncqzgjQmFMcVcHpsfqMzGYIn/HNxLm2wPXnR1u0+g9MP3xsoG50JdrRqQgn XRFKDVHLicnFoPnvZhbMply6ZoknBFrsMits8PuyIunmhOaMBaD2qSTb+JIXA89+Ps+P Gt/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hIJVMVPO; 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 i70-20020a638749000000b003f9f41da8casi8213134pge.14.2022.05.23.14.18.06; Mon, 23 May 2022 14:18:18 -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=hIJVMVPO; 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 S233122AbiEWUdN (ORCPT + 99 others); Mon, 23 May 2022 16:33:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbiEWUdM (ORCPT ); Mon, 23 May 2022 16:33:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1D9D3888; Mon, 23 May 2022 13:33:11 -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 8A846614C5; Mon, 23 May 2022 20:33:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76106C385AA; Mon, 23 May 2022 20:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653337991; bh=VNVQzR9kS5xu6l5roSausKAujCRxQKGSD7vdR797KGE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hIJVMVPO4q0ZiGjXpeP/mp4WoS7qMOycauFqdeUAuUGM43xRdfvgUY8U5T6wMqW1L zMPwuEAUOEXE75o6b8ynAoLKUQhYAvGJ0ymtZ1WAwPxNpjZO0V49qzIyyFprsl1zAP 8s3OG0kh5AngMWZjGcnxwNJOMNzDrPepOl+1DPt7XkAqz8gfKLlqQg516vupKzVIL/ TxUEMRRj8+CXre1EU5IRDttOTfc7nBok6vfvfW8mHhpuDbK2eizWsbWMngOCKATCwz Z7SOdDnPK8DfSpFWHOsq5M8fXFUT+49SGHKfi6/C6UAT0Y+OZE+EuW5lBjz53bDXLM LW3NXhYYO/qPA== Date: Mon, 23 May 2022 23:31:29 +0300 From: Jarkko Sakkinen To: Miguel Ojeda Cc: Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, 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: Re: [PATCH v7 03/25] kallsyms: increase maximum kernel symbol length to 512 Message-ID: References: <20220523020209.11810-1-ojeda@kernel.org> <20220523020209.11810-4-ojeda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220523020209.11810-4-ojeda@kernel.org> X-Spam-Status: No, score=-7.8 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 On Mon, May 23, 2022 at 04:01:16AM +0200, Miguel Ojeda wrote: > 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. There's no description what the patch does. > > 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 > --- > This is a prerequisite patch, independently submitted at: > > https://lore.kernel.org/lkml/20220506203443.24721-4-ojeda@kernel.org/ > > 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 ce1bd2fbf23e..e5ad6e31697d 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 7e99799aa7b9..275044b840dc 100644 > --- a/scripts/kallsyms.c > +++ b/scripts/kallsyms.c > @@ -30,10 +30,10 @@ > #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. */ > -#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 e7758707cadd..116a80c31675 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.36.1 > BR, Jarkko