All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: migration: deposit page table when copying a PMD migration entry.
@ 2017-10-30 14:46 ` Zi Yan
  0 siblings, 0 replies; 4+ messages in thread
From: Zi Yan @ 2017-10-30 14:46 UTC (permalink / raw)
  To: Andrew Morton, linux-mm, linux-kernel
  Cc: Kirill A . Shutemov, Zi Yan, Fengguang Wu

From: Zi Yan <zi.yan@cs.rutgers.edu>

We need to deposit pre-allocated PTE page table when a PMD migration
entry is copied in copy_huge_pmd(). Otherwise, we will leak the
pre-allocated page and cause a NULL pointer dereference later
in zap_huge_pmd().

The missing counters during PMD migration entry copy process are added
as well.

The bug report is here: https://lkml.org/lkml/2017/10/29/214

Fixes: 84c3fc4e9c563 ("mm: thp: check pmd migration entry in common path")
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Zi Yan <zi.yan@cs.rutgers.edu>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 mm/huge_memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 269b5df58543..1981ed697dab 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -941,6 +941,9 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
 				pmd = pmd_swp_mksoft_dirty(pmd);
 			set_pmd_at(src_mm, addr, src_pmd, pmd);
 		}
+		add_mm_counter(dst_mm, MM_ANONPAGES, HPAGE_PMD_NR);
+		atomic_long_inc(&dst_mm->nr_ptes);
+		pgtable_trans_huge_deposit(dst_mm, dst_pmd, pgtable);
 		set_pmd_at(dst_mm, addr, dst_pmd, pmd);
 		ret = 0;
 		goto out_unlock;
-- 
2.14.2

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

* [PATCH] mm: migration: deposit page table when copying a PMD migration entry.
@ 2017-10-30 14:46 ` Zi Yan
  0 siblings, 0 replies; 4+ messages in thread
From: Zi Yan @ 2017-10-30 14:46 UTC (permalink / raw)
  To: Andrew Morton, linux-mm, linux-kernel
  Cc: Kirill A . Shutemov, Zi Yan, Fengguang Wu

From: Zi Yan <zi.yan@cs.rutgers.edu>

We need to deposit pre-allocated PTE page table when a PMD migration
entry is copied in copy_huge_pmd(). Otherwise, we will leak the
pre-allocated page and cause a NULL pointer dereference later
in zap_huge_pmd().

The missing counters during PMD migration entry copy process are added
as well.

The bug report is here: https://lkml.org/lkml/2017/10/29/214

Fixes: 84c3fc4e9c563 ("mm: thp: check pmd migration entry in common path")
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Zi Yan <zi.yan@cs.rutgers.edu>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 mm/huge_memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 269b5df58543..1981ed697dab 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -941,6 +941,9 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
 				pmd = pmd_swp_mksoft_dirty(pmd);
 			set_pmd_at(src_mm, addr, src_pmd, pmd);
 		}
+		add_mm_counter(dst_mm, MM_ANONPAGES, HPAGE_PMD_NR);
+		atomic_long_inc(&dst_mm->nr_ptes);
+		pgtable_trans_huge_deposit(dst_mm, dst_pmd, pgtable);
 		set_pmd_at(dst_mm, addr, dst_pmd, pmd);
 		ret = 0;
 		goto out_unlock;
-- 
2.14.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm: migration: deposit page table when copying a PMD migration entry.
  2017-10-30 14:46 ` Zi Yan
@ 2017-10-30 16:09   ` Kirill A. Shutemov
  -1 siblings, 0 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2017-10-30 16:09 UTC (permalink / raw)
  To: Zi Yan
  Cc: Andrew Morton, linux-mm, linux-kernel, Kirill A . Shutemov,
	Zi Yan, Fengguang Wu

On Mon, Oct 30, 2017 at 10:46:36AM -0400, Zi Yan wrote:
> From: Zi Yan <zi.yan@cs.rutgers.edu>
> 
> We need to deposit pre-allocated PTE page table when a PMD migration
> entry is copied in copy_huge_pmd(). Otherwise, we will leak the
> pre-allocated page and cause a NULL pointer dereference later
> in zap_huge_pmd().
> 
> The missing counters during PMD migration entry copy process are added
> as well.
> 
> The bug report is here: https://lkml.org/lkml/2017/10/29/214
> 
> Fixes: 84c3fc4e9c563 ("mm: thp: check pmd migration entry in common path")
> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> Signed-off-by: Zi Yan <zi.yan@cs.rutgers.edu>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov

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

* Re: [PATCH] mm: migration: deposit page table when copying a PMD migration entry.
@ 2017-10-30 16:09   ` Kirill A. Shutemov
  0 siblings, 0 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2017-10-30 16:09 UTC (permalink / raw)
  To: Zi Yan
  Cc: Andrew Morton, linux-mm, linux-kernel, Kirill A . Shutemov,
	Zi Yan, Fengguang Wu

On Mon, Oct 30, 2017 at 10:46:36AM -0400, Zi Yan wrote:
> From: Zi Yan <zi.yan@cs.rutgers.edu>
> 
> We need to deposit pre-allocated PTE page table when a PMD migration
> entry is copied in copy_huge_pmd(). Otherwise, we will leak the
> pre-allocated page and cause a NULL pointer dereference later
> in zap_huge_pmd().
> 
> The missing counters during PMD migration entry copy process are added
> as well.
> 
> The bug report is here: https://lkml.org/lkml/2017/10/29/214
> 
> Fixes: 84c3fc4e9c563 ("mm: thp: check pmd migration entry in common path")
> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> Signed-off-by: Zi Yan <zi.yan@cs.rutgers.edu>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2017-10-30 16:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-30 14:46 [PATCH] mm: migration: deposit page table when copying a PMD migration entry Zi Yan
2017-10-30 14:46 ` Zi Yan
2017-10-30 16:09 ` Kirill A. Shutemov
2017-10-30 16:09   ` Kirill A. Shutemov

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.