Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>, Shuah Khan <shuah@kernel.org>
Cc: Mark Brown <broonie@kernel.org>,
	Amit Daniel Kachhap <amit.kachhap@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kselftest@vger.kernel.org
Subject: [PATCH 4/8] kselftest/arm64: mte: use string literal for printf-style functions
Date: Fri, 16 Aug 2024 16:32:47 +0100	[thread overview]
Message-ID: <20240816153251.2833702-5-andre.przywara@arm.com> (raw)
In-Reply-To: <20240816153251.2833702-1-andre.przywara@arm.com>

Using pointers for the format specifier strings in printf-style
functions can create potential security problems, as the number of
arguments to be parsed could vary from call to call. Most compilers
consequently warn about those:
"format not a string literal and no format arguments [-Wformat-security]"

If we only want to print a constant string, we can just use a fixed "%s"
format instead, and pass the string as an argument.

Fixes: e9b60476bea0 ("kselftest/arm64: Add utilities and a test to validate mte memory")
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 tools/testing/selftests/arm64/mte/mte_common_util.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/arm64/mte/mte_common_util.h b/tools/testing/selftests/arm64/mte/mte_common_util.h
index 2d3e71724e55c..a0017a303beb2 100644
--- a/tools/testing/selftests/arm64/mte/mte_common_util.h
+++ b/tools/testing/selftests/arm64/mte/mte_common_util.h
@@ -77,13 +77,13 @@ static inline void evaluate_test(int err, const char *msg)
 {
 	switch (err) {
 	case KSFT_PASS:
-		ksft_test_result_pass(msg);
+		ksft_test_result_pass("%s", msg);
 		break;
 	case KSFT_FAIL:
-		ksft_test_result_fail(msg);
+		ksft_test_result_fail("%s", msg);
 		break;
 	case KSFT_SKIP:
-		ksft_test_result_skip(msg);
+		ksft_test_result_skip("%s", msg);
 		break;
 	default:
 		ksft_test_result_error("Unknown return code %d from %s",
-- 
2.25.1


  parent reply	other threads:[~2024-08-16 15:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-16 15:32 [PATCH 0/8] kselftest/arm64: various compilation fixes Andre Przywara
2024-08-16 15:32 ` [PATCH 1/8] kselftest/arm64: signal: drop now redundant GNU_SOURCE definition Andre Przywara
2024-08-16 16:24   ` Mark Brown
2024-08-16 15:32 ` [PATCH 2/8] kselftest/arm64: hwcap: fix f8dp2 cpuinfo name Andre Przywara
2024-08-16 16:24   ` Mark Brown
2024-08-16 15:32 ` [PATCH 3/8] kselftest/arm64: mte: use proper SKIP syntax Andre Przywara
2024-08-16 16:25   ` Mark Brown
2024-08-16 15:32 ` Andre Przywara [this message]
2024-08-16 16:26   ` [PATCH 4/8] kselftest/arm64: mte: use string literal for printf-style functions Mark Brown
2024-08-16 15:32 ` [PATCH 5/8] kselftest/arm64: mte: fix printf type warning about mask Andre Przywara
2024-08-16 16:30   ` Mark Brown
2024-08-16 16:55     ` Andre Przywara
2024-08-16 17:07       ` Mark Brown
2024-08-16 15:32 ` [PATCH 6/8] kselftest/arm64: mte: fix printf type warnings about __u64 Andre Przywara
2024-08-16 16:31   ` Mark Brown
2024-08-16 15:32 ` [PATCH 7/8] kselftest/arm64: mte: fix printf type warnings about pointers Andre Przywara
2024-08-16 16:32   ` Mark Brown
2024-08-16 16:59     ` Andre Przywara
2024-08-16 17:12       ` Mark Brown
2024-08-16 15:32 ` [PATCH 8/8] kselftest/arm64: mte: fix printf type warnings about longs Andre Przywara
2024-08-16 16:33   ` Mark Brown
2024-10-17 17:59 ` (subset) [PATCH 0/8] kselftest/arm64: various compilation fixes Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240816153251.2833702-5-andre.przywara@arm.com \
    --to=andre.przywara@arm.com \
    --cc=amit.kachhap@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox