From nobody Tue Nov 26 19:43:36 2024 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB8DF1F80A9 for ; Tue, 15 Oct 2024 23:19:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729034383; cv=none; b=KVDpLGqyWH0wZNdYj6CPUi5uQ+l24MGi6zEY0ASfLccRedhVjobpzmYxtjwdq8Amj1B3WX/QK/w6yMoZPeAf76u8itnrbEJEreRYC3zCDbfR/BhXXji9KtvWoJX38hMFegzt20LFE87P1EHIkXBFUWYl6Z0uQKj8o4pnVATVAY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729034383; c=relaxed/simple; bh=eBJG2rXeVYA/XEzcQYJAZKaNWGCWFxTaGo2H2wh3ljw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Dz536u0rF9njK9d4qCSbffBFVRpC1wMJlhNSsNgdFq4XkMkf44DpMWxj4K1/72DEs2fem8TSkZ/E2ibI39xleteO2wz1roYNIlOTKTPi55zGXjIFfnQAAH00luUtrevbHrnHhxBa+/QMgDjpNeRjnDYojMXGg3bzS3PvcJh9oE4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=HudI9Ysc; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HudI9Ysc" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e290b8b69f8so9818803276.2 for ; Tue, 15 Oct 2024 16:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729034381; x=1729639181; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=kcWYIAwP9b7jjsyrsKEHRrU+6v789OznTVm7Ys3lY5Q=; b=HudI9YscA6FvaCounyUY/VU0lVXBbLKqsQFSi32mPopNM7pInijLK3EUXckBqR0o97 x7kD1rbA+ULIYTt1fjL1YX/l4/Xn3LAY6XT7Kx0sUjSEVBmjiei/4/BlBAKRDUKbp0RB coWHQemMeFQzc9vaUz8QcWmZPsgwg62jEuTr5cVx1bBwPHi3E2D7rmug+2lJ/9dJJkQz XcFZf4Eo6RfI74L88bd7GeUCZF4Vh8Rs3DUlZjW917ZkxbRiIN0ps7wAC5auDZ9cRocN jBGOhuF4T5FoWFhdqraIhqXy5phuyc1FfjdriSLf5I6LGBPGB10/2lpxWYOSVPAhfjhj oGHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729034381; x=1729639181; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kcWYIAwP9b7jjsyrsKEHRrU+6v789OznTVm7Ys3lY5Q=; b=vF+uOs2qptCYxZMoU2cX/IHHKJeg40jYBnxN1UuvWcIYw5cGw7OHDJNoStKmzsp9LZ I7FmrRtpHFfJY2dECbfbHPAUffC3oiFh86KWDcMxTOdJFuq3gw943PFlsaphk7QV4Ve2 6MHsxb1v8CqN35EpZqk78pM5HFiDYYGn8g6VGLMkD2PJubsjaPs8VAen0jS8GeLMe+Nv KiswZM/iTIfmF8nJFi3vdbw9KfRI5A3PtgZR8WucEmqMyYNuBnxqFYh4oRNQ9LBsYD1l GYI9eA5EqWEkQzM29NDCXKMb7YJCK9wZcZc4QVr+QKmpWNvhXakpMuTa3iGDq/WBJpI4 mUrw== X-Forwarded-Encrypted: i=1; AJvYcCVaVH78FdOVvWripyzz1qSCj0tmtmdEN2kVuYXxu/QJF9pvj1s89pCFa1a6cMiPc52wzjQ0SYakHc842MY=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0uYIYPG0XJ1z+RavNTW51VD8ucWFKMtRoauVPuRQk99Lm5qkG WpBEJUhD+vdoYGgcuGnN4yfQeCoIgXBrcVY/hPFTk+DddFphPKV7KXuUIFymE9B8vp2JPIyqORS 3KJJyng== X-Google-Smtp-Source: AGHT+IFGh7T9/sOWrOvku3a83TcqKp+gmz3hSjkGEL/6gT3UKoDIzg6hQ4IXpJdp72DC6zOThRZlztPzdbc9 X-Received: from anyblade.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1791]) (user=mmaurer job=sendgmr) by 2002:a05:6902:1c3:b0:e28:ee84:e4d8 with SMTP id 3f1490d57ef6-e29783006b4mr1193276.3.1729034380759; Tue, 15 Oct 2024 16:19:40 -0700 (PDT) Date: Tue, 15 Oct 2024 23:18:56 +0000 In-Reply-To: <20241015231925.3854230-1-mmaurer@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241015231925.3854230-1-mmaurer@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <20241015231925.3854230-2-mmaurer@google.com> Subject: [PATCH v6 1/5] export_report: Rehabilitate script From: Matthew Maurer To: masahiroy@kernel.org, ndesaulniers@google.com, ojeda@kernel.org, gary@garyguo.net, mcgrof@kernel.org, Alex Gaynor Cc: rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, neal@gompa.dev, marcan@marcan.st, j@jannau.net, asahi@lists.linux.dev, linux-modules@vger.kernel.org, samitolvanen@google.com, Matthew Maurer , Boqun Feng , "=?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?=" , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The `export_report.pl` script was broken [1] a while back due to a code cleanup causing the regex to no longer match. Additionally, it assumes a `modules.order` file containing `.ko` in a build directory with `.mod.c` files. I cannot find when this would have been the case in the history, as normally `.ko` files only appear in `modules.order` in installed modules directories, and those do not contain `.mod.c` files. This patch makes it able to report symbol usage counts for a build tree with modules and MODVERSIONS. Since the rest of this series will change the format of `.mod.c`, this change fixes the script to work correctly against a current build tree. Given that the regex no longer matches the format used in `.mod.c`, it cannot have worked since 2019, so updating this script is purely out of an abundance of caution. I am unsure who uses this script or for what purpose. * modules.order in a build directory uses .o, not .ko files. Allow .o files when parsing modules.order. * The .mod.c format changed [1] how it expressed the section attribute, leading to a regex mismatch. Update it to match modpost.c [1]: https://lore.kernel.org/all/20190909113423.2289-2-yamada.masahiro@soci= onext.com/ Signed-off-by: Matthew Maurer --- scripts/export_report.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/export_report.pl b/scripts/export_report.pl index feb3d5542a62..30b5f7819086 100755 --- a/scripts/export_report.pl +++ b/scripts/export_report.pl @@ -55,6 +55,7 @@ sub collectcfiles { open my $fh, '< modules.order' or die "cannot open modules.order: $!\n= "; while (<$fh>) { s/\.ko$/.mod.c/; + s/\.o$/.mod.c/; push (@file, $_) } close($fh); @@ -120,7 +121,7 @@ foreach my $thismod (@allcfiles) { next; } if ($state =3D=3D 1) { - $state =3D 2 if ($_ =3D~ /__attribute__\(\(section\("__versions"\)\)\)/= ); + $state =3D 2 if ($_ =3D~ /__used __section\("__versions"\)/); next; } if ($state =3D=3D 2) { --=20 2.47.0.rc1.288.g06298d1525-goog From nobody Tue Nov 26 19:43:36 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A42261FC7D1 for ; Tue, 15 Oct 2024 23:19:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729034391; cv=none; b=EOd9uqH+Z+XO98HyAz7u90h2m9Jr4q1SeRsvnkX5eiIL3u2DtzAQIbeC9QFOKxNQtUiJXe9HkHDt5YKe9Gq9TBONw25gNo8QHaGTWJmZlWjsd/BlId7k7bHxcRMX8FPr6DnB8PXm71KEzxf7uh0EIdoXWzdho+hMEvPmrd56/4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729034391; c=relaxed/simple; bh=EqoiMCMwtXRzYrztphzbbyPQC7yghBAcoUcUTqsjzc0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=u6KmAisvBGkmsjUOTcHHtNV90Md+eULoeS5cIHFjYjQVyVUAiVP01R/QICrcLAy8eG0SWNG7BDin5M/zZMD/JUN84lNcRrQipfMyceNWZcCHYwNP4sbDLTgIiL9r/av77VcXWLYGUQgIcs0j4v3ZafoJrEuXp8lyZU9NDU0l19c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zngqYdbL; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zngqYdbL" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e321d26b38so104505527b3.2 for ; Tue, 15 Oct 2024 16:19:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729034389; x=1729639189; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FMSQ/Tp5KquWB/NFr+gBjq3itwue5CA00E66TGsfFAE=; b=zngqYdbLfl0d/a7MD30SgV0RuqONkrAxH2x7WguyJGcVGHh98qOW8Ce/WKbtmuk8Xy 3RW0CobFe0NDu8oS/aqQ3tqRLL/t8yGx/nNwwt1VlIwy6EBOz7CxKRbD5OuR7bdYpvgO 26gB/zkKlvU4Cv+rQtosZVWqMauQ+J8TIRvzbr2ZxQm3ip+5R+yWzOjZirDFjY+gqlaM UQTW8SOSR3SujwSr/5ypfDs3CNf3J9mRK9PyOtKnmsc+G2FG9UPLXYF+UcUnwjHXhbc2 rkMilJyKrpFGe/zY5KVql1KQdJ6jFhQTQxgoEUPwlaCHozwkTDh5nc1CxQ6GI+9wi4PU y4Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729034389; x=1729639189; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FMSQ/Tp5KquWB/NFr+gBjq3itwue5CA00E66TGsfFAE=; b=UkgGOlKStaCpVGDe3SJhI4Tlr/7LxtPoHPQ8y6om0rkjdvwAv/Uislh5zYPBo7QIgL JguZ7/xqndVk+QKZPnPuEgfgVifG80bUlIrSJcMDY+ZG4n8EO95eUiFzEfG7x5WFaGC2 wyrZ0ooXwI79ebONc94rQ0qo5sIb/CLqWlPHZFHm8/WIyxbOhdOHSL0UUXeP4mtH6DO0 XYOPvXZBYoJ0BhbU0HoL3X9uO98DuCwLh0OKj9/mGpl4G3WykSNpINT7ugzegKLjsB/r y6vFFJO5vCxEwyGHDNba/WZyXLJkDnrAoeqHxiRwcvO5MHxoUy/xbL7vajYW+OB0zjZj LizA== X-Forwarded-Encrypted: i=1; AJvYcCXQrrZSxAbMaes6twANgUVDTNEYdjEtIzxjTAGBBd9tfDqirDpCpzm/PvyZk+06UQQJqNfHuF09T8a3x0Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yzmlw/zO6/umpShXsNS07AH+Jz+7ROTKWpN/KTP+pjsdvAutPUM GTE+Eah7NVil06GWJEpsjCiMeEFKmwkrHQrz2i6FIwv+TYIYvH7rKgKtUlSrmlfz16qyMJi/3HA c/2R+dg== X-Google-Smtp-Source: AGHT+IGX0icJ1CWivcvNRrA/zojDVZFklRmkCxNQxnPYkIU1lCS12nRY8wVMRxtxvqJKRQSf0gcnC2/QNxRA X-Received: from anyblade.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1791]) (user=mmaurer job=sendgmr) by 2002:a0d:c405:0:b0:6b2:3ecc:817 with SMTP id 00721157ae682-6e3d41eb817mr246597b3.8.1729034388608; Tue, 15 Oct 2024 16:19:48 -0700 (PDT) Date: Tue, 15 Oct 2024 23:18:57 +0000 In-Reply-To: <20241015231925.3854230-1-mmaurer@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241015231925.3854230-1-mmaurer@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <20241015231925.3854230-3-mmaurer@google.com> Subject: [PATCH v6 2/5] modules: Support extended MODVERSIONS info From: Matthew Maurer To: masahiroy@kernel.org, ndesaulniers@google.com, ojeda@kernel.org, gary@garyguo.net, mcgrof@kernel.org, Michael Ellerman , Alex Gaynor , Naveen N Rao , Arnd Bergmann , "Mike Rapoport (Microsoft)" , Benjamin Gray Cc: rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, neal@gompa.dev, marcan@marcan.st, j@jannau.net, asahi@lists.linux.dev, linux-modules@vger.kernel.org, samitolvanen@google.com, Matthew Maurer , Nicholas Piggin , Christophe Leroy , Madhavan Srinivasan , Petr Pavlu , Daniel Gomez , Boqun Feng , "=?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?=" , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Andrew Morton , linuxppc-dev@lists.ozlabs.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Adds a new format for MODVERSIONS which stores each field in a separate ELF section. This initially adds support for variable length names, but could later be used to add additional fields to MODVERSIONS in a backwards compatible way if needed. Any new fields will be ignored by old user tooling, unlike the current format where user tooling cannot tolerate adjustments to the format (for example making the name field longer). Since PPC munges its version records to strip leading dots, we reproduce the munging for the new format. Other architectures do not appear to have architecture-specific usage of this information. Signed-off-by: Matthew Maurer --- arch/powerpc/kernel/module_64.c | 23 ++++++++- kernel/module/internal.h | 11 ++++ kernel/module/main.c | 92 ++++++++++++++++++++++++++++++--- kernel/module/version.c | 45 ++++++++++++++++ 4 files changed, 161 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_6= 4.c index 135960918d14..0f7ef7e7e9d6 100644 --- a/arch/powerpc/kernel/module_64.c +++ b/arch/powerpc/kernel/module_64.c @@ -355,6 +355,23 @@ static void dedotify_versions(struct modversion_info *= vers, } } =20 +static void dedotify_ext_version_names(char *str_seq, unsigned long size) +{ + unsigned long out =3D 0; + unsigned long in; + char last =3D '\0'; + + for (in =3D 0; in < size; in++) { + /* Skip one leading dot */ + if (last =3D=3D '\0' && str_seq[in] =3D=3D '.') + in++; + last =3D str_seq[in]; + str_seq[out++] =3D last; + } + /* Zero the trailing portion of the names table for robustness */ + memset(&str_seq[out], 0, size - out); +} + /* * Undefined symbols which refer to .funcname, hack to funcname. Make .TOC. * seem to be defined (value set later). @@ -424,10 +441,12 @@ int module_frob_arch_sections(Elf64_Ehdr *hdr, me->arch.toc_section =3D i; if (sechdrs[i].sh_addralign < 8) sechdrs[i].sh_addralign =3D 8; - } - else if (strcmp(secstrings+sechdrs[i].sh_name,"__versions")=3D=3D0) + } else if (strcmp(secstrings + sechdrs[i].sh_name, "__versions") =3D=3D = 0) dedotify_versions((void *)hdr + sechdrs[i].sh_offset, sechdrs[i].sh_size); + else if (strcmp(secstrings + sechdrs[i].sh_name, "__version_ext_names") = =3D=3D 0) + dedotify_ext_version_names((void *)hdr + sechdrs[i].sh_offset, + sechdrs[i].sh_size); =20 if (sechdrs[i].sh_type =3D=3D SHT_SYMTAB) dedotify((void *)hdr + sechdrs[i].sh_offset, diff --git a/kernel/module/internal.h b/kernel/module/internal.h index daef2be83902..59959c21b205 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -86,6 +86,8 @@ struct load_info { unsigned int vers; unsigned int info; unsigned int pcpu; + unsigned int vers_ext_crc; + unsigned int vers_ext_name; } index; }; =20 @@ -389,6 +391,15 @@ void module_layout(struct module *mod, struct modversi= on_info *ver, struct kerne struct kernel_symbol *ks, struct tracepoint * const *tp); int check_modstruct_version(const struct load_info *info, struct module *m= od); int same_magic(const char *amagic, const char *bmagic, bool has_crcs); +struct modversion_info_ext { + size_t remaining; + const s32 *crc; + const char *name; +}; +void modversion_ext_start(const struct load_info *info, struct modversion_= info_ext *ver); +void modversion_ext_advance(struct modversion_info_ext *ver); +#define for_each_modversion_info_ext(ver, info) \ + for (modversion_ext_start(info, &ver); ver.remaining > 0; modversion_ext_= advance(&ver)) #else /* !CONFIG_MODVERSIONS */ static inline int check_version(const struct load_info *info, const char *symname, diff --git a/kernel/module/main.c b/kernel/module/main.c index 3db9ff544c09..f5f4ceaef31a 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2072,6 +2072,82 @@ static int elf_validity_cache_index_str(struct load_= info *info) return 0; } =20 +/** + * elf_validity_cache_index_versions() - Validate and cache version indices + * @info: Load info to cache version indices in. + * Must have &load_info->sechdrs and &load_info->secstrings popula= ted. + * @flags: Load flags, relevant to suppress version loading, see + * uapi/linux/module.h + * + * If we're ignoring modversions based on @flags, zero all version indices + * and return validity. Othewrise check: + * + * * If "__version_ext_crcs" is present, "__version_ext_names" is present + * * There is a name present for every crc + * + * Then populate: + * + * * &load_info->index.vers + * * &load_info->index.vers_ext_crc + * * &load_info->index.vers_ext_names + * + * if present. + * + * Return: %0 if valid, %-ENOEXEC on failure. + */ +static int elf_validity_cache_index_versions(struct load_info *info, int f= lags) +{ + unsigned int vers_ext_crc; + unsigned int vers_ext_name; + size_t crc_count; + size_t remaining_len; + size_t name_size; + char *name; + + /* If modversions were suppressed, pretend we didn't find any */ + if (flags & MODULE_INIT_IGNORE_MODVERSIONS) { + info->index.vers =3D 0; + info->index.vers_ext_crc =3D 0; + info->index.vers_ext_name =3D 0; + return 0; + } + + vers_ext_crc =3D find_sec(info, "__version_ext_crcs"); + vers_ext_name =3D find_sec(info, "__version_ext_names"); + + /* If we have one field, we must have the other */ + if (!!vers_ext_crc !=3D !!vers_ext_name) { + pr_err("extended version crc+name presence does not match"); + return -ENOEXEC; + } + + /* + * If we have extended version information, we should have the same + * number of entries in every section. + */ + if (vers_ext_crc) { + crc_count =3D info->sechdrs[vers_ext_crc].sh_size / sizeof(s32); + name =3D (void *)info->hdr + + info->sechdrs[vers_ext_name].sh_offset; + remaining_len =3D info->sechdrs[vers_ext_name].sh_size; + + while (crc_count--) { + name_size =3D strnlen(name, remaining_len) + 1; + if (name_size > remaining_len) { + pr_err("more extended version crcs than names"); + return -ENOEXEC; + } + remaining_len -=3D name_size; + name +=3D name_size; + } + } + + info->index.vers =3D find_sec(info, "__versions"); + info->index.vers_ext_crc =3D vers_ext_crc; + info->index.vers_ext_name =3D vers_ext_name; + return 0; +} + /** * elf_validity_cache_index() - Resolve, validate, cache section indices * @info: Load info to read from and update. @@ -2086,9 +2162,7 @@ static int elf_validity_cache_index_str(struct load_i= nfo *info) * * elf_validity_cache_index_mod() * * elf_validity_cache_index_sym() * * elf_validity_cache_index_str() - * - * If versioning is not suppressed via flags, load the version index from - * a section called "__versions" with no validation. + * * elf_validity_cache_index_versions() * * If CONFIG_SMP is enabled, load the percpu section by name with no * validation. @@ -2111,11 +2185,9 @@ static int elf_validity_cache_index(struct load_info= *info, int flags) err =3D elf_validity_cache_index_str(info); if (err < 0) return err; - - if (flags & MODULE_INIT_IGNORE_MODVERSIONS) - info->index.vers =3D 0; /* Pretend no __versions section! */ - else - info->index.vers =3D find_sec(info, "__versions"); + err =3D elf_validity_cache_index_versions(info, flags); + if (err < 0) + return err; =20 info->index.pcpu =3D find_pcpusec(info); =20 @@ -2326,6 +2398,10 @@ static int rewrite_section_headers(struct load_info = *info, int flags) =20 /* Track but don't keep modinfo and version sections. */ info->sechdrs[info->index.vers].sh_flags &=3D ~(unsigned long)SHF_ALLOC; + info->sechdrs[info->index.vers_ext_crc].sh_flags &=3D + ~(unsigned long)SHF_ALLOC; + info->sechdrs[info->index.vers_ext_name].sh_flags &=3D + ~(unsigned long)SHF_ALLOC; info->sechdrs[info->index.info].sh_flags &=3D ~(unsigned long)SHF_ALLOC; =20 return 0; diff --git a/kernel/module/version.c b/kernel/module/version.c index 53f43ac5a73e..c246d4087970 100644 --- a/kernel/module/version.c +++ b/kernel/module/version.c @@ -19,11 +19,28 @@ int check_version(const struct load_info *info, unsigned int versindex =3D info->index.vers; unsigned int i, num_versions; struct modversion_info *versions; + struct modversion_info_ext version_ext; =20 /* Exporting module didn't supply crcs? OK, we're already tainted. */ if (!crc) return 1; =20 + /* If we have extended version info, rely on it */ + if (info->index.vers_ext_crc) { + for_each_modversion_info_ext(version_ext, info) { + if (strcmp(version_ext.name, symname) !=3D 0) + continue; + if (*version_ext.crc =3D=3D *crc) + return 1; + pr_debug("Found checksum %X vs module %X\n", + *crc, *version_ext.crc); + goto bad_version; + } + pr_warn_once("%s: no extended symbol version for %s\n", + info->name, symname); + return 1; + } + /* No versions at all? modprobe --force does this. */ if (versindex =3D=3D 0) return try_to_force_load(mod, symname) =3D=3D 0; @@ -87,6 +104,34 @@ int same_magic(const char *amagic, const char *bmagic, return strcmp(amagic, bmagic) =3D=3D 0; } =20 +void modversion_ext_start(const struct load_info *info, + struct modversion_info_ext *start) +{ + unsigned int crc_idx =3D info->index.vers_ext_crc; + unsigned int name_idx =3D info->index.vers_ext_name; + Elf_Shdr *sechdrs =3D info->sechdrs; + + /* + * Both of these fields are needed for this to be useful + * Any future fields should be initialized to NULL if absent. + */ + if (crc_idx =3D=3D 0 || name_idx =3D=3D 0) { + start->remaining =3D 0; + return; + } + + start->crc =3D (const s32 *)sechdrs[crc_idx].sh_addr; + start->name =3D (const char *)sechdrs[name_idx].sh_addr; + start->remaining =3D sechdrs[crc_idx].sh_size / sizeof(*start->crc); +} + +void modversion_ext_advance(struct modversion_info_ext *vers) +{ + vers->remaining--; + vers->crc++; + vers->name +=3D strlen(vers->name) + 1; +} + /* * Generate the signature for all relevant module structures here. * If these change, we don't want to try to parse the module. --=20 2.47.0.rc1.288.g06298d1525-goog From nobody Tue Nov 26 19:43:36 2024 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61F8F1FDF8A for ; Tue, 15 Oct 2024 23:19:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729034399; cv=none; b=L54yKAJArt0Uo3Q6njGfxiftVLCOaK9NtgsouX+mZIrKgXKf9IEtwKB7pNsR/3cfoLCxjfuz+UiBHOmdW/L3JKdv8jNORPVJ8ucyMe5/9o7nVp32rrjd+g0OuzDVbWygr5fnbRkl18ydQSciwBgLDyoSgLqDVKxzrN5bkcS3Zno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729034399; c=relaxed/simple; bh=b/Bd5hNVwONQMAMAKZObOat4jqHFnL5FtBWQng4HuQc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rNwq9Yi2jP5BQ/T6GIrTiSmehHCUpjhpz9pfniE7BKH5cmn+nGLzSKCmtCdRLwRJAVj1WAXcohb1192vZzb/6UlmL1hUZvFJDCDS5RLyB7nxlKpU9UNC7q+TH4Ph0dHfhlWwjdqSFlAA7e9I420ZW1AtbGdow5lPuWK1/tFqoAQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=N1dO/cYJ; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="N1dO/cYJ" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e291ac8dcf3so6663468276.3 for ; Tue, 15 Oct 2024 16:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729034396; x=1729639196; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=GMeFuBGaCaHx7HaM28eyKlSyRMkG/ZUOc3U36euZD88=; b=N1dO/cYJgyXeHSEkWZ8PHaXrwa/kRuKQYlwroncJFvpb+qGuZlcqMJw7yzLeY03SXD Tf3MIpwjEaL7rtuiH2HoEPdISP63RqtNsmBauP0fjZ2ytZWbuvDpD+XpeuwdZb7Vel4m rwDhDnugNGydsQ1jb9+y0lEiDpgyAVIil/SrHktcGNRXQXh9H2ygeeMx7bECNdUZQcIj Z7/PWE5YWKimlu0XXydjHhLEDV8BRzdbczjknmDR/oFRbo29BvVQpWyMRCP1FD/p+JoX 38hchTAzzXjhve1pzxwljmTVZxAabLdBO5rZo8/VNAbjcLY+ffYEL/sMO1vvBnP7+C1y Krjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729034396; x=1729639196; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GMeFuBGaCaHx7HaM28eyKlSyRMkG/ZUOc3U36euZD88=; b=jCDTqGFh41fOGSkQhxQAUzejGBSGb/Sdwuww8wpYX1Pqxmv+FacjKZmH7JTz4KS9Bw CwBfjj23DfPrrCbls6HE/7VLOinsZLiCUibwDbOUbZD/pr9nYONpZ7unFj0l8tyO7y9O 0nJ+b0MPzV9F2cHH3MYbdO9OLAzvS7DcndAO9Ceh5358WOAujulQribIaKLwyfgw75y5 m27QCCpaUoLHS5ggOi9IP/ILGB4GKQVmjl4jp7sfQxy/V72QK7bSLGGUC72U304AAsHP amUv6Wg6eO2q9u8R6yi90zAyy76qI0ATdEAaSSm+OEyX213kVdAPpyfhPAJVKjySBjma X+gQ== X-Forwarded-Encrypted: i=1; AJvYcCVVXC6A/8LWlSMo8wKFjI3y0vb23oXrD52g8d6yPlHI94+drxGRJJbeC+mL4RE8lKXKkJzpoyLI+T2Ik18=@vger.kernel.org X-Gm-Message-State: AOJu0YzKprO2gVud55568eXruSMzemfux6HheYEVkuVFUaV8dc5XA1Zu wX8ArBgVkKkMLvZJPlHjbx9EO9oVWRgbd3+iT4MEgwPUdvvc9z7uUGGmisCelzOZeR8WV8qMKta CsaR6GA== X-Google-Smtp-Source: AGHT+IHJ/PD4IZdXpfLT+phmwcv6QqIW8I80B2uJZiw7eFoWOINWL5PmPprPbPx3sBWJLPoXxBjkxCvK2VhZ X-Received: from anyblade.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1791]) (user=mmaurer job=sendgmr) by 2002:a5b:341:0:b0:e29:68a9:8612 with SMTP id 3f1490d57ef6-e29782f4017mr1762276.4.1729034396326; Tue, 15 Oct 2024 16:19:56 -0700 (PDT) Date: Tue, 15 Oct 2024 23:18:58 +0000 In-Reply-To: <20241015231925.3854230-1-mmaurer@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241015231925.3854230-1-mmaurer@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <20241015231925.3854230-4-mmaurer@google.com> Subject: [PATCH v6 3/5] export_report: Tolerate additional `.mod.c` content From: Matthew Maurer To: masahiroy@kernel.org, ndesaulniers@google.com, ojeda@kernel.org, gary@garyguo.net, mcgrof@kernel.org, Alex Gaynor Cc: rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, neal@gompa.dev, marcan@marcan.st, j@jannau.net, asahi@lists.linux.dev, linux-modules@vger.kernel.org, samitolvanen@google.com, Matthew Maurer , Boqun Feng , "=?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?=" , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, `export_report.pl` will error out if it sees a hex number not in the context of the original `__versions` array. This adds a "finished" state so that it does not attempt to parse content past the end of the array, and requires the array to be terminated. This is prepwork for the subsequent extended modversions information, which would not be parseable otherwise. Signed-off-by: Matthew Maurer --- scripts/export_report.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/export_report.pl b/scripts/export_report.pl index 30b5f7819086..dcef915405f3 100755 --- a/scripts/export_report.pl +++ b/scripts/export_report.pl @@ -125,6 +125,10 @@ foreach my $thismod (@allcfiles) { next; } if ($state =3D=3D 2) { + if ( $_ =3D~ /};/ ) { + $state =3D 3; + next; + } if ( $_ !~ /0x[0-9a-f]+,/ ) { next; } @@ -134,7 +138,7 @@ foreach my $thismod (@allcfiles) { push(@{$MODULE{$thismod}} , $sym); } } - if ($state !=3D 2) { + if ($state !=3D 3) { warn "WARNING:$thismod is not built with CONFIG_MODVERSIONS enabled\n"; $modversion_warnings++; } --=20 2.47.0.rc1.288.g06298d1525-goog From nobody Tue Nov 26 19:43:36 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DB351FDFA9 for ; Tue, 15 Oct 2024 23:19:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729034401; cv=none; b=By/E4m8JuMenks+s/1G0TfK/yVk3hn5HkX0gr07ivL0KtZxNUeiQFPqgu1HH6t42zs/pqZ6jY7Cu+jVkgO5hs0CJ41wpqMLlkL+iIFP/As6SxouJUKVRu5MSxqkUT05Kjx67Bqlc/Cfzvvq8+686HoFoFldnvreDZweRulp2dSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729034401; c=relaxed/simple; bh=Kp5uggGbEJrPIVkqdlvJVT6U0SCrN+hpDOmeYYUT59w=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UiaOxMxDF8PzSWKLp4tzpX13bBia6/RV9w8eyYrep+Lftrq3Nq2y4a8vm3x/zt2IK5jabiOqdPxUlYmLhVf5qSdsC+0tkhgvkCY58j8EfozX9L0e56q4dbLN2usDo+QM7f6bLdiucklW0ItegDAWfdvJWGSFLsbo1mZVKb2w8jQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=aetkJSJz; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aetkJSJz" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e3497c8eb0so6722127b3.0 for ; Tue, 15 Oct 2024 16:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729034398; x=1729639198; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xasC2bG4ku4iDrf29H3XucNRhtvas+BiYTJxtPjY34w=; b=aetkJSJzE6emuP+So9ibvLCPDzwF7Fq2cOR6yXqUAPhw9UmIaD9cFKb2Td3jJ00JHu iTTq3whxjkEowJoKiGf0VhDK6J8/tY1AtZB7vqbbF6fOw3UHCQ3Zc7ahH5tEPcasVwFR QzNFPwqDMq4abvOt7bva51XwTvQfvAMfhvmNK5p/iB832yLG/AJ23y5t/Xcjb1zdhBLX iiFHVmLPbnuVL8xKLvdZcrCZNIafp7IepylQjM8PryRz7f+rL79HJwEkXnBV6TK1DDhx OdDEjXAhIc/v54B/wvx6AG1ZWIdPrWJgYPThlSuIzS5XPIvNgnpurUcoTZuAMQ5IyBeG 5xJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729034398; x=1729639198; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xasC2bG4ku4iDrf29H3XucNRhtvas+BiYTJxtPjY34w=; b=ciHcpYhyurwAnJeY2KUDvWcuURWIq+OlbW5LNcsjwzLPcvEFaSZJD3qQlNk1IAPBEf HZBwt5r7U1614EE2AfNQb4HHDY5wZqyr3Ue3p9wnDZtut7tSip6KbbBGZ7nZKJ9LzOYy HUiEphoU0KntROyIT0hSZ0bgsRvpI1I2b+n/641czTwshuR62zzemd3Qq85BkKYnP++W xTCxUDOWfqko6qg+MYnjAmZWRMrv4tiinLtDS1OBx06If/ZkfOYKoTPIhEIH4eFEGlrD 9g6fwkp26ZLzH6q/CJrbhsn56iL6g5QqBe1gxf+4DG3jMGH9UQCAr5KVkNsFODGtA+/s LH9Q== X-Forwarded-Encrypted: i=1; AJvYcCU3j8STbwTsDzEI+ilqD+3KHZFQV1ngA2NNcQDmh1q5n8yc2Ne3IQWYrF5x1jm1WaEJjHyCu9TEScL5osc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4oeY03xkJmIc9MqLpHjXrjIgxTRDeSpGvKFHPJVPh4UOcjDNM 9Ztju3BKsLkxtVQNlo24Se191zKNj49MReO0Be1WHznVoCjUiT+FQL+r8mXoz4DDIBICDJO6Fky jw9J4GA== X-Google-Smtp-Source: AGHT+IEhM7UuM8n6j7x3Tn2NtgtBsdUObL6hxcYJG9U32wvNR7YuZK72mjGGNuHH/96W7Ib7Lctj8rOyPY/w X-Received: from anyblade.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1791]) (user=mmaurer job=sendgmr) by 2002:a05:690c:3587:b0:68e:8de6:617c with SMTP id 00721157ae682-6e3d3aacfc0mr316117b3.5.1729034398638; Tue, 15 Oct 2024 16:19:58 -0700 (PDT) Date: Tue, 15 Oct 2024 23:18:59 +0000 In-Reply-To: <20241015231925.3854230-1-mmaurer@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241015231925.3854230-1-mmaurer@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <20241015231925.3854230-5-mmaurer@google.com> Subject: [PATCH v6 4/5] modpost: Produce extended MODVERSIONS information From: Matthew Maurer To: masahiroy@kernel.org, ndesaulniers@google.com, ojeda@kernel.org, gary@garyguo.net, mcgrof@kernel.org, Alex Gaynor Cc: rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, neal@gompa.dev, marcan@marcan.st, j@jannau.net, asahi@lists.linux.dev, linux-modules@vger.kernel.org, samitolvanen@google.com, Matthew Maurer , Petr Pavlu , Daniel Gomez , Nathan Chancellor , Nicolas Schier , Boqun Feng , "=?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?=" , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Generate both the existing modversions format and the new extended one when running modpost. Presence of this metadata in the final .ko is guarded by CONFIG_EXTENDED_MODVERSIONS. We no longer generate an error on long symbols in modpost if CONFIG_EXTENDED_MODVERSIONS is set, as they can now be appropriately encoded in the extended section. These symbols will be skipped in the previous encoding. An error will still be generated if CONFIG_EXTENDED_MODVERSIONS is not set. Signed-off-by: Matthew Maurer --- kernel/module/Kconfig | 8 ++++++++ scripts/mod/modpost.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig index 7c6588148d42..a5de2b7f2758 100644 --- a/kernel/module/Kconfig +++ b/kernel/module/Kconfig @@ -177,6 +177,14 @@ config ASM_MODVERSIONS assembly. This can be enabled only when the target architecture supports it. =20 +config EXTENDED_MODVERSIONS + bool "Extended Module Versioning Support" + depends on MODVERSIONS + help + This enables extended MODVERSIONs support, allowing long symbol + names to be versioned. The most likely reasons you would enable + this are for Rust usage or aggressive LTO configurations. + config MODULE_SRCVERSION_ALL bool "Source checksum for all modules" help diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 107393a8c48a..d18ff8a1109a 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1840,15 +1840,56 @@ static void add_versions(struct buffer *b, struct m= odule *mod) continue; } if (strlen(s->name) >=3D MODULE_NAME_LEN) { +#ifdef CONFIG_EXTENDED_MODVERSIONS + /* this symbol will only be in the extended info */ + continue; +#else error("too long symbol \"%s\" [%s.ko]\n", s->name, mod->name); break; +#endif } buf_printf(b, "\t{ %#8x, \"%s\" },\n", s->crc, s->name); } =20 buf_printf(b, "};\n"); + + buf_printf(b, "#ifdef CONFIG_EXTENDED_MODVERSIONS\n"); + buf_printf(b, "static const s32 ____version_ext_crcs[]\n"); + buf_printf(b, "__used __section(\"__version_ext_crcs\") =3D {\n"); + list_for_each_entry(s, &mod->unresolved_symbols, list) { + if (!s->module) + continue; + if (!s->crc_valid) { + /* + * We already warned on this when producing the legacy + * modversions table. + */ + continue; + } + buf_printf(b, "\t%#8x,\n", s->crc); + } + buf_printf(b, "};\n"); + + buf_printf(b, "static const char ____version_ext_names[]\n"); + buf_printf(b, "__used __section(\"__version_ext_names\") =3D\n"); + list_for_each_entry(s, &mod->unresolved_symbols, list) { + if (!s->module) + continue; + if (!s->crc_valid) { + /* + * We already warned on this when producing the legacy + * modversions table. + * We need to skip its name too, as the indexes in + * both tables need to align. + */ + continue; + } + buf_printf(b, "\t\"%s\\0\"\n", s->name); + } + buf_printf(b, ";\n"); + buf_printf(b, "#endif\n"); } =20 static void add_depends(struct buffer *b, struct module *mod) --=20 2.47.0.rc1.288.g06298d1525-goog From nobody Tue Nov 26 19:43:36 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E612F1FE117 for ; Tue, 15 Oct 2024 23:20:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729034408; cv=none; b=m9r9Q/0D726+jBNoH802sHBEBwcoiwIgepJ9zoM8DT9dhIRfyZqHRuLBGiy/17rPAofFNl6WAO8bDNLXV6TevwldvAzNK2XuSUQMPVpccftIkTV0kvdG/JEw9Vzpvc8NGpm1XtYbfvZ0OaczMQwm65RlTYusibH3IqgWT/l9Ybg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729034408; c=relaxed/simple; bh=THSkSo9lSkuxsbYiUqaXJmBiMFSg1TaDfQHynW6LWoM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=aJkPntjS1FH2jL+PacufWar8sjDdUvGqb+Qycb0Vu6bthzbP/ykDy4A7ow/TInbv05WK9rtJDOUlGzzUiQh1B0cc6tCz726bLxM899J9pEvWFGyF+2CRJeG4FPZtmDl0NlXIKU+8kMct/QJ0QZ3qWdbaDiuQIfATu2aAlZOqlLA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=DJkd1Qjd; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DJkd1Qjd" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e3231725c9so89764797b3.1 for ; Tue, 15 Oct 2024 16:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729034406; x=1729639206; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=y90q7N+0JYvarHeSSS/HcK3d00J7zzbtwQB+DjacdQs=; b=DJkd1Qjd6nfYoALd0SmcygiPVkhCub3F6KQlzJFaGd172PG+zHvYXrDFqdcoFw0l0z tWxJYs8O1wnSlt1nmB4VxN8+fUgqqTfBhiR1l2yEoKMPJWI3W59zpmOEvX9mbskJt5ZT nrBnDIBtqftzCfy78ruvNKuL1ztQTwLC7QLbOMYdZJn13C9pt/W4Vz+YSlZhAJocTjU2 I7+ez/lBvnXV0i12tYHwHherRtEsaIgNIovI3jTloJGbO+ZKEPhTn4o1sBQRHEYouOfd 1rKPDILVBOJjh8HMLJ9xvCghVD5Iw+lGW8VdhR92biWljp6a1fLZNBHKBTb1EBl1NPrF OwyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729034406; x=1729639206; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=y90q7N+0JYvarHeSSS/HcK3d00J7zzbtwQB+DjacdQs=; b=Q+7Ls56AH/ljKfu/bl4eYSS/gRbOF2WwMLIjwPx59VDno8H2p1pWD3GmLz0eb7Feg2 UmJYCAjmmTAlEiGMTtEQhbJGV8x0qKf9WFRY1XENGvT7xGl+tB3g9+vnyM/x9pwpUzW1 spwmW45Vwllu6YPfvaOaYTUJo+H2jlYUun1zI/rym8IkQ0p1OEGlEh8k9wCrZLTglpFh NaFJU8UqL3LdjSRdwCCGNNr7Ln4CXHYl4bQAygk9pc1RupUcEzb0HrAIEh8xMU8E2rBo oUW4YzynC2FHJknfRsx2jDzJVP//mDNmaJhCp33R/5khDfj2MtzmFd3fzlLzFbb1/eve YkOA== X-Forwarded-Encrypted: i=1; AJvYcCWMducQuiqM/VlfIK6SUGnVAnCMwWtTX6t54nZUJvbVOOluh3e7nMhdjHwP8n3gMdLs5I3IDUr0M2azETk=@vger.kernel.org X-Gm-Message-State: AOJu0YySyl7NuDi+/DNpAj1sj9V3ZLQEVT/vXPgyqTCzkOngMVWoaIOX Ou30V/T9XbRrMMHPG63lkm24gecXUlCQbbRu6MtbhmV7vA1bHOCnJnxR8PEI39tbOhiWCNFOJeV ychnhtA== X-Google-Smtp-Source: AGHT+IEl0PoSNMsAIV4NYkV6h7fXXICopbsvroAdggBgvaXcptZB1VvmgZiKvr9u8QtCOHgbZG9OiwkRYgC+ X-Received: from anyblade.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1791]) (user=mmaurer job=sendgmr) by 2002:a05:690c:9b02:b0:6e2:371f:4afe with SMTP id 00721157ae682-6e3d4194914mr597357b3.4.1729034405979; Tue, 15 Oct 2024 16:20:05 -0700 (PDT) Date: Tue, 15 Oct 2024 23:19:00 +0000 In-Reply-To: <20241015231925.3854230-1-mmaurer@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241015231925.3854230-1-mmaurer@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <20241015231925.3854230-6-mmaurer@google.com> Subject: [PATCH v6 5/5] export_report: Use new version info format From: Matthew Maurer To: masahiroy@kernel.org, ndesaulniers@google.com, ojeda@kernel.org, gary@garyguo.net, mcgrof@kernel.org, Alex Gaynor Cc: rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, neal@gompa.dev, marcan@marcan.st, j@jannau.net, asahi@lists.linux.dev, linux-modules@vger.kernel.org, samitolvanen@google.com, Matthew Maurer , Boqun Feng , "=?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?=" , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The new version info format has a superset of symbols in the old format. Since this is a tool for in-tree modules, we don't need to parse the old one with this tool any longer. Even if we build without CONFIG_EXTENDED_MODVERSIONS, these are still in the `.mod.c` file. Their presence in the final module is controlled by conditional compilation inside the at file. Signed-off-by: Matthew Maurer --- scripts/export_report.pl | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/scripts/export_report.pl b/scripts/export_report.pl index dcef915405f3..6a37df6f947f 100755 --- a/scripts/export_report.pl +++ b/scripts/export_report.pl @@ -114,31 +114,29 @@ foreach my $thismod (@allcfiles) { } =20 my $state=3D0; + # State map: + # 0 - Looking for names + # 1 - Scanning names + # 2 - Done while ( <$module> ) { chomp; if ($state =3D=3D 0) { - $state =3D 1 if ($_ =3D~ /static const struct modversion_info/); + $state =3D 1 if ($_ =3D~ /__used __section\("__version_ext_names"\)/); next; } if ($state =3D=3D 1) { - $state =3D 2 if ($_ =3D~ /__used __section\("__versions"\)/); - next; - } - if ($state =3D=3D 2) { - if ( $_ =3D~ /};/ ) { - $state =3D 3; - next; - } - if ( $_ !~ /0x[0-9a-f]+,/ ) { + if ( $_ =3D~ /;/ ) { + $state =3D 2; next; } - my $sym =3D (split /([,"])/,)[4]; + $_ =3D~ /"(.*)\\0"/; + my $sym =3D $1; my ($module, $value, $symbol, $gpl) =3D @{$SYMBOL{$sym}}; $SYMBOL{ $sym } =3D [ $module, $value+1, $symbol, $gpl]; push(@{$MODULE{$thismod}} , $sym); } } - if ($state !=3D 3) { + if ($state !=3D 2) { warn "WARNING:$thismod is not built with CONFIG_MODVERSIONS enabled\n"; $modversion_warnings++; } --=20 2.47.0.rc1.288.g06298d1525-goog