Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1610938rwr; Wed, 26 Apr 2023 18:42:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5eCP/QHWc2cmSRfoqGdHHGxtdvj/RngWW6Hx/IiqlJAxKpc4UohkhxF23Yl7AFLZb/OYam X-Received: by 2002:a05:6a00:1947:b0:63b:8b47:453c with SMTP id s7-20020a056a00194700b0063b8b47453cmr87046pfk.1.1682559739008; Wed, 26 Apr 2023 18:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682559738; cv=none; d=google.com; s=arc-20160816; b=edfxLurZkOhyJYW8FyS8oMiz+87bUtBlymZ5gihS1oAYPCRQtXX/yVnfhRHxTW37Mn mThEi/1bgoVoxZ/eREcD7o3SY7jPTZOgeGKVi50kbdZqI08hZYSb/ssVkppC6aO/CL3h xkm7kipY/QSVNkaNzVfA8nUzmzzMHxQtBgi9+Sua54/qVVX1P4mIXsaA2GCBeiy3U0u+ V0pO64mWyFy5AZXlU976Y7l//krItIAWHzrPYX3Hn28xICvGo9iKZuStcOUWcQuxIuk8 blqyC/kQZ7qw4Rhyoy4E2QU7P8mKqHqYywP3HJGSyRj+6nB1uYTGKGtlaeBT6TC95gs5 c8sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=JJJ9GNOktEDMsIQh8tPRssoqPVemKIENPCJQ8t3CG4M=; b=VeWblpJb+W+e02zPEBRlDYAR9JEDgdIbW/XMEFPTlhlQvv/o7AXE/pbWDFAu1iXkj6 1w3HyQ8z1wfDtG+mTrE3S7AlpDkgxu1ZLqx2/eobpw8Z/IzknGOjTvEo7dJZbs6C7zT/ I8a5rLLk/BV7ecCIjvPmTLhpNKhgyD8NnuBCVl+wKZx1fi/jCUVfdbD898iF9lOrldAQ xrOivW8X9dmJFoWU6VRT4pvS20sMbcv7IOD1oxAi8KTZdOd77lD5DmQizLQGXNHxSMt/ z8Ywighn5PNXMkE+IMwVievtekICWGpB0iUAO0+HyDHsIT9Jva9y2apz+yP3qtR4DXoG WplQ== 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 q22-20020aa79836000000b0063b54679d0dsi18086656pfl.44.2023.04.26.18.41.56; Wed, 26 Apr 2023 18:42:18 -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 S242722AbjD0Bax (ORCPT + 99 others); Wed, 26 Apr 2023 21:30:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232094AbjD0Bav (ORCPT ); Wed, 26 Apr 2023 21:30:51 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0D7F26BC; Wed, 26 Apr 2023 18:30:49 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Q6J4F70RtzpTCX; Thu, 27 Apr 2023 09:26:53 +0800 (CST) Received: from localhost.localdomain (10.67.174.95) 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:30:47 +0800 From: Yang Jihong To: , , , , , , , , , , , , CC: Subject: [PATCH] perf symbols: Fix return incorrect build_id size in elf_read_build_id() Date: Thu, 27 Apr 2023 01:28:41 +0000 Message-ID: <20230427012841.231729-1-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.95] 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=-4.2 required=5.0 tests=BAYES_00,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 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 --- tools/perf/util/symbol-elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 41882ae8452e..059f88eca630 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -903,7 +903,7 @@ static int elf_read_build_id(Elf *elf, void *bf, size_t size) size_t sz = min(size, descsz); memcpy(bf, ptr, sz); memset(bf + sz, 0, size - sz); - err = descsz; + err = sz; break; } } -- 2.30.GIT