Received: by 10.223.185.116 with SMTP id b49csp970918wrg; Wed, 21 Feb 2018 09:52:49 -0800 (PST) X-Google-Smtp-Source: AH8x227i/YQsvSoJmXRrSfNV3k4PAAM2nuwwzjEb5bvdp3E/l33l741AB+smu4gg56CX2vXXFUdH X-Received: by 2002:a17:902:34e:: with SMTP id 72-v6mr3867502pld.277.1519235569642; Wed, 21 Feb 2018 09:52:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519235569; cv=none; d=google.com; s=arc-20160816; b=tn2boXiVJKq6m9SQzJKIkpTEOQFiAgNPRKiiFu9EdIGMNgvOoq3TF9HLYzDosua86+ pCrGNBF+Cg0cRtdwVubK86hkwdDwrbHCGxQC8sGtfaTn+F/iKa7zKrpPM+GLpTr+cCgB wnJn69ytzo4BxDY2TB90YPGJQ4UXWV8/SOfYJRuzUTwbbMIDwI1x0z7YZPfYGpKzNoru BxjiMd5R++ZXgHqZA0wcWWnzGjcoDSQoXWwZNstu+ghI7DsypTQvqklSLY4rntQ8Rdla B0TqJ7os5UZo001gFztMlL+h5M+83p81dJt+9GdBbqux5pvz5qM9ht72ASmnQyTHq8qt ShNg== 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 :arc-authentication-results; bh=+2wrC7Dc+0EiltFho6sq+CssfYQhm+9TyoqkkHCejy0=; b=bp2WOg+aXoGK59Ib7jwiSuHEq8Rnt9CQ3mlgDdMIJNK9M3H+j68a7ambulWjhusgX/ 1Lip9/89d7XCD2QGyYefReh69VutNTvn8A3y14D90W7p6XqK1J6W9uklah2kX0TKhxDO an1eB9CAssCn3E7DqHLqgJrk++AxON+VqlIugqIr7qOchmHS2oqPTu8rTP6Ri521/+3F NGHqQQ5nwpl27uysBmBAQP18uPcilTDLNJl6P2OWDP0DD6BEXoRU9VFceXYA6P4x2CW6 aGhYsESvqRSReMQP7LwddovirPfcvEzMoy4M2Cguajq5bFZdhQfpj9Yze+Z93yjJZjfJ I74w== 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 v4-v6si1304399plo.55.2018.02.21.09.52.35; Wed, 21 Feb 2018 09:52:49 -0800 (PST) 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 S934143AbeBUMyt (ORCPT + 99 others); Wed, 21 Feb 2018 07:54:49 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34192 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934114AbeBUMys (ORCPT ); Wed, 21 Feb 2018 07:54:48 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7C0861155; Wed, 21 Feb 2018 12:54:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liu Bo , Josef Bacik , David Sterba Subject: [PATCH 4.9 20/77] Btrfs: fix extent state leak from tree log Date: Wed, 21 Feb 2018 13:48:29 +0100 Message-Id: <20180221124433.029399304@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124432.172390020@linuxfoundation.org> References: <20180221124432.172390020@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: Liu Bo commit 55237a5f2431a72435e3ed39e4306e973c0446b7 upstream. It's possible that btrfs_sync_log() bails out after one of the two btrfs_write_marked_extents() which convert extent state's state bit into EXTENT_NEED_WAIT from EXTENT_DIRTY/EXTENT_NEW, however only EXTENT_DIRTY and EXTENT_NEW are searched by free_log_tree() so that those extent states with EXTENT_NEED_WAIT lead to memory leak. cc: Signed-off-by: Liu Bo Reviewed-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/tree-log.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3013,13 +3013,14 @@ static void free_log_tree(struct btrfs_t while (1) { ret = find_first_extent_bit(&log->dirty_log_pages, - 0, &start, &end, EXTENT_DIRTY | EXTENT_NEW, + 0, &start, &end, + EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT, NULL); if (ret) break; clear_extent_bits(&log->dirty_log_pages, start, end, - EXTENT_DIRTY | EXTENT_NEW); + EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT); } /*