diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-13 20:31:37 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-29 15:40:23 -0400 |
commit | 3dc20cb282ec03cc4c997130d680c800011ed479 (patch) | |
tree | d8374e58a433a144c571e193cb0b024374ee0b6a /arch/x86/ia32 | |
parent | 3af0761307d04f6b9a4626fb80011a22c143d75e (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 'arch/x86/ia32')
-rw-r--r-- | arch/x86/ia32/ia32_aout.c | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c index 03abf9b70011..03d721cbbc32 100644 --- a/arch/x86/ia32/ia32_aout.c +++ b/arch/x86/ia32/ia32_aout.c | |||
@@ -323,11 +323,8 @@ static int load_aout_binary(struct linux_binprm *bprm) | |||
323 | 323 | ||
324 | if (N_MAGIC(ex) == OMAGIC) { | 324 | if (N_MAGIC(ex) == OMAGIC) { |
325 | unsigned long text_addr, map_size; | 325 | unsigned long text_addr, map_size; |
326 | loff_t pos; | ||
327 | 326 | ||
328 | text_addr = N_TXTADDR(ex); | 327 | text_addr = N_TXTADDR(ex); |
329 | |||
330 | pos = 32; | ||
331 | map_size = ex.a_text+ex.a_data; | 328 | map_size = ex.a_text+ex.a_data; |
332 | 329 | ||
333 | error = vm_brk(text_addr & PAGE_MASK, map_size); | 330 | error = vm_brk(text_addr & PAGE_MASK, map_size); |
@@ -337,15 +334,12 @@ static int load_aout_binary(struct linux_binprm *bprm) | |||
337 | return error; | 334 | return error; |
338 | } | 335 | } |
339 | 336 | ||
340 | error = bprm->file->f_op->read(bprm->file, | 337 | error = read_code(bprm->file, text_addr, 32, |
341 | (char __user *)text_addr, | 338 | ex.a_text + ex.a_data); |
342 | ex.a_text+ex.a_data, &pos); | ||
343 | if ((signed long)error < 0) { | 339 | if ((signed long)error < 0) { |
344 | send_sig(SIGKILL, current, 0); | 340 | send_sig(SIGKILL, current, 0); |
345 | return error; | 341 | return error; |
346 | } | 342 | } |
347 | |||
348 | flush_icache_range(text_addr, text_addr+ex.a_text+ex.a_data); | ||
349 | } else { | 343 | } else { |
350 | #ifdef WARN_OLD | 344 | #ifdef WARN_OLD |
351 | static unsigned long error_time, error_time2; | 345 | static unsigned long error_time, error_time2; |
@@ -367,15 +361,9 @@ static int load_aout_binary(struct linux_binprm *bprm) | |||
367 | #endif | 361 | #endif |
368 | 362 | ||
369 | if (!bprm->file->f_op->mmap || (fd_offset & ~PAGE_MASK) != 0) { | 363 | if (!bprm->file->f_op->mmap || (fd_offset & ~PAGE_MASK) != 0) { |
370 | loff_t pos = fd_offset; | ||
371 | |||
372 | vm_brk(N_TXTADDR(ex), ex.a_text+ex.a_data); | 364 | vm_brk(N_TXTADDR(ex), ex.a_text+ex.a_data); |
373 | bprm->file->f_op->read(bprm->file, | 365 | read_code(bprm->file, N_TXTADDR(ex), fd_offset, |
374 | (char __user *)N_TXTADDR(ex), | 366 | ex.a_text+ex.a_data); |
375 | ex.a_text+ex.a_data, &pos); | ||
376 | flush_icache_range((unsigned long) N_TXTADDR(ex), | ||
377 | (unsigned long) N_TXTADDR(ex) + | ||
378 | ex.a_text+ex.a_data); | ||
379 | goto beyond_if; | 367 | goto beyond_if; |
380 | } | 368 | } |
381 | 369 | ||
@@ -452,8 +440,6 @@ static int load_aout_library(struct file *file) | |||
452 | start_addr = ex.a_entry & 0xfffff000; | 440 | start_addr = ex.a_entry & 0xfffff000; |
453 | 441 | ||
454 | if ((N_TXTOFF(ex) & ~PAGE_MASK) != 0) { | 442 | if ((N_TXTOFF(ex) & ~PAGE_MASK) != 0) { |
455 | loff_t pos = N_TXTOFF(ex); | ||
456 | |||
457 | #ifdef WARN_OLD | 443 | #ifdef WARN_OLD |
458 | static unsigned long error_time; | 444 | static unsigned long error_time; |
459 | if (time_after(jiffies, error_time + 5*HZ)) { | 445 | if (time_after(jiffies, error_time + 5*HZ)) { |
@@ -466,12 +452,8 @@ static int load_aout_library(struct file *file) | |||
466 | #endif | 452 | #endif |
467 | vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); | 453 | vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); |
468 | 454 | ||
469 | file->f_op->read(file, (char __user *)start_addr, | 455 | read_code(file, start_addr, N_TXTOFF(ex), |
470 | ex.a_text + ex.a_data, &pos); | 456 | ex.a_text + ex.a_data); |
471 | flush_icache_range((unsigned long) start_addr, | ||
472 | (unsigned long) start_addr + ex.a_text + | ||
473 | ex.a_data); | ||
474 | |||
475 | retval = 0; | 457 | retval = 0; |
476 | goto out; | 458 | goto out; |
477 | } | 459 | } |