Skip to content

Commit

Permalink
ksmd: fix wrong rcu lock for oplock list
Browse files Browse the repository at this point in the history
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
namjaejeon committed Aug 24, 2024
1 parent 8558705 commit 2b14495
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions oplock.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static void lease_add_list(struct oplock_info *opinfo)
struct lease_table *lb = opinfo->o_lease->l_lb;

spin_lock(&lb->lb_lock);
list_add_rcu(&opinfo->lease_entry, &lb->lease_list);
list_add(&opinfo->lease_entry, &lb->lease_list);
spin_unlock(&lb->lb_lock);
}

Expand Down Expand Up @@ -214,7 +214,7 @@ static void opinfo_add(struct oplock_info *opinfo)
struct ksmbd_inode *ci = opinfo->o_fp->f_ci;

down_write(&ci->m_lock);
list_add_rcu(&opinfo->op_entry, &ci->m_op_list);
list_add(&opinfo->op_entry, &ci->m_op_list);
up_write(&ci->m_lock);
}

Expand All @@ -228,7 +228,7 @@ static void opinfo_del(struct oplock_info *opinfo)
write_unlock(&lease_list_lock);
}
down_write(&ci->m_lock);
list_del_rcu(&opinfo->op_entry);
list_del(&opinfo->op_entry);
up_write(&ci->m_lock);
}

Expand Down Expand Up @@ -1584,8 +1584,8 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp,
ci = fp->f_ci;
op = opinfo_get(fp);

rcu_read_lock();
list_for_each_entry_rcu(brk_op, &ci->m_op_list, op_entry) {
down_read(&ci->m_lock);
list_for_each_entry(brk_op, &ci->m_op_list, op_entry) {
if (brk_op->conn == NULL)
continue;

Expand All @@ -1598,8 +1598,6 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp,
continue;
}

rcu_read_unlock();

#ifdef CONFIG_SMB_INSECURE_SERVER
if (brk_op->is_smb2) {
if (brk_op->is_lease && (brk_op->o_lease->state &
Expand Down Expand Up @@ -1659,9 +1657,8 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp,
oplock_break(brk_op, SMB2_OPLOCK_LEVEL_NONE);
next:
opinfo_conn_put(brk_op);
rcu_read_lock();
}
rcu_read_unlock();
up_read(&ci->m_lock);

if (op)
opinfo_put(op);
Expand Down

0 comments on commit 2b14495

Please sign in to comment.