0222-x86-ldt-Make-LDT-pgtable-free-conditional.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From 35ef33d8c7a31a246e499588a28717ef0bfa2a91 Mon Sep 17 00:00:00 2001
  2. From: Thomas Gleixner <[email protected]>
  3. Date: Sun, 31 Dec 2017 16:52:15 +0100
  4. Subject: [PATCH 222/242] x86/ldt: Make LDT pgtable free conditional
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. Andy prefers to be paranoid about the pagetable free in the error path of
  10. write_ldt(). Make it conditional and warn whenever the installment of a
  11. secondary LDT fails.
  12. Requested-by: Andy Lutomirski <[email protected]>
  13. Signed-off-by: Thomas Gleixner <[email protected]>
  14. (cherry picked from commit 7f414195b0c3612acd12b4611a5fe75995cf10c7)
  15. Signed-off-by: Andy Whitcroft <[email protected]>
  16. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  17. (cherry picked from commit 4e23d9d8427c9b2bd10176bd56dfcaca5e0d6b0f)
  18. Signed-off-by: Fabian Grünbichler <[email protected]>
  19. ---
  20. arch/x86/kernel/ldt.c | 3 ++-
  21. 1 file changed, 2 insertions(+), 1 deletion(-)
  22. diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
  23. index 9a35b7e541bc..51af781fac85 100644
  24. --- a/arch/x86/kernel/ldt.c
  25. +++ b/arch/x86/kernel/ldt.c
  26. @@ -425,7 +425,8 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
  27. * already installed then the PTE page is already
  28. * populated. Mop up a half populated page table.
  29. */
  30. - free_ldt_pgtables(mm);
  31. + if (!WARN_ON_ONCE(old_ldt))
  32. + free_ldt_pgtables(mm);
  33. free_ldt_struct(new_ldt);
  34. goto out_unlock;
  35. }
  36. --
  37. 2.14.2