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] [thread-next>] [day] [month] [year] [list]
Message-ID: <871q64n5dr.ffs@tglx>
Date: Tue, 14 May 2024 10:51:12 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: Justin Stitt <justinstitt@...gle.com>, John Stultz <jstultz@...gle.com>
Cc: Stephen Boyd <sboyd@...nel.org>, Nathan Chancellor <nathan@...nel.org>,
 Bill Wendling <morbo@...gle.com>, linux-kernel@...r.kernel.org,
 llvm@...ts.linux.dev
Subject: Re: [PATCH] ntp: safeguard against time_constant overflow case

On Tue, May 07 2024 at 22:03, Justin Stitt wrote:
> On Mon, May 06, 2024 at 11:02:17PM -0700, John Stultz wrote:
>> > @@ -734,10 +737,10 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
>> >
>> >         if (txc->modes & ADJ_TIMECONST) {
>> >                 time_constant = txc->constant;
>> > -               if (!(time_status & STA_NANO))
>> > -                       time_constant += 4;
>> > -               time_constant = min(time_constant, (long)MAXTC);
>> > -               time_constant = max(time_constant, 0l);
>> > +               if (!(time_status & STA_NANO) &&
>> > +                   unlikely(LONG_MAX - time_constant_inc >= time_constant))
>> > +                       time_constant += time_constant_inc;
>> > +               time_constant = clamp_t(long, time_constant, 0, MAXTC);
>> >         }
>> 
>> Overall, this looks fine. Though the time_status conditional is now a
>> little unwieldy.
>> 
>> I wonder if some sort of a helper like:
>>       time_constant = safe_add(time_constant, TIME_CONSTANT_INC, LONG_MAX);
>> 
>> Might make this a little easier to read?
>
> How about something like this:
>
> 	if (txc->modes & ADJ_TIMECONST) {
> 		if (!(time_status & STA_NANO))
> 			time_constant = clamp_t(long, txc->constant,
> 						-TIME_CONSTANT_INC,
> 						MAXTC - TIME_CONSTANT_INC) +
> 						TIME_CONSTANT_INC;
> 		else
> 			time_constant = clamp_t(long, txc->constant, 0, MAXTC);
> 	}
>
> We can remove the initial assignment and use some fancy clamps.

That's unreadable TBH.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ