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] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240904-devel-anna-maria-b4-timers-flseep-v1-9-e98760256370@linutronix.de>
Date: Wed, 04 Sep 2024 15:04:59 +0200
From: Anna-Maria Behnsen <anna-maria@...utronix.de>
To: Frederic Weisbecker <frederic@...nel.org>, 
 Thomas Gleixner <tglx@...utronix.de>, Jonathan Corbet <corbet@....net>
Cc: linux-kernel@...r.kernel.org, Len Brown <len.brown@...el.com>, 
 "Rafael J. Wysocki" <rafael@...nel.org>, 
 Anna-Maria Behnsen <anna-maria@...utronix.de>, 
 Andy Whitcroft <apw@...onical.com>, Joe Perches <joe@...ches.com>
Subject: [PATCH 09/15] timers: Add a warning to usleep_range_state() for
 wrong order of arguments

There is a warning in checkpatch script that triggers, when min and max
arguments of usleep_range_state() are in reverse order. This check does
only cover callsites which uses constants. Move this check into the code as
a WARN_ON_ONCE() to also cover callsites not using constants and get rid of
it in checkpatch.

Cc: Andy Whitcroft <apw@...onical.com>
Cc: Joe Perches <joe@...ches.com>
Signed-off-by: Anna-Maria Behnsen <anna-maria@...utronix.de>
---
 kernel/time/sleep_timeout.c | 2 ++
 scripts/checkpatch.pl       | 4 ----
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/kernel/time/sleep_timeout.c b/kernel/time/sleep_timeout.c
index 1ebd8429a64a..e028e9b4b113 100644
--- a/kernel/time/sleep_timeout.c
+++ b/kernel/time/sleep_timeout.c
@@ -351,6 +351,8 @@ void __sched usleep_range_state(unsigned long min, unsigned long max,
 	ktime_t exp = ktime_add_us(ktime_get(), min);
 	u64 delta = (u64)(max - min) * NSEC_PER_USEC;
 
+	WARN_ON_ONCE(max < min);
+
 	for (;;) {
 		__set_current_state(state);
 		/* Do not return before the requested sleep time has elapsed */
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 39032224d504..ba3359bdd1fa 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -7088,10 +7088,6 @@ sub process {
 			if ($min eq $max) {
 				WARN("USLEEP_RANGE",
 				     "usleep_range should not use min == max args; see Documentation/timers/timers-howto.rst\n" . "$here\n$stat\n");
-			} elsif ($min =~ /^\d+$/ && $max =~ /^\d+$/ &&
-				 $min > $max) {
-				WARN("USLEEP_RANGE",
-				     "usleep_range args reversed, use min then max; see Documentation/timers/timers-howto.rst\n" . "$here\n$stat\n");
 			}
 		}
 

-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ