Received: by 10.192.165.148 with SMTP id m20csp4141075imm; Mon, 30 Apr 2018 12:30:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqHxRq4UIlL2AsBCIAKkcGhJXBXwCGuQZJUDhGLyHSUylzwKzjMKYeKuSd+mk5Zinn1RF4D X-Received: by 2002:a63:b443:: with SMTP id n3-v6mr4281651pgu.342.1525116646106; Mon, 30 Apr 2018 12:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525116646; cv=none; d=google.com; s=arc-20160816; b=iudszKXUfiJLxuHffyS2UjPtovPJ2g6Cg8SZWhEJckvBvjxnk71eU2U3MBad0GOTl3 gSb9cuvg6WVaqmmzbowddWhVqjNu0p2aMXLqQtjslYMQsHKZP72TWIHnYt0ZSWqJG5qr YFRioVsYmhsVlzRBHWlSKUnerXOXIfeYp5IHRxHRf62bO4Sa4W2vIQoZm0VKHm30MHij PWaJmhkugajJw+i6iiTBaTm/Rvb88NcWmjO8CwxB83RY4LJMLeBIx0wT8foKzQyWFq94 cBryh2gzH0hB6GarTYvgea8TXkqUb90p4qOjWdABXSyCm84XnJFDttX4cMGfL7PIIvzV M1FA== 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=NiyKtxN2e6QAYtppS8rsGxntoTSmRW49UhMpd0fuM0E=; b=td/MchbIW5Sn308ThDb7y5zNGFJShBC4oCnlRbszAycyh4wkqk0/Xnc8zGzTQz4AdV xIs+VHPkW5lXpn/qgBcvFBg9ce3i0tF40ECLZvNTz3Lf40zqvVrIjcdVQTvS4ykEmXNM hq5JEGHy+rhX95p4b0Vzr4ASGribMRUTY9PVm8iORfgNBD5/MZ+XOysQQBPvoaGp9mZv /1qNLuXJQKF4Dd4EuzqpKC4SL7U++L/jWQzqrUzhX1cjRdO0G0lNsrT7TtLfaOOy1mcK 9KmFHwNkKHsQcVWdHEI9V83gq/ccbVkLYv9oM4ulVpqSMyVNooj3ciM7qRi7bnX7FL8V gSCg== 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 1-v6si7941719ply.464.2018.04.30.12.30.01; Mon, 30 Apr 2018 12:30:46 -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 S1756193AbeD3T3m (ORCPT + 99 others); Mon, 30 Apr 2018 15:29:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:37832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932468AbeD3T3i (ORCPT ); Mon, 30 Apr 2018 15:29:38 -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 5B01022DAC; Mon, 30 Apr 2018 19:29:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B01022DAC 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.4 02/44] ext4: set h_journal if there is a failure starting a reserved handle Date: Mon, 30 Apr 2018 12:24:13 -0700 Message-Id: <20180430190946.410293362@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430190946.093694747@linuxfoundation.org> References: <20180430190946.093694747@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.4-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 @@ -527,6 +527,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; }