Skip to content

Commit

Permalink
[ARM] Fix shared mmap when more than two maps of the same file exist
Browse files Browse the repository at this point in the history
The shared mmap code works fine for the test case, which only checked
for two shared maps of the same file.  However, three shared maps
result in one mapping remaining cached, resulting in stale data being
visible via that mapping.  Fix this.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Russell King authored and Russell King committed Jul 27, 2008
1 parent daf93dd commit 53cdb27
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions arch/arm/mm/fault-armv.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address)
pgd_t *pgd;
pmd_t *pmd;
pte_t *pte, entry;
int ret = 0;
int ret;

pgd = pgd_offset(vma->vm_mm, address);
if (pgd_none(*pgd))
Expand All @@ -54,16 +54,20 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address)
pte = pte_offset_map(pmd, address);
entry = *pte;

/*
* If this page is present, it's actually being shared.
*/
ret = pte_present(entry);

/*
* If this page isn't present, or is already setup to
* fault (ie, is old), we can safely ignore any issues.
*/
if (pte_present(entry) && pte_val(entry) & shared_pte_mask) {
if (ret && pte_val(entry) & shared_pte_mask) {
flush_cache_page(vma, address, pte_pfn(entry));
pte_val(entry) &= ~shared_pte_mask;
set_pte_at(vma->vm_mm, address, pte, entry);
flush_tlb_page(vma, address);
ret = 1;
}
pte_unmap(pte);
return ret;
Expand Down

0 comments on commit 53cdb27

Please sign in to comment.