]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: don't rewrite ret from inode_permission
authorJosef Bacik <josef@toxicpanda.com>
Tue, 18 Nov 2025 16:08:41 +0000 (17:08 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 25 Nov 2025 00:52:24 +0000 (01:52 +0100)
In our user safe ino resolve ioctl we'll just turn any ret into -EACCES
from inode_permission().  This is redundant, and could potentially be
wrong if we had an ENOMEM in the security layer or some such other
error, so simply return the actual return value.

Note: The patch was taken from v5 of fscrypt patchset
(https://lore.kernel.org/linux-btrfs/cover.1706116485.git.josef@toxicpanda.com/)
which was handled over time by various people: Omar Sandoval, Sweet Tea
Dorminy, Josef Bacik.

Fixes: 23d0b79dfaed ("btrfs: Add unprivileged version of ino_lookup ioctl")
CC: stable@vger.kernel.org # 5.4+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Daniel Vacek <neelx@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ add note ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c

index 59cef7e376a0f30d5f2f995e8645a102e90f82e1..a10b60439718696799821fe6ced531d7f419072f 100644 (file)
@@ -1910,10 +1910,8 @@ static int btrfs_search_path_in_tree_user(struct mnt_idmap *idmap,
                        ret = inode_permission(idmap, &temp_inode->vfs_inode,
                                               MAY_READ | MAY_EXEC);
                        iput(&temp_inode->vfs_inode);
-                       if (ret) {
-                               ret = -EACCES;
+                       if (ret)
                                goto out_put;
-                       }
 
                        if (key.offset == upper_limit)
                                break;