Skip to content

Commit 1f0c621

Browse files
rohiths-msftksacilotto
authored andcommitted
smb3: Call cifs reconnect from demultiplex thread
BugLink: https://bugs.launchpad.net/bugs/1908562 commit de9ac0a upstream. cifs_reconnect needs to be called only from demultiplex thread. skip cifs_reconnect in offload thread. So, cifs_reconnect will be called by demultiplex thread in subsequent request. These patches address a problem found during decryption offload: CIFS: VFS: trying to dequeue a deleted mid that can cause a refcount use after free: [ 1271.389453] Workqueue: smb3decryptd smb2_decrypt_offload [cifs] [ 1271.389456] RIP: 0010:refcount_warn_saturate+0xae/0xf0 [ 1271.389457] Code: fa 1d 6a 01 01 e8 c7 44 b1 ff 0f 0b 5d c3 80 3d e7 1d 6a 01 00 75 91 48 c7 c7 d8 be 1d a2 c6 05 d7 1d 6a 01 01 e8 a7 44 b1 ff <0f> 0b 5d c3 80 3d c5 1d 6a 01 00 0f 85 6d ff ff ff 48 c7 c7 30 bf [ 1271.389458] RSP: 0018:ffffa4cdc1f87e30 EFLAGS: 00010286 [ 1271.389458] RAX: 0000000000000000 RBX: ffff9974d2809f00 RCX: ffff9974df898cc8 [ 1271.389459] RDX: 00000000ffffffd8 RSI: 0000000000000027 RDI: ffff9974df898cc0 [ 1271.389460] RBP: ffffa4cdc1f87e30 R08: 0000000000000004 R09: 00000000000002c0 [ 1271.389460] R10: 0000000000000000 R11: 0000000000000001 R12: ffff9974b7fdb5c0 [ 1271.389461] R13: ffff9974d2809f00 R14: ffff9974ccea0a80 R15: ffff99748e60db80 [ 1271.389462] FS: 0000000000000000(0000) GS:ffff9974df880000(0000) knlGS:0000000000000000 [ 1271.389462] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1271.389463] CR2: 000055c60f344fe4 CR3: 0000001031a3c002 CR4: 00000000003706e0 [ 1271.389465] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1271.389465] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 1271.389466] Call Trace: [ 1271.389483] cifs_mid_q_entry_release+0xce/0x110 [cifs] [ 1271.389499] smb2_decrypt_offload+0xa9/0x1c0 [cifs] [ 1271.389501] process_one_work+0x1e8/0x3b0 [ 1271.389503] worker_thread+0x50/0x370 [ 1271.389504] kthread+0x12f/0x150 [ 1271.389506] ? process_one_work+0x3b0/0x3b0 [ 1271.389507] ? __kthread_bind_mask+0x70/0x70 [ 1271.389509] ret_from_fork+0x22/0x30 Signed-off-by: Rohith Surabattula <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]> CC: Stable <[email protected]> #5.4+ Signed-off-by: Steve French <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Ian May <[email protected]>
1 parent 7a0cad8 commit 1f0c621

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fs/cifs/smb2ops.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,7 +4018,8 @@ init_read_bvec(struct page **pages, unsigned int npages, unsigned int data_size,
40184018
static int
40194019
handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid,
40204020
char *buf, unsigned int buf_len, struct page **pages,
4021-
unsigned int npages, unsigned int page_data_size)
4021+
unsigned int npages, unsigned int page_data_size,
4022+
bool is_offloaded)
40224023
{
40234024
unsigned int data_offset;
40244025
unsigned int data_len;
@@ -4040,7 +4041,8 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid,
40404041

40414042
if (server->ops->is_session_expired &&
40424043
server->ops->is_session_expired(buf)) {
4043-
cifs_reconnect(server);
4044+
if (!is_offloaded)
4045+
cifs_reconnect(server);
40444046
wake_up(&server->response_q);
40454047
return -1;
40464048
}
@@ -4181,7 +4183,8 @@ static void smb2_decrypt_offload(struct work_struct *work)
41814183
mid->decrypted = true;
41824184
rc = handle_read_data(dw->server, mid, dw->buf,
41834185
dw->server->vals->read_rsp_size,
4184-
dw->ppages, dw->npages, dw->len);
4186+
dw->ppages, dw->npages, dw->len,
4187+
true);
41854188
mid->callback(mid);
41864189
cifs_mid_q_entry_release(mid);
41874190
}
@@ -4285,7 +4288,7 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid,
42854288
(*mid)->decrypted = true;
42864289
rc = handle_read_data(server, *mid, buf,
42874290
server->vals->read_rsp_size,
4288-
pages, npages, len);
4291+
pages, npages, len, false);
42894292
}
42904293

42914294
free_pages:
@@ -4430,7 +4433,7 @@ smb3_handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid)
44304433
char *buf = server->large_buf ? server->bigbuf : server->smallbuf;
44314434

44324435
return handle_read_data(server, mid, buf, server->pdu_size,
4433-
NULL, 0, 0);
4436+
NULL, 0, 0, false);
44344437
}
44354438

44364439
static int

0 commit comments

Comments
 (0)