libhugetlbfs-2.20-noexec-stack.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. https://github.com/libhugetlbfs/libhugetlbfs/pull/9
  2. From 1c41d751d57a598919c40ab9c27514a98da93273 Mon Sep 17 00:00:00 2001
  3. From: "Robin H. Johnson" <robbat2@gentoo.org>
  4. Date: Sat, 31 Oct 2009 07:59:57 +0000
  5. Subject: [PATCH] set noexec markers in the asm file directly
  6. Using -Wl,-z,noexecstack can hide real exec stack issues coming from other
  7. files, and is a bit unportable. Instead, set proper section markers in the
  8. assembly files directly. It also means people using the static libraries
  9. won't have to use -Wl,-z,noexecstack when they link their code.
  10. ---
  11. Makefile | 2 +-
  12. sys-aarch64elf.S | 4 ++++
  13. sys-armelf_linux_eabi.S | 4 ++++
  14. sys-elf32ppclinux.S | 4 ++++
  15. sys-elf64_s390.S | 4 ++++
  16. sys-elf64ppc.S | 4 ++++
  17. sys-elf_i386.S | 4 ++++
  18. sys-elf_s390.S | 4 ++++
  19. sys-elf_x86_64.S | 4 ++++
  20. 9 files changed, 33 insertions(+), 1 deletion(-)
  21. diff --git a/Makefile b/Makefile
  22. index 73ebad7..ca987d9 100644
  23. --- a/Makefile
  24. +++ b/Makefile
  25. @@ -27,7 +27,7 @@ NODEPTARGETS=<version.h> <clean>
  26. INSTALL = install
  27. -LDFLAGS += -Wl,-z,noexecstack -ldl
  28. +LDFLAGS += -ldl
  29. CFLAGS ?= -O2 -g
  30. CFLAGS += -Wall -fPIC
  31. CPPFLAGS += -D__LIBHUGETLBFS__
  32. diff --git a/sys-aarch64elf.S b/sys-aarch64elf.S
  33. index 54799d3..210558b 100644
  34. --- a/sys-aarch64elf.S
  35. +++ b/sys-aarch64elf.S
  36. @@ -32,3 +32,7 @@ direct_syscall:
  37. mov x6, x7
  38. svc 0x0
  39. ret
  40. +
  41. +#if defined(__linux__) && defined(__ELF__)
  42. + .section .note.GNU-stack,"",%progbits
  43. +#endif
  44. diff --git a/sys-armelf_linux_eabi.S b/sys-armelf_linux_eabi.S
  45. index dfa7407..265b75d 100644
  46. --- a/sys-armelf_linux_eabi.S
  47. +++ b/sys-armelf_linux_eabi.S
  48. @@ -31,3 +31,7 @@ direct_syscall:
  49. swi 0x0
  50. ldmfd sp!, {r4, r5, r6, r7}
  51. bx lr
  52. +
  53. +#if defined(__linux__) && defined(__ELF__)
  54. + .section .note.GNU-stack,"",%progbits
  55. +#endif
  56. diff --git a/sys-elf32ppclinux.S b/sys-elf32ppclinux.S
  57. index 65d8b3f..6ba3f22 100644
  58. --- a/sys-elf32ppclinux.S
  59. +++ b/sys-elf32ppclinux.S
  60. @@ -32,3 +32,7 @@ direct_syscall:
  61. mr 8,9
  62. sc
  63. blr
  64. +
  65. +#if defined(__linux__) && defined(__ELF__)
  66. + .section .note.GNU-stack,"",%progbits
  67. +#endif
  68. diff --git a/sys-elf64_s390.S b/sys-elf64_s390.S
  69. index 425a387..5c31899 100644
  70. --- a/sys-elf64_s390.S
  71. +++ b/sys-elf64_s390.S
  72. @@ -20,3 +20,7 @@ direct_syscall:
  73. lgr %r5,%r6
  74. svc 0
  75. br %r14
  76. +
  77. +#if defined(__linux__) && defined(__ELF__)
  78. + .section .note.GNU-stack,"",%progbits
  79. +#endif
  80. diff --git a/sys-elf64ppc.S b/sys-elf64ppc.S
  81. index d50f4a6..b57a345 100644
  82. --- a/sys-elf64ppc.S
  83. +++ b/sys-elf64ppc.S
  84. @@ -46,3 +46,7 @@ direct_syscall:
  85. mr 8,9
  86. sc
  87. blr
  88. +
  89. +#if defined(__linux__) && defined(__ELF__)
  90. + .section .note.GNU-stack,"",%progbits
  91. +#endif
  92. diff --git a/sys-elf_i386.S b/sys-elf_i386.S
  93. index ab30c8d..6182b3d 100644
  94. --- a/sys-elf_i386.S
  95. +++ b/sys-elf_i386.S
  96. @@ -40,3 +40,7 @@ direct_syscall:
  97. pop %edi
  98. pop %ebp
  99. ret
  100. +
  101. +#if defined(__linux__) && defined(__ELF__)
  102. + .section .note.GNU-stack,"",%progbits
  103. +#endif
  104. diff --git a/sys-elf_s390.S b/sys-elf_s390.S
  105. index 40630d1..e6a9a96 100644
  106. --- a/sys-elf_s390.S
  107. +++ b/sys-elf_s390.S
  108. @@ -20,3 +20,7 @@ direct_syscall:
  109. lr %r5,%r6
  110. svc 0
  111. br %r14
  112. +
  113. +#if defined(__linux__) && defined(__ELF__)
  114. + .section .note.GNU-stack,"",%progbits
  115. +#endif
  116. diff --git a/sys-elf_x86_64.S b/sys-elf_x86_64.S
  117. index 6af06ad..561f49b 100644
  118. --- a/sys-elf_x86_64.S
  119. +++ b/sys-elf_x86_64.S
  120. @@ -32,3 +32,7 @@ direct_syscall:
  121. mov 0x8(%rsp),%r9
  122. syscall
  123. retq
  124. +
  125. +#if defined(__linux__) && defined(__ELF__)
  126. + .section .note.GNU-stack,"",%progbits
  127. +#endif
  128. --
  129. 2.6.2