summaryrefslogtreecommitdiff
path: root/fs/ksmbd/vfs_cache.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/vfs_cache.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/vfs_cache.c')
-rw-r--r--fs/ksmbd/vfs_cache.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/ksmbd/vfs_cache.c b/fs/ksmbd/vfs_cache.c
index 5c9efcfaeb5c..1941ad3f5aa5 100644
--- a/fs/ksmbd/vfs_cache.c
+++ b/fs/ksmbd/vfs_cache.c
@@ -251,7 +251,8 @@ static void __ksmbd_inode_close(struct ksmbd_file *fp)
filp = fp->filp;
if (ksmbd_stream_fd(fp) && (ci->m_flags & S_DEL_ON_CLS_STREAM)) {
ci->m_flags &= ~S_DEL_ON_CLS_STREAM;
- err = ksmbd_vfs_remove_xattr(filp->f_path.dentry,
+ err = ksmbd_vfs_remove_xattr(file_mnt_user_ns(filp),
+ filp->f_path.dentry,
fp->stream.name);
if (err)
pr_err("remove xattr failed : %s\n",
@@ -265,7 +266,7 @@ static void __ksmbd_inode_close(struct ksmbd_file *fp)
dir = dentry->d_parent;
ci->m_flags &= ~(S_DEL_ON_CLS | S_DEL_PENDING);
write_unlock(&ci->m_lock);
- ksmbd_vfs_unlink(dir, dentry);
+ ksmbd_vfs_unlink(file_mnt_user_ns(filp), dir, dentry);
write_lock(&ci->m_lock);
}
write_unlock(&ci->m_lock);