0215-x86-mm-dump_pagetables-Add-page-table-directory-to-t.patch 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. From d03b4d2a3e43228bb98fae4c6f5365d4f9d00f4c Mon Sep 17 00:00:00 2001
  2. From: Borislav Petkov <[email protected]>
  3. Date: Mon, 4 Dec 2017 15:08:04 +0100
  4. Subject: [PATCH 215/232] x86/mm/dump_pagetables: Add page table directory to
  5. the debugfs VFS hierarchy
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5754
  10. The upcoming support for dumping the kernel and the user space page tables
  11. of the current process would create more random files in the top level
  12. debugfs directory.
  13. Add a page table directory and move the existing file to it.
  14. Signed-off-by: Borislav Petkov <[email protected]>
  15. Signed-off-by: Thomas Gleixner <[email protected]>
  16. Cc: Andy Lutomirski <[email protected]>
  17. Cc: Boris Ostrovsky <[email protected]>
  18. Cc: Borislav Petkov <[email protected]>
  19. Cc: Brian Gerst <[email protected]>
  20. Cc: Dave Hansen <[email protected]>
  21. Cc: David Laight <[email protected]>
  22. Cc: Denys Vlasenko <[email protected]>
  23. Cc: Eduardo Valentin <[email protected]>
  24. Cc: Greg KH <[email protected]>
  25. Cc: H. Peter Anvin <[email protected]>
  26. Cc: Josh Poimboeuf <[email protected]>
  27. Cc: Juergen Gross <[email protected]>
  28. Cc: Linus Torvalds <[email protected]>
  29. Cc: Peter Zijlstra <[email protected]>
  30. Cc: Will Deacon <[email protected]>
  31. Cc: [email protected]
  32. Cc: [email protected]
  33. Cc: [email protected]
  34. Cc: [email protected]
  35. Signed-off-by: Ingo Molnar <[email protected]>
  36. (cherry picked from commit 75298aa179d56cd64f54e58a19fffc8ab922b4c0)
  37. Signed-off-by: Andy Whitcroft <[email protected]>
  38. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  39. (cherry picked from commit ae5c4af9bbefed4adc12075c28fb5889547c99cc)
  40. Signed-off-by: Fabian Grünbichler <[email protected]>
  41. ---
  42. arch/x86/mm/debug_pagetables.c | 15 ++++++++++-----
  43. 1 file changed, 10 insertions(+), 5 deletions(-)
  44. diff --git a/arch/x86/mm/debug_pagetables.c b/arch/x86/mm/debug_pagetables.c
  45. index bfcffdf6c577..d1449fb6dc7a 100644
  46. --- a/arch/x86/mm/debug_pagetables.c
  47. +++ b/arch/x86/mm/debug_pagetables.c
  48. @@ -22,21 +22,26 @@ static const struct file_operations ptdump_fops = {
  49. .release = single_release,
  50. };
  51. -static struct dentry *pe;
  52. +static struct dentry *dir, *pe;
  53. static int __init pt_dump_debug_init(void)
  54. {
  55. - pe = debugfs_create_file("kernel_page_tables", S_IRUSR, NULL, NULL,
  56. - &ptdump_fops);
  57. - if (!pe)
  58. + dir = debugfs_create_dir("page_tables", NULL);
  59. + if (!dir)
  60. return -ENOMEM;
  61. + pe = debugfs_create_file("kernel", 0400, dir, NULL, &ptdump_fops);
  62. + if (!pe)
  63. + goto err;
  64. return 0;
  65. +err:
  66. + debugfs_remove_recursive(dir);
  67. + return -ENOMEM;
  68. }
  69. static void __exit pt_dump_debug_exit(void)
  70. {
  71. - debugfs_remove_recursive(pe);
  72. + debugfs_remove_recursive(dir);
  73. }
  74. module_init(pt_dump_debug_init);
  75. --
  76. 2.14.2