* [PATCH] hostfs: handle idmapped mounts
@ 2023-01-28 1:41 Glenn Washburn
2023-02-27 16:33 ` Which branch should this patch be based against? Glenn Washburn
0 siblings, 1 reply; 4+ messages in thread
From: Glenn Washburn @ 2023-01-28 1:41 UTC (permalink / raw)
To: linux-um, Richard Weinberger, Johannes Berg, Anton Ivanov; +Cc: Glenn Washburn
Let hostfs handle idmapped mounts. This allows to have the same hostfs
mount appear in multiple locations with different id mappings.
root@(none):/media# id
uid=0(root) gid=0(root) groups=0(root)
root@(none):/media# mkdir mnt idmapped
root@(none):/media# mount -thostfs -o/home/user hostfs mnt
root@(none):/media# touch mnt/aaa
root@(none):/media# mount-idmapped --map-mount u:`id -u user`:0:1 --map-mount g:`id -g user`:0:1 /media/mnt /media/idmapped
root@(none):/media# ls -l mnt/aaa idmapped/aaa
-rw-r--r-- 1 root root 0 Jan 28 01:23 idmapped/aaa
-rw-r--r-- 1 user user 0 Jan 28 01:23 mnt/aaa
root@(none):/media# touch idmapped/bbb
root@(none):/media# ls -l mnt/bbb idmapped/bbb
-rw-r--r-- 1 root root 0 Jan 28 01:26 idmapped/bbb
-rw-r--r-- 1 user user 0 Jan 28 01:26 mnt/bbb
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
fs/hostfs/hostfs_kern.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index cc1bc6f93a01..876b73e05ac1 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -786,7 +786,7 @@ static int hostfs_permission(struct user_namespace *mnt_userns,
err = access_file(name, r, w, x);
__putname(name);
if (!err)
- err = generic_permission(&init_user_ns, ino, desired);
+ err = generic_permission(mnt_userns, ino, desired);
return err;
}
@@ -800,7 +800,7 @@ static int hostfs_setattr(struct user_namespace *mnt_userns,
int fd = HOSTFS_I(inode)->fd;
- err = setattr_prepare(&init_user_ns, dentry, attr);
+ err = setattr_prepare(mnt_userns, dentry, attr);
if (err)
return err;
@@ -814,11 +814,11 @@ static int hostfs_setattr(struct user_namespace *mnt_userns,
}
if (attr->ia_valid & ATTR_UID) {
attrs.ia_valid |= HOSTFS_ATTR_UID;
- attrs.ia_uid = from_kuid(&init_user_ns, attr->ia_uid);
+ attrs.ia_uid = from_kuid(mnt_userns, attr->ia_uid);
}
if (attr->ia_valid & ATTR_GID) {
attrs.ia_valid |= HOSTFS_ATTR_GID;
- attrs.ia_gid = from_kgid(&init_user_ns, attr->ia_gid);
+ attrs.ia_gid = from_kgid(mnt_userns, attr->ia_gid);
}
if (attr->ia_valid & ATTR_SIZE) {
attrs.ia_valid |= HOSTFS_ATTR_SIZE;
@@ -857,7 +857,7 @@ static int hostfs_setattr(struct user_namespace *mnt_userns,
attr->ia_size != i_size_read(inode))
truncate_setsize(inode, attr->ia_size);
- setattr_copy(&init_user_ns, inode, attr);
+ setattr_copy(mnt_userns, inode, attr);
mark_inode_dirty(inode);
return 0;
}
@@ -991,7 +991,7 @@ static struct file_system_type hostfs_type = {
.name = "hostfs",
.mount = hostfs_read_sb,
.kill_sb = hostfs_kill_sb,
- .fs_flags = 0,
+ .fs_flags = FS_ALLOW_IDMAP,
};
MODULE_ALIAS_FS("hostfs");
--
2.30.2
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Which branch should this patch be based against?
2023-01-28 1:41 [PATCH] hostfs: handle idmapped mounts Glenn Washburn
@ 2023-02-27 16:33 ` Glenn Washburn
2023-02-28 9:01 ` Christian Brauner
0 siblings, 1 reply; 4+ messages in thread
From: Glenn Washburn @ 2023-02-27 16:33 UTC (permalink / raw)
To: linux-um, Richard Weinberger, Johannes Berg, Anton Ivanov
Hi,
On Fri, 27 Jan 2023 19:41:59 -0600
Glenn Washburn <development@efficientek.com> wrote:
> Let hostfs handle idmapped mounts. This allows to have the same hostfs
> mount appear in multiple locations with different id mappings.
This patch is based off of linux-next in the Richard's UML repo[1].
However, I've noticed that this patch needs some modifications to be
applied against the tip[2]. So I'm wondering which branch in what repo
is best to base patches from?
Glenn
[1] git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml.git
[2] git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Which branch should this patch be based against?
2023-02-27 16:33 ` Which branch should this patch be based against? Glenn Washburn
@ 2023-02-28 9:01 ` Christian Brauner
2023-03-01 0:42 ` Glenn Washburn
0 siblings, 1 reply; 4+ messages in thread
From: Christian Brauner @ 2023-02-28 9:01 UTC (permalink / raw)
To: Glenn Washburn
Cc: linux-um, Richard Weinberger, Johannes Berg, Anton Ivanov, Seth Forshee
On Mon, Feb 27, 2023 at 10:33:36AM -0600, Glenn Washburn wrote:
> Hi,
>
> On Fri, 27 Jan 2023 19:41:59 -0600
> Glenn Washburn <development@efficientek.com> wrote:
>
> > Let hostfs handle idmapped mounts. This allows to have the same hostfs
> > mount appear in multiple locations with different id mappings.
>
> This patch is based off of linux-next in the Richard's UML repo[1].
> However, I've noticed that this patch needs some modifications to be
> applied against the tip[2]. So I'm wondering which branch in what repo
> is best to base patches from?
Hey Glenn,
Linus merged my pull request that introduces a dedicated new type for
idmapped mounts into the vfs: struct mnt_idmap. So any branch you base
this on should contain that work. Let me know if you need help with the
conversion.
Christian
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Which branch should this patch be based against?
2023-02-28 9:01 ` Christian Brauner
@ 2023-03-01 0:42 ` Glenn Washburn
0 siblings, 0 replies; 4+ messages in thread
From: Glenn Washburn @ 2023-03-01 0:42 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-um, Richard Weinberger, Johannes Berg, Anton Ivanov, Seth Forshee
On Tue, 28 Feb 2023 10:01:42 +0100
Christian Brauner <brauner@kernel.org> wrote:
> On Mon, Feb 27, 2023 at 10:33:36AM -0600, Glenn Washburn wrote:
> > Hi,
> >
> > On Fri, 27 Jan 2023 19:41:59 -0600
> > Glenn Washburn <development@efficientek.com> wrote:
> >
> > > Let hostfs handle idmapped mounts. This allows to have the same
> > > hostfs mount appear in multiple locations with different id
> > > mappings.
> >
> > This patch is based off of linux-next in the Richard's UML repo[1].
> > However, I've noticed that this patch needs some modifications to be
> > applied against the tip[2]. So I'm wondering which branch in what
> > repo is best to base patches from?
>
> Hey Glenn,
>
> Linus merged my pull request that introduces a dedicated new type for
> idmapped mounts into the vfs: struct mnt_idmap. So any branch you base
> this on should contain that work. Let me know if you need help with
> the conversion.
Hi Christian,
I was about to ask for help yesterday when I was trying to figure it
out, but I think I got it working. However, you probably will have
suggestions for improvement. I'll send an updated version soon, and
make sure you're explicitly included.
Glenn
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-01 0:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-28 1:41 [PATCH] hostfs: handle idmapped mounts Glenn Washburn
2023-02-27 16:33 ` Which branch should this patch be based against? Glenn Washburn
2023-02-28 9:01 ` Christian Brauner
2023-03-01 0:42 ` Glenn Washburn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).