patch-2.4.23 linux-2.4.23/fs/exec.c

Next file: linux-2.4.23/fs/fcntl.c
Previous file: linux-2.4.23/fs/dquot.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.22/fs/exec.c linux-2.4.23/fs/exec.c
@@ -50,6 +50,7 @@
 
 int core_uses_pid;
 char core_pattern[65] = "core";
+int core_setuid_ok = 0;
 /* The maximal length of core_pattern is also specified in sysctl.c */ 
 
 static struct linux_binfmt *formats;
@@ -425,11 +426,6 @@
 	struct mm_struct * mm, * old_mm;
 
 	old_mm = current->mm;
-	if (old_mm && atomic_read(&old_mm->mm_users) == 1) {
-		mm_release();
-		exit_mmap(old_mm);
-		return 0;
-	}
 
 	mm = mm_alloc();
 	if (mm) {
@@ -1104,13 +1100,18 @@
 	struct file * file;
 	struct inode * inode;
 	int retval = 0;
+	int fsuid = current->fsuid;
 
 	lock_kernel();
 	binfmt = current->binfmt;
 	if (!binfmt || !binfmt->core_dump)
 		goto fail;
 	if (!is_dumpable(current))
-		goto fail;
+	{
+		if(!core_setuid_ok || !current->task_dumpable)
+			goto fail;
+		current->fsuid = 0;
+	}
 	current->mm->dumpable = 0;
 	if (current->rlim[RLIMIT_CORE].rlim_cur < binfmt->min_coredump)
 		goto fail;
@@ -1139,6 +1140,8 @@
 close_fail:
 	filp_close(file, NULL);
 fail:
+	if (fsuid != current->fsuid)
+		current->fsuid = fsuid;
 	unlock_kernel();
 	return retval;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)