From 3dc20cb282ec03cc4c997130d680c800011ed479 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 13 Apr 2013 20:31:37 -0400 Subject: new helper: read_code() switch binfmts that use ->read() to that (and to kernel_read() in several cases in binfmt_flat - sure, it's nommu, but still, doing ->read() into kmalloc'ed buffer...) Signed-off-by: Al Viro --- fs/exec.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'fs/exec.c') diff --git a/fs/exec.c b/fs/exec.c index a96a4885bbbf..77dc9096440f 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -802,6 +802,15 @@ int kernel_read(struct file *file, loff_t offset, EXPORT_SYMBOL(kernel_read); +ssize_t read_code(struct file *file, unsigned long addr, loff_t pos, size_t len) +{ + ssize_t res = file->f_op->read(file, (void __user *)addr, len, &pos); + if (res > 0) + flush_icache_range(addr, addr + len); + return res; +} +EXPORT_SYMBOL(read_code); + static int exec_mmap(struct mm_struct *mm) { struct task_struct *tsk; -- cgit v1.2.3