aboutsummaryrefslogtreecommitdiffstats
path: root/fs/binfmt_aout.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-04-13 20:31:37 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-04-29 15:40:23 -0400
commit3dc20cb282ec03cc4c997130d680c800011ed479 (patch)
treed8374e58a433a144c571e193cb0b024374ee0b6a /fs/binfmt_aout.c
parent3af0761307d04f6b9a4626fb80011a22c143d75e (diff)
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 <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/binfmt_aout.c')
-rw-r--r--fs/binfmt_aout.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index bbc8f8827eac..b23253df8756 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -287,15 +287,12 @@ static int load_aout_binary(struct linux_binprm * bprm)
287 return error; 287 return error;
288 } 288 }
289 289
290 error = bprm->file->f_op->read(bprm->file, 290 error = read_code(bprm->file, text_addr, pos,
291 (char __user *)text_addr, 291 ex.a_text+ex.a_data);
292 ex.a_text+ex.a_data, &pos);
293 if ((signed long)error < 0) { 292 if ((signed long)error < 0) {
294 send_sig(SIGKILL, current, 0); 293 send_sig(SIGKILL, current, 0);
295 return error; 294 return error;
296 } 295 }
297
298 flush_icache_range(text_addr, text_addr+ex.a_text+ex.a_data);
299 } else { 296 } else {
300 if ((ex.a_text & 0xfff || ex.a_data & 0xfff) && 297 if ((ex.a_text & 0xfff || ex.a_data & 0xfff) &&
301 (N_MAGIC(ex) != NMAGIC) && printk_ratelimit()) 298 (N_MAGIC(ex) != NMAGIC) && printk_ratelimit())
@@ -311,14 +308,9 @@ static int load_aout_binary(struct linux_binprm * bprm)
311 } 308 }
312 309
313 if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) { 310 if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) {
314 loff_t pos = fd_offset;
315 vm_brk(N_TXTADDR(ex), ex.a_text+ex.a_data); 311 vm_brk(N_TXTADDR(ex), ex.a_text+ex.a_data);
316 bprm->file->f_op->read(bprm->file, 312 read_code(bprm->file, N_TXTADDR(ex), fd_offset,
317 (char __user *)N_TXTADDR(ex), 313 ex.a_text + ex.a_data);
318 ex.a_text+ex.a_data, &pos);
319 flush_icache_range((unsigned long) N_TXTADDR(ex),
320 (unsigned long) N_TXTADDR(ex) +
321 ex.a_text+ex.a_data);
322 goto beyond_if; 314 goto beyond_if;
323 } 315 }
324 316
@@ -397,8 +389,6 @@ static int load_aout_library(struct file *file)
397 start_addr = ex.a_entry & 0xfffff000; 389 start_addr = ex.a_entry & 0xfffff000;
398 390
399 if ((N_TXTOFF(ex) & ~PAGE_MASK) != 0) { 391 if ((N_TXTOFF(ex) & ~PAGE_MASK) != 0) {
400 loff_t pos = N_TXTOFF(ex);
401
402 if (printk_ratelimit()) 392 if (printk_ratelimit())
403 { 393 {
404 printk(KERN_WARNING 394 printk(KERN_WARNING
@@ -407,11 +397,8 @@ static int load_aout_library(struct file *file)
407 } 397 }
408 vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); 398 vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss);
409 399
410 file->f_op->read(file, (char __user *)start_addr, 400 read_code(file, start_addr, N_TXTOFF(ex),
411 ex.a_text + ex.a_data, &pos); 401 ex.a_text + ex.a_data);
412 flush_icache_range((unsigned long) start_addr,
413 (unsigned long) start_addr + ex.a_text + ex.a_data);
414
415 retval = 0; 402 retval = 0;
416 goto out; 403 goto out;
417 } 404 }