All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: "Hong H. Pham" <hong.pham@windriver.com>,
	linux-rt-users <linux-rt-users@vger.kernel.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Cc: Paul Mackerras <paulus@samba.org>,
	"Hong H. Pham" <hong.pham@windriver.com>,
	linux-stable <stable@vger.kernel.org>
Subject: Re: [PATCH] powerpc: Fix PTE page address mismatch in pgtable ctor/dtor
Date: Fri, 06 Dec 2013 16:08:19 +0530	[thread overview]
Message-ID: <874n6muuw4.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1386258894-21851-1-git-send-email-hong.pham@windriver.com>

"Hong H. Pham" <hong.pham@windriver.com> writes:

> In pte_alloc_one(), pgtable_page_ctor() is passed an address that has
> not been converted by page_address() to the newly allocated PTE page.
>
> When the PTE is freed, __pte_free_tlb() calls pgtable_page_dtor()
> with an address to the PTE page that has been converted by page_address().
> The mismatch in the PTE's page address causes pgtable_page_dtor() to access
> invalid memory, so resources for that PTE (such as the page lock) is not
> properly cleaned up.
>
> This bug was introduced by commit d614bb041209fd7cb5e4b35e11a7b2f6ee8f62b8
> "powerpc: Move the pte free routines from common header".
>
> On a preempt-rt kernel, a spinlock is dynamically allocated for each
> PTE in pgtable_page_ctor().  When the PTE is freed, calling
> pgtable_page_dtor() with a mismatched page address causes a memory leak,
> as the pointer to the PTE's spinlock is bogus.
>
> On mainline, there isn't any immediately obvious symptoms, but the
> problem still exists here.


can you also specifiy the config details here. ie, 4K page size functions
are broken ?

>
> Fixes: d614bb041209fd7c "powerpc: Move the pte free routes from common header"
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: linux-stable <stable@vger.kernel.org> # v3.10+
> Signed-off-by: Hong H. Pham <hong.pham@windriver.com>
> ---
>  arch/powerpc/include/asm/pgalloc-32.h | 2 +-
>  arch/powerpc/include/asm/pgalloc-64.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/pgalloc-32.h b/arch/powerpc/include/asm/pgalloc-32.h
> index 27b2386..7ff24f0 100644
> --- a/arch/powerpc/include/asm/pgalloc-32.h
> +++ b/arch/powerpc/include/asm/pgalloc-32.h
> @@ -87,7 +87,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
>  	struct page *page = page_address(table);
>
>  	tlb_flush_pgtable(tlb, address);
> -	pgtable_page_dtor(page);
> +	pgtable_page_dtor(table);
>  	pgtable_free_tlb(tlb, page, 0);
>  }
>  #endif /* _ASM_POWERPC_PGALLOC_32_H */
> diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
> index f65e27b..b187dc5 100644
> --- a/arch/powerpc/include/asm/pgalloc-64.h
> +++ b/arch/powerpc/include/asm/pgalloc-64.h
> @@ -147,7 +147,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
>  	struct page *page = page_address(table);


That one is also wrong right ? why not 

>
>  	tlb_flush_pgtable(tlb, address);
> -	pgtable_page_dtor(page);
> +	pgtable_page_dtor(table);
>  	pgtable_free_tlb(tlb, page, 0);
>  }
>

make it closer to what it was before,

pgtable_page_dtor(table);
pgtable_free_tlb(tlb, page_address(table), 0);

This is what we had before

-static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage,
-                                 unsigned long address)
-{
-       tlb_flush_pgtable(tlb, address);
-       pgtable_page_dtor(ptepage);
-       pgtable_free_tlb(tlb, page_address(ptepage), 0);
-}


-aneesh

WARNING: multiple messages have this Message-ID (diff)
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: "Hong H. Pham" <hong.pham@windriver.com>,
	linux-rt-users <linux-rt-users@vger.kernel.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Cc: "Hong H. Pham" <hong.pham@windriver.com>,
	Paul Mackerras <paulus@samba.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	linux-stable <stable@vger.kernel.org>
Subject: Re: [PATCH] powerpc: Fix PTE page address mismatch in pgtable ctor/dtor
Date: Fri, 06 Dec 2013 16:08:19 +0530	[thread overview]
Message-ID: <874n6muuw4.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1386258894-21851-1-git-send-email-hong.pham@windriver.com>

"Hong H. Pham" <hong.pham@windriver.com> writes:

> In pte_alloc_one(), pgtable_page_ctor() is passed an address that has
> not been converted by page_address() to the newly allocated PTE page.
>
> When the PTE is freed, __pte_free_tlb() calls pgtable_page_dtor()
> with an address to the PTE page that has been converted by page_address().
> The mismatch in the PTE's page address causes pgtable_page_dtor() to access
> invalid memory, so resources for that PTE (such as the page lock) is not
> properly cleaned up.
>
> This bug was introduced by commit d614bb041209fd7cb5e4b35e11a7b2f6ee8f62b8
> "powerpc: Move the pte free routines from common header".
>
> On a preempt-rt kernel, a spinlock is dynamically allocated for each
> PTE in pgtable_page_ctor().  When the PTE is freed, calling
> pgtable_page_dtor() with a mismatched page address causes a memory leak,
> as the pointer to the PTE's spinlock is bogus.
>
> On mainline, there isn't any immediately obvious symptoms, but the
> problem still exists here.


can you also specifiy the config details here. ie, 4K page size functions
are broken ?

>
> Fixes: d614bb041209fd7c "powerpc: Move the pte free routes from common header"
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: linux-stable <stable@vger.kernel.org> # v3.10+
> Signed-off-by: Hong H. Pham <hong.pham@windriver.com>
> ---
>  arch/powerpc/include/asm/pgalloc-32.h | 2 +-
>  arch/powerpc/include/asm/pgalloc-64.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/pgalloc-32.h b/arch/powerpc/include/asm/pgalloc-32.h
> index 27b2386..7ff24f0 100644
> --- a/arch/powerpc/include/asm/pgalloc-32.h
> +++ b/arch/powerpc/include/asm/pgalloc-32.h
> @@ -87,7 +87,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
>  	struct page *page = page_address(table);
>
>  	tlb_flush_pgtable(tlb, address);
> -	pgtable_page_dtor(page);
> +	pgtable_page_dtor(table);
>  	pgtable_free_tlb(tlb, page, 0);
>  }
>  #endif /* _ASM_POWERPC_PGALLOC_32_H */
> diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
> index f65e27b..b187dc5 100644
> --- a/arch/powerpc/include/asm/pgalloc-64.h
> +++ b/arch/powerpc/include/asm/pgalloc-64.h
> @@ -147,7 +147,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
>  	struct page *page = page_address(table);


That one is also wrong right ? why not 

>
>  	tlb_flush_pgtable(tlb, address);
> -	pgtable_page_dtor(page);
> +	pgtable_page_dtor(table);
>  	pgtable_free_tlb(tlb, page, 0);
>  }
>

make it closer to what it was before,

pgtable_page_dtor(table);
pgtable_free_tlb(tlb, page_address(table), 0);

This is what we had before

-static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage,
-                                 unsigned long address)
-{
-       tlb_flush_pgtable(tlb, address);
-       pgtable_page_dtor(ptepage);
-       pgtable_free_tlb(tlb, page_address(ptepage), 0);
-}


-aneesh

  reply	other threads:[~2013-12-06 10:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05 15:54 [PATCH] powerpc: Fix PTE page address mismatch in pgtable ctor/dtor Hong H. Pham
2013-12-05 15:54 ` Hong H. Pham
2013-12-06 10:38 ` Aneesh Kumar K.V [this message]
2013-12-06 10:38   ` Aneesh Kumar K.V
2013-12-06 16:15   ` Hong H. Pham
2013-12-06 16:15     ` Hong H. Pham
2013-12-07 14:05     ` Hong H. Pham
2013-12-07 14:05       ` Hong H. Pham
2013-12-06 16:17   ` [PATCH v2] " Hong H. Pham
2013-12-06 16:17     ` Hong H. Pham
2013-12-07 14:06   ` [PATCH v3] " Hong H. Pham
2013-12-07 14:06     ` Hong H. Pham
2013-12-07 20:27     ` Benjamin Herrenschmidt
2013-12-07 20:27       ` Benjamin Herrenschmidt
2013-12-07 20:32       ` Benjamin Herrenschmidt
2013-12-07 20:32         ` Benjamin Herrenschmidt
2013-12-09  8:41       ` Aneesh Kumar K.V
2013-12-09  8:41         ` Aneesh Kumar K.V
2013-12-09  8:42     ` Aneesh Kumar K.V
2013-12-09  8:42       ` Aneesh Kumar K.V
2013-12-15 12:59     ` Sebastian Andrzej Siewior
2013-12-15 12:59       ` Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874n6muuw4.fsf@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=hong.pham@windriver.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.