ARM: ioremap: Fix static vm area boundary checking.
PATCH 1/1 ARM: ioremap: Fix static vm area boundary checking.
Static vm area boundary check:
paddr1 --->| |
| |
|-------| <-\--- svm->vm->addr(is page aligned)
paddr2 --->| | |
| --| <--|-- svm->vm->phys_addr
| | |
paddr3 --->| | |
| | |
|-------| <--|-- next page boundary
| | |
paddr4 --->| | | <----- svm->vm->size(including guard page)
| | |
| | |
max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end
| ///// | |
paddr5 --->| guard | |
| page | |
| ///// | |
------- <-/--- svm->vm->addr + svm->vm_size<1> If the paddr == paddr1, then continue;
<2> If the paddr == paddr2~paddr4 and paddr_end > phys_addr_end,
then continue;
<3> if the paddr >= paddr5 then continue;
--- arch/arm/mm/ioremap.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-)
arch/arm/mm/ioremap.c +42 -2
@@ -47,16 +47,56 @@ static struct static_vm *find_static_vm_paddr(phys_addr_t paddr, {struct static_vm *svm;struct vm_struct *vm; +size_t offset; + +/* +* Make sure the size the mapping size is page aligned. +*/ + size =PAGE_ALIGN ((paddr & ~PAGE_SIZE ) + size); + offset = paddr & ~PAGE_SIZE ;list_for_each_entry (svm, &static_vmlist, list) { +phys_addr_t paddr_end, phys_addr_end; +size_t vmoff; + vm = &svm->vm;if (!(vm->flags &VM_ARM_STATIC_MAPPING ))continue ;if ((vm->flags &VM_ARM_MTYPE_MASK ) !=VM_ARM_MTYPE (mtype))continue ; -if (vm->phys_addr > paddr || - paddr + size -1 > vm->phys_addr + vm->size -1 ) +/* Static vm area boundary check: +* +* paddr1 --->| | +* | | +* |-------| <-\--- svm->vm->addr(page aligned) +* paddr2 --->| | | +* | --| <--|-- svm->vm->phys_addr +* | | | +* paddr3 --->| | | +* | | | +* |-------| <--|-- next page boundary +* | | | +* paddr4 --->| | | <----- svm->vm->size, +* | | | including guard page +* | | | +* max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end +* | ///// | | +* paddr5 --->| guard | | +* | page | | +* | ///// | | +* ------- <-/-- svm->vm->addr + svm->vm_size +* +* <1> If paddr == paddr1, then continue; +* <2> If paddr == paddr2~paddr4 and paddr_end > phys_addr_end, +* then continue; +* <3> if paddr >= paddr5 then continue; +*/ + vmoff = vm->phys_addr & ~PAGE_SIZE ; + phys_addr_end = vm->phys_addr + vm->size -PAGE_SIZE - vmoff; + paddr_end = paddr + size - offset; +if (__phys_to_pfn (vm->phys_addr) >__phys_to_pfn (paddr) || + paddr_end -1 > phys_addr_end -1 )continue ;return svm;
Signature · 1 line
1.8.4
Quoted 41 lines
Subject: [PATCH] ARM: ioremap: Fix static vm area boundary checking.
Static vm area boundary check:
paddr1 --->| | | | |-------| <-\--- svm->vm->addr(is page aligned) paddr2 --->| | | | --| <--|-- svm->vm->phys_addr | | | paddr3 --->| | | | | | |-------| <--|-- next page boundary | | | paddr4 --->| | | <----- svm->vm->size(including guard page) | | | | | | max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end | ///// | | paddr5 --->| guard | | | page | | | ///// | | ------- <-/--- svm->vm->addr + svm->vm_size<1> If the paddr == paddr1, then continue;
<2> If the paddr == paddr2~paddr4 andpaddr_end>phys_addr_end,then continue;<3> if the paddr >= paddr5 then continue;
Signed-off-by Richard Lee <[email protected]>--- arch/arm/mm/ioremap.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-)arch/arm/mm/ioremap.c +0
-0@@ -47,16 +47,56 @@ static struct static_vm *find_static_vm_paddr(phys_addr_t paddr, {
arch/arm/mm/ioremap.c static struct static_vm *find_static_vm_paddr(phys_addr_t · line 58
Quoted 10 lines
arch/arm/mm/ioremap.c +7
-0struct static_vm *svm;struct vm_struct *vm; +size_t offset; + +/* +* Make sure the size the mapping size is page aligned. +*/ + size =PAGE_ALIGN ((paddr & ~PAGE_SIZE ) + size); + offset = paddr & ~PAGE_SIZE ;
Shouldn't it be PAGE_MASK ?
Quoted 30 lines
arch/arm/mm/ioremap.c +21
-2list_for_each_entry (svm, &static_vmlist, list) { +phys_addr_t paddr_end, phys_addr_end; +size_t vmoff; + vm = &svm->vm;if (!(vm->flags &VM_ARM_STATIC_MAPPING ))continue ;if ((vm->flags &VM_ARM_MTYPE_MASK ) !=VM_ARM_MTYPE (mtype))continue ; -if (vm->phys_addr > paddr || - paddr + size -1 > vm->phys_addr + vm->size -1 ) +/* Static vm area boundary check: +* +* paddr1 --->| | +* | | +* |-------| <-\--- svm->vm->addr(page aligned) +* paddr2 --->| | | +* | --| <--|-- svm->vm->phys_addr +* | | | +* paddr3 --->| | | +* | | | +* |-------| <--|-- next page boundary +* | | | +* paddr4 --->| | | <----- svm->vm->size, +* | | | including guard page +* | | | +* max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end +* | ///// | | +* paddr5 --->| guard | |
arch/arm/mm/ioremap.c static struct static_vm *find_static_vm_paddr(phys_addr_t paddr, · line 95
Quoted 10 lines
arch/arm/mm/ioremap.c +10
-0+* | page | | +* | ///// | | +* ------- <-/-- svm->vm->addr + svm->vm_size +* +* <1> If paddr == paddr1, then continue; +* <2> If paddr == paddr2~paddr4 and paddr_end > phys_addr_end, +* then continue; +* <3> if paddr >= paddr5 then continue; +*/ + vmoff = vm->phys_addr & ~PAGE_SIZE ;
And here.
Thanks,
BRs
Xiubo
Quoted 15 lines
arch/arm/mm/ioremap.c +4
-0+ phys_addr_end = vm->phys_addr + vm->size -PAGE_SIZE - vmoff; + paddr_end = paddr + size - offset; +if (__phys_to_pfn (vm->phys_addr) >__phys_to_pfn (paddr) || + paddr_end -1 > phys_addr_end -1 )continue ;return svm;
--
1.8.4_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 45 lines · Li.Xiubo at freescale.com
Quoted 45 lines
Subject: [PATCH] ARM: ioremap: Fix static vm area boundary checking.
Static vm area boundary check:
paddr1 --->| | | | |-------| <-\--- svm->vm->addr(is page aligned) paddr2 --->| | | | --| <--|-- svm->vm->phys_addr | | | paddr3 --->| | | | | | |-------| <--|-- next page boundary | | | paddr4 --->| | | <----- svm->vm->size(including guard page) | | | | | | max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end | ///// | | paddr5 --->| guard | | | page | | | ///// | | ------- <-/--- svm->vm->addr + svm->vm_size<1> If the paddr == paddr1, then continue;
<2> If the paddr == paddr2~paddr4 andpaddr_end>phys_addr_end,then continue;<3> if the paddr >= paddr5 then continue;
Signed-off-by Richard Lee <[email protected]>--- arch/arm/mm/ioremap.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-)arch/arm/mm/ioremap.c +2
-0@@ -47,16 +47,56 @@ static struct static_vm *find_static_vm_paddr(phys_addr_t paddr, {struct static_vm *svm;struct vm_struct *vm; +size_t offset; +
Quoted 9 lines
arch/arm/mm/ioremap.c static struct static_vm *find_static_vm_paddr(phys_addr_t paddr, · line 57
Quoted 6 lines
arch/arm/mm/ioremap.c +5
-0+/* +* Make sure the size the mapping size is page aligned. +*/ + size =PAGE_ALIGN ((paddr & ~PAGE_SIZE ) + size); + offset = paddr & ~PAGE_SIZE ;Shouldn't it be
PAGE_MASK?
Yes, it is. I'll fix it.
Thanks,
Best regards,
Richard Lee
Quoted 63 lines
Quoted 31 lines
arch/arm/mm/ioremap.c +21
-2list_for_each_entry (svm, &static_vmlist, list) { +phys_addr_t paddr_end, phys_addr_end; +size_t vmoff; + vm = &svm->vm;if (!(vm->flags &VM_ARM_STATIC_MAPPING ))continue ;if ((vm->flags &VM_ARM_MTYPE_MASK ) !=VM_ARM_MTYPE (mtype))continue ; -if (vm->phys_addr > paddr || - paddr + size -1 > vm->phys_addr + vm->size -1 ) +/* Static vm area boundary check: +* +* paddr1 --->| | +* | | +* |-------| <-\--- svm->vm->addr(page aligned) +* paddr2 --->| | | +* | --| <--|-- svm->vm->phys_addr +* | | | +* paddr3 --->| | | +* | | | +* |-------| <--|-- next page boundary +* | | | +* paddr4 --->| | | <----- svm->vm->size, +* | | | including guard page +* | | | +* max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end +* | ///// | | +* paddr5 --->| guard | | arch/arm/mm/ioremap.c static struct static_vm *find_static_vm_paddr(phys_addr_t paddr, · line 95
Quoted 10 lines
arch/arm/mm/ioremap.c +10
-0+* | page | | +* | ///// | | +* ------- <-/-- svm->vm->addr + svm->vm_size +* +* <1> If paddr == paddr1, then continue; +* <2> If paddr == paddr2~paddr4 and paddr_end > phys_addr_end, +* then continue; +* <3> if paddr >= paddr5 then continue; +*/ + vmoff = vm->phys_addr & ~PAGE_SIZE ;And here.
Thanks,
BRs
XiuboQuoted 15 lines
arch/arm/mm/ioremap.c +4
-0+ phys_addr_end = vm->phys_addr + vm->size -PAGE_SIZE - vmoff; + paddr_end = paddr + size - offset; +if (__phys_to_pfn (vm->phys_addr) >__phys_to_pfn (paddr) || + paddr_end -1 > phys_addr_end -1 )continue ;return svm;--
1.8.4_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel