diff options
author | Dmitry Safonov <dima@arista.com> | 2019-11-21 00:03:03 +0000 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2019-11-21 01:17:58 +0100 |
commit | 7b8474466ed97be458c825f34a85f2c2b84c3f95 (patch) | |
tree | adffb97ae9965400c9975048ec02b65dfb16e89a /kernel | |
parent | af42d3466bdc8f39806b26f593604fdc54140bcb (diff) | |
download | linux-stable-7b8474466ed97be458c825f34a85f2c2b84c3f95.tar.gz linux-stable-7b8474466ed97be458c825f34a85f2c2b84c3f95.tar.bz2 linux-stable-7b8474466ed97be458c825f34a85f2c2b84c3f95.zip |
time: Zero the upper 32-bits in __kernel_timespec on 32-bit
On compat interfaces, the high order bits of nanoseconds should be zeroed
out. This is because the application code or the libc do not guarantee
zeroing of these. If used without zeroing, kernel might be at risk of using
timespec values incorrectly.
Originally it was handled correctly, but lost during is_compat_syscall()
cleanup. Revert the condition back to check CONFIG_64BIT.
Fixes: 98f76206b335 ("compat: Cleanup in_compat_syscall() callers")
Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20191121000303.126523-1-dima@arista.com
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/time/time.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/time/time.c b/kernel/time/time.c index 5c54ca632d08..83f403e7a15c 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -881,7 +881,8 @@ int get_timespec64(struct timespec64 *ts, ts->tv_sec = kts.tv_sec; /* Zero out the padding for 32 bit systems or in compat mode */ - if (IS_ENABLED(CONFIG_64BIT_TIME) && in_compat_syscall()) + if (IS_ENABLED(CONFIG_64BIT_TIME) && (!IS_ENABLED(CONFIG_64BIT) || + in_compat_syscall())) kts.tv_nsec &= 0xFFFFFFFFUL; ts->tv_nsec = kts.tv_nsec; |