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

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