DEV: zero: use correct pgprot for zeromapping
Subsystems (2)
PATCH 1/1 DEV: zero: use correct pgprot for zeromapping
Instead of PAGE_COPY use the pgprot bits established already at original mapping time of the VMA. This will also include any architecture specific bits setup through protection_map. zeromap_page_range will take care of COW'ing the passed pgprot.
This fixes at least one problem on ARM where reading /dev/zero in one process created global PTE mappings thus - practically - zeroing out memory ranges of all other processes.
--- drivers/char/mem.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/char/mem.c +1 -1
@@ -646,7 +646,7 @@ static inline size_t read_zero_pagealigned(char __user * buf, size_t size) count = size;zap_page_range (vma, addr, count,NULL ); -if (zeromap_page_range (vma, addr, count,PAGE_COPY )) +if (zeromap_page_range (vma, addr, count, vma->vm_page_prot))break ; size -= count;
Signature · 1 line
1.4.4.3.GIT
Quoted 4 lines · Imre Deak
Instead of
PAGE_COPYuse the pgprot bits established already at original mapping time of the VMA. This will also include any architecture specific bits setup throughprotection_map.zeromap_page_rangewill take care of COW'ing the passed pgprot.
NAK. What if PAGE_COPY is used elsewhere and ends up accidentally allowing write access?
I think the right solution is to make PAGE_COPY a variable in the same way that PAGE_KERNEL is, and adjust it as appropriate.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of:
Quoted 8 lines · Russell King
Quoted 4 lines · Imre Deak
Instead of
PAGE_COPYuse the pgprot bits established already at original mapping time of the VMA. This will also include any architecture specific bits setup throughprotection_map.zeromap_page_rangewill take care of COW'ing the passed pgprot.NAK. What if
PAGE_COPYis used elsewhere and ends up accidentally allowing write access?
Or rather, result in the bogus global mapping. True.
Quoted 3 lines
I think the right solution is to make
PAGE_COPYa variable in the same way thatPAGE_KERNELis, and adjust it as appropriate.
Ok, and also at least PAGE_SHARED and PAGE_READONLY I assume.
--Imre
PATCH 1/1 ARM: VM: fix user page protection values (was Re: [PATCH] DEV: zero: use correct pgprot for zeromapping)
Quoted 10 lines · Imre Deak
Quoted 8 lines · Russell King
Quoted 4 lines · Imre Deak
Instead of
PAGE_COPYuse the pgprot bits established already at original mapping time of the VMA. This will also include any architecture specific bits setup throughprotection_map.zeromap_page_rangewill take care of COW'ing the passed pgprot.NAK. What if
PAGE_COPYis used elsewhere and ends up accidentally allowing write access?
Quoted 7 lines
Or rather, result in the bogus global mapping. True.
Quoted 3 lines
I think the right solution is to make
PAGE_COPYa variable in the same way thatPAGE_KERNELis, and adjust it as appropriate.Ok, and also at least
PAGE_SHAREDandPAGE_READONLYI assume.
[ For consistency base all PAGE_* macros off a variable. I tested this on ARM1136. ]
The PAGE_* user page protection macros don't take into account the configured memory policy and other architecture specific bits like the global/ASID and shared mapping bits. Instead of constants let these depend on a variable fixed up at init just like PAGE_KERNEL.
--- arch/arm/mm/mmu.c | 3 ++ include/asm-arm/pgtable.h | 54 ++++++++++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 22 deletions(-)
arch/arm/mm/mmu.c +3 -0
@@ -49,8 +49,10 @@ pmd_t *top_pmd;static unsigned int cachepolicy__initdata =CPOLICY_WRITEBACK ;static unsigned int ecc_mask__initdata =0 ; +pgprot_t pgprot_user;pgprot_t pgprot_kernel; +EXPORT_SYMBOL (pgprot_user);EXPORT_SYMBOL (pgprot_kernel);struct cachepolicy {
@@ -345,6 +347,7 @@ static void __init build_mem_type_table(void) mem_types[MT_MINICLEAN ].prot_sect &= ~PMD_SECT_TEX (1 ); } + pgprot_user =__pgprot (L_PTE_PRESENT |L_PTE_YOUNG | user_pgprot); pgprot_kernel =__pgprot (L_PTE_PRESENT |L_PTE_YOUNG |L_PTE_DIRTY |L_PTE_WRITE |L_PTE_EXEC | kern_pgprot);
include/asm-arm/pgtable.h +32 -22
74 lines not on this page · raw message
Signature · 1 line
1.4.4.3.GIT