From: Greg Kroah-Hartman Date: Mon, 15 Apr 2024 12:52:40 +0000 (+0200) Subject: 6.8-stable patches X-Git-Tag: v5.15.156~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e31cc15622012c47aa7b18edc4a08ed0d4e016c;p=thirdparty%2Fkernel%2Fstable-queue.git 6.8-stable patches 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 --- 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 index 00000000000..b676e8f61b5 --- /dev/null +++ b/queue-6.8/selftests-kselftest-mark-functions-that-unconditionally-call-exit-as-__noreturn.patch @@ -0,0 +1,111 @@ +From f7d5bcd35d427daac7e206b1073ca14f5db85c27 Mon Sep 17 00:00:00 2001 +From: Nathan Chancellor +Date: Thu, 11 Apr 2024 11:45:40 -0700 +Subject: selftests: kselftest: Mark functions that unconditionally call exit() as __noreturn + +From: Nathan Chancellor + +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 +Signed-off-by: Nathan Chancellor +Signed-off-by: Thomas Gleixner +Acked-by: Shuah Khan +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 +--- + 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 index 00000000000..2a26a8d7992 --- /dev/null +++ b/queue-6.8/selftests-timers-fix-abs-warning-in-posix_timers-test.patch @@ -0,0 +1,39 @@ +From ed366de8ec89d4f960d66c85fc37d9de22f7bf6d Mon Sep 17 00:00:00 2001 +From: John Stultz +Date: Wed, 10 Apr 2024 16:26:30 -0700 +Subject: selftests: timers: Fix abs() warning in posix_timers test + +From: John Stultz + +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 +Signed-off-by: Thomas Gleixner +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/20240410232637.4135564-3-jstultz@google.com +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..06fa2cd4b5f --- /dev/null +++ b/queue-6.8/selftests-timers-fix-posix_timers-ksft_print_msg-warning.patch @@ -0,0 +1,47 @@ +From e4a6bceac98eba3c00e874892736b34ea5fdaca3 Mon Sep 17 00:00:00 2001 +From: John Stultz +Date: Wed, 10 Apr 2024 16:26:28 -0700 +Subject: selftests: timers: Fix posix_timers ksft_print_msg() warning + +From: John Stultz + +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 +Signed-off-by: Thomas Gleixner +Acked-by: Justin Stitt +Acked-by: Shuah Khan +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/20240410232637.4135564-1-jstultz@google.com +Signed-off-by: Greg Kroah-Hartman +--- + 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 + diff --git a/queue-6.8/series b/queue-6.8/series index ac855ac6a93..5d0a8c71626 100644 --- a/queue-6.8/series +++ b/queue-6.8/series @@ -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