diff --git a/arch/Kconfig b/arch/Kconfig index de39e65a9a0f..45c657772362 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1699,7 +1699,6 @@ config HAVE_SPARSE_SYSCALL_NR related optimizations for a given architecture. config ARCH_HAS_VDSO_ARCH_DATA - depends on HAVE_GENERIC_VDSO bool config ARCH_HAS_VDSO_TIME_DATA diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig index 871bd58d2ccc..f7bea397a201 100644 --- a/arch/arm/mm/Kconfig +++ b/arch/arm/mm/Kconfig @@ -924,7 +924,6 @@ config VDSO bool "Enable VDSO for acceleration of some system calls" depends on AEABI && MMU && CPU_V7 default y if ARM_ARCH_TIMER - select HAVE_GENERIC_VDSO select GENERIC_GETTIMEOFDAY help Place in the process address space an ELF shared object diff --git a/arch/arm/vdso/vdso.lds.S b/arch/arm/vdso/vdso.lds.S index 74d8d8bc8a40..e61038c0195a 100644 --- a/arch/arm/vdso/vdso.lds.S +++ b/arch/arm/vdso/vdso.lds.S @@ -70,9 +70,11 @@ VERSION { LINUX_2.6 { global: +#ifdef CONFIG_COMPAT_32BIT_TIME __vdso_clock_gettime; __vdso_gettimeofday; __vdso_clock_getres; +#endif /* CONFIG_COMPAT_32BIT_TIME */ __vdso_clock_gettime64; __vdso_clock_getres_time64; local: *; diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c index f7a2f5dc2fdc..3eebeddbfd18 100644 --- a/arch/arm/vdso/vgettimeofday.c +++ b/arch/arm/vdso/vgettimeofday.c @@ -10,16 +10,17 @@ #include #include +#ifdef CONFIG_COMPAT_32BIT_TIME int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) { return __cvdso_clock_gettime32(clock, ts); } -int __vdso_clock_gettime64(clockid_t clock, - struct __kernel_timespec *ts) +int __vdso_clock_getres(clockid_t clock_id, + struct old_timespec32 *res) { - return __cvdso_clock_gettime(clock, ts); + return __cvdso_clock_getres_time32(clock_id, res); } int __vdso_gettimeofday(struct __kernel_old_timeval *tv, @@ -27,11 +28,12 @@ int __vdso_gettimeofday(struct __kernel_old_timeval *tv, { return __cvdso_gettimeofday(tv, tz); } +#endif /* CONFIG_COMPAT_32BIT_TIME */ -int __vdso_clock_getres(clockid_t clock_id, - struct old_timespec32 *res) +int __vdso_clock_gettime64(clockid_t clock, + struct __kernel_timespec *ts) { - return __cvdso_clock_getres_time32(clock_id, res); + return __cvdso_clock_gettime(clock, ts); } int __vdso_clock_getres_time64(clockid_t clock_id, struct __kernel_timespec *res) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index eca8d9e518b1..440c1015eb38 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -229,7 +229,6 @@ config ARM64 select HAVE_SYSCALL_TRACEPOINTS select HAVE_KPROBES select HAVE_KRETPROBES - select HAVE_GENERIC_VDSO select HOTPLUG_CORE_SYNC_DEAD if HOTPLUG_CPU select HOTPLUG_SMT if HOTPLUG_CPU select IRQ_DOMAIN diff --git a/arch/arm64/kernel/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32/vdso.lds.S index c374fb0146f3..12bfc39e8aab 100644 --- a/arch/arm64/kernel/vdso32/vdso.lds.S +++ b/arch/arm64/kernel/vdso32/vdso.lds.S @@ -82,9 +82,11 @@ VERSION { LINUX_2.6 { global: +#ifdef CONFIG_COMPAT_32BIT_TIME __vdso_clock_gettime; __vdso_gettimeofday; __vdso_clock_getres; +#endif /* CONFIG_COMPAT_32BIT_TIME */ __vdso_clock_gettime64; __vdso_clock_getres_time64; local: *; diff --git a/arch/arm64/kernel/vdso32/vgettimeofday.c b/arch/arm64/kernel/vdso32/vgettimeofday.c index 0c6998ebe491..12d0255cc2cf 100644 --- a/arch/arm64/kernel/vdso32/vgettimeofday.c +++ b/arch/arm64/kernel/vdso32/vgettimeofday.c @@ -8,16 +8,17 @@ #define BUILD_VDSO32_64 #include +#ifdef CONFIG_COMPAT_32BIT_TIME int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) { return __cvdso_clock_gettime32(clock, ts); } -int __vdso_clock_gettime64(clockid_t clock, - struct __kernel_timespec *ts) +int __vdso_clock_getres(clockid_t clock_id, + struct old_timespec32 *res) { - return __cvdso_clock_gettime(clock, ts); + return __cvdso_clock_getres_time32(clock_id, res); } int __vdso_gettimeofday(struct __kernel_old_timeval *tv, @@ -25,11 +26,12 @@ int __vdso_gettimeofday(struct __kernel_old_timeval *tv, { return __cvdso_gettimeofday(tv, tz); } +#endif /* CONFIG_COMPAT_32BIT_TIME */ -int __vdso_clock_getres(clockid_t clock_id, - struct old_timespec32 *res) +int __vdso_clock_gettime64(clockid_t clock, + struct __kernel_timespec *ts) { - return __cvdso_clock_getres_time32(clock_id, res); + return __cvdso_clock_gettime(clock, ts); } int __vdso_clock_getres_time64(clockid_t clock_id, struct __kernel_timespec *res) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index d8d252325017..41ed648fcec9 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -153,7 +153,6 @@ config LOONGARCH select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER select HAVE_GCC_PLUGINS - select HAVE_GENERIC_VDSO select HAVE_HW_BREAKPOINT if PERF_EVENTS select HAVE_IOREMAP_PROT select HAVE_IRQ_EXIT_ON_IRQ_STACK @@ -213,6 +212,7 @@ config LOONGARCH select TRACE_IRQFLAGS_SUPPORT select USE_PERCPU_NUMA_NODE_ID select USER_STACKTRACE_SUPPORT + select VDSO_DATASTORE select VDSO_GETRANDOM select ZONE_DMA32 if 64BIT diff --git a/arch/loongarch/kernel/time.c b/arch/loongarch/kernel/time.c index dbaaabcaf6f0..5892f6da07a5 100644 --- a/arch/loongarch/kernel/time.c +++ b/arch/loongarch/kernel/time.c @@ -212,9 +212,7 @@ static struct clocksource clocksource_const = { .read = read_const_counter, .mask = CLOCKSOURCE_MASK(64), .flags = CLOCK_SOURCE_IS_CONTINUOUS, -#ifdef CONFIG_GENERIC_GETTIMEOFDAY .vdso_clock_mode = VDSO_CLOCKMODE_CPU, -#endif }; int __init constant_clocksource_init(void) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 8555bbf47c63..a06f24317306 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -3163,7 +3163,6 @@ config MIPS_EXTERNAL_TIMER config MIPS_GENERIC_GETTIMEOFDAY def_bool y select GENERIC_GETTIMEOFDAY - select HAVE_GENERIC_VDSO depends on CSRC_R4K || CLKSRC_MIPS_GIC # GCC (at least up to version 9.2) appears to emit function calls that make use # of the GOT when targeting microMIPS, which we can't use in the VDSO due to diff --git a/arch/mips/kernel/csrc-r4k.c b/arch/mips/kernel/csrc-r4k.c index 241a934543a8..59eca397f297 100644 --- a/arch/mips/kernel/csrc-r4k.c +++ b/arch/mips/kernel/csrc-r4k.c @@ -126,14 +126,12 @@ int __init init_r4k_clocksource(void) clocksource_mips.rating = 200; clocksource_mips.rating += clamp(mips_hpt_frequency / 10000000, 0, 99); -#ifdef CONFIG_GENERIC_GETTIMEOFDAY /* * R2 onwards makes the count accessible to user mode so it can be used * by the VDSO (HWREna is configured by configure_hwrena()). */ if (cpu_has_mips_r2_r6 && rdhwr_count_usable()) clocksource_mips.vdso_clock_mode = VDSO_CLOCKMODE_R4K; -#endif clocksource_register_hz(&clocksource_mips, mips_hpt_frequency); diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c index bd1fc17d3975..29a10045f2b6 100644 --- a/arch/mips/kernel/vdso.c +++ b/arch/mips/kernel/vdso.c @@ -129,7 +129,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) * This ensures that when the kernel updates the VDSO data userland * will observe it without requiring cache invalidations. */ - if (cpu_has_dc_aliases && IS_ENABLED(CONFIG_HAVE_GENERIC_VDSO)) { + if (cpu_has_dc_aliases && IS_ENABLED(CONFIG_MIPS_GENERIC_GETTIMEOFDAY)) { base = __ALIGN_MASK(base, shm_align_mask); base += ((unsigned long)vdso_k_time_data - gic_size) & shm_align_mask; } @@ -137,7 +137,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) data_addr = base + gic_size; vdso_addr = data_addr + VDSO_NR_PAGES * PAGE_SIZE; - if (IS_ENABLED(CONFIG_HAVE_GENERIC_VDSO)) { + if (IS_ENABLED(CONFIG_MIPS_GENERIC_GETTIMEOFDAY)) { vma = vdso_install_vvar_mapping(mm, data_addr); if (IS_ERR(vma)) { ret = PTR_ERR(vma); diff --git a/arch/mips/vdso/vdso.lds.S b/arch/mips/vdso/vdso.lds.S index 278ab6444e98..b11ee493c67f 100644 --- a/arch/mips/vdso/vdso.lds.S +++ b/arch/mips/vdso/vdso.lds.S @@ -97,9 +97,11 @@ VERSION LINUX_2.6 { #ifdef CONFIG_GENERIC_GETTIMEOFDAY global: +#if _MIPS_SIM == _MIPS_SIM_ABI64 || defined(CONFIG_COMPAT_32BIT_TIME) __vdso_clock_gettime; __vdso_gettimeofday; __vdso_clock_getres; +#endif #if _MIPS_SIM != _MIPS_SIM_ABI64 __vdso_clock_gettime64; __vdso_clock_getres_time64; diff --git a/arch/mips/vdso/vgettimeofday.c b/arch/mips/vdso/vgettimeofday.c index 00f9fcfc327e..a1fb06b8973e 100644 --- a/arch/mips/vdso/vgettimeofday.c +++ b/arch/mips/vdso/vgettimeofday.c @@ -12,6 +12,8 @@ #include #if _MIPS_SIM != _MIPS_SIM_ABI64 + +#ifdef CONFIG_COMPAT_32BIT_TIME int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) { @@ -29,6 +31,7 @@ int __vdso_clock_getres(clockid_t clock_id, { return __cvdso_clock_getres_time32(clock_id, res); } +#endif /* CONFIG_COMPAT_32BIT_TIME */ int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index da35126d93ac..2580e27e4328 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -256,7 +256,6 @@ config PPC select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER if !COMPILE_TEST && (PPC64 || (PPC32 && CC_IS_GCC)) select HAVE_GCC_PLUGINS - select HAVE_GENERIC_VDSO select HAVE_HARDLOCKUP_DETECTOR_ARCH if PPC_BOOK3S_64 && SMP select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI select HAVE_HW_BREAKPOINT if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx) @@ -331,6 +330,7 @@ config PPC select SYSCTL_EXCEPTION_TRACE select THREAD_INFO_IN_TASK select TRACE_IRQFLAGS_SUPPORT + select VDSO_DATASTORE select VDSO_GETRANDOM # # Please keep this list sorted alphabetically. diff --git a/arch/powerpc/kernel/vdso/gettimeofday.S b/arch/powerpc/kernel/vdso/gettimeofday.S index 1c8e51691bf8..c635cd1e77be 100644 --- a/arch/powerpc/kernel/vdso/gettimeofday.S +++ b/arch/powerpc/kernel/vdso/gettimeofday.S @@ -67,9 +67,11 @@ * int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz); * */ +#if defined(__powerpc64__) || defined(CONFIG_COMPAT_32BIT_TIME) V_FUNCTION_BEGIN(__kernel_gettimeofday) cvdso_call __c_kernel_gettimeofday V_FUNCTION_END(__kernel_gettimeofday) +#endif /* * Exact prototype of clock_gettime() @@ -77,9 +79,11 @@ V_FUNCTION_END(__kernel_gettimeofday) * int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp); * */ +#if defined(__powerpc64__) || defined(CONFIG_COMPAT_32BIT_TIME) V_FUNCTION_BEGIN(__kernel_clock_gettime) cvdso_call __c_kernel_clock_gettime V_FUNCTION_END(__kernel_clock_gettime) +#endif /* * Exact prototype of clock_gettime64() @@ -99,9 +103,11 @@ V_FUNCTION_END(__kernel_clock_gettime64) * int __kernel_clock_getres(clockid_t clock_id, struct timespec *res); * */ +#if defined(__powerpc64__) || defined(CONFIG_COMPAT_32BIT_TIME) V_FUNCTION_BEGIN(__kernel_clock_getres) cvdso_call __c_kernel_clock_getres V_FUNCTION_END(__kernel_clock_getres) +#endif /* * Exact prototype of clock_getres_time64() @@ -122,6 +128,8 @@ V_FUNCTION_END(__kernel_clock_getres_time64) * time_t time(time *t); * */ +#if defined(__powerpc64__) || defined(CONFIG_COMPAT_32BIT_TIME) V_FUNCTION_BEGIN(__kernel_time) cvdso_call __c_kernel_time call_time=1 V_FUNCTION_END(__kernel_time) +#endif diff --git a/arch/powerpc/kernel/vdso/vdso32.lds.S b/arch/powerpc/kernel/vdso/vdso32.lds.S index 3f384a2526ae..5e87c18fd282 100644 --- a/arch/powerpc/kernel/vdso/vdso32.lds.S +++ b/arch/powerpc/kernel/vdso/vdso32.lds.S @@ -119,13 +119,15 @@ VERSION { VDSO_VERSION_STRING { global: - __kernel_get_syscall_map; +#ifdef CONFIG_COMPAT_32BIT_TIME __kernel_gettimeofday; __kernel_clock_gettime; - __kernel_clock_gettime64; __kernel_clock_getres; - __kernel_clock_getres_time64; __kernel_time; +#endif /* CONFIG_COMPAT_32BIT_TIME */ + __kernel_get_syscall_map; + __kernel_clock_gettime64; + __kernel_clock_getres_time64; __kernel_get_tbfreq; __kernel_sync_dicache; __kernel_sigtramp32; diff --git a/arch/powerpc/kernel/vdso/vgettimeofday.c b/arch/powerpc/kernel/vdso/vgettimeofday.c index 3c194e1ab562..4b712fb01a3f 100644 --- a/arch/powerpc/kernel/vdso/vgettimeofday.c +++ b/arch/powerpc/kernel/vdso/vgettimeofday.c @@ -18,23 +18,25 @@ int __c_kernel_clock_getres(clockid_t clock_id, struct __kernel_timespec *res, return __cvdso_clock_getres_data(vd, clock_id, res); } #else +#ifdef CONFIG_COMPAT_32BIT_TIME int __c_kernel_clock_gettime(clockid_t clock, struct old_timespec32 *ts, const struct vdso_time_data *vd) { return __cvdso_clock_gettime32_data(vd, clock, ts); } -int __c_kernel_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts, - const struct vdso_time_data *vd) -{ - return __cvdso_clock_gettime_data(vd, clock, ts); -} - int __c_kernel_clock_getres(clockid_t clock_id, struct old_timespec32 *res, const struct vdso_time_data *vd) { return __cvdso_clock_getres_time32_data(vd, clock_id, res); } +#endif /* CONFIG_COMPAT_32BIT_TIME */ + +int __c_kernel_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts, + const struct vdso_time_data *vd) +{ + return __cvdso_clock_gettime_data(vd, clock, ts); +} int __c_kernel_clock_getres_time64(clockid_t clock_id, struct __kernel_timespec *res, const struct vdso_time_data *vd) @@ -43,6 +45,7 @@ int __c_kernel_clock_getres_time64(clockid_t clock_id, struct __kernel_timespec } #endif +#if defined(__powerpc64__) || defined(CONFIG_COMPAT_32BIT_TIME) int __c_kernel_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz, const struct vdso_time_data *vd) { @@ -53,3 +56,4 @@ __kernel_old_time_t __c_kernel_time(__kernel_old_time_t *time, const struct vdso { return __cvdso_time_data(vd, time); } +#endif diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index aa98bbdfabfb..ccd10d77bad7 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -55,7 +55,7 @@ config RISCV select ARCH_HAS_SYSCALL_WRAPPER select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAS_UBSAN - select ARCH_HAS_VDSO_ARCH_DATA if HAVE_GENERIC_VDSO + select ARCH_HAS_VDSO_ARCH_DATA select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_KEEP_MEMBLOCK if ACPI || KEXEC select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE if 64BIT && MMU @@ -111,7 +111,7 @@ config RISCV select GENERIC_CPU_VULNERABILITIES select GENERIC_EARLY_IOREMAP select GENERIC_ENTRY - select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO && 64BIT + select GENERIC_GETTIMEOFDAY if MMU && 64BIT select GENERIC_IDLE_POLL_SETUP select GENERIC_IOREMAP if MMU select HAVE_IOREMAP_PROT if MMU @@ -172,7 +172,6 @@ config RISCV select HAVE_FUNCTION_ARG_ACCESS_API select HAVE_FUNCTION_ERROR_INJECTION select HAVE_GCC_PLUGINS - select HAVE_GENERIC_VDSO if MMU select HAVE_IRQ_TIME_ACCOUNTING select HAVE_KERNEL_BZIP2 if !EFI_ZBOOT select HAVE_KERNEL_GZIP if !EFI_ZBOOT @@ -228,7 +227,8 @@ config RISCV select THREAD_INFO_IN_TASK select TRACE_IRQFLAGS_SUPPORT select UACCESS_MEMCPY if !MMU - select VDSO_GETRANDOM if HAVE_GENERIC_VDSO && 64BIT + select VDSO_DATASTORE if MMU + select VDSO_GETRANDOM if MMU && 64BIT select USER_STACKTRACE_SUPPORT select ZONE_DMA32 if 64BIT diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 378fcd2b6181..b6aa74480a25 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -215,7 +215,6 @@ config S390 select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER select HAVE_GCC_PLUGINS - select HAVE_GENERIC_VDSO select HAVE_IOREMAP_PROT if PCI select HAVE_KERNEL_BZIP2 select HAVE_KERNEL_GZIP diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index a979a4be79a9..ab77d3f2536e 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -114,7 +114,6 @@ config SPARC64 select ARCH_SUPPORTS_SCHED_SMT if SMP select ARCH_SUPPORTS_SCHED_MC if SMP select ARCH_HAS_LAZY_MMU_MODE - select HAVE_GENERIC_VDSO select GENERIC_GETTIMEOFDAY config ARCH_PROC_KCORE_TEXT diff --git a/arch/sparc/vdso/vclock_gettime.c b/arch/sparc/vdso/vclock_gettime.c index 1d9859392e4c..221bd4ed19f5 100644 --- a/arch/sparc/vdso/vclock_gettime.c +++ b/arch/sparc/vdso/vclock_gettime.c @@ -21,6 +21,7 @@ #include "../../../../lib/vdso/gettimeofday.c" +#if defined(CONFIG_SPARC64) || defined(CONFIG_COMPAT_32BIT_TIME) int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) { return __cvdso_gettimeofday(tv, tz); @@ -28,6 +29,7 @@ int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) int gettimeofday(struct __kernel_old_timeval *, struct timezone *) __weak __alias(__vdso_gettimeofday); +#endif #if defined(CONFIG_SPARC64) int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts) @@ -40,6 +42,7 @@ int clock_gettime(clockid_t, struct __kernel_timespec *) #else +#if defined(CONFIG_COMPAT_32BIT_TIME) int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) { return __cvdso_clock_gettime32(clock, ts); @@ -47,6 +50,7 @@ int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) int clock_gettime(clockid_t, struct old_timespec32 *) __weak __alias(__vdso_clock_gettime); +#endif int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts) { diff --git a/arch/sparc/vdso/vdso32/vdso32.lds.S b/arch/sparc/vdso/vdso32/vdso32.lds.S index a14e4f77e6f2..28052168b875 100644 --- a/arch/sparc/vdso/vdso32/vdso32.lds.S +++ b/arch/sparc/vdso/vdso32/vdso32.lds.S @@ -15,12 +15,14 @@ VERSION { LINUX_2.6 { global: +#ifdef CONFIG_COMPAT_32BIT_TIME clock_gettime; __vdso_clock_gettime; - clock_gettime64; - __vdso_clock_gettime64; gettimeofday; __vdso_gettimeofday; +#endif + clock_gettime64; + __vdso_clock_gettime64; local: *; }; } diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 3683a7c6f5cb..485e014330cc 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -303,7 +303,6 @@ config X86 select HAVE_UNSTABLE_SCHED_CLOCK select HAVE_UNWIND_USER_FP if X86_64 select HAVE_USER_RETURN_NOTIFIER - select HAVE_GENERIC_VDSO select VDSO_GETRANDOM if X86_64 select HOTPLUG_PARALLEL if SMP && X86_64 select HOTPLUG_SMT if SMP diff --git a/arch/x86/entry/vdso/common/vclock_gettime.c b/arch/x86/entry/vdso/common/vclock_gettime.c index 57066f346b3f..304dbd1f9db4 100644 --- a/arch/x86/entry/vdso/common/vclock_gettime.c +++ b/arch/x86/entry/vdso/common/vclock_gettime.c @@ -15,6 +15,7 @@ #include "lib/vdso/gettimeofday.c" +#if defined(__x86_64__) || defined(CONFIG_COMPAT_32BIT_TIME) int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) { return __cvdso_gettimeofday(tv, tz); @@ -29,6 +30,7 @@ __kernel_old_time_t __vdso_time(__kernel_old_time_t *t) } __kernel_old_time_t time(__kernel_old_time_t *t) __attribute__((weak, alias("__vdso_time"))); +#endif /* CONFIG_COMPAT_32BIT_TIME */ #if defined(CONFIG_X86_64) && !defined(BUILD_VDSO32_64) @@ -51,6 +53,7 @@ int clock_getres(clockid_t, struct __kernel_timespec *) #else /* i386 only */ +#ifdef CONFIG_COMPAT_32BIT_TIME int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) { return __cvdso_clock_gettime32(clock, ts); @@ -59,6 +62,15 @@ int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) int clock_gettime(clockid_t, struct old_timespec32 *) __attribute__((weak, alias("__vdso_clock_gettime"))); +int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res) +{ + return __cvdso_clock_getres_time32(clock, res); +} + +int clock_getres(clockid_t, struct old_timespec32 *) + __attribute__((weak, alias("__vdso_clock_getres"))); +#endif /* CONFIG_COMPAT_32BIT_TIME */ + int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts) { return __cvdso_clock_gettime(clock, ts); @@ -67,14 +79,6 @@ int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts) int clock_gettime64(clockid_t, struct __kernel_timespec *) __attribute__((weak, alias("__vdso_clock_gettime64"))); -int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res) -{ - return __cvdso_clock_getres_time32(clock, res); -} - -int clock_getres(clockid_t, struct old_timespec32 *) - __attribute__((weak, alias("__vdso_clock_getres"))); - int __vdso_clock_getres_time64(clockid_t clock, struct __kernel_timespec *ts) { return __cvdso_clock_getres(clock, ts); diff --git a/arch/x86/entry/vdso/vdso32/vdso32.lds.S b/arch/x86/entry/vdso/vdso32/vdso32.lds.S index cee8f7f9fe80..00629192db56 100644 --- a/arch/x86/entry/vdso/vdso32/vdso32.lds.S +++ b/arch/x86/entry/vdso/vdso32/vdso32.lds.S @@ -23,10 +23,12 @@ VERSION { LINUX_2.6 { global: +#ifdef CONFIG_COMPAT_32BIT_TIME __vdso_clock_gettime; __vdso_gettimeofday; __vdso_time; __vdso_clock_getres; +#endif /* CONFIG_COMPAT_32BIT_TIME */ __vdso_clock_gettime64; __vdso_clock_getres_time64; __vdso_getcpu; diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 7b4a98df6962..cc9a8b399004 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -56,11 +56,7 @@ static struct clock_event_device __percpu *arch_timer_evt; static enum arch_timer_ppi_nr arch_timer_uses_ppi __ro_after_init = ARCH_TIMER_VIRT_PPI; static bool arch_timer_c3stop __ro_after_init; static bool arch_counter_suspend_stop __ro_after_init; -#ifdef CONFIG_GENERIC_GETTIMEOFDAY static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_ARCHTIMER; -#else -static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_NONE; -#endif /* CONFIG_GENERIC_GETTIMEOFDAY */ static cpumask_t evtstrm_available = CPU_MASK_NONE; static bool evtstrm_enable __ro_after_init = IS_ENABLED(CONFIG_ARM_ARCH_TIMER_EVTSTREAM); diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c index a1669266c94d..1501c7db9a8e 100644 --- a/drivers/clocksource/mips-gic-timer.c +++ b/drivers/clocksource/mips-gic-timer.c @@ -198,9 +198,7 @@ static struct clocksource gic_clocksource = { .name = "GIC", .read = gic_hpt_read, .flags = CLOCK_SOURCE_IS_CONTINUOUS, -#ifdef CONFIG_GENERIC_GETTIMEOFDAY .vdso_clock_mode = VDSO_CLOCKMODE_GIC, -#endif }; static void gic_clocksource_unstable(char *reason) diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c index cfc4d83c42c0..b310e6721fac 100644 --- a/drivers/clocksource/timer-riscv.c +++ b/drivers/clocksource/timer-riscv.c @@ -98,11 +98,7 @@ static struct clocksource riscv_clocksource = { .mask = CLOCKSOURCE_MASK(64), .flags = CLOCK_SOURCE_IS_CONTINUOUS, .read = riscv_clocksource_rdtime, -#if IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY) .vdso_clock_mode = VDSO_CLOCKMODE_ARCHTIMER, -#else - .vdso_clock_mode = VDSO_CLOCKMODE_NONE, -#endif }; static int riscv_timer_starting_cpu(unsigned int cpu) diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild index 15df9dcb42a5..2bc00c67dc54 100644 --- a/include/asm-generic/Kbuild +++ b/include/asm-generic/Kbuild @@ -62,6 +62,7 @@ mandatory-y += topology.h mandatory-y += trace_clock.h mandatory-y += uaccess.h mandatory-y += unwind_user.h +mandatory-y += vdso/clocksource.h mandatory-y += vermagic.h mandatory-y += vga.h mandatory-y += video.h diff --git a/include/asm-generic/vdso/clocksource.h b/include/asm-generic/vdso/clocksource.h new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/include/asm-generic/vdso/vsyscall.h b/include/asm-generic/vdso/vsyscall.h index 5c6d9799f4e7..a6b03cfba0e2 100644 --- a/include/asm-generic/vdso/vsyscall.h +++ b/include/asm-generic/vdso/vsyscall.h @@ -2,7 +2,7 @@ #ifndef __ASM_GENERIC_VSYSCALL_H #define __ASM_GENERIC_VSYSCALL_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ #ifndef __arch_get_vdso_u_time_data static __always_inline const struct vdso_time_data *__arch_get_vdso_u_time_data(void) @@ -30,6 +30,6 @@ static __always_inline void __arch_sync_vdso_time_data(struct vdso_time_data *vd } #endif /* __arch_sync_vdso_time_data */ -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ #endif /* __ASM_GENERIC_VSYSCALL_H */ diff --git a/include/linux/vdso_datastore.h b/include/linux/vdso_datastore.h index 3dfba9502d78..13b01baf3497 100644 --- a/include/linux/vdso_datastore.h +++ b/include/linux/vdso_datastore.h @@ -7,10 +7,10 @@ extern const struct vm_special_mapping vdso_vvar_mapping; struct vm_area_struct *vdso_install_vvar_mapping(struct mm_struct *mm, unsigned long addr); -#ifdef CONFIG_HAVE_GENERIC_VDSO +#ifdef CONFIG_VDSO_DATASTORE void __init vdso_setup_data_pages(void); -#else /* !CONFIG_HAVE_GENERIC_VDSO */ +#else /* !CONFIG_VDSO_DATASTORE */ static inline void vdso_setup_data_pages(void) { } -#endif /* CONFIG_HAVE_GENERIC_VDSO */ +#endif /* CONFIG_VDSO_DATASTORE */ #endif /* _LINUX_VDSO_DATASTORE_H */ diff --git a/include/vdso/clocksource.h b/include/vdso/clocksource.h index c682e7c60273..bce81c02a7c6 100644 --- a/include/vdso/clocksource.h +++ b/include/vdso/clocksource.h @@ -4,13 +4,11 @@ #include -#ifdef CONFIG_GENERIC_GETTIMEOFDAY #include -#endif /* CONFIG_GENERIC_GETTIMEOFDAY */ enum vdso_clock_mode { VDSO_CLOCKMODE_NONE, -#ifdef CONFIG_GENERIC_GETTIMEOFDAY +#ifdef VDSO_ARCH_CLOCKMODES VDSO_ARCH_CLOCKMODES, #endif VDSO_CLOCKMODE_MAX, diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h index 5977723fb3b5..09897f76ae07 100644 --- a/include/vdso/datapage.h +++ b/include/vdso/datapage.h @@ -2,7 +2,7 @@ #ifndef __VDSO_DATAPAGE_H #define __VDSO_DATAPAGE_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ #include @@ -176,7 +176,7 @@ enum vdso_pages { VDSO_NR_PAGES }; -#else /* !__ASSEMBLY__ */ +#else /* !__ASSEMBLER__ */ #ifdef CONFIG_VDSO_GETRANDOM #define __vdso_u_rng_data PROVIDE(vdso_u_rng_data = vdso_u_data + 2 * PAGE_SIZE); @@ -197,6 +197,6 @@ enum vdso_pages { __vdso_u_arch_data \ -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ #endif /* __VDSO_DATAPAGE_H */ diff --git a/include/vdso/helpers.h b/include/vdso/helpers.h index a3bf4f1c0d37..65151b681c4f 100644 --- a/include/vdso/helpers.h +++ b/include/vdso/helpers.h @@ -2,7 +2,7 @@ #ifndef __VDSO_HELPERS_H #define __VDSO_HELPERS_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ #include #include @@ -111,6 +111,6 @@ static __always_inline void vdso_write_end(struct vdso_time_data *vd) vdso_write_seq_end(&vc[CS_RAW]); } -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ #endif /* __VDSO_HELPERS_H */ diff --git a/include/vdso/processor.h b/include/vdso/processor.h index fbe8265ea3c4..cc781912a696 100644 --- a/include/vdso/processor.h +++ b/include/vdso/processor.h @@ -5,10 +5,10 @@ #ifndef __VDSO_PROCESSOR_H #define __VDSO_PROCESSOR_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ #include -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* __VDSO_PROCESSOR_H */ diff --git a/include/vdso/vsyscall.h b/include/vdso/vsyscall.h index b0fdc9c6bf43..c5c2a2c07857 100644 --- a/include/vdso/vsyscall.h +++ b/include/vdso/vsyscall.h @@ -2,13 +2,13 @@ #ifndef __VDSO_VSYSCALL_H #define __VDSO_VSYSCALL_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ #include unsigned long vdso_update_begin(void); void vdso_update_end(unsigned long flags); -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ #endif /* __VDSO_VSYSCALL_H */ diff --git a/init/Kconfig b/init/Kconfig index 5d884f0c213f..db9f72d2061c 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1861,7 +1861,7 @@ config HAVE_FUTEX_ROBUST_UNLOCK bool config FUTEX_ROBUST_UNLOCK - def_bool FUTEX && HAVE_GENERIC_VDSO && GENERIC_IRQ_ENTRY && RSEQ && HAVE_FUTEX_ROBUST_UNLOCK + def_bool FUTEX && GENERIC_IRQ_ENTRY && RSEQ && HAVE_FUTEX_ROBUST_UNLOCK config EPOLL bool "Enable eventpoll support" if EXPERT diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index add3032da16f..c8be0abaa407 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c @@ -351,6 +351,10 @@ COND_SYSCALL(ppoll_time32); COND_SYSCALL_COMPAT(ppoll_time32); COND_SYSCALL(utimensat_time32); COND_SYSCALL(clock_adjtime32); +COND_SYSCALL(gettimeofday); +COND_SYSCALL_COMPAT(gettimeofday); +COND_SYSCALL(time); +COND_SYSCALL(stime); /* * The syscalls below are not found in include/uapi/asm-generic/unistd.h diff --git a/kernel/time/namespace_vdso.c b/kernel/time/namespace_vdso.c index 0d74d160eec9..5ac7b6a6d3a8 100644 --- a/kernel/time/namespace_vdso.c +++ b/kernel/time/namespace_vdso.c @@ -74,11 +74,8 @@ struct page *find_timens_vvar_page(struct vm_area_struct *vma) return current->nsproxy->time_ns->vvar_page; /* - * VM_PFNMAP | VM_IO protect .fault() handler from being called - * through interfaces like /proc/$pid/mem or - * process_vm_{readv,writev}() as long as there's no .access() - * in special_mapping_vmops(). - * For more details check_vma_flags() and __access_remote_vm() + * vvar_fault() protects this from being called through remote interfaces like + * /proc/$pid/mem or process_vm_{readv,writev}(). */ WARN(1, "vvar_page accessed remotely"); diff --git a/kernel/time/time.c b/kernel/time/time.c index d1a7efd80bf5..079ab34f61db 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -44,6 +44,12 @@ #include "timekeeping.h" #include "timekeeping_internal.h" +#if defined(CONFIG_64BIT) || defined(CONFIG_COMPAT_32BIT_TIME) +#define __WANT_OLD_TIME_TYPE_SYSCALL 1 +#endif + +static_assert(sizeof(__kernel_old_time_t) == 8 ? IS_ENABLED(__WANT_OLD_TIME_TYPE_SYSCALL) : true); + /* * The timezone where the local system is located. Used as a default by some * programs who obtain this value by using gettimeofday. @@ -52,7 +58,7 @@ struct timezone sys_tz; EXPORT_SYMBOL(sys_tz); -#ifdef __ARCH_WANT_SYS_TIME +#if defined(__ARCH_WANT_SYS_TIME) && defined(__WANT_OLD_TIME_TYPE_SYSCALL) /* * sys_time() can be implemented in user-level using @@ -97,7 +103,7 @@ SYSCALL_DEFINE1(stime, __kernel_old_time_t __user *, tptr) return 0; } -#endif /* __ARCH_WANT_SYS_TIME */ +#endif /* __ARCH_WANT_SYS_TIME && __WANT_OLD_TIME_TYPE_SYSCALL */ #ifdef CONFIG_COMPAT_32BIT_TIME #ifdef __ARCH_WANT_SYS_TIME32 @@ -138,6 +144,7 @@ SYSCALL_DEFINE1(stime32, old_time32_t __user *, tptr) #endif /* __ARCH_WANT_SYS_TIME32 */ #endif +#ifdef __WANT_OLD_TIME_TYPE_SYSCALL SYSCALL_DEFINE2(gettimeofday, struct __kernel_old_timeval __user *, tv, struct timezone __user *, tz) { @@ -155,6 +162,7 @@ SYSCALL_DEFINE2(gettimeofday, struct __kernel_old_timeval __user *, tv, } return 0; } +#endif /* __WANT_OLD_TIME_TYPE_SYSCALL */ /* * In case for some reason the CMOS clock has not already been running @@ -204,6 +212,9 @@ SYSCALL_DEFINE2(settimeofday, struct __kernel_old_timeval __user *, tv, struct timezone new_tz; if (tv) { + if (!IS_ENABLED(__WANT_OLD_TIME_TYPE_SYSCALL)) + return -EINVAL; + if (get_user(new_ts.tv_sec, &tv->tv_sec) || get_user(new_ts.tv_nsec, &tv->tv_usec)) return -EFAULT; @@ -221,7 +232,7 @@ SYSCALL_DEFINE2(settimeofday, struct __kernel_old_timeval __user *, tv, return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL); } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_COMPAT_32BIT_TIME COMPAT_SYSCALL_DEFINE2(gettimeofday, struct old_timeval32 __user *, tv, struct timezone __user *, tz) { @@ -240,7 +251,9 @@ COMPAT_SYSCALL_DEFINE2(gettimeofday, struct old_timeval32 __user *, tv, return 0; } +#endif /* CONFIG_COMPAT_32BIT_TIME */ +#ifdef CONFIG_COMPAT COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv, struct timezone __user *, tz) { @@ -248,6 +261,9 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv, struct timezone new_tz; if (tv) { + if (!IS_ENABLED(CONFIG_COMPAT_32BIT_TIME)) + return -EINVAL; + if (get_user(new_ts.tv_sec, &tv->tv_sec) || get_user(new_ts.tv_nsec, &tv->tv_usec)) return -EFAULT; @@ -264,7 +280,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv, return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL); } -#endif +#endif /* CONFIG_COMPAT */ #ifdef CONFIG_64BIT SYSCALL_DEFINE1(adjtimex, struct __kernel_timex __user *, txc_p) diff --git a/lib/vdso/Kconfig b/lib/vdso/Kconfig index db87ba34ef19..597f5f0f9681 100644 --- a/lib/vdso/Kconfig +++ b/lib/vdso/Kconfig @@ -1,12 +1,11 @@ # SPDX-License-Identifier: GPL-2.0 -config HAVE_GENERIC_VDSO +config VDSO_DATASTORE bool -if HAVE_GENERIC_VDSO - config GENERIC_GETTIMEOFDAY bool + select VDSO_DATASTORE help This is a generic implementation of gettimeofday vdso. Each architecture that enables this feature has to @@ -21,7 +20,6 @@ config GENERIC_VDSO_OVERFLOW_PROTECT config VDSO_GETRANDOM bool + select VDSO_DATASTORE help Selected by architectures that support vDSO getrandom(). - -endif diff --git a/lib/vdso/Makefile b/lib/vdso/Makefile index 405f743253d7..ac304def42d6 100644 --- a/lib/vdso/Makefile +++ b/lib/vdso/Makefile @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_HAVE_GENERIC_VDSO) += datastore.o +obj-$(CONFIG_VDSO_DATASTORE) += datastore.o diff --git a/lib/vdso/datastore.c b/lib/vdso/datastore.c index 17d37b82ebc6..1426bf4e0c12 100644 --- a/lib/vdso/datastore.c +++ b/lib/vdso/datastore.c @@ -29,10 +29,11 @@ struct vdso_arch_data *vdso_k_arch_data __ro_after_init = (void *)&vdso_initdata[VDSO_ARCH_PAGES_START * PAGE_SIZE]; #endif /* CONFIG_ARCH_HAS_VDSO_ARCH_DATA */ +static struct page *vdso_data_pages __ro_after_init; + void __init vdso_setup_data_pages(void) { unsigned int order = get_order(VDSO_NR_PAGES * PAGE_SIZE); - struct page *pages; /* * Allocate the data pages dynamically. SPARC does not support mapping @@ -42,24 +43,24 @@ void __init vdso_setup_data_pages(void) * Do not use folios. In time namespaces the pages are mapped in a different order * to userspace, which is not handled by the folio optimizations in finish_fault(). */ - pages = alloc_pages(GFP_KERNEL, order); - if (!pages) + vdso_data_pages = alloc_pages(GFP_KERNEL, order); + if (!vdso_data_pages) panic("Unable to allocate VDSO storage pages"); /* The pages are mapped one-by-one into userspace and each one needs to be refcounted. */ - split_page(pages, order); + split_page(vdso_data_pages, order); /* Move the data already written by other subsystems to the new pages */ - memcpy(page_address(pages), vdso_initdata, VDSO_NR_PAGES * PAGE_SIZE); + memcpy(page_address(vdso_data_pages), vdso_initdata, VDSO_NR_PAGES * PAGE_SIZE); if (IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY)) - vdso_k_time_data = page_address(pages + VDSO_TIME_PAGE_OFFSET); + vdso_k_time_data = page_address(vdso_data_pages + VDSO_TIME_PAGE_OFFSET); if (IS_ENABLED(CONFIG_VDSO_GETRANDOM)) - vdso_k_rng_data = page_address(pages + VDSO_RNG_PAGE_OFFSET); + vdso_k_rng_data = page_address(vdso_data_pages + VDSO_RNG_PAGE_OFFSET); if (IS_ENABLED(CONFIG_ARCH_HAS_VDSO_ARCH_DATA)) - vdso_k_arch_data = page_address(pages + VDSO_ARCH_PAGES_START); + vdso_k_arch_data = page_address(vdso_data_pages + VDSO_ARCH_PAGES_START); } static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, @@ -67,27 +68,28 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, { struct page *page, *timens_page; + if (unlikely(vmf->flags & FAULT_FLAG_REMOTE)) + return VM_FAULT_SIGBUS; + + page = vdso_data_pages + vmf->pgoff; timens_page = find_timens_vvar_page(vma); switch (vmf->pgoff) { case VDSO_TIME_PAGE_OFFSET: - if (!IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY)) - return VM_FAULT_SIGBUS; - page = virt_to_page(vdso_k_time_data); - if (timens_page) { - /* - * Fault in VVAR page too, since it will be accessed - * to get clock data anyway. - */ - unsigned long addr; - vm_fault_t err; + if (!IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY) || !timens_page) + break; + /* + * Fault in VVAR page too, since it will be accessed + * to get clock data anyway. + */ + unsigned long addr; + vm_fault_t err; - addr = vmf->address + VDSO_TIMENS_PAGE_OFFSET * PAGE_SIZE; - err = vmf_insert_page(vma, addr, page); - if (unlikely(err & VM_FAULT_ERROR)) - return err; - page = timens_page; - } + addr = vmf->address + VDSO_TIMENS_PAGE_OFFSET * PAGE_SIZE; + err = vmf_insert_page(vma, addr, page); + if (unlikely(err & VM_FAULT_ERROR)) + return err; + page = timens_page; break; case VDSO_TIMENS_PAGE_OFFSET: /* @@ -98,18 +100,11 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, * See also the comment near timens_setup_vdso_data(). */ if (!IS_ENABLED(CONFIG_TIME_NS) || !timens_page) - return VM_FAULT_SIGBUS; - page = virt_to_page(vdso_k_time_data); + break; + page = vdso_data_pages + VDSO_TIME_PAGE_OFFSET; break; case VDSO_RNG_PAGE_OFFSET: - if (!IS_ENABLED(CONFIG_VDSO_GETRANDOM)) - return VM_FAULT_SIGBUS; - page = virt_to_page(vdso_k_rng_data); - break; case VDSO_ARCH_PAGES_START ... VDSO_ARCH_PAGES_END: - if (!IS_ENABLED(CONFIG_ARCH_HAS_VDSO_ARCH_DATA)) - return VM_FAULT_SIGBUS; - page = virt_to_page(vdso_k_arch_data) + vmf->pgoff - VDSO_ARCH_PAGES_START; break; default: return VM_FAULT_SIGBUS; @@ -128,7 +123,7 @@ const struct vm_special_mapping vdso_vvar_mapping = { struct vm_area_struct *vdso_install_vvar_mapping(struct mm_struct *mm, unsigned long addr) { return _install_special_mapping(mm, addr, VDSO_NR_PAGES * PAGE_SIZE, - VM_READ | VM_MAYREAD | VM_IO | VM_DONTDUMP | + VM_READ | VM_MAYREAD | VM_DONTDUMP | VM_MIXEDMAP | VM_SEALED_SYSMAP, &vdso_vvar_mapping); } diff --git a/lib/vdso/getrandom.c b/lib/vdso/getrandom.c index 7e29005aa208..2851afa9154f 100644 --- a/lib/vdso/getrandom.c +++ b/lib/vdso/getrandom.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -18,11 +19,6 @@ /* Bring in default accessors */ #include -#undef PAGE_SIZE -#undef PAGE_MASK -#define PAGE_SIZE (1UL << CONFIG_PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE - 1)) - #define MEMCPY_AND_ZERO_SRC(type, dst, src, len) do { \ while (len >= sizeof(type)) { \ __put_unaligned_t(type, __get_unaligned_t(type, src), dst); \ diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index e0f289d3d110..f7a591aba59f 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -12,6 +12,8 @@ #include #include +#include + /* * The generic vDSO implementation requires that gettimeofday.h * provides: @@ -23,6 +25,8 @@ */ #include +#include + /* Bring in default accessors */ #include @@ -323,6 +327,8 @@ __cvdso_clock_gettime32_data(const struct vdso_time_data *vd, clockid_t clock, struct __kernel_timespec ts; bool ok; + BUILD_BUG_ON(!IS_ENABLED(CONFIG_COMPAT_32BIT_TIME)); + ok = __cvdso_clock_gettime_common(vd, clock, &ts); if (unlikely(!ok)) @@ -348,6 +354,12 @@ __cvdso_gettimeofday_data(const struct vdso_time_data *vd, { const struct vdso_clock *vc = vd->clock_data; +#ifndef __NR_gettimeofday + BUILD_BUG(); +#endif + + BUILD_BUG_ON(sizeof(tv->tv_sec) != 8 && !IS_ENABLED(CONFIG_COMPAT_32BIT_TIME)); + if (likely(tv != NULL)) { struct __kernel_timespec ts; @@ -382,6 +394,12 @@ __cvdso_time_data(const struct vdso_time_data *vd, __kernel_old_time_t *time) const struct vdso_clock *vc = vd->clock_data; __kernel_old_time_t t; +#ifndef __NR_time + BUILD_BUG(); +#endif + + BUILD_BUG_ON(sizeof(*time) != 8 && !IS_ENABLED(CONFIG_COMPAT_32BIT_TIME)); + if (vdso_is_timens_clock(vc)) { vd = vdso_timens_data(vd); vc = vd->clock_data; @@ -471,6 +489,8 @@ __cvdso_clock_getres_time32_data(const struct vdso_time_data *vd, clockid_t cloc struct __kernel_timespec ts; bool ok; + BUILD_BUG_ON(!IS_ENABLED(CONFIG_COMPAT_32BIT_TIME)); + ok = __cvdso_clock_getres_common(vd, clock, &ts); if (unlikely(!ok)) diff --git a/scripts/Makefile.asm-headers b/scripts/Makefile.asm-headers index 8a4856e74180..b38931314ad7 100644 --- a/scripts/Makefile.asm-headers +++ b/scripts/Makefile.asm-headers @@ -48,14 +48,13 @@ syscall-y := $(addprefix $(obj)/, $(syscall-y)) generated-y := $(addprefix $(obj)/, $(generated-y)) # Remove stale wrappers when the corresponding files are removed from generic-y -old-headers := $(wildcard $(obj)/*.h) +old-headers := $(shell test -d $(obj) && find $(obj) -name *.h) unwanted := $(filter-out $(generic-y) $(generated-y) $(syscall-y),$(old-headers)) -quiet_cmd_wrap = WRAP $@ - cmd_wrap = echo "\#include " > $@ +filechk_wrap = echo "\#include " quiet_cmd_remove = REMOVE $(unwanted) - cmd_remove = rm -f $(unwanted) + cmd_remove = rm -f $(unwanted); find $(obj) -type d -empty -delete quiet_cmd_syshdr = SYSHDR $@ cmd_syshdr = $(CONFIG_SHELL) $(syshdr) \ @@ -74,8 +73,8 @@ all: $(generic-y) $(syscall-y) $(if $(unwanted),$(call cmd,remove)) @: -$(obj)/%.h: $(srctree)/$(generic)/%.h - $(call cmd,wrap) +$(obj)/%.h: $(srctree)/$(generic)/%.h FORCE + $(call filechk,wrap) $(obj)/unistd_%.h: $(syscalltbl) $(syshdr) FORCE $(call if_changed,syshdr)