Unionfs: fix unionfs_setattr to handle ATTR_KILL_S*ID
authorJeff Layton <jlayton@redhat.com>
Fri, 19 Oct 2007 04:44:00 +0000 (00:44 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 12 Aug 2011 02:36:39 +0000 (22:36 -0400)
Don't allow unionfs_setattr to trip the BUG() in notify_change. Clear
ATTR_MODE if the either ATTR_KILL_S*ID is set. This also allows the
lower filesystem to interpret these bits in its own way.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Cc: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/inode.c

index 4e59ace59b759dd07283e27e98daf60f5773f1f9..6ca52f4863f0399b24c5f98133ba0b13dd6e9596 100644 (file)
@@ -1048,6 +1048,13 @@ static int unionfs_setattr(struct dentry *dentry, struct iattr *ia)
        bend = dbend(dentry);
        inode = dentry->d_inode;
 
+       /*
+        * mode change is for clearing setuid/setgid. Allow lower filesystem
+        * to reinterpret it in its own way.
+        */
+       if (ia->ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))
+               ia->ia_valid &= ~ATTR_MODE;
+
        for (bindex = bstart; (bindex <= bend) || (bindex == bstart);
             bindex++) {
                lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);