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 5031AC0015E for ; Fri, 16 Jun 2023 08:53:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343900AbjFPIxG (ORCPT ); Fri, 16 Jun 2023 04:53:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343914AbjFPIwd (ORCPT ); Fri, 16 Jun 2023 04:52:33 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B36D43A9D for ; Fri, 16 Jun 2023 01:52:24 -0700 (PDT) Received: from dggpemm500006.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QjCZX2FD4zTlQF; Fri, 16 Jun 2023 16:51:48 +0800 (CST) Received: from [10.174.178.55] (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 16:52:21 +0800 Subject: Re: [PATCH] kallsyms: let kallsyms_on_each_match_symbol match symbols exactly From: "Leizhen (ThunderTown)" To: Song Liu CC: Song Liu , "live-patching@vger.kernel.org" , Josh Poimboeuf , Jiri Kosina , "mbenes@suse.cz" , "pmladek@suse.com" , "joe.lawrence@redhat.com" , Kernel Team , "mcgrof@kernel.org" References: <20230615170048.2382735-1-song@kernel.org> <4c05c5eb-7a15-484f-8227-55ad95abc295@huawei.com> <85475c44-d9c4-d5ad-350e-bb5fd713ff26@huawei.com> <77d57723-73d3-8837-b2b5-9fc81e482a8d@huawei.com> Message-ID: <6eb17ba3-0a20-b6da-2466-016c559d79f3@huawei.com> Date: Fri, 16 Jun 2023 16:52:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <77d57723-73d3-8837-b2b5-9fc81e482a8d@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: live-patching@vger.kernel.org On 2023/6/16 16:43, Leizhen (ThunderTown) wrote: > > > On 2023/6/16 16:11, Leizhen (ThunderTown) wrote: >> >> >> On 2023/6/16 13:01, Song Liu wrote: >>> >>> >>>> On Jun 15, 2023, at 7:19 PM, Leizhen (ThunderTown) wrote: >>>> >>>> On 2023/6/16 1:00, Song Liu wrote: >>>>> With CONFIG_LTO_CLANG, kallsyms.c:cleanup_symbol_name() removes symbols >>>>> suffixes during comparison. This is problematic for livepatch, as >>>>> kallsyms_on_each_match_symbol may find multiple matches for the same >>>>> symbol, and fail with: >>>>> >>>>> livepatch: unresolvable ambiguity for symbol 'xxx' in object 'yyy' >>>> >>>> Did you forget to specify 'old_sympos'? When there are multiple symbols with >>>> the same name, we need to specify the sequence number of the symbols to be >>>> matched. >>> >>> >>> old_sympos is indeed 0 here. However, the issue with CONFIG_LTO_CLANG >>> is different. Here is an example: >>> >>> $ grep bpf_verifier_vlog /proc/kallsyms >>> ffffffff81549f60 t bpf_verifier_vlog >>> ffffffff8268b430 d bpf_verifier_vlog._entry >>> ffffffff8282a958 d bpf_verifier_vlog._entry_ptr >>> ffffffff82e12a1f d bpf_verifier_vlog.__already_done >>> >>> kallsyms_on_each_match_symbol matches "bpf_verifier_vlog" to all of >>> these because of cleanup_symbol_name(). IOW, we only have one >>> function called bpf_verifier_vlog, but kallsyms_on_each_match_symbol() >>> matches it to bpf_verifier_vlog.*. >>> >>> Does this make sense? >> >> Sorry. I mistakenly thought you were operating a static function. >> >> These suffixes are not mentioned in the comments in the function >> cleanup_symbol_name(). So I didn't notice it. > We can keep these three suffixes on the kallsyms tool end. And modify cleanup_symbol_name() not to cleanup these three suffixes. > >> >>> >>> Thanks, >>> Song >>> >>> >>> . >>> >> > -- Regards, Zhen Lei