patch-2.3.99-pre4 linux/fs/exec.c

Next file: linux/fs/ext2/namei.c
Previous file: linux/fs/dquot.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre3/linux/fs/exec.c linux/fs/exec.c
@@ -112,7 +112,7 @@
 		goto out;
 	file = fget(fd);
 	retval = -ENOEXEC;
-	if (file && file->f_dentry && file->f_op && file->f_op->read) {
+	if (file && file->f_op && file->f_op->read) {
 		spin_lock(&binfmt_lock);
 		for (fmt = formats ; fmt ; fmt = fmt->next) {
 			if (!fmt->load_shlib)
@@ -315,27 +315,30 @@
 	return 0;
 }
 
+/* MOUNT_REWRITE: &mnt should be passed to lookup_dentry */
 struct file *open_exec(const char *name)
 {
 	struct dentry *dentry;
+	struct vfsmount *mnt = NULL;
 	struct file *file;
 
 	lock_kernel();
-	dentry = lookup_dentry(name, NULL, LOOKUP_FOLLOW);
+	dentry = lookup_dentry(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE);
 	file = (struct file*) dentry;
 	if (!IS_ERR(dentry)) {
 		file = ERR_PTR(-EACCES);
-		if (dentry->d_inode && S_ISREG(dentry->d_inode->i_mode)) {
+		if (S_ISREG(dentry->d_inode->i_mode)) {
 			int err = permission(dentry->d_inode, MAY_EXEC);
 			file = ERR_PTR(err);
 			if (!err) {
-				file = dentry_open(dentry, O_RDONLY);
+				file = dentry_open(dentry, mnt, O_RDONLY);
 out:
 				unlock_kernel();
 				return file;
 			}
 		}
 		dput(dentry);
+		mntput(mnt);
 	}
 	goto out;
 }
@@ -860,7 +863,6 @@
 	struct linux_binfmt * binfmt;
 	char corename[6+sizeof(current->comm)];
 	struct file * file;
-	struct dentry * dentry;
 	struct inode * inode;
 
 	lock_kernel();
@@ -879,17 +881,16 @@
 #else
 	corename[4] = '\0';
 #endif
-	file = filp_open(corename, O_CREAT | 2 | O_TRUNC | O_NOFOLLOW, 0600, NULL);
+	file = filp_open(corename, O_CREAT | 2 | O_TRUNC | O_NOFOLLOW, 0600);
 	if (IS_ERR(file))
 		goto fail;
-	dentry = file->f_dentry;
-	inode = dentry->d_inode;
+	inode = file->f_dentry->d_inode;
 	if (inode->i_nlink > 1)
 		goto close_fail;	/* multiple links - don't dump */
 
 	if (!S_ISREG(inode->i_mode))
 		goto close_fail;
-	if (!inode->i_fop)
+	if (!file->f_op)
 		goto close_fail;
 	if (!file->f_op->write)
 		goto close_fail;

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