Received: by 10.192.165.148 with SMTP id m20csp4144265imm; Mon, 30 Apr 2018 12:35:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqVjmA0FT8W7BL2I0thu367GfFsh8RLtyY3r5n+9elXcoQiFvkph2l+rGF3OCK14tfJyYnL X-Received: by 2002:a65:5047:: with SMTP id k7-v6mr10752527pgo.93.1525116903834; Mon, 30 Apr 2018 12:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525116903; cv=none; d=google.com; s=arc-20160816; b=B2LvSFGj1Uua0rjmzaznA7FwK7dz6VtwCoS3W+XNbkPrI1AnqbQJE78KTEKWjbbVp7 QjsvQR7nRllf51WEviZ0I4Q7pGXY3cZ10BVvMgjbg7t31t3vU6M2aDdl3obspm97grbK RNMsi9dMSrjQFH2Zjl/SqegOZQb+u7DoGZ2hlNjTXklWfVOWimpY7iW3mBB3gk6M/mAv jXzwxXx8e81+k4PvfoubkwcRh074YXziGOzLzYTtuiIl6zmeEYlIp4WZ9f732E26I1GS lBqo+UW3Vg7jpFI2QWXh7gS7TgtnEVw5w3h9+mVbVRxY7HVsIDgrN86Mbt6LRaJpOg6h v0mA== 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=CfSFftIVdiqpOmfSZXSs5wlBfqSezwIobvzGydgOfcw=; b=aQa60aYcJ6hvYKKEHFrxY82Dzk3MsUNS7uU+zevVN24IYcqxOWpbnhXl6Rfj1aARWy BVQM0WdAi0oqtChQhPRsUNA3YEQZBdshjjLA/bzdvZ7cQQr1ERvXPvjsjBUcSQTKAEDH gD1p26Z4qj6+zXsB43EBxgsx6Frk7/q7SNv+A5NxTTNzwpUHVSmo06v3lWlK8gjt/Tq8 aNM5FHFiqJnVXyhnYJL1EG2SSklUBVacA6bqRKGMutguYO/KPM53D17eiDt8lKxyPumI fa7Ezmv9kx1ZwUBSX5mVgKKgGOAArgpYEWsk0SLs/rt6eiECQcpNtLaMuEfd2+t+16PG zT8Q== 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 g28-v6si8014907plj.529.2018.04.30.12.34.19; Mon, 30 Apr 2018 12:35:03 -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 S1756463AbeD3TaE (ORCPT + 99 others); Mon, 30 Apr 2018 15:30:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:37976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755751AbeD3T3v (ORCPT ); Mon, 30 Apr 2018 15:29:51 -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 730D822DAC; Mon, 30 Apr 2018 19:29:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 730D822DAC 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.9 02/61] ext4: set h_journal if there is a failure starting a reserved handle Date: Mon, 30 Apr 2018 12:24:05 -0700 Message-Id: <20180430183951.537285237@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430183951.312721450@linuxfoundation.org> References: <20180430183951.312721450@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: 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 @@ -528,6 +528,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; }