Path: blob/master/arch/alpha/kernel/binfmt_loader.c
10817 views
#include <linux/init.h>1#include <linux/fs.h>2#include <linux/file.h>3#include <linux/mm_types.h>4#include <linux/binfmts.h>5#include <linux/a.out.h>67static int load_binary(struct linux_binprm *bprm, struct pt_regs *regs)8{9struct exec *eh = (struct exec *)bprm->buf;10unsigned long loader;11struct file *file;12int retval;1314if (eh->fh.f_magic != 0x183 || (eh->fh.f_flags & 0x3000) != 0x3000)15return -ENOEXEC;1617if (bprm->loader)18return -ENOEXEC;1920allow_write_access(bprm->file);21fput(bprm->file);22bprm->file = NULL;2324loader = bprm->vma->vm_end - sizeof(void *);2526file = open_exec("/sbin/loader");27retval = PTR_ERR(file);28if (IS_ERR(file))29return retval;3031/* Remember if the application is TASO. */32bprm->taso = eh->ah.entry < 0x100000000UL;3334bprm->file = file;35bprm->loader = loader;36retval = prepare_binprm(bprm);37if (retval < 0)38return retval;39return search_binary_handler(bprm,regs);40}4142static struct linux_binfmt loader_format = {43.load_binary = load_binary,44};4546static int __init init_loader_binfmt(void)47{48return insert_binfmt(&loader_format);49}50arch_initcall(init_loader_binfmt);515253