Make aout executables work again
Subsystems (4)
PATCH 1/1 Make aout executables work again
This a reworked, replacement version of x86-fix-vdso-mapping-for-aout-executables-* series of patches in -mm.
1) Define arch_setup_additional_pages() as weak in linux/interp.h
2) Include linux/interp.h in appropriate places
3) Conditionally call arch_setup_additional_pages() from binfmt_*.c if the arch defines it
4) EXPORT_SYMBOL_GPL(arch_setup_additional_pages) for all x86{64}, powerpc, sh - binfmt_aout can be built as module
5) Get rid of ARCH_HAS_SETUP_ADDITIONAL_PAGES from various places
6) For x86_64 - define and export arch_setup_additional_pages as a wrapper over syscall32_setup_pages, call it from ia32_aout.c
Fully tested on x86. (Compile, boot and run the aout binary at http://ftp.funet.fi/pub/Linux/bin/as86.tar.Z). Other arches - changes are minimal but still I'll appreciate if someone tests them.
arch/i386/kernel/sysenter.c +1 -0
@@ -137,6 +137,7 @@up_write (&mm->mmap_sem);return ret; } +EXPORT_SYMBOL_GPL (arch_setup_additional_pages);const char *arch_vma_name (struct vm_area_struct *vma) {
arch/powerpc/kernel/vdso.c +1 -0
@@ -254,6 +254,7 @@up_write (&mm->mmap_sem);return rc; } +EXPORT_SYMBOL_GPL (arch_setup_additional_pages);const char *arch_vma_name (struct vm_area_struct *vma) {
arch/sh/kernel/vsyscall/vsyscall.c +1 -0
@@ -85,6 +85,7 @@up_write (&mm->mmap_sem);return ret; } +EXPORT_SYMBOL_GPL (arch_setup_additional_pages);const char *arch_vma_name (struct vm_area_struct *vma) {
arch/x86_64/ia32/ia32_aout.c +4 -0
@@ -23,6 +23,7 @@#include <linux/user.h> #include <linux/slab.h> #include <linux/binfmts.h> +#include <linux/interp.h> #include <linux/personality.h> #include <linux/init.h>
@@ -410,6 +411,12 @@send_sig (SIGKILL , current,0 );return retval; } + + retval =arch_setup_additional_pages (bprm,EXSTACK_DEFAULT ); + if (retval < 0) { + send_sig(SIGKILL, current, 0); + return retval; + } current->mm->start_stack = (unsigned long )create_aout_tables ((char __user *)bprm->p, bprm);
arch/x86_64/ia32/ia32_binfmt.c +0 -4
@@ -258,10 +258,6 @@static void elf32_init (struct pt_regs *); -#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 -#define arch_setup_additional_pages syscall32_setup_pages -extern int syscall32_setup_pages (struct linux_binprm *,int exstack); -#include "../../../fs/binfmt_elf.c" static void elf32_init (struct pt_regs *regs)
arch/x86_64/ia32/syscall32.c +6 -0
@@ -48,6 +48,12 @@return ret; } +int arch_setup_additional_pages (struct linux_binprm * bprm,int exstack) +{ +return syscall32_setup_pages (bprm, exstack); +} +EXPORT_SYMBOL_GPL (arch_setup_additional_pages); +const char *arch_vma_name (struct vm_area_struct *vma) { if (vma->vm_start == VSYSCALL32_BASE &&
fs/binfmt_aout.c +6 -0
@@ -22,6 +22,7 @@#include <linux/user.h> #include <linux/slab.h> #include <linux/binfmts.h> +#include <linux/interp.h> #include <linux/personality.h> #include <linux/init.h>
@@ -445,6 +446,14 @@send_sig (SIGKILL , current,0 );return retval; } + + if(arch_setup_additional_pages) { + retval =arch_setup_additional_pages (bprm,EXSTACK_DEFAULT ); + if (retval < 0) { + send_sig(SIGKILL, current, 0); + return retval; + } + } current->mm->start_stack = (unsigned long )create_aout_tables ((char __user *) bprm->p, bprm);
fs/binfmt_elf.c +7 -6
@@ -20,6 +20,7 @@#include <linux/errno.h> #include <linux/signal.h> #include <linux/binfmts.h> +#include <linux/interp.h> #include <linux/string.h> #include <linux/file.h> #include <linux/fcntl.h>
@@ -974,13 +975,13 @@set_binfmt (&elf_format); -#ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES - retval =arch_setup_additional_pages (bprm, executable_stack); -if (retval <0 ) { -send_sig (SIGKILL , current,0 ); - goto out; +if (arch_setup_additional_pages) { + retval =arch_setup_additional_pages (bprm, executable_stack); +if (retval <0 ) { +send_sig (SIGKILL , current,0 ); + goto out; + } } -#endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */ compute_creds (bprm); current->flags &= ~PF_FORKNOEXEC ;
include/linux/interp.h +7 -0
@@ -0,0 +1,8 @@ +#ifndef _LINUX_INTERP_H +#define _LINUX_INTERP_H + +struct linux_binprm ; + +extern int __attribute__((weak)) + arch_setup_additional_pages(struct linux_binprm*, int); +#endif /* _LINUX_INTERP_H */
Quoted 13 lines · Parag Warudkar
This a reworked, replacement version of x86-fix-vdso-mapping-for-aout-executables-* series of patches in -mm.
1) Define
arch_setup_additional_pages()as weak inlinux/interp.h
2) Includelinux/interp.hin appropriate places
3) Conditionally callarch_setup_additional_pages()from binfmt_*.c if the arch defines it
4)EXPORT_SYMBOL_GPL(arch_setup_additional_pages)for all x86{64}, powerpc, sh -binfmt_aoutcan be built as module
5) Get rid ofARCH_HAS_SETUP_ADDITIONAL_PAGESfrom various places
6) Forx86_64- define and exportarch_setup_additional_pagesas a wrapper oversyscall32_setup_pages, call it fromia32_aout.c
Quoted 3 lines
Fully tested on x86. (Compile, boot and run the aout binary at
http://ftp.funet.fi/pub/Linux/bin/as86.tar.Z). Other arches - changes are minimal but still I'll appreciate if someone tests them.
I already fixed this in a different way -- just use the stack trampoline on a.out
Can you double check
ftp://ftp.firstfloor.org/pub/ak/x86_64/quilt/patches/aout-no-vdso
works for you?
-Andi
Quoted 8 lines
I already fixed this in a different way -- just use the stack trampoline on a.out
Can you double check
ftp://ftp.firstfloor.org/pub/ak/x86_64/quilt/patches/aout-no-vdso
works for you?
Is there a reason why we specifically want to make a distinction between binfmts having and not having VDSOs and do we want aout to have the possibility of NOT having VDSO when a) It used to have it unconditionally b) nothing special is needed in arch or common code to have it and c) Not letting have it requires special arch-specific code* ?
[*] I see the patch handles i386 and x86_64 - but I am not sure if something similar will be needed for the other arches to allow aout executables in absence of VDSO (powerpc, sh).
Parag
Quoted 7 lines · Parag Warudkar
Quoted 7 lines
I already fixed this in a different way -- just use the stack trampoline on a.out
Can you double check
ftp://ftp.firstfloor.org/pub/ak/x86_64/quilt/patches/aout-no-vdso
Quoted 8 lines
Quoted 1 line
works for you?
Is there a reason why we specifically want to make a distinction between binfmts having and not having VDSOs and do we want aout to have the possibility of NOT having VDSO when a) It used to have it unconditionally b) nothing special is needed in arch or common code to have it and c) Not letting have it requires special arch-specific code* ?
I mainly did it this way because it was quite a lot simpler. I'm not worrying too much about other strange binfmts to be honest
Quoted 3 lines
[*] I see the patch handles i386 and
x86_64- but I am not sure if something similar will be needed for the other arches to allow aout executables in absence of VDSO (powerpc, sh).
Neither powerpc nor sh support a.out.
-Andi
Quoted 10 lines
Quoted 6 lines
Is there a reason why we specifically want to make a distinction between binfmts having and not having VDSOs and do we want aout to have the possibility of NOT having VDSO when a) It used to have it unconditionally b) nothing special is needed in arch or common code to have it and c) Not letting have it requires special arch-specific code* ?
I mainly did it this way because it was quite a lot simpler. I'm not worrying too much about other strange binfmts to be honest
Well with your suggestion of using weak definition (BTW, I find that thing cool :)) for arch_setup_additional_pages() I think my patch is simpler and it preserves existing behavior - it just boils down to actually calling the already existing function in binfmt_aout.c.
Quoted 6 lines
Quoted 3 lines
[*] I see the patch handles i386 and
x86_64- but I am not sure if something similar will be needed for the other arches to allow aout executables in absence of VDSO (powerpc, sh).Neither powerpc nor sh support a.out.
Ok, that's not a concern then. Not that I care about aout but if a simple fix can let it have VDSO and prevent special casing, I would prefer to let it have VDSO and still work - at least in the interest of preserving existing behavior.
Parag
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
[*] I see the patch handles i386 and
x86_64- but I am not sure if something similar will be needed for the other arches to allow aout executables in absence of VDSO (powerpc, sh).
Quoted 7 lines
Quoted 2 lines
Neither powerpc nor sh support a.out.
Ok, that's not a concern then. Not that I care about aout but if a simple fix can let it have VDSO and prevent special casing, I would prefer to let it have VDSO and still work - at least in the interest of preserving existing behavior.
Ok reasonable argument.
-Andi