Skip to content

Commit 4e8771a

Browse files
ChenXiaoSongSteve French
authored andcommitted
smb/server: fix potential null-ptr-deref of lease_ctx_info in smb2_open()
null-ptr-deref will occur when (req_op_level == SMB2_OPLOCK_LEVEL_LEASE) and parse_lease_state() return NULL. Fix this by check if 'lease_ctx_info' is NULL. Additionally, remove the redundant parentheses in parse_durable_handle_context(). Signed-off-by: ChenXiaoSong <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 2186a11 commit 4e8771a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
@@ -3414,7 +3414,7 @@ int smb2_open(struct ksmbd_work *work)
34143414
goto err_out1;
34153415
}
34163416
} else {
3417-
if (req_op_level == SMB2_OPLOCK_LEVEL_LEASE) {
3417+
if (req_op_level == SMB2_OPLOCK_LEVEL_LEASE && lc) {
34183418
if (S_ISDIR(file_inode(filp)->i_mode)) {
34193419
lc->req_state &= ~SMB2_LEASE_WRITE_CACHING_LE;
34203420
lc->is_dir = true;

0 commit comments

Comments
 (0)