Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6068948rwb; Wed, 18 Jan 2023 00:16:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXut/vZjuCv2aIDU91VXo4sTE4qtpf72XtqUUpXNISJ7WoiM7QmndyDAgRDPsjx/yy1MxmKX X-Received: by 2002:a17:906:762a:b0:7c0:be5d:59a9 with SMTP id c10-20020a170906762a00b007c0be5d59a9mr18883340ejn.20.1674029811044; Wed, 18 Jan 2023 00:16:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674029811; cv=none; d=google.com; s=arc-20160816; b=NethbCzMkyo5rxnGHVjv4//1moD1v89NxN1OHpsD0D40dH9g24gbhFKiwhDJ5YA7z3 hbu73kU/lIfg+yiHITJWoojZDStgq0pu7KLBqqdREnOq41fEgk7km0H1KMN8bBd+WEcv M9ZeT5+ERU5+EdSRr9JUZA3IFyhFvnrwBVeENLngtpo+xf5yywS6GV+nbIxO2tqqFvzG BF/iG0go1LNlXul64nQrTQ9kQ3w3+HbhIiDKAZM9c1qcd6fUF6v0kXEC6ZeRhz3eESPn 8fCI2qe4/EkW/K3X1M+HOK40qFU4mIuqNjnMQoJTlu0p/QUrMBJU3+yZ6SfN36k5cAPi DVDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=x83Fht0RNJFEypFL5Osajj4PSjJIsH+MuQYX0T1qZMM=; b=t6OAYjsBelTcHZuvNKttv96n44f9QIwjNYJ/jldH1CHundKCkhSyMQXw9Xw+rqL2Wu IWY2KkMtpbJMZhHpodYQ8g5dO3Uad60FEaUMjScR1fBGcen2DiSyYeJm75/RYck53k9c YCMCdvL/ZCcPRYvsWrMO6O7/hTfs+umnZeG9sFkKDO73CcenTpL4elJ1BodToKVJ47Xg i2/mByV68x17PmJFgwqNyUnb2rjyonnbsCR5bONvzcdkY+RQOa+DTBjAONcUie+uZ0s0 vPaCwT6BBPzgJKaEjNz16wknE/PZAFP1yVKmHx+z4qw4fwPM3HdKk6X3NO0be2H7F3G3 1HWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DSgHVawM; 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 hb44-20020a170907162c00b0084d4707b50bsi33638932ejc.698.2023.01.18.00.16.40; Wed, 18 Jan 2023 00:16:51 -0800 (PST) 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=DSgHVawM; 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 S229779AbjARHlU (ORCPT + 46 others); Wed, 18 Jan 2023 02:41:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbjARHjK (ORCPT ); Wed, 18 Jan 2023 02:39:10 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E90CD2ED76; Tue, 17 Jan 2023 23:02:09 -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 95DBBB81B7B; Wed, 18 Jan 2023 07:02:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 379B0C433A0; Wed, 18 Jan 2023 07:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674025327; bh=hpCZZmsqf4/6Mxu3Z+UTxXvwuRL1LaW+0KrqiGLzrlw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=DSgHVawM2Lsbp1jqLhhrzzbXJt2A/+zta9eAwgCv3451lTKsCGx3Xy0LDIRX49ICc NK+gQKeOG47zXzt54pg53kZEJ0P+rQrFot+WzXi/WdNiD/QGHjAVcP6LhEYXIuneX7 aV8/FNmafMuswBPQHR2WAe4H+Ii+7BaO5BA3DNheJdnY+dpib9ZU1WdrN9gxvSo6a6 i7suaS0Ta2qvPrl2vJf/2GkourBl7CrW5Tb9VSF1uGS0nGGIbKyFchzA8bVZhYYyaE SqkgWJM/vhO98tSNVK2vAX4kmmPVlGuM3Cvzjjgc8pmU5wNZPIC2PJxGWK4P2z/JhW TwZ8CbFBzGKyA== Received: by mail-oi1-f171.google.com with SMTP id s124so11106094oif.1; Tue, 17 Jan 2023 23:02:07 -0800 (PST) X-Gm-Message-State: AFqh2krB0e2Yg9EkSs5F4kHXsYDKi39pYpFCp2/ZNvkwUGdZmMqs1ofB qtS53meYXd3KWvAxaGmgU+5c9HOtFnDuGrH45/o= X-Received: by 2002:aca:acd5:0:b0:364:5d10:7202 with SMTP id v204-20020acaacd5000000b003645d107202mr275302oie.194.1674025326155; Tue, 17 Jan 2023 23:02:06 -0800 (PST) MIME-Version: 1.0 References: <20230111161155.1349375-1-gary@garyguo.net> <20230112214059.o4vq474c47edjup6@ldmartin-desk2> <20230113181841.4d378a24.gary@garyguo.net> <20230117175144.GI16547@kitsune.suse.cz> <20230117192059.z5v5lfc2bzxk4ad2@ldmartin-desk2.lan> In-Reply-To: <20230117192059.z5v5lfc2bzxk4ad2@ldmartin-desk2.lan> From: Masahiro Yamada Date: Wed, 18 Jan 2023 16:01:29 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] modpost: support arbitrary symbol length in modversion To: Lucas De Marchi Cc: =?UTF-8?Q?Michal_Such=C3=A1nek?= , Gary Guo , Kees Cook , linux-kbuild@vger.kernel.org, Wedson Almeida Filho , Joel Stanley , Alex Gaynor , Miguel Ojeda , Wedson Almeida Filho , Nicolas Schier , rust-for-linux@vger.kernel.org, Guo Zhengkui , Boqun Feng , Nicholas Piggin , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Nathan Chancellor , Nick Desaulniers , linux-kernel@vger.kernel.org, Julia Lawall , Luis Chamberlain , linuxppc-dev@lists.ozlabs.org, linux-modules@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 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 On Wed, Jan 18, 2023 at 4:23 AM Lucas De Marchi wrote: > > On Tue, Jan 17, 2023 at 06:51:44PM +0100, Michal Such=C3=A1nek wrote: > >Hello, > > > >On Fri, Jan 13, 2023 at 06:18:41PM +0000, Gary Guo wrote: > >> On Thu, 12 Jan 2023 14:40:59 -0700 > >> Lucas De Marchi wrote: > >> > >> > On Wed, Jan 11, 2023 at 04:11:51PM +0000, Gary Guo wrote: > >> > > > >> > > struct modversion_info { > >> > >- unsigned long crc; > >> > >- char name[MODULE_NAME_LEN]; > >> > >+ /* Offset of the next modversion entry in relation to this one. *= / > >> > >+ u32 next; > >> > >+ u32 crc; > >> > >+ char name[0]; > >> > > >> > although not really exported as uapi, this will break userspace as t= his is > >> > used in the elf file generated for the modules. I think > >> > this change must be made in a backward compatible way and kmod updat= ed > >> > to deal with the variable name length: > >> > > >> > kmod $ git grep "\[64" > >> > libkmod/libkmod-elf.c: char name[64 - sizeof(uint32_t)]; > >> > libkmod/libkmod-elf.c: char name[64 - sizeof(uint64_t)]; > >> > > >> > in kmod we have both 32 and 64 because a 64-bit kmod can read both 3= 2 > >> > and 64 bit module, and vice versa. > >> > > >> > >> Hi Lucas, > >> > >> Thanks for the information. > >> > >> The change can't be "truly" backward compatible, in a sense that > >> regardless of the new format we choose, kmod would not be able to deco= de > >> symbols longer than "64 - sizeof(long)" bytes. So the list it retrieve= s > >> is going to be incomplete, isn't it? > >> > >> What kind of backward compatibility should be expected? It could be: > >> * short symbols can still be found by old versions of kmod, but not > >> long symbols; > > > >That sounds good. Not everyone is using rust, and with this option > >people who do will need to upgrade tooling, and people who don't care > >don't need to do anything. > > that could be it indeed. My main worry here is: > > "After the support is added in kmod, kmod needs to be able to output the > correct information regardless if the module is from before/after the > change in the kernel and also without relying on kernel version." > Just changing the struct modversion_info doesn't make that possible. > > Maybe adding the long symbols in another section? Or ble > just increase to 512 and add the size to a > "__versions_hdr" section. If we then output a max size per module, > this would offset a little bit the additional size gained for the > modules using rust. And the additional 0's should compress well > so I'm not sure the additional size is that much relevant here. I also thought of new section(s) for long symbols. One idea is to have separate sections for CRCs and symbol names. section __version_crc: 0x12345678 0x23456789 0x34567890 section __version_sym: "very_very_very_very_long_symbol" "another_very_very_very_very_very_long_symbol" "yet_another_very_very_very_very_very_long_symbol" You can iterate in each section with this: crc +=3D sizeof(u32); name +=3D strlen(name) + 1; Benefits: - No next pointer - No padding - *.mod.c is kept human readable. BTW, the following is impossible because the pointer reference to .rodata is not available at this point? struct modversion_info { u32 crc; const char *name: }; --=20 Best Regards Masahiro Yamada