Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1338047rdb; Fri, 16 Feb 2024 12:23:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU5j9iH0TwTL6fWid1T4nWeLg7lF5Y4jHlrUPmmb0/aqT2owxn5p9ZTVuFd0px6euHxPdHp3BDrH5kphfZ/JYH3PBDBd8mzgE5IXa1NGg== X-Google-Smtp-Source: AGHT+IEGqSDq89HIXuXVPqG/wlDFRiIyVLdYtAFL0tcIQSamf6MyZsLc1HENVmP/Lt7T3CqYIQRm X-Received: by 2002:a05:6358:5927:b0:17a:a774:93a3 with SMTP id g39-20020a056358592700b0017aa77493a3mr4415108rwf.15.1708114987574; Fri, 16 Feb 2024 12:23:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708114987; cv=pass; d=google.com; s=arc-20160816; b=a0S7kAfhosZ7oJMzch0SoQgd9vIFgSQ6EYUpvenIiJv2huWO+hb6wwGiCD2UheBTdj GutFvLrugQ9tgXHkzeSx+vCAQlSV6pqpj+q6cYVqITVTuO1gH1fh0alaJQAlYEx2iVYe e5JQt/OBorAB2dsbXwdhsK13nOY429BsB8VoXSDms18PYgIKpSRqJb0aM0fU+gWlO0D5 xaJZ2Aq0aAk/yOkCjBN9NWt+/u0VHl0b/Wsij8zVzUIuPE5XAaFrbPAVZ0Rq3RBcPxIu l7RRdcXNN5CMLjidmw/uq/ne66Np0mBvi3qupK/4y1tLS/cpK5iI7QeuVUleSnVgWUss xXDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=Oq0A0N9FMvQiwLtedEjU1Y/XLo5XcWAr1iJu9cUBjms=; fh=fayNP5d7E3r6woSm5Lc6ewqI3DZDxt8fuJ8GptUWmAM=; b=uFx/cnkjMDew4Oep9oDDzgQiiUNdWKw/CXk94HoGHJudHl6cFbZK1Bts9a1974Y8Z+ pj1hsa/0B4/MPdQIPQTHfRdGnZhwBDMPwtRUp0dq9ibO+vkwmnzGRF3gfNTlh3B1Fod3 jbeIfrMKvJDLO6e1japBxakrWSlWc3NgypBQh92QvB01CjhNN5eUcG0DrmsAbf60SWbn hIa+ECjOPGpQ0E1tZ8/N4Ab6y/j2nZ66OzARG1OkDiK+cSIlaZYMVErkEjbikcHOs4+H lBD6Iv2xbY5QpLDuxNLOB+JkbokUEDYgQ6R5GjbVmrtKtKm36AEDuUVA9YtKmzgNlJHK Fvwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-69288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69288-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s25-20020a656919000000b005dc98dad590si386725pgq.68.2024.02.16.12.23.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:23:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-69288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69288-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C2830B213FD for ; Fri, 16 Feb 2024 20:22:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FCA213B280; Fri, 16 Feb 2024 20:22:27 +0000 (UTC) Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25ABA137C5A; Fri, 16 Feb 2024 20:22:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708114946; cv=none; b=THbKRU3mPW0TKxmEyVCBE+jCBZmDqY75qoyASNIEXwdqE/xBZrRc4WpNPoYdNjSser34sXYnEzwdm3bh1eoe6MO1fK89W4bkrIsQeXq4ThnBtKO/facJKB3TcKfsmJM4tkgZXdwh3KieweSLxcxfbnYZHEYba6G6HiGTChH/IgY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708114946; c=relaxed/simple; bh=pnCogIDz14LG5tHCuqzaTGDuVoRYHckFSaXPPX5xATI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=C+jeZxzIvDTOHcNHNbn/AiMwru+8OT7/NVbuzS1+8vSW9x8u18oIEp0As2nPBfpawzqeYzMAfOFbVql6jtIsCiVN8iM1+Ke5cdyRUABpR8zRGYwFXt5olLnlloKGrtEX+YY2uImxZLAUg0/Tty26S84HioJh4UJC0K9em3HsuQw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2995185dbbbso141325a91.3; Fri, 16 Feb 2024 12:22:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708114944; x=1708719744; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Oq0A0N9FMvQiwLtedEjU1Y/XLo5XcWAr1iJu9cUBjms=; b=XbjlfEqd+soG7CDvwv1svXhAN+6q+9p5qM1xGRrzcZCwmaLMe+cWmCQMP3tFLzK5s5 vZD4Q2P2MOQb1/WuCNKrOpeRIXzzX5YyMGLR5J7hdf6fepJMaOOatR2YlbWob6xPvNDi Cdd4w9HP+T8uGIMRSKj1HrTGRdjr6Z8C2D2J1lvBhy+4RdePyZvLAw3yIwwZTwqn/+qT h1t4caU/0DqaQ71pi1y3qB/FmSjLe75jZOex613fSdmer7IuXdxEFayS3lMbz6/+TGOc Kr/oVYlJ10/LfaEmpYEWRiGl8QUuIH1Ums3Ctir4XR0P8TtdGgFhDAwiK60pIGVIZKyQ OwTQ== X-Forwarded-Encrypted: i=1; AJvYcCViRTV6pk25t8bwPxbK1Ecv35GIy19g8oPun8kbS481pRrFx+YijGyOcwIcLTb8vpb3fNd7KKwMJlOVmlLaThOO3ME5V7QwPB5FCnajvXfZ70ZdvBTbmuCc60lfX3xUHHw3Lqq5/cXqGxZTgF8sJw== X-Gm-Message-State: AOJu0Yx4HBD9BFvtEnK9VDVtae3cMXJRoKLiw+xMJBavzAdWV4vv/TVH hdfjFFSrQIMFbwVT9YaeZnpuGsAMXCUhXlM1Yv9ygEkoLx5/JmPzttHGSC3Vs8mCIDA5aN22YiR EtKXHTEBjsAMyA0LBRZn5QcRH+2k= X-Received: by 2002:a17:90a:a883:b0:299:1aaa:5ff with SMTP id h3-20020a17090aa88300b002991aaa05ffmr4758561pjq.7.1708114944478; Fri, 16 Feb 2024 12:22:24 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240214045356.748330-1-irogers@google.com> <20240214045356.748330-7-irogers@google.com> In-Reply-To: <20240214045356.748330-7-irogers@google.com> From: Namhyung Kim Date: Fri, 16 Feb 2024 12:22:12 -0800 Message-ID: Subject: Re: [PATCH v4 6/8] perf tests: Use scandirat for shell script finding To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , James Clark , Athira Jajeev , Kan Liang , Yang Jihong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 13, 2024 at 8:54=E2=80=AFPM Ian Rogers wro= te: > > Avoid filename appending buffers by using openat, faccessat and > scandirat more widely. Turn the script's path back to a file name > using readlink from /proc//fd/. > > Read the script's description using api/io.h to avoid fdopen > conversions. Whilst reading perform additional sanity checks on the > script's contents. > > Signed-off-by: Ian Rogers > --- > tools/perf/tests/builtin-test.c | 21 ++--- > tools/perf/tests/tests-scripts.c | 144 ++++++++++++++++++------------- > tools/perf/tests/tests-scripts.h | 1 - > 3 files changed, 95 insertions(+), 71 deletions(-) > > diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-t= est.c > index eff3c62e9b47..6d5001daaf63 100644 > --- a/tools/perf/tests/builtin-test.c > +++ b/tools/perf/tests/builtin-test.c > @@ -300,22 +300,20 @@ static int test_and_print(struct test_suite *t, int= subtest) > } > > struct shell_test { > - const char *dir; > const char *file; > }; > > static int shell_test__run(struct test_suite *test, int subdir __maybe_u= nused) > { > int err; > - char script[PATH_MAX]; > struct shell_test *st =3D test->priv; > + char *cmd; > > - path__join(script, sizeof(script) - 3, st->dir, st->file); > - > - if (verbose > 0) > - strncat(script, " -v", sizeof(script) - strlen(script) - = 1); > - > - err =3D system(script); > + asprintf(&cmd, "%s%s", st->file, verbose ? " -v" : ""); > + if (!cmd) > + return TEST_FAIL; It fails to build. tests/tests-scripts.c: In function =E2=80=98shell_test__run=E2=80=99: tests/tests-scripts.c:130:9: error: ignoring return value of =E2=80=98asprintf=E2=80=99 declared with attribute =E2=80=98warn_unused_res= ult=E2=80=99 [-Werror=3Dunused-result] 130 | asprintf(&cmd, "%s%s", file, verbose ? " -v" : ""); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Thanks, Namhyung > + err =3D system(cmd); > + free(cmd); > if (!err) > return TEST_OK; >