lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20240109215406.18218-3-mirsad.todorovac@alu.unizg.hr>
Date: Tue,  9 Jan 2024 22:54:08 +0100
From: Mirsad Todorovac <mirsad.todorovac@....unizg.hr>
To: Mirsad Todorovac <mirsad.todorovac@....unizg.hr>,
	linux-kselftest@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: Shuah Khan <shuah@...nel.org>,
	Paul Elder <paul.elder@...t.edu>,
	Alice Ferrazzi <alice.ferrazzi@...il.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: [PATCH v1 2/2] selftest: breakpoints: clear the format string warning and secure the output

GCC 13.2.0 compiler reported the following warning:

breakpoint_test.c: In function ‘check_success’:
breakpoint_test.c:287:17: warning: format not a string literal and no format arguments [-Wformat-security]
  287 |                 ksft_test_result_pass(msg);
      |                 ^~~~~~~~~~~~~~~~~~~~~
breakpoint_test.c:289:17: warning: format not a string literal and no format arguments [-Wformat-security]
  289 |                 ksft_test_result_fail(msg);
      |                 ^~~~~~~~~~~~~~~~~~~~~

ksft_*() functions are unprotected against potential spurious format specifiers
in msg.

Protecting the conversion with "%s\n" format string fixes the warning.

Fixes: 748e84b79af01 ("kselftest: breakpoints: convert breakpoint_test to TAP13 output")
Cc: Paul Elder <paul.elder@...t.edu>
Cc: Alice Ferrazzi <alice.ferrazzi@...il.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Shuah Khan <shuah@...nel.org>
Cc: linux-kselftest@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Mirsad Todorovac <mirsad.todorovac@....unizg.hr>
---
 tools/testing/selftests/breakpoints/breakpoint_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/breakpoints/breakpoint_test.c b/tools/testing/selftests/breakpoints/breakpoint_test.c
index 3266cc9293fe..07249251859b 100644
--- a/tools/testing/selftests/breakpoints/breakpoint_test.c
+++ b/tools/testing/selftests/breakpoints/breakpoint_test.c
@@ -284,9 +284,9 @@ static void check_success(const char *msg)
 	nr_tests++;
 
 	if (ret)
-		ksft_test_result_pass(msg);
+		ksft_test_result_pass("%s\n", msg);
 	else
-		ksft_test_result_fail(msg);
+		ksft_test_result_fail("%s\n", msg);
 }
 
 static void launch_instruction_breakpoints(char *buf, int local, int global)
-- 
2.40.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ