Re: [PATCH] time: Validate the usec before covert to nsec in do_adjtimex

From: zhangxiaoxu (A)
Date: Mon Jul 08 2019 - 06:42:43 EST




在 2019/7/8 17:24, Thomas Gleixner 写道:
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.

That's correct, but the actuall inject function wants to keep the sanity
check,
timekeeping_inject_offset is called only by timekeeping_warp_clock and do_adjtimex.
The do_adjtimex already validate it, and timekeeping_warp_clock is set tv_nsec=0.
We keep the sanity check is for some other maybe use this function?
I had send a v2 to keep the sanity check in timekeeping_inject_offset.

Thanks.

Thanks,

tglx

.