x86/mm: Don't free P4D table when it is folded at runtime
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 x86/mm: Don't free P4D table when it is folded at runtime
From: "[email protected]" <[email protected]>
commit 0e311d237d7f3022b7dafb639b42541bfb42fe94 upstream.
When the P4D page table layer is folded at runtime, the p4d_free() should do nothing, the same as in <asm-generic/pgtable-nop4d.h>.
It seems this bug should cause double-free in efi_call_phys_epilog(), but I don't know how to trigger that code path, so I can't confirm that by testing.
--- arch/x86/include/asm/pgalloc.h | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/include/asm/pgalloc.h +3 -0
@@ -184,6 +184,9 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr)static inline void p4d_free (struct mm_struct *mm,p4d_t *p4d) { +if (!pgtable_l5_enabled) +return ; +BUG_ON ((unsigned long )p4d & (PAGE_SIZE -1 ));free_page ((unsigned long )p4d); }
Signature · 1 line
2.16.4
Greg KH
maintainerQuoted 1 line · Andrey Ryabinin
From: "[email protected]" <[email protected]>
Huh? I didn't write this patch.
Quoted 29 lines
commit
0e311d237d7f3022b7dafb639b42541bfb42fe94upstream.When the P4D page table layer is folded at runtime, the
p4d_free()should do nothing, the same as in <asm-generic/pgtable-nop4d.h>.It seems this bug should cause double-free in
efi_call_phys_epilog(), but I don't know how to trigger that code path, so I can't confirm that by testing.Signed-off-by Andrey Ryabinin <[email protected]>Reviewed-by Kirill A. Shutemov <[email protected]>Cc Linus Torvalds <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>Cc [email protected] # 4.17Fixes 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")Signed-off-by Ingo Molnar <[email protected]>Signed-off-by Andrey Ryabinin <[email protected]>--- arch/x86/include/asm/pgalloc.h | 3 +++ 1 file changed, 3 insertions(+)arch/x86/include/asm/pgalloc.h +0
-0
arch/x86/include/asm/pgalloc.h static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr) · line 189
Quoted 6 lines
arch/x86/include/asm/pgalloc.h +3
-0@@ -184,6 +184,9 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr)static inline void p4d_free (struct mm_struct *mm,p4d_t *p4d) { +if (!pgtable_l5_enabled) +return ; +
Did you test build this patch?
Please do so, and be careful about author attribution, again, I did not write this patch.
greg k-h
Quoted 4 lines · Greg KH
Quoted 1 line · Andrey Ryabinin
From: "[email protected]" <[email protected]>
Huh? I didn't write this patch.
Right, I've noticed this and sent v2 with this fixed.
It's because I did 'git am' on your email with backported patch, but missed that git changed the autorship.
Quoted 31 lines
Quoted 31 lines
commit
0e311d237d7f3022b7dafb639b42541bfb42fe94upstream.When the P4D page table layer is folded at runtime, the
p4d_free()should do nothing, the same as in <asm-generic/pgtable-nop4d.h>.It seems this bug should cause double-free in
efi_call_phys_epilog(), but I don't know how to trigger that code path, so I can't confirm that by testing.Signed-off-by Andrey Ryabinin <[email protected]>Reviewed-by Kirill A. Shutemov <[email protected]>Cc Linus Torvalds <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>Cc [email protected] # 4.17Fixes 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")Signed-off-by Ingo Molnar <[email protected]>Signed-off-by Andrey Ryabinin <[email protected]>--- arch/x86/include/asm/pgalloc.h | 3 +++ 1 file changed, 3 insertions(+)arch/x86/include/asm/pgalloc.h +0
-0@@ -184,6 +184,9 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr)
Quoted 8 lines
arch/x86/include/asm/pgalloc.h static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr) · line 189
Quoted 5 lines
arch/x86/include/asm/pgalloc.h +3
-0static inline void p4d_free (struct mm_struct *mm,p4d_t *p4d) { +if (!pgtable_l5_enabled) +return ; +Did you test build this patch?
Sure, successfully built on top of 4.17.3
Quoted 5 lines
Please do so, and be careful about author attribution, again, I did not write this patch.
greg k-h
PATCH v2 1/1 x86/mm: Don't free P4D table when it is folded at runtime
In reply to a message not in the archivecommit 0e311d237d7f3022b7dafb639b42541bfb42fe94 upstream.
When the P4D page table layer is folded at runtime, the p4d_free() should do nothing, the same as in <asm-generic/pgtable-nop4d.h>.
It seems this bug should cause double-free in efi_call_phys_epilog(), but I don't know how to trigger that code path, so I can't confirm that by testing.
---
Changes since v1:
- Fix wrong "From:" field
arch/x86/include/asm/pgalloc.h | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/include/asm/pgalloc.h +3 -0
@@ -184,6 +184,9 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr)static inline void p4d_free (struct mm_struct *mm,p4d_t *p4d) { +if (!pgtable_l5_enabled) +return ; +BUG_ON ((unsigned long )p4d & (PAGE_SIZE -1 ));free_page ((unsigned long )p4d); }
Signature · 1 line
2.16.4
Greg KH
maintainerQuoted 32 lines · Andrey Ryabinin
commit
0e311d237d7f3022b7dafb639b42541bfb42fe94upstream.When the P4D page table layer is folded at runtime, the
p4d_free()should do nothing, the same as in <asm-generic/pgtable-nop4d.h>.It seems this bug should cause double-free in
efi_call_phys_epilog(), but I don't know how to trigger that code path, so I can't confirm that by testing.Signed-off-by Andrey Ryabinin <[email protected]>Reviewed-by Kirill A. Shutemov <[email protected]>Cc Linus Torvalds <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>Cc [email protected] # 4.17Fixes 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")Signed-off-by Ingo Molnar <[email protected]>Signed-off-by Andrey Ryabinin <[email protected]>---
Changes since v1:
- Fix wrong "From:" fieldarch/x86/include/asm/pgalloc.h | 3 +++ 1 file changed, 3 insertions(+)arch/x86/include/asm/pgalloc.h +0
-0
arch/x86/include/asm/pgalloc.h static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr) · line 189
Quoted 6 lines
arch/x86/include/asm/pgalloc.h +3
-0@@ -184,6 +184,9 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr)static inline void p4d_free (struct mm_struct *mm,p4d_t *p4d) { +if (!pgtable_l5_enabled) +return ; +
Again, did you actually test-build this? What changed from the original patch which blew the build up into little tiny pieces?
greg k-h
Quoted 34 lines · Greg KH
Quoted 33 lines · Andrey Ryabinin
commit
0e311d237d7f3022b7dafb639b42541bfb42fe94upstream.When the P4D page table layer is folded at runtime, the
p4d_free()should do nothing, the same as in <asm-generic/pgtable-nop4d.h>.It seems this bug should cause double-free in
efi_call_phys_epilog(), but I don't know how to trigger that code path, so I can't confirm that by testing.Signed-off-by Andrey Ryabinin <[email protected]>Reviewed-by Kirill A. Shutemov <[email protected]>Cc Linus Torvalds <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>Cc [email protected] # 4.17Fixes 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")Signed-off-by Ingo Molnar <[email protected]>Signed-off-by Andrey Ryabinin <[email protected]>---
Changes since v1:
- Fix wrong "From:" fieldarch/x86/include/asm/pgalloc.h | 3 +++ 1 file changed, 3 insertions(+)arch/x86/include/asm/pgalloc.h +0
-0@@ -184,6 +184,9 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr)
Quoted 7 lines
arch/x86/include/asm/pgalloc.h static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr) · line 189
Quoted 5 lines
arch/x86/include/asm/pgalloc.h +3
-0static inline void p4d_free (struct mm_struct *mm,p4d_t *p4d) { +if (!pgtable_l5_enabled) +return ; +Again, did you actually test-build this?
Again, yes, I did test-build this.
Quoted 3 lines
What changed from the original
patch which blew the build up into little tiny pieces?
Removed '()'. In 4.17 pgtable_l5_enabled is variable, in 4.18 it's function.
Quoted 2 lines
greg k-h
Greg KH
maintainerQuoted 45 lines · Andrey Ryabinin
Quoted 34 lines · Greg KH
Quoted 33 lines · Andrey Ryabinin
commit
0e311d237d7f3022b7dafb639b42541bfb42fe94upstream.When the P4D page table layer is folded at runtime, the
p4d_free()should do nothing, the same as in <asm-generic/pgtable-nop4d.h>.It seems this bug should cause double-free in
efi_call_phys_epilog(), but I don't know how to trigger that code path, so I can't confirm that by testing.Signed-off-by Andrey Ryabinin <[email protected]>Reviewed-by Kirill A. Shutemov <[email protected]>Cc Linus Torvalds <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>Cc [email protected] # 4.17Fixes 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")Signed-off-by Ingo Molnar <[email protected]>Signed-off-by Andrey Ryabinin <[email protected]>---
Changes since v1:
- Fix wrong "From:" fieldarch/x86/include/asm/pgalloc.h | 3 +++ 1 file changed, 3 insertions(+)arch/x86/include/asm/pgalloc.h +0
-0@@ -184,6 +184,9 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr)Quoted 7 lines
arch/x86/include/asm/pgalloc.h static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr) · line 189
Quoted 5 lines
arch/x86/include/asm/pgalloc.h +3
-0static inline void p4d_free (struct mm_struct *mm,p4d_t *p4d) { +if (!pgtable_l5_enabled) +return ; +Again, did you actually test-build this?
Quoted 7 lines
Again, yes, I did test-build this.
Quoted 3 lines
What changed from the original
patch which blew the build up into little tiny pieces?Removed '()'. In 4.17
pgtable_l5_enabledis variable, in 4.18 it's function.
Ah, good, it wasn't obvious that you changed anything. I'll queue this up after these latest kernels are released in a few days.
thanks,
greg k-h