From patchwork Fri Dec 21 14:54:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Zhou X-Patchwork-Id: 10740553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 001136C5 for ; Fri, 21 Dec 2018 14:54:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2D7F2239C for ; Fri, 21 Dec 2018 14:54:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D675227D29; Fri, 21 Dec 2018 14:54:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A88042239C for ; Fri, 21 Dec 2018 14:54:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731163AbeLUOyu (ORCPT ); Fri, 21 Dec 2018 09:54:50 -0500 Received: from mail-yw1-f66.google.com ([209.85.161.66]:33755 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729556AbeLUOyu (ORCPT ); Fri, 21 Dec 2018 09:54:50 -0500 Received: by mail-yw1-f66.google.com with SMTP id p65so1045183ywe.0; Fri, 21 Dec 2018 06:54:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GnWw34EUMHWcEqLf5GmmebOYoPKtH2U+0j1NgExUaKU=; b=C/wwgs+tjgaFwRDJuD1li3++9RkBelnk7FFu4unOJ8XxHOSjsm52ghixMygfORmTvp hHpvPx5hlHVVCy7+DRNTYWlCiKDfafQvalL5Hvq9uZ0HugmxW38IRmLQo2LXFrKVxIEX 7zBiH1qigW6y/wN9HllNe4bBpwQprMTQ0c/HJBJSCSWfzWlv+iNBmEFwt0dvFqR5j8/M Vxe/icsfF3QwaBxIXBm0U0u0pAqtwYMjR+F0XrvP3Pf/iQgoevhdqGnMHCeD6WxxS2MS CAruEYOr53JsV0e11KtHbA3gc9kkz8dO+10W2ifTPNph92iUG9+TPuTvzc4B62IO5WGP Dtkg== X-Gm-Message-State: AA+aEWb849ETqqNY7y11hGlNY/X11FPMn9JyRokGX2PEF3yL9ig0B25P IeeVcedP8nfUIztzd0P/1dA= X-Google-Smtp-Source: AFSGD/XN4KedZRhXoVbszrZqpjSqrf41FyH5qN0dMTUVpbTP6ogg1LZl5ztEZJXcuKcMvXE5tRSiMQ== X-Received: by 2002:a81:9184:: with SMTP id i126mr2746230ywg.371.1545404088874; Fri, 21 Dec 2018 06:54:48 -0800 (PST) Received: from dennisz-mbp.thefacebook.com ([199.201.65.2]) by smtp.gmail.com with ESMTPSA id x4sm14607101ywj.80.2018.12.21.06.54.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Dec 2018 06:54:48 -0800 (PST) From: Dennis Zhou To: Jens Axboe Cc: kernel-team@fb.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Dennis Zhou Subject: [PATCH] blkcg: add rcu lock to bio_clone_blkg_association() Date: Fri, 21 Dec 2018 08:54:41 -0600 Message-Id: <20181221145441.13814-1-dennis@kernel.org> X-Mailer: git-send-email 2.13.5 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 */