Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 114788
b: refs/heads/master
c: bf2a9a3
h: refs/heads/master
v: v3
  • Loading branch information
Kirill A. Shutemov authored and Linus Torvalds committed Oct 16, 2008
1 parent e26b5c6 commit 54c094f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 53112488bebe25c0f5f8a002470046c0fe9a6c61
refs/heads/master: bf2a9a39639b8b51377905397a5005f444e9a892
2 changes: 1 addition & 1 deletion trunk/fs/binfmt_em86.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static int load_em86(struct linux_binprm *bprm,struct pt_regs *regs)
return -ENOEXEC;
}

bprm->sh_bang = 1; /* Well, the bang-shell is implicit... */
bprm->recursion_depth++; /* Well, the bang-shell is implicit... */
allow_write_access(bprm->file);
fput(bprm->file);
bprm->file = NULL;
Expand Down
4 changes: 2 additions & 2 deletions trunk/fs/binfmt_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
goto _ret;

retval = -ENOEXEC;
if (bprm->misc_bang)
if (bprm->recursion_depth > BINPRM_MAX_RECURSION)
goto _ret;

/* to keep locking time low, we copy the interpreter string */
Expand Down Expand Up @@ -197,7 +197,7 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
if (retval < 0)
goto _error;

bprm->misc_bang = 1;
bprm->recursion_depth++;

retval = search_binary_handler (bprm, regs);
if (retval < 0)
Expand Down
5 changes: 3 additions & 2 deletions trunk/fs/binfmt_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ static int load_script(struct linux_binprm *bprm,struct pt_regs *regs)
char interp[BINPRM_BUF_SIZE];
int retval;

if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!') || (bprm->sh_bang))
if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!') ||
(bprm->recursion_depth > BINPRM_MAX_RECURSION))
return -ENOEXEC;
/*
* This section does the #! interpretation.
* Sorta complicated, but hopefully it will work. -TYT
*/

bprm->sh_bang = 1;
bprm->recursion_depth++;
allow_write_access(bprm->file);
fput(bprm->file);
bprm->file = NULL;
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/binfmts.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct linux_binprm{
#ifdef __alpha__
unsigned int taso:1;
#endif
unsigned int recursion_depth;
struct file * file;
int e_uid, e_gid;
kernel_cap_t cap_post_exec_permitted;
Expand All @@ -61,6 +62,7 @@ struct linux_binprm{
#define BINPRM_FLAGS_EXECFD_BIT 1
#define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT)

#define BINPRM_MAX_RECURSION 4

/*
* This structure defines the functions that are used to load the binary formats that
Expand Down

0 comments on commit 54c094f

Please sign in to comment.