0116-selftests-x86-ldt_get-Add-a-few-additional-tests-for.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Andy Lutomirski <[email protected]>
  3. Date: Sat, 4 Nov 2017 04:19:52 -0700
  4. Subject: [PATCH] selftests/x86/ldt_get: Add a few additional tests for limits
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. We weren't testing the .limit and .limit_in_pages fields very well.
  10. Add more tests.
  11. This addition seems to trigger the "bits 16:19 are undefined" issue
  12. that was fixed in an earlier patch. I think that, at least on my
  13. CPU, the high nibble of the limit ends in LAR bits 16:19.
  14. Signed-off-by: Andy Lutomirski <[email protected]>
  15. Cc: Borislav Petkov <[email protected]>
  16. Cc: Linus Torvalds <[email protected]>
  17. Cc: Peter Zijlstra <[email protected]>
  18. Cc: Thomas Gleixner <[email protected]>
  19. Link: http://lkml.kernel.org/r/5601c15ea9b3113d288953fd2838b18bedf6bc67.1509794321.git.luto@kernel.org
  20. Signed-off-by: Ingo Molnar <[email protected]>
  21. (cherry picked from commit fec8f5ae1715a01c72ad52cb2ecd8aacaf142302)
  22. Signed-off-by: Andy Whitcroft <[email protected]>
  23. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  24. (cherry picked from commit a1cdabf77d7ed9ba02697ad8beb04adf46a7c7b8)
  25. Signed-off-by: Fabian Grünbichler <[email protected]>
  26. ---
  27. tools/testing/selftests/x86/ldt_gdt.c | 17 ++++++++++++++++-
  28. 1 file changed, 16 insertions(+), 1 deletion(-)
  29. diff --git a/tools/testing/selftests/x86/ldt_gdt.c b/tools/testing/selftests/x86/ldt_gdt.c
  30. index 05d0d6f49c2c..8e290c9b2c3f 100644
  31. --- a/tools/testing/selftests/x86/ldt_gdt.c
  32. +++ b/tools/testing/selftests/x86/ldt_gdt.c
  33. @@ -403,9 +403,24 @@ static void do_simple_tests(void)
  34. install_invalid(&desc, false);
  35. desc.seg_not_present = 0;
  36. - desc.read_exec_only = 0;
  37. desc.seg_32bit = 1;
  38. + desc.read_exec_only = 0;
  39. + desc.limit = 0xfffff;
  40. +
  41. install_valid(&desc, AR_DPL3 | AR_TYPE_RWDATA | AR_S | AR_P | AR_DB);
  42. +
  43. + desc.limit_in_pages = 1;
  44. +
  45. + install_valid(&desc, AR_DPL3 | AR_TYPE_RWDATA | AR_S | AR_P | AR_DB | AR_G);
  46. + desc.read_exec_only = 1;
  47. + install_valid(&desc, AR_DPL3 | AR_TYPE_RODATA | AR_S | AR_P | AR_DB | AR_G);
  48. + desc.contents = 1;
  49. + desc.read_exec_only = 0;
  50. + install_valid(&desc, AR_DPL3 | AR_TYPE_RWDATA_EXPDOWN | AR_S | AR_P | AR_DB | AR_G);
  51. + desc.read_exec_only = 1;
  52. + install_valid(&desc, AR_DPL3 | AR_TYPE_RODATA_EXPDOWN | AR_S | AR_P | AR_DB | AR_G);
  53. +
  54. + desc.limit = 0;
  55. install_invalid(&desc, true);
  56. }
  57. --
  58. 2.14.2