diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2016-05-27 11:06:05 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-05-27 20:09:16 -0400 |
| commit | 3767e255b390d72f9a33c08d9e86c5f21f25860f (patch) | |
| tree | 519dcbb61591a2ad94c36d3896e4787074e4813d /fs/ecryptfs | |
| parent | 5930122683dff58f0846b0f0405b4bd598a3ba6a (diff) | |
switch ->setxattr() to passing dentry and inode separately
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>
Diffstat (limited to 'fs/ecryptfs')
| -rw-r--r-- | fs/ecryptfs/crypto.c | 9 | ||||
| -rw-r--r-- | fs/ecryptfs/ecryptfs_kernel.h | 4 | ||||
| -rw-r--r-- | fs/ecryptfs/inode.c | 7 | ||||
| -rw-r--r-- | fs/ecryptfs/mmap.c | 3 |
4 files changed, 13 insertions, 10 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index ebd40f46ed4c..0d8eb3455b34 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
| @@ -1141,12 +1141,13 @@ ecryptfs_write_metadata_to_contents(struct inode *ecryptfs_inode, | |||
| 1141 | 1141 | ||
| 1142 | static int | 1142 | static int |
| 1143 | ecryptfs_write_metadata_to_xattr(struct dentry *ecryptfs_dentry, | 1143 | ecryptfs_write_metadata_to_xattr(struct dentry *ecryptfs_dentry, |
| 1144 | struct inode *ecryptfs_inode, | ||
| 1144 | char *page_virt, size_t size) | 1145 | char *page_virt, size_t size) |
| 1145 | { | 1146 | { |
| 1146 | int rc; | 1147 | int rc; |
| 1147 | 1148 | ||
| 1148 | rc = ecryptfs_setxattr(ecryptfs_dentry, ECRYPTFS_XATTR_NAME, page_virt, | 1149 | rc = ecryptfs_setxattr(ecryptfs_dentry, ecryptfs_inode, |
| 1149 | size, 0); | 1150 | ECRYPTFS_XATTR_NAME, page_virt, size, 0); |
| 1150 | return rc; | 1151 | return rc; |
| 1151 | } | 1152 | } |
| 1152 | 1153 | ||
| @@ -1215,8 +1216,8 @@ int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry, | |||
| 1215 | goto out_free; | 1216 | goto out_free; |
| 1216 | } | 1217 | } |
| 1217 | if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) | 1218 | if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) |
| 1218 | rc = ecryptfs_write_metadata_to_xattr(ecryptfs_dentry, virt, | 1219 | rc = ecryptfs_write_metadata_to_xattr(ecryptfs_dentry, ecryptfs_inode, |
| 1219 | size); | 1220 | virt, size); |
| 1220 | else | 1221 | else |
| 1221 | rc = ecryptfs_write_metadata_to_contents(ecryptfs_inode, virt, | 1222 | rc = ecryptfs_write_metadata_to_contents(ecryptfs_inode, virt, |
| 1222 | virt_len); | 1223 | virt_len); |
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index 3ec495db7e82..4ba1547bb9ad 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
| @@ -609,8 +609,8 @@ ssize_t | |||
| 609 | ecryptfs_getxattr_lower(struct dentry *lower_dentry, struct inode *lower_inode, | 609 | ecryptfs_getxattr_lower(struct dentry *lower_dentry, struct inode *lower_inode, |
| 610 | const char *name, void *value, size_t size); | 610 | const char *name, void *value, size_t size); |
| 611 | int | 611 | int |
| 612 | ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, | 612 | ecryptfs_setxattr(struct dentry *dentry, struct inode *inode, const char *name, |
| 613 | size_t size, int flags); | 613 | const void *value, size_t size, int flags); |
| 614 | int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode); | 614 | int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode); |
| 615 | #ifdef CONFIG_ECRYPT_FS_MESSAGING | 615 | #ifdef CONFIG_ECRYPT_FS_MESSAGING |
| 616 | int ecryptfs_process_response(struct ecryptfs_daemon *daemon, | 616 | int ecryptfs_process_response(struct ecryptfs_daemon *daemon, |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 318b04689d76..9d153b6a1d72 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
| @@ -1001,7 +1001,8 @@ static int ecryptfs_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
| 1001 | } | 1001 | } |
| 1002 | 1002 | ||
| 1003 | int | 1003 | int |
| 1004 | ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, | 1004 | ecryptfs_setxattr(struct dentry *dentry, struct inode *inode, |
| 1005 | const char *name, const void *value, | ||
| 1005 | size_t size, int flags) | 1006 | size_t size, int flags) |
| 1006 | { | 1007 | { |
| 1007 | int rc = 0; | 1008 | int rc = 0; |
| @@ -1014,8 +1015,8 @@ ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, | |||
| 1014 | } | 1015 | } |
| 1015 | 1016 | ||
| 1016 | rc = vfs_setxattr(lower_dentry, name, value, size, flags); | 1017 | rc = vfs_setxattr(lower_dentry, name, value, size, flags); |
| 1017 | if (!rc && d_really_is_positive(dentry)) | 1018 | if (!rc && inode) |
| 1018 | fsstack_copy_attr_all(d_inode(dentry), d_inode(lower_dentry)); | 1019 | fsstack_copy_attr_all(inode, d_inode(lower_dentry)); |
| 1019 | out: | 1020 | out: |
| 1020 | return rc; | 1021 | return rc; |
| 1021 | } | 1022 | } |
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index 148d11b514fb..9c3437c8a5b1 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c | |||
| @@ -442,7 +442,8 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode) | |||
| 442 | if (size < 0) | 442 | if (size < 0) |
| 443 | size = 8; | 443 | size = 8; |
| 444 | put_unaligned_be64(i_size_read(ecryptfs_inode), xattr_virt); | 444 | put_unaligned_be64(i_size_read(ecryptfs_inode), xattr_virt); |
| 445 | rc = lower_inode->i_op->setxattr(lower_dentry, ECRYPTFS_XATTR_NAME, | 445 | rc = lower_inode->i_op->setxattr(lower_dentry, lower_inode, |
| 446 | ECRYPTFS_XATTR_NAME, | ||
| 446 | xattr_virt, size, 0); | 447 | xattr_virt, size, 0); |
| 447 | inode_unlock(lower_inode); | 448 | inode_unlock(lower_inode); |
| 448 | if (rc) | 449 | if (rc) |
