From: Jens Axboe <axboe@kernel.dk>
To: Ming Lei <ming.lei@redhat.com>
Cc: linux-block@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Hannes Reinecke <hare@suse.com>,
Greg KH <gregkh@linuxfoundation.org>,
Mike Snitzer <snitzer@redhat.com>,
Bart Van Assche <bvanassche@acm.org>
Subject: Re: [PATCH] block: don't release queue's sysfs lock during switching elevator
Date: Thu, 26 Sep 2019 08:46:10 +0200 [thread overview]
Message-ID: <34390039-1f05-e66f-e99c-7cacf50d40a0@kernel.dk> (raw)
In-Reply-To: <20190923151209.7466-1-ming.lei@redhat.com>
On 9/23/19 5:12 PM, Ming Lei wrote:
> cecf5d87ff20 ("block: split .sysfs_lock into two locks") starts to
> release & acquire sysfs_lock before registering/un-registering elevator
> queue during switching elevator for avoiding potential deadlock from
> showing & storing 'queue/iosched' attributes and removing elevator's
> kobject.
>
> Turns out there isn't such deadlock because 'q->sysfs_lock' isn't
> required in .show & .store of queue/iosched's attributes, and just
> elevator's sysfs lock is acquired in elv_iosched_store() and
> elv_iosched_show(). So it is safe to hold queue's sysfs lock when
> registering/un-registering elevator queue.
>
> The biggest issue is that commit cecf5d87ff20 assumes that concurrent
> write on 'queue/scheduler' can't happen. However, this assumption isn't
> true, because kernfs_fop_write() only guarantees that concurrent write
> aren't called on the same open file, but the write could be from
> different open on the file. So we can't release & re-acquire queue's
> sysfs lock during switching elevator, otherwise use-after-free on
> elevator could be triggered.
>
> Fixes the issue by not releasing queue's sysfs lock during switching
> elevator.
Applied, thanks Ming.
--
Jens Axboe
prev parent reply other threads:[~2019-09-26 6:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-23 15:12 [PATCH] block: don't release queue's sysfs lock during switching elevator Ming Lei
2019-09-24 18:37 ` Bart Van Assche
2019-09-25 0:13 ` Ming Lei
2019-09-25 23:40 ` Bart Van Assche
2019-09-26 6:46 ` Jens Axboe [this message]
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=34390039-1f05-e66f-e99c-7cacf50d40a0@kernel.dk \
--to=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=gregkh@linuxfoundation.org \
--cc=hare@suse.com \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=snitzer@redhat.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).