From: NeilBrown <neilb@suse.de>
To: Shaohua Li <shli@kernel.org>, Lars Ellenberg <lars.ellenberg@linbit.com>
Cc: Jens Axboe <axboe@kernel.dk>, Chris Mason <clm@fb.com>,
Josef Bacik <jbacik@fb.com>, David Sterba <dsterba@suse.com>,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] [RFC] fix potential access after free: return value of blk_check_plugged() must be used schedule() safe
Date: Wed, 06 Apr 2016 13:10:57 +1000 [thread overview]
Message-ID: <87k2kbo2im.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20160406004956.GA102852@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 1592 bytes --]
On Wed, Apr 06 2016, Shaohua Li wrote:
> On Tue, Apr 05, 2016 at 03:36:57PM +0200, Lars Ellenberg wrote:
>> blk_check_plugged() will return a pointer
>> to an object linked on current->plug->cb_list.
>>
>> That list may "at any time" be implicitly cleared by
>> blk_flush_plug_list()
>> flush_plug_callbacks()
>> either as a result of blk_finish_plug(),
>> or implicitly by schedule() [and maybe other implicit mechanisms?]
>>
>> If there is no protection against an implicit unplug
>> between the call to blk_check_plug() and using its return value,
>> that implicit unplug may have already happened,
>> even before the plug is actually initialized or populated,
>> and we may be using a pointer to already free()d data.
>
> This isn't correct. flush plug is never called in preemption, which is designed
> only called when the task is going to sleep. See sched_submit_work. Am I
> missing anything?
Ahh yes, thanks.
Only two places call blk_schedule_flush_plug().
One is io_schedule_timeout() which must be called explicitly.
There other is, as you say, sched_submit_work(). It starts:
static inline void sched_submit_work(struct task_struct *tsk)
{
if (!tsk->state || tsk_is_pi_blocked(tsk))
return;
so if the task is runnable, then as
include/linux/sched.h:#define TASK_RUNNING 0
it will never call blk_schedule_flush_plug().
So I don't think you are missing anything, we were.
Lars: have your concerns been relieved or do you still have reason to
think there is a problem?
Thanks,
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
next prev parent reply other threads:[~2016-04-06 3:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-05 13:36 [PATCH] [RFC] fix potential access after free: return value of blk_check_plugged() must be used schedule() safe Lars Ellenberg
2016-04-05 22:49 ` NeilBrown
2016-04-05 22:49 ` NeilBrown
2016-04-06 0:30 ` Chris Mason
2016-04-06 0:30 ` Chris Mason
2016-04-06 0:49 ` Shaohua Li
2016-04-06 3:10 ` NeilBrown [this message]
2016-04-06 12:01 ` Lars Ellenberg
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=87k2kbo2im.fsf@notabene.neil.brown.name \
--to=neilb@suse.de \
--cc=axboe@kernel.dk \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=jbacik@fb.com \
--cc=lars.ellenberg@linbit.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=shli@kernel.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 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.