0167-x86-vsyscall-64-Warn-and-fail-vsyscall-emulation-in-.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. From e8354b2be6f97e97515021452082436cec8857ea Mon Sep 17 00:00:00 2001
  2. From: Andy Lutomirski <[email protected]>
  3. Date: Sun, 10 Dec 2017 22:47:20 -0800
  4. Subject: [PATCH 167/232] x86/vsyscall/64: Warn and fail vsyscall emulation in
  5. NATIVE mode
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5754
  10. If something goes wrong with pagetable setup, vsyscall=native will
  11. accidentally fall back to emulation. Make it warn and fail so that we
  12. notice.
  13. Signed-off-by: Andy Lutomirski <[email protected]>
  14. Signed-off-by: Thomas Gleixner <[email protected]>
  15. Cc: Borislav Petkov <[email protected]>
  16. Cc: Brian Gerst <[email protected]>
  17. Cc: Dave Hansen <[email protected]>
  18. Cc: David Laight <[email protected]>
  19. Cc: H. Peter Anvin <[email protected]>
  20. Cc: Josh Poimboeuf <[email protected]>
  21. Cc: Juergen Gross <[email protected]>
  22. Cc: Kees Cook <[email protected]>
  23. Cc: Linus Torvalds <[email protected]>
  24. Cc: Peter Zijlstra <[email protected]>
  25. Signed-off-by: Ingo Molnar <[email protected]>
  26. (cherry picked from commit 4831b779403a836158917d59a7ca880483c67378)
  27. Signed-off-by: Andy Whitcroft <[email protected]>
  28. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  29. (cherry picked from commit ba10c7488b12c3106d79c8b2ba3f4e79c7e40ee4)
  30. Signed-off-by: Fabian Grünbichler <[email protected]>
  31. ---
  32. arch/x86/entry/vsyscall/vsyscall_64.c | 4 ++++
  33. 1 file changed, 4 insertions(+)
  34. diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c
  35. index 91f3133cf5f1..5e56a4ced848 100644
  36. --- a/arch/x86/entry/vsyscall/vsyscall_64.c
  37. +++ b/arch/x86/entry/vsyscall/vsyscall_64.c
  38. @@ -138,6 +138,10 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
  39. WARN_ON_ONCE(address != regs->ip);
  40. + /* This should be unreachable in NATIVE mode. */
  41. + if (WARN_ON(vsyscall_mode == NATIVE))
  42. + return false;
  43. +
  44. if (vsyscall_mode == NONE) {
  45. warn_bad_vsyscall(KERN_INFO, regs,
  46. "vsyscall attempted with vsyscall=none");
  47. --
  48. 2.14.2