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]
Date:   Mon, 8 Jul 2019 15:04:21 +0200 (CEST)
From:   Thomas Gleixner <tglx@...utronix.de>
To:     ZhangXiaoxu <zhangxiaoxu5@...wei.com>
cc:     john.stultz@...aro.org, sboyd@...nel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [v2] time: Validate the usec before covert to nsec in
 do_adjtimex

On Mon, 8 Jul 2019, ZhangXiaoxu wrote:

> When covert the usec to nsec, it will multiple 1000, it maybe
> overflow and lead an undefined behavior.
> 
> For example, users may input an negative tv_usec values when
> call adjtimex syscall, then multiple 1000 maybe overflow it
> to a positive and legal number.
> 
> So, we should validate the usec before coverted it to nsec.

Looking deeper before applying it. That change is wrong for two reasons:

 1) The value is already validated in timekeeping_validate_timex()

 2) The tv_usec value can legitimately be >= USEC_PER_SEC if the ADJ_NANO
    mode bit is set. See timekeeping_validate_timex() and the code you
    actually modified:

>  	if (txc->modes & ADJ_SETOFFSET) {
>  		struct timespec64 delta;
> +
> +		if (txc->time.tv_usec < 0 || txc->time.tv_usec >= USEC_PER_SEC)
> +			return -EINVAL;
>  		delta.tv_sec  = txc->time.tv_sec;
>  		delta.tv_nsec = txc->time.tv_usec;
>  		if (!(txc->modes & ADJ_NANO))
			delta.tv_nsec *= 1000;

    	The multiplication is conditional ....

Thanks,

	tglx


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ