From: Steven Rostedt <rostedt@goodmis.org>
To: "yukuai (C)" <yukuai3@huawei.com>
Cc: <gregkh@linuxfoundation.org>, <rafael@kernel.org>,
<oleg@redhat.com>, <jack@suse.cz>, <linux-kernel@vger.kernel.org>,
<zhengbin13@huawei.com>, <yi.zhang@huawei.com>,
<chenxiang66@hisilicon.com>, <xiexiuqi@huawei.com>,
"Al Viro" <viro@ZenIV.linux.org.uk>
Subject: Re: [PATCH] debugfs: fix potential infinite loop in debugfs_remove_recursive
Date: Thu, 14 Nov 2019 20:53:11 -0500 [thread overview]
Message-ID: <20191114205311.3ce9c7ac@gandalf.local.home> (raw)
In-Reply-To: <6ac793b1-5472-6a39-fe94-348ad6a4e2be@huawei.com>
On Fri, 15 Nov 2019 09:47:38 +0800
"yukuai (C)" <yukuai3@huawei.com> wrote:
> On 2019/11/14 22:34, Steven Rostedt wrote:
> > On Thu, 14 Nov 2019 14:59:04 +0800
> > "yukuai (C)" <yukuai3@huawei.com> wrote:
> >
> >>> Have you tried this patch with lockdep enabled and tried to hit this
> >>> code path?
> >>>
> >
> >>>
> >> You are right, I get the results with lockdep enabled:
> >
> > That was what I was afraid of :-(
> >
> >> [ 64.314748] ============================================
> >> [ 64.315568] WARNING: possible recursive locking detected
> >> [ 64.316549] 5.4.0-rc7-dirty #5 Tainted: G O
> >> [ 64.317398] --------------------------------------------
> >> [ 64.318230] rmmod/2607 is trying to acquire lock:
> >
> >>
> >> The warning will disappeare by adding
> >> lockdep_set_novalidate_class(&child->d_lock) before calling
> >> simple_empty(child). But I'm not sure It's the right modfication.
> >
> > I'm wondering if we should add a simple_empty_unlocked() that does
> > simple_empty() without taking the lock, to allow us to call
> > spin_lock_nested() on the child. Of course, I don't know how much
> > nesting we allow as it calls the nesting too.
> Do you think we can do this:
> 1. add a new enum type for dentry_d_lock_class:
> enum dentry_d_lock_class
> {
> DENTRY_D_LOCK_NORMAL, /* implicitly used by plain spin_lock() APIs. */
> DENTRY_D_LOCK_NESTED
> DENTRY_D_LOCK_NESTED_1 /* maybe another name */
> };
> 2. use the new enum type in simple_empty
> int simple_empty(struct dentry *dentry)
> {
> spin_lock(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
> list_for_each_entry(child, &dentry->d_subdirs, d_child) {
> spin_lock_nested(&child->d_lock, DENTRY_D_LOCK_NESTED_1);
> }
>
> If you agree, I'll try to send a patch or patchset(with modification in
> debugfs_remove_recursive).
>
It sounds fine to me, but I think the decision needs to be with the
debugfs and vfs maintainers.
-- Steve
next prev parent reply other threads:[~2019-11-15 1:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-31 13:34 [PATCH] debugfs: fix potential infinite loop in debugfs_remove_recursive yu kuai
2019-11-13 20:17 ` Steven Rostedt
2019-11-14 2:01 ` yukuai (C)
2019-11-14 2:43 ` Steven Rostedt
2019-11-14 3:20 ` yukuai (C)
2019-11-14 6:59 ` yukuai (C)
2019-11-14 14:34 ` Steven Rostedt
2019-11-15 1:47 ` yukuai (C)
2019-11-15 1:53 ` Steven Rostedt [this message]
2019-11-15 2:13 ` yukuai (C)
2019-11-15 1:57 ` yukuai (C)
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=20191114205311.3ce9c7ac@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=chenxiang66@hisilicon.com \
--cc=gregkh@linuxfoundation.org \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=rafael@kernel.org \
--cc=viro@ZenIV.linux.org.uk \
--cc=xiexiuqi@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
--cc=zhengbin13@huawei.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;
as well as URLs for NNTP newsgroup(s).