mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ceph: use the mount idmap for the owner checks in the SET_LAYOUT ioctls
@ 2026-07-27  1:47 Zhan Xusheng
  2026-07-28 11:30 ` Ilya Dryomov
  0 siblings, 1 reply; 6+ messages in thread
From: Zhan Xusheng @ 2026-07-27  1:47 UTC (permalink / raw)
  To: Ilya Dryomov
  Cc: Alex Markuze, Viacheslav Dubeyko, Max Kellermann, ceph-devel,
	linux-kernel, Zhan Xusheng, stable

From: Zhan Xusheng <zhanxusheng@xiaomi.com>

ceph_ioctl_set_layout() and ceph_ioctl_set_layout_policy() call
inode_owner_or_capable() with &nop_mnt_idmap instead of the idmap of the
mount the ioctl was issued on.

CephFS supports idmapped mounts (FS_ALLOW_IDMAP), so on such a mount this
compares the caller's fsuid against the unmapped on-disk owner rather than
the mapped owner: the actual owner can be wrongly denied with -EACCES and
an unrelated caller wrongly allowed.  Both functions already have the
struct file, so use file_mnt_idmap(file) instead.

Fixes: cee38bbf5556 ("ceph: add owner/capability checks for CEPH_IOC_SET_LAYOUT*")
Cc: stable@vger.kernel.org
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
---
 fs/ceph/ioctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index de07f19b0caa..12cb50e0a166 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -72,7 +72,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
 	struct ceph_ioctl_layout nl;
 	int err;
 
-	if (!inode_owner_or_capable(&nop_mnt_idmap, inode))
+	if (!inode_owner_or_capable(file_mnt_idmap(file), inode))
 		return -EACCES;
 
 	if (copy_from_user(&l, arg, sizeof(l)))
@@ -145,7 +145,7 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)
 	int err;
 	struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(inode->i_sb)->mdsc;
 
-	if (!inode_owner_or_capable(&nop_mnt_idmap, inode))
+	if (!inode_owner_or_capable(file_mnt_idmap(file), inode))
 		return -EACCES;
 
 	/* copy and validate */
-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ceph: use the mount idmap for the owner checks in the SET_LAYOUT ioctls
  2026-07-27  1:47 [PATCH] ceph: use the mount idmap for the owner checks in the SET_LAYOUT ioctls Zhan Xusheng
@ 2026-07-28 11:30 ` Ilya Dryomov
  2026-08-08  6:30   ` Max Kellermann
  0 siblings, 1 reply; 6+ messages in thread
From: Ilya Dryomov @ 2026-07-28 11:30 UTC (permalink / raw)
  To: Max Kellermann
  Cc: Zhan Xusheng, Alex Markuze, Viacheslav Dubeyko, ceph-devel,
	linux-kernel, Zhan Xusheng, stable

On Mon, Jul 27, 2026 at 3:47 AM Zhan Xusheng <zhanxusheng1024@gmail.com> wrote:
>
> From: Zhan Xusheng <zhanxusheng@xiaomi.com>
>
> ceph_ioctl_set_layout() and ceph_ioctl_set_layout_policy() call
> inode_owner_or_capable() with &nop_mnt_idmap instead of the idmap of the
> mount the ioctl was issued on.
>
> CephFS supports idmapped mounts (FS_ALLOW_IDMAP), so on such a mount this
> compares the caller's fsuid against the unmapped on-disk owner rather than
> the mapped owner: the actual owner can be wrongly denied with -EACCES and
> an unrelated caller wrongly allowed.  Both functions already have the
> struct file, so use file_mnt_idmap(file) instead.
>
> Fixes: cee38bbf5556 ("ceph: add owner/capability checks for CEPH_IOC_SET_LAYOUT*")
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
> ---
>  fs/ceph/ioctl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
> index de07f19b0caa..12cb50e0a166 100644
> --- a/fs/ceph/ioctl.c
> +++ b/fs/ceph/ioctl.c
> @@ -72,7 +72,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
>         struct ceph_ioctl_layout nl;
>         int err;
>
> -       if (!inode_owner_or_capable(&nop_mnt_idmap, inode))
> +       if (!inode_owner_or_capable(file_mnt_idmap(file), inode))
>                 return -EACCES;
>
>         if (copy_from_user(&l, arg, sizeof(l)))
> @@ -145,7 +145,7 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)
>         int err;
>         struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(inode->i_sb)->mdsc;
>
> -       if (!inode_owner_or_capable(&nop_mnt_idmap, inode))
> +       if (!inode_owner_or_capable(file_mnt_idmap(file), inode))

Hi Max,

Was there any specific reason you used nop_mnt_idmap for these checks?

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ceph: use the mount idmap for the owner checks in the SET_LAYOUT ioctls
  2026-07-28 11:30 ` Ilya Dryomov
@ 2026-08-08  6:30   ` Max Kellermann
  2026-08-09 17:33     ` Ilya Dryomov
  0 siblings, 1 reply; 6+ messages in thread
From: Max Kellermann @ 2026-08-08  6:30 UTC (permalink / raw)
  To: Ilya Dryomov
  Cc: Zhan Xusheng, Alex Markuze, Viacheslav Dubeyko, ceph-devel,
	linux-kernel, Zhan Xusheng, stable

On Tue, Jul 28, 2026 at 1:31 PM Ilya Dryomov <idryomov@gmail.com> wrote:
> Was there any specific reason you used nop_mnt_idmap for these checks?

No, I copied that check from another filesystem, probably ext2. I had
no idea what this parameter means (and I have never used idmappings).
I guess the amended parameter in this patch is correct.

-- 
Max Kellermann
Principal Architect
Hosting Technology

cm4all | Im Mediapark 6a | 50670 Köln | Germany
General information about the company can be found here:
https://www.cm4all.com/impressum
A member of the IONOS Group

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ceph: use the mount idmap for the owner checks in the SET_LAYOUT ioctls
  2026-08-08  6:30   ` Max Kellermann
@ 2026-08-09 17:33     ` Ilya Dryomov
  2026-08-12 11:32       ` Xiubo Li
  0 siblings, 1 reply; 6+ messages in thread
From: Ilya Dryomov @ 2026-08-09 17:33 UTC (permalink / raw)
  To: Xiubo Li
  Cc: Max Kellermann, Zhan Xusheng, Alex Markuze, Viacheslav Dubeyko,
	ceph-devel, linux-kernel, Zhan Xusheng, stable

On Sat, Aug 8, 2026 at 8:31 AM Max Kellermann <max.kellermann@ionos.com> wrote:
>
> On Tue, Jul 28, 2026 at 1:31 PM Ilya Dryomov <idryomov@gmail.com> wrote:
> > Was there any specific reason you used nop_mnt_idmap for these checks?
>
> No, I copied that check from another filesystem, probably ext2. I had
> no idea what this parameter means (and I have never used idmappings).
> I guess the amended parameter in this patch is correct.

Hi Xiubo,

You reviewed Max's "ceph: add owner/capability checks for
CEPH_IOC_SET_LAYOUT*" patch.  Would you be able to review this fixup as
well?

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ceph: use the mount idmap for the owner checks in the SET_LAYOUT ioctls
  2026-08-09 17:33     ` Ilya Dryomov
@ 2026-08-12 11:32       ` Xiubo Li
  2026-08-12 19:57         ` Ilya Dryomov
  0 siblings, 1 reply; 6+ messages in thread
From: Xiubo Li @ 2026-08-12 11:32 UTC (permalink / raw)
  To: Ilya Dryomov
  Cc: Max Kellermann, Zhan Xusheng, Alex Markuze, Viacheslav Dubeyko,
	ceph-devel, linux-kernel, Zhan Xusheng, stable

Hi Ilya,

I'm not sure why I couldn't find the original email of this. I checked
the changes on lore.kernel.org.

The fix looks correct to me.

On an idmapped mount, using &nop_mnt_idmap compares the caller's fsuid
against the unmapped on-disk uid directly, which would wrongly deny
the actual mapped owner and potentially allow an unrelated caller.
Both functions already have the struct file, so switching to
file_mnt_idmap(file) is the right thing to do.

Reviewed-by: Xiubo Li <xiubo.li@clyso.com>

Thanks
Xiubo Li

On Sun, 9 Aug 2026 at 10:33, Ilya Dryomov <idryomov@gmail.com> wrote:
>
> On Sat, Aug 8, 2026 at 8:31 AM Max Kellermann <max.kellermann@ionos.com> wrote:
> >
> > On Tue, Jul 28, 2026 at 1:31 PM Ilya Dryomov <idryomov@gmail.com> wrote:
> > > Was there any specific reason you used nop_mnt_idmap for these checks?
> >
> > No, I copied that check from another filesystem, probably ext2. I had
> > no idea what this parameter means (and I have never used idmappings).
> > I guess the amended parameter in this patch is correct.
>
> Hi Xiubo,
>
> You reviewed Max's "ceph: add owner/capability checks for
> CEPH_IOC_SET_LAYOUT*" patch.  Would you be able to review this fixup as
> well?
>
> Thanks,
>
>                 Ilya

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ceph: use the mount idmap for the owner checks in the SET_LAYOUT ioctls
  2026-08-12 11:32       ` Xiubo Li
@ 2026-08-12 19:57         ` Ilya Dryomov
  0 siblings, 0 replies; 6+ messages in thread
From: Ilya Dryomov @ 2026-08-12 19:57 UTC (permalink / raw)
  To: Xiubo Li
  Cc: Max Kellermann, Zhan Xusheng, Alex Markuze, Viacheslav Dubeyko,
	ceph-devel, linux-kernel, Zhan Xusheng, stable

On Wed, Aug 12, 2026 at 1:32 PM Xiubo Li <xiubo.li@clyso.com> wrote:
>
> Hi Ilya,
>
> I'm not sure why I couldn't find the original email of this. I checked
> the changes on lore.kernel.org.
>
> The fix looks correct to me.
>
> On an idmapped mount, using &nop_mnt_idmap compares the caller's fsuid
> against the unmapped on-disk uid directly, which would wrongly deny
> the actual mapped owner and potentially allow an unrelated caller.
> Both functions already have the struct file, so switching to
> file_mnt_idmap(file) is the right thing to do.
>
> Reviewed-by: Xiubo Li <xiubo.li@clyso.com>

Applied.

Thanks,

                Ilya

>
> Thanks
> Xiubo Li
>
> On Sun, 9 Aug 2026 at 10:33, Ilya Dryomov <idryomov@gmail.com> wrote:
> >
> > On Sat, Aug 8, 2026 at 8:31 AM Max Kellermann <max.kellermann@ionos.com> wrote:
> > >
> > > On Tue, Jul 28, 2026 at 1:31 PM Ilya Dryomov <idryomov@gmail.com> wrote:
> > > > Was there any specific reason you used nop_mnt_idmap for these checks?
> > >
> > > No, I copied that check from another filesystem, probably ext2. I had
> > > no idea what this parameter means (and I have never used idmappings).
> > > I guess the amended parameter in this patch is correct.
> >
> > Hi Xiubo,
> >
> > You reviewed Max's "ceph: add owner/capability checks for
> > CEPH_IOC_SET_LAYOUT*" patch.  Would you be able to review this fixup as
> > well?
> >
> > Thanks,
> >
> >                 Ilya

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-12 19:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-27  1:47 [PATCH] ceph: use the mount idmap for the owner checks in the SET_LAYOUT ioctls Zhan Xusheng
2026-07-28 11:30 ` Ilya Dryomov
2026-08-08  6:30   ` Max Kellermann
2026-08-09 17:33     ` Ilya Dryomov
2026-08-12 11:32       ` Xiubo Li
2026-08-12 19:57         ` Ilya Dryomov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®