mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
ksmbd: change security id to the one samba used for posix extension
[ Upstream commit 5609bdd9ff ]
Samba set SIDOWNER and SIDUNIX_GROUP in create posix context and
set SIDUNIX_USER/GROUP in other sids for posix extension.
This patch change security id to the one samba used.
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
62e6846ee3
commit
813ef06ea2
@@ -1615,7 +1615,11 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
|
|||||||
memset(buf, 0, sizeof(struct create_posix_rsp));
|
memset(buf, 0, sizeof(struct create_posix_rsp));
|
||||||
buf->ccontext.DataOffset = cpu_to_le16(offsetof
|
buf->ccontext.DataOffset = cpu_to_le16(offsetof
|
||||||
(struct create_posix_rsp, nlink));
|
(struct create_posix_rsp, nlink));
|
||||||
buf->ccontext.DataLength = cpu_to_le32(52);
|
/*
|
||||||
|
* DataLength = nlink(4) + reparse_tag(4) + mode(4) +
|
||||||
|
* domain sid(28) + unix group sid(16).
|
||||||
|
*/
|
||||||
|
buf->ccontext.DataLength = cpu_to_le32(56);
|
||||||
buf->ccontext.NameOffset = cpu_to_le16(offsetof
|
buf->ccontext.NameOffset = cpu_to_le16(offsetof
|
||||||
(struct create_posix_rsp, Name));
|
(struct create_posix_rsp, Name));
|
||||||
buf->ccontext.NameLength = cpu_to_le16(POSIX_CTXT_DATA_LEN);
|
buf->ccontext.NameLength = cpu_to_le16(POSIX_CTXT_DATA_LEN);
|
||||||
@@ -1640,12 +1644,19 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
|
|||||||
buf->nlink = cpu_to_le32(inode->i_nlink);
|
buf->nlink = cpu_to_le32(inode->i_nlink);
|
||||||
buf->reparse_tag = cpu_to_le32(fp->volatile_id);
|
buf->reparse_tag = cpu_to_le32(fp->volatile_id);
|
||||||
buf->mode = cpu_to_le32(inode->i_mode);
|
buf->mode = cpu_to_le32(inode->i_mode);
|
||||||
|
/*
|
||||||
|
* SidBuffer(44) contain two sids(Domain sid(28), UNIX group sid(16)).
|
||||||
|
* Domain sid(28) = revision(1) + num_subauth(1) + authority(6) +
|
||||||
|
* sub_auth(4 * 4(num_subauth)) + RID(4).
|
||||||
|
* UNIX group id(16) = revision(1) + num_subauth(1) + authority(6) +
|
||||||
|
* sub_auth(4 * 1(num_subauth)) + RID(4).
|
||||||
|
*/
|
||||||
id_to_sid(from_kuid_munged(&init_user_ns,
|
id_to_sid(from_kuid_munged(&init_user_ns,
|
||||||
i_uid_into_mnt(user_ns, inode)),
|
i_uid_into_mnt(user_ns, inode)),
|
||||||
SIDNFS_USER, (struct smb_sid *)&buf->SidBuffer[0]);
|
SIDOWNER, (struct smb_sid *)&buf->SidBuffer[0]);
|
||||||
id_to_sid(from_kgid_munged(&init_user_ns,
|
id_to_sid(from_kgid_munged(&init_user_ns,
|
||||||
i_gid_into_mnt(user_ns, inode)),
|
i_gid_into_mnt(user_ns, inode)),
|
||||||
SIDNFS_GROUP, (struct smb_sid *)&buf->SidBuffer[20]);
|
SIDUNIX_GROUP, (struct smb_sid *)&buf->SidBuffer[28]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -3619,10 +3619,15 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
|
|||||||
S_ISDIR(ksmbd_kstat->kstat->mode) ? ATTR_DIRECTORY_LE : ATTR_ARCHIVE_LE;
|
S_ISDIR(ksmbd_kstat->kstat->mode) ? ATTR_DIRECTORY_LE : ATTR_ARCHIVE_LE;
|
||||||
if (d_info->hide_dot_file && d_info->name[0] == '.')
|
if (d_info->hide_dot_file && d_info->name[0] == '.')
|
||||||
posix_info->DosAttributes |= ATTR_HIDDEN_LE;
|
posix_info->DosAttributes |= ATTR_HIDDEN_LE;
|
||||||
|
/*
|
||||||
|
* SidBuffer(32) contain two sids(Domain sid(16), UNIX group sid(16)).
|
||||||
|
* UNIX sid(16) = revision(1) + num_subauth(1) + authority(6) +
|
||||||
|
* sub_auth(4 * 1(num_subauth)) + RID(4).
|
||||||
|
*/
|
||||||
id_to_sid(from_kuid_munged(&init_user_ns, ksmbd_kstat->kstat->uid),
|
id_to_sid(from_kuid_munged(&init_user_ns, ksmbd_kstat->kstat->uid),
|
||||||
SIDNFS_USER, (struct smb_sid *)&posix_info->SidBuffer[0]);
|
SIDUNIX_USER, (struct smb_sid *)&posix_info->SidBuffer[0]);
|
||||||
id_to_sid(from_kgid_munged(&init_user_ns, ksmbd_kstat->kstat->gid),
|
id_to_sid(from_kgid_munged(&init_user_ns, ksmbd_kstat->kstat->gid),
|
||||||
SIDNFS_GROUP, (struct smb_sid *)&posix_info->SidBuffer[20]);
|
SIDUNIX_GROUP, (struct smb_sid *)&posix_info->SidBuffer[16]);
|
||||||
memcpy(posix_info->name, conv_name, conv_len);
|
memcpy(posix_info->name, conv_name, conv_len);
|
||||||
posix_info->name_len = cpu_to_le32(conv_len);
|
posix_info->name_len = cpu_to_le32(conv_len);
|
||||||
posix_info->NextEntryOffset = cpu_to_le32(next_entry_offset);
|
posix_info->NextEntryOffset = cpu_to_le32(next_entry_offset);
|
||||||
|
|||||||
@@ -724,7 +724,8 @@ struct create_posix_rsp {
|
|||||||
__le32 nlink;
|
__le32 nlink;
|
||||||
__le32 reparse_tag;
|
__le32 reparse_tag;
|
||||||
__le32 mode;
|
__le32 mode;
|
||||||
u8 SidBuffer[40];
|
/* SidBuffer contain two sids(Domain sid(28), UNIX group sid(16)) */
|
||||||
|
u8 SidBuffer[44];
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
#define SMB2_LEASE_NONE_LE cpu_to_le32(0x00)
|
#define SMB2_LEASE_NONE_LE cpu_to_le32(0x00)
|
||||||
@@ -1617,7 +1618,8 @@ struct smb2_posix_info {
|
|||||||
__le32 HardLinks;
|
__le32 HardLinks;
|
||||||
__le32 ReparseTag;
|
__le32 ReparseTag;
|
||||||
__le32 Mode;
|
__le32 Mode;
|
||||||
u8 SidBuffer[40];
|
/* SidBuffer contain two sids (UNIX user sid(16), UNIX group sid(16)) */
|
||||||
|
u8 SidBuffer[32];
|
||||||
__le32 name_len;
|
__le32 name_len;
|
||||||
u8 name[1];
|
u8 name[1];
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user