Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1592740rwr; Wed, 26 Apr 2023 18:20:12 -0700 (PDT) X-Google-Smtp-Source: AKy350as6+v1SqBqGZ6YpGuv63Y15G1Kwx1oOgk74fRIGOV9J3Lc6CvDhgyuwmuL/8x28qc0QN8U X-Received: by 2002:a17:902:e808:b0:1a1:bfe8:4fae with SMTP id u8-20020a170902e80800b001a1bfe84faemr29020704plg.43.1682558411704; Wed, 26 Apr 2023 18:20:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682558411; cv=none; d=google.com; s=arc-20160816; b=yqiZRxavNy79c68ELs/zGIgU7sNvmOJCvB4fEUSulyjUoAiUdX2SlWv1pqH+R5p49V hPOF8DDjJn+N2M8VNkiEAaS6g+q5NrO40cuZjMymTRrYmVmGVZ7QcwQyXEOFQ0VtfBbp kBAzX0xcLmu0gC1nijiZK8RxIlAyIzZVDHpWI2DHtw+TmAf9E3iCzGRbLEK+n/CNUcrD rbfNWuNnE4+qLK499xxKErBazy/6Gw9AmgKCb2FPFn32Du/SCZrz8mJCC+4oaTAX3nmA XUGuU3cloh4dmiONFvoeNYpLYln6Kxd4eIaKqrlrW4P1SyS69OBrH2ZaH1FfYOH9O9QK t4Mg== 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=p44FNIv5BMxuwS1NmpShXCbSQyqiAxfTm3suOeXu+Sk=; b=Fn7EHKL6pdM/Zx2b56923T+SAVeaPRXHJB3p7IhWI+VFP3D3Ekg5Wo4oTciULsVqYG Uz5y38HNPFZXvqNEVoyTmQdDW+3d37seMhowQh4xdnl5HNj5gP7v+LvrGKRYEM39HKoR KwLTTef13xa1tPg3Nke9IcIpFVhyItgN18hPOA6aNmwcrIMYE+K6/haA57Tcb23HdPQv advaHzGARpzRrl7wZ0DCPadLQQ1pzSLZF2tDTzkqcQKtfOZtvEwSm8BqQwpz251TCu41 /RxcgX4Kh/h/U37lnxUJr3sQxDHVGF61wxDP65iR19bzMqxZ5UeuTz5RlB5jSBlPVjTB 6OEw== 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 q7-20020a17090311c700b001a526bc2b84si17987378plh.620.2023.04.26.18.20.00; Wed, 26 Apr 2023 18:20:11 -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 S242959AbjD0BTY (ORCPT + 99 others); Wed, 26 Apr 2023 21:19:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242938AbjD0BTJ (ORCPT ); Wed, 26 Apr 2023 21:19:09 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49C113A92; Wed, 26 Apr 2023 18:18:53 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Q6Hqn6g6pzLnkF; Thu, 27 Apr 2023 09:16:05 +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 09:18:50 +0800 Subject: Re: Bug: "perf record" reporting buffer overflow when writing data To: Will Ochowicz , "linux-perf-users@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <6c88ac58-a2c8-0b15-a106-9c8b0e26b3ac@huawei.com> From: Yang Jihong Message-ID: <2a7fd858-1639-53a7-bc65-d4f65a9eed2f@huawei.com> Date: Thu, 27 Apr 2023 09:18:49 +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: 8bit X-Originating-IP: [10.67.111.205] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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,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/26 20:52, Will Ochowicz wrote: > Hi Yang, > > 1. Displaying notes found in: .note.gnu.build-id >   Owner                Data size        Description >   GNU                  0x00000028       NT_GNU_BUILD_ID (unique > build ID bitstring) >     Build ID: > 6236326637343061343961353463366632643232333465366562353039656634 > 3938656130663039 > > 2. That patch did fix the issue. Thanks for your test to help confirm the problem. I'll send a fix patch. > > Would you mind giving me a quick explanation of the issue for my own > edification? > According to the coredump stack trace, the following code causes the out-of-bounds access problem: #7 0x00005555557e7ddd in memcpy (__len=40, __src=0x555556a28b38, __dest=0x7fffffff843c) at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29 #8 write_buildid (fd=0x7fffffff8590, misc=, pid=-1, bid=0x555556a28b38, name_len=, name=0x555556a28c0c "/opt/pylon/lib/libpylonbase-6.1.1.so") at util/build-id.c:312 That is, an error occurred when writing the build_id of the "/opt/pylon/lib/libpylonbase-6.1.1.so" file. The corresponding code is as follows: write_buildid() { ... memcpy(&b.data, bid->data, bid->size); ... } b.data is an array whose size is Build_ID_SIZE(20), but bid->size is greater than this value. Check the perf code and find this problem. Thanks, Yang.