Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2010594imm; Tue, 10 Jul 2018 11:32:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf0RdivQ+XujZH26/nXtm8oM9Sux4w7zqrHMcuP6qnBt/SzErQXvye59LPmS7E1egLF74WI X-Received: by 2002:a63:5624:: with SMTP id k36-v6mr23740027pgb.146.1531247569865; Tue, 10 Jul 2018 11:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531247569; cv=none; d=google.com; s=arc-20160816; b=n++P7fHg70gXjAMa33TKgrjaePNAWuUs5yoLHlKqW5ZQ+0j76fQflhaOO1AacuBloi rke+ekfLdrMUjOVGNIK+WWpvXdxboI48mYCTSO9DoaW+MoxptSTsuAWPdi4wWGCPnroE j2XCxh0P36dOhn+/yNmp9kXJQadIUvrN69FR9oYKhYhtC3Vc/NBaAJ6Xmr6ZWOa5xbv8 ++nuwbJivK8ebf2SVdapsXHBQdBfr+8ZNDJ4rkLfSa1rY8iksva3qB+uRuaer1XHR63b 8KBPIZOmWayELkjmViyayJRZqWSJGjAjfo+7OmTRmqmAqJJ0k/yNQ9UWbGsE+S8Se4M5 JBLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Ck0JOqTtjSFsx+yLs1Kaba0OotvhDhaaEcjXLHbiKvs=; b=fKGXsYTlBVA2DWA3Axye9JcpzVTf5bSiMAZNC8ulnuMEmyc18HxMUfqAaQWttIN1IT 9dKEnbNkRLAGHPmjd8iwfiQVkoKtGTjlhD3tMfRS4hOuPnnWjGrebEXXotJNn6Mj7CJW 0nzYSxedhROo1CfnpoTGuMj+86LRSsspE8fPCAUByKKsygHOjVPDygEfWrSCnu8K6pWQ hn22XT+vYCA9cTR+ucmFVPphDRQ0dBQwtzM7sKKjF6+RL4ARhnxiGWqLMakdGyd/go1w tPH0SEi79vQ5b/aVw6UHGLZV016nwo1UqX2+70Oqtxz8N9plmHgN9hYTgp/uA4y+tHmY M0Hg== ARC-Authentication-Results: i=1; mx.google.com; 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 u6-v6si10506546plz.423.2018.07.10.11.32.34; Tue, 10 Jul 2018 11:32:49 -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; 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 S2388405AbeGJSbg (ORCPT + 99 others); Tue, 10 Jul 2018 14:31:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45862 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387531AbeGJSbf (ORCPT ); Tue, 10 Jul 2018 14:31:35 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 69D7CEB4; Tue, 10 Jul 2018 18:31:23 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Derrick , Theodore Tso , stable@kernel.org Subject: [PATCH 4.9 35/52] ext4: check superblock mapped prior to committing Date: Tue, 10 Jul 2018 20:25:03 +0200 Message-Id: <20180710182452.612088046@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710182449.285532226@linuxfoundation.org> References: <20180710182449.285532226@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jon Derrick commit a17712c8e4be4fa5404d20e9cd3b2b21eae7bc56 upstream. This patch attempts to close a hole leading to a BUG seen with hot removals during writes [1]. A block device (NVME namespace in this test case) is formatted to EXT4 without partitions. It's mounted and write I/O is run to a file, then the device is hot removed from the slot. The superblock attempts to be written to the drive which is no longer present. The typical chain of events leading to the BUG: ext4_commit_super() __sync_dirty_buffer() submit_bh() submit_bh_wbc() BUG_ON(!buffer_mapped(bh)); This fix checks for the superblock's buffer head being mapped prior to syncing. [1] https://www.spinics.net/lists/linux-ext4/msg56527.html Signed-off-by: Jon Derrick Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/super.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4629,6 +4629,14 @@ static int ext4_commit_super(struct supe if (!sbh || block_device_ejected(sb)) return error; + + /* + * The superblock bh should be mapped, but it might not be if the + * device was hot-removed. Not much we can do but fail the I/O. + */ + if (!buffer_mapped(sbh)) + return error; + /* * If the file system is mounted read-only, don't update the * superblock write time. This avoids updating the superblock