Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp787163ybj; Thu, 7 May 2020 07:38:47 -0700 (PDT) X-Google-Smtp-Source: APiQypJn1b+uakiwsVk8ujW92+3Fe7OZel9PXhBH4kCayCPJdwcdoFfZ28mb/musZM47/QDcQhRB X-Received: by 2002:aa7:dcd4:: with SMTP id w20mr12485401edu.282.1588862327500; Thu, 07 May 2020 07:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588862327; cv=none; d=google.com; s=arc-20160816; b=OgkGdvHLtjKyXln1WGOWbOR08sAMzPKHY9lBDADHTQvzf6N0DMaKhcI7aOqm4+AICC Sakzoe+uikeVpw3ZTB0bd+9MyH1hDCvsIkKmIsaLCpX5OSI3iNKhdElb7uu/IPagvsKb H5AxbHRp8EjKFK+4TKcxTUReDedA+qx1R3PVKXWHwqP0Frgd71ObFSSiBmGn/uWWmuW1 1zdu1K7gcJEGMLWrwgKZrQe0vQWQv6At2IUtbYTebZtWL926ubkSjq3wt5ztBXjVNS48 HQFZX9E5A8AkAfqP8HKZfTAdeJ3QtLDYyQb5On297U9aj2um0yi24QIx4i0z3Om6A9r9 VgZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DYdKoC8f96j+410ueBI/zkMJyuS1h0xRusT297Tq3pY=; b=LPDSfvn90Yk/GqgDnqn3/Oaunw5wnykpzF9M1hziHu24morzR2WIX4mnJCA0PCnhfc KYEaXHzNgT/CkXixI7gSfSyR9npRGfwynKjgQ+w7P9Fm9wFkYN/Iq5jzGhPRyB0gOonS BvvFFulZPGKaDuC3A0+v0IOnWMP+s6iVQK70EXbakmsEJtSuXE0egaVVySk1TUt4L01p ligkH9PaI5jCBiuv3fRx0aKW5r8lGzeBZYADXI0cUG4QHEYnWDyJz0u8HzIzpRza5gfl MAvCzvYFku5DM9i6Z9se6N1OfTuNT3NJRWdcbFvVCG92vbrHgfBpFP/2sLLeapPGjSLU XHuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TMBZ7SB5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w21si3102489edx.313.2020.05.07.07.38.23; Thu, 07 May 2020 07:38:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TMBZ7SB5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728590AbgEGOgb (ORCPT + 99 others); Thu, 7 May 2020 10:36:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:54630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728018AbgEGO2Q (ORCPT ); Thu, 7 May 2020 10:28:16 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3B60B2084D; Thu, 7 May 2020 14:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588861695; bh=ryjBNdDtm/1arVH5IDmIEcwKyKd10FYQTjhgnyy1IJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TMBZ7SB58kbkwiiBQ4kDrf956obPeniN3JYPs6ZSpU8eqcoTNJLvS6GsN25FUNZiv J6sxIgI+/0OYAJgJi7vEuqJE6D2tJgwuUuKN8zX405ZcYD36MRRPDEKnvGWjaqfLd0 mbWzgmGCK2TaOvPxgAHXh0yviDIyp5AsrfadfCRg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: David Howells , Lukas Czerner , Ian Kent , Al Viro , Linus Torvalds , Sasha Levin , linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 5.6 38/50] Fix use after free in get_tree_bdev() Date: Thu, 7 May 2020 10:27:14 -0400 Message-Id: <20200507142726.25751-38-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200507142726.25751-1-sashal@kernel.org> References: <20200507142726.25751-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells [ Upstream commit dd7bc8158b413e0b580c491e8bd18cb91057c7c2 ] Commit 6fcf0c72e4b9, a fix to get_tree_bdev() put a missing blkdev_put() in the wrong place, before a warnf() that displays the bdev under consideration rather after it. This results in a silent lockup in printk("%pg") called via warnf() from get_tree_bdev() under some circumstances when there's a race with the blockdev being frozen. This can be caused by xfstests/tests/generic/085 in combination with Lukas Czerner's ext4 mount API conversion patchset. It looks like it ought to occur with other users of get_tree_bdev() such as XFS, but apparently doesn't. Fix this by switching the order of the lines. Fixes: 6fcf0c72e4b9 ("vfs: add missing blkdev_put() in get_tree_bdev()") Reported-by: Lukas Czerner Signed-off-by: David Howells cc: Ian Kent cc: Al Viro Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/super.c b/fs/super.c index cd352530eca90..a288cd60d2aed 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1302,8 +1302,8 @@ int get_tree_bdev(struct fs_context *fc, mutex_lock(&bdev->bd_fsfreeze_mutex); if (bdev->bd_fsfreeze_count > 0) { mutex_unlock(&bdev->bd_fsfreeze_mutex); - blkdev_put(bdev, mode); warnf(fc, "%pg: Can't mount, blockdev is frozen", bdev); + blkdev_put(bdev, mode); return -EBUSY; } -- 2.20.1