diff options
| -rw-r--r-- | fs/nfs/nfs4proc.c | 53 | ||||
| -rw-r--r-- | fs/xattr.c | 4 | ||||
| -rw-r--r-- | security/smack/smack_lsm.c | 2 |
3 files changed, 40 insertions, 19 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index f6f40aae92b1..dbfade2602c9 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
| @@ -6279,10 +6279,6 @@ static size_t nfs4_xattr_list_nfs4_acl(const struct xattr_handler *handler, | |||
| 6279 | } | 6279 | } |
| 6280 | 6280 | ||
| 6281 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL | 6281 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL |
| 6282 | static inline int nfs4_server_supports_labels(struct nfs_server *server) | ||
| 6283 | { | ||
| 6284 | return server->caps & NFS_CAP_SECURITY_LABEL; | ||
| 6285 | } | ||
| 6286 | 6282 | ||
| 6287 | static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler, | 6283 | static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler, |
| 6288 | struct dentry *dentry, const char *key, | 6284 | struct dentry *dentry, const char *key, |
| @@ -6304,29 +6300,34 @@ static int nfs4_xattr_get_nfs4_label(const struct xattr_handler *handler, | |||
| 6304 | return -EOPNOTSUPP; | 6300 | return -EOPNOTSUPP; |
| 6305 | } | 6301 | } |
| 6306 | 6302 | ||
| 6307 | static size_t nfs4_xattr_list_nfs4_label(const struct xattr_handler *handler, | 6303 | static ssize_t |
| 6308 | struct dentry *dentry, char *list, | 6304 | nfs4_listxattr_nfs4_label(struct inode *inode, char *list, size_t list_len) |
| 6309 | size_t list_len, const char *name, | ||
| 6310 | size_t name_len) | ||
| 6311 | { | 6305 | { |
| 6312 | size_t len = 0; | 6306 | int len = 0; |
| 6313 | 6307 | ||
| 6314 | if (nfs_server_capable(d_inode(dentry), NFS_CAP_SECURITY_LABEL)) { | 6308 | if (nfs_server_capable(inode, NFS_CAP_SECURITY_LABEL)) { |
| 6315 | len = security_inode_listsecurity(d_inode(dentry), NULL, 0); | 6309 | len = security_inode_listsecurity(inode, list, list_len); |
| 6316 | if (list && len <= list_len) | 6310 | if (list_len && len > list_len) |
| 6317 | security_inode_listsecurity(d_inode(dentry), list, len); | 6311 | return -ERANGE; |
| 6318 | } | 6312 | } |
| 6319 | return len; | 6313 | return len; |
| 6320 | } | 6314 | } |
| 6321 | 6315 | ||
| 6322 | static const struct xattr_handler nfs4_xattr_nfs4_label_handler = { | 6316 | static const struct xattr_handler nfs4_xattr_nfs4_label_handler = { |
| 6323 | .prefix = XATTR_SECURITY_PREFIX, | 6317 | .prefix = XATTR_SECURITY_PREFIX, |
| 6324 | .list = nfs4_xattr_list_nfs4_label, | ||
| 6325 | .get = nfs4_xattr_get_nfs4_label, | 6318 | .get = nfs4_xattr_get_nfs4_label, |
| 6326 | .set = nfs4_xattr_set_nfs4_label, | 6319 | .set = nfs4_xattr_set_nfs4_label, |
| 6327 | }; | 6320 | }; |
| 6328 | #endif | ||
| 6329 | 6321 | ||
| 6322 | #else | ||
| 6323 | |||
| 6324 | static ssize_t | ||
| 6325 | nfs4_listxattr_nfs4_label(struct inode *inode, char *list, size_t list_len) | ||
| 6326 | { | ||
| 6327 | return 0; | ||
| 6328 | } | ||
| 6329 | |||
| 6330 | #endif | ||
| 6330 | 6331 | ||
| 6331 | /* | 6332 | /* |
| 6332 | * nfs_fhget will use either the mounted_on_fileid or the fileid | 6333 | * nfs_fhget will use either the mounted_on_fileid or the fileid |
| @@ -8743,6 +8744,24 @@ const struct nfs4_minor_version_ops *nfs_v4_minor_ops[] = { | |||
| 8743 | #endif | 8744 | #endif |
| 8744 | }; | 8745 | }; |
| 8745 | 8746 | ||
| 8747 | ssize_t nfs4_listxattr(struct dentry *dentry, char *list, size_t size) | ||
| 8748 | { | ||
| 8749 | ssize_t error, error2; | ||
| 8750 | |||
| 8751 | error = generic_listxattr(dentry, list, size); | ||
| 8752 | if (error < 0) | ||
| 8753 | return error; | ||
| 8754 | if (list) { | ||
| 8755 | list += error; | ||
| 8756 | size -= error; | ||
| 8757 | } | ||
| 8758 | |||
| 8759 | error2 = nfs4_listxattr_nfs4_label(d_inode(dentry), list, size); | ||
| 8760 | if (error2 < 0) | ||
| 8761 | return error2; | ||
| 8762 | return error + error2; | ||
| 8763 | } | ||
| 8764 | |||
| 8746 | static const struct inode_operations nfs4_dir_inode_operations = { | 8765 | static const struct inode_operations nfs4_dir_inode_operations = { |
| 8747 | .create = nfs_create, | 8766 | .create = nfs_create, |
| 8748 | .lookup = nfs_lookup, | 8767 | .lookup = nfs_lookup, |
| @@ -8759,7 +8778,7 @@ static const struct inode_operations nfs4_dir_inode_operations = { | |||
| 8759 | .setattr = nfs_setattr, | 8778 | .setattr = nfs_setattr, |
| 8760 | .getxattr = generic_getxattr, | 8779 | .getxattr = generic_getxattr, |
| 8761 | .setxattr = generic_setxattr, | 8780 | .setxattr = generic_setxattr, |
| 8762 | .listxattr = generic_listxattr, | 8781 | .listxattr = nfs4_listxattr, |
| 8763 | .removexattr = generic_removexattr, | 8782 | .removexattr = generic_removexattr, |
| 8764 | }; | 8783 | }; |
| 8765 | 8784 | ||
| @@ -8769,7 +8788,7 @@ static const struct inode_operations nfs4_file_inode_operations = { | |||
| 8769 | .setattr = nfs_setattr, | 8788 | .setattr = nfs_setattr, |
| 8770 | .getxattr = generic_getxattr, | 8789 | .getxattr = generic_getxattr, |
| 8771 | .setxattr = generic_setxattr, | 8790 | .setxattr = generic_setxattr, |
| 8772 | .listxattr = generic_listxattr, | 8791 | .listxattr = nfs4_listxattr, |
| 8773 | .removexattr = generic_removexattr, | 8792 | .removexattr = generic_removexattr, |
| 8774 | }; | 8793 | }; |
| 8775 | 8794 | ||
diff --git a/fs/xattr.c b/fs/xattr.c index c3af6c9670cb..2c7776403aba 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
| @@ -723,6 +723,8 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
| 723 | 723 | ||
| 724 | if (!buffer) { | 724 | if (!buffer) { |
| 725 | for_each_xattr_handler(handlers, handler) { | 725 | for_each_xattr_handler(handlers, handler) { |
| 726 | if (!handler->list) | ||
| 727 | continue; | ||
| 726 | size += handler->list(handler, dentry, NULL, 0, | 728 | size += handler->list(handler, dentry, NULL, 0, |
| 727 | NULL, 0); | 729 | NULL, 0); |
| 728 | } | 730 | } |
| @@ -730,6 +732,8 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
| 730 | char *buf = buffer; | 732 | char *buf = buffer; |
| 731 | 733 | ||
| 732 | for_each_xattr_handler(handlers, handler) { | 734 | for_each_xattr_handler(handlers, handler) { |
| 735 | if (!handler->list) | ||
| 736 | continue; | ||
| 733 | size = handler->list(handler, dentry, buf, buffer_size, | 737 | size = handler->list(handler, dentry, buf, buffer_size, |
| 734 | NULL, 0); | 738 | NULL, 0); |
| 735 | if (size > buffer_size) | 739 | if (size > buffer_size) |
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index ff81026f6ddb..37fdd5416a64 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
| @@ -1519,8 +1519,6 @@ static int smack_inode_getsecurity(const struct inode *inode, | |||
| 1519 | * @inode: the object | 1519 | * @inode: the object |
| 1520 | * @buffer: where they go | 1520 | * @buffer: where they go |
| 1521 | * @buffer_size: size of buffer | 1521 | * @buffer_size: size of buffer |
| 1522 | * | ||
| 1523 | * Returns 0 on success, -EINVAL otherwise | ||
| 1524 | */ | 1522 | */ |
| 1525 | static int smack_inode_listsecurity(struct inode *inode, char *buffer, | 1523 | static int smack_inode_listsecurity(struct inode *inode, char *buffer, |
| 1526 | size_t buffer_size) | 1524 | size_t buffer_size) |
