2024-09-09 08:52:07 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2002 Linus Torvalds
|
|
|
|
* Portions based on the vdso-randomization code from exec-shield:
|
|
|
|
* Copyright(C) 2005-2006, Red Hat, Inc., Ingo Molnar
|
|
|
|
*
|
|
|
|
* This file contains the needed initializations to support sysenter.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/smp.h>
|
2024-09-09 08:57:42 +00:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mm_types.h>
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
#include <asm/cpufeature.h>
|
2024-09-09 08:57:42 +00:00
|
|
|
#include <asm/processor.h>
|
2024-09-09 08:52:07 +00:00
|
|
|
#include <asm/vdso.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_COMPAT_VDSO
|
2024-09-09 08:57:42 +00:00
|
|
|
#define VDSO_DEFAULT 0
|
2024-09-09 08:52:07 +00:00
|
|
|
#else
|
2024-09-09 08:57:42 +00:00
|
|
|
#define VDSO_DEFAULT 1
|
2024-09-09 08:52:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Should the kernel map a VDSO page into processes and pass its
|
|
|
|
* address down to glibc upon exec()?
|
|
|
|
*/
|
2024-09-09 08:57:42 +00:00
|
|
|
unsigned int __read_mostly vdso32_enabled = VDSO_DEFAULT;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
static int __init vdso32_setup(char *s)
|
2024-09-09 08:52:07 +00:00
|
|
|
{
|
2024-09-09 08:57:42 +00:00
|
|
|
vdso32_enabled = simple_strtoul(s, NULL, 0);
|
|
|
|
|
|
|
|
if (vdso32_enabled > 1)
|
|
|
|
pr_warn("vdso32 values other than 0 and 1 are no longer allowed; vdso disabled\n");
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For consistency, the argument vdso32=[012] affects the 32-bit vDSO
|
|
|
|
* behavior on both 64-bit and 32-bit kernels.
|
|
|
|
* On 32-bit kernels, vdso=[012] means the same thing.
|
|
|
|
*/
|
2024-09-09 08:57:42 +00:00
|
|
|
__setup("vdso32=", vdso32_setup);
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_X86_32
|
2024-09-09 08:57:42 +00:00
|
|
|
__setup_param("vdso=", vdso_setup, vdso32_setup, 0);
|
2024-09-09 08:52:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
|
|
|
|
#define vdso32_sysenter() (boot_cpu_has(X86_FEATURE_SYSENTER32))
|
|
|
|
#define vdso32_syscall() (boot_cpu_has(X86_FEATURE_SYSCALL32))
|
|
|
|
|
|
|
|
#else /* CONFIG_X86_32 */
|
|
|
|
|
|
|
|
#define vdso32_sysenter() (boot_cpu_has(X86_FEATURE_SEP))
|
|
|
|
#define vdso32_syscall() (0)
|
|
|
|
|
|
|
|
#endif /* CONFIG_X86_64 */
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
#if defined(CONFIG_X86_32) || defined(CONFIG_COMPAT)
|
|
|
|
const struct vdso_image *selected_vdso32;
|
2024-09-09 08:52:07 +00:00
|
|
|
#endif
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
int __init sysenter_setup(void)
|
2024-09-09 08:52:07 +00:00
|
|
|
{
|
2024-09-09 08:57:42 +00:00
|
|
|
#ifdef CONFIG_COMPAT
|
|
|
|
if (vdso32_syscall())
|
|
|
|
selected_vdso32 = &vdso_image_32_syscall;
|
|
|
|
else
|
2024-09-09 08:52:07 +00:00
|
|
|
#endif
|
2024-09-09 08:57:42 +00:00
|
|
|
if (vdso32_sysenter())
|
|
|
|
selected_vdso32 = &vdso_image_32_sysenter;
|
|
|
|
else
|
|
|
|
selected_vdso32 = &vdso_image_32_int80;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
init_vdso_image(selected_vdso32);
|
2024-09-09 08:52:07 +00:00
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
return 0;
|
2024-09-09 08:52:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
|
|
|
|
subsys_initcall(sysenter_setup);
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYSCTL
|
|
|
|
/* Register vsyscall32 into the ABI table */
|
|
|
|
#include <linux/sysctl.h>
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
static struct ctl_table abi_table2[] = {
|
2024-09-09 08:52:07 +00:00
|
|
|
{
|
|
|
|
.procname = "vsyscall32",
|
2024-09-09 08:57:42 +00:00
|
|
|
.data = &vdso32_enabled,
|
2024-09-09 08:52:07 +00:00
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
static struct ctl_table abi_root_table2[] = {
|
2024-09-09 08:52:07 +00:00
|
|
|
{
|
|
|
|
.procname = "abi",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = abi_table2
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
static __init int ia32_binfmt_init(void)
|
|
|
|
{
|
|
|
|
register_sysctl_table(abi_root_table2);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
__initcall(ia32_binfmt_init);
|
2024-09-09 08:57:42 +00:00
|
|
|
#endif /* CONFIG_SYSCTL */
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
#endif /* CONFIG_X86_64 */
|