mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Belouin <nicolas@belouin.fr>
To: Dave Kleikamp <shaggy@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	jfs-discussion@lists.sourceforge.net
Cc: Nicolas Belouin <nicolas@belouin.fr>
Subject: [PATCH] fs: fix xattr permission checking error
Date: Sat, 21 Oct 2017 15:39:47 +0200	[thread overview]
Message-ID: <20171021133947.19935-1-nicolas@belouin.fr> (raw)

Fix an issue making trusted xattr world readable and other
cap_sys_admin only

Signed-off-by: Nicolas Belouin <nicolas@belouin.fr>
---
 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

             reply	other threads:[~2017-10-21 13:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-21 13:39 Nicolas Belouin [this message]
2017-10-21 19:48 ` Andreas Dilger
2017-10-21 20:00   ` Nicolas Belouin
2017-10-22  5:39 ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171021133947.19935-1-nicolas@belouin.fr \
    --to=nicolas@belouin.fr \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shaggy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®