Message ID | 20250221164929.357460-1-paul.barker.ct@bp.renesas.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [4.4.y-st] posix-clock: Fix backported timespec64 check | expand |
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c index 74468c1dd74c..bd78bfa48666 100644 --- a/kernel/time/posix-clock.c +++ b/kernel/time/posix-clock.c @@ -342,7 +342,7 @@ static int pc_clock_settime(clockid_t id, const struct timespec *ts) struct posix_clock_desc cd; int err; - if (!timespec64_valid_strict(ts)) + if (!timespec64_valid_strict(&ts64)) return -EINVAL; err = get_clock_desc(id, &cd);
The backported check calls timespec64_valid_strict(ts), but in linux-4.4.y-st the `ts` argument is not a timespec64 instance. This leads to the following warning: kernel/time/posix-clock.c: In function 'pc_clock_settime': kernel/time/posix-clock.c:345:31: warning: passing argument 1 of 'timespec64_valid_strict' from incompatible pointer type [-Wincompatible-pointer-types] if (!timespec64_valid_strict(ts)) ^~ In file included from include/linux/time.h:7:0, from include/linux/ktime.h:24, from include/linux/rcupdate.h:47, from include/linux/idr.h:18, from include/linux/kernfs.h:14, from include/linux/sysfs.h:15, from include/linux/kobject.h:21, from include/linux/device.h:17, from kernel/time/posix-clock.c:20: include/linux/time64.h:181:20: note: expected 'const struct timespec64 *' but argument is of type 'const struct timespec *' static inline bool timespec64_valid_strict(const struct timespec64 *ts) ^~~~~~~~~~~~~~~~~~~~~~~ As struct timespec64 is larger than struct timespec, this could result in out-of-bounds memory access. Fix this by passing the converted timespec64 instance to timespec64_valid_strict(). Fixes: 40ec979c6d01 ("posix-clock: Fix missing timespec64 check in pc_clock_settime()") Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com> --- This patch has been tested on RZ/G1M using the linux-4.4.y-cip tree, but I'm sending it for linux-4.4.y-st as the issue is also present there. I currently have no way to test the -st tree without the corresponding cip patches. kernel/time/posix-clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)