Skip to contentSkip to conversation

kernel fault in get_dump_page on at91

DISCUSSION Gilles Chanteperdrix 2 participants 2 messages Jun 16, 2012 – Jun 18, 2012 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

Hi,

It seems generating a coredump on an at91rm9200 with kernels 3.4 and 3.5 causes an oops.

The function get_dump_page calls vivt_flush_cache_page which tests if the current cpu belongs to mm_cpumask(vma->vm_mm), but vma->vm_mm is NULL for the vector page.

Setting gate_vma.vm_mm to &init_mm seems to avoid the issue, but I am not sure this is the right thing to do.

Regards.

Signature · 1 line
                                                                Gilles.
#1 lore raw
Quoted 2 lines · Gilles Chanteperdrix

Hi,

Hello Gilles,

Quoted 6 lines

The function get_dump_page calls vivt_flush_cache_page which tests if the current cpu belongs to mm_cpumask(vma->vm_mm), but vma->vm_mm is NULL for the vector page.

Setting gate_vma.vm_mm to &init_mm seems to avoid the issue, but I am not sure this is the right thing to do.

I don't think that is the right thing to do -- instead we should check that vm_mm isn't NULL before dereferencing it:

arch/arm/include/asm/cacheflush.h +4 -2
index 004c1bc..b35c376 100644
@@ -215,7 +215,8 @@ static inline void vivt_flush_cache_mm(struct mm_struct *mm)
 static inline void
 vivt_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
 {
-       if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm)))
+       if (!vma->vm_mm ||
+           cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm)))
                __cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end),
                                        vma->vm_flags);
 }
@@ -223,7 +224,8 @@ vivt_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned
 static inline void
 vivt_flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr, unsigned long pfn)
 {
-       if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm))) {
+       if (!vma->vm_mm ||
+           cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm))) {
                unsigned long addr = user_addr & PAGE_MASK;
                __cpuc_flush_user_range(addr, addr + PAGE_SIZE, vma->vm_flags);
        }

The bit that worries me is that code like this isn't confined to vivt cache flushing. We also have similar sequences for ptrace flushing and TLB maintenance. The former is probably ok since the gate_vma isn't writable/COWable but can we guarantee that TLB page flushing routines won't be called on the gate_vma?

Will