From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Jens Axboe <axboe@kernel.dk>,
Andrew Morton <akpm@linux-foundation.org>,
Kay Sievers <kay.sievers@vrfy.org>,
Namhyung Kim <namhyung@gmail.com>,
Lukas Czerner <lczerner@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] loop: fput() called in loop_clr_fd() may cause bd_mutex recursive locking
Date: Sun, 18 Dec 2011 01:37:45 +0300 [thread overview]
Message-ID: <20111217223745.GC3313@swordfish> (raw)
In-Reply-To: <20111217223033.GB2203@ZenIV.linux.org.uk>
On (12/17/11 22:30), Al Viro wrote:
> > Sorry, why is that a false positive?
> >
> > blkdev_put() calls lo_release() while holding bd_mutex,
> > lo_release() calls loop_clr_fd() -> fput(). fput() once again
> > attempts to grub already held bd_mutex calling blkdev_put().
> > Looks like a recursion to me.
>
> Because of this:
> /* Avoid recursion */
> f = file;
> while (is_loop_device(f)) {
> struct loop_device *l;
>
> if (f->f_mapping->host->i_bdev == bdev)
> goto out_putf;
>
> l = f->f_mapping->host->i_bdev->bd_disk->private_data;
> if (l->lo_state == Lo_unbound) {
> error = -EINVAL;
> goto out_putf;
> }
> f = l->lo_backing_file;
> }
> in loop_set_fd().
Oh, thanks. I didn't notice that one.
> Think of it for a minute - if we could run into the
> same bdev in that recursion, what would have happened on read() from
> that sucker? So yes, it is a false positive.
I've tried read()/write() some time ago and it worked. Perhaps, I just
wasn't "lucky" enough to hit any problems.
> And your patch would simply leave the underlying device opened,
> with all the consequences...
>
well, that sucks.
Sergey
next prev parent reply other threads:[~2011-12-17 22:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-17 21:53 [PATCH] loop: fput() called in loop_clr_fd() may cause bd_mutex recursive locking Sergey Senozhatsky
2011-12-17 22:12 ` Al Viro
2011-12-17 22:19 ` Sergey Senozhatsky
2011-12-17 22:30 ` Al Viro
2011-12-17 22:37 ` Sergey Senozhatsky [this message]
2011-12-17 22:58 ` Al Viro
2011-12-17 23:20 ` Sergey Senozhatsky
2011-12-17 23:38 ` Al Viro
2011-12-17 23:47 ` Sergey Senozhatsky
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=20111217223745.GC3313@swordfish \
--to=sergey.senozhatsky@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=kay.sievers@vrfy.org \
--cc=lczerner@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@gmail.com \
--cc=viro@ZenIV.linux.org.uk \
/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