Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4551782ybz; Tue, 28 Apr 2020 13:28:33 -0700 (PDT) X-Google-Smtp-Source: APiQypKHHs/d2YKytCwqpwsHHU0Dg3gMDXMsvJcIinFT8fd1qaSUykRIGD0EnU89jb3V8P4p9cGC X-Received: by 2002:aa7:c98a:: with SMTP id c10mr24134512edt.94.1588105712576; Tue, 28 Apr 2020 13:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588105712; cv=none; d=google.com; s=arc-20160816; b=jbMttgL5JjaqF1PyN/yUitXaWz4r+tnLFeo41u1xgVMdRGw89DS8GGt/wo0eMogQ8M w0i/JKP7T/G6fex92DDQj2CHQ9vsfPYmkYPdlCD3ZHp6QOX+KB1psNxBGaG91nt02dze DpDWtOEPjH6k1Mg+L+Gw70ht9Fc8bIxoaAruooFHewAzIp1X18gzEugWJQNAMYt6hliQ pfIpTKcAj3RmoAFLBufF5rXE3Q+4ls8RQE8p0ft/PoezLL0XijIR4q4IU+fq8QdZaGsZ XJAZak96Yzd+61kOa/hgnZDzbbcqqloEmCI7WUD3aORQTgTxABnxIEjqaN33aY9DN4MA IXwQ== 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 :user-agent:message-id:date:cc:to:from:subject:organization :dkim-signature; bh=Eg1xk1qbLOD2jm86OCEQIZspFf2KSHhRV26te2Q2h+g=; b=muIT8J9hPyFqnUus/iN6I7LUGLCVG5TwX8p3eEwmnJ/OjjDBLYfKtfSwB0eROVMo6t LHJSNF5evXldW8cmLXK3k8Z2Fe934GuZEcKL5J5L01Ma6ns0Map4xKf2zAMYqzfjLZne xDKdgHQ+UveKo3bu6/rc/sqGs+svse7+a1UwzEv0jESA3qMKnaKzeIo/SW6BYltE93NZ ZvgKxe8eMIVy0NuO/e34mLyZEaLT/SZ60YyL4tWBjbf2IZdEiTzKerHiSUHDMJnObNIc cmQ8gF0ISFASJyTwFjcOXxhDJiC9ftjHwp3i8tKCPNnzldOlADclKHvmYoMe7VqHcdQk xUCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hAeK2RY7; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si2637470eju.300.2020.04.28.13.28.01; Tue, 28 Apr 2020 13:28:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@redhat.com header.s=mimecast20190719 header.b=hAeK2RY7; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726291AbgD1U14 (ORCPT + 99 others); Tue, 28 Apr 2020 16:27:56 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:23661 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726284AbgD1U14 (ORCPT ); Tue, 28 Apr 2020 16:27:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588105675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Eg1xk1qbLOD2jm86OCEQIZspFf2KSHhRV26te2Q2h+g=; b=hAeK2RY72viEtrFmmnlslL4eDE9KSl+Cb6+7kfSSNiDYAvHjRS7PjBXy318dbNlMzmKFJU 0/k9UviwvmTAsoOHmbt6lOHYWbMvOUrK7fwGhS1QpqZU5tQwON42/NdfWYEpAleG4XKQUP Fi9Taae2lgEXx+OYI1HZLctxm/ps3f4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-X_DZxyeYPVy9uo7zIXD4BA-1; Tue, 28 Apr 2020 16:27:52 -0400 X-MC-Unique: X_DZxyeYPVy9uo7zIXD4BA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4234480058A; Tue, 28 Apr 2020 20:27:51 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-113-129.rdu2.redhat.com [10.10.113.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id A756A60CD3; Tue, 28 Apr 2020 20:27:49 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH] Fix use after free in get_tree_bdev() From: David Howells To: viro@zeniv.linux.org.uk Cc: Lukas Czerner , Ian Kent , torvalds@linux-foundation.org, dhowells@redhat.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 28 Apr 2020 21:27:48 +0100 Message-ID: <158810566883.1168184.8679527126430822408.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.21 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/super.c b/fs/super.c index cd352530eca9..a288cd60d2ae 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; }