#1145355 btrfs-progs: btrfs sub del fails silently when it can't open the subvol directory

Package:
btrfs-progs
Source:
btrfs-progs
Description:
Checksumming Copy on Write Filesystem utilities
Submitter:
Russell Coker
Date:
2026-08-24 18:19:02 UTC
Severity:
normal
Tags:
#1145355#5
Date:
2026-08-24 12:41:30 UTC
From:
To:
root@ami:~# btrfs sub del /test
root@ami:~# echo $?
1
root@ami:~# ls -al /test
total 0
drwx------. 1 root root   0 Aug 24 22:31 .
drwxr-xr-x. 1 root root 262 Aug 24 22:31 ..

The above is an example of it failing due to SE Linux denying read access to
the directory.  While the recent SE Linux policy will allow that for all
reasonable labels error conditions should still be flagged to the operator.

Here is strace output:

openat(AT_FDCWD, "/test", O_RDONLY)     = -1 EACCES (Permission denied)
close(3)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++

What I expect to see is a printf with a brief explanation of the issue so the
sysadmin doesn't need to run strace to find out what is going on and so that
if a cron job fails there will be email sent.

Also if openat() succeeds but ioctl fails later in the operation it is another
situation of a quiet exit(1) with no explanation.

#1145355#10
Date:
2026-08-24 18:18:15 UTC
From:
To:
control: found -1 btrfs-progs/7.0-1
control: tag -1 moreinfo

Hi Russell,

Thanks for reporting, reply follows inline.  I need one morsel of info before forwarding this upstream:

Russell Coker <russell@coker.com.au> writes:
[snip]
[snip]

I tested if this was a fundamental permissions handling issue rather
than a SE Linux-specific thing; this looks like an unhandled general
case to me.  What is more, it's arguably a regression.  Btrfs-progs 6.14 (in
Debian 13/trixie) emits the following error for EPERM EACCES on a
directory (as a normal user):

  WARNING: cannot read default subvolume id: Operation not permitted

What error does btrfs-progs 6.14-1 emit in the case of an EPERM EACCESS
caused by SE Linux?

Insufficieng plain UNIX permissions fail silently in btrfs-progs >=7.0:

$ cd snapshots
$ sudo btrfs snap ../some_subvolume some_subvolume_snap
$ sudo chmod go-rwx some_subvolume_snap
$ btrfs sub delete some_subvolume_snap # silently errors
$ strace btrfs sub delete some_subvolume_snap
…
openat(AT_FDCWD, "/btrfs-admin/Red/snapshots", O_RDONLY) = 3
ioctl(3, BTRFS_IOC_TREE_SEARCH, {key={tree_id=BTRFS_ROOT_TREE_OBJECTID, min_objectid=BTRFS_ROOT_TREE_DIR_OBJECTID, max_objectid=BTRFS_ROOT_TREE_DIR_OBJECTID, min_offset=0, max_offset=UINT64_MAX, min_transid=0, max_transid=UINT64_MAX, min_type=BTRFS_DIR_ITEM_KEY, max_type=BTRFS_DIR_ITEM_KEY, nr_items=4096}}) = -1 EPERM (Operation not permitted)
geteuid()                               = 1000
openat(AT_FDCWD, "@some_subvolume_snap", O_RDONLY) = -1 EACCES (Permission denied)
close(3)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++


Cheers,
Nicholas