Commit bce69857 authored by Yu Liao's avatar Yu Liao Committed by Yang Yingliang
Browse files

time: Normalize timespec64 before timespec64_compare()

hulk inclusion
category: bugfix
bugzilla: 185831, https://gitee.com/openeuler/kernel/issues/I4MO2G


CVE: NA

-------------------------------------------------

Passing unnormalized timespec64 to timespec64_compare() may cause
incorrect results.

For example:
  wall_to_monotonic = {tv_sec = -10, tv_nsec = 900000000}
  ts_delta = {tv_sec = -9, tv_nsec = -900000000}

timespec64_compare() returns -1, but actually wall_to_monotonic > ts_delta.
This will cause wall_to_monotonic to become a positive number.

Use timespec64_sub() instead of direct subtraction to avoid this.

Signed-off-by: default avatarYu Liao <liaoyu15@huawei.com>
Reviewed-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent c12e68b4
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment