stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4.17] x86/mm: Don't free P4D table when it is folded at runtime
       [not found] <20180701143858.GA22410@kroah.com>
@ 2018-07-02  8:45 ` Andrey Ryabinin
  2018-07-02  8:47   ` Greg KH
  2018-07-02  8:48 ` [PATCH 4.17 v2] " Andrey Ryabinin
  1 sibling, 1 reply; 7+ messages in thread
From: Andrey Ryabinin @ 2018-07-02  8:45 UTC (permalink / raw)
  To: Greg KH
  Cc: stable-commits, Andrey Ryabinin, Linus Torvalds, Peter Zijlstra,
	Thomas Gleixner, stable, Ingo Molnar

From: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>

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.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org # 4.17
Fixes: 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")
Link: http://lkml.kernel.org/r/20180625102427.15015-1-aryabinin@virtuozzo.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 arch/x86/include/asm/pgalloc.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
index 263c142a6a6c..f65e9e1cea4c 100644
--- a/arch/x86/include/asm/pgalloc.h
+++ b/arch/x86/include/asm/pgalloc.h
@@ -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);
 }
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 4.17] x86/mm: Don't free P4D table when it is folded at runtime
  2018-07-02  8:45 ` [PATCH 4.17] x86/mm: Don't free P4D table when it is folded at runtime Andrey Ryabinin
@ 2018-07-02  8:47   ` Greg KH
  2018-07-02  9:01     ` Andrey Ryabinin
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2018-07-02  8:47 UTC (permalink / raw)
  To: Andrey Ryabinin
  Cc: stable-commits, Linus Torvalds, Peter Zijlstra, Thomas Gleixner,
	stable, Ingo Molnar

On Mon, Jul 02, 2018 at 11:45:36AM +0300, Andrey Ryabinin wrote:
> From: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>

Huh?  I didn't write this patch.

> 
> 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.
> 
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: stable@vger.kernel.org # 4.17
> Fixes: 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")
> Link: http://lkml.kernel.org/r/20180625102427.15015-1-aryabinin@virtuozzo.com
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> ---
>  arch/x86/include/asm/pgalloc.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
> index 263c142a6a6c..f65e9e1cea4c 100644
> --- a/arch/x86/include/asm/pgalloc.h
> +++ b/arch/x86/include/asm/pgalloc.h
> @@ -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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4.17 v2] x86/mm: Don't free P4D table when it is folded at runtime
       [not found] <20180701143858.GA22410@kroah.com>
  2018-07-02  8:45 ` [PATCH 4.17] x86/mm: Don't free P4D table when it is folded at runtime Andrey Ryabinin
@ 2018-07-02  8:48 ` Andrey Ryabinin
  2018-07-02  9:15   ` Greg KH
  1 sibling, 1 reply; 7+ messages in thread
From: Andrey Ryabinin @ 2018-07-02  8:48 UTC (permalink / raw)
  To: Greg KH
  Cc: stable-commits, Andrey Ryabinin, Linus Torvalds, Peter Zijlstra,
	Thomas Gleixner, stable, Ingo Molnar

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.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org # 4.17
Fixes: 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")
Link: http://lkml.kernel.org/r/20180625102427.15015-1-aryabinin@virtuozzo.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---

Changes since v1:
 - Fix wrong "From:" field

 arch/x86/include/asm/pgalloc.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
index 263c142a6a6c..f65e9e1cea4c 100644
--- a/arch/x86/include/asm/pgalloc.h
+++ b/arch/x86/include/asm/pgalloc.h
@@ -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);
 }
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 4.17] x86/mm: Don't free P4D table when it is folded at runtime
  2018-07-02  8:47   ` Greg KH
@ 2018-07-02  9:01     ` Andrey Ryabinin
  0 siblings, 0 replies; 7+ messages in thread
From: Andrey Ryabinin @ 2018-07-02  9:01 UTC (permalink / raw)
  To: Greg KH
  Cc: stable-commits, Linus Torvalds, Peter Zijlstra, Thomas Gleixner,
	stable, Ingo Molnar



On 07/02/2018 11:47 AM, Greg KH wrote:
> On Mon, Jul 02, 2018 at 11:45:36AM +0300, Andrey Ryabinin wrote:
>> From: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
> 
> 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.


> 
>>
>> 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.
>>
>> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>> Cc: Peter Zijlstra <peterz@infradead.org>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: stable@vger.kernel.org # 4.17
>> Fixes: 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")
>> Link: http://lkml.kernel.org/r/20180625102427.15015-1-aryabinin@virtuozzo.com
>> Signed-off-by: Ingo Molnar <mingo@kernel.org>
>> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>> ---
>>  arch/x86/include/asm/pgalloc.h | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
>> index 263c142a6a6c..f65e9e1cea4c 100644
>> --- a/arch/x86/include/asm/pgalloc.h
>> +++ b/arch/x86/include/asm/pgalloc.h
>> @@ -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?
> 

Sure, successfully built on top of 4.17.3

> Please do so, and be careful about author attribution, again, I did not
> write this patch.
> 
> greg k-h
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4.17 v2] x86/mm: Don't free P4D table when it is folded at runtime
  2018-07-02  8:48 ` [PATCH 4.17 v2] " Andrey Ryabinin
@ 2018-07-02  9:15   ` Greg KH
  2018-07-02  9:20     ` Andrey Ryabinin
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2018-07-02  9:15 UTC (permalink / raw)
  To: Andrey Ryabinin
  Cc: stable-commits, Linus Torvalds, Peter Zijlstra, Thomas Gleixner,
	stable, Ingo Molnar

On Mon, Jul 02, 2018 at 11:48:28AM +0300, Andrey Ryabinin wrote:
> 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.
> 
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: stable@vger.kernel.org # 4.17
> Fixes: 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")
> Link: http://lkml.kernel.org/r/20180625102427.15015-1-aryabinin@virtuozzo.com
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> ---
> 
> Changes since v1:
>  - Fix wrong "From:" field
> 
>  arch/x86/include/asm/pgalloc.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
> index 263c142a6a6c..f65e9e1cea4c 100644
> --- a/arch/x86/include/asm/pgalloc.h
> +++ b/arch/x86/include/asm/pgalloc.h
> @@ -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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4.17 v2] x86/mm: Don't free P4D table when it is folded at runtime
  2018-07-02  9:15   ` Greg KH
@ 2018-07-02  9:20     ` Andrey Ryabinin
  2018-07-02  9:37       ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Andrey Ryabinin @ 2018-07-02  9:20 UTC (permalink / raw)
  To: Greg KH
  Cc: stable-commits, Linus Torvalds, Peter Zijlstra, Thomas Gleixner,
	stable, Ingo Molnar



On 07/02/2018 12:15 PM, Greg KH wrote:
> On Mon, Jul 02, 2018 at 11:48:28AM +0300, Andrey Ryabinin wrote:
>> 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.
>>
>> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>> Cc: Peter Zijlstra <peterz@infradead.org>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: stable@vger.kernel.org # 4.17
>> Fixes: 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")
>> Link: http://lkml.kernel.org/r/20180625102427.15015-1-aryabinin@virtuozzo.com
>> Signed-off-by: Ingo Molnar <mingo@kernel.org>
>> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>> ---
>>
>> Changes since v1:
>>  - Fix wrong "From:" field
>>
>>  arch/x86/include/asm/pgalloc.h | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
>> index 263c142a6a6c..f65e9e1cea4c 100644
>> --- a/arch/x86/include/asm/pgalloc.h
>> +++ b/arch/x86/include/asm/pgalloc.h
>> @@ -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?

Again, yes, I did test-build this.

> 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.

> greg k-h
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4.17 v2] x86/mm: Don't free P4D table when it is folded at runtime
  2018-07-02  9:20     ` Andrey Ryabinin
@ 2018-07-02  9:37       ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2018-07-02  9:37 UTC (permalink / raw)
  To: Andrey Ryabinin
  Cc: stable-commits, Linus Torvalds, Peter Zijlstra, Thomas Gleixner,
	stable, Ingo Molnar

On Mon, Jul 02, 2018 at 12:20:06PM +0300, Andrey Ryabinin wrote:
> 
> 
> On 07/02/2018 12:15 PM, Greg KH wrote:
> > On Mon, Jul 02, 2018 at 11:48:28AM +0300, Andrey Ryabinin wrote:
> >> 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.
> >>
> >> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> >> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> >> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> >> Cc: Peter Zijlstra <peterz@infradead.org>
> >> Cc: Thomas Gleixner <tglx@linutronix.de>
> >> Cc: stable@vger.kernel.org # 4.17
> >> Fixes: 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")
> >> Link: http://lkml.kernel.org/r/20180625102427.15015-1-aryabinin@virtuozzo.com
> >> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> >> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> >> ---
> >>
> >> Changes since v1:
> >>  - Fix wrong "From:" field
> >>
> >>  arch/x86/include/asm/pgalloc.h | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
> >> index 263c142a6a6c..f65e9e1cea4c 100644
> >> --- a/arch/x86/include/asm/pgalloc.h
> >> +++ b/arch/x86/include/asm/pgalloc.h
> >> @@ -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?
> 
> Again, yes, I did test-build this.
> 
> > 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.

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-07-02  9:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20180701143858.GA22410@kroah.com>
2018-07-02  8:45 ` [PATCH 4.17] x86/mm: Don't free P4D table when it is folded at runtime Andrey Ryabinin
2018-07-02  8:47   ` Greg KH
2018-07-02  9:01     ` Andrey Ryabinin
2018-07-02  8:48 ` [PATCH 4.17 v2] " Andrey Ryabinin
2018-07-02  9:15   ` Greg KH
2018-07-02  9:20     ` Andrey Ryabinin
2018-07-02  9:37       ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).