diff options
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r-- | fs/binfmt_elf.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 111771d38e6e..a93b1170551b 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -513,6 +513,7 @@ out: | |||
513 | return error; | 513 | return error; |
514 | } | 514 | } |
515 | 515 | ||
516 | #ifdef CONFIG_ARCH_SUPPORTS_AOUT | ||
516 | static unsigned long load_aout_interp(struct exec *interp_ex, | 517 | static unsigned long load_aout_interp(struct exec *interp_ex, |
517 | struct file *interpreter) | 518 | struct file *interpreter) |
518 | { | 519 | { |
@@ -558,6 +559,14 @@ static unsigned long load_aout_interp(struct exec *interp_ex, | |||
558 | out: | 559 | out: |
559 | return elf_entry; | 560 | return elf_entry; |
560 | } | 561 | } |
562 | #else | ||
563 | /* dummy extern - the function should never be called if !CONFIG_AOUT_BINFMT */ | ||
564 | static inline unsigned long load_aout_interp(struct exec *interp_ex, | ||
565 | struct file *interpreter) | ||
566 | { | ||
567 | return -ELIBACC; | ||
568 | } | ||
569 | #endif | ||
561 | 570 | ||
562 | /* | 571 | /* |
563 | * These are the functions used to load ELF style executables and shared | 572 | * These are the functions used to load ELF style executables and shared |
@@ -565,9 +574,15 @@ out: | |||
565 | */ | 574 | */ |
566 | 575 | ||
567 | #define INTERPRETER_NONE 0 | 576 | #define INTERPRETER_NONE 0 |
568 | #define INTERPRETER_AOUT 1 | ||
569 | #define INTERPRETER_ELF 2 | 577 | #define INTERPRETER_ELF 2 |
570 | 578 | ||
579 | #ifdef CONFIG_ARCH_SUPPORTS_AOUT | ||
580 | #define INTERPRETER_AOUT 1 | ||
581 | #define IS_AOUT_INTERP(x) ((x) == INTERPRETER_AOUT) | ||
582 | #else | ||
583 | #define IS_AOUT_INTERP(x) (0) | ||
584 | #endif | ||
585 | |||
571 | #ifndef STACK_RND_MASK | 586 | #ifndef STACK_RND_MASK |
572 | #define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12)) /* 8MB of VA */ | 587 | #define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12)) /* 8MB of VA */ |
573 | #endif | 588 | #endif |
@@ -775,6 +790,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
775 | /* Some simple consistency checks for the interpreter */ | 790 | /* Some simple consistency checks for the interpreter */ |
776 | if (elf_interpreter) { | 791 | if (elf_interpreter) { |
777 | static int warn; | 792 | static int warn; |
793 | #ifdef CONFIG_ARCH_SUPPORTS_AOUT | ||
778 | interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT; | 794 | interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT; |
779 | 795 | ||
780 | /* Now figure out which format our binary is */ | 796 | /* Now figure out which format our binary is */ |
@@ -782,11 +798,13 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
782 | (N_MAGIC(loc->interp_ex) != ZMAGIC) && | 798 | (N_MAGIC(loc->interp_ex) != ZMAGIC) && |
783 | (N_MAGIC(loc->interp_ex) != QMAGIC)) | 799 | (N_MAGIC(loc->interp_ex) != QMAGIC)) |
784 | interpreter_type = INTERPRETER_ELF; | 800 | interpreter_type = INTERPRETER_ELF; |
785 | 801 | #else | |
802 | interpreter_type = INTERPRETER_ELF; | ||
803 | #endif | ||
786 | if (memcmp(loc->interp_elf_ex.e_ident, ELFMAG, SELFMAG) != 0) | 804 | if (memcmp(loc->interp_elf_ex.e_ident, ELFMAG, SELFMAG) != 0) |
787 | interpreter_type &= ~INTERPRETER_ELF; | 805 | interpreter_type &= ~INTERPRETER_ELF; |
788 | 806 | ||
789 | if (interpreter_type == INTERPRETER_AOUT && warn < 10) { | 807 | if (IS_AOUT_INTERP(interpreter_type) && warn < 10) { |
790 | printk(KERN_WARNING "a.out ELF interpreter %s is " | 808 | printk(KERN_WARNING "a.out ELF interpreter %s is " |
791 | "deprecated and will not be supported " | 809 | "deprecated and will not be supported " |
792 | "after Linux 2.6.25\n", elf_interpreter); | 810 | "after Linux 2.6.25\n", elf_interpreter); |
@@ -815,7 +833,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
815 | 833 | ||
816 | /* OK, we are done with that, now set up the arg stuff, | 834 | /* OK, we are done with that, now set up the arg stuff, |
817 | and then start this sucker up */ | 835 | and then start this sucker up */ |
818 | if ((!bprm->sh_bang) && (interpreter_type == INTERPRETER_AOUT)) { | 836 | if (IS_AOUT_INTERP(interpreter_type) && !bprm->sh_bang) { |
819 | char *passed_p = passed_fileno; | 837 | char *passed_p = passed_fileno; |
820 | sprintf(passed_fileno, "%d", elf_exec_fileno); | 838 | sprintf(passed_fileno, "%d", elf_exec_fileno); |
821 | 839 | ||
@@ -1004,7 +1022,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
1004 | } | 1022 | } |
1005 | 1023 | ||
1006 | if (elf_interpreter) { | 1024 | if (elf_interpreter) { |
1007 | if (interpreter_type == INTERPRETER_AOUT) { | 1025 | if (IS_AOUT_INTERP(interpreter_type)) { |
1008 | elf_entry = load_aout_interp(&loc->interp_ex, | 1026 | elf_entry = load_aout_interp(&loc->interp_ex, |
1009 | interpreter); | 1027 | interpreter); |
1010 | } else { | 1028 | } else { |
@@ -1045,7 +1063,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
1045 | 1063 | ||
1046 | kfree(elf_phdata); | 1064 | kfree(elf_phdata); |
1047 | 1065 | ||
1048 | if (interpreter_type != INTERPRETER_AOUT) | 1066 | if (!IS_AOUT_INTERP(interpreter_type)) |
1049 | sys_close(elf_exec_fileno); | 1067 | sys_close(elf_exec_fileno); |
1050 | 1068 | ||
1051 | set_binfmt(&elf_format); | 1069 | set_binfmt(&elf_format); |
@@ -1061,14 +1079,14 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
1061 | compute_creds(bprm); | 1079 | compute_creds(bprm); |
1062 | current->flags &= ~PF_FORKNOEXEC; | 1080 | current->flags &= ~PF_FORKNOEXEC; |
1063 | retval = create_elf_tables(bprm, &loc->elf_ex, | 1081 | retval = create_elf_tables(bprm, &loc->elf_ex, |
1064 | (interpreter_type == INTERPRETER_AOUT), | 1082 | IS_AOUT_INTERP(interpreter_type), |
1065 | load_addr, interp_load_addr); | 1083 | load_addr, interp_load_addr); |
1066 | if (retval < 0) { | 1084 | if (retval < 0) { |
1067 | send_sig(SIGKILL, current, 0); | 1085 | send_sig(SIGKILL, current, 0); |
1068 | goto out; | 1086 | goto out; |
1069 | } | 1087 | } |
1070 | /* N.B. passed_fileno might not be initialized? */ | 1088 | /* N.B. passed_fileno might not be initialized? */ |
1071 | if (interpreter_type == INTERPRETER_AOUT) | 1089 | if (IS_AOUT_INTERP(interpreter_type)) |
1072 | current->mm->arg_start += strlen(passed_fileno) + 1; | 1090 | current->mm->arg_start += strlen(passed_fileno) + 1; |
1073 | current->mm->end_code = end_code; | 1091 | current->mm->end_code = end_code; |
1074 | current->mm->start_code = start_code; | 1092 | current->mm->start_code = start_code; |