Received: by 10.223.185.116 with SMTP id b49csp1018991wrg; Wed, 21 Feb 2018 10:39:52 -0800 (PST) X-Google-Smtp-Source: AH8x226u8UEK8XNazkJui53ABNDh2EjMGwNmL+P8d0gKsCIppsSlHsyordPwW0nezTKBe3pXMora X-Received: by 2002:a17:902:aa87:: with SMTP id d7-v6mr3939530plr.237.1519238391997; Wed, 21 Feb 2018 10:39:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238391; cv=none; d=google.com; s=arc-20160816; b=S2F8S0PX4LywafilHdUorG43rUUmOAZyzmXgJLey7Ijfm8Q+milqlKrzH88USO8had r1eArKVDRm+lvL5MffOlWy81laKJ41p3wXqMpmtSmTc4QLMYP+A0EzXcin2XdHnnceyJ jXqrU0+UHv98xJ4uuX98FUWySYs6BBQEDekd9nSssTHCpeu5RwC7lG4fvwt6RDXIKJcL o1duUFBe2UBhZ1pYUA2AdcVHXn00W9g4WVXihIxwnfMXQUpfdlvhYQQVUGYFlqy5oYsi Qod6zh+RAAU0dt0cZya6uHcPYy3qSXbBnEKO/5ClLRKSN+Eq0rmyOsF1rW/zvl1rMQAq 4ToQ== 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=EqL2NqodpN0zK4PCgPnL5Hh6I+nVqUiCdh153+9fhZo=; b=NLO16DpDFx35uFmYfhOI+psBqVgj3pRbuOSXgXgwHANumGqv15N6ouYOyWY8ELsJqc uFuxoa7Cht6FrkwjUT92gfAMgGoB2nu/L0cXGxScbYbkx3JonAhqv/VBPvlxBOP7PjDh BRM7NuwqK9Y01KVUesDnJIQTRgWLSm4W4+9hdWB+rxlzl3OC1TQwZ+JNLxpsNtTXOtWC ySzLhlmh64cBy2bjRxm0kcHodnJC6tleZU/InfVficEL2TNZRwRgli5WCVhemy8qW+lr LNOYR3+4vZtfPFltGGPhfsHIzZ4Xp4vh1/gae0a+xXFhUiddsnr2nFCFxCqPvIkOJ4Mz UW/w== 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 k189si1701886pgc.598.2018.02.21.10.39.37; Wed, 21 Feb 2018 10:39:51 -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 S1754567AbeBUNN1 (ORCPT + 99 others); Wed, 21 Feb 2018 08:13:27 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:46050 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753216AbeBUNNY (ORCPT ); Wed, 21 Feb 2018 08:13:24 -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 188271107; Wed, 21 Feb 2018 13:13:23 +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.15 137/163] Btrfs: fix extent state leak from tree log Date: Wed, 21 Feb 2018 13:49:26 +0100 Message-Id: <20180221124537.745508657@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124529.931834518@linuxfoundation.org> References: <20180221124529.931834518@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.15-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 @@ -3049,13 +3049,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); } /*