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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Miklos Szeredi <[email protected]>

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 <[email protected]>
---

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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux