0112-selftests-x86-protection_keys-Fix-syscall-NR-redefin.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. From 6be390fe5b1a7e9480e9cf0f85777a8eb205ad08 Mon Sep 17 00:00:00 2001
  2. From: Andy Lutomirski <[email protected]>
  3. Date: Sat, 4 Nov 2017 04:19:48 -0700
  4. Subject: [PATCH 112/242] selftests/x86/protection_keys: Fix syscall NR
  5. redefinition warnings
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5754
  10. On new enough glibc, the pkey syscalls numbers are available. Check
  11. first before defining them to avoid warnings like:
  12. protection_keys.c:198:0: warning: "SYS_pkey_alloc" redefined
  13. Signed-off-by: Andy Lutomirski <[email protected]>
  14. Cc: Borislav Petkov <[email protected]>
  15. Cc: Dave Hansen <[email protected]>
  16. Cc: Linus Torvalds <[email protected]>
  17. Cc: Peter Zijlstra <[email protected]>
  18. Cc: Thomas Gleixner <[email protected]>
  19. Cc: [email protected]
  20. Link: http://lkml.kernel.org/r/1fbef53a9e6befb7165ff855fc1a7d4788a191d6.1509794321.git.luto@kernel.org
  21. Signed-off-by: Ingo Molnar <[email protected]>
  22. (cherry picked from commit 693cb5580fdb026922363aa103add64b3ecd572e)
  23. Signed-off-by: Andy Whitcroft <[email protected]>
  24. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  25. (cherry picked from commit 64c8ec4beb84ca8b0ff3250a8b6044d06be6315b)
  26. Signed-off-by: Fabian Grünbichler <[email protected]>
  27. ---
  28. tools/testing/selftests/x86/protection_keys.c | 24 ++++++++++++++++++------
  29. 1 file changed, 18 insertions(+), 6 deletions(-)
  30. diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c
  31. index 3237bc010e1c..3c54d5c40952 100644
  32. --- a/tools/testing/selftests/x86/protection_keys.c
  33. +++ b/tools/testing/selftests/x86/protection_keys.c
  34. @@ -188,17 +188,29 @@ void lots_o_noops_around_write(int *write_to_me)
  35. #define u64 uint64_t
  36. #ifdef __i386__
  37. -#define SYS_mprotect_key 380
  38. -#define SYS_pkey_alloc 381
  39. -#define SYS_pkey_free 382
  40. +
  41. +#ifndef SYS_mprotect_key
  42. +# define SYS_mprotect_key 380
  43. +#endif
  44. +#ifndef SYS_pkey_alloc
  45. +# define SYS_pkey_alloc 381
  46. +# define SYS_pkey_free 382
  47. +#endif
  48. #define REG_IP_IDX REG_EIP
  49. #define si_pkey_offset 0x14
  50. +
  51. #else
  52. -#define SYS_mprotect_key 329
  53. -#define SYS_pkey_alloc 330
  54. -#define SYS_pkey_free 331
  55. +
  56. +#ifndef SYS_mprotect_key
  57. +# define SYS_mprotect_key 329
  58. +#endif
  59. +#ifndef SYS_pkey_alloc
  60. +# define SYS_pkey_alloc 330
  61. +# define SYS_pkey_free 331
  62. +#endif
  63. #define REG_IP_IDX REG_RIP
  64. #define si_pkey_offset 0x20
  65. +
  66. #endif
  67. void dump_mem(void *dumpme, int len_bytes)
  68. --
  69. 2.14.2