Skip to content

Commit 7b84744

Browse files
0x7f454c46KAGA-KOKO
authored andcommitted
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: 98f7620 ("compat: Cleanup in_compat_syscall() callers") Reported-by: Ben Hutchings <[email protected]> Signed-off-by: Dmitry Safonov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent af42d34 commit 7b84744

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/time/time.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,8 @@ int get_timespec64(struct timespec64 *ts,
881881
ts->tv_sec = kts.tv_sec;
882882

883883
/* Zero out the padding for 32 bit systems or in compat mode */
884-
if (IS_ENABLED(CONFIG_64BIT_TIME) && in_compat_syscall())
884+
if (IS_ENABLED(CONFIG_64BIT_TIME) && (!IS_ENABLED(CONFIG_64BIT) ||
885+
in_compat_syscall()))
885886
kts.tv_nsec &= 0xFFFFFFFFUL;
886887

887888
ts->tv_nsec = kts.tv_nsec;

0 commit comments

Comments
 (0)