Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3965434img; Mon, 25 Mar 2019 23:41:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwT6lroorFvuUVNUC2kXd39Mn2t5P1Yo5lYBNbCZyu60FPgDrGgSXqIjVjmmhFC1u5gfQMI X-Received: by 2002:a17:902:396a:: with SMTP id e39mr7489776plg.220.1553582500360; Mon, 25 Mar 2019 23:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553582500; cv=none; d=google.com; s=arc-20160816; b=lKRXAEI1FbZcYE6nAzrGtuILxd07QfLCAqFoK/FKi/ptXHAxVxAZWv29VP+RZqCys3 wv+XFifyMV0gw/vn71bnvcFIJiQKw5FrTf8rw6c5ZS8O6Qt9hJVYgixLgxj3LrMpwmnB rc9gAAWK7GnP1bdZK5XY7cY3gdmosNWaabFD1iIP6iWkNVX19UTrzDd8I+iXl+IEvOdf UrGajI7aCP0X1inydYQPaunO2KeGyvmR47L/qNqAU+QQXTCMJFBiWPX6xeVr/syVuLEl J7XeG8HHH+jCvowOo+z/Bib/ywQVmOJnOpiwTuET8I5LEVvtwThU8bnpPqIf4Tz0TTB4 YayA== 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=aP7t21MH2/9jWNS+z4FfrODurtVxBV2q2+40BYnritc=; b=U9f9w+CgoSPXGZB08Ev+6EzftSBWXrQfTBeIlpYVOj+G4Hr5ZjxmcLE7ER5Od3z3ko pO6gadR1sOtK0IqOuZ+fHHoiNYFQrTgkgVt4sewcYPZa+nx5InDS0bSvpdVW/nV6X/Qj U9PP3f+P9lw1cWhyCACywHbC6ZFSLmA00MDOA+g2gAH1v1Wr3qyCD5eCvonBkqWwKiCr obkDn+Apvik+KkQSOIdE50RKXlORHHyPLFPvUD1okrmfyGuqjUQ1EbR8ILgXlYZ30T3a /ip79wF/ybmM0TfAerqsQws9/tRk/5tTvhsyM28xdZnkHtf6lbcyaTngRA+Zte51pWBi hmhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="XlH6sl9/"; 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 x6si4779473pfa.59.2019.03.25.23.41.25; Mon, 25 Mar 2019 23:41:40 -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="XlH6sl9/"; 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 S1732698AbfCZGj1 (ORCPT + 99 others); Tue, 26 Mar 2019 02:39:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:54856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731504AbfCZGjZ (ORCPT ); Tue, 26 Mar 2019 02:39:25 -0400 Received: from localhost (unknown [104.132.152.111]) (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 787D320863; Tue, 26 Mar 2019 06:39:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553582365; bh=CqJnK4VxGxe3ZzTtXCR+fPZ5RTuwt8BRkdpM7PAdZuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XlH6sl9/VYNrPwsFzgOXAIZCiZf5G0mSwFD2PN3GXGLq/2u4PwZOBs9K3DmdmHmPY pi48w9LRy8eyeQQ2/q3OhZdqnzGifCPbVvRsDUS91KJICu+EYFAs/dp/+4mkRPIj50 7L8AMTswqupD449RxVoUGoD0JDCeRSGQwRRxdscU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiufei Xue , Theodore Tso , Joseph Qi , stable@kernel.org Subject: [PATCH 5.0 33/52] ext4: fix NULL pointer dereference while journal is aborted Date: Tue, 26 Mar 2019 15:30:20 +0900 Message-Id: <20190326042702.719875504@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190326042700.963224437@linuxfoundation.org> References: <20190326042700.963224437@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiufei Xue commit fa30dde38aa8628c73a6dded7cb0bba38c27b576 upstream. We see the following NULL pointer dereference while running xfstests generic/475: BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 PGD 8000000c84bad067 P4D 8000000c84bad067 PUD c84e62067 PMD 0 Oops: 0000 [#1] SMP PTI CPU: 7 PID: 9886 Comm: fsstress Kdump: loaded Not tainted 5.0.0-rc8 #10 RIP: 0010:ext4_do_update_inode+0x4ec/0x760 ... Call Trace: ? jbd2_journal_get_write_access+0x42/0x50 ? __ext4_journal_get_write_access+0x2c/0x70 ? ext4_truncate+0x186/0x3f0 ext4_mark_iloc_dirty+0x61/0x80 ext4_mark_inode_dirty+0x62/0x1b0 ext4_truncate+0x186/0x3f0 ? unmap_mapping_pages+0x56/0x100 ext4_setattr+0x817/0x8b0 notify_change+0x1df/0x430 do_truncate+0x5e/0x90 ? generic_permission+0x12b/0x1a0 This is triggered because the NULL pointer handle->h_transaction was dereferenced in function ext4_update_inode_fsync_trans(). I found that the h_transaction was set to NULL in jbd2__journal_restart but failed to attached to a new transaction while the journal is aborted. Fix this by checking the handle before updating the inode. Fixes: b436b9bef84d ("ext4: Wait for proper transaction commit on fsync") Signed-off-by: Jiufei Xue Signed-off-by: Theodore Ts'o Reviewed-by: Joseph Qi Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/ext4_jbd2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/ext4/ext4_jbd2.h +++ b/fs/ext4/ext4_jbd2.h @@ -384,7 +384,7 @@ static inline void ext4_update_inode_fsy { struct ext4_inode_info *ei = EXT4_I(inode); - if (ext4_handle_valid(handle)) { + if (ext4_handle_valid(handle) && !is_handle_aborted(handle)) { ei->i_sync_tid = handle->h_transaction->t_tid; if (datasync) ei->i_datasync_tid = handle->h_transaction->t_tid;