Skip to content

Commit 97dbac1

Browse files
committed
ksmbd: fix potential use-after-free in oplock/lease break ack
If ksmbd_iov_pin_rsp return error, use-after-free can happen by accessing opinfo->state and opinfo_put and ksmbd_fd_put could called twice. Signed-off-by: Namjae Jeon <[email protected]>
1 parent be1dbb0 commit 97dbac1

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

smb2pdu.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9189,13 +9189,13 @@ static void smb20_oplock_break_ack(struct ksmbd_work *work)
91899189
ret = ksmbd_iov_pin_rsp(work, rsp, sizeof(struct smb2_oplock_break));
91909190
if (!ret)
91919191
return;
9192-
9192+
else {
91939193
err_out:
9194-
opinfo->op_state = OPLOCK_STATE_NONE;
9195-
wake_up_interruptible_all(&opinfo->oplock_q);
9196-
9197-
opinfo_put(opinfo);
9198-
ksmbd_fd_put(work, fp);
9194+
opinfo->op_state = OPLOCK_STATE_NONE;
9195+
wake_up_interruptible_all(&opinfo->oplock_q);
9196+
opinfo_put(opinfo);
9197+
ksmbd_fd_put(work, fp);
9198+
}
91999199
smb2_set_err_rsp(work);
92009200
}
92019201

@@ -9341,13 +9341,13 @@ static void smb21_lease_break_ack(struct ksmbd_work *work)
93419341
ret = ksmbd_iov_pin_rsp(work, rsp, sizeof(struct smb2_lease_ack));
93429342
if (!ret)
93439343
return;
9344-
9344+
else {
93459345
err_out:
9346-
wake_up_interruptible_all(&opinfo->oplock_q);
9347-
atomic_dec(&opinfo->breaking_cnt);
9348-
wake_up_interruptible_all(&opinfo->oplock_brk);
9349-
9350-
opinfo_put(opinfo);
9346+
wake_up_interruptible_all(&opinfo->oplock_q);
9347+
atomic_dec(&opinfo->breaking_cnt);
9348+
wake_up_interruptible_all(&opinfo->oplock_brk);
9349+
opinfo_put(opinfo);
9350+
}
93519351
smb2_set_err_rsp(work);
93529352
}
93539353

0 commit comments

Comments
 (0)