From 2b14495d46d8475c588cab5ca5ab1c3179e0448d Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Sun, 25 Aug 2024 08:42:46 +0900 Subject: [PATCH] ksmd: fix wrong rcu lock for oplock list Signed-off-by: Namjae Jeon --- oplock.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/oplock.c b/oplock.c index 50af5499..2cc6b806 100644 --- a/oplock.c +++ b/oplock.c @@ -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); } @@ -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); } @@ -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); } @@ -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; @@ -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 & @@ -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);