diff options
| -rw-r--r-- | fs/ubifs/crypto.c | 7 | ||||
| -rw-r--r-- | fs/ubifs/ubifs.h | 2 | ||||
| -rw-r--r-- | fs/ubifs/xattr.c | 17 |
3 files changed, 15 insertions, 11 deletions
diff --git a/fs/ubifs/crypto.c b/fs/ubifs/crypto.c index 382ed428cfd2..114ba455bac3 100644 --- a/fs/ubifs/crypto.c +++ b/fs/ubifs/crypto.c | |||
| @@ -9,8 +9,13 @@ static int ubifs_crypt_get_context(struct inode *inode, void *ctx, size_t len) | |||
| 9 | static int ubifs_crypt_set_context(struct inode *inode, const void *ctx, | 9 | static int ubifs_crypt_set_context(struct inode *inode, const void *ctx, |
| 10 | size_t len, void *fs_data) | 10 | size_t len, void *fs_data) |
| 11 | { | 11 | { |
| 12 | /* | ||
| 13 | * Creating an encryption context is done unlocked since we | ||
| 14 | * operate on a new inode which is not visible to other users | ||
| 15 | * at this point. So, no need to check whether inode is locked. | ||
| 16 | */ | ||
| 12 | return ubifs_xattr_set(inode, UBIFS_XATTR_NAME_ENCRYPTION_CONTEXT, | 17 | return ubifs_xattr_set(inode, UBIFS_XATTR_NAME_ENCRYPTION_CONTEXT, |
| 13 | ctx, len, 0); | 18 | ctx, len, 0, false); |
| 14 | } | 19 | } |
| 15 | 20 | ||
| 16 | static bool ubifs_crypt_empty_dir(struct inode *inode) | 21 | static bool ubifs_crypt_empty_dir(struct inode *inode) |
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index d933edade14a..cd43651f1731 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
| @@ -1755,7 +1755,7 @@ int ubifs_check_dir_empty(struct inode *dir); | |||
| 1755 | extern const struct xattr_handler *ubifs_xattr_handlers[]; | 1755 | extern const struct xattr_handler *ubifs_xattr_handlers[]; |
| 1756 | ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size); | 1756 | ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size); |
| 1757 | int ubifs_xattr_set(struct inode *host, const char *name, const void *value, | 1757 | int ubifs_xattr_set(struct inode *host, const char *name, const void *value, |
| 1758 | size_t size, int flags); | 1758 | size_t size, int flags, bool check_lock); |
| 1759 | ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf, | 1759 | ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf, |
| 1760 | size_t size); | 1760 | size_t size); |
| 1761 | void ubifs_evict_xattr_inode(struct ubifs_info *c, ino_t xattr_inum); | 1761 | void ubifs_evict_xattr_inode(struct ubifs_info *c, ino_t xattr_inum); |
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c index 98f11257d66c..c13eae819cbc 100644 --- a/fs/ubifs/xattr.c +++ b/fs/ubifs/xattr.c | |||
| @@ -280,7 +280,7 @@ static struct inode *iget_xattr(struct ubifs_info *c, ino_t inum) | |||
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | int ubifs_xattr_set(struct inode *host, const char *name, const void *value, | 282 | int ubifs_xattr_set(struct inode *host, const char *name, const void *value, |
| 283 | size_t size, int flags) | 283 | size_t size, int flags, bool check_lock) |
| 284 | { | 284 | { |
| 285 | struct inode *inode; | 285 | struct inode *inode; |
| 286 | struct ubifs_info *c = host->i_sb->s_fs_info; | 286 | struct ubifs_info *c = host->i_sb->s_fs_info; |
| @@ -289,12 +289,7 @@ int ubifs_xattr_set(struct inode *host, const char *name, const void *value, | |||
| 289 | union ubifs_key key; | 289 | union ubifs_key key; |
| 290 | int err; | 290 | int err; |
| 291 | 291 | ||
| 292 | /* | 292 | if (check_lock) |
| 293 | * Creating an encryption context is done unlocked since we | ||
| 294 | * operate on a new inode which is not visible to other users | ||
| 295 | * at this point. | ||
| 296 | */ | ||
| 297 | if (strcmp(name, UBIFS_XATTR_NAME_ENCRYPTION_CONTEXT) != 0) | ||
| 298 | ubifs_assert(inode_is_locked(host)); | 293 | ubifs_assert(inode_is_locked(host)); |
| 299 | 294 | ||
| 300 | if (size > UBIFS_MAX_INO_DATA) | 295 | if (size > UBIFS_MAX_INO_DATA) |
| @@ -598,8 +593,12 @@ static int init_xattrs(struct inode *inode, const struct xattr *xattr_array, | |||
| 598 | } | 593 | } |
| 599 | strcpy(name, XATTR_SECURITY_PREFIX); | 594 | strcpy(name, XATTR_SECURITY_PREFIX); |
| 600 | strcpy(name + XATTR_SECURITY_PREFIX_LEN, xattr->name); | 595 | strcpy(name + XATTR_SECURITY_PREFIX_LEN, xattr->name); |
| 596 | /* | ||
| 597 | * creating a new inode without holding the inode rwsem, | ||
| 598 | * no need to check whether inode is locked. | ||
| 599 | */ | ||
| 601 | err = ubifs_xattr_set(inode, name, xattr->value, | 600 | err = ubifs_xattr_set(inode, name, xattr->value, |
| 602 | xattr->value_len, 0); | 601 | xattr->value_len, 0, false); |
| 603 | kfree(name); | 602 | kfree(name); |
| 604 | if (err < 0) | 603 | if (err < 0) |
| 605 | break; | 604 | break; |
| @@ -646,7 +645,7 @@ static int xattr_set(const struct xattr_handler *handler, | |||
| 646 | name = xattr_full_name(handler, name); | 645 | name = xattr_full_name(handler, name); |
| 647 | 646 | ||
| 648 | if (value) | 647 | if (value) |
| 649 | return ubifs_xattr_set(inode, name, value, size, flags); | 648 | return ubifs_xattr_set(inode, name, value, size, flags, true); |
| 650 | else | 649 | else |
| 651 | return ubifs_xattr_remove(inode, name); | 650 | return ubifs_xattr_remove(inode, name); |
| 652 | } | 651 | } |
