[PATCH v7 4/6] btrfs: don't rewrite ret from inode_permission

Daniel Vacek posted 6 patches 1 week, 6 days ago
[PATCH v7 4/6] btrfs: don't rewrite ret from inode_permission
Posted by Daniel Vacek 1 week, 6 days ago
From: Josef Bacik <josef@toxicpanda.com>

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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/ioctl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 1920caf8d308..c2d992f5ce7d 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -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;
-- 
2.51.0
Re: [PATCH v7 4/6] btrfs: don't rewrite ret from inode_permission
Posted by Johannes Thumshirn 1 week, 5 days ago
This patch on it's own looks reasonable and IMHO should be merged ASAP 
to not overwrite the inode_permisison() return value.

I think also a

Fixes: 23d0b79dfaed ("btrfs: Add unprivileged version of ino_lookup ioctl")

would be appropriate

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Re: [PATCH v7 4/6] btrfs: don't rewrite ret from inode_permission
Posted by Johannes Thumshirn 1 week, 5 days ago
On 11/19/25 11:08 AM, Johannes Thumshirn wrote:
> This patch on it's own looks reasonable and IMHO should be merged ASAP
> to not overwrite the inode_permisison() return value.
>
> I think also a
>
> Fixes: 23d0b79dfaed ("btrfs: Add unprivileged version of ino_lookup ioctl")
>
> would be appropriate
>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>
>
Forgot to add, this needs your Signed-off-by as well as you've rebased 
it. Same for the other patches.

Re: [PATCH v7 4/6] btrfs: don't rewrite ret from inode_permission
Posted by David Sterba 1 week, 5 days ago
On Wed, Nov 19, 2025 at 10:13:10AM +0000, Johannes Thumshirn wrote:
> On 11/19/25 11:08 AM, Johannes Thumshirn wrote:
> > This patch on it's own looks reasonable and IMHO should be merged ASAP
> > to not overwrite the inode_permisison() return value.
> >
> > I think also a
> >
> > Fixes: 23d0b79dfaed ("btrfs: Add unprivileged version of ino_lookup ioctl")
> >
> > would be appropriate
> >
> > Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Yes this seems to have effects on user space, though hopefully nothing
really bad as the error codes from the permission checks is EACCESS or
EPERM, other than the ENOMEM and similar.

> Forgot to add, this needs your Signed-off-by as well as you've rebased 
> it. Same for the other patches.

I'll add it, the final list will be the original author, Daniel as he
touched it last and mine. The code hasn't evolved over the revisions so
adding everybody who submitted it at some point does not seem adequate.
Still I will also add a text to the changelog linking to the latest v5
series and mentioning people who handled the series in the past to give
credit.