]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: lustre: llite: Setting xattr are properly checked with and without ACLs
authorDmitry Eremin <dmitry.eremin@intel.com>
Sun, 29 Jan 2017 00:04:57 +0000 (19:04 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Feb 2017 12:01:37 +0000 (13:01 +0100)
Setting extended attributes permissions are properly checked with and
without ACLs. In user.* namespace, only regular files and directories
can have extended attributes. For sticky directories, only the owner
and privileged user can write attributes.

Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1482
Reviewed-on: http://review.whamcloud.com/21496
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/llite/xattr.c

index 7a848ebc57c1e6f22ab7629978660a1cd32a5d03..421cc04ecf1e881adf62d520db133212082dd55c 100644 (file)
@@ -132,6 +132,15 @@ ll_xattr_set_common(const struct xattr_handler *handler,
            (!strcmp(name, "ima") || !strcmp(name, "evm")))
                return -EOPNOTSUPP;
 
+       /*
+        * In user.* namespace, only regular files and directories can have
+        * extended attributes.
+        */
+       if (handler->flags == XATTR_USER_T) {
+               if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
+                       return -EPERM;
+       }
+
        sprintf(fullname, "%s%s\n", handler->prefix, name);
        rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode),
                         valid, fullname, pv, size, 0, flags,