Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp84500yba; Mon, 20 May 2019 05:26:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0Cvl5EuCeHUdBTnyYPESltyqoDFEXbQZckFve3S3HoXJrA0EJU0n6gqGTNs01jZDH1xuK X-Received: by 2002:a62:7d8e:: with SMTP id y136mr58177975pfc.224.1558355168354; Mon, 20 May 2019 05:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558355168; cv=none; d=google.com; s=arc-20160816; b=pMJ1LuuOWxFY9CHGI328yEd2e9ZincLcVMib2bGKDd8ITloV+Y5QV/+BsbENUiQtpt wU7pjZoh/e+34znt48oNd4nxIWa6Ih8rr7RLIPKxPwqeXUpw1wBTFa5Yw4pxuYIHyCsM AGxr6RnIVN7BIdftwAPfTqvbfSUbYsq0G2ENFmlemoeT4UdAxy4PjKFAl3+pV/UZ3nf3 5ZbLLfiIf/z7sOYkbvKcXjmIi70GQ9S3c4fUzAZJ+J5h0lMlS/W3A3Oln5v1kv4lPVu6 Subncv2z+GX2d2WVrIX8WI+Xoui7glpYWNNRQ3dHCvN6A+cFGuJMMtOCRvbBrySsdRID axHA== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=77CqfDRExSZQ24GPTCalHmzoSLsqh24m+M8Cm29qoq4=; b=ZC13ztpGuDinAAREC6b3s71U1rA0iPsLfYIrnPYmZNpLOgusOhjjPVu7K3pP/m6cqy hDi3M4BykTMxZUqfvWowdLic3JNjLjWV9D4z/F1kjYRyTfi8AFURvdBmz8+0zPaZKkV5 UJs/v9jzCfihmyawcypb01e4kDUTzmyefE7r9IcvM60u+quKcfmQ/QmmEXBXuRqSLP2u 8jSljqXR8xZNu+/6dQXqRkuF3Pkme63ToAgRBNI3XlGCI7p2Fph6W+vDYwXZi5Za8Og6 mXY+4eXlX0mAimO3J412HXULRWPh9m1QVFt9vmZNZWdo8ZGQRlEUw3/mMe3mGuzAOo2t HP7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZsbPERi0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g13si16845253pgs.161.2019.05.20.05.25.53; Mon, 20 May 2019 05:26:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZsbPERi0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388646AbfETMXj (ORCPT + 99 others); Mon, 20 May 2019 08:23:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:38132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388637AbfETMXh (ORCPT ); Mon, 20 May 2019 08:23:37 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5162C20645; Mon, 20 May 2019 12:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355016; bh=L/Cv3EAR9jLgZ9/NL7/jp4JloC3gs6Kc1Nk8kU4hPu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZsbPERi01uLxASVFAAxMTj0jIdaSxxpKeRw0gs5oQnQR9tfiQTejzq+eHt0qwV12J p1o1SPoBhQs6g5L9x/QkYdJR6qMVl8sP912ai4j7Go+tGnRNv8FZudeTvTfFmPq/HX MX02rJUMzNJwu5tvLigxk00rPANaK1y+a3dvoi+M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Ren , Jiufei Xue , Theodore Tso , Jan Kara , stable@kernel.org Subject: [PATCH 4.19 065/105] jbd2: check superblock mapped prior to committing Date: Mon, 20 May 2019 14:14:11 +0200 Message-Id: <20190520115251.665060078@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115247.060821231@linuxfoundation.org> References: <20190520115247.060821231@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiufei Xue commit 742b06b5628f2cd23cb51a034cb54dc33c6162c5 upstream. We hit a BUG at fs/buffer.c:3057 if we detached the nbd device before unmounting ext4 filesystem. The typical chain of events leading to the BUG: jbd2_write_superblock submit_bh submit_bh_wbc BUG_ON(!buffer_mapped(bh)); The block device is removed and all the pages are invalidated. JBD2 was trying to write journal superblock to the block device which is no longer present. Fix this by checking the journal superblock's buffer head prior to submitting. Reported-by: Eric Ren Signed-off-by: Jiufei Xue Signed-off-by: Theodore Ts'o Reviewed-by: Jan Kara Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/jbd2/journal.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1366,6 +1366,10 @@ static int jbd2_write_superblock(journal journal_superblock_t *sb = journal->j_superblock; int ret; + /* Buffer got discarded which means block device got invalidated */ + if (!buffer_mapped(bh)) + return -EIO; + trace_jbd2_write_superblock(journal, write_flags); if (!(journal->j_flags & JBD2_BARRIER)) write_flags &= ~(REQ_FUA | REQ_PREFLUSH);