Commit 270239fd5697caf728f59cfa873fc198d59e76a1

Authored by Christoph Hellwig
Committed by Greg Kroah-Hartman
1 parent f6301b5d70

nfs: only show Posix ACLs in listxattr if actually present

commit 74adf83f5d7720925499b4938f930591f947b660 upstream.

The big ACL switched nfs to use generic_listxattr, which calls all existing
->list handlers.  Add a custom .listxattr implementation that only lists
the ACLs if they actually are present on the given inode.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Philippe Troin <phil@fifi.org>
Tested-by: Philippe Troin <phil@fifi.org>
Fixes: 013cdf1088d7 (nfs: use generic posix ACL infrastructure ...)
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 2 changed files with 45 additions and 2 deletions Side-by-side Diff

... ... @@ -247,4 +247,47 @@
247 247 &posix_acl_default_xattr_handler,
248 248 NULL,
249 249 };
  250 +
  251 +static int
  252 +nfs3_list_one_acl(struct inode *inode, int type, const char *name, void *data,
  253 + size_t size, ssize_t *result)
  254 +{
  255 + struct posix_acl *acl;
  256 + char *p = data + *result;
  257 +
  258 + acl = get_acl(inode, type);
  259 + if (!acl)
  260 + return 0;
  261 +
  262 + posix_acl_release(acl);
  263 +
  264 + *result += strlen(name);
  265 + *result += 1;
  266 + if (!size)
  267 + return 0;
  268 + if (*result > size)
  269 + return -ERANGE;
  270 +
  271 + strcpy(p, name);
  272 + return 0;
  273 +}
  274 +
  275 +ssize_t
  276 +nfs3_listxattr(struct dentry *dentry, char *data, size_t size)
  277 +{
  278 + struct inode *inode = dentry->d_inode;
  279 + ssize_t result = 0;
  280 + int error;
  281 +
  282 + error = nfs3_list_one_acl(inode, ACL_TYPE_ACCESS,
  283 + POSIX_ACL_XATTR_ACCESS, data, size, &result);
  284 + if (error)
  285 + return error;
  286 +
  287 + error = nfs3_list_one_acl(inode, ACL_TYPE_DEFAULT,
  288 + POSIX_ACL_XATTR_DEFAULT, data, size, &result);
  289 + if (error)
  290 + return error;
  291 + return result;
  292 +}
... ... @@ -891,7 +891,7 @@
891 891 .getattr = nfs_getattr,
892 892 .setattr = nfs_setattr,
893 893 #ifdef CONFIG_NFS_V3_ACL
894   - .listxattr = generic_listxattr,
  894 + .listxattr = nfs3_listxattr,
895 895 .getxattr = generic_getxattr,
896 896 .setxattr = generic_setxattr,
897 897 .removexattr = generic_removexattr,
... ... @@ -905,7 +905,7 @@
905 905 .getattr = nfs_getattr,
906 906 .setattr = nfs_setattr,
907 907 #ifdef CONFIG_NFS_V3_ACL
908   - .listxattr = generic_listxattr,
  908 + .listxattr = nfs3_listxattr,
909 909 .getxattr = generic_getxattr,
910 910 .setxattr = generic_setxattr,
911 911 .removexattr = generic_removexattr,