From: Jens Axboe <axboe@kernel.dk>
To: Paolo Valente <paolo.valente@linaro.org>, Tejun Heo <tj@kernel.org>
Cc: linux-block@vger.kernel.org,
Linux-Kernal <linux-kernel@vger.kernel.org>,
ulf.hansson@linaro.org, broonie@kernel.org
Subject: Re: [PATCH BUGFIX] block, bfq: access and cache blkg data only when safe
Date: Thu, 8 Jun 2017 09:52:14 -0600 [thread overview]
Message-ID: <cd8f0234-f33f-d13b-34eb-f574f546d8ae@kernel.dk> (raw)
In-Reply-To: <20847C23-6D7A-4D24-ADBF-51849612FEDA@linaro.org>
On 06/08/2017 09:30 AM, Paolo Valente wrote:
>
>> Il giorno 05 giu 2017, alle ore 10:11, Paolo Valente <paolo.valente@linaro.org> ha scritto:
>>
>> In blk-cgroup, operations on blkg objects are protected with the
>> request_queue lock. This is no more the lock that protects
>> I/O-scheduler operations in blk-mq. In fact, the latter are now
>> protected with a finer-grained per-scheduler-instance lock. As a
>> consequence, although blkg lookups are also rcu-protected, blk-mq I/O
>> schedulers may see inconsistent data when they access blkg and
>> blkg-related objects. BFQ does access these objects, and does incur
>> this problem, in the following case.
>>
>> The blkg_lookup performed in bfq_get_queue, being protected (only)
>> through rcu, may happen to return the address of a copy of the
>> original blkg. If this is the case, then the blkg_get performed in
>> bfq_get_queue, to pin down the blkg, is useless: it does not prevent
>> blk-cgroup code from destroying both the original blkg and all objects
>> directly or indirectly referred by the copy of the blkg. BFQ accesses
>> these objects, which typically causes a crash for NULL-pointer
>> dereference of memory-protection violation.
>>
>> Some additional protection mechanism should be added to blk-cgroup to
>> address this issue. In the meantime, this commit provides a quick
>> temporary fix for BFQ: cache (when safe) blkg data that might
>> disappear right after a blkg_lookup.
>>
>> In particular, this commit exploits the following facts to achieve its
>> goal without introducing further locks. Destroy operations on a blkg
>> invoke, as a first step, hooks of the scheduler associated with the
>> blkg. And these hooks are executed with bfqd->lock held for BFQ. As a
>> consequence, for any blkg associated with the request queue an
>> instance of BFQ is attached to, we are guaranteed that such a blkg is
>> not destroyed, and that all the pointers it contains are consistent,
>> while that instance is holding its bfqd->lock. A blkg_lookup performed
>> with bfqd->lock held then returns a fully consistent blkg, which
>> remains consistent until this lock is held. In more detail, this holds
>> even if the returned blkg is a copy of the original one.
>>
>> Finally, also the object describing a group inside BFQ needs to be
>> protected from destruction on the blkg_free of the original blkg
>> (which invokes bfq_pd_free). This commit adds private refcounting for
>> this object, to let it disappear only after no bfq_queue refers to it
>> any longer.
>>
>> This commit also removes or updates some stale comments on locking
>> issues related to blk-cgroup operations.
>>
>> Reported-by: Tomas Konir <tomas.konir@gmail.com>
>> Reported-by: Lee Tibbert <lee.tibbert@gmail.com>
>> Reported-by: Marco Piazza <mpiazza@gmail.com>
>> Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
>> Tested-by: Tomas Konir <tomas.konir@gmail.com>
>> Tested-by: Lee Tibbert <lee.tibbert@gmail.com>
>> Tested-by: Marco Piazza <mpiazza@gmail.com>
>
> Hi Jens,
> are you waiting for some further review/ack on this, or is it just in
> your queue of patches to check? Sorry for bothering you, but this bug
> is causing problems to users.
I'll pull it in, it'll make the next -rc. I'll often let patches sit
for a few days even if I agree with them, to give others a chance to
either further review, comment, or disagree with them.
--
Jens Axboe
next prev parent reply other threads:[~2017-06-08 15:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-05 8:11 Paolo Valente
2017-06-08 15:30 ` Paolo Valente
2017-06-08 15:52 ` Jens Axboe [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-05-19 8:39 Paolo Valente
2017-05-19 14:37 ` Jens Axboe
2017-05-22 20:20 ` Paolo Valente
2017-05-19 14:54 ` Tejun Heo
2017-05-20 7:27 ` Paolo Valente
2017-05-23 20:42 ` Tejun Heo
2017-05-24 11:53 ` Paolo Valente
2017-05-24 14:24 ` Paolo Valente
2017-05-24 14:50 ` Tejun Heo
2017-05-24 16:43 ` Paolo Valente
2017-05-24 16:47 ` Tejun Heo
2017-05-25 7:10 ` Paolo Valente
2017-05-25 14:37 ` Tejun Heo
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=cd8f0234-f33f-d13b-34eb-f574f546d8ae@kernel.dk \
--to=axboe@kernel.dk \
--cc=broonie@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paolo.valente@linaro.org \
--cc=tj@kernel.org \
--cc=ulf.hansson@linaro.org \
/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®