switch ->setxattr() to passing dentry and inode separately
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 27 May 2016 15:06:05 +0000 (11:06 -0400)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 29 Jan 2019 02:25:42 +0000 (11:25 +0900)
commit 3767e255b390d72f9a33c08d9e86c5f21f25860f upstream.

smack ->d_instantiate() uses ->setxattr(), so to be able to call it before
we'd hashed the new dentry and attached it to inode, we need ->setxattr()
instances getting the inode as an explicit argument rather than obtaining
it from dentry.

Similar change for ->getxattr() had been done in commit ce23e64.  Unlike
->getxattr() (which is used by both selinux and smack instances of
->d_instantiate()) ->setxattr() is used only by smack one and unfortunately
it got missed back then.

Reported-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Tested-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
[sw0312.kim: backport from mainline to resolve setxattr crash on smack]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I4bf991924e16f61746453b7fd096e5d59438659b

32 files changed:
Documentation/filesystems/porting
drivers/staging/lustre/lustre/llite/llite_internal.h
drivers/staging/lustre/lustre/llite/xattr.c
fs/bad_inode.c
fs/btrfs/xattr.c
fs/btrfs/xattr.h
fs/ceph/super.h
fs/ceph/xattr.c
fs/cifs/cifsfs.h
fs/cifs/xattr.c
fs/ecryptfs/crypto.c
fs/ecryptfs/ecryptfs_kernel.h
fs/ecryptfs/inode.c
fs/ecryptfs/mmap.c
fs/fuse/dir.c
fs/gfs2/inode.c
fs/hfs/attr.c
fs/hfs/hfs_fs.h
fs/jfs/jfs_xattr.h
fs/jfs/xattr.c
fs/kernfs/inode.c
fs/kernfs/kernfs-internal.h
fs/libfs.c
fs/overlayfs/inode.c
fs/overlayfs/overlayfs.h
fs/ubifs/ubifs.h
fs/ubifs/xattr.c
fs/xattr.c
include/linux/fs.h
include/linux/xattr.h
mm/shmem.c
security/smack/smack_lsm.c

index d5f6834ed51ac9bffe7018f2d8da94dd045378ef..59d6fe34b3c0a9c84e1c76bdeb609f4be73f588d 100644 (file)
@@ -510,3 +510,10 @@ in your dentry operations instead.
        dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
        in the instances.  Rationale: !@#!@# security_d_instantiate() needs to be
        called before we attach dentry to inode.
+--
+[mandatory]
+       ->setxattr() and xattr_handler.set() get dentry and inode passed separately.
+       dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
+       in the instances.  Rationale: !@#!@# security_d_instantiate() needs to be
+       called before we attach dentry to inode and !@#!@##!@$!$#!@#$!@$!@$ smack
+       ->d_instantiate() uses not just ->getxattr() but ->setxattr() as well.
index c350b01feab71883f2c86ad30ac7e515a3a074e9..f5df05b2520ba6ad22be699c1f944e6438ebb26c 100644 (file)
@@ -1030,8 +1030,8 @@ static inline __u64 ll_file_maxbytes(struct inode *inode)
 }
 
 /* llite/xattr.c */
-int ll_setxattr(struct dentry *dentry, const char *name,
-               const void *value, size_t size, int flags);
+int ll_setxattr(struct dentry *dentry, struct inode *inode,
+               const char *name, const void *value, size_t size, int flags);
 ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode,
                    const char *name, void *buffer, size_t size);
 ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size);
index 8102740d39e46b443d7e841b789b3cc8979f0743..798a2e982c2e428d52feed01c459db7984dbe068 100644 (file)
@@ -209,11 +209,9 @@ int ll_setxattr_common(struct inode *inode, const char *name,
        return 0;
 }
 
-int ll_setxattr(struct dentry *dentry, const char *name,
-               const void *value, size_t size, int flags)
+int ll_setxattr(struct dentry *dentry, struct inode *inode,
+               const char *name, const void *value, size_t size, int flags)
 {
-       struct inode *inode = d_inode(dentry);
-
        LASSERT(inode);
        LASSERT(name);
 
index 86df8d475d1fd3f65046d5ad51abff2e09652c74..39e5ba4232bdf66d1a60ca691c03dcb80d719f1f 100644 (file)
@@ -100,8 +100,8 @@ static int bad_inode_setattr(struct dentry *direntry, struct iattr *attrs)
        return -EIO;
 }
 
-static int bad_inode_setxattr(struct dentry *dentry, const char *name,
-               const void *value, size_t size, int flags)
+static int bad_inode_setxattr(struct dentry *dentry, struct inode *inode,
+               const char *name, const void *value, size_t size, int flags)
 {
        return -EIO;
 }
index a58622a2130b4224f0765770fce953fc14a8a033..7e2217a19fa21efdf90b55fd862764429ec5a23d 100644 (file)
@@ -416,10 +416,11 @@ ssize_t btrfs_getxattr(struct dentry *dentry, struct inode *inode,
        return __btrfs_getxattr(inode, name, buffer, size);
 }
 
-int btrfs_setxattr(struct dentry *dentry, const char *name, const void *value,
+int btrfs_setxattr(struct dentry *dentry, struct inode *inode,
+                  const char *name, const void *value,
                   size_t size, int flags)
 {
-       struct btrfs_root *root = BTRFS_I(d_inode(dentry))->root;
+       struct btrfs_root *root = BTRFS_I(inode)->root;
        int ret;
 
        /*
@@ -435,20 +436,21 @@ int btrfs_setxattr(struct dentry *dentry, const char *name, const void *value,
         * for it via sb->s_xattr.
         */
        if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
-               return generic_setxattr(dentry, name, value, size, flags);
+               return generic_setxattr(dentry, inode, name, value,
+                                       size, flags);
 
        ret = btrfs_is_valid_xattr(name);
        if (ret)
                return ret;
 
        if (!strncmp(name, XATTR_BTRFS_PREFIX, XATTR_BTRFS_PREFIX_LEN))
-               return btrfs_set_prop(d_inode(dentry), name,
+               return btrfs_set_prop(inode, name,
                                      value, size, flags);
 
        if (size == 0)
                value = "";  /* empty EA, do not remove */
 
-       return __btrfs_setxattr(NULL, d_inode(dentry), name, value, size,
+       return __btrfs_setxattr(NULL, inode, name, value, size,
                                flags);
 }
 
index 8ee432942e326df62b5956eeb3b41e7763ecb4c3..bbd23f3ce4565d5c6e26e6cdc99044079c07330e 100644 (file)
@@ -30,8 +30,9 @@ extern int __btrfs_setxattr(struct btrfs_trans_handle *trans,
                            const void *value, size_t size, int flags);
 extern ssize_t btrfs_getxattr(struct dentry *dentry, struct inode *inode,
                              const char *name, void *buffer, size_t size);
-extern int btrfs_setxattr(struct dentry *dentry, const char *name,
-               const void *value, size_t size, int flags);
+extern int btrfs_setxattr(struct dentry *dentry, struct inode *inode,
+                         const char *name, const void *value,
+                         size_t size, int flags);
 extern int btrfs_removexattr(struct dentry *dentry, const char *name);
 
 extern int btrfs_xattr_security_init(struct btrfs_trans_handle *trans,
index 2793ae2c0ff6389c0d1a3e904b8c8d2b09295f36..1ae16fee9bf9cf7c6d2830d0b07c01390e636b82 100644 (file)
@@ -794,8 +794,8 @@ extern int ceph_getattr(struct vfsmount *mnt, struct dentry *dentry,
                        struct kstat *stat);
 
 /* xattr.c */
-extern int ceph_setxattr(struct dentry *, const char *, const void *,
-                        size_t, int);
+extern int ceph_setxattr(struct dentry *, struct inode *, const char *,
+                        const void *, size_t, int);
 int __ceph_setxattr(struct dentry *, const char *, const void *, size_t, int);
 ssize_t __ceph_getxattr(struct inode *, const char *, void *, size_t);
 int __ceph_removexattr(struct dentry *, const char *);
index 4e4d0b7df85a3486be41c93f616ab40002d0c10e..bd79a77f9a157ebfc2c10d9b1f7a12d677e9a0a8 100644 (file)
@@ -1027,14 +1027,15 @@ out:
        return err;
 }
 
-int ceph_setxattr(struct dentry *dentry, const char *name,
+int ceph_setxattr(struct dentry *dentry, struct inode *inode, const char *name,
                  const void *value, size_t size, int flags)
 {
-       if (ceph_snap(d_inode(dentry)) != CEPH_NOSNAP)
+       if (ceph_snap(inode) != CEPH_NOSNAP)
                return -EROFS;
 
        if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
-               return generic_setxattr(dentry, name, value, size, flags);
+               return generic_setxattr(dentry, inode, name, value, size,
+                                       flags);
 
        if (size == 0)
                value = "";  /* empty EA, do not remove */
index 39c380cd0b90e732dd32a41ee506573205f484ed..fbe5f88d6e68271f9ee050f6f20af61f603ca2ba 100644 (file)
@@ -122,8 +122,8 @@ extern int cifs_readlink(struct dentry *direntry, char __user *buffer,
 extern int cifs_symlink(struct inode *inode, struct dentry *direntry,
                        const char *symname);
 extern int     cifs_removexattr(struct dentry *, const char *);
-extern int     cifs_setxattr(struct dentry *, const char *, const void *,
-                       size_t, int);
+extern int     cifs_setxattr(struct dentry *, struct inode *, const char *,
+                       const void *, size_t, int);
 extern ssize_t cifs_getxattr(struct dentry *, struct inode *, const char *, void *, size_t);
 extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
 extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
index 0de08cd2e56141ef793b388fdfbc0ddbd18f7942..87355a763932afcab69cfdf4206a25a0a5901e20 100644 (file)
@@ -97,8 +97,9 @@ remove_ea_exit:
        return rc;
 }
 
-int cifs_setxattr(struct dentry *direntry, const char *ea_name,
-                 const void *ea_value, size_t value_size, int flags)
+int cifs_setxattr(struct dentry *direntry, struct inode *inode,
+                 const char *ea_name, const void *ea_value, size_t value_size,
+                 int flags)
 {
        int rc = -EOPNOTSUPP;
 #ifdef CONFIG_CIFS_XATTR
@@ -113,7 +114,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
                return -EIO;
        if (d_really_is_negative(direntry))
                return -EIO;
-       sb = d_inode(direntry)->i_sb;
+       sb = inode->i_sb;
        if (sb == NULL)
                return -EIO;
 
@@ -177,12 +178,12 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
                        memcpy(pacl, ea_value, value_size);
                        if (pTcon->ses->server->ops->set_acl)
                                rc = pTcon->ses->server->ops->set_acl(pacl,
-                                               value_size, d_inode(direntry),
+                                               value_size, inode,
                                                full_path, CIFS_ACL_DACL);
                        else
                                rc = -EOPNOTSUPP;
                        if (rc == 0) /* force revalidate of the inode */
-                               CIFS_I(d_inode(direntry))->time = 0;
+                               CIFS_I(inode)->time = 0;
                        kfree(pacl);
                }
 #else
index 81701fdedbebef6d2d0345b1eacf17afb9a2b51e..78c8b6a24968cf0f6755e5f5bc9ea74dac1d3bbe 100644 (file)
@@ -1148,12 +1148,13 @@ ecryptfs_write_metadata_to_contents(struct inode *ecryptfs_inode,
 
 static int
 ecryptfs_write_metadata_to_xattr(struct dentry *ecryptfs_dentry,
+                                struct inode *ecryptfs_inode,
                                 char *page_virt, size_t size)
 {
        int rc;
 
-       rc = ecryptfs_setxattr(ecryptfs_dentry, ECRYPTFS_XATTR_NAME, page_virt,
-                              size, 0);
+       rc = ecryptfs_setxattr(ecryptfs_dentry, ecryptfs_inode,
+                              ECRYPTFS_XATTR_NAME, page_virt, size, 0);
        return rc;
 }
 
@@ -1222,8 +1223,8 @@ int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry,
                goto out_free;
        }
        if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR)
-               rc = ecryptfs_write_metadata_to_xattr(ecryptfs_dentry, virt,
-                                                     size);
+               rc = ecryptfs_write_metadata_to_xattr(ecryptfs_dentry, ecryptfs_inode,
+                                                     virt, size);
        else
                rc = ecryptfs_write_metadata_to_contents(ecryptfs_inode, virt,
                                                         virt_len);
index 7d2e3933ec92aa243df1fe2c7a102d60d4a0d3d1..990899934d161296b657d9134edb9e3892de7996 100644 (file)
@@ -621,8 +621,8 @@ ssize_t
 ecryptfs_getxattr_lower(struct dentry *lower_dentry, struct inode *lower_inode,
                        const char *name, void *value, size_t size);
 int
-ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
-                 size_t size, int flags);
+ecryptfs_setxattr(struct dentry *dentry, struct inode *inode, const char *name,
+                 const void *value, size_t size, int flags);
 int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode);
 #ifdef CONFIG_ECRYPT_FS_MESSAGING
 int ecryptfs_process_response(struct ecryptfs_daemon *daemon,
index 6447a9d61ab866e58b111c82297982cb0c5d7868..63af5973eb2a4a367d9cbeddd7594e7b529b2ff1 100644 (file)
@@ -1012,7 +1012,8 @@ static int ecryptfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
 }
 
 int
-ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
+ecryptfs_setxattr(struct dentry *dentry, struct inode *inode,
+                 const char *name, const void *value,
                  size_t size, int flags)
 {
        int rc = 0;
@@ -1025,8 +1026,8 @@ ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
        }
 
        rc = vfs_setxattr(lower_dentry, name, value, size, flags);
-       if (!rc && d_really_is_positive(dentry))
-               fsstack_copy_attr_all(d_inode(dentry), d_inode(lower_dentry));
+       if (!rc && inode)
+               fsstack_copy_attr_all(inode, d_inode(lower_dentry));
 out:
        return rc;
 }
index f8863df50ff7fa89bb77a3444c8c8ba20dd52633..0bc6bfb043e7a2f8eaf004e46b1e74ef16ae7a68 100644 (file)
@@ -443,7 +443,8 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode)
        if (size < 0)
                size = 8;
        put_unaligned_be64(i_size_read(ecryptfs_inode), xattr_virt);
-       rc = lower_inode->i_op->setxattr(lower_dentry, ECRYPTFS_XATTR_NAME,
+       rc = lower_inode->i_op->setxattr(lower_dentry, lower_inode,
+                                        ECRYPTFS_XATTR_NAME,
                                         xattr_virt, size, 0);
        mutex_unlock(&lower_inode->i_mutex);
        if (rc)
index 8c6ad17285fd3960023bea0b31d8461eee093e49..52ac50ce1636146970e7bfc609f6bf6a09214290 100644 (file)
@@ -1763,10 +1763,10 @@ static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry,
        return fuse_update_attributes(inode, stat, NULL, NULL);
 }
 
-static int fuse_setxattr(struct dentry *entry, const char *name,
-                        const void *value, size_t size, int flags)
+static int fuse_setxattr(struct dentry *unused, struct inode *inode,
+                        const char *name, const void *value,
+                        size_t size, int flags)
 {
-       struct inode *inode = d_inode(entry);
        struct fuse_conn *fc = get_fuse_conn(inode);
        FUSE_ARGS(args);
        struct fuse_setxattr_in inarg;
index eefef81ae3bad580c14aff3a7affc3453c0cb430..3e7eb1fa83acb46b864e94e0b8144ec0381c4dab 100644 (file)
@@ -1991,10 +1991,10 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
        return 0;
 }
 
-static int gfs2_setxattr(struct dentry *dentry, const char *name,
-                        const void *data, size_t size, int flags)
+static int gfs2_setxattr(struct dentry *dentry, struct inode *inode,
+                        const char *name, const void *data,
+                        size_t size, int flags)
 {
-       struct inode *inode = d_inode(dentry);
        struct gfs2_inode *ip = GFS2_I(inode);
        struct gfs2_holder gh;
        int ret;
@@ -2004,7 +2004,8 @@ static int gfs2_setxattr(struct dentry *dentry, const char *name,
        if (ret == 0) {
                ret = gfs2_rs_alloc(ip);
                if (ret == 0)
-                       ret = generic_setxattr(dentry, name, data, size, flags);
+                       ret = generic_setxattr(dentry, inode, name, data, size,
+                                              flags);
                gfs2_glock_dq(&gh);
        }
        gfs2_holder_uninit(&gh);
index 064f92f17efc8c1a1f7110e1986bced67911700f..d9a86919fdf6e9d371b7d01d048acf100f0cc0a6 100644 (file)
 #include "hfs_fs.h"
 #include "btree.h"
 
-int hfs_setxattr(struct dentry *dentry, const char *name,
-                const void *value, size_t size, int flags)
+int hfs_setxattr(struct dentry *unused, struct inode *inode,
+                const char *name, const void *value,
+                size_t size, int flags)
 {
-       struct inode *inode = d_inode(dentry);
        struct hfs_find_data fd;
        hfs_cat_rec rec;
        struct hfs_cat_file *file;
index 79daa097929a58510b2c4e8a3745cbe267777e8c..cacf761a782c5ef7f47396a42e62d04f82916881 100644 (file)
@@ -211,7 +211,7 @@ extern void hfs_evict_inode(struct inode *);
 extern void hfs_delete_inode(struct inode *);
 
 /* attr.c */
-extern int hfs_setxattr(struct dentry *dentry, const char *name,
+extern int hfs_setxattr(struct dentry *dentry, struct inode *inode, const char *name,
                        const void *value, size_t size, int flags);
 extern ssize_t hfs_getxattr(struct dentry *dentry, struct inode *inode,
                            const char *name, void *value, size_t size);
index e69e14f3777b3e7957a1692e604d8a563d0b3204..01c47b165313fc0c978570acddb8948c5824aeeb 100644 (file)
@@ -54,8 +54,8 @@ struct jfs_ea_list {
 
 extern int __jfs_setxattr(tid_t, struct inode *, const char *, const void *,
                          size_t, int);
-extern int jfs_setxattr(struct dentry *, const char *, const void *, size_t,
-                       int);
+extern int jfs_setxattr(struct dentry *, struct inode *, const char *,
+                       const void *, size_t, int);
 extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t);
 extern ssize_t jfs_getxattr(struct dentry *, struct inode *, const char *, void *, size_t);
 extern ssize_t jfs_listxattr(struct dentry *, char *, size_t);
index 77e6c1a5377bb1387959a57b5f1499841fc6e565..edfba219be941ceca6bb2155cd168f218adad00a 100644 (file)
@@ -848,10 +848,9 @@ int __jfs_setxattr(tid_t tid, struct inode *inode, const char *name,
        return rc;
 }
 
-int jfs_setxattr(struct dentry *dentry, const char *name, const void *value,
-                size_t value_len, int flags)
+int jfs_setxattr(struct dentry *dentry, struct inode *inode,  const char *name,
+                const void *value, size_t value_len, int flags)
 {
-       struct inode *inode = d_inode(dentry);
        struct jfs_inode_info *ji = JFS_IP(inode);
        int rc;
        tid_t tid;
@@ -862,7 +861,8 @@ int jfs_setxattr(struct dentry *dentry, const char *name, const void *value,
         * for it via sb->s_xattr.
         */
        if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
-               return generic_setxattr(dentry, name, value, value_len, flags);
+               return generic_setxattr(dentry, inode, name, value, value_len,
+                                       flags);
 
        if ((rc = can_set_xattr(inode, name, value, value_len)))
                return rc;
@@ -874,7 +874,7 @@ int jfs_setxattr(struct dentry *dentry, const char *name, const void *value,
 
        tid = txBegin(inode->i_sb, 0);
        mutex_lock(&ji->commit_mutex);
-       rc = __jfs_setxattr(tid, d_inode(dentry), name, value, value_len,
+       rc = __jfs_setxattr(tid, inode, name, value, value_len,
                            flags);
        if (!rc)
                rc = txCommit(tid, 1, &inode, 0);
index 4c643c128c22f6789ec805922bacc31878e6b25a..664d06339bc9d596446c9c9049c8c1f2da49c91b 100644 (file)
@@ -157,10 +157,11 @@ static int kernfs_node_setsecdata(struct kernfs_node *kn, void **secdata,
        return 0;
 }
 
-int kernfs_iop_setxattr(struct dentry *dentry, const char *name,
-                       const void *value, size_t size, int flags)
+int kernfs_iop_setxattr(struct dentry *unused, struct inode *inode,
+                       const char *name, const void *value,
+                       size_t size, int flags)
 {
-       struct kernfs_node *kn = dentry->d_fsdata;
+       struct kernfs_node *kn = inode->i_private;
        struct kernfs_iattrs *attrs;
        void *secdata;
        int error;
@@ -172,11 +173,11 @@ int kernfs_iop_setxattr(struct dentry *dentry, const char *name,
 
        if (!strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN)) {
                const char *suffix = name + XATTR_SECURITY_PREFIX_LEN;
-               error = security_inode_setsecurity(d_inode(dentry), suffix,
+               error = security_inode_setsecurity(inode, suffix,
                                                value, size, flags);
                if (error)
                        return error;
-               error = security_inode_getsecctx(d_inode(dentry),
+               error = security_inode_getsecctx(inode,
                                                &secdata, &secdata_len);
                if (error)
                        return error;
index 45c9192c276e4544621dc393da03d76b088d86f3..37159235ac10969db99278598724adfedda23889 100644 (file)
@@ -81,7 +81,8 @@ int kernfs_iop_permission(struct inode *inode, int mask);
 int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr);
 int kernfs_iop_getattr(struct vfsmount *mnt, struct dentry *dentry,
                       struct kstat *stat);
-int kernfs_iop_setxattr(struct dentry *dentry, const char *name, const void *value,
+int kernfs_iop_setxattr(struct dentry *dentry, struct inode *inode,
+                       const char *name, const void *value,
                        size_t size, int flags);
 int kernfs_iop_removexattr(struct dentry *dentry, const char *name);
 ssize_t kernfs_iop_getxattr(struct dentry *dentry, struct inode *inode,
index 18804a8ea5cadb858dc158f81c0867ee76a17d3e..59ac04b542a32bd1cdf1828d674b0c563e87fa44 100644 (file)
@@ -1125,8 +1125,9 @@ static int empty_dir_setattr(struct dentry *dentry, struct iattr *attr)
        return -EPERM;
 }
 
-static int empty_dir_setxattr(struct dentry *dentry, const char *name,
-                             const void *value, size_t size, int flags)
+static int empty_dir_setxattr(struct dentry *dentry, struct inode *inode,
+                             const char *name, const void *value,
+                             size_t size, int flags)
 {
        return -EOPNOTSUPP;
 }
index e3a0dafdf9ac7471fcb0945ce1e121db2143feaf..4809a9c940dbe0670f2ecdb067d60ab9862376e4 100644 (file)
@@ -224,8 +224,9 @@ bool ovl_is_private_xattr(const char *name)
        return strncmp(name, OVL_XATTR_PRE_NAME, OVL_XATTR_PRE_LEN) == 0;
 }
 
-int ovl_setxattr(struct dentry *dentry, const char *name,
-                const void *value, size_t size, int flags)
+int ovl_setxattr(struct dentry *dentry, struct inode *inode,
+                const char *name, const void *value,
+                size_t size, int flags)
 {
        int err;
        struct dentry *upperdentry;
index 837b7dc80cc5c9d2e0f201e31d24ae594e978ef8..d03618d209552cf7cfd9f2a7b275dab0ace9486a 100644 (file)
@@ -171,8 +171,9 @@ void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt,
 /* inode.c */
 int ovl_setattr(struct dentry *dentry, struct iattr *attr);
 int ovl_permission(struct inode *inode, int mask);
-int ovl_setxattr(struct dentry *dentry, const char *name,
-                const void *value, size_t size, int flags);
+int ovl_setxattr(struct dentry *dentry, struct inode *inode,
+                const char *name, const void *value,
+                size_t size, int flags);
 ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode,
                     const char *name, void *value, size_t size);
 ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
index f2115158214f24ea2a56ecac9d90b5bae3d7d0e6..bf2fc8622b2959e12b96fe72097ef0f6c97f6756 100644 (file)
@@ -1756,7 +1756,7 @@ int ubifs_getattr(struct vfsmount *mnt, struct dentry *dentry,
                  struct kstat *stat);
 
 /* xattr.c */
-int ubifs_setxattr(struct dentry *dentry, const char *name,
+int ubifs_setxattr(struct dentry *dentry, struct inode *inode, const char *name,
                   const void *value, size_t size, int flags);
 ssize_t ubifs_getxattr(struct dentry *dentry, struct inode *host,
                       const char *name, void *buf, size_t size);
index c2f0e5735a400b5686aa4234beb3203f8f525826..55af1868751c10e78917d0b02f0591670d797abe 100644 (file)
@@ -365,13 +365,13 @@ out_free:
        return err;
 }
 
-int ubifs_setxattr(struct dentry *dentry, const char *name,
+int ubifs_setxattr(struct dentry *dentry, struct inode *inode, const char *name,
                   const void *value, size_t size, int flags)
 {
        dbg_gen("xattr '%s', host ino %lu ('%pd'), size %zd",
-               name, d_inode(dentry)->i_ino, dentry, size);
+               name, inode->i_ino, dentry, size);
 
-       return setxattr(d_inode(dentry), name, value, size, flags);
+       return setxattr(inode, name, value, size, flags);
 }
 
 ssize_t ubifs_getxattr(struct dentry *dentry, struct inode *host,
index 87b67a010b6cbf2c6962957a4d2f2750c9e3d1f4..916b04dc44c202552d3ec01bb09743a592094a8b 100644 (file)
@@ -100,7 +100,7 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const char *name,
        if (issec)
                inode->i_flags &= ~S_NOSEC;
        if (inode->i_op->setxattr) {
-               error = inode->i_op->setxattr(dentry, name, value, size, flags);
+               error = inode->i_op->setxattr(dentry, inode, name, value, size, flags);
                if (!error) {
                        fsnotify_xattr(dentry);
                        security_inode_post_setxattr(dentry, name, value,
@@ -760,7 +760,8 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
  * Find the handler for the prefix and dispatch its set() operation.
  */
 int
-generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags)
+generic_setxattr(struct dentry *dentry, struct inode *inode, const char *name,
+                const void *value, size_t size, int flags)
 {
        const struct xattr_handler *handler;
 
@@ -769,8 +770,7 @@ generic_setxattr(struct dentry *dentry, const char *name, const void *value, siz
        handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
        if (!handler)
                return -EOPNOTSUPP;
-       return handler->set(handler, dentry, d_inode(dentry), name, value,
-                           size, flags);
+       return handler->set(handler, dentry, inode, name, value, size, flags);
 }
 
 /*
index 34d63032bfb7053d444ca95cb1408c7defa9fb19..fd84a6cb124f2ee91fc7351ded68baa05e513068 100644 (file)
@@ -1697,7 +1697,8 @@ struct inode_operations {
                        struct inode *, struct dentry *, unsigned int);
        int (*setattr) (struct dentry *, struct iattr *);
        int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
-       int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
+       int (*setxattr) (struct dentry *, struct inode *,
+                        const char *, const void *, size_t, int);
        ssize_t (*getxattr) (struct dentry *, struct inode *,
                             const char *, void *, size_t);
        ssize_t (*listxattr) (struct dentry *, char *, size_t);
index 042b2a3954a1bc2b10fac43178503e8aa1654347..5ea6d734439437d759b6dc5fc17c5bbb2da81787 100644 (file)
@@ -50,7 +50,8 @@ int vfs_removexattr(struct dentry *, const char *);
 
 ssize_t generic_getxattr(struct dentry *dentry, struct inode *inode, const char *name, void *buffer, size_t size);
 ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
-int generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags);
+int generic_setxattr(struct dentry *dentry, struct inode *inode,
+                    const char *name, const void *value, size_t size, int flags);
 int generic_removexattr(struct dentry *dentry, const char *name);
 ssize_t vfs_getxattr_alloc(struct dentry *dentry, const char *name,
                           char **xattr_value, size_t size, gfp_t flags);
index f03c71f268bb8592d0c8ee39261fe6b4fe69e294..b6e188c0742646af45b30fd9068722b58446ea89 100644 (file)
@@ -2603,10 +2603,11 @@ static ssize_t shmem_getxattr(struct dentry *dentry, struct inode *inode,
        return simple_xattr_get(&info->xattrs, name, buffer, size);
 }
 
-static int shmem_setxattr(struct dentry *dentry, const char *name,
-                         const void *value, size_t size, int flags)
+static int shmem_setxattr(struct dentry *dentry, struct inode *inode,
+                         const char *name, const void *value, size_t size,
+                         int flags)
 {
-       struct shmem_inode_info *info = SHMEM_I(d_inode(dentry));
+       struct shmem_inode_info *info = SHMEM_I(inode);
        int err;
 
        /*
@@ -2615,7 +2616,8 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
         * for it via sb->s_xattr.
         */
        if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
-               return generic_setxattr(dentry, name, value, size, flags);
+               return generic_setxattr(dentry, inode, name, value, size,
+                                       flags);
 
        err = shmem_xattr_validate(name);
        if (err)
index 9d55924f72883cc6c306075a53aa2bf508f0ddca..e75a5126acaef3354ab4e2de03d89c5fce1615ed 100644 (file)
@@ -3536,7 +3536,7 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
                         */
                        if (isp->smk_flags & SMK_INODE_CHANGED) {
                                isp->smk_flags &= ~SMK_INODE_CHANGED;
-                               rc = inode->i_op->setxattr(dp,
+                               rc = inode->i_op->setxattr(dp, inode,
                                        XATTR_NAME_SMACKTRANSMUTE,
                                        TRANS_TRUE, TRANS_TRUE_SIZE,
                                        0);