[PATCH] fs: fix xattr permission checking error

Nicolas Belouin <[email protected]>
Newsgroups gmane.comp.file-systems.jfs.general
Message-ID <20171021133947.19935-1-nicolas__10931.9484363825$1508644642$gmane$org@belouin.fr>
Fix an issue making trusted xattr world readable and other
cap_sys_admin only

Signed-off-by: Nicolas Belouin <[email protected]>
---
 fs/hfsplus/xattr.c | 2 +-
 fs/jfs/xattr.c     | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
index d37bb88dc746..ae03a19196ef 100644
--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -604,7 +604,7 @@ static inline int can_list(const char *xattr_name)
 	if (!xattr_name)
 		return 0;
 
-	return strncmp(xattr_name, XATTR_TRUSTED_PREFIX,
+	return !strncmp(xattr_name, XATTR_TRUSTED_PREFIX,
 			XATTR_TRUSTED_PREFIX_LEN) ||
 				capable(CAP_SYS_ADMIN);
 }
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index c60f3d32ee91..1c46573a96ed 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -858,9 +858,8 @@ ssize_t __jfs_getxattr(struct inode *inode, const char *name, void *data,
  */
 static inline int can_list(struct jfs_ea *ea)
 {
-	return (strncmp(ea->name, XATTR_TRUSTED_PREFIX,
-			    XATTR_TRUSTED_PREFIX_LEN) ||
-		capable(CAP_SYS_ADMIN));
+	return (!strncmp(ea->name, XATTR_TRUSTED_PREFIX,
+			 XATTR_TRUSTED_PREFIX_LEN) || capable(CAP_SYS_ADMIN));
 }
 
 ssize_t jfs_listxattr(struct dentry * dentry, char *data, size_t buf_size)
-- 
2.14.2


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.