Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: Flush executable pages in copy_user_highpage

This resolves a problem seen when using the Android dynamic linker.
Sometimes the dynamic linker would seg-fault at start up and this
was eventually traced to the handling of a COW fault for a page which
was being modified by the linker. If there was no cache aliasing between
the kernel and the user page, the page was not flushed, leaving the
newly copied data in the D-cache. However when executing instructions
from that page, the I-cache is filled directly from external memory,
rather than the D-cache, and causing garbage to be executed.

Signed-off-by: Stuart Menefy <stuart.menefy@st.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>

authored by

Stuart Menefy and committed by
Paul Mundt
a25bbe12 a0865368

+2 -1
+2 -1
arch/sh/mm/cache.c
··· 108 108 kunmap_atomic(vfrom, KM_USER0); 109 109 } 110 110 111 - if (pages_do_alias((unsigned long)vto, vaddr & PAGE_MASK)) 111 + if (pages_do_alias((unsigned long)vto, vaddr & PAGE_MASK) || 112 + (vma->vm_flags & VM_EXEC)) 112 113 __flush_purge_region(vto, PAGE_SIZE); 113 114 114 115 kunmap_atomic(vto, KM_USER1);