Skip to content

Commit 780bdc1

Browse files
committed
Merge tag '6.11-rc5-server-fixes' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French: - query directory flex array fix - fix potential null ptr reference in open - fix error message in some open cases - two minor cleanups * tag '6.11-rc5-server-fixes' of git://git.samba.org/ksmbd: smb/server: update misguided comment of smb2_allocate_rsp_buf() smb/server: remove useless assignment of 'file_present' in smb2_open() smb/server: fix potential null-ptr-deref of lease_ctx_info in smb2_open() smb/server: fix return value of smb2_open() ksmbd: the buffer of smb2 query dir response has at least 1 byte
2 parents 48fb4b3 + 2b7e057 commit 780bdc1

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

fs/smb/server/oplock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ void create_lease_buf(u8 *rbuf, struct lease *lease)
15101510
* parse_lease_state() - parse lease context containted in file open request
15111511
* @open_req: buffer containing smb2 file open(create) request
15121512
*
1513-
* Return: oplock state, -ENOENT if create lease context not found
1513+
* Return: allocated lease context object on success, otherwise NULL
15141514
*/
15151515
struct lease_ctx_info *parse_lease_state(void *open_req)
15161516
{

fs/smb/server/smb2pdu.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ int init_smb2_rsp_hdr(struct ksmbd_work *work)
519519
* smb2_allocate_rsp_buf() - allocate smb2 response buffer
520520
* @work: smb work containing smb request buffer
521521
*
522-
* Return: 0 on success, otherwise -ENOMEM
522+
* Return: 0 on success, otherwise error
523523
*/
524524
int smb2_allocate_rsp_buf(struct ksmbd_work *work)
525525
{
@@ -2770,8 +2770,8 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
27702770
}
27712771
}
27722772

2773-
if (((lc && (lc->req_state & SMB2_LEASE_HANDLE_CACHING_LE)) ||
2774-
req_op_level == SMB2_OPLOCK_LEVEL_BATCH)) {
2773+
if ((lc && (lc->req_state & SMB2_LEASE_HANDLE_CACHING_LE)) ||
2774+
req_op_level == SMB2_OPLOCK_LEVEL_BATCH) {
27752775
dh_info->CreateGuid =
27762776
durable_v2_blob->CreateGuid;
27772777
dh_info->persistent =
@@ -2791,8 +2791,8 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
27912791
goto out;
27922792
}
27932793

2794-
if (((lc && (lc->req_state & SMB2_LEASE_HANDLE_CACHING_LE)) ||
2795-
req_op_level == SMB2_OPLOCK_LEVEL_BATCH)) {
2794+
if ((lc && (lc->req_state & SMB2_LEASE_HANDLE_CACHING_LE)) ||
2795+
req_op_level == SMB2_OPLOCK_LEVEL_BATCH) {
27962796
ksmbd_debug(SMB, "Request for durable open\n");
27972797
dh_info->type = dh_idx;
27982798
}
@@ -3096,7 +3096,6 @@ int smb2_open(struct ksmbd_work *work)
30963096
goto err_out;
30973097
}
30983098

3099-
file_present = true;
31003099
idmap = mnt_idmap(path.mnt);
31013100
} else {
31023101
if (rc != -ENOENT)
@@ -3414,7 +3413,7 @@ int smb2_open(struct ksmbd_work *work)
34143413
goto err_out1;
34153414
}
34163415
} else {
3417-
if (req_op_level == SMB2_OPLOCK_LEVEL_LEASE) {
3416+
if (req_op_level == SMB2_OPLOCK_LEVEL_LEASE && lc) {
34183417
if (S_ISDIR(file_inode(filp)->i_mode)) {
34193418
lc->req_state &= ~SMB2_LEASE_WRITE_CACHING_LE;
34203419
lc->is_dir = true;
@@ -3713,7 +3712,7 @@ int smb2_open(struct ksmbd_work *work)
37133712
kfree(name);
37143713
kfree(lc);
37153714

3716-
return 0;
3715+
return rc;
37173716
}
37183717

37193718
static int readdir_info_level_struct_sz(int info_level)
@@ -4409,7 +4408,8 @@ int smb2_query_dir(struct ksmbd_work *work)
44094408
rsp->OutputBufferLength = cpu_to_le32(0);
44104409
rsp->Buffer[0] = 0;
44114410
rc = ksmbd_iov_pin_rsp(work, (void *)rsp,
4412-
sizeof(struct smb2_query_directory_rsp));
4411+
offsetof(struct smb2_query_directory_rsp, Buffer)
4412+
+ 1);
44134413
if (rc)
44144414
goto err_out;
44154415
} else {

0 commit comments

Comments
 (0)