vdso32-setup.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 <linux/elf.h>
  14. #include <asm/processor.h>
  15. #include <asm/vdso.h>
  16. #ifdef CONFIG_COMPAT_VDSO
  17. #define VDSO_DEFAULT 0
  18. #else
  19. #define VDSO_DEFAULT 1
  20. #endif
  21. /*
  22. * Should the kernel map a VDSO page into processes and pass its
  23. * address down to glibc upon exec()?
  24. */
  25. unsigned int __read_mostly vdso32_enabled = VDSO_DEFAULT;
  26. static int __init vdso32_setup(char *s)
  27. {
  28. vdso32_enabled = simple_strtoul(s, NULL, 0);
  29. if (vdso32_enabled > 1) {
  30. pr_warn("vdso32 values other than 0 and 1 are no longer allowed; vdso disabled\n");
  31. vdso32_enabled = 0;
  32. }
  33. return 1;
  34. }
  35. /*
  36. * For consistency, the argument vdso32=[012] affects the 32-bit vDSO
  37. * behavior on both 64-bit and 32-bit kernels.
  38. * On 32-bit kernels, vdso=[012] means the same thing.
  39. */
  40. __setup("vdso32=", vdso32_setup);
  41. #ifdef CONFIG_X86_32
  42. __setup_param("vdso=", vdso_setup, vdso32_setup, 0);
  43. #endif
  44. int __init sysenter_setup(void)
  45. {
  46. init_vdso_image(&vdso_image_32);
  47. return 0;
  48. }
  49. #ifdef CONFIG_X86_64
  50. subsys_initcall(sysenter_setup);
  51. #ifdef CONFIG_SYSCTL
  52. /* Register vsyscall32 into the ABI table */
  53. #include <linux/sysctl.h>
  54. static const int zero;
  55. static const int one = 1;
  56. static struct ctl_table abi_table2[] = {
  57. {
  58. .procname = "vsyscall32",
  59. .data = &vdso32_enabled,
  60. .maxlen = sizeof(int),
  61. .mode = 0644,
  62. .proc_handler = proc_dointvec_minmax,
  63. .extra1 = (int *)&zero,
  64. .extra2 = (int *)&one,
  65. },
  66. {}
  67. };
  68. static struct ctl_table abi_root_table2[] = {
  69. {
  70. .procname = "abi",
  71. .mode = 0555,
  72. .child = abi_table2
  73. },
  74. {}
  75. };
  76. static __init int ia32_binfmt_init(void)
  77. {
  78. register_sysctl_table(abi_root_table2);
  79. return 0;
  80. }
  81. __initcall(ia32_binfmt_init);
  82. #endif /* CONFIG_SYSCTL */
  83. #endif /* CONFIG_X86_64 */