Skip to content

Commit

Permalink
ksmbd: fix race condition from parallel smb2 lock requests
Browse files Browse the repository at this point in the history
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
namjaejeon committed Oct 2, 2023
1 parent c410910 commit c9bff4c
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -7648,10 +7648,6 @@ int smb2_lock(struct ksmbd_work *work)

ksmbd_debug(SMB,
"would have to wait for getting lock\n");
spin_lock(&work->conn->llist_lock);
list_add_tail(&smb_lock->clist,
&work->conn->lock_list);
spin_unlock(&work->conn->llist_lock);
list_add(&smb_lock->llist, &rollback_list);

argv = kmalloc(sizeof(void *), GFP_KERNEL);
Expand Down Expand Up @@ -7682,9 +7678,6 @@ int smb2_lock(struct ksmbd_work *work)

if (work->state != KSMBD_WORK_ACTIVE) {
list_del(&smb_lock->llist);
spin_lock(&work->conn->llist_lock);
list_del(&smb_lock->clist);
spin_unlock(&work->conn->llist_lock);
locks_free_lock(flock);

if (work->state == KSMBD_WORK_CANCELLED) {
Expand All @@ -7704,19 +7697,16 @@ int smb2_lock(struct ksmbd_work *work)
}

list_del(&smb_lock->llist);
spin_lock(&work->conn->llist_lock);
list_del(&smb_lock->clist);
spin_unlock(&work->conn->llist_lock);
release_async_work(work);
goto retry;
} else if (!rc) {
list_add(&smb_lock->llist, &rollback_list);
spin_lock(&work->conn->llist_lock);
list_add_tail(&smb_lock->clist,
&work->conn->lock_list);
list_add_tail(&smb_lock->flist,
&fp->lock_list);
spin_unlock(&work->conn->llist_lock);
list_add(&smb_lock->llist, &rollback_list);
ksmbd_debug(SMB, "successful in taking lock\n");
} else {
goto out;
Expand Down

0 comments on commit c9bff4c

Please sign in to comment.