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 39F11C433EF for ; Tue, 24 May 2022 13:46:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237928AbiEXNqF (ORCPT ); Tue, 24 May 2022 09:46:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237943AbiEXNp5 (ORCPT ); Tue, 24 May 2022 09:45:57 -0400 Received: from condef-06.nifty.com (condef-06.nifty.com [202.248.20.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB0A795A05 for ; Tue, 24 May 2022 06:45:56 -0700 (PDT) Received: from conssluserg-01.nifty.com ([10.126.8.80])by condef-06.nifty.com with ESMTP id 24ODghXu006073 for ; Tue, 24 May 2022 22:42:43 +0900 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (authenticated) by conssluserg-01.nifty.com with ESMTP id 24ODgDUG022736; Tue, 24 May 2022 22:42:13 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com 24ODgDUG022736 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1653399734; bh=aNLlIgPVqKG5chGBjgSqnkX4433JxjcWB7yJEVQZ+Gg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=vXA8HrUWNsrcMbb4jjxlOaE1UOW4nzjC8LOPdbOMXac6+lkDf8ercmWRWQ6PntFhp lbAfJ7j+CQ2UH7nNTb2juSxDe9MRJtGGZ6aySjIrlfVlcX9sJSj0BVCm/FTEkEAEbw A3FQPgOVjUU/yzKOkS2SqKMP52kVy5IEdmzSXSipe+inDpK4wNAA2xuR9MR32X2bYd de/lBb9qz4JB5gK5mtbgS7x4URxRknF7H6BevFWGGucM4329GlHTvZRGpAN6u/qHt5 jRTks2KxEk9Lxq4w8hPRb/lid7BQBgy9Fo/YcgPj+aV9bw+6GW5vkSONg8kGGvsLzU PIUGgvvPbp5RQ== X-Nifty-SrcIP: [209.85.214.175] Received: by mail-pl1-f175.google.com with SMTP id n8so15901205plh.1; Tue, 24 May 2022 06:42:13 -0700 (PDT) X-Gm-Message-State: AOAM532fDD7fTgrP2PSZWbA+u73O7vrxW/J+2a+2RkvgM1c2OOfz5JLb SyP6IgYnglXAMWGxmPBxAYDepk5z1FlvutCIXJo= X-Google-Smtp-Source: ABdhPJyTdv6DT7AK41vY70QzhcMH2A38iaGQn1upGmFmPJo+2BcK+NmA7eL9uIW06HJVa028vlOfajtpPNm4sy2hH34= X-Received: by 2002:a17:90a:e004:b0:1e0:7a66:fb3a with SMTP id u4-20020a17090ae00400b001e07a66fb3amr2891041pjy.119.1653399732689; Tue, 24 May 2022 06:42:12 -0700 (PDT) MIME-Version: 1.0 References: <20220209185752.1226407-1-alexandr.lobakin@intel.com> <20220209185752.1226407-2-alexandr.lobakin@intel.com> <20220524113337.4128239-1-alexandr.lobakin@intel.com> In-Reply-To: <20220524113337.4128239-1-alexandr.lobakin@intel.com> From: Masahiro Yamada Date: Tue, 24 May 2022 22:40:51 +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: live-patching@vger.kernel.org On Tue, May 24, 2022 at 8:34 PM Alexander Lobakin wrote: > > From: Masahiro Yamada > Date: Tue, 24 May 2022 03:04:00 +0900 > > > 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. > > It's a good idea, I'd like to! > I don't use `-z unique-symbol` for FG-KALSR anymore*, but this fix > is not directly related to it and can be taken independently. > Should I change the commit message or it's ok to take it as it is? I am fine with either way. If you want to resubmit this with a fresh commit log, please send it to: linux-kbuild@vger.kernel.org Then, I will take care of it in this MW. Thanks. > > > > Please let me know your thoughts. > > > > > > -- > > Best Regards > > Masahiro Yamada > > * I'm planning to submit a new rev of FG-KASLR series soon, but > since I'm too busy with XDP for now, it will happen no sooner than > in a couple months =\ > > Thanks! > Al -- Best Regards Masahiro Yamada