Skip to content

Commit 4f30292

Browse files
committed
Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
Pull MIPS fix from Ralf Baechle: "Only a single fix for 4.7 pending at this point. It fixes an issue that may lead to corruption of the cache mode bits in the page table" * 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: MIPS: Fix possible corruption of cache mode by mprotect.
2 parents 70bd68d + 6d037de commit 4f30292

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

arch/mips/include/asm/pgtable.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct mm_struct;
2424
struct vm_area_struct;
2525

2626
#define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_NO_READ | \
27-
_CACHE_CACHABLE_NONCOHERENT)
27+
_page_cachable_default)
2828
#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_WRITE | \
2929
_page_cachable_default)
3030
#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_NO_EXEC | \
@@ -476,7 +476,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
476476
pte.pte_low &= (_PAGE_MODIFIED | _PAGE_ACCESSED | _PFNX_MASK);
477477
pte.pte_high &= (_PFN_MASK | _CACHE_MASK);
478478
pte.pte_low |= pgprot_val(newprot) & ~_PFNX_MASK;
479-
pte.pte_high |= pgprot_val(newprot) & ~_PFN_MASK;
479+
pte.pte_high |= pgprot_val(newprot) & ~(_PFN_MASK | _CACHE_MASK);
480480
return pte;
481481
}
482482
#elif defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32)
@@ -491,7 +491,8 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
491491
#else
492492
static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
493493
{
494-
return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot));
494+
return __pte((pte_val(pte) & _PAGE_CHG_MASK) |
495+
(pgprot_val(newprot) & ~_PAGE_CHG_MASK));
495496
}
496497
#endif
497498

@@ -632,7 +633,8 @@ static inline struct page *pmd_page(pmd_t pmd)
632633

633634
static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
634635
{
635-
pmd_val(pmd) = (pmd_val(pmd) & _PAGE_CHG_MASK) | pgprot_val(newprot);
636+
pmd_val(pmd) = (pmd_val(pmd) & _PAGE_CHG_MASK) |
637+
(pgprot_val(newprot) & ~_PAGE_CHG_MASK);
636638
return pmd;
637639
}
638640

0 commit comments

Comments
 (0)