]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
kselftest/arm64: mte: use string literal for printf-style functions
authorAndre Przywara <andre.przywara@arm.com>
Fri, 16 Aug 2024 15:32:47 +0000 (16:32 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Thu, 17 Oct 2024 17:54:11 +0000 (18:54 +0100)
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.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20240816153251.2833702-5-andre.przywara@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
tools/testing/selftests/arm64/mte/mte_common_util.h

index 2d3e71724e55c3a98680f42fa59194584bbbb42c..a0017a303beb28cf3e3822667295ca5cae999328 100644 (file)
@@ -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",