Skip to content

Commit 3498e7f

Browse files
committed
Merge tag '5.16-rc2-ksmbd-fixes' of git://git.samba.org/ksmbd
Pull ksmbd fixes from Steve French: "Five ksmbd server fixes, four of them for stable: - memleak fix - fix for default data stream on filesystems that don't support xattr - error logging fix - session setup fix - minor doc cleanup" * tag '5.16-rc2-ksmbd-fixes' of git://git.samba.org/ksmbd: ksmbd: fix memleak in get_file_stream_info() ksmbd: contain default data stream even if xattr is empty ksmbd: downgrade addition info error msg to debug in smb2_get_info_sec() docs: filesystem: cifs: ksmbd: Fix small layout issues ksmbd: Fix an error handling path in 'smb2_sess_setup()'
2 parents 00169a9 + 178ca6f commit 3498e7f

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

Documentation/filesystems/cifs/ksmbd.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ ksmbd.mountd (user space daemon)
5050
--------------------------------
5151

5252
ksmbd.mountd is userspace process to, transfer user account and password that
53-
are registered using ksmbd.adduser(part of utils for user space). Further it
53+
are registered using ksmbd.adduser (part of utils for user space). Further it
5454
allows sharing information parameters that parsed from smb.conf to ksmbd in
5555
kernel. For the execution part it has a daemon which is continuously running
5656
and connected to the kernel interface using netlink socket, it waits for the
57-
requests(dcerpc and share/user info). It handles RPC calls (at a minimum few
57+
requests (dcerpc and share/user info). It handles RPC calls (at a minimum few
5858
dozen) that are most important for file server from NetShareEnum and
5959
NetServerGetInfo. Complete DCE/RPC response is prepared from the user space
6060
and passed over to the associated kernel thread for the client.
@@ -154,11 +154,11 @@ Each layer
154154
1. Enable all component prints
155155
# sudo ksmbd.control -d "all"
156156

157-
2. Enable one of components(smb, auth, vfs, oplock, ipc, conn, rdma)
157+
2. Enable one of components (smb, auth, vfs, oplock, ipc, conn, rdma)
158158
# sudo ksmbd.control -d "smb"
159159

160-
3. Show what prints are enable.
161-
# cat/sys/class/ksmbd-control/debug
160+
3. Show what prints are enabled.
161+
# cat /sys/class/ksmbd-control/debug
162162
[smb] auth vfs oplock ipc conn [rdma]
163163

164164
4. Disable prints:

fs/ksmbd/smb2pdu.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,8 +1697,10 @@ int smb2_sess_setup(struct ksmbd_work *work)
16971697
negblob_off = le16_to_cpu(req->SecurityBufferOffset);
16981698
negblob_len = le16_to_cpu(req->SecurityBufferLength);
16991699
if (negblob_off < offsetof(struct smb2_sess_setup_req, Buffer) ||
1700-
negblob_len < offsetof(struct negotiate_message, NegotiateFlags))
1701-
return -EINVAL;
1700+
negblob_len < offsetof(struct negotiate_message, NegotiateFlags)) {
1701+
rc = -EINVAL;
1702+
goto out_err;
1703+
}
17021704

17031705
negblob = (struct negotiate_message *)((char *)&req->hdr.ProtocolId +
17041706
negblob_off);
@@ -4457,6 +4459,12 @@ static void get_file_stream_info(struct ksmbd_work *work,
44574459
&stat);
44584460
file_info = (struct smb2_file_stream_info *)rsp->Buffer;
44594461

4462+
buf_free_len =
4463+
smb2_calc_max_out_buf_len(work, 8,
4464+
le32_to_cpu(req->OutputBufferLength));
4465+
if (buf_free_len < 0)
4466+
goto out;
4467+
44604468
xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
44614469
if (xattr_list_len < 0) {
44624470
goto out;
@@ -4465,12 +4473,6 @@ static void get_file_stream_info(struct ksmbd_work *work,
44654473
goto out;
44664474
}
44674475

4468-
buf_free_len =
4469-
smb2_calc_max_out_buf_len(work, 8,
4470-
le32_to_cpu(req->OutputBufferLength));
4471-
if (buf_free_len < 0)
4472-
goto out;
4473-
44744476
while (idx < xattr_list_len) {
44754477
stream_name = xattr_list + idx;
44764478
streamlen = strlen(stream_name);
@@ -4496,8 +4498,10 @@ static void get_file_stream_info(struct ksmbd_work *work,
44964498
":%s", &stream_name[XATTR_NAME_STREAM_LEN]);
44974499

44984500
next = sizeof(struct smb2_file_stream_info) + streamlen * 2;
4499-
if (next > buf_free_len)
4501+
if (next > buf_free_len) {
4502+
kfree(stream_buf);
45004503
break;
4504+
}
45014505

45024506
file_info = (struct smb2_file_stream_info *)&rsp->Buffer[nbytes];
45034507
streamlen = smbConvertToUTF16((__le16 *)file_info->StreamName,
@@ -4514,6 +4518,7 @@ static void get_file_stream_info(struct ksmbd_work *work,
45144518
file_info->NextEntryOffset = cpu_to_le32(next);
45154519
}
45164520

4521+
out:
45174522
if (!S_ISDIR(stat.mode) &&
45184523
buf_free_len >= sizeof(struct smb2_file_stream_info) + 7 * 2) {
45194524
file_info = (struct smb2_file_stream_info *)
@@ -4522,14 +4527,13 @@ static void get_file_stream_info(struct ksmbd_work *work,
45224527
"::$DATA", 7, conn->local_nls, 0);
45234528
streamlen *= 2;
45244529
file_info->StreamNameLength = cpu_to_le32(streamlen);
4525-
file_info->StreamSize = 0;
4526-
file_info->StreamAllocationSize = 0;
4530+
file_info->StreamSize = cpu_to_le64(stat.size);
4531+
file_info->StreamAllocationSize = cpu_to_le64(stat.blocks << 9);
45274532
nbytes += sizeof(struct smb2_file_stream_info) + streamlen;
45284533
}
45294534

45304535
/* last entry offset should be 0 */
45314536
file_info->NextEntryOffset = 0;
4532-
out:
45334537
kvfree(xattr_list);
45344538

45354539
rsp->OutputBufferLength = cpu_to_le32(nbytes);
@@ -5068,7 +5072,7 @@ static int smb2_get_info_sec(struct ksmbd_work *work,
50685072
if (addition_info & ~(OWNER_SECINFO | GROUP_SECINFO | DACL_SECINFO |
50695073
PROTECTED_DACL_SECINFO |
50705074
UNPROTECTED_DACL_SECINFO)) {
5071-
pr_err("Unsupported addition info: 0x%x)\n",
5075+
ksmbd_debug(SMB, "Unsupported addition info: 0x%x)\n",
50725076
addition_info);
50735077

50745078
pntsd->revision = cpu_to_le16(1);

0 commit comments

Comments
 (0)