Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp265518rwr; Thu, 27 Apr 2023 00:35:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6pKcLO25fduA92fNC46/ONjX5bNmGtw+M6rCUTbcxH/t89gzf/hnzaotkrFl5mNGdCmCrD X-Received: by 2002:a05:6a21:32a2:b0:f5:7e36:485b with SMTP id yt34-20020a056a2132a200b000f57e36485bmr594037pzb.6.1682580940072; Thu, 27 Apr 2023 00:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682580940; cv=none; d=google.com; s=arc-20160816; b=B7HQiv39ioXQTHxYAjP8/JrVO/P1FFjMRYqZzZIKawD9CRy1tWYyw/HvLdvEsELp06 Fb/fWTGPgd/kUIIFZF9awJj8dTpigQESPASr9o23lQbMA96L8fBJMEvZse4o5BXk81oh C/+CWMT4+SJorEPkrUbZn9YZsefgLMFex9v5mBJPy6zwVHho45cGF2wMartU9NvCzrz5 djARDqui565nnC9f9jBDfSkAchRHdM/RDlGrXj4MVNDVCtzJQwRhOFghlW+hRLWXEKnx 8XdG/LZgHlq+zQ+7q/EKOK6gnok+/QfA1jETxNnbLWxSkKgox97ssyKbxLLxHtqdIxLl h+ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject; bh=gxbeWsdErDbMM07LDV45ROBK7bHL4kpgFYxp/e+/4ZM=; b=FY1hZvPs+4rDWDfH0BdkLJVo5ULYGIRR4PJtRvWFe45Q6VX45aB3JhwdedRvYfdnOE 6w9AxFXx9Ns/lkbHP9fLxOqDH2/6506oL1YezhGxRSmFgMx6vvyOzPHU1QEvIaXK1wgH O1Z08gVjWll3DMm0KRLOzXdKXsvUDFg+qZ2bJUgXwaEg0ZpgmKnxkLwQffYd4BXT7Oqb nnsY5z340r44+e/t9Fsv59e2Cpzy/JnAAp7VSr/QZeZ8OsepIdMBPE/jRKnXFBmeOTnl ta3/FU3v41noDagMcD/niBICbyebdwyVwhQ+34PYpPmwmd31BV+jnNH8rtNV21VW2IeT 8B6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a72-20020a63904b000000b00513232c46e6si18675132pge.283.2023.04.27.00.35.27; Thu, 27 Apr 2023 00:35:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242821AbjD0H2G (ORCPT + 99 others); Thu, 27 Apr 2023 03:28:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242971AbjD0H2B (ORCPT ); Thu, 27 Apr 2023 03:28:01 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22C094EFE; Thu, 27 Apr 2023 00:27:35 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Q6Rzm4bbtz18KXF; Thu, 27 Apr 2023 15:23:32 +0800 (CST) Received: from [10.67.111.205] (10.67.111.205) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 27 Apr 2023 15:27:25 +0800 Subject: Re: [PATCH] perf symbols: Fix return incorrect build_id size in elf_read_build_id() To: Adrian Hunter , , , , , , , , , , , , References: <20230427012841.231729-1-yangjihong1@huawei.com> From: Yang Jihong Message-ID: Date: Thu, 27 Apr 2023 15:27:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.111.205] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On 2023/4/27 14:02, Adrian Hunter wrote: > On 27/04/23 04:28, Yang Jihong wrote: >> In elf_read_build_id(), if gnu build_id is found, should return the size of >> the actually copied data. If descsz is greater thanBuild_ID_SIZE, >> write_buildid data access may occur. >> >> Fixes: be96ea8ffa78 ("perf symbols: Fix issue with binaries using 16-bytes buildids (v2)") >> Reported-by: Will Ochowicz >> Link: https://lore.kernel.org/lkml/CWLP265MB49702F7BA3D6D8F13E4B1A719C649@CWLP265MB4970.GBRP265.PROD.OUTLOOK.COM/T/ >> Tested-by: Will Ochowicz >> Signed-off-by: Yang Jihong > > As an aside, note that the build ID on the ELF file triggering the bug was > 62363266373430613439613534633666326432323334653665623530396566343938656130663039 > which is 80 ASCII characters, which would have been a 20 byte binary number i.e. > > $ echo -en "0000: 62363266373430613439613534633666\n0010: 32643232333465366562353039656634\n0020: 3938656130663039" | xxd -r | od -c -A d > 0000000 b 6 2 f 7 4 0 a 4 9 a 5 4 c 6 f > 0000016 2 d 2 2 3 4 e 6 e b 5 0 9 e f 4 > 0000032 9 8 e a 0 f 0 9 > 0000040 > > So perhaps a mistake in the creation of the build ID on that ELF file. > Yes, it may be an error, or it may be that the build-id was specified when the elf file was created. I tried ld can specify a build-id larger than 160-bit hexadecimal digits: $ ld -o test test.o --build-id=0x62363266373430613439613534633666326432323334653665623530396566343938656130663039 $ readelf -n test Displaying notes found in: .note.gnu.build-id Owner Data size Description GNU 0x00000028 NT_GNU_BUILD_ID (unique build ID bitstring) Build ID: 62363266373430613439613534633666326432323334653665623530396566343938656130663039 All in all, it feels like a rare scene :) > In any case, for the fix: > > Acked-by: Adrian Hunter > Thanks for the acked-by. Thanks, Yang