Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/vdso/32: Use 32bit syscall fallback

The generic VDSO implementation uses the Y2038 safe clock_gettime64() and
clock_getres_time64() syscalls as fallback for 32bit VDSO. This breaks
seccomp setups because these syscalls might be not (yet) allowed.

Implement the 32bit variants which use the legacy syscalls and select the
variant in the core library.

The 64bit time variants are not removed because they are required for the
time64 based vdso accessors.

Fixes: 7ac870747988 ("x86/vdso: Switch to generic vDSO implementation")
Reported-by: Sean Christopherson <sean.j.christopherson@intel.com>
Reported-by: Paul Bolle <pebolle@tiscali.nl>
Suggested-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Link: https://lkml.kernel.org/r/20190728131648.879156507@linutronix.de

+36
+36
arch/x86/include/asm/vdso/gettimeofday.h
··· 96 96 97 97 #else 98 98 99 + #define VDSO_HAS_32BIT_FALLBACK 1 100 + 99 101 static __always_inline 100 102 long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts) 101 103 { ··· 110 108 "mov %%edx, %%ebx \n" 111 109 : "=a" (ret), "=m" (*_ts) 112 110 : "0" (__NR_clock_gettime64), [clock] "g" (_clkid), "c" (_ts) 111 + : "edx"); 112 + 113 + return ret; 114 + } 115 + 116 + static __always_inline 117 + long clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts) 118 + { 119 + long ret; 120 + 121 + asm ( 122 + "mov %%ebx, %%edx \n" 123 + "mov %[clock], %%ebx \n" 124 + "call __kernel_vsyscall \n" 125 + "mov %%edx, %%ebx \n" 126 + : "=a" (ret), "=m" (*_ts) 127 + : "0" (__NR_clock_gettime), [clock] "g" (_clkid), "c" (_ts) 113 128 : "edx"); 114 129 115 130 return ret; ··· 162 143 "mov %%edx, %%ebx \n" 163 144 : "=a" (ret), "=m" (*_ts) 164 145 : "0" (__NR_clock_getres_time64), [clock] "g" (_clkid), "c" (_ts) 146 + : "edx"); 147 + 148 + return ret; 149 + } 150 + 151 + static __always_inline 152 + long clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts) 153 + { 154 + long ret; 155 + 156 + asm ( 157 + "mov %%ebx, %%edx \n" 158 + "mov %[clock], %%ebx \n" 159 + "call __kernel_vsyscall \n" 160 + "mov %%edx, %%ebx \n" 161 + : "=a" (ret), "=m" (*_ts) 162 + : "0" (__NR_clock_getres), [clock] "g" (_clkid), "c" (_ts) 165 163 : "edx"); 166 164 167 165 return ret;