Received: from mail.burntcomma.com (mail2.burntcomma.com [217.169.27.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C07E3342503 for ; Wed, 18 Feb 2026 15:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.169.27.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771430126; cv=none; b=nRNgpi79spurh3GWayQG0jcRXvxC+sNBbe5bK6AiBdPmIfqm2Knd/KCrZmRANMvVjP0m0+41Bjc49W7a65Ylyza8VmRjXm3RRI9XK8er+Artz1lx0EAyZSNrf2Pjb0iaoKN2fJ5jgYiY/4Df3pf89OuGLc8tY9UbMqvb4JEPDQQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771430126; c=relaxed/simple; bh=I1it41f4+Jw9ou1GGOSrdrRftUmVt0NR6Fq12+gy80g=; h=Message-ID:Date:Mime-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dUZ/qR8PB/f/K6y4FYZ3hgs0pCvMVSBkI2pjbo+l6rCWTe+fadkgi7D6BUdFF3qwmZd2O7pQGK2s/jyI2koQIz5DnJ23hMzyH++Xci5jaWzCkQeNp0hFGG6RX/2JngtOJGYfD07W4KJ00Bl1hWUqbLUjw8pv1Pr9T+GLKYBrtcc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=harmstone.com; spf=pass smtp.mailfrom=harmstone.com; dkim=pass (1024-bit key) header.d=harmstone.com header.i=@harmstone.com header.b=vDWdy1hD; arc=none smtp.client-ip=217.169.27.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=harmstone.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=harmstone.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=harmstone.com header.i=@harmstone.com header.b="vDWdy1hD" Received: from [IPV6:2a02:8012:8cf0:0:ce28:aaff:fe0d:6db2] (beren.burntcomma.com [IPv6:2a02:8012:8cf0:0:ce28:aaff:fe0d:6db2]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "hellas", Issuer "burntcomma.com" (verified OK)) by mail.burntcomma.com (Postfix) with ESMTPS id DCDE730383F; Wed, 18 Feb 2026 15:55:19 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=harmstone.com; s=mail; t=1771430119; bh=a5BMWqt3E+L/WJYGqbeWWJp8qzVxdmkjvGl/3xoYxKw=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=vDWdy1hDLbi054Rd+cylqXG9vyL2aub+VWLXeQxcXFC1RzJr3iwrxpFoDlC2i++Gp Y+dDaYJs/fwGLg2IZtG/+yzjzjRLtQtWkr9eHNesn0Qwt5GIJaM8i+Ci5NQRwvcazA L+iuEjq2Bso+J9q/he4kfpYuS96v5HCzc34TQ/qk= Message-ID: <408293e5-75f8-461b-9d0e-65ff95027a0b@harmstone.com> Date: Wed, 18 Feb 2026 15:55:19 +0000 Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Subject: Re: [PATCH] btrfs: fix chunk map leaks in btrfs_map_block() To: Filipe Manana Cc: linux-btrfs@vger.kernel.org, Chris Mason References: <20260218143334.25014-1-mark@harmstone.com> Content-Language: en-US From: Mark Harmstone Autocrypt: addr=mark@harmstone.com; keydata= xsBNBFp/GMsBCACtFsuHZqHWpHtHuFkNZhMpiZMChyou4X8Ueur3XyF8KM2j6TKkZ5M/72qT EycEM0iU1TYVN/Rb39gBGtRclLFVY1bx4i+aUCzh/4naRxqHgzM2SeeLWHD0qva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gYFTroHD9n+QAR AQABwsGsBBgBCAAgFiEEG2JgKYgV0WRwIJAqbKyhHeAWK+0FAlp/GMsCGy4BQAkQbKyhHeAW K+3AdCAEGQEIAB0WIQR6bEAu0hwk2Q9ibSlt5UHXRQtUiwUCWn8YywAKCRBt5UHXRQtUiwdE B/9OpyjmrshY40kwpmPwUfode2Azufd3QRdthnNPAY8Tv9erwsMS3sMh+M9EP+iYJh+AIRO7 fDN/u0AWIqZhHFzCndqZp8JRYULnspXSKPmVSVRIagylKew406XcAVFpEjloUtDhziBN7ykk srAMoLASaBHZpAfp8UAGDrr8Fx1on46rDxsWbh1K1h4LEmkkVooDELjsbN9jvxr8ym8Bkt54 FcpypTOd8jkt/lJRvnKXoL3rZ83HFiUFtp/ZkveZKi53ANUaqy5/U5v0Q0Ppz9ujcRA9I/V3 B66DKMg1UjiigJG6espeIPjXjw0n9BCa9jqGICyJTIZhnbEs1yEpsM87eUIH/0UFLv0b8IZe pL/3QfiFoYSqMEAwCVDFkCt4uUVFZczKTDXTFkwm7zflvRHdy5QyVFDWMyGnTN+Bq48Gwn1M uRT/Sg37LIjAUmKRJPDkVr/DQDbyL6rTvNbA3hTBu392v0CXFsvpgRNYaT8oz7DDBUUWj2Ny 6bZCBtwr/O+CwVVqWRzKDQgVo4t1xk2ts1F0R1uHHLsX7mIgfXBYdo/y4UgFBAJH5NYUcBR+ QQcOgUUZeF2MC9i0oUaHJOIuuN2q+m9eMpnJdxVKAUQcZxDDvNjZwZh+ejsgG4Ejd2XR/T0y XFoR/dLFIhf2zxRylN1xq27M9P2t1xfQFocuYToPsVk= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 18/02/2026 2.54 pm, Filipe Manana wrote: > On Wed, Feb 18, 2026 at 2:33 PM Mark Harmstone wrote: >> >> Fix the two early returns in btrfs_map_block() so that we can no longer >> fail to put the chunk map after getting it. >> >> Signed-off-by: Mark Harmstone >> Reported-by: Chris Mason > > So being a bug fix, this is the type of patch that should have a Fixes tag. > > The commit that introduced the first leak is not in any released > kernel, so no stable releases are affected. > However it's still useful to have the Fixes tag here, because in case > someone decides to backport the offending commit, either upstream or > downstream, there are scripts in place to check if there are newer > commits that fix a bug in the former commit and therefore must be > backported as well. > > But the second leak was introduced in a much older commit, from 2024, > and should be backported. > Se comments inline below. > > Also, since this was reported publicly, please add a Link tag pointing > to the URL with the review. > >> --- >> fs/btrfs/volumes.c | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c >> index 83e2834ea273..a1f0fccd552c 100644 >> --- a/fs/btrfs/volumes.c >> +++ b/fs/btrfs/volumes.c >> @@ -7082,7 +7082,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, >> >> ret = btrfs_translate_remap(fs_info, &new_logical, length); >> if (ret) >> - return ret; >> + goto out; > > For this hunk: > > Fixes: 18ba64992871 ("btrfs: redirect I/O for remapped block groups") > >> >> if (new_logical != logical) { >> btrfs_free_chunk_map(map); >> @@ -7096,8 +7096,10 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, >> } >> >> num_copies = btrfs_chunk_map_num_copies(map); >> - if (io_geom.mirror_num > num_copies) >> - return -EINVAL; >> + if (io_geom.mirror_num > num_copies) { >> + ret = -EINVAL; >> + goto out; >> + } > > For this hunk: > > Fixes: 0ae653fbec2b ("btrfs: reduce chunk_map lookups in btrfs_map_block()") > > I would suggest splitting this into 2 different patches, each one with > the respective Fixes tag so that the second leak can be backported > more easily. Thanks Filipe, I'll do just that. Please ignore this one. > >> >> map_offset = logical - map->start; >> io_geom.raid56_full_stripe_start = (u64)-1; >> -- >> 2.52.0 >> >>