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 DD559C433F5 for ; Tue, 3 May 2022 07:31:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232319AbiECHer (ORCPT ); Tue, 3 May 2022 03:34:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232280AbiECHeo (ORCPT ); Tue, 3 May 2022 03:34:44 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B8B817074; Tue, 3 May 2022 00:31:13 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 1FF1E1F749; Tue, 3 May 2022 07:31:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651563072; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=w+PouQmnZ9GsbOBxPEA2aGYdP7XgCY+B9Qhwz2UQ8+Y=; b=ox1CyHAMnWjmEqLQwK8dSc53AwYIueIddr3rIyNhdAh2r9ypOQwtjkrpz55leMI4agVEFu ifQJhpDj2meSrhcdmc3gQKoNNsVuYOX/JYRryRrYxdQrC4tq6KadDhHNSdJoAa4NxZmGNc jChZK/w6hEpO3GjgQW3mNeQDcjqP/fQ= Received: from suse.cz (unknown [10.100.224.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 148A12C141; Tue, 3 May 2022 07:31:08 +0000 (UTC) Date: Tue, 3 May 2022 09:31:07 +0200 From: Petr Mladek To: Alexander Lobakin Cc: linux-hardening@vger.kernel.org, x86@kernel.org, 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 , Masahiro Yamada , 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@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, live-patching@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH v10 01/15] modpost: fix removing numeric suffixes Message-ID: References: <20220209185752.1226407-1-alexandr.lobakin@intel.com> <20220209185752.1226407-2-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220209185752.1226407-2-alexandr.lobakin@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2022-02-09 19:57:38, 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' Yup, the + 1 is for the '.' between the symbol name and the number. In the order of apperance it would be: n + 1 + m > 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 Reviewed-by: Petr Mladek Best Regards, Petr