From: Vivek Goyal <vgoyal@redhat.com>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
viro@zeniv.linux.org.uk
Cc: virtio-fs@redhat.com, dwalsh@redhat.com, dgilbert@redhat.com,
berrange@redhat.com, vgoyal@redhat.com
Subject: [PATCH 1/1] xattr: Allow user.* xattr on symlink/special files with CAP_SYS_RESOURCE
Date: Fri, 25 Jun 2021 15:12:29 -0400 [thread overview]
Message-ID: <20210625191229.1752531-2-vgoyal@redhat.com> (raw)
In-Reply-To: <20210625191229.1752531-1-vgoyal@redhat.com>
As of now user.* xattrs are allowed only on regular files and directories.
And in case of directories if sticky bit is set, then it is allowed
only if caller is owner or has CAP_FOWNER.
"man xattr" suggests that primary reason behind this restrcition is that
users can set unlimited amount of "user.*" xattrs on symlinks and special
files and bypass quota checks. Following is from man page.
"These differences would allow users to consume filesystem resources in
a way not controllable by disk quotas for group or world writable spe‐
cial files and directories"
Capability CAP_SYS_RESOURCE allows for overriding disk quota limits. If
being able to bypass quota is primary reason behind these restrictions,
can we relax these restrictions if caller has CAP_SYS_RESOURCE.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
fs/xattr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/xattr.c b/fs/xattr.c
index 5c8c5175b385..10bb918029dd 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -124,7 +124,8 @@ xattr_permission(struct user_namespace *mnt_userns, struct inode *inode,
* extended attributes. For sticky directories, only the owner and
* privileged users can write attributes.
*/
- if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
+ if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) &&
+ !capable(CAP_SYS_RESOURCE)) {
if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
--
2.25.4
next prev parent reply other threads:[~2021-06-25 19:12 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-25 19:12 [RFC PATCH 0/1] xattr: Allow user.* xattr on symlink/special files if caller has CAP_SYS_RESOURCE Vivek Goyal
2021-06-25 19:12 ` Vivek Goyal [this message]
2021-06-28 12:33 ` [PATCH 1/1] xattr: Allow user.* xattr on symlink/special files with CAP_SYS_RESOURCE Christian Brauner
2021-06-28 15:00 ` Vivek Goyal
2021-06-29 3:13 ` [xattr] 8d8cd767b6: ltp.setxattr02.fail kernel test robot
2021-06-29 12:59 ` Vivek Goyal
2021-06-25 21:49 ` [RFC PATCH 0/1] xattr: Allow user.* xattr on symlink/special files if caller has CAP_SYS_RESOURCE Schaufler, Casey
2021-06-28 11:58 ` Dr. David Alan Gilbert
2021-06-28 13:17 ` Vivek Goyal
2021-06-28 13:36 ` Daniel Walsh
2021-06-28 16:04 ` Casey Schaufler
2021-06-28 16:28 ` Dr. David Alan Gilbert
2021-06-28 17:41 ` Casey Schaufler
2021-06-29 9:00 ` Dr. David Alan Gilbert
2021-06-29 14:38 ` Casey Schaufler
2021-06-29 15:20 ` Vivek Goyal
2021-06-29 16:13 ` Casey Schaufler
2021-06-29 16:35 ` Dr. David Alan Gilbert
2021-06-29 16:51 ` Casey Schaufler
2021-06-29 17:35 ` Vivek Goyal
2021-06-29 20:28 ` Daniel Walsh
2021-06-30 4:12 ` Theodore Ts'o
2021-06-30 8:07 ` Dr. David Alan Gilbert
2021-06-30 14:47 ` Theodore Ts'o
2021-06-30 15:01 ` Dr. David Alan Gilbert
2021-06-30 19:59 ` Theodore Ts'o
2021-06-30 20:32 ` Vivek Goyal
2021-07-01 8:48 ` Dr. David Alan Gilbert
2021-07-01 12:21 ` Vivek Goyal
2021-07-01 13:10 ` Vivek Goyal
2021-07-01 16:58 ` Casey Schaufler
2021-06-30 16:09 ` Vivek Goyal
2021-06-30 14:27 ` Vivek Goyal
2021-06-29 16:25 ` Theodore Ts'o
2021-06-28 17:22 ` Vivek Goyal
2021-06-28 18:55 ` Daniel Walsh
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=20210625191229.1752531-2-vgoyal@redhat.com \
--to=vgoyal@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=dwalsh@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=virtio-fs@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).