lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 17 Aug 2022 23:45:59 +0900
From:   Masahiro Yamada <masahiroy@...nel.org>
To:     Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>
Cc:     matoro <matoro_mailinglist_kernel@...oro.tk>,
        Michal Marek <michal.lkml@...kovi.net>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Nicolas Schier <nicolas@...sle.eu>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] modpost: fix module versioning when a symbol lacks valid CRC

On Tue, Aug 9, 2022 at 11:13 PM Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> Since commit 7b4537199a4a ("kbuild: link symbol CRCs at final link,
> removing CONFIG_MODULE_REL_CRCS"), module versioning is broken on
> some architectures. Loading a module fails with "disagrees about
> version of symbol module_layout".
>
> On such architectures (e.g. ARCH=sparc build with sparc64_defconfig),
> modpost shows a warning, like follows:
>
>   WARNING: modpost: EXPORT symbol "_mcount" [vmlinux] version generation failed, symbol will not be versioned.
>   Is "_mcount" prototyped in <asm/asm-prototypes.h>?
>
> Previously, it was a harmless warning (CRC check was just skipped),
> but now wrong CRCs are used for comparison because invalid CRCs are
> just skipped.
>
>   $ sparc64-linux-gnu-nm -n vmlinux
>     [snip]
>   0000000000c2cea0 r __ksymtab__kstrtol
>   0000000000c2ceb8 r __ksymtab__kstrtoul
>   0000000000c2ced0 r __ksymtab__local_bh_enable
>   0000000000c2cee8 r __ksymtab__mcount
>   0000000000c2cf00 r __ksymtab__printk
>   0000000000c2cf18 r __ksymtab__raw_read_lock
>   0000000000c2cf30 r __ksymtab__raw_read_lock_bh
>     [snip]
>   0000000000c53b34 D __crc__kstrtol
>   0000000000c53b38 D __crc__kstrtoul
>   0000000000c53b3c D __crc__local_bh_enable
>   0000000000c53b40 D __crc__printk
>   0000000000c53b44 D __crc__raw_read_lock
>   0000000000c53b48 D __crc__raw_read_lock_bh
>
> Please notice __crc__mcount is missing here.
>
> When the module subsystem looks up a CRC that comes after, it results
> in reading out a wrong address. For example, when __crc__printk is
> needed, the module subsystem reads 0xc53b44 instead of 0xc53b40.
>
> All CRC entries must be output for correct index accessing. Invalid
> CRCs will be unused, but are needed to keep the one-to-one mapping
> between __ksymtab_* and __crc_*.
>
> The best is to fix all modpost warnings, but several warnings are still
> remaining on less popular architectures.
>
> Fixes: 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS")
> Reported-by: matoro <matoro_mailinglist_kernel@...oro.tk>
> Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
> Tested-by: matoro <matoro_mailinglist_kernel@...oro.tk>


Applied to linux-kbuild/fixes.





> ---
>
>  scripts/mod/modpost.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 8484c0798f28..22dc332eebfa 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -2018,13 +2018,11 @@ static void add_exported_symbols(struct buffer *buf, struct module *mod)
>         /* record CRCs for exported symbols */
>         buf_printf(buf, "\n");
>         list_for_each_entry(sym, &mod->exported_symbols, list) {
> -               if (!sym->crc_valid) {
> +               if (!sym->crc_valid)
>                         warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n"
>                              "Is \"%s\" prototyped in <asm/asm-prototypes.h>?\n",
>                              sym->name, mod->name, mod->is_vmlinux ? "" : ".ko",
>                              sym->name);
> -                       continue;
> -               }
>
>                 buf_printf(buf, "SYMBOL_CRC(%s, 0x%08x, \"%s\");\n",
>                            sym->name, sym->crc, sym->is_gpl_only ? "_gpl" : "");
> --
> 2.34.1
>


-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ