From: "Sun YangKai" <sunyangkai@fnnas.com>
To: "Filipe Manana" <fdmanana@kernel.org>
Cc: <linux-btrfs@vger.kernel.org>, <sunk67188@gmail.com>
Subject: Re: [PATCH v2] btrfs: check if root is readonly when setting posix acl
Date: Fri, 10 Jul 2026 17:03:22 +0800 [thread overview]
Message-ID: <2edb04cd-4939-41d5-a696-ab40aba6e85f@fnnas.com> (raw)
In-Reply-To: <CAL3q7H6wxWNKWcXD7u58O4JJ_0z0_XMpAHc6eQfAiBOPNbKkQw@mail.gmail.com>
On 2026/7/9 18:43, Filipe Manana wrote:
> On Thu, Jul 9, 2026 at 9:26 AM Sun YangKai <sunk67188@gmail.com> wrote:
>>
>> From: Sun YangKai <sunyangkai@fnnas.com>
>>
>> For a filesystem which has btrfs read-only property set to true, all
>> write operations including acl and xattr should be denied. However,
>> acl can still be set even if btrfs ro property is true.
>>
>> This happens because no function on the set_acl code path checks the root
>> is readonly or not. It was checked in btrfs_setxattr_trans() but got
>> removed in
>> commit 353c2ea735e4 ("btrfs: remove redundant readonly root check in btrfs_setxattr_trans")
>>
>> That commit didn't check if all the callers properly check the root's
>> read-only flag. A previous fix is
>> commit b51111271b03("btrfs: check if root is readonly while setting security xattr")
>>
>> Always check if the root is read-only before performing the set acl
>> operation.
>>
>> Fixes: 353c2ea735e4 ("btrfs: remove redundant readonly root check in btrfs_setxattr_trans")
>> Signed-off-by: Sun YangKai <sunyangkai@fnnas.com>
>
> Test case please (fstests).
Ok, I'll work on that later.
I've noticed the test case btrfs/275 for b51111271b03 and I'll take that
as reference.
Thanks,
Sun YangKai
>
>> ---
>> Changes to v1:
>> - add the missing header file
>>
>> ---
>> fs/btrfs/acl.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
>> index e55b686fe1ab..662cdd1cbdef 100644
>> --- a/fs/btrfs/acl.c
>> +++ b/fs/btrfs/acl.c
>> @@ -15,6 +15,7 @@
>> #include "xattr.h"
>> #include "acl.h"
>> #include "misc.h"
>> +#include "btrfs_inode.h"
>>
>> struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu)
>> {
>> @@ -107,6 +108,9 @@ int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
>> struct inode *inode = d_inode(dentry);
>> umode_t old_mode = inode->i_mode;
>>
>> + if (btrfs_root_readonly(BTRFS_I(inode)->root))
>> + return -EROFS;
>> +
>> if (type == ACL_TYPE_ACCESS && acl) {
>> ret = posix_acl_update_mode(idmap, inode,
>> &inode->i_mode, &acl);
>> --
>> 2.54.0
>>
>>
prev parent reply other threads:[~2026-07-10 9:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 8:23 [PATCH v2] btrfs: check if root is readonly when setting posix acl Sun YangKai
2026-07-09 9:54 ` Johannes Thumshirn
2026-07-09 10:43 ` Filipe Manana
2026-07-10 9:03 ` Sun YangKai [this message]
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=2edb04cd-4939-41d5-a696-ab40aba6e85f@fnnas.com \
--to=sunyangkai@fnnas.com \
--cc=fdmanana@kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=sunk67188@gmail.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