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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6de4bef3-35e7-474f-8232-d951f7732aa0@nfschina.com>
Date: Tue, 29 Apr 2025 09:12:03 +0800
From: Su Hui <suhui@...china.com>
To: John Stultz <jstultz@...gle.com>
Cc: tglx@...utronix.de, sboyd@...nel.org, linux-kernel@...r.kernel.org,
 kernel-janitors@...r.kernel.org
Subject: Re: [PATCH v2 2/3] alarmtimer: remove dead return value in
 clock2alarm()

On 2025/4/29 07:03, John Stultz wrote:
> On Sun, Apr 27, 2025 at 4:35 AM Su Hui <suhui@...china.com> wrote:
>> 'clockid' only can be ALARM_REALTIME and ALARM_BOOTTIME. It's impossible
>> to return -1 and callers never check the value of -1.
>>
>> Only alarm_clock_get_timespec(), alarm_clock_get_ktime(),
>> alarm_timer_create() and alarm_timer_nsleep() call clock2alarm(). These
>> callers using clockid_to_kclock() to get 'struct k_clock', this ensures
>> clock2alarm() never returns -1.
>>
>> Signed-off-by: Su Hui <suhui@...china.com>
>> ---
>> v2:
>>   - No Change.
>>   kernel/time/alarmtimer.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
>> index 0ddccdff119a..e5450a77ada9 100644
>> --- a/kernel/time/alarmtimer.c
>> +++ b/kernel/time/alarmtimer.c
>> @@ -515,9 +515,9 @@ static enum alarmtimer_type clock2alarm(clockid_t clockid)
>>   {
>>          if (clockid == CLOCK_REALTIME_ALARM)
>>                  return ALARM_REALTIME;
>> -       if (clockid == CLOCK_BOOTTIME_ALARM)
>> -               return ALARM_BOOTTIME;
>> -       return -1;
>> +
>> +       /* CLOCK_BOOTTIME_ALARM case */
>> +       return ALARM_BOOTTIME;
> So, I think your change is a good one, as the error case of -1 is never checked.
> But it might be worth adding a WARN_ON_ONCE() if the clockid isn't
> CLOCK_REALTIME_ALARM or CLOCK_BOOTTIME_ALARM, just so there aren't any
> surprises if someone misuses the function.
Yes, it's better to add WARN_ON_ONCE().
Will update in v3 patch. Thanks for your suggestion.

Su Hui


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ