Skip to content

Commit 826c484

Browse files
committed
Merge tag '6.7-rc-smb3-server-part2' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French: - slab out of bounds fix in ACL handling - fix malformed request oops - minor doc fix * tag '6.7-rc-smb3-server-part2' of git://git.samba.org/ksmbd: ksmbd: handle malformed smb1 message ksmbd: fix kernel-doc comment of ksmbd_vfs_kern_path_locked() ksmbd: fix slab out of bounds write in smb_inherit_dacl()
2 parents e21165b + 5a5409d commit 826c484

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

fs/smb/server/smb_common.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,22 @@ static int smb1_allocate_rsp_buf(struct ksmbd_work *work)
366366
return 0;
367367
}
368368

369+
/**
370+
* set_smb1_rsp_status() - set error type in smb response header
371+
* @work: smb work containing smb response header
372+
* @err: error code to set in response
373+
*/
374+
static void set_smb1_rsp_status(struct ksmbd_work *work, __le32 err)
375+
{
376+
work->send_no_response = 1;
377+
}
378+
369379
static struct smb_version_ops smb1_server_ops = {
370380
.get_cmd_val = get_smb1_cmd_val,
371381
.init_rsp_hdr = init_smb1_rsp_hdr,
372382
.allocate_rsp_buf = smb1_allocate_rsp_buf,
373383
.check_user_session = smb1_check_user_session,
384+
.set_rsp_status = set_smb1_rsp_status,
374385
};
375386

376387
static int smb1_negotiate(struct ksmbd_work *work)

fs/smb/server/smbacl.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
11071107
struct smb_acl *pdacl;
11081108
struct smb_sid *powner_sid = NULL, *pgroup_sid = NULL;
11091109
int powner_sid_size = 0, pgroup_sid_size = 0, pntsd_size;
1110+
int pntsd_alloc_size;
11101111

11111112
if (parent_pntsd->osidoffset) {
11121113
powner_sid = (struct smb_sid *)((char *)parent_pntsd +
@@ -1119,9 +1120,10 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
11191120
pgroup_sid_size = 1 + 1 + 6 + (pgroup_sid->num_subauth * 4);
11201121
}
11211122

1122-
pntsd = kzalloc(sizeof(struct smb_ntsd) + powner_sid_size +
1123-
pgroup_sid_size + sizeof(struct smb_acl) +
1124-
nt_size, GFP_KERNEL);
1123+
pntsd_alloc_size = sizeof(struct smb_ntsd) + powner_sid_size +
1124+
pgroup_sid_size + sizeof(struct smb_acl) + nt_size;
1125+
1126+
pntsd = kzalloc(pntsd_alloc_size, GFP_KERNEL);
11251127
if (!pntsd) {
11261128
rc = -ENOMEM;
11271129
goto free_aces_base;
@@ -1136,6 +1138,27 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
11361138
pntsd->gsidoffset = parent_pntsd->gsidoffset;
11371139
pntsd->dacloffset = parent_pntsd->dacloffset;
11381140

1141+
if ((u64)le32_to_cpu(pntsd->osidoffset) + powner_sid_size >
1142+
pntsd_alloc_size) {
1143+
rc = -EINVAL;
1144+
kfree(pntsd);
1145+
goto free_aces_base;
1146+
}
1147+
1148+
if ((u64)le32_to_cpu(pntsd->gsidoffset) + pgroup_sid_size >
1149+
pntsd_alloc_size) {
1150+
rc = -EINVAL;
1151+
kfree(pntsd);
1152+
goto free_aces_base;
1153+
}
1154+
1155+
if ((u64)le32_to_cpu(pntsd->dacloffset) + sizeof(struct smb_acl) + nt_size >
1156+
pntsd_alloc_size) {
1157+
rc = -EINVAL;
1158+
kfree(pntsd);
1159+
goto free_aces_base;
1160+
}
1161+
11391162
if (pntsd->osidoffset) {
11401163
struct smb_sid *owner_sid = (struct smb_sid *)((char *)pntsd +
11411164
le32_to_cpu(pntsd->osidoffset));

fs/smb/server/vfs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,9 +1177,10 @@ static int ksmbd_vfs_lookup_in_dir(const struct path *dir, char *name,
11771177

11781178
/**
11791179
* ksmbd_vfs_kern_path_locked() - lookup a file and get path info
1180-
* @name: file path that is relative to share
1181-
* @flags: lookup flags
1182-
* @path: if lookup succeed, return path info
1180+
* @name: file path that is relative to share
1181+
* @flags: lookup flags
1182+
* @parent_path: if lookup succeed, return parent_path info
1183+
* @path: if lookup succeed, return path info
11831184
* @caseless: caseless filename lookup
11841185
*
11851186
* Return: 0 on success, otherwise error

0 commit comments

Comments
 (0)