patch-2.4.10 linux/fs/exec.c
Next file: linux/fs/ext2/dir.c
Previous file: linux/fs/dquot.c
Back to the patch index
Back to the overall index
- Lines: 128
- Date:
Tue Sep 18 13:39:32 2001
- Orig file:
v2.4.9/linux/fs/exec.c
- Orig date:
Wed Jul 25 17:10:24 2001
diff -u --recursive --new-file v2.4.9/linux/fs/exec.c linux/fs/exec.c
@@ -34,6 +34,7 @@
#include <linux/pagemap.h>
#include <linux/highmem.h>
#include <linux/spinlock.h>
+#include <linux/personality.h>
#define __NO_VERSION__
#include <linux/module.h>
@@ -45,6 +46,8 @@
#include <linux/kmod.h>
#endif
+int core_uses_pid;
+
static struct linux_binfmt *formats;
static rwlock_t binfmt_lock = RW_LOCK_UNLOCKED;
@@ -159,11 +162,9 @@
if (argv != NULL) {
for (;;) {
char * p;
- int error;
- error = get_user(p,argv);
- if (error)
- return error;
+ if (get_user(p, argv))
+ return -EFAULT;
if (!p)
break;
argv++;
@@ -186,7 +187,7 @@
int len;
unsigned long pos;
- if (get_user(str, argv+argc) || !str || !(len = strnlen_user(str, bprm->p)))
+ if (get_user(str, argv+argc) || !(len = strnlen_user(str, bprm->p)))
return -EFAULT;
if (bprm->p < len)
return -E2BIG;
@@ -262,7 +263,7 @@
pte_t * pte;
if (page_count(page) != 1)
- printk("mem_map disagrees with %p at %08lx\n", page, address);
+ printk(KERN_ERR "mem_map disagrees with %p at %08lx\n", page, address);
pgd = pgd_offset(tsk->mm, address);
spin_lock(&tsk->mm->page_table_lock);
@@ -347,8 +348,11 @@
if (!err) {
inode = nd.dentry->d_inode;
file = ERR_PTR(-EACCES);
- if (!IS_NOEXEC(inode) && S_ISREG(inode->i_mode)) {
+ if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&
+ S_ISREG(inode->i_mode)) {
int err = permission(inode, MAY_EXEC);
+ if (!err && !(inode->i_mode & 0111))
+ err = -EACCES;
file = ERR_PTR(err);
if (!err) {
file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
@@ -580,9 +584,10 @@
mmap_failed:
flush_failed:
spin_lock_irq(¤t->sigmask_lock);
- if (current->sig != oldsig)
+ if (current->sig != oldsig) {
kfree(current->sig);
- current->sig = oldsig;
+ current->sig = oldsig;
+ }
spin_unlock_irq(¤t->sigmask_lock);
return retval;
}
@@ -593,7 +598,7 @@
*/
static inline int must_not_trace_exec(struct task_struct * p)
{
- return (p->ptrace & PT_PTRACED) && !cap_raised(p->p_pptr->cap_effective, CAP_SYS_PTRACE);
+ return (p->ptrace & PT_PTRACED) && !(p->ptrace & PT_PTRACE_CAP);
}
/*
@@ -606,7 +611,10 @@
struct inode * inode = bprm->file->f_dentry->d_inode;
mode = inode->i_mode;
- /* Huh? We had already checked for MAY_EXEC, WTF do we check this? */
+ /*
+ * Check execute perms again - if the caller has CAP_DAC_OVERRIDE,
+ * vfs_permission lets a non-executable through
+ */
if (!(mode & 0111)) /* with at least _one_ execute bit set */
return -EACCES;
if (bprm->file->f_op == NULL)
@@ -615,7 +623,7 @@
bprm->e_uid = current->euid;
bprm->e_gid = current->egid;
- if(!IS_NOSUID(inode)) {
+ if(!(bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID)) {
/* Set-uid? */
if (mode & S_ISUID)
bprm->e_uid = inode->i_uid;
@@ -924,7 +932,7 @@
int do_coredump(long signr, struct pt_regs * regs)
{
struct linux_binfmt * binfmt;
- char corename[6+sizeof(current->comm)];
+ char corename[6+sizeof(current->comm)+10];
struct file * file;
struct inode * inode;
int retval = 0;
@@ -940,11 +948,9 @@
goto fail;
memcpy(corename,"core.", 5);
-#if 0
- memcpy(corename+5,current->comm,sizeof(current->comm));
-#else
corename[4] = '\0';
-#endif
+ if (core_uses_pid || atomic_read(¤t->mm->mm_users) != 1)
+ sprintf(&corename[4], ".%d", current->pid);
file = filp_open(corename, O_CREAT | 2 | O_NOFOLLOW, 0600);
if (IS_ERR(file))
goto fail;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)