linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] blkcg: add rcu lock to bio_clone_blkg_association()
@ 2018-12-21 14:54 Dennis Zhou
  2018-12-21 15:26 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Dennis Zhou @ 2018-12-21 14:54 UTC (permalink / raw)
  To: Jens Axboe; +Cc: kernel-team, linux-block, linux-kernel, Dennis Zhou

I cleaned up blkg_tryget_closest() to require rcu_read_lock() earlier.
However, this was a subtle case too which clearly was too subtle for me.
The idea was the src bio should be holding a ref to the blkg so rcu
wasn't technically needed. If it doesn't hold a ref, it should be %NULL
and the blkg->parent pointers are unused.

This adds the appropriate read lock in bio_clone_blkg_association().

Fixes: 80fd3c272c1a ("blkcg: clean up blkg_tryget_closest()")
Reported-by: syzbot+a36a3ba92bea3b315c64@syzkaller.appspotmail.com
Signed-off-by: Dennis Zhou <dennis@kernel.org>
---
 block/bio.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/bio.c b/block/bio.c
index c288b9057042..9194d8ad3d5e 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -2096,8 +2096,12 @@ EXPORT_SYMBOL_GPL(bio_associate_blkg);
  */
 void bio_clone_blkg_association(struct bio *dst, struct bio *src)
 {
+	rcu_read_lock();
+
 	if (src->bi_blkg)
 		__bio_associate_blkg(dst, src->bi_blkg);
+
+	rcu_read_unlock();
 }
 EXPORT_SYMBOL_GPL(bio_clone_blkg_association);
 #endif /* CONFIG_BLK_CGROUP */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] blkcg: add rcu lock to bio_clone_blkg_association()
  2018-12-21 14:54 [PATCH] blkcg: add rcu lock to bio_clone_blkg_association() Dennis Zhou
@ 2018-12-21 15:26 ` Jens Axboe
  2018-12-21 17:02   ` Dennis Zhou
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2018-12-21 15:26 UTC (permalink / raw)
  To: Dennis Zhou; +Cc: kernel-team, linux-block, linux-kernel

On 12/21/18 7:54 AM, Dennis Zhou wrote:
> I cleaned up blkg_tryget_closest() to require rcu_read_lock() earlier.
> However, this was a subtle case too which clearly was too subtle for me.
> The idea was the src bio should be holding a ref to the blkg so rcu
> wasn't technically needed. If it doesn't hold a ref, it should be %NULL
> and the blkg->parent pointers are unused.
> 
> This adds the appropriate read lock in bio_clone_blkg_association().

Shall I just fold this with the previous? I staged it in a
later-in-merge-cycle branch, so that's not an issue to amend.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] blkcg: add rcu lock to bio_clone_blkg_association()
  2018-12-21 15:26 ` Jens Axboe
@ 2018-12-21 17:02   ` Dennis Zhou
  2018-12-21 17:03     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Dennis Zhou @ 2018-12-21 17:02 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Dennis Zhou, kernel-team, linux-block, linux-kernel

On Fri, Dec 21, 2018 at 08:26:02AM -0700, Jens Axboe wrote:
> On 12/21/18 7:54 AM, Dennis Zhou wrote:
> > I cleaned up blkg_tryget_closest() to require rcu_read_lock() earlier.
> > However, this was a subtle case too which clearly was too subtle for me.
> > The idea was the src bio should be holding a ref to the blkg so rcu
> > wasn't technically needed. If it doesn't hold a ref, it should be %NULL
> > and the blkg->parent pointers are unused.
> > 
> > This adds the appropriate read lock in bio_clone_blkg_association().
> 
> Shall I just fold this with the previous? I staged it in a
> later-in-merge-cycle branch, so that's not an issue to amend.
> 

Yeah that would be great!

Thanks,
Dennis

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] blkcg: add rcu lock to bio_clone_blkg_association()
  2018-12-21 17:02   ` Dennis Zhou
@ 2018-12-21 17:03     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2018-12-21 17:03 UTC (permalink / raw)
  To: Dennis Zhou; +Cc: kernel-team, linux-block, linux-kernel

On 12/21/18 10:02 AM, Dennis Zhou wrote:
> On Fri, Dec 21, 2018 at 08:26:02AM -0700, Jens Axboe wrote:
>> On 12/21/18 7:54 AM, Dennis Zhou wrote:
>>> I cleaned up blkg_tryget_closest() to require rcu_read_lock() earlier.
>>> However, this was a subtle case too which clearly was too subtle for me.
>>> The idea was the src bio should be holding a ref to the blkg so rcu
>>> wasn't technically needed. If it doesn't hold a ref, it should be %NULL
>>> and the blkg->parent pointers are unused.
>>>
>>> This adds the appropriate read lock in bio_clone_blkg_association().
>>
>> Shall I just fold this with the previous? I staged it in a
>> later-in-merge-cycle branch, so that's not an issue to amend.
>>
> 
> Yeah that would be great!

Done

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-21 17:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-21 14:54 [PATCH] blkcg: add rcu lock to bio_clone_blkg_association() Dennis Zhou
2018-12-21 15:26 ` Jens Axboe
2018-12-21 17:02   ` Dennis Zhou
2018-12-21 17:03     ` Jens Axboe

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).