From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 739CEC433EF for ; Mon, 23 May 2022 18:44:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244021AbiEWSoi (ORCPT ); Mon, 23 May 2022 14:44:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243314AbiEWSoZ (ORCPT ); Mon, 23 May 2022 14:44:25 -0400 Received: from condef-08.nifty.com (condef-08.nifty.com [202.248.20.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE74F6A079; Mon, 23 May 2022 11:27:18 -0700 (PDT) Received: from conssluserg-04.nifty.com ([10.126.8.83])by condef-08.nifty.com with ESMTP id 24NI6ipB016156; Tue, 24 May 2022 03:06:44 +0900 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (authenticated) by conssluserg-04.nifty.com with ESMTP id 24NI5KXv002937; Tue, 24 May 2022 03:05:20 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com 24NI5KXv002937 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1653329121; bh=xyfMz2s6K1FqS7FKBYD4t23CA7hAJBCjnd+TynP5fZY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=wLWMHJLOejJIXhpVDGf9HNSx+SpTPVQUXvZhixAqDXV0z7z7XYTc7NHsjSVsRdrzO 5gFFxjxAUV70SlzCQBQA5zl5Eo9n3JLjoa+Z6Z6R/1GbKTffwLWtZu+guZMreSmFOo 7q4VUHA2w4OzRP2FjYyb0e0KAjEyh94eDs+96SgIZ2UVW9GimqGFg1VqKzrk/kK8OQ AcR2aj6xN3Rb2zu003g+PPx3SfgMH1DkkD+0tPAJpqKgRxHuThQsY/RooKKGvP/DEB 4EQhtFDGmBM6nCZxh15asv7RHHDlLkbFfBaqLcp135Okm0y8QUoLxGBd96f1e5nsjk 5xNLqrgDzpRng== X-Nifty-SrcIP: [209.85.215.173] Received: by mail-pg1-f173.google.com with SMTP id 137so14345838pgb.5; Mon, 23 May 2022 11:05:20 -0700 (PDT) X-Gm-Message-State: AOAM530DxU7nDVS7Z5BXL7oz+xUhCMQ2pSYLP0vvfRhu4WCSqnnmZ8f2 koha5Px06Y1k+zW+TD4rzjR4rsyWMMZOi9kth9M= X-Google-Smtp-Source: ABdhPJx5Lme6JhQ7OKXuXU7KdkCmDLJQv7tFwa3fzbZTWXsLVHVozSYCDjkmkCCK6F2tBUWOu/ge6oucCPgm4OmGxhg= X-Received: by 2002:a63:fc5e:0:b0:3db:5804:f3b with SMTP id r30-20020a63fc5e000000b003db58040f3bmr21273043pgk.126.1653329119628; Mon, 23 May 2022 11:05:19 -0700 (PDT) MIME-Version: 1.0 References: <20220209185752.1226407-1-alexandr.lobakin@intel.com> <20220209185752.1226407-2-alexandr.lobakin@intel.com> In-Reply-To: <20220209185752.1226407-2-alexandr.lobakin@intel.com> From: Masahiro Yamada Date: Tue, 24 May 2022 03:04:00 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v10 01/15] modpost: fix removing numeric suffixes To: Alexander Lobakin Cc: linux-hardening@vger.kernel.org, X86 ML , Borislav Petkov , Jesse Brandeburg , Kristen Carlson Accardi , Kees Cook , Miklos Szeredi , Ard Biesheuvel , Tony Luck , Bruce Schlobohm , Jessica Yu , kernel test robot , Miroslav Benes , Evgenii Shatokhin , Jonathan Corbet , Michal Marek , Nick Desaulniers , Herbert Xu , "David S. Miller" , Thomas Gleixner , Will Deacon , Ingo Molnar , Christoph Hellwig , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Arnd Bergmann , Josh Poimboeuf , Nathan Chancellor , Masami Hiramatsu , Marios Pomonis , Sami Tolvanen , "H.J. Lu" , Nicolas Pitre , Linux Kernel Mailing List , Linux Kbuild mailing list , linux-arch , live-patching@vger.kernel.org, clang-built-linux Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Thu, Feb 10, 2022 at 3:59 AM Alexander Lobakin wrote: > > `-z unique-symbol` linker flag which is planned to use with FG-KASLR > to simplify livepatching (hopefully globally later on) triggers the > following: > > ERROR: modpost: "param_set_uint.0" [vmlinux] is a static EXPORT_SYMBOL > > The reason is that for now the condition from remove_dot(): > > if (m && (s[n + m] == '.' || s[n + m] == 0)) > > which was designed to test if it's a dot or a '\0' after the suffix > is never satisfied. > This is due to that `s[n + m]` always points to the last digit of a > numeric suffix, not on the symbol next to it (from a custom debug > print added to modpost): > > param_set_uint.0, s[n + m] is '0', s[n + m + 1] is '\0' > > So it's off-by-one and was like that since 2014. > Fix this for the sake of upcoming features, but don't bother > stable-backporting, as it's well hidden -- apart from that LD flag, > can be triggered only by GCC LTO which never landed upstream. > > Fixes: fcd38ed0ff26 ("scripts: modpost: fix compilation warning") > Signed-off-by: Alexander Lobakin > --- > scripts/mod/modpost.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > index 6bfa33217914..4648b7afe5cc 100644 > --- a/scripts/mod/modpost.c > +++ b/scripts/mod/modpost.c > @@ -1986,7 +1986,7 @@ static char *remove_dot(char *s) > > if (n && s[n]) { > size_t m = strspn(s + n + 1, "0123456789"); > - if (m && (s[n + m] == '.' || s[n + m] == 0)) > + if (m && (s[n + m + 1] == '.' || s[n + m + 1] == 0)) > s[n] = 0; > > /* strip trailing .lto */ > -- > 2.34.1 > This trivial patch has not been picked up yet. I can apply this to my tree, if you want. Please let me know your thoughts. -- Best Regards Masahiro Yamada