From: Luis Chamberlain <mcgrof@kernel.org>
To: Bart Van Assche <bvanassche@acm.org>
Cc: axboe@kernel.dk, viro@zeniv.linux.org.uk,
gregkh@linuxfoundation.org, rostedt@goodmis.org,
mingo@redhat.com, jack@suse.cz, ming.lei@redhat.com,
nstange@suse.de, akpm@linux-foundation.org, mhocko@suse.com,
yukuai3@huawei.com, martin.petersen@oracle.com,
jejb@linux.ibm.com, linux-block@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v7 5/8] loop: be paranoid on exit and prevent new additions / removals
Date: Mon, 22 Jun 2020 12:27:42 +0000 [thread overview]
Message-ID: <20200622122742.GU11244@42.do-not-panic.com> (raw)
In-Reply-To: <7e76d892-b5fd-18ec-c96e-cf4537379eba@acm.org>
On Sat, Jun 20, 2020 at 10:11:46AM -0700, Bart Van Assche wrote:
> On 2020-06-19 13:47, Luis Chamberlain wrote:
> > Be pedantic on removal as well and hold the mutex.
> > This should prevent uses of addition while we exit.
> >
> > Reviewed-by: Ming Lei <ming.lei@redhat.com>
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> > ---
> > drivers/block/loop.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> > index c33bbbfd1bd9..d55e1b52f076 100644
> > --- a/drivers/block/loop.c
> > +++ b/drivers/block/loop.c
> > @@ -2402,6 +2402,8 @@ static void __exit loop_exit(void)
> >
> > range = max_loop ? max_loop << part_shift : 1UL << MINORBITS;
> >
> > + mutex_lock(&loop_ctl_mutex);
> > +
> > idr_for_each(&loop_index_idr, &loop_exit_cb, NULL);
> > idr_destroy(&loop_index_idr);
> >
> > @@ -2409,6 +2411,8 @@ static void __exit loop_exit(void)
> > unregister_blkdev(LOOP_MAJOR, "loop");
> >
> > misc_deregister(&loop_misc);
> > +
> > + mutex_unlock(&loop_ctl_mutex);
> > }
> >
> > module_init(loop_init);
>
> Is try_module_get(fops->owner) called before a loop device is opened and
> is module_put(fops->owner) called after a loop device is closed? Does
> that mean that it is impossible to unload the loop driver while a loop
> device is open? Does that mean that the above patch is not necessary or
> did I perhaps miss something?
That's not the only way to add or remove the loop module though.
You may add/remove it manually. And again, as mentioned in the commit log,
I couldn't trigger a race myself, however this seemed the more pedantic
and careful strategy we can take.
Note: this will bring you sanity if you try to figure out *why* we still
get:
[235530.144343] debugfs: Directory 'loop0' with parent 'block' already present!
[235530.149477] blktrace: debugfs_dir not present for loop0 so skipping
[235530.232328] debugfs: Directory 'loop0' with parent 'block' already present!
[235530.238962] blktrace: debugfs_dir not present for loop0 so skipping
If you run run_0004.sh from break-blktrace [0]. Even with all my patches
merged we still run into this. And so the bug lies within the block
layer or on the driver. I haven't been able to find the issue yet.
[0] https://github.com/mcgrof/break-blktrace
Luis
next prev parent reply other threads:[~2020-06-22 12:27 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 20:47 [PATCH v7 0/8] blktrace: fix debugfs use after free Luis Chamberlain
2020-06-19 20:47 ` [PATCH v7 1/8] block: add docs for gendisk / request_queue refcount helpers Luis Chamberlain
2020-06-19 20:47 ` [PATCH v7 2/8] block: clarify context for refcount increment helpers Luis Chamberlain
2020-06-19 20:47 ` [PATCH v7 3/8] block: revert back to synchronous request_queue removal Luis Chamberlain
2020-06-19 20:47 ` [PATCH v7 4/8] blktrace: annotate required lock on do_blk_trace_setup() Luis Chamberlain
2020-06-20 17:02 ` Bart Van Assche
2020-06-19 20:47 ` [PATCH v7 5/8] loop: be paranoid on exit and prevent new additions / removals Luis Chamberlain
2020-06-20 17:11 ` Bart Van Assche
2020-06-22 12:27 ` Luis Chamberlain [this message]
2020-06-23 2:16 ` Bart Van Assche
2020-06-23 16:56 ` Luis Chamberlain
2020-06-23 17:05 ` Johannes Thumshirn
2020-06-24 12:08 ` Luis Chamberlain
2020-06-19 20:47 ` [PATCH v7 6/8] blktrace: fix debugfs use after free Luis Chamberlain
2020-06-20 7:29 ` Christoph Hellwig
2020-06-20 17:31 ` Bart Van Assche
2020-06-22 12:36 ` Luis Chamberlain
2020-06-19 20:47 ` [PATCH v7 7/8] blktrace: ensure our debugfs dir exists Luis Chamberlain
2020-06-20 7:29 ` Christoph Hellwig
2020-06-20 17:33 ` Bart Van Assche
2020-06-19 20:47 ` [PATCH v7 8/8] block: create the request_queue debugfs_dir on registration Luis Chamberlain
2020-06-20 7:30 ` Christoph Hellwig
2020-06-20 18:07 ` Bart Van Assche
2020-06-22 12:42 ` Luis Chamberlain
2020-06-23 3:18 ` Bart Van Assche
2020-06-20 21:18 ` [PATCH v7 0/8] blktrace: fix debugfs use after free Jens Axboe
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=20200622122742.GU11244@42.do-not-panic.com \
--to=mcgrof@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jejb@linux.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=martin.petersen@oracle.com \
--cc=mhocko@suse.com \
--cc=ming.lei@redhat.com \
--cc=mingo@redhat.com \
--cc=nstange@suse.de \
--cc=rostedt@goodmis.org \
--cc=viro@zeniv.linux.org.uk \
--cc=yukuai3@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.