]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.8-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Apr 2024 12:52:40 +0000 (14:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Apr 2024 12:52:40 +0000 (14:52 +0200)
added patches:
selftests-kselftest-mark-functions-that-unconditionally-call-exit-as-__noreturn.patch
selftests-timers-fix-abs-warning-in-posix_timers-test.patch
selftests-timers-fix-posix_timers-ksft_print_msg-warning.patch

queue-6.8/selftests-kselftest-mark-functions-that-unconditionally-call-exit-as-__noreturn.patch [new file with mode: 0644]
queue-6.8/selftests-timers-fix-abs-warning-in-posix_timers-test.patch [new file with mode: 0644]
queue-6.8/selftests-timers-fix-posix_timers-ksft_print_msg-warning.patch [new file with mode: 0644]
queue-6.8/series

diff --git a/queue-6.8/selftests-kselftest-mark-functions-that-unconditionally-call-exit-as-__noreturn.patch b/queue-6.8/selftests-kselftest-mark-functions-that-unconditionally-call-exit-as-__noreturn.patch
new file mode 100644 (file)
index 0000000..b676e8f
--- /dev/null
@@ -0,0 +1,111 @@
+From f7d5bcd35d427daac7e206b1073ca14f5db85c27 Mon Sep 17 00:00:00 2001
+From: Nathan Chancellor <nathan@kernel.org>
+Date: Thu, 11 Apr 2024 11:45:40 -0700
+Subject: selftests: kselftest: Mark functions that unconditionally call exit() as __noreturn
+
+From: Nathan Chancellor <nathan@kernel.org>
+
+commit f7d5bcd35d427daac7e206b1073ca14f5db85c27 upstream.
+
+After commit 6d029c25b71f ("selftests/timers/posix_timers: Reimplement
+check_timer_distribution()"), clang warns:
+
+  tools/testing/selftests/timers/../kselftest.h:398:6: warning: variable 'major' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
+    398 |         if (uname(&info) || sscanf(info.release, "%u.%u.", &major, &minor) != 2)
+        |             ^~~~~~~~~~~~
+  tools/testing/selftests/timers/../kselftest.h:401:9: note: uninitialized use occurs here
+    401 |         return major > min_major || (major == min_major && minor >= min_minor);
+        |                ^~~~~
+  tools/testing/selftests/timers/../kselftest.h:398:6: note: remove the '||' if its condition is always false
+    398 |         if (uname(&info) || sscanf(info.release, "%u.%u.", &major, &minor) != 2)
+        |             ^~~~~~~~~~~~~~~
+  tools/testing/selftests/timers/../kselftest.h:395:20: note: initialize the variable 'major' to silence this warning
+    395 |         unsigned int major, minor;
+        |                           ^
+        |                            = 0
+
+This is a false positive because if uname() fails, ksft_exit_fail_msg()
+will be called, which unconditionally calls exit(), a noreturn function.
+However, clang does not know that ksft_exit_fail_msg() will call exit() at
+the point in the pipeline that the warning is emitted because inlining has
+not occurred, so it assumes control flow will resume normally after
+ksft_exit_fail_msg() is called.
+
+Make it clear to clang that all of the functions that call exit()
+unconditionally in kselftest.h are noreturn transitively by marking them
+explicitly with '__attribute__((__noreturn__))', which clears up the
+warning above and any future warnings that may appear for the same reason.
+
+Fixes: 6d029c25b71f ("selftests/timers/posix_timers: Reimplement check_timer_distribution()")
+Reported-by: John Stultz <jstultz@google.com>
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Acked-by: Shuah Khan <skhan@linuxfoundation.org>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/r/20240411-mark-kselftest-exit-funcs-noreturn-v1-1-b027c948f586@kernel.org
+Closes: https://lore.kernel.org/all/20240410232637.4135564-2-jstultz@google.com/
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/testing/selftests/kselftest.h |   15 +++++++++------
+ 1 file changed, 9 insertions(+), 6 deletions(-)
+
+--- a/tools/testing/selftests/kselftest.h
++++ b/tools/testing/selftests/kselftest.h
+@@ -79,6 +79,9 @@
+ #define KSFT_XPASS 3
+ #define KSFT_SKIP  4
++#ifndef __noreturn
++#define __noreturn       __attribute__((__noreturn__))
++#endif
+ #define __printf(a, b)   __attribute__((format(printf, a, b)))
+ /* counters */
+@@ -255,13 +258,13 @@ static inline __printf(1, 2) void ksft_t
+       va_end(args);
+ }
+-static inline int ksft_exit_pass(void)
++static inline __noreturn int ksft_exit_pass(void)
+ {
+       ksft_print_cnts();
+       exit(KSFT_PASS);
+ }
+-static inline int ksft_exit_fail(void)
++static inline __noreturn int ksft_exit_fail(void)
+ {
+       ksft_print_cnts();
+       exit(KSFT_FAIL);
+@@ -288,7 +291,7 @@ static inline int ksft_exit_fail(void)
+                 ksft_cnt.ksft_xfail + \
+                 ksft_cnt.ksft_xskip)
+-static inline __printf(1, 2) int ksft_exit_fail_msg(const char *msg, ...)
++static inline __noreturn __printf(1, 2) int ksft_exit_fail_msg(const char *msg, ...)
+ {
+       int saved_errno = errno;
+       va_list args;
+@@ -303,19 +306,19 @@ static inline __printf(1, 2) int ksft_ex
+       exit(KSFT_FAIL);
+ }
+-static inline int ksft_exit_xfail(void)
++static inline __noreturn int ksft_exit_xfail(void)
+ {
+       ksft_print_cnts();
+       exit(KSFT_XFAIL);
+ }
+-static inline int ksft_exit_xpass(void)
++static inline __noreturn int ksft_exit_xpass(void)
+ {
+       ksft_print_cnts();
+       exit(KSFT_XPASS);
+ }
+-static inline __printf(1, 2) int ksft_exit_skip(const char *msg, ...)
++static inline __noreturn __printf(1, 2) int ksft_exit_skip(const char *msg, ...)
+ {
+       int saved_errno = errno;
+       va_list args;
diff --git a/queue-6.8/selftests-timers-fix-abs-warning-in-posix_timers-test.patch b/queue-6.8/selftests-timers-fix-abs-warning-in-posix_timers-test.patch
new file mode 100644 (file)
index 0000000..2a26a8d
--- /dev/null
@@ -0,0 +1,39 @@
+From ed366de8ec89d4f960d66c85fc37d9de22f7bf6d Mon Sep 17 00:00:00 2001
+From: John Stultz <jstultz@google.com>
+Date: Wed, 10 Apr 2024 16:26:30 -0700
+Subject: selftests: timers: Fix abs() warning in posix_timers test
+
+From: John Stultz <jstultz@google.com>
+
+commit ed366de8ec89d4f960d66c85fc37d9de22f7bf6d upstream.
+
+Building with clang results in the following warning:
+
+  posix_timers.c:69:6: warning: absolute value function 'abs' given an
+      argument of type 'long long' but has parameter of type 'int' which may
+      cause truncation of value [-Wabsolute-value]
+        if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
+            ^
+So switch to using llabs() instead.
+
+Fixes: 0bc4b0cf1570 ("selftests: add basic posix timers selftests")
+Signed-off-by: John Stultz <jstultz@google.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/r/20240410232637.4135564-3-jstultz@google.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/testing/selftests/timers/posix_timers.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/tools/testing/selftests/timers/posix_timers.c
++++ b/tools/testing/selftests/timers/posix_timers.c
+@@ -66,7 +66,7 @@ static int check_diff(struct timeval sta
+       diff = end.tv_usec - start.tv_usec;
+       diff += (end.tv_sec - start.tv_sec) * USECS_PER_SEC;
+-      if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
++      if (llabs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
+               printf("Diff too high: %lld..", diff);
+               return -1;
+       }
diff --git a/queue-6.8/selftests-timers-fix-posix_timers-ksft_print_msg-warning.patch b/queue-6.8/selftests-timers-fix-posix_timers-ksft_print_msg-warning.patch
new file mode 100644 (file)
index 0000000..06fa2cd
--- /dev/null
@@ -0,0 +1,47 @@
+From e4a6bceac98eba3c00e874892736b34ea5fdaca3 Mon Sep 17 00:00:00 2001
+From: John Stultz <jstultz@google.com>
+Date: Wed, 10 Apr 2024 16:26:28 -0700
+Subject: selftests: timers: Fix posix_timers ksft_print_msg() warning
+
+From: John Stultz <jstultz@google.com>
+
+commit e4a6bceac98eba3c00e874892736b34ea5fdaca3 upstream.
+
+After commit 6d029c25b71f ("selftests/timers/posix_timers: Reimplement
+check_timer_distribution()") the following warning occurs when building
+with an older gcc:
+
+posix_timers.c:250:2: warning: format not a string literal and no format arguments [-Wformat-security]
+  250 |  ksft_print_msg(errmsg);
+      |  ^~~~~~~~~~~~~~
+
+Fix this up by changing it to ksft_print_msg("%s", errmsg)
+
+Fixes: 6d029c25b71f ("selftests/timers/posix_timers: Reimplement check_timer_distribution()")
+Signed-off-by: John Stultz <jstultz@google.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Acked-by: Justin Stitt <justinstitt@google.com>
+Acked-by: Shuah Khan <skhan@linuxfoundation.org>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/r/20240410232637.4135564-1-jstultz@google.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/testing/selftests/timers/posix_timers.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tools/testing/selftests/timers/posix_timers.c b/tools/testing/selftests/timers/posix_timers.c
+index d86a0e00711e..348f47176e0a 100644
+--- a/tools/testing/selftests/timers/posix_timers.c
++++ b/tools/testing/selftests/timers/posix_timers.c
+@@ -247,7 +247,7 @@ static int check_timer_distribution(void)
+               ksft_test_result_skip("check signal distribution (old kernel)\n");
+       return 0;
+ err:
+-      ksft_print_msg(errmsg);
++      ksft_print_msg("%s", errmsg);
+       return -1;
+ }
+-- 
+2.44.0
+
index ac855ac6a933670d21a2f5eff3ac87e50a6a8803..5d0a8c7162670162ec7802483862a1888402997f 100644 (file)
@@ -142,3 +142,6 @@ vhost-add-smp_rmb-in-vhost_enable_notify.patch
 perf-x86-fix-out-of-range-data.patch
 x86-cpu-actually-turn-off-mitigations-by-default-for-speculation_mitigations-n.patch
 selftests-timers-posix_timers-reimplement-check_timer_distribution.patch
+selftests-timers-fix-posix_timers-ksft_print_msg-warning.patch
+selftests-timers-fix-abs-warning-in-posix_timers-test.patch
+selftests-kselftest-mark-functions-that-unconditionally-call-exit-as-__noreturn.patch