Skip to content

Commit 3bfacef

Browse files
Al Virotorvalds
authored andcommitted
get rid of special-casing the /sbin/loader on alpha
... just make it a binfmt handler like #! one. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 17580d7 commit 3bfacef

3 files changed

Lines changed: 52 additions & 40 deletions

File tree

‎arch/alpha/kernel/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ EXTRA_CFLAGS := -Werror -Wno-sign-compare
88

99
obj-y := entry.o traps.o process.o init_task.o osf_sys.o irq.o \
1010
irq_alpha.o signal.o setup.o ptrace.o time.o \
11-
alpha_ksyms.o systbls.o err_common.o io.o
11+
alpha_ksyms.o systbls.o err_common.o io.o binfmt_loader.o
1212

1313
obj-$(CONFIG_VGA_HOSE) += console.o
1414
obj-$(CONFIG_SMP) += smp.o

‎arch/alpha/kernel/binfmt_loader.c‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <linux/init.h>
2+
#include <linux/fs.h>
3+
#include <linux/file.h>
4+
#include <linux/mm_types.h>
5+
#include <linux/binfmts.h>
6+
#include <linux/a.out.h>
7+
8+
static int load_binary(struct linux_binprm *bprm, struct pt_regs *regs)
9+
{
10+
struct exec *eh = (struct exec *)bprm->buf;
11+
unsigned long loader;
12+
struct file *file;
13+
int retval;
14+
15+
if (eh->fh.f_magic != 0x183 || (eh->fh.f_flags & 0x3000) != 0x3000)
16+
return -ENOEXEC;
17+
18+
if (bprm->loader)
19+
return -ENOEXEC;
20+
21+
allow_write_access(bprm->file);
22+
fput(bprm->file);
23+
bprm->file = NULL;
24+
25+
loader = bprm->vma->vm_end - sizeof(void *);
26+
27+
file = open_exec("/sbin/loader");
28+
retval = PTR_ERR(file);
29+
if (IS_ERR(file))
30+
return retval;
31+
32+
/* Remember if the application is TASO. */
33+
bprm->taso = eh->ah.entry < 0x100000000UL;
34+
35+
bprm->file = file;
36+
bprm->loader = loader;
37+
retval = prepare_binprm(bprm);
38+
if (retval < 0)
39+
return retval;
40+
return search_binary_handler(bprm,regs);
41+
}
42+
43+
static struct linux_binfmt loader_format = {
44+
.load_binary = load_binary,
45+
};
46+
47+
static int __init init_loader_binfmt(void)
48+
{
49+
return register_binfmt(&loader_format);
50+
}
51+
arch_initcall(init_loader_binfmt);

‎fs/exec.c‎

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@
5757
#include <asm/tlb.h>
5858
#include "internal.h"
5959

60-
#ifdef __alpha__
61-
/* for /sbin/loader handling in search_binary_handler() */
62-
#include <linux/a.out.h>
63-
#endif
64-
6560
int core_uses_pid;
6661
char core_pattern[CORENAME_MAX_SIZE] = "core";
6762
int suid_dumpable = 0;
@@ -1172,41 +1167,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
11721167
unsigned int depth = bprm->recursion_depth;
11731168
int try,retval;
11741169
struct linux_binfmt *fmt;
1175-
#ifdef __alpha__
1176-
/* handle /sbin/loader.. */
1177-
{
1178-
struct exec * eh = (struct exec *) bprm->buf;
11791170

1180-
if (!bprm->loader && eh->fh.f_magic == 0x183 &&
1181-
(eh->fh.f_flags & 0x3000) == 0x3000)
1182-
{
1183-
struct file * file;
1184-
unsigned long loader;
1185-
1186-
allow_write_access(bprm->file);
1187-
fput(bprm->file);
1188-
bprm->file = NULL;
1189-
1190-
loader = bprm->vma->vm_end - sizeof(void *);
1191-
1192-
file = open_exec("/sbin/loader");
1193-
retval = PTR_ERR(file);
1194-
if (IS_ERR(file))
1195-
return retval;
1196-
1197-
/* Remember if the application is TASO. */
1198-
bprm->taso = eh->ah.entry < 0x100000000UL;
1199-
1200-
bprm->file = file;
1201-
bprm->loader = loader;
1202-
retval = prepare_binprm(bprm);
1203-
if (retval<0)
1204-
return retval;
1205-
/* should call search_binary_handler recursively here,
1206-
but it does not matter */
1207-
}
1208-
}
1209-
#endif
12101171
retval = security_bprm_check(bprm);
12111172
if (retval)
12121173
return retval;

0 commit comments

Comments
 (0)