Skip to content

Commit 2632d81

Browse files
committed
Merge tag 'v6.16-rc5-ksmbd-server-fixes' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French: - fix use after free in lease break - small fix for freeing rdma transport (fixes missing logging of cm_qp_destroy) - fix write count leak * tag 'v6.16-rc5-ksmbd-server-fixes' of git://git.samba.org/ksmbd: ksmbd: fix potential use-after-free in oplock/lease break ack ksmbd: fix a mount write count leak in ksmbd_vfs_kern_path_locked() smb: server: make use of rdma_destroy_qp()
2 parents 379f604 + 50f930d commit 2632d81

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8573,28 +8573,22 @@ static void smb20_oplock_break_ack(struct ksmbd_work *work)
85738573
goto err_out;
85748574
}
85758575

8576-
opinfo->op_state = OPLOCK_STATE_NONE;
8577-
wake_up_interruptible_all(&opinfo->oplock_q);
8578-
opinfo_put(opinfo);
8579-
ksmbd_fd_put(work, fp);
8580-
85818576
rsp->StructureSize = cpu_to_le16(24);
85828577
rsp->OplockLevel = rsp_oplevel;
85838578
rsp->Reserved = 0;
85848579
rsp->Reserved2 = 0;
85858580
rsp->VolatileFid = volatile_id;
85868581
rsp->PersistentFid = persistent_id;
85878582
ret = ksmbd_iov_pin_rsp(work, rsp, sizeof(struct smb2_oplock_break));
8588-
if (!ret)
8589-
return;
8590-
8583+
if (ret) {
85918584
err_out:
8585+
smb2_set_err_rsp(work);
8586+
}
8587+
85928588
opinfo->op_state = OPLOCK_STATE_NONE;
85938589
wake_up_interruptible_all(&opinfo->oplock_q);
8594-
85958590
opinfo_put(opinfo);
85968591
ksmbd_fd_put(work, fp);
8597-
smb2_set_err_rsp(work);
85988592
}
85998593

86008594
static int check_lease_state(struct lease *lease, __le32 req_state)
@@ -8724,11 +8718,6 @@ static void smb21_lease_break_ack(struct ksmbd_work *work)
87248718
}
87258719

87268720
lease_state = lease->state;
8727-
opinfo->op_state = OPLOCK_STATE_NONE;
8728-
wake_up_interruptible_all(&opinfo->oplock_q);
8729-
atomic_dec(&opinfo->breaking_cnt);
8730-
wake_up_interruptible_all(&opinfo->oplock_brk);
8731-
opinfo_put(opinfo);
87328721

87338722
rsp->StructureSize = cpu_to_le16(36);
87348723
rsp->Reserved = 0;
@@ -8737,16 +8726,16 @@ static void smb21_lease_break_ack(struct ksmbd_work *work)
87378726
rsp->LeaseState = lease_state;
87388727
rsp->LeaseDuration = 0;
87398728
ret = ksmbd_iov_pin_rsp(work, rsp, sizeof(struct smb2_lease_ack));
8740-
if (!ret)
8741-
return;
8742-
8729+
if (ret) {
87438730
err_out:
8731+
smb2_set_err_rsp(work);
8732+
}
8733+
8734+
opinfo->op_state = OPLOCK_STATE_NONE;
87448735
wake_up_interruptible_all(&opinfo->oplock_q);
87458736
atomic_dec(&opinfo->breaking_cnt);
87468737
wake_up_interruptible_all(&opinfo->oplock_brk);
8747-
87488738
opinfo_put(opinfo);
8749-
smb2_set_err_rsp(work);
87508739
}
87518740

87528741
/**

fs/smb/server/transport_rdma.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ static void free_transport(struct smb_direct_transport *t)
433433
if (t->qp) {
434434
ib_drain_qp(t->qp);
435435
ib_mr_pool_destroy(t->qp, &t->qp->rdma_mrs);
436-
ib_destroy_qp(t->qp);
436+
t->qp = NULL;
437+
rdma_destroy_qp(t->cm_id);
437438
}
438439

439440
ksmbd_debug(RDMA, "drain the reassembly queue\n");
@@ -1940,8 +1941,8 @@ static int smb_direct_create_qpair(struct smb_direct_transport *t,
19401941
return 0;
19411942
err:
19421943
if (t->qp) {
1943-
ib_destroy_qp(t->qp);
19441944
t->qp = NULL;
1945+
rdma_destroy_qp(t->cm_id);
19451946
}
19461947
if (t->recv_cq) {
19471948
ib_destroy_cq(t->recv_cq);

fs/smb/server/vfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,7 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
12821282

12831283
err = ksmbd_vfs_lock_parent(parent_path->dentry, path->dentry);
12841284
if (err) {
1285+
mnt_drop_write(parent_path->mnt);
12851286
path_put(path);
12861287
path_put(parent_path);
12871288
}

0 commit comments

Comments
 (0)