Skip to content

Commit ddb7ea3

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: fix r_count dec/increment mismatch
r_count is only increased when there is an oplock break wait, so r_count inc/decrement are not paired. This can cause r_count to become negative, which can lead to a problem where the ksmbd thread does not terminate. Fixes: 3aa660c ("ksmbd: prevent connection release during oplock break notification") Reported-by: Norbert Szetei <norbert@doyensec.com> Tested-by: Norbert Szetei <norbert@doyensec.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent c188304 commit ddb7ea3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/smb/server/oplock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,8 @@ static int smb2_oplock_break_noti(struct oplock_info *opinfo)
724724
work->conn = conn;
725725
work->sess = opinfo->sess;
726726

727+
ksmbd_conn_r_count_inc(conn);
727728
if (opinfo->op_state == OPLOCK_ACK_WAIT) {
728-
ksmbd_conn_r_count_inc(conn);
729729
INIT_WORK(&work->work, __smb2_oplock_break_noti);
730730
ksmbd_queue_work(work);
731731

@@ -833,8 +833,8 @@ static int smb2_lease_break_noti(struct oplock_info *opinfo)
833833
work->conn = conn;
834834
work->sess = opinfo->sess;
835835

836+
ksmbd_conn_r_count_inc(conn);
836837
if (opinfo->op_state == OPLOCK_ACK_WAIT) {
837-
ksmbd_conn_r_count_inc(conn);
838838
INIT_WORK(&work->work, __smb2_lease_break_noti);
839839
ksmbd_queue_work(work);
840840
wait_for_break_ack(opinfo);

0 commit comments

Comments
 (0)