vdso32-setup.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * (C) Copyright 2002 Linus Torvalds
  4. * Portions based on the vdso-randomization code from exec-shield:
  5. * Copyright(C) 2005-2006, Red Hat, Inc., Ingo Molnar
  6. *
  7. * This file contains the needed initializations to support sysenter.
  8. */
  9. #include <linux/init.h>
  10. #include <linux/smp.h>
  11. #include <linux/kernel.h>
  12. #include <linux/mm_types.h>
  13. #include <asm/processor.h>
  14. #include <asm/vdso.h>
  15. #ifdef CONFIG_COMPAT_VDSO
  16. #define VDSO_DEFAULT 0
  17. #else
  18. #define VDSO_DEFAULT 1
  19. #endif
  20. /*
  21. * Should the kernel map a VDSO page into processes and pass its
  22. * address down to glibc upon exec()?
  23. */
  24. unsigned int __read_mostly vdso32_enabled = VDSO_DEFAULT;
  25. static int __init vdso32_setup(char *s)
  26. {
  27. vdso32_enabled = simple_strtoul(s, NULL, 0);
  28. if (vdso32_enabled > 1) {
  29. pr_warn("vdso32 values other than 0 and 1 are no longer allowed; vdso disabled\n");
  30. vdso32_enabled = 0;
  31. }
  32. return 1;
  33. }
  34. /*
  35. * For consistency, the argument vdso32=[012] affects the 32-bit vDSO
  36. * behavior on both 64-bit and 32-bit kernels.
  37. * On 32-bit kernels, vdso=[012] means the same thing.
  38. */
  39. __setup("vdso32=", vdso32_setup);
  40. #ifdef CONFIG_X86_32
  41. __setup_param("vdso=", vdso_setup, vdso32_setup, 0);
  42. #endif
  43. int __init sysenter_setup(void)
  44. {
  45. init_vdso_image(&vdso_image_32);
  46. return 0;
  47. }
  48. #ifdef CONFIG_X86_64
  49. subsys_initcall(sysenter_setup);
  50. #ifdef CONFIG_SYSCTL
  51. /* Register vsyscall32 into the ABI table */
  52. #include <linux/sysctl.h>
  53. static const int zero;
  54. static const int one = 1;
  55. static struct ctl_table abi_table2[] = {
  56. {
  57. .procname = "vsyscall32",
  58. .data = &vdso32_enabled,
  59. .maxlen = sizeof(int),
  60. .mode = 0644,
  61. .proc_handler = proc_dointvec_minmax,
  62. .extra1 = (int *)&zero,
  63. .extra2 = (int *)&one,
  64. },
  65. {}
  66. };
  67. static struct ctl_table abi_root_table2[] = {
  68. {
  69. .procname = "abi",
  70. .mode = 0555,
  71. .child = abi_table2
  72. },
  73. {}
  74. };
  75. static __init int ia32_binfmt_init(void)
  76. {
  77. register_sysctl_table(abi_root_table2);
  78. return 0;
  79. }
  80. __initcall(ia32_binfmt_init);
  81. #endif /* CONFIG_SYSCTL */
  82. #endif /* CONFIG_X86_64 */