[patch 5/9] fuse: fix setting i_mode bits

From: miklos
Date: Thu Aug 09 2007 - 05:28:54 EST


From: Miklos Szeredi <mszeredi@xxxxxxx>

The patch titled "fuse: fix permission checking on sticky directories"
removed all but the S_IFMT bits from i_mode.

However some of these are unfortunately used by the VFS, such as the
execute, suid and sgid bits.

So only remove the sticky bit, which is used for checking deletion
from a directory.

Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxx>
---

Index: linux/fs/fuse/inode.c
===================================================================
--- linux.orig/fs/fuse/inode.c 2007-08-09 11:01:55.000000000 +0200
+++ linux/fs/fuse/inode.c 2007-08-09 11:04:26.000000000 +0200
@@ -124,14 +124,7 @@ void fuse_change_attributes(struct inode
loff_t oldsize;

inode->i_ino = attr->ino;
- fi->orig_i_mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777);
- /*
- * Don't set the mode bits in i_mode, unless we want the VFS
- * to check permissions. This prevents failures due to the
- * sticky bit check in may_delete().
- */
- if (fc->flags & FUSE_DEFAULT_PERMISSIONS)
- inode->i_mode = fi->orig_i_mode;
+ inode->i_mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777);
inode->i_nlink = attr->nlink;
inode->i_uid = attr->uid;
inode->i_gid = attr->gid;
@@ -143,6 +136,15 @@ void fuse_change_attributes(struct inode
inode->i_ctime.tv_sec = attr->ctime;
inode->i_ctime.tv_nsec = attr->ctimensec;

+ /*
+ * Don't set the sticky bit in i_mode, unless we want the VFS
+ * to check permissions. This prevents failures due to the
+ * check in may_delete().
+ */
+ fi->orig_i_mode = inode->i_mode;
+ if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS))
+ inode->i_mode &= ~S_ISVTX;
+
spin_lock(&fc->lock);
oldsize = inode->i_size;
i_size_write(inode, attr->size);

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/