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

mips: compat: vdso: Use legacy syscalls as 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.

Cc: Paul Burton <paul.burton@mips.com>
Fixes: 00b26474c2f1 ("lib/vdso: Provide generic VDSO implementation")
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: linux-arch@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org
Cc: catalin.marinas@arm.com
Cc: will@kernel.org
Cc: tglx@linutronix.de
Cc: salyzyn@android.com
Cc: 0x7f454c46@gmail.com
Cc: luto@kernel.org

authored by

Vincenzo Frascino and committed by
Paul Burton
932bb934 3d77a95f

+46
+45
arch/mips/include/asm/vdso/gettimeofday.h
··· 105 105 return error ? -ret : ret; 106 106 } 107 107 108 + #if _MIPS_SIM != _MIPS_SIM_ABI64 109 + 110 + #define VDSO_HAS_32BIT_FALLBACK 1 111 + 112 + static __always_inline long clock_gettime32_fallback( 113 + clockid_t _clkid, 114 + struct old_timespec32 *_ts) 115 + { 116 + register struct old_timespec32 *ts asm("a1") = _ts; 117 + register clockid_t clkid asm("a0") = _clkid; 118 + register long ret asm("v0"); 119 + register long nr asm("v0") = __NR_clock_gettime; 120 + register long error asm("a3"); 121 + 122 + asm volatile( 123 + " syscall\n" 124 + : "=r" (ret), "=r" (error) 125 + : "r" (clkid), "r" (ts), "r" (nr) 126 + : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", 127 + "$14", "$15", "$24", "$25", "hi", "lo", "memory"); 128 + 129 + return error ? -ret : ret; 130 + } 131 + 132 + static __always_inline int clock_getres32_fallback( 133 + clockid_t _clkid, 134 + struct old_timespec32 *_ts) 135 + { 136 + register struct old_timespec32 *ts asm("a1") = _ts; 137 + register clockid_t clkid asm("a0") = _clkid; 138 + register long ret asm("v0"); 139 + register long nr asm("v0") = __NR_clock_getres; 140 + register long error asm("a3"); 141 + 142 + asm volatile( 143 + " syscall\n" 144 + : "=r" (ret), "=r" (error) 145 + : "r" (clkid), "r" (ts), "r" (nr) 146 + : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", 147 + "$14", "$15", "$24", "$25", "hi", "lo", "memory"); 148 + 149 + return error ? -ret : ret; 150 + } 151 + #endif 152 + 108 153 #ifdef CONFIG_CSRC_R4K 109 154 110 155 static __always_inline u64 read_r4k_count(void)
+1
arch/mips/vdso/config-n32-o32-env.c
··· 10 10 */ 11 11 #undef CONFIG_64BIT 12 12 13 + #define BUILD_VDSO32 13 14 #define CONFIG_32BIT 1 14 15 #define CONFIG_GENERIC_ATOMIC64 1 15 16 #define BUILD_VDSO32_64