Skip to content

Commit 3cdc20e

Browse files
Christian Braunersmfrench
authored andcommitted
ksmbd: fix translation in create_posix_rsp_buf()
When transferring ownership information to the client the k*ids are translated into raw *ids before they are sent over the wire. The function currently erroneously translates the k*ids according to the mount's idmapping. Instead, reporting the owning *ids to userspace the underlying k*ids need to be mapped up in the caller's user namespace. This is how stat() works. The caller in this instance is ksmbd itself and ksmbd always runs in the initial user namespace. Translate according to that taking any potential idmapped mounts into account. Switch to from_k*id_munged() which ensures that the overflow*id is returned instead of the (*id_t)-1 when the k*id can't be translated. Cc: Steve French <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Namjae Jeon <[email protected]> Cc: Hyunchul Lee <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: [email protected] Signed-off-by: Christian Brauner <[email protected]> Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 475d6f9 commit 3cdc20e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/ksmbd/oplock.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,9 +1614,11 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
16141614
buf->nlink = cpu_to_le32(inode->i_nlink);
16151615
buf->reparse_tag = cpu_to_le32(fp->volatile_id);
16161616
buf->mode = cpu_to_le32(inode->i_mode);
1617-
id_to_sid(from_kuid(user_ns, inode->i_uid),
1617+
id_to_sid(from_kuid_munged(&init_user_ns,
1618+
i_uid_into_mnt(user_ns, inode)),
16181619
SIDNFS_USER, (struct smb_sid *)&buf->SidBuffer[0]);
1619-
id_to_sid(from_kgid(user_ns, inode->i_gid),
1620+
id_to_sid(from_kgid_munged(&init_user_ns,
1621+
i_gid_into_mnt(user_ns, inode)),
16201622
SIDNFS_GROUP, (struct smb_sid *)&buf->SidBuffer[20]);
16211623
}
16221624

0 commit comments

Comments
 (0)