This is a note to let you know that I've just added the patch titled
minmax.h: use BUILD_BUG_ON_MSG() for the lo < hi test in clamp()
to the 6.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
minmax.h-use-build_bug_on_msg-for-the-lo-hi-test-in-clamp.patch
and it can be found in the queue-6.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.
>From [email protected] Fri Oct 3 14:27:07
>2025
From: Eliav Farber <[email protected]>
Date: Fri, 3 Oct 2025 12:15:17 +0000
Subject: minmax.h: use BUILD_BUG_ON_MSG() for the lo < hi test in clamp()
To: <[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>,
<[email protected]>, <[email protected]>,
<[email protected]>, <stable@vger.
kernel.org>, <[email protected]>
Cc: Arnd Bergmann <[email protected]>, Christoph Hellwig <[email protected]>,
Dan Carpenter <[email protected]>, "Jason A. Donenfeld"
<[email protected]>, Jens Axboe <[email protected]>, Lorenzo Stoakes
<[email protected]>, Mateusz Guzik <[email protected]>, "Matthew
Wilcox" <[email protected]>, Pedro Falcato <[email protected]>
Message-ID: <[email protected]>
From: David Laight <[email protected]>
[ Upstream commit a5743f32baec4728711bbc01d6ac2b33d4c67040 ]
Use BUILD_BUG_ON_MSG(statically_true(ulo > uhi), ...) for the sanity check
of the bounds in clamp(). Gives better error coverage and one less
expansion of the arguments.
Link:
https://lkml.kernel.org/r/[email protected]
Signed-off-by: David Laight <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Dan Carpenter <[email protected]>
Cc: Jason A. Donenfeld <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Lorenzo Stoakes <[email protected]>
Cc: Mateusz Guzik <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Pedro Falcato <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Eliav Farber <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
include/linux/minmax.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/include/linux/minmax.h
+++ b/include/linux/minmax.h
@@ -106,8 +106,7 @@
__auto_type uval = (val);
\
__auto_type ulo = (lo);
\
__auto_type uhi = (hi);
\
- static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)),
\
- (lo) <= (hi), true),
\
+ BUILD_BUG_ON_MSG(statically_true(ulo > uhi),
\
"clamp() low limit " #lo " greater than high limit " #hi);
\
BUILD_BUG_ON_MSG(!__types_ok3(uval, ulo, uhi),
\
"clamp("#val", "#lo", "#hi") signedness error");
\
Patches currently in stable-queue which might be from [email protected] are
queue-6.1/minmax-improve-macro-expansion-and-type-checking.patch
queue-6.1/minmax.h-simplify-the-variants-of-clamp.patch
queue-6.1/minmax.h-move-all-the-clamp-definitions-after-the-min-max-ones.patch
queue-6.1/minmax-don-t-use-max-in-situations-that-want-a-c-constant-expression.patch
queue-6.1/minmax.h-remove-some-defines-that-are-only-expanded-once.patch
queue-6.1/minmax.h-use-build_bug_on_msg-for-the-lo-hi-test-in-clamp.patch
queue-6.1/minmax-simplify-min-max-clamp-implementation.patch
queue-6.1/minmax.h-add-whitespace-around-operators-and-after-commas.patch
queue-6.1/minmax-fix-up-min3-and-max3-too.patch
queue-6.1/minmax.h-reduce-the-define-expansion-of-min-max-and-clamp.patch
queue-6.1/minmax.h-update-some-comments.patch