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
| ||
|
Message-Id: <20221003070716.679782473@linuxfoundation.org> Date: Mon, 3 Oct 2022 09:11:55 +0200 From: Greg Kroah-Hartman <gregkh@...uxfoundation.org> To: linux-kernel@...r.kernel.org Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, stable@...r.kernel.org, Alistair Popple <apopple@...dia.com>, Nadav Amit <nadav.amit@...il.com>, "Huang, Ying" <ying.huang@...el.com>, David Hildenbrand <david@...hat.com>, Peter Xu <peterx@...hat.com>, Alex Sierra <alex.sierra@....com>, Ben Skeggs <bskeggs@...hat.com>, Felix Kuehling <Felix.Kuehling@....com>, huang ying <huang.ying.caritas@...il.com>, Jason Gunthorpe <jgg@...dia.com>, John Hubbard <jhubbard@...dia.com>, Karol Herbst <kherbst@...hat.com>, Logan Gunthorpe <logang@...tatee.com>, Lyude Paul <lyude@...hat.com>, Matthew Wilcox <willy@...radead.org>, Paul Mackerras <paulus@...abs.org>, Ralph Campbell <rcampbell@...dia.com>, Andrew Morton <akpm@...ux-foundation.org> Subject: [PATCH 5.4 13/30] mm/migrate_device.c: flush TLB while holding PTL From: Alistair Popple <apopple@...dia.com> commit 60bae73708963de4a17231077285bd9ff2f41c44 upstream. When clearing a PTE the TLB should be flushed whilst still holding the PTL to avoid a potential race with madvise/munmap/etc. For example consider the following sequence: CPU0 CPU1 ---- ---- migrate_vma_collect_pmd() pte_unmap_unlock() madvise(MADV_DONTNEED) -> zap_pte_range() pte_offset_map_lock() [ PTE not present, TLB not flushed ] pte_unmap_unlock() [ page is still accessible via stale TLB ] flush_tlb_range() In this case the page may still be accessed via the stale TLB entry after madvise returns. Fix this by flushing the TLB while holding the PTL. Fixes: 8c3328f1f36a ("mm/migrate: migrate_vma() unmap page from vma while collecting pages") Link: https://lkml.kernel.org/r/9f801e9d8d830408f2ca27821f606e09aa856899.1662078528.git-series.apopple@nvidia.com Signed-off-by: Alistair Popple <apopple@...dia.com> Reported-by: Nadav Amit <nadav.amit@...il.com> Reviewed-by: "Huang, Ying" <ying.huang@...el.com> Acked-by: David Hildenbrand <david@...hat.com> Acked-by: Peter Xu <peterx@...hat.com> Cc: Alex Sierra <alex.sierra@....com> Cc: Ben Skeggs <bskeggs@...hat.com> Cc: Felix Kuehling <Felix.Kuehling@....com> Cc: huang ying <huang.ying.caritas@...il.com> Cc: Jason Gunthorpe <jgg@...dia.com> Cc: John Hubbard <jhubbard@...dia.com> Cc: Karol Herbst <kherbst@...hat.com> Cc: Logan Gunthorpe <logang@...tatee.com> Cc: Lyude Paul <lyude@...hat.com> Cc: Matthew Wilcox <willy@...radead.org> Cc: Paul Mackerras <paulus@...abs.org> Cc: Ralph Campbell <rcampbell@...dia.com> Cc: <stable@...r.kernel.org> Signed-off-by: Andrew Morton <akpm@...ux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org> --- mm/migrate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2343,13 +2343,14 @@ next: migrate->dst[migrate->npages] = 0; migrate->src[migrate->npages++] = mpfn; } - arch_leave_lazy_mmu_mode(); - pte_unmap_unlock(ptep - 1, ptl); /* Only flush the TLB if we actually modified any entries */ if (unmapped) flush_tlb_range(walk->vma, start, end); + arch_leave_lazy_mmu_mode(); + pte_unmap_unlock(ptep - 1, ptl); + return 0; }
Powered by blists - more mailing lists