Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1289294rwb; Thu, 22 Sep 2022 12:50:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6STcoSnvDyDDcFwrdO8DT/7AAQyx7LTLlh8fUQIYUo5x3rfigbL5ZrLYSxnqLyERWacWJJ X-Received: by 2002:a17:90b:4f8e:b0:202:dd39:c04d with SMTP id qe14-20020a17090b4f8e00b00202dd39c04dmr5603239pjb.66.1663876243129; Thu, 22 Sep 2022 12:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663876243; cv=none; d=google.com; s=arc-20160816; b=P0q3Etm8u7uFUh85CibjvPWbxLbbLxyb3br2BWPs5R4cqnk0m7JfezVk2+dWn8rLbR nMYxi210Cw82YjLq0DZjjZ2Vpf0+u07zA5sEKNetj9abfMHwyQ5/zTV6/0E5HdRyh2I0 nQ1ZvDfD4ZD85v0ufr+SnrZK3vurOdynOiYF/F5b21O6hHCj0kDGZYwI6b5wK46W37lC uOOEAJavlrkEKtLD/6dFw++f0CSU6fWnegjU1y8dzMMJt665PvEKGD4TcTtBl2719rqc h2AO8+Dxv/TdNk0UMvzB64IW4+8bxyzvwOvbT7ZnKegKTeNGnjwgpXw9kqSn33JFT2Of Jndg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wk8fmA1iCwITkgzYtyEeyVDGa7yADMsp6aK1uLDElbo=; b=LUmhXDQBMdOaS6EDGxPwxcdl8gPtV+USCBWsKYGHkFQ/HuDzV0OllNmUX/Q7uoAkdL Ju0zS4slmazzWXSzS0z2BGS1bHNZOQrSFO+zPVuL5I8sGOXj7xk23g5yAYIvDqPfLSN5 ZmSot7aloyPd3xuyaeTSRZuBROZw40zvQo+EvNHP6vXOd+J675tLB9ciAw0KlXjIrdz2 j8jDoJIWJ/mlLBF24OPbz+8bG5uJgAPHyjZ6Ww3lY5M8KMnuddPjAM07k+OcpohwEjfa NmmJdop+MREjtW6qtalGRCR64fe0Z0DyCjSEUeOCOcfaboDX75ung5WGZwz5rOsDEuql X5gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HpInakzF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pi10-20020a17090b1e4a00b002025f0f2926si573572pjb.93.2022.09.22.12.50.32; Thu, 22 Sep 2022 12:50:43 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HpInakzF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230216AbiIVTTH (ORCPT + 99 others); Thu, 22 Sep 2022 15:19:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbiIVTTG (ORCPT ); Thu, 22 Sep 2022 15:19:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84133106A29; Thu, 22 Sep 2022 12:19:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1DE9160ED1; Thu, 22 Sep 2022 19:19:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 589B6C433D6; Thu, 22 Sep 2022 19:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663874344; bh=fH/ftMSCMde/tGgysJ6GXrjfJcRK3hwxp51NNNMYSFQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HpInakzF/YtLR0GbsbO3sqUR/uaQGEOaH+QUKjCFD90cCiAoPClfFis7jvQ6Iq9V9 woDePn4JOZoLS9INmwPdG7h13IZNDGzJb8Kb5ZqSrn7ZpoyI7zw4XYk2gaPAr4iq9f aWwP2c/elk1FeYiiKcsKG/QHmkknN3Cle7cpBrrCGNWEoP55aQAfFtIBFRlHHdSys5 9ORBGvqGGh560Grx4MyYKxPBsS7mj/mOjDhO27d0AljgDH0mdXHQwr9V49JaUV36Dh B6Gc2Bn2b+1kgE0Iqfte0cikEZ6TdtwzePpimxEORHsHxmnPJ/U2vlICBeAkxP4Rvx ecUjR6FvTZH1Q== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 2EBA2403B0; Thu, 22 Sep 2022 20:19:02 +0100 (IST) Date: Thu, 22 Sep 2022 20:19:02 +0100 From: Arnaldo Carvalho de Melo To: cgel.zte@gmail.com Cc: mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, songliubraving@fb.com, adrian.hunter@intel.com, davemarchevsky@fb.com, wcohen@redhat.com, andres@anarazel.de, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, ye xingchen , Zeal Robot Subject: Re: [PATCH linux-next] perf annotate: use strscpy() is more robust and safer Message-ID: References: <20220922012431.232372-1-ye.xingchen@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220922012431.232372-1-ye.xingchen@zte.com.cn> X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Em Thu, Sep 22, 2022 at 01:24:31AM +0000, cgel.zte@gmail.com escreveu: > From: ye xingchen > > The implementation of strscpy() is more robust and safer. Where is strscpy() defined? I see it defined in the kernel: ⬢[acme@toolbox perf]$ grep -w strscpy include/linux/string.h ssize_t strscpy(char *, const char *, size_t); /* Wraps calls to strscpy()/memset(), no arch specific code required */ ⬢[acme@toolbox perf]$ But not in tools/ Have you actually build with these patches? - Arnaldo > That's now the recommended way to copy NUL terminated strings. > > Reported-by: Zeal Robot > Signed-off-by: ye xingchen > --- > tools/perf/util/annotate.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c > index 5bc63c9e0324..e2b038b14ff6 100644 > --- a/tools/perf/util/annotate.c > +++ b/tools/perf/util/annotate.c > @@ -1702,7 +1702,7 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil > char *new_name = filename_with_chroot(dso->nsinfo->pid, > filename); > if (new_name) { > - strlcpy(filename, new_name, filename_size); > + strscpy(filename, new_name, filename_size); > free(new_name); > } > } > @@ -2002,7 +2002,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args) > kce.len = sym->end - sym->start; > if (!kcore_extract__create(&kce)) { > delete_extract = true; > - strlcpy(symfs_filename, kce.extract_filename, > + strscpy(symfs_filename, kce.extract_filename, > sizeof(symfs_filename)); > } > } else if (dso__needs_decompress(dso)) { > -- > 2.25.1 -- - Arnaldo