Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3226318imu; Sat, 24 Nov 2018 00:32:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/VyMyaRQlEy6odETkk7qeLKMfUS+UOIn5DEKgb1haOv7DTDPyYIT9uUBpzUmzwFwWo3Np2o X-Received: by 2002:a63:f65:: with SMTP id 37mr16957612pgp.238.1543048366256; Sat, 24 Nov 2018 00:32:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543048366; cv=none; d=google.com; s=arc-20160816; b=CoJc7WPO/MHRvtlkk5CI8Li5xqeG0/bfeeORsHANDItWcY3kjcD/BnfXzCL+3QiI/H SAIxJRzqnX3a25k/DeCVjsCDvjEVKXQ8rrRKw1jo97XkiAIs9eL5f+hxMo4lfFOgnwKo Z5Jujkoal8Ol0CoYR2UJPmDpjc8NNUtXBr6YM/usXkHPhSNB6LnWKeSEjvxHdC1Ot8Kq ZTVo/3fvpA/b88XUThb/9A5LnEmSTk9Qj+h+PIcjUtKtqtblBNjiZdRogYbQ+WYHwb37 8ZdkMx4+sPEltl35tbv439X2YkyV4oCXTIUkGFPfZvR4eO5gBfEIcMvXZWp5gDpyJhRQ SfMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :reply-to:message-id:subject:cc:to:from:date; bh=Hurc8+Pca2r85QQotr6j2uB7hFAi/KyT0bmrQ8s92ds=; b=I83KRBoFqUBF//Ya1lXUlbsK4lwOLVh0kXpxJ0mXKE1ScPIhKQQkoauL9W96qo/ZnN B5PMfvMoN9L7YhOD70LWmoML991Bc6BFNIc43jTPWuPXKqjLKPV/ajA5fKDFvlWszKvw UQFkDPFFtxD7D9RvjO9fPi5eL0VZtAryAbLRpN4ohxrcbBpetzLo2faCoRdoCnkPbERo VK2dxnWShPlXuPry3j9hbxyxq0u3jJCjlJ6RiMotYvKtmodtAzNwDTE9AlO0LZTKWIMa cb/HK3yxdWOyF12XY34ZdEZ1vtI7u9JC7yyw637NjWbdI6LSNwocnIHQKhSsjorJPO0B lYiQ== 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 p64si3813738pfa.94.2018.11.24.00.32.31; Sat, 24 Nov 2018 00:32:46 -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 S2409939AbeKWXbK (ORCPT + 99 others); Fri, 23 Nov 2018 18:31:10 -0500 Received: from mx2.suse.de ([195.135.220.15]:38614 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2394756AbeKWXbJ (ORCPT ); Fri, 23 Nov 2018 18:31:09 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AFDB7AEFA; Fri, 23 Nov 2018 12:47:04 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id BCF29DA858; Fri, 23 Nov 2018 13:46:49 +0100 (CET) Date: Fri, 23 Nov 2018 13:46:49 +0100 From: David Sterba To: Pan Bian Cc: Chris Mason , Josef Bacik , David Sterba , Wang Shilong , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] btrfs: relocation: set trans to be NULL after free Message-ID: <20181123124648.GB2842@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Pan Bian , Chris Mason , Josef Bacik , David Sterba , Wang Shilong , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <1542967815-14547-1-git-send-email-bianpan2016@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1542967815-14547-1-git-send-email-bianpan2016@163.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 23, 2018 at 06:10:15PM +0800, Pan Bian wrote: > The function relocate_block_group calls btrfs_end_transaction to release > trans when update_backref_cache returns 1, and then continues the loop > body. If btrfs_block_rsv_refill fails this time, it will jump out the > loop and the freed trans will be accessed. This may result in a > use-after-free bug. The patch assigns NULL to trans after trans is > released so that it will not be accessed. > > Fixes: 0647bf564f1("Btrfs: improve forever loop when doing balance > relocation") > > Signed-off-by: Pan Bian Good catch, thanks. Reviewed-by: David Sterba