Received: by 10.192.165.148 with SMTP id m20csp4143073imm; Mon, 30 Apr 2018 12:33:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpV4GB8HftQcaDS0uP5u8EBvFbydaKJlUNmaG6bGWdEFY5+aQcjySfVA8LR+wDpxCjFls+z X-Received: by 2002:a63:8c4d:: with SMTP id q13-v6mr11015972pgn.44.1525116806299; Mon, 30 Apr 2018 12:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525116806; cv=none; d=google.com; s=arc-20160816; b=zaLjERiwG546hTbau2h7QKcvNrqFoV6S2BHnpRwS0jL2kwz9JvJlM6sQbbVK4/5TcN hN281LISOl36KnSi9BcbUxZWMzcLgMb2dqaiu60nh/0Sg6669AbCMK1lifCOBlC3G2Gh oy6C3ig1EEC0rbWT23wp+3zTgIFUjEppamFp/xT2rUf1Ax0XCNAxJFVul+AwPZjZxt2U yVnQzYH+/SjrUt1nNy0C6QpXd88oFwZbw8bx+ETRvvsUvs/IgZn4yaEG+hNGpw/rjXGk OTZgGmQnV4/A9JEymlWvim7+XH/bl0vgpON2KPxWfSlBUu2XAMBNwGo2rbfT9mlbQrjw CMrw== 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=CyLa2c4x/vem9zLj0xjxE/IiSQSlTU84I3Gwrfz95Gw=; b=GMbwlKWDY6NNI4iLaLbXLLmLPoHyQVeQl7tqZtoTh/3oMGN08UU3AUb+Xqcg65bg74 dm3h9xWxnvIlQ5n/ruFanykQ+3Ajwzn4VOG0vndcpbNZswcWbLbV1bHyQukp6HLcOvIP rjKBGKKvleffgujgJvgEqpuxJ7qINGXqCMvLpGGKQa1VmQXRtzYAra4pwfwLQRrkwyKL BSb3oZIFSsxz4vHhWAjkeOwRhQki+eZ9Ge9ZEfTweBfTqsG/pxT+AQQ9A5+dMFpJygOV CPl82a/Jyp38eJCEHo27Vcc2o+2lypMH4mdBg6eRBLE1mGf9GrwTCwcqJiqIa5pP3kbd 9xEA== 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 d65si8179925pfa.263.2018.04.30.12.33.12; Mon, 30 Apr 2018 12:33:26 -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 S1756512AbeD3TbD (ORCPT + 99 others); Mon, 30 Apr 2018 15:31:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:38202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756482AbeD3TaW (ORCPT ); Mon, 30 Apr 2018 15:30:22 -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 C3B3422DAC; Mon, 30 Apr 2018 19:30:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3B3422DAC 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.14 02/91] ext4: set h_journal if there is a failure starting a reserved handle Date: Mon, 30 Apr 2018 12:23:44 -0700 Message-Id: <20180430184004.346695281@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@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.14-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 @@ -535,6 +535,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; }