Received: by 10.192.165.148 with SMTP id m20csp4141915imm; Mon, 30 Apr 2018 12:31:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZodV6Io0eWgq9j46VMvzheZfM2ul3LHu9McEMMZYDewDYIg1pL15PzQ8pWw66TuzR0MLEi7 X-Received: by 2002:a63:a74b:: with SMTP id w11-v6mr10876730pgo.351.1525116709054; Mon, 30 Apr 2018 12:31:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525116709; cv=none; d=google.com; s=arc-20160816; b=E3buNOvCwJOc/s9l9wvENl3ioa+8MoOAn302R8/ksgTL4E8paJydYEvqh+3eNuJcyb fs26bIK8trJPUdzw3VXUEUBK8AUjeM8cN7nWAwuQdcCFhBA90uoZsaGPT47Wtf0qrNv+ UoXZ6Kvmp0uTPIRsCg4XViVyWyr5Jm7NU+kxm6dovxpSljgyC9VWEj+baEcATixIuZ/t SZkq5Sc+iJ4P1p71+aOK/PPUgUGMf90oPFO5bfsweiLTcBywI3F2Jmy59dNJX7KvUyTQ hbBNfAh1IqWRy+Jxo+Ce2RxmmBjhGtK0w+Dyh4TZf9xUK0ibT7ZkTZMDPg3OLhPFedY1 6tkQ== 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:dmarc-filter :arc-authentication-results; bh=7YG6bYrNVL6kLzTYwFqN3vF1x4QGtpXHBKW/LdaAzRM=; b=r/NsuJaFn17XVxv1/nyue9hX+v5Xn/8X2Gsy2X7zCjl/jRjdVe5CN49PyV/roXdMoO jHoG+VdLCn9s2jhVzG3WfICuq9026p8ZAKkrRPgNNEvH6CyTFLRRZ2/EbonrOzQdPd+Z 3lgf9gktPxR7GIeC9HrWSrU5darohef/HvDO9nZYQ7qFToZXycpxo3ZRKdIux0mzUgX9 lu8QhEg/eW1AQ9nLsMw8KGiq8lrv5mogBz4n8r46vPWUR4BlE6GuL2noUYtQ1VvM5ldT +mNv/mJ9n/r4GbXx8F0Gxp5JT5h0+4jgHcyDaCvv2OPCaL7/6Z69IATaD9y7pIpqzPkV M4Cw== 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 f59-v6si8056099plf.38.2018.04.30.12.31.34; Mon, 30 Apr 2018 12:31: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 S932590AbeD3Tal (ORCPT + 99 others); Mon, 30 Apr 2018 15:30:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:38324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756483AbeD3Taj (ORCPT ); Mon, 30 Apr 2018 15:30:39 -0400 Received: from localhost (unknown [104.132.1.102]) (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 D5FCF22DAA; Mon, 30 Apr 2018 19:30:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5FCF22DAA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso , Andreas Dilger , Jan Kara Subject: [PATCH 4.16 002/113] ext4: set h_journal if there is a failure starting a reserved handle Date: Mon, 30 Apr 2018 12:23:33 -0700 Message-Id: <20180430184015.170310390@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o commit b2569260d55228b617bd82aba6d0db2faeeb4116 upstream. If ext4 tries to start a reserved handle via jbd2_journal_start_reserved(), and the journal has been aborted, this can result in a NULL pointer dereference. This is because the fields h_journal and h_transaction in the handle structure share the same memory, via a union, so jbd2_journal_start_reserved() will clear h_journal before calling start_this_handle(). If this function fails due to an aborted handle, h_journal will still be NULL, and the call to jbd2_journal_free_reserved() will pass a NULL journal to sub_reserve_credits(). This can be reproduced by running "kvm-xfstests -c dioread_nolock generic/475". Cc: stable@kernel.org # 3.11 Fixes: 8f7d89f36829b ("jbd2: transaction reservation support") Signed-off-by: Theodore Ts'o Reviewed-by: Andreas Dilger Reviewed-by: Jan Kara Signed-off-by: Greg Kroah-Hartman --- fs/jbd2/transaction.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -532,6 +532,7 @@ int jbd2_journal_start_reserved(handle_t */ ret = start_this_handle(journal, handle, GFP_NOFS); if (ret < 0) { + handle->h_journal = journal; jbd2_journal_free_reserved(handle); return ret; }