From: Rock Li <lihongweizz@inspur.com>
To: <mark@fasheh.com>, <jlbec@evilplan.org>, <joseph.qi@linux.alibaba.com>
Cc: <ocfs2-devel@oss.oracle.com>, <linux-kernel@vger.kernel.org>,
Rock Li <lihongweizz@inspur.com>
Subject: [PATCH] ocfs2: fix crash issue if access released lockres in debugfs
Date: Tue, 20 Sep 2022 15:36:38 +0800 [thread overview]
Message-ID: <20220920073638.1358-1-lihongweizz@inspur.com> (raw)
Access locking_state of dlm debugfs may cause crash as scene below:
Proc A: Proc that access debuginfo:
add_lockres_tracking(lockresA)
...
ocfs2_dlm_seq_next():
//priv->p_iter_res points to next
//lockres e.g. B. priv->p_tmp_res hold
//copy of lockres A before leave
ocfs2_dlm_seq_show()
...
remove_lockres_tracking(lockres B):
//free lockres B, l_debug_list in
//priv->p_ter_res is updated but not
//priv->p_tmp_res
...
ocfs2_dlm_seq_next():
//priv->p_tmp_res which holds a old copy of
//lockres A, the l_debug_list holds a
//out-of-date succeed pointer, which will
//cause crash as //access invalid memory
iter = v; //priv->p_tmp_res
iter = ocfs2_dlm_next_res(iter, priv)
The root cause of this issue is that private->p_iter_res acts as the
agent of accessing lockres and is protected by ocfs2_dlm_tracking_lock
while p_tmp_res is only a copy of the lockres and will be out-of-dated
after leave critial region of ocfs2_dlm_tracking_lock. We should use
priv->p_ter_res as the forward iterater instead.
Signed-off-by: Rock Li <lihongweizz@inspur.com>
---
fs/ocfs2/dlmglue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index c28bc98..5d84350 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -3109,7 +3109,7 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)
struct ocfs2_lock_res *dummy = &priv->p_iter_res;
spin_lock(&ocfs2_dlm_tracking_lock);
- iter = ocfs2_dlm_next_res(iter, priv);
+ iter = ocfs2_dlm_next_res(dummy, priv);
list_del_init(&dummy->l_debug_list);
if (iter) {
list_add(&dummy->l_debug_list, &iter->l_debug_list);
--
1.8.3.1
next reply other threads:[~2022-09-20 7:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 7:36 Rock Li [this message]
2022-09-27 1:51 ` Joseph Qi
2022-09-27 9:18 Rock Li(李宏伟)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220920073638.1358-1-lihongweizz@inspur.com \
--to=lihongweizz@inspur.com \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@oss.oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®