From patchwork Tue Aug 8 09:16:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 711774 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA7D5C04A6A for ; Tue, 8 Aug 2023 16:44:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233112AbjHHQoi (ORCPT ); Tue, 8 Aug 2023 12:44:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233311AbjHHQnp (ORCPT ); Tue, 8 Aug 2023 12:43:45 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06DFE91AE; Tue, 8 Aug 2023 08:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691510156; x=1723046156; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rne6Z00MCR3wZ1vIjFslt4JG7P23DQ8pQjYdbPRS0Vg=; b=NKqxWYiY/dDpd3UGIOTjWlIeFzZCm7VI7Kbu4GKD5wOnd2QQQKB2fKnA 3PrbEQi+4mRjDRkSzd8s9Y0yGfKXvKHLHqPdrJpi7DN5uaw71DyU84CdZ fD3gOxWt6gQeVhb+fxjkA8IiH8pzzsXcv7lv0XszozlKo8j2hINIvcl2V ioDCS6rRG3YNzs/wS/qxx/J0bSGCJI14MphXf7gorodIMvDSQC6t3Ktue A9JYCl67rMRi1vZnRSHZKveqQrbjNxC2/EOY7SHvFhJKM/3ZLHPDaSYeU HGtiHUhqHuI2pP9uOlDoz4No0IIWjX6dvT3BPwSXFylso/f5/eoI5djKH Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="437097780" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="437097780" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2023 02:16:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="977776813" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="977776813" Received: from mtofeni-mobl.ger.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.48.21]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2023 02:16:41 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: Shuah Khan , linux-kselftest@vger.kernel.org, Shuah Khan , Reinette Chatre , Maciej Wieczor-Retman , Fenghua Yu , Sai Praneeth Prakhya , Babu Moger , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 1/7] selftests/resctrl: Ensure the benchmark commands fits to its array Date: Tue, 8 Aug 2023 12:16:19 +0300 Message-Id: <20230808091625.12760-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230808091625.12760-1-ilpo.jarvinen@linux.intel.com> References: <20230808091625.12760-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Benchmark command is copied into an array in the stack. The array is BENCHMARK_ARGS items long but the command line could try to provide a longer command. Return error in case the benchmark command does not fit to its array. Fixes: ecdbb911f22d ("selftests/resctrl: Add MBM test") Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl_tests.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index d511daeb6851..eef9e02516ad 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -255,6 +255,9 @@ int main(int argc, char **argv) return ksft_exit_skip("Not running as root. Skipping...\n"); if (has_ben) { + if (argc - ben_ind >= BENCHMARK_ARGS - 1) + ksft_exit_fail_msg("Too long benchmark command"); + /* Extract benchmark command from command line. */ for (i = ben_ind; i < argc; i++) { benchmark_cmd[i - ben_ind] = benchmark_cmd_area[i];