提交 56ef5ae6 编写于 作者: Z Zhang Xiaoxu 提交者: Xie XiuQi

timekeeping: Fix ktime_add overflow in tk_set_wall_to_mono

euler inclusion
category: bugfix
Bugzilla: 5380
CVE: N/A
----------------------------------------

Syzkaller report UBSAN bug:
UBSAN: Undefined behaviour in kernel/time/timekeeping.c:98:17
signed integer overflow:
8589935550743139462 + 2147483647000000000 cannot be represented
in type 'long long int'

Use add_time_safe instead add_time in tk_set_wall_to_mono.
Signed-off-by: NZhang Xiaoxu <zhangxiaoxu5@huawei.com>
Reviewed-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 22e88bfb
...@@ -144,7 +144,8 @@ static void tk_set_wall_to_mono(struct timekeeper *tk, struct timespec64 wtm) ...@@ -144,7 +144,8 @@ static void tk_set_wall_to_mono(struct timekeeper *tk, struct timespec64 wtm)
tk->wall_to_monotonic = wtm; tk->wall_to_monotonic = wtm;
set_normalized_timespec64(&tmp, -wtm.tv_sec, -wtm.tv_nsec); set_normalized_timespec64(&tmp, -wtm.tv_sec, -wtm.tv_nsec);
tk->offs_real = timespec64_to_ktime(tmp); tk->offs_real = timespec64_to_ktime(tmp);
tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tk->tai_offset, 0)); tk->offs_tai = ktime_add_safe(tk->offs_real,
ktime_set(tk->tai_offset, 0));
} }
static inline void tk_update_sleep_time(struct timekeeper *tk, ktime_t delta) static inline void tk_update_sleep_time(struct timekeeper *tk, ktime_t delta)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册