lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 15 Mar 2018 09:18:40 +0800
From:   "Huang, Ying" <ying.huang@...el.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Huang Ying <ying.huang@...el.com>,
        "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
        Michal Hocko <mhocko@...e.com>,
        Minchan Kim <minchan@...nel.org>, Shaohua Li <shli@...nel.org>,
        Zi Yan <zi.yan@...rutgers.edu>, jglisse@...hat.com,
        "Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
Subject: [PATCH -mm] mm, madvise, THP: Use THP aligned address in madvise_free_huge_pmd()

From: Huang Ying <ying.huang@...el.com>

The address argument passed in madvise_free_huge_pmd() may be not THP
aligned.  But some THP operations like pmdp_invalidate(),
set_pmd_at(), and tlb_remove_pmd_tlb_entry() need the address to be
THP aligned.  Fix this via using THP aligned address for these
functions in madvise_free_huge_pmd().

Signed-off-by: "Huang, Ying" <ying.huang@...el.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: Michal Hocko <mhocko@...e.com>
Cc: Minchan Kim <minchan@...nel.org>
Cc: Shaohua Li <shli@...nel.org>
Cc: Zi Yan <zi.yan@...rutgers.edu>
Cc: jglisse@...hat.com
Cc: "Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
---
 mm/huge_memory.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 0cc62405de9c..c5e1bfb08bd7 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1617,6 +1617,7 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
 	struct page *page;
 	struct mm_struct *mm = tlb->mm;
 	bool ret = false;
+	unsigned long haddr = addr & HPAGE_PMD_MASK;
 
 	tlb_remove_check_page_size_change(tlb, HPAGE_PMD_SIZE);
 
@@ -1663,12 +1664,12 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
 	unlock_page(page);
 
 	if (pmd_young(orig_pmd) || pmd_dirty(orig_pmd)) {
-		pmdp_invalidate(vma, addr, pmd);
+		pmdp_invalidate(vma, haddr, pmd);
 		orig_pmd = pmd_mkold(orig_pmd);
 		orig_pmd = pmd_mkclean(orig_pmd);
 
-		set_pmd_at(mm, addr, pmd, orig_pmd);
-		tlb_remove_pmd_tlb_entry(tlb, pmd, addr);
+		set_pmd_at(mm, haddr, pmd, orig_pmd);
+		tlb_remove_pmd_tlb_entry(tlb, pmd, haddr);
 	}
 
 	mark_page_lazyfree(page);
-- 
2.16.1

Powered by blists - more mailing lists