* [PATCH] btrfs: check if root is readonly when setting posix acl
@ 2026-07-09 7:14 Sun YangKai
2026-08-07 12:56 ` kernel test robot
2026-08-08 22:19 ` kernel test robot
0 siblings, 2 replies; 3+ messages in thread
From: Sun YangKai @ 2026-07-09 7:14 UTC (permalink / raw)
To: linux-btrfs; +Cc: Sun YangKai
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>
---
fs/btrfs/acl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index e55b686fe1ab..7609eed6f41f 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -107,6 +107,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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: check if root is readonly when setting posix acl
2026-07-09 7:14 [PATCH] btrfs: check if root is readonly when setting posix acl Sun YangKai
@ 2026-08-07 12:56 ` kernel test robot
2026-08-08 22:19 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-08-07 12:56 UTC (permalink / raw)
To: Sun YangKai, linux-btrfs; +Cc: oe-kbuild-all, Sun YangKai
Hi Sun,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v7.2-rc6]
[cannot apply to kdave/for-next next-20260806]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sun-YangKai/btrfs-check-if-root-is-readonly-when-setting-posix-acl/20260807-183739
base: linus/master
patch link: https://lore.kernel.org/r/20260709071529.4033-1-sunk67188%40gmail.com
patch subject: [PATCH] btrfs: check if root is readonly when setting posix acl
config: alpha-allmodconfig (https://download.01.org/0day-ci/archive/20260807/202608072012.WLkLdXMW-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 16.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260807/202608072012.WLkLdXMW-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608072012.WLkLdXMW-lkp@intel.com/
All errors (new ones prefixed by >>):
fs/btrfs/acl.c: In function 'btrfs_set_acl':
>> fs/btrfs/acl.c:110:33: error: implicit declaration of function 'BTRFS_I' [-Wimplicit-function-declaration]
110 | if (btrfs_root_readonly(BTRFS_I(inode)->root))
| ^~~~~~~
>> fs/btrfs/acl.c:110:47: error: invalid type argument of '->' (have 'int')
110 | if (btrfs_root_readonly(BTRFS_I(inode)->root))
| ^~
vim +/BTRFS_I +110 fs/btrfs/acl.c
102
103 int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
104 struct posix_acl *acl, int type)
105 {
106 int ret;
107 struct inode *inode = d_inode(dentry);
108 umode_t old_mode = inode->i_mode;
109
> 110 if (btrfs_root_readonly(BTRFS_I(inode)->root))
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: check if root is readonly when setting posix acl
2026-07-09 7:14 [PATCH] btrfs: check if root is readonly when setting posix acl Sun YangKai
2026-08-07 12:56 ` kernel test robot
@ 2026-08-08 22:19 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-08-08 22:19 UTC (permalink / raw)
To: Sun YangKai, linux-btrfs; +Cc: llvm, oe-kbuild-all, Sun YangKai
Hi Sun,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v7.2-rc6]
[cannot apply to kdave/for-next next-20260807]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sun-YangKai/btrfs-check-if-root-is-readonly-when-setting-posix-acl/20260807-183739
base: linus/master
patch link: https://lore.kernel.org/r/20260709071529.4033-1-sunk67188%40gmail.com
patch subject: [PATCH] btrfs: check if root is readonly when setting posix acl
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20260809/202608090528.DQ0KtccR-lkp@intel.com/config)
compiler: clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260809/202608090528.DQ0KtccR-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608090528.DQ0KtccR-lkp@intel.com/
All errors (new ones prefixed by >>):
>> fs/btrfs/acl.c:110:26: error: call to undeclared function 'BTRFS_I'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
110 | if (btrfs_root_readonly(BTRFS_I(inode)->root))
| ^
>> fs/btrfs/acl.c:110:42: error: member reference type 'int' is not a pointer
110 | if (btrfs_root_readonly(BTRFS_I(inode)->root))
| ~~~~~~~~~~~~~~ ^
2 errors generated.
vim +/BTRFS_I +110 fs/btrfs/acl.c
102
103 int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
104 struct posix_acl *acl, int type)
105 {
106 int ret;
107 struct inode *inode = d_inode(dentry);
108 umode_t old_mode = inode->i_mode;
109
> 110 if (btrfs_root_readonly(BTRFS_I(inode)->root))
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-08 22:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09 7:14 [PATCH] btrfs: check if root is readonly when setting posix acl Sun YangKai
2026-08-07 12:56 ` kernel test robot
2026-08-08 22:19 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox