ksmbd: fix warning: comparison of distinct pointer types lacks a cast
Subsystems (2)
Namjae Jeon
maintainerPATCH 1/1 ksmbd: fix warning: comparison of distinct pointer types lacks a cast
smb2pdu.c: In function ‘smb2_open’:./include/linux/minmax.h:20:28: warning: comparison of distinct pointer types lacks a cast
20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
| ^~./include/linux/minmax.h:26:4: note: in expansion of macro ‘__typecheck’
26 | (__typecheck(x, y) && __no_side_effects(x, y))
| ^~~~~~~~~~~
./include/linux/minmax.h:36:24: note: in expansion of macro ‘__safe_cmp’
36 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~
./include/linux/minmax.h:45:19: note: in expansion of macro ‘__careful_cmp’
45 | #define min(x, y) __careful_cmp(x, y, <)
| ^~~~~~~~~~~~~/home/linkinjeon/git/smbd_work/ksmbd/smb2pdu.c:3713:27: note: in expansion of macro ‘min’
3713 | fp->durable_timeout = min(dh_info.timeout,
--- fs/smb/server/smb2pdu.c | 5 +++-- fs/smb/server/vfs_cache.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-)
fs/smb/server/smb2pdu.c +3 -2
@@ -3531,8 +3531,9 @@ int smb2_open(struct ksmbd_work *work)memcpy (fp->create_guid, dh_info.CreateGuid,SMB2_CREATE_GUID_SIZE );if (dh_info.timeout) - fp->durable_timeout =min (dh_info.timeout, -DURABLE_HANDLE_MAX_TIMEOUT ); + fp->durable_timeout = + min_t(unsigned int, dh_info.timeout, +DURABLE_HANDLE_MAX_TIMEOUT );else fp->durable_timeout =60 ; }
fs/smb/server/vfs_cache.h +2 -2
@@ -100,8 +100,8 @@ struct ksmbd_file {struct list_head blocked_works;struct list_head lock_list; -int durable_timeout; -int durable_scavenger_timeout; +unsigned int durable_timeout; +unsigned int durable_scavenger_timeout;/* if ls is happening on directory, below is valid*/ struct ksmbd_readdir_data readdir_data;
Signature · 1 line
2.25.1
Namjae Jeon
maintainerPATCH 1/1 ksmbd: remove unsafe_memcpy use in session setup
Kees pointed out to just use directly ->Buffer instead of pointing ->Buffer using offset not to use unsafe_memcpy().
--- fs/smb/server/smb2pdu.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
fs/smb/server/smb2pdu.c +3 -9
@@ -1335,8 +1335,7 @@ static int ntlm_negotiate(struct ksmbd_work *work,return rc; sz =le16_to_cpu (rsp->SecurityBufferOffset); - chgblob = - (struct challenge_message *)((char *)&rsp->hdr.ProtocolId + sz); + chgblob = (struct challenge_message *)rsp->Buffer;memset (chgblob,0 ,sizeof (struct challenge_message ));if (!work->conn->use_spnego) {
@@ -1369,9 +1368,7 @@ static int ntlm_negotiate(struct ksmbd_work *work, goto out; } - sz =le16_to_cpu (rsp->SecurityBufferOffset); -unsafe_memcpy ((char *)&rsp->hdr.ProtocolId + sz, spnego_blob, spnego_blob_len, - /* alloc is larger than blob, see smb2_allocate_rsp_buf() */); +memcpy (rsp->Buffer, spnego_blob, spnego_blob_len); rsp->SecurityBufferLength =cpu_to_le16 (spnego_blob_len); out:
@@ -1453,10 +1450,7 @@ static int ntlm_authenticate(struct ksmbd_work *work,if (rc)return -ENOMEM ; - sz =le16_to_cpu (rsp->SecurityBufferOffset); -unsafe_memcpy ((char *)&rsp->hdr.ProtocolId + sz, spnego_blob, - spnego_blob_len, - /* alloc is larger than blob, see smb2_allocate_rsp_buf() */); +memcpy (rsp->Buffer, spnego_blob, spnego_blob_len); rsp->SecurityBufferLength =cpu_to_le16 (spnego_blob_len);kfree (spnego_blob); }
Signature · 1 line
2.25.1
Namjae Jeon
maintainerPATCH 1/1 ksmbd: fix open failure from block and char device file
In reply to Namjae Jeonchar/block device file can't be opened with dentry_open() if device driver is not loaded. Use O_PATH flags for fake openning file to handle it if file is a block or char file.
--- fs/smb/server/smb2pdu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
fs/smb/server/smb2pdu.c +8 -6
@@ -2052,18 +2052,20 @@ int smb2_tree_connect(struct ksmbd_work *work)* @access: file access flags * @disposition: file disposition flags * @may_flags: set with MAY_ flags -* @is_dir: is creating open flags for directory +* @coptions: file creation options +* @mode: file mode * * Return: file open flags */ static int smb2_create_open_flags (bool file_present,__le32 access,__le32 disposition,int *may_flags, -bool is_dir) +__le32 coptions, +umode_t mode) {int oflags =O_NONBLOCK |O_LARGEFILE ; -if (is_dir) { +if (coptions &FILE_DIRECTORY_FILE_LE ||S_ISDIR (mode)) { access &= ~FILE_WRITE_DESIRE_ACCESS_LE ;ksmbd_debug (SMB ,"Discard write access to a directory\n" ); }
@@ -2080,7 +2082,7 @@ static int smb2_create_open_flags(bool file_present, __le32 access, *may_flags =MAY_OPEN |MAY_READ ; } -if (access ==FILE_READ_ATTRIBUTES_LE ) +if (access ==FILE_READ_ATTRIBUTES_LE ||S_ISBLK (mode) ||S_ISCHR (mode)) oflags |=O_PATH ;if (file_present) {
@@ -3175,8 +3177,8 @@ int smb2_open(struct ksmbd_work *work) open_flags =smb2_create_open_flags (file_present, daccess, req->CreateDisposition, &may_flags, - req->CreateOptions &FILE_DIRECTORY_FILE_LE || - (file_present &&S_ISDIR (d_inode (path.dentry)->i_mode))); + req->CreateOptions, + file_present ?d_inode (path.dentry)->i_mode :0 );if (!test_tree_conn_flag (tcon,KSMBD_TREE_CONN_FLAG_WRITABLE )) {if (open_flags & (O_CREAT |O_TRUNC )) {
Signature · 1 line
2.25.1