ext4: ea_inode owner should be the same as the inode owner
authorTahsin Erdogan <tahsin@google.com>
Thu, 22 Jun 2017 01:27:00 +0000 (21:27 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 22 Jun 2017 01:27:00 +0000 (21:27 -0400)
Quota charging is based on the ownership of the inode. Currently, the
xattr inode owner is set to the caller which may be different from the
parent inode owner. This is inconsistent with how quota is charged for
xattr block and regular data block writes.

Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/xattr.c

index 0b77ab944c3faaee65c6d3ca3e2726d0c9b97f5c..a29e68293d592bf0b0383388a05589d6432607fa 100644 (file)
@@ -824,6 +824,7 @@ static struct inode *ext4_xattr_inode_create(handle_t *handle,
                                             struct inode *inode)
 {
        struct inode *ea_inode = NULL;
+       uid_t owner[2] = { i_uid_read(inode), i_gid_read(inode) };
        int err;
 
        /*
@@ -831,7 +832,7 @@ static struct inode *ext4_xattr_inode_create(handle_t *handle,
         * in the same group, or nearby one.
         */
        ea_inode = ext4_new_inode(handle, inode->i_sb->s_root->d_inode,
-                                 S_IFREG | 0600, NULL, inode->i_ino + 1, NULL,
+                                 S_IFREG | 0600, NULL, inode->i_ino + 1, owner,
                                  EXT4_EA_INODE_FL);
        if (!IS_ERR(ea_inode)) {
                ea_inode->i_op = &ext4_file_inode_operations;