RAMFS NOMMU: missed POSIX UID/GID inode attribute checking
authorBryan Wu <bryan.wu@analog.com>
Tue, 5 Jun 2007 03:02:01 +0000 (11:02 +0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Fri, 8 Jun 2007 00:11:13 +0000 (17:11 -0700)
This bug was caught by LTP testcase fchmod06 on Blackfin platform.

In the manpage of fchmod, "EPERM: The effective UID does not match the
owner of the file, and the process is not privileged (Linux: it does not
have the CAP_FOWNER capability)."

But the ramfs nommu code missed the inode_change_ok POSIX UID/GID
verification. This patch fixed this.

Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ramfs/file-nommu.c

index 9345a46ffb325f3dda57a0aeb048e3428475ad0c..5d258c40a2fd9c59fead95c4d3d84d7a4092bce3 100644 (file)
@@ -195,6 +195,11 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia)
        unsigned int old_ia_valid = ia->ia_valid;
        int ret = 0;
 
        unsigned int old_ia_valid = ia->ia_valid;
        int ret = 0;
 
+       /* POSIX UID/GID verification for setting inode attributes */
+       ret = inode_change_ok(inode, ia);
+       if (ret)
+               return ret;
+
        /* by providing our own setattr() method, we skip this quotaism */
        if ((old_ia_valid & ATTR_UID && ia->ia_uid != inode->i_uid) ||
            (old_ia_valid & ATTR_GID && ia->ia_gid != inode->i_gid))
        /* by providing our own setattr() method, we skip this quotaism */
        if ((old_ia_valid & ATTR_UID && ia->ia_uid != inode->i_uid) ||
            (old_ia_valid & ATTR_GID && ia->ia_gid != inode->i_gid))