summaryrefslogtreecommitdiff
path: root/fs/ksmbd/ndr.c
diff options
context:
space:
mode:
authorHyunchul Lee <hyc.lee@gmail.com>2021-06-30 18:25:53 +0900
committerNamjae Jeon <namjae.jeon@samsung.com>2021-07-02 16:27:10 +0900
commitaf34983e831587472333e47c86a350a2360c6093 (patch)
tree0db387e95eb0372e4e6ebb6304671603d0c9690a /fs/ksmbd/ndr.c
parentef24c962d0f29036041a007a75bcd0f50233c83e (diff)
ksmbd: add user namespace support
For user namespace support, call vfs functions with struct user_namespace got from struct path. This patch have been tested mannually as below. Create an id-mapped mount using the mount-idmapped utility (https://github.com/brauner/mount-idmapped). $ mount-idmapped --map-mount b:1003:1002:1 /home/foo <EXPORT DIR>/foo (the user, "foo" is 1003, and the user "bar" is 1002). And mount the export directory using cifs with the user, "bar". succeed to create/delete/stat/read/write files and directory in the <EXPORT DIR>/foo. But fail with a bind mount for /home/foo. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/ksmbd/ndr.c')
-rw-r--r--fs/ksmbd/ndr.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/ksmbd/ndr.c b/fs/ksmbd/ndr.c
index bcf13a2aa9d4..cf0df78259c9 100644
--- a/fs/ksmbd/ndr.c
+++ b/fs/ksmbd/ndr.c
@@ -222,7 +222,9 @@ static int ndr_encode_posix_acl_entry(struct ndr *n, struct xattr_smb_acl *acl)
return 0;
}
-int ndr_encode_posix_acl(struct ndr *n, struct inode *inode,
+int ndr_encode_posix_acl(struct ndr *n,
+ struct user_namespace *user_ns,
+ struct inode *inode,
struct xattr_smb_acl *acl,
struct xattr_smb_acl *def_acl)
{
@@ -250,8 +252,8 @@ int ndr_encode_posix_acl(struct ndr *n, struct inode *inode,
ndr_write_int32(n, 0);
}
- ndr_write_int64(n, from_kuid(&init_user_ns, inode->i_uid));
- ndr_write_int64(n, from_kgid(&init_user_ns, inode->i_gid));
+ ndr_write_int64(n, from_kuid(user_ns, inode->i_uid));
+ ndr_write_int64(n, from_kgid(user_ns, inode->i_gid));
ndr_write_int32(n, inode->i_mode);
if (acl) {