0115-selftests-x86-ldt_gdt-Run-most-existing-LDT-test-cas.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From 8307fa79c19ddc006d5f816f6eb5127d9064dcd3 Mon Sep 17 00:00:00 2001
  2. From: Andy Lutomirski <[email protected]>
  3. Date: Sat, 4 Nov 2017 04:19:51 -0700
  4. Subject: [PATCH 115/232] selftests/x86/ldt_gdt: Run most existing LDT test
  5. cases against the GDT as well
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5754
  10. Now that the main test infrastructure supports the GDT, run tests
  11. that will pass the kernel's GDT permission tests against the GDT.
  12. Signed-off-by: Andy Lutomirski <[email protected]>
  13. Cc: Borislav Petkov <[email protected]>
  14. Cc: Linus Torvalds <[email protected]>
  15. Cc: Peter Zijlstra <[email protected]>
  16. Cc: Thomas Gleixner <[email protected]>
  17. Link: http://lkml.kernel.org/r/686a1eda63414da38fcecc2412db8dba1ae40581.1509794321.git.luto@kernel.org
  18. Signed-off-by: Ingo Molnar <[email protected]>
  19. (cherry picked from commit adedf2893c192dd09b1cc2f2dcfdd7cad99ec49d)
  20. Signed-off-by: Andy Whitcroft <[email protected]>
  21. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  22. (cherry picked from commit f05c092307d8479094d83d4337d66e6e86e730a9)
  23. Signed-off-by: Fabian Grünbichler <[email protected]>
  24. ---
  25. tools/testing/selftests/x86/ldt_gdt.c | 10 +++++++++-
  26. 1 file changed, 9 insertions(+), 1 deletion(-)
  27. diff --git a/tools/testing/selftests/x86/ldt_gdt.c b/tools/testing/selftests/x86/ldt_gdt.c
  28. index 337f217d0ae9..05d0d6f49c2c 100644
  29. --- a/tools/testing/selftests/x86/ldt_gdt.c
  30. +++ b/tools/testing/selftests/x86/ldt_gdt.c
  31. @@ -188,7 +188,15 @@ static bool install_valid_mode(const struct user_desc *d, uint32_t ar,
  32. static bool install_valid(const struct user_desc *desc, uint32_t ar)
  33. {
  34. - return install_valid_mode(desc, ar, false, true);
  35. + bool ret = install_valid_mode(desc, ar, false, true);
  36. +
  37. + if (desc->contents <= 1 && desc->seg_32bit &&
  38. + !desc->seg_not_present) {
  39. + /* Should work in the GDT, too. */
  40. + install_valid_mode(desc, ar, false, false);
  41. + }
  42. +
  43. + return ret;
  44. }
  45. static void install_invalid(const struct user_desc *desc, bool oldmode)
  46. --
  47. 2.14.2