Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / alpha / kernel / binfmt_loader.c
blobe4be7a543ecfd4dba7f50d2e7221a915a21897f9
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/init.h>
3 #include <linux/fs.h>
4 #include <linux/file.h>
5 #include <linux/mm_types.h>
6 #include <linux/binfmts.h>
7 #include <linux/a.out.h>
9 static int load_binary(struct linux_binprm *bprm)
11 struct exec *eh = (struct exec *)bprm->buf;
12 unsigned long loader;
13 struct file *file;
14 int retval;
16 if (eh->fh.f_magic != 0x183 || (eh->fh.f_flags & 0x3000) != 0x3000)
17 return -ENOEXEC;
19 if (bprm->loader)
20 return -ENOEXEC;
22 loader = bprm->vma->vm_end - sizeof(void *);
24 file = open_exec("/sbin/loader");
25 retval = PTR_ERR(file);
26 if (IS_ERR(file))
27 return retval;
29 /* Remember if the application is TASO. */
30 bprm->taso = eh->ah.entry < 0x100000000UL;
32 bprm->interpreter = file;
33 bprm->loader = loader;
34 return 0;
37 static struct linux_binfmt loader_format = {
38 .load_binary = load_binary,
41 static int __init init_loader_binfmt(void)
43 insert_binfmt(&loader_format);
44 return 0;
46 arch_initcall(init_loader_binfmt);