Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 198744
b: refs/heads/master
c: c713541
h: refs/heads/master
v: v3
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed May 27, 2010
1 parent 8feeb6e commit 1977bc7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 33 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: 04b1c384fbc4e0209e5c1affb67050886376d44b
refs/heads/master: c713541125002b8bc9e681af3b09118e771e2d8a
63 changes: 31 additions & 32 deletions trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,6 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
char corename[CORENAME_MAX_SIZE + 1];
struct mm_struct *mm = current->mm;
struct linux_binfmt * binfmt;
struct inode * inode;
const struct cred *old_cred;
struct cred *cred;
int retval = 0;
Expand Down Expand Up @@ -1914,9 +1913,6 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
ispipe = format_corename(corename, signr);
unlock_kernel();

if ((!ispipe) && (cprm.limit < binfmt->min_coredump))
goto fail_unlock;

if (ispipe) {
if (cprm.limit == 1) {
/*
Expand Down Expand Up @@ -1969,39 +1965,42 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
corename);
goto fail_dropcount;
}
} else
} else {
struct inode *inode;

if (cprm.limit < binfmt->min_coredump)
goto fail_unlock;

cprm.file = filp_open(corename,
O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
0600);
if (IS_ERR(cprm.file))
goto fail_dropcount;
inode = cprm.file->f_path.dentry->d_inode;
if (inode->i_nlink > 1)
goto close_fail; /* multiple links - don't dump */
if (!ispipe && d_unhashed(cprm.file->f_path.dentry))
goto close_fail;

/* AK: actually i see no reason to not allow this for named pipes etc.,
but keep the previous behaviour for now. */
if (!ispipe && !S_ISREG(inode->i_mode))
goto close_fail;
/*
* Dont allow local users get cute and trick others to coredump
* into their pre-created files:
* Note, this is not relevant for pipes
*/
if (!ispipe && (inode->i_uid != current_fsuid()))
goto close_fail;
if (!cprm.file->f_op)
goto close_fail;
if (!cprm.file->f_op->write)
goto close_fail;
if (!ispipe &&
do_truncate(cprm.file->f_path.dentry, 0, 0, cprm.file) != 0)
goto close_fail;
if (IS_ERR(cprm.file))
goto fail_unlock;

retval = binfmt->core_dump(&cprm);
inode = cprm.file->f_path.dentry->d_inode;
if (inode->i_nlink > 1)
goto close_fail;
if (d_unhashed(cprm.file->f_path.dentry))
goto close_fail;
/*
* AK: actually i see no reason to not allow this for named
* pipes etc, but keep the previous behaviour for now.
*/
if (!S_ISREG(inode->i_mode))
goto close_fail;
/*
* Dont allow local users get cute and trick others to coredump
* into their pre-created files.
*/
if (inode->i_uid != current_fsuid())
goto close_fail;
if (!cprm.file->f_op || !cprm.file->f_op->write)
goto close_fail;
if (do_truncate(cprm.file->f_path.dentry, 0, 0, cprm.file))
goto close_fail;
}

retval = binfmt->core_dump(&cprm);
if (retval)
current->signal->group_exit_code |= 0x80;
close_fail:
Expand Down

0 comments on commit 1977bc7

Please sign in to comment.