Re: 2.6.23-mm1: BUG in reiserfs_delete_xattrs

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Laurent Riffard <laurent.riffard@...>
Cc: Andrew Morton <akpm@...>, Dave Hansen <haveblue@...>, <linux-kernel@...>, <linux-fsdevel@...>, <reiserfs-devel@...>
Date: Monday, October 15, 2007 - 4:40 am

On Mon, Oct 15, 2007 at 12:34:58AM +0200, Laurent Riffard wrote:

The delete path is a similar case as the one Dave fixed, also cause by
a NULL vfsmount passed to dentry_open, but through a different code-path.

Untested fix for this problem below:

Index: linux-2.6.23-rc8/fs/reiserfs/xattr.c
===================================================================
--- linux-2.6.23-rc8.orig/fs/reiserfs/xattr.c	2007-09-30 14:13:46.000000000 +0200
+++ linux-2.6.23-rc8/fs/reiserfs/xattr.c	2007-09-30 14:18:30.000000000 +0200
@@ -207,9 +207,8 @@ static struct dentry *get_xa_file_dentry
  * we're called with i_mutex held, so there are no worries about the directory
  * changing underneath us.
  */
-static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir)
+static int __xattr_readdir(struct inode *inode, void *dirent, filldir_t filldir)
 {
-	struct inode *inode = filp->f_path.dentry->d_inode;
 	struct cpu_key pos_key;	/* key of current position in the directory (key of directory entry) */
 	INITIALIZE_PATH(path_to_entry);
 	struct buffer_head *bh;
@@ -352,24 +351,19 @@ static int __xattr_readdir(struct file *
  * this is stolen from vfs_readdir
  *
  */
-static
-int xattr_readdir(struct file *file, filldir_t filler, void *buf)
+static int xattr_readdir(struct inode *inode, filldir_t filler, void *buf)
 {
-	struct inode *inode = file->f_path.dentry->d_inode;
 	int res = -ENOTDIR;
-	if (!file->f_op || !file->f_op->readdir)
-		goto out;
+
 	mutex_lock_nested(&inode->i_mutex, I_MUTEX_XATTR);
-//        down(&inode->i_zombie);
 	res = -ENOENT;
 	if (!IS_DEADDIR(inode)) {
 		lock_kernel();
-		res = __xattr_readdir(file, buf, filler);
+		res = __xattr_readdir(inode, buf, filler);
 		unlock_kernel();
 	}
-//        up(&inode->i_zombie);
 	mutex_unlock(&inode->i_mutex);
-      out:
+
 	return res;
 }
 
@@ -721,7 +715,6 @@ reiserfs_delete_xattrs_filler(void *buf,
 /* This is called w/ inode->i_mutex downed */
 int reiserfs_delete_xattrs(struct inode *inode)
 {
-	struct file *fp;
 	struct dentry *dir, *root;
 	int err = 0;
 
@@ -742,15 +735,8 @@ int reiserfs_delete_xattrs(struct inode 
 		return 0;
 	}
 
-	fp = dentry_open(dir, NULL, O_RDWR);
-	if (IS_ERR(fp)) {
-		err = PTR_ERR(fp);
-		/* dentry_open dputs the dentry if it fails */
-		goto out;
-	}
-
 	lock_kernel();
-	err = xattr_readdir(fp, reiserfs_delete_xattrs_filler, dir);
+	err = xattr_readdir(dir->d_inode, reiserfs_delete_xattrs_filler, dir);
 	if (err) {
 		unlock_kernel();
 		goto out_dir;
@@ -770,7 +756,7 @@ int reiserfs_delete_xattrs(struct inode 
 	unlock_kernel();
 
       out_dir:
-	fput(fp);
+	dput(dir);
 
       out:
 	if (!err)
@@ -812,7 +798,6 @@ reiserfs_chown_xattrs_filler(void *buf, 
 
 int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
 {
-	struct file *fp;
 	struct dentry *dir;
 	int err = 0;
 	struct reiserfs_chown_buf buf;
@@ -836,13 +821,6 @@ int reiserfs_chown_xattrs(struct inode *
 		goto out;
 	}
 
-	fp = dentry_open(dir, NULL, O_RDWR);
-	if (IS_ERR(fp)) {
-		err = PTR_ERR(fp);
-		/* dentry_open dputs the dentry if it fails */
-		goto out;
-	}
-
 	lock_kernel();
 
 	attrs->ia_valid &= (ATTR_UID | ATTR_GID | ATTR_CTIME);
@@ -850,7 +828,7 @@ int reiserfs_chown_xattrs(struct inode *
 	buf.attrs = attrs;
 	buf.inode = inode;
 
-	err = xattr_readdir(fp, reiserfs_chown_xattrs_filler, &buf);
+	err = xattr_readdir(dir->d_inode, reiserfs_chown_xattrs_filler, &buf);
 	if (err) {
 		unlock_kernel();
 		goto out_dir;
@@ -860,7 +838,7 @@ int reiserfs_chown_xattrs(struct inode *
 	unlock_kernel();
 
       out_dir:
-	fput(fp);
+	dput(dir);
 
       out:
 	attrs->ia_valid = ia_valid;
@@ -1008,7 +986,6 @@ reiserfs_listxattr_filler(void *buf, con
  */
 ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
 {
-	struct file *fp;
 	struct dentry *dir;
 	int err = 0;
 	struct reiserfs_listxattr_buf buf;
@@ -1031,13 +1008,6 @@ ssize_t reiserfs_listxattr(struct dentry
 		goto out;
 	}
 
-	fp = dentry_open(dir, NULL, O_RDWR);
-	if (IS_ERR(fp)) {
-		err = PTR_ERR(fp);
-		/* dentry_open dputs the dentry if it fails */
-		goto out;
-	}
-
 	buf.r_buf = buffer;
 	buf.r_size = buffer ? size : 0;
 	buf.r_pos = 0;
@@ -1045,7 +1015,7 @@ ssize_t reiserfs_listxattr(struct dentry
 
 	REISERFS_I(dentry->d_inode)->i_flags |= i_has_xattr_dir;
 
-	err = xattr_readdir(fp, reiserfs_listxattr_filler, &buf);
+	err = xattr_readdir(dir->d_inode, reiserfs_listxattr_filler, &buf);
 	if (err)
 		goto out_dir;
 
@@ -1055,7 +1025,7 @@ ssize_t reiserfs_listxattr(struct dentry
 		err = buf.r_pos;
 
       out_dir:
-	fput(fp);
+	dput(dir);
 
       out:
 	reiserfs_read_unlock_xattr_i(dentry->d_inode);
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
2.6.23-mm1, Andrew Morton, (Fri Oct 12, 12:31 am)
kernel panic when running tcpdump, Mariusz Kozlowski, (Mon Oct 22, 2:40 pm)
Re: kernel panic when running tcpdump, Andrew Morton, (Mon Oct 22, 3:03 pm)
Re: kernel panic when running tcpdump, Mariusz Kozlowski, (Mon Oct 22, 5:16 pm)
mysqld prevents s2ram [Re: 2.6.23-mm1], Mattia Dongili, (Sun Oct 21, 1:58 am)
Re: mysqld prevents s2ram [Re: 2.6.23-mm1], Pavel Machek, (Sun Oct 21, 5:58 am)
Re: mysqld prevents s2ram [Re: 2.6.23-mm1], Rafael J. Wysocki, (Sun Oct 21, 7:53 am)
Re: mysqld prevents s2ram [Re: 2.6.23-mm1], Mattia Dongili, (Sun Oct 21, 2:28 am)
Re: 2.6.23-mm1 - list_add corruption in cgroup, Cedric Le Goater, (Wed Oct 17, 11:54 am)
Re: 2.6.23-mm1 - list_add corruption in cgroup, Paul Menage, (Fri Oct 19, 6:11 pm)
Re: 2.6.23-mm1 - list_add corruption in cgroup, Paul Menage, (Thu Oct 18, 11:56 am)
Re: 2.6.23-mm1: BUG in reiserfs_delete_xattrs, Laurent Riffard, (Sun Oct 14, 6:34 pm)
Re: 2.6.23-mm1: BUG in reiserfs_delete_xattrs, Christoph Hellwig, (Mon Oct 15, 4:40 am)
Re: 2.6.23-mm1: BUG in reiserfs_delete_xattrs, Laurent Riffard, (Mon Oct 15, 3:51 pm)
Re: 2.6.23-mm1: BUG in reiserfs_delete_xattrs, Jeff Mahoney, (Mon Oct 15, 2:31 pm)
Re: 2.6.23-mm1: BUG in reiserfs_delete_xattrs, Laurent Riffard, (Mon Oct 15, 4:06 pm)
Re: 2.6.23-mm1: BUG in reiserfs_delete_xattrs, Jeff Mahoney, (Mon Oct 15, 4:23 pm)
Re: 2.6.23-mm1: BUG in reiserfs_delete_xattrs, Christoph Hellwig, (Wed Oct 17, 4:59 am)
Re: 2.6.23-mm1: BUG in reiserfs_delete_xattrs, Christoph Hellwig, (Wed Oct 17, 4:58 am)
Re: 2.6.23-mm1: BUG in reiserfs_delete_xattrs, Jeff Mahoney, (Wed Oct 17, 10:55 am)
[2.6.23-mm1] CONFIG_LOCALVERSION handling broken, Tilman Schmidt, (Sat Oct 13, 6:11 pm)
Re: [2.6.23-mm1] CONFIG_LOCALVERSION handling broken, Tilman Schmidt, (Wed Oct 17, 7:06 pm)
Re: [2.6.23-mm1] CONFIG_LOCALVERSION handling broken, Tilman Schmidt, (Sat Oct 27, 11:19 am)
Re: [2.6.23-mm1] CONFIG_LOCALVERSION handling broken, Sam Ravnborg, (Sat Oct 27, 11:28 am)
Re: [2.6.23-mm1] CONFIG_LOCALVERSION handling broken, Sam Ravnborg, (Wed Oct 17, 4:27 pm)
Re: 2.6.23-mm1, Gabriel C, (Sat Oct 13, 1:12 pm)
Re: 2.6.23-mm1, Andrew Morton, (Sat Oct 13, 2:01 pm)
Re: 2.6.23-mm1, Gabriel C, (Sat Oct 13, 2:08 pm)
Re: 2.6.23-mm1, Dave Hansen, (Mon Oct 15, 12:28 pm)
Re: 2.6.23-mm1 - build failure with advansys, Kamalesh Babulal, (Sat Oct 13, 12:44 am)
Re: 2.6.23-mm1 - build failure with advansys, Andrew Morton, (Sat Oct 13, 2:52 am)
Re: 2.6.23-mm1 - build failure with advansys, Paul Mackerras, (Wed Oct 17, 8:07 pm)
Re: 2.6.23-mm1 - build failure with advansys, Matthew Wilcox, (Wed Oct 17, 9:48 pm)
Re: 2.6.23-mm1 - Build failure on rgmii, Kamalesh Babulal, (Sat Oct 13, 12:35 am)
Re: 2.6.23-mm1, Laurent Riffard, (Fri Oct 12, 4:38 pm)
Re: 2.6.23-mm1, Andrew Morton, (Fri Oct 12, 5:00 pm)
Re: 2.6.23-mm1, Zan Lynx, (Mon Oct 15, 12:13 pm)
Re: 2.6.23-mm1 - build failure on axonram, Kamalesh Babulal, (Fri Oct 12, 3:44 am)
oops in lbmIODone, fails to boot [Re: 2.6.23-mm1], Mattia Dongili, (Sat Oct 20, 12:57 am)
Re: oops in lbmIODone, fails to boot [Re: 2.6.23-mm1], Andrew Morton, (Sat Oct 20, 1:34 am)
Re: oops in lbmIODone, fails to boot [Re: 2.6.23-mm1], Dave Kleikamp, (Sat Oct 20, 8:18 am)
Re: oops in lbmIODone, fails to boot [Re: 2.6.23-mm1], Mattia Dongili, (Sun Oct 21, 1:44 am)
Re: 2.6.23-mm1 - autofs broken, Rik van Riel, (Sat Oct 20, 1:13 am)
Re: 2.6.23-mm1 - autofs broken, Ian Kent, (Sun Oct 21, 11:45 pm)
Re: 2.6.23-mm1 - autofs broken, Rik van Riel, (Mon Oct 22, 12:46 pm)
Re: 2.6.23-mm1 - autofs broken, Andrew Morton, (Sat Oct 20, 1:39 am)
Re: 2.6.23-mm1 - autofs broken, Rik van Riel, (Sat Oct 20, 1:54 am)
Re: 2.6.23-mm1 - autofs broken, Rik van Riel, (Sat Oct 20, 1:54 am)
Re: 2.6.23-mm1 - autofs broken, Rik van Riel, (Sat Oct 20, 10:56 am)
Re: 2.6.23-mm1 - autofs broken, Dave Hansen, (Mon Oct 22, 6:03 pm)
Re: 2.6.23-mm1, KAMEZAWA Hiroyuki, (Wed Oct 17, 3:01 am)
Re: 2.6.23-mm1, Jiri Kosina, (Wed Oct 17, 5:10 am)
Re: 2.6.23-mm1, KAMEZAWA Hiroyuki, (Wed Oct 17, 5:36 am)
Re: 2.6.23-mm1, Jiri Kosina, (Fri Oct 19, 5:54 pm)
Re: 2.6.23-mm1, Jiri Kosina, (Wed Oct 17, 7:42 am)
Re: 2.6.23-mm1, KAMEZAWA Hiroyuki, (Wed Oct 17, 8:33 am)
PIE randomization (was Re: 2.6.23-mm1), Jiri Kosina, (Fri Oct 19, 5:07 am)
Re: 2.6.23-mm1, Andrew Morton, (Wed Oct 17, 5:02 am)
Suspend Broken (Re: 2.6.23-mm1), Dhaval Giani, (Sat Oct 13, 1:58 pm)
Re: Suspend Broken (Re: 2.6.23-mm1), Rafael J. Wysocki, (Sat Oct 13, 2:33 pm)
Re: Suspend Broken (Re: 2.6.23-mm1), Dhaval Giani, (Sun Oct 14, 12:26 am)
Re: Suspend Broken (Re: 2.6.23-mm1), Rafael J. Wysocki, (Sun Oct 14, 10:19 am)
Re: 2.6.23-mm1 pm_prepare() and _finish() w/ args vs. without, Rafael J. Wysocki, (Sat Oct 13, 1:22 pm)
Re: 2.6.23-mm1 pm_prepare() and _finish() w/ args vs. without, Rafael J. Wysocki, (Sat Oct 13, 3:13 pm)
Re: 2.6.23-mm1 pm_prepare() and _finish() w/ args vs. without, Rafael J. Wysocki, (Sun Oct 14, 4:20 pm)
Re: 2.6.23-mm1 pm_prepare() and _finish() w/ args vs. without, Rafael J. Wysocki, (Mon Oct 15, 4:55 pm)
Re: 2.6.23-mm1, Rafael J. Wysocki, (Fri Oct 12, 5:32 pm)
Re: 2.6.23-mm1, Mark Gross, (Mon Oct 15, 12:09 pm)
Re: 2.6.23-mm1, Rafael J. Wysocki, (Mon Oct 15, 4:40 pm)
Re: 2.6.23-mm1, Mark Gross, (Tue Oct 16, 3:58 pm)
Re: 2.6.23-mm1, Rafael J. Wysocki, (Tue Oct 16, 4:28 pm)
Re: 2.6.23-mm1, Mark Gross, (Tue Oct 16, 7:31 pm)
Re: 2.6.23-mm1, KAMEZAWA Hiroyuki, (Fri Oct 12, 1:03 am)
Re: 2.6.23-mm1, Cedric Le Goater, (Fri Oct 12, 2:48 am)
Re: 2.6.23-mm1, Andrew Morton, (Fri Oct 12, 2:42 am)
Re: 2.6.23-mm1, Torsten Kaiser, (Fri Oct 12, 4:31 am)
Re: 2.6.23-mm1, Andrew Morton, (Fri Oct 12, 4:37 am)
Re: 2.6.23-mm1, Torsten Kaiser, (Sat Oct 13, 4:01 am)
Re: 2.6.23-mm1, Jeff Garzik, (Sat Oct 13, 6:55 am)
Re: 2.6.23-mm1, Torsten Kaiser, (Sat Oct 13, 8:03 am)
Re: 2.6.23-mm1, Jeff Garzik, (Sat Oct 13, 8:19 am)
Re: 2.6.23-mm1, Torsten Kaiser, (Sat Oct 13, 10:32 am)
Re: 2.6.23-mm1, Torsten Kaiser, (Sat Oct 13, 10:40 am)
Re: 2.6.23-mm1, Torsten Kaiser, (Sat Oct 13, 11:13 am)
Re: 2.6.23-mm1, Jeff Garzik, (Sat Oct 13, 1:48 pm)
Re: 2.6.23-mm1, Torsten Kaiser, (Sat Oct 13, 2:05 pm)
Re: 2.6.23-mm1, Jeff Garzik, (Sat Oct 13, 2:41 pm)
Re: 2.6.23-mm1, Andrew Morton, (Sat Oct 13, 2:18 pm)
Re: 2.6.23-mm1, Torsten Kaiser, (Sun Oct 14, 7:54 am)
Re: 2.6.23-mm1, Andrew Morton, (Sun Oct 14, 2:39 pm)
Re: 2.6.23-mm1, Torsten Kaiser, (Sun Oct 14, 3:12 pm)
Re: 2.6.23-mm1, Andrew Morton, (Sun Oct 14, 3:26 pm)
Re: 2.6.23-mm1, Torsten Kaiser, (Sun Oct 14, 3:40 pm)
Re: 2.6.23-mm1, Milan Broz, (Sun Oct 14, 6:03 pm)
Re: 2.6.23-mm1, Jens Axboe, (Mon Oct 15, 2:50 am)
Re: 2.6.23-mm1, Torsten Kaiser, (Sat Oct 13, 2:35 pm)
Re: 2.6.23-mm1, Torsten Kaiser, (Fri Oct 12, 8:46 am)
Re: 2.6.23-mm1, KAMEZAWA Hiroyuki, (Fri Oct 12, 3:25 am)
Re: 2.6.23-mm1, Sam Ravnborg, (Fri Oct 12, 4:36 am)
Re: 2.6.23-mm1, Al Viro, (Fri Oct 12, 2:46 am)
Re: 2.6.23-mm1, Andrew Morton, (Fri Oct 12, 3:13 am)
Re: 2.6.23-mm1 thread exit_group issue, Mathieu Desnoyers, (Fri Oct 12, 3:47 pm)
Re: 2.6.23-mm1 thread exit_group issue, Andrew Morton, (Fri Oct 12, 9:03 pm)
Re: 2.6.23-mm1 thread exit_group issue, Oleg Nesterov, (Sat Oct 13, 7:48 am)
Re: 2.6.23-mm1 thread exit_group issue, Mathieu Desnoyers, (Sun Oct 14, 12:04 am)
Re: 2.6.23-mm1 thread exit_group issue, Oleg Nesterov, (Sat Oct 13, 8:02 am)
Re: 2.6.23-mm1 thread exit_group issue, Andrew Morton, (Sat Oct 13, 1:49 pm)
Re: 2.6.23-mm1 thread exit_group issue, Andrew Morton, (Fri Oct 12, 4:01 pm)
Re: 2.6.23-mm1, Al Viro, (Fri Oct 12, 3:04 pm)
[PATCH net-2.6] uml: hard_header fix, Stephen Hemminger, (Fri Oct 12, 2:06 pm)
Build Failure (Was Re: 2.6.23-mm1), Dhaval Giani, (Fri Oct 12, 5:42 am)
[PATCH] add missing parenthesis in cfe_writeblk() macro, Mariusz Kozlowski, (Fri Oct 12, 2:51 am)
nfs mmap adventure (was: 2.6.23-mm1), Peter Zijlstra, (Mon Oct 15, 8:28 am)
Re: nfs mmap adventure (was: 2.6.23-mm1), David Howells, (Mon Oct 15, 10:06 am)
Re: nfs mmap adventure (was: 2.6.23-mm1), Nick Piggin, (Mon Oct 15, 9:46 pm)
Re: nfs mmap adventure (was: 2.6.23-mm1), David Howells, (Mon Oct 15, 7:27 pm)
Re: nfs mmap adventure (was: 2.6.23-mm1), Trond Myklebust, (Mon Oct 15, 11:51 am)
Re: nfs mmap adventure (was: 2.6.23-mm1), Peter Zijlstra, (Mon Oct 15, 12:38 pm)
Re: nfs mmap adventure (was: 2.6.23-mm1), Trond Myklebust, (Mon Oct 15, 11:43 am)