Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1425425 > unrolled thread

[PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is used inappropriately

Started byAndy Lutomirski <luto@kernel.org>
First post2016-06-17 22:10 +0200
Last post2016-06-18 12:40 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is used inappropriately Andy Lutomirski <luto@kernel.org> - 2016-06-17 22:10 +0200
    Re: [PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is  used inappropriately Borislav Petkov <bp@alien8.de> - 2016-06-17 22:40 +0200
      Re: [PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is  used inappropriately Andy Lutomirski <luto@amacapital.net> - 2016-06-18 12:30 +0200
        Re: [PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is  used inappropriately Borislav Petkov <bp@alien8.de> - 2016-06-18 12:40 +0200

#1425425 — [PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is used inappropriately

FromAndy Lutomirski <luto@kernel.org>
Date2016-06-17 22:10 +0200
Subject[PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is used inappropriately
Message-ID<rL8fv-2Ds-17@gated-at.bofh.it>
It's currently only used in the EFI code, which is safe AFAICT.
Warn if anyone tries to use it on the normal kernel pgd.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/mm/pageattr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 6a8026918bf6..e9b9c5cedbb8 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -1996,6 +1996,9 @@ out:
 void kernel_unmap_pages_in_pgd(pgd_t *root, unsigned long address,
 			       unsigned numpages)
 {
+	/* Unmapping kernel entries from init_mm's pgd is not allowed. */
+	WARN_ON(root == init_mm.pgd);
+
 	unmap_pgd_range(root, address, address + (numpages << PAGE_SHIFT));
 }
 
-- 
2.5.5

[toc] | [next] | [standalone]


#1425458 — Re: [PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is used inappropriately

FromBorislav Petkov <bp@alien8.de>
Date2016-06-17 22:40 +0200
SubjectRe: [PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is used inappropriately
Message-ID<rL8Ix-2Uy-5@gated-at.bofh.it>
In reply to#1425425
On Fri, Jun 17, 2016 at 01:00:39PM -0700, Andy Lutomirski wrote:
> It's currently only used in the EFI code, which is safe AFAICT.

"It is basically useful for a pagetable hierarchy which is not init_mm."

> Warn if anyone tries to use it on the normal kernel pgd.
> 
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
>  arch/x86/mm/pageattr.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
> index 6a8026918bf6..e9b9c5cedbb8 100644
> --- a/arch/x86/mm/pageattr.c
> +++ b/arch/x86/mm/pageattr.c
> @@ -1996,6 +1996,9 @@ out:
>  void kernel_unmap_pages_in_pgd(pgd_t *root, unsigned long address,
>  			       unsigned numpages)
>  {
> +	/* Unmapping kernel entries from init_mm's pgd is not allowed. */
> +	WARN_ON(root == init_mm.pgd);

We can also return and not do the unmapping:

	if (WARN_ON(root == init_mm.pgd))
		return;

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

[toc] | [prev] | [next] | [standalone]


#1425690 — Re: [PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is used inappropriately

FromAndy Lutomirski <luto@amacapital.net>
Date2016-06-18 12:30 +0200
SubjectRe: [PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is used inappropriately
Message-ID<rLlFM-2MV-31@gated-at.bofh.it>
In reply to#1425458
On Fri, Jun 17, 2016 at 1:30 PM, Borislav Petkov <bp@alien8.de> wrote:
> On Fri, Jun 17, 2016 at 01:00:39PM -0700, Andy Lutomirski wrote:
>> It's currently only used in the EFI code, which is safe AFAICT.
>
> "It is basically useful for a pagetable hierarchy which is not init_mm."
>
>> Warn if anyone tries to use it on the normal kernel pgd.
>>
>> Signed-off-by: Andy Lutomirski <luto@kernel.org>
>> ---
>>  arch/x86/mm/pageattr.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
>> index 6a8026918bf6..e9b9c5cedbb8 100644
>> --- a/arch/x86/mm/pageattr.c
>> +++ b/arch/x86/mm/pageattr.c
>> @@ -1996,6 +1996,9 @@ out:
>>  void kernel_unmap_pages_in_pgd(pgd_t *root, unsigned long address,
>>                              unsigned numpages)
>>  {
>> +     /* Unmapping kernel entries from init_mm's pgd is not allowed. */
>> +     WARN_ON(root == init_mm.pgd);
>
> We can also return and not do the unmapping:
>
>         if (WARN_ON(root == init_mm.pgd))
>                 return;

I'll do one better: the only function that calls this function is
unused.  I'll just delete it.

--Andy

[toc] | [prev] | [next] | [standalone]


#1425694 — Re: [PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is used inappropriately

FromBorislav Petkov <bp@alien8.de>
Date2016-06-18 12:40 +0200
SubjectRe: [PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is used inappropriately
Message-ID<rLlPr-2Q1-7@gated-at.bofh.it>
In reply to#1425690
On Sat, Jun 18, 2016 at 03:29:01AM -0700, Andy Lutomirski wrote:
> I'll do one better: the only function that calls this function is
> unused.  I'll just delete it.

Fair enough - Matt is on CC.

Btw, normally I'm almost never talking to you at that time of the day,
what's up? Can't sleep?

:-))

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web