Skip to content

Commit 9717d53

Browse files
committed
Merge tag 'v6.12-rc-ksmbd-server-fixes' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French: - fix querying dentry for char/block special files - small cleanup patches * tag 'v6.12-rc-ksmbd-server-fixes' of git://git.samba.org/ksmbd: ksmbd: Correct typos in multiple comments across various files ksmbd: fix open failure from block and char device file ksmbd: remove unsafe_memcpy use in session setup ksmbd: Replace one-element arrays with flexible-array members ksmbd: fix warning: comparison of distinct pointer types lacks a cast
2 parents f04ff5a + 9e676e5 commit 9717d53

File tree

10 files changed

+30
-33
lines changed

10 files changed

+30
-33
lines changed

fs/smb/common/smb2pdu.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Note that, due to trying to use names similar to the protocol specifications,
77
* there are many mixed case field names in the structures below. Although
88
* this does not match typical Linux kernel style, it is necessary to be
9-
* able to match against the protocol specfication.
9+
* able to match against the protocol specification.
1010
*
1111
* SMB2 commands
1212
* Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
@@ -491,7 +491,7 @@ struct smb2_encryption_neg_context {
491491
__le16 ContextType; /* 2 */
492492
__le16 DataLength;
493493
__le32 Reserved;
494-
/* CipherCount usally 2, but can be 3 when AES256-GCM enabled */
494+
/* CipherCount usually 2, but can be 3 when AES256-GCM enabled */
495495
__le16 CipherCount; /* AES128-GCM and AES128-CCM by default */
496496
__le16 Ciphers[];
497497
} __packed;
@@ -1061,7 +1061,7 @@ struct smb2_server_client_notification {
10611061
#define IL_IMPERSONATION cpu_to_le32(0x00000002)
10621062
#define IL_DELEGATE cpu_to_le32(0x00000003)
10631063

1064-
/* File Attrubutes */
1064+
/* File Attributes */
10651065
#define FILE_ATTRIBUTE_READONLY 0x00000001
10661066
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
10671067
#define FILE_ATTRIBUTE_SYSTEM 0x00000004

fs/smb/server/connection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ DECLARE_RWSEM(conn_list_lock);
2525
/**
2626
* ksmbd_conn_free() - free resources of the connection instance
2727
*
28-
* @conn: connection instance to be cleand up
28+
* @conn: connection instance to be cleaned up
2929
*
3030
* During the thread termination, the corresponding conn instance
3131
* resources(sock/memory) are released and finally the conn object is freed.

fs/smb/server/ksmbd_netlink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ struct ksmbd_tree_connect_response {
213213
};
214214

215215
/*
216-
* IPC Request struture to disconnect tree connection.
216+
* IPC Request structure to disconnect tree connection.
217217
*/
218218
struct ksmbd_tree_disconnect_request {
219219
__u64 session_id; /* session id */

fs/smb/server/oplock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
796796
/**
797797
* smb2_lease_break_noti() - break lease when a new client request
798798
* write lease
799-
* @opinfo: conains lease state information
799+
* @opinfo: contains lease state information
800800
*
801801
* Return: 0 on success, otherwise error
802802
*/
@@ -1484,7 +1484,7 @@ void create_lease_buf(u8 *rbuf, struct lease *lease)
14841484
}
14851485

14861486
/**
1487-
* parse_lease_state() - parse lease context containted in file open request
1487+
* parse_lease_state() - parse lease context contained in file open request
14881488
* @open_req: buffer containing smb2 file open(create) request
14891489
*
14901490
* Return: allocated lease context object on success, otherwise NULL

fs/smb/server/server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static void handle_ksmbd_work(struct work_struct *wk)
279279

280280
/**
281281
* queue_ksmbd_work() - queue a smb request to worker thread queue
282-
* for proccessing smb command and sending response
282+
* for processing smb command and sending response
283283
* @conn: connection instance
284284
*
285285
* read remaining data from socket create and submit work.

fs/smb/server/smb2pdu.c

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,8 +1335,7 @@ static int ntlm_negotiate(struct ksmbd_work *work,
13351335
return rc;
13361336

13371337
sz = le16_to_cpu(rsp->SecurityBufferOffset);
1338-
chgblob =
1339-
(struct challenge_message *)((char *)&rsp->hdr.ProtocolId + sz);
1338+
chgblob = (struct challenge_message *)rsp->Buffer;
13401339
memset(chgblob, 0, sizeof(struct challenge_message));
13411340

13421341
if (!work->conn->use_spnego) {
@@ -1369,9 +1368,7 @@ static int ntlm_negotiate(struct ksmbd_work *work,
13691368
goto out;
13701369
}
13711370

1372-
sz = le16_to_cpu(rsp->SecurityBufferOffset);
1373-
unsafe_memcpy((char *)&rsp->hdr.ProtocolId + sz, spnego_blob, spnego_blob_len,
1374-
/* alloc is larger than blob, see smb2_allocate_rsp_buf() */);
1371+
memcpy(rsp->Buffer, spnego_blob, spnego_blob_len);
13751372
rsp->SecurityBufferLength = cpu_to_le16(spnego_blob_len);
13761373

13771374
out:
@@ -1453,10 +1450,7 @@ static int ntlm_authenticate(struct ksmbd_work *work,
14531450
if (rc)
14541451
return -ENOMEM;
14551452

1456-
sz = le16_to_cpu(rsp->SecurityBufferOffset);
1457-
unsafe_memcpy((char *)&rsp->hdr.ProtocolId + sz, spnego_blob,
1458-
spnego_blob_len,
1459-
/* alloc is larger than blob, see smb2_allocate_rsp_buf() */);
1453+
memcpy(rsp->Buffer, spnego_blob, spnego_blob_len);
14601454
rsp->SecurityBufferLength = cpu_to_le16(spnego_blob_len);
14611455
kfree(spnego_blob);
14621456
}
@@ -2058,18 +2052,20 @@ int smb2_tree_connect(struct ksmbd_work *work)
20582052
* @access: file access flags
20592053
* @disposition: file disposition flags
20602054
* @may_flags: set with MAY_ flags
2061-
* @is_dir: is creating open flags for directory
2055+
* @coptions: file creation options
2056+
* @mode: file mode
20622057
*
20632058
* Return: file open flags
20642059
*/
20652060
static int smb2_create_open_flags(bool file_present, __le32 access,
20662061
__le32 disposition,
20672062
int *may_flags,
2068-
bool is_dir)
2063+
__le32 coptions,
2064+
umode_t mode)
20692065
{
20702066
int oflags = O_NONBLOCK | O_LARGEFILE;
20712067

2072-
if (is_dir) {
2068+
if (coptions & FILE_DIRECTORY_FILE_LE || S_ISDIR(mode)) {
20732069
access &= ~FILE_WRITE_DESIRE_ACCESS_LE;
20742070
ksmbd_debug(SMB, "Discard write access to a directory\n");
20752071
}
@@ -2086,7 +2082,7 @@ static int smb2_create_open_flags(bool file_present, __le32 access,
20862082
*may_flags = MAY_OPEN | MAY_READ;
20872083
}
20882084

2089-
if (access == FILE_READ_ATTRIBUTES_LE)
2085+
if (access == FILE_READ_ATTRIBUTES_LE || S_ISBLK(mode) || S_ISCHR(mode))
20902086
oflags |= O_PATH;
20912087

20922088
if (file_present) {
@@ -3181,8 +3177,8 @@ int smb2_open(struct ksmbd_work *work)
31813177
open_flags = smb2_create_open_flags(file_present, daccess,
31823178
req->CreateDisposition,
31833179
&may_flags,
3184-
req->CreateOptions & FILE_DIRECTORY_FILE_LE ||
3185-
(file_present && S_ISDIR(d_inode(path.dentry)->i_mode)));
3180+
req->CreateOptions,
3181+
file_present ? d_inode(path.dentry)->i_mode : 0);
31863182

31873183
if (!test_tree_conn_flag(tcon, KSMBD_TREE_CONN_FLAG_WRITABLE)) {
31883184
if (open_flags & (O_CREAT | O_TRUNC)) {
@@ -3531,8 +3527,9 @@ int smb2_open(struct ksmbd_work *work)
35313527
memcpy(fp->create_guid, dh_info.CreateGuid,
35323528
SMB2_CREATE_GUID_SIZE);
35333529
if (dh_info.timeout)
3534-
fp->durable_timeout = min(dh_info.timeout,
3535-
DURABLE_HANDLE_MAX_TIMEOUT);
3530+
fp->durable_timeout =
3531+
min_t(unsigned int, dh_info.timeout,
3532+
DURABLE_HANDLE_MAX_TIMEOUT);
35363533
else
35373534
fp->durable_timeout = 60;
35383535
}
@@ -4586,7 +4583,7 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
45864583
path = &fp->filp->f_path;
45874584
/* single EA entry is requested with given user.* name */
45884585
if (req->InputBufferLength) {
4589-
if (le32_to_cpu(req->InputBufferLength) <
4586+
if (le32_to_cpu(req->InputBufferLength) <=
45904587
sizeof(struct smb2_ea_info_req))
45914588
return -EINVAL;
45924589

@@ -8090,7 +8087,7 @@ int smb2_ioctl(struct ksmbd_work *work)
80908087
goto out;
80918088
}
80928089

8093-
if (in_buf_len < sizeof(struct copychunk_ioctl_req)) {
8090+
if (in_buf_len <= sizeof(struct copychunk_ioctl_req)) {
80948091
ret = -EINVAL;
80958092
goto out;
80968093
}

fs/smb/server/smb2pdu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ struct copychunk_ioctl_req {
194194
__le64 ResumeKey[3];
195195
__le32 ChunkCount;
196196
__le32 Reserved;
197-
__u8 Chunks[1]; /* array of srv_copychunk */
197+
__u8 Chunks[]; /* array of srv_copychunk */
198198
} __packed;
199199

200200
struct srv_copychunk {
@@ -370,7 +370,7 @@ struct smb2_file_attr_tag_info {
370370
struct smb2_ea_info_req {
371371
__le32 NextEntryOffset;
372372
__u8 EaNameLength;
373-
char name[1];
373+
char name[];
374374
} __packed; /* level 15 Query */
375375

376376
struct smb2_ea_info {

fs/smb/server/smb_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,
488488
* @shortname: destination short filename
489489
*
490490
* Return: shortname length or 0 when source long name is '.' or '..'
491-
* TODO: Though this function comforms the restriction of 8.3 Filename spec,
491+
* TODO: Though this function conforms the restriction of 8.3 Filename spec,
492492
* but the result is different with Windows 7's one. need to check.
493493
*/
494494
int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname,

fs/smb/server/vfs_cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ struct ksmbd_file {
100100
struct list_head blocked_works;
101101
struct list_head lock_list;
102102

103-
int durable_timeout;
104-
int durable_scavenger_timeout;
103+
unsigned int durable_timeout;
104+
unsigned int durable_scavenger_timeout;
105105

106106
/* if ls is happening on directory, below is valid*/
107107
struct ksmbd_readdir_data readdir_data;

fs/smb/server/xattr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ struct xattr_ntacl {
9999
__u8 posix_acl_hash[XATTR_SD_HASH_SIZE]; /* 64bytes hash for posix acl */
100100
};
101101

102-
/* DOS ATTRIBUITE XATTR PREFIX */
102+
/* DOS ATTRIBUTE XATTR PREFIX */
103103
#define DOS_ATTRIBUTE_PREFIX "DOSATTRIB"
104104
#define DOS_ATTRIBUTE_PREFIX_LEN (sizeof(DOS_ATTRIBUTE_PREFIX) - 1)
105105
#define XATTR_NAME_DOS_ATTRIBUTE (XATTR_USER_PREFIX DOS_ATTRIBUTE_PREFIX)

0 commit comments

Comments
 (0)