Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4757710rdb; Tue, 12 Dec 2023 08:31:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1u/geO0hYucRbSX6WYRps7e/84I5bzOdKq5ce6/TqY3TSKEYH/7GyMlHr1A6lHDIlh+vZ X-Received: by 2002:a17:902:ecca:b0:1d0:7b65:9f8a with SMTP id a10-20020a170902ecca00b001d07b659f8amr3907359plh.51.1702398664770; Tue, 12 Dec 2023 08:31:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702398664; cv=none; d=google.com; s=arc-20160816; b=qjaH7ai5gKzI4DfN/LBh4GB1eNDuCDWCuJwwlXh398hJDY/uWPklGnz7SGocMzIU1P Ym3X5wl6QohBtagybq81m6P9XrycnUKQVCzqOBehIksOuggKS/caw+Kbbu58xYhW/Ni8 AA5MS2URHMIBQquYKfZKhfxfM5Pq9IOOpCdK/swDcz5ZwfwGd62epyNObf/wiMc0/Bhc GZqAND1QKlffc3hN84rfLOiqWIPLmY7Z6BUu0UJmQY5sjnKKZiqxxZ/t/s4+yjn24a7n rTpQg8fnMTDASWs6NtKfrwrYCasKR9oielKFEOhN3LL40uOEqm0qeGDP+dtTMllQkTaW RUTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=5JN4i9FyZO5OQasrQlGKq2WcO8Ez/U2xySCeSqo5Ids=; fh=Delo4F7CiXA9ejufpeULh4kiKdFyx275VRtz59xPVGc=; b=xJz8qUzWAdiYd1cQaSKXD4ry4yJaUfIHuhjUDDLQC5msqTDdgUYYk+Z/+VrdB1U45N oVzhLhtU0pZZsVUPzLfpgFtiBORIJUlyZSMu/LntoMnjCQFzJ6tiiNMxSzil4OEyQ5RL aN2LR20FODVOnb6nJHtVUr2DcFO3QQRxROc2jws1j6NqNwYwKpaEPUmherlrjSUqMlpw +xV+Nxe68HEldYbXW1U/qOrQfn7jwLlFSr/T87wvFc9vJ8EeTN/d+uZpqfQHc3RSQjz7 PHz+w2xZZJocbRIBV2lwnMhRs6L37pCt13PlMZSE1DRnzdw4Dyakar9oDm6Ok6s1QHkL bW2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ifybhCwY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id p9-20020a1709027ec900b001cfb4f3da6csi7928068plb.44.2023.12.12.08.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 08:31:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ifybhCwY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7D83280AD97B; Tue, 12 Dec 2023 08:30:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232603AbjLLQ3w (ORCPT + 99 others); Tue, 12 Dec 2023 11:29:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbjLLQ3v (ORCPT ); Tue, 12 Dec 2023 11:29:51 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84024EA; Tue, 12 Dec 2023 08:29:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702398597; x=1733934597; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=1KPdh+IHvxj61yHY90L5mpUKcg5ebFH71mmxLtM871E=; b=ifybhCwYVdLDuvOn7VAspe8BDO/p87H+8nFgZPi0Z/pPqZ+kqj/XKjHz XzrfNJxJsdu1BeQyt99gS+eZI5kdUIgx2bk8GFsWyoquA7LtWl6xEte7f 32wXmA83EkZJfubhA29zrRCvJKXexoje8GwrFPi6mQcSddRraMd7lpi7j E6NdCdFv97lTgMOVREu9R0MEHzOPjzpeAecrXqfHCRoVCbc0U4CHyT6f6 fdyl7yHo1yXLFYV+U7cS3z0qkmr1nk2M/kT9eADWypWT7gkeBchae+SVF gaaj7p3gMXRgNL3DtJ3DZP18oJ04XQbuFGIKyWyk+vYrShB5ZKgrkiD2Y w==; X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="8195796" X-IronPort-AV: E=Sophos;i="6.04,270,1695711600"; d="scan'208";a="8195796" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2023 08:29:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="777155040" X-IronPort-AV: E=Sophos;i="6.04,270,1695711600"; d="scan'208";a="777155040" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.252.48.253]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2023 08:29:52 -0800 Message-ID: <6b6a238d-4b1c-452f-8061-6840d44120bc@intel.com> Date: Tue, 12 Dec 2023 18:29:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH linux-next] perf intel-pt: replace strlcpy() with strscpy() Content-Language: en-US To: yang.guang5@zte.com.cn Cc: jiang.xuexin@zte.com.cn, chen.haonan2@zte.com.cn, cgel.zte@gmail.com, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, liam.howlett@oracle.com, ojeda@kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, peterz@infradead.org References: <202312121122562881958@zte.com.cn> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: <202312121122562881958@zte.com.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 12 Dec 2023 08:30:06 -0800 (PST) On 12/12/23 05:22, yang.guang5@zte.com.cn wrote: > From: Yang Guang > > strlcpy() reads the entire source buffer first. This read may exceed > the destination size limit. This is both inefficient and can lead > to linear read overflows if a source string is not NUL-terminated. > No return values were used, so direct replacement is safe. > > Signed-off-by: Chen Haonan > --- > tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c > index b450178e3420..5b14c6701ecb 100644 > --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c > +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c > @@ -507,7 +507,7 @@ int intel_pt__strerror(int code, char *buf, size_t buflen) > { > if (code < 1 || code >= INTEL_PT_ERR_MAX) > code = INTEL_PT_ERR_UNK; > - strlcpy(buf, intel_pt_err_msgs[code], buflen); > + strscpy(buf, intel_pt_err_msgs[code], buflen); > return 0; > } > perf doesn't have strscpy(): util/intel-pt-decoder/intel-pt-decoder.c: In function ‘intel_pt__strerror’: util/intel-pt-decoder/intel-pt-decoder.c:510:9: error: implicit declaration of function ‘strscpy’; did you mean ‘strlcpy’? [-Werror=implicit-function-declaration] 510 | strscpy(buf, intel_pt_err_msgs[code], buflen); | ^~~~~~~ | strlcpy cc1: all warnings being treated as errors