mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
mm/memory.c: fix potential pte_unmap_unlock pte error
If all pte entry is none in 'non-create' case, we would break the loop with
pte unchanged. Then the wrong pte - 1 would be passed to pte_unmap_unlock.
This is a theoretical issue which may not be a real bug. So it's not worth
cc stable.
Link: https://lkml.kernel.org/r/20210205081925.59809-1-linmiaohe@huawei.com
Fixes: aee16b3cee
("Add apply_to_page_range() which applies a function to a pte range")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Ian Pratt <ian.pratt@xensource.com>
Cc: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
374437a274
commit
8abb50c76b
@@ -2394,18 +2394,18 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,
|
|||||||
pte_fn_t fn, void *data, bool create,
|
pte_fn_t fn, void *data, bool create,
|
||||||
pgtbl_mod_mask *mask)
|
pgtbl_mod_mask *mask)
|
||||||
{
|
{
|
||||||
pte_t *pte;
|
pte_t *pte, *mapped_pte;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
spinlock_t *ptl;
|
spinlock_t *ptl;
|
||||||
|
|
||||||
if (create) {
|
if (create) {
|
||||||
pte = (mm == &init_mm) ?
|
mapped_pte = pte = (mm == &init_mm) ?
|
||||||
pte_alloc_kernel_track(pmd, addr, mask) :
|
pte_alloc_kernel_track(pmd, addr, mask) :
|
||||||
pte_alloc_map_lock(mm, pmd, addr, &ptl);
|
pte_alloc_map_lock(mm, pmd, addr, &ptl);
|
||||||
if (!pte)
|
if (!pte)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
} else {
|
} else {
|
||||||
pte = (mm == &init_mm) ?
|
mapped_pte = pte = (mm == &init_mm) ?
|
||||||
pte_offset_kernel(pmd, addr) :
|
pte_offset_kernel(pmd, addr) :
|
||||||
pte_offset_map_lock(mm, pmd, addr, &ptl);
|
pte_offset_map_lock(mm, pmd, addr, &ptl);
|
||||||
}
|
}
|
||||||
@@ -2428,7 +2428,7 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,
|
|||||||
arch_leave_lazy_mmu_mode();
|
arch_leave_lazy_mmu_mode();
|
||||||
|
|
||||||
if (mm != &init_mm)
|
if (mm != &init_mm)
|
||||||
pte_unmap_unlock(pte-1, ptl);
|
pte_unmap_unlock(mapped_pte, ptl);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user