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: <alpine.DEB.2.21.1906170814590.1760@nanos.tec.linutronix.de>
Date:   Mon, 17 Jun 2019 09:21:04 +0200 (CEST)
From:   Thomas Gleixner <tglx@...utronix.de>
To:     Weikang shi <swkhack@...il.com>
cc:     John Stultz <john.stultz@...aro.org>, sboyd@...nel.org,
        LKML <linux-kernel@...r.kernel.org>, swkhack@...com,
        Miroslav Lichvar <mlichvar@...hat.com>
Subject: Re: [PATCH] time: fix a assignment error in ntp module

On Mon, 22 Apr 2019, Weikang shi wrote:

> From: swkhack <swkhack@...il.com>
> 
> It is meanless to check a 64bit(txc->constant) value is postive 
> when the value has to be assigned to a 32 bit variable(*time_tai).
> So I make a temp type conversion before the compare.

What? Casting it to int makes it more negative, right?

That's just wrong:

       long long x = 0xFFFFFFFF00000000;
       int y = (int) x;

x is obviously negative, but y not. C type casting 101.

> Signed-off-by: swkhack <swkhack@...il.com>
> ---
>  kernel/time/ntp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
> index 92a90014a..6b454eafc 100644
> --- a/kernel/time/ntp.c
> +++ b/kernel/time/ntp.c
> @@ -690,7 +690,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
>  		time_constant = max(time_constant, 0l);
>  	}
>  
> -	if (txc->modes & ADJ_TAI && txc->constant > 0)
> +	if (txc->modes & ADJ_TAI && (int)txc->constant > 0)
>  		*time_tai = txc->constant;

The way more interesting question is whether txc->constant can be >
UINT_MAX. In that case the txc->constant would be truncated.

Miroslav?

Thanks,

	tglx


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ