All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Harmstone <maharmstone@meta.com>
To: Filipe Manana <fdmanana@kernel.org>
Cc: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
	Qu Wenruo <wqu@suse.com>
Subject: Re: [PATCH] btrfs: don't clobber ret in btrfs_validate_super()
Date: Tue, 11 Mar 2025 18:27:04 +0000	[thread overview]
Message-ID: <f41a50af-bcdd-476d-8f08-bfc9f005b733@meta.com> (raw)
In-Reply-To: <CAL3q7H5aMFgD_p5vE_9jkLN=-vMK-qQinZPaR1d1GUN5iTYjgA@mail.gmail.com>

On 11/3/25 16:54, Filipe Manana wrote:
> > 
> On Tue, Mar 11, 2025 at 4:39 PM Mark Harmstone <maharmstone@fb.com> wrote:
>>
>> Commit 2a9bb78cfd36 introduces a call to validate_sys_chunk_array() in
>> btrfs_validate_super(), which clobbers the value of ret set earlier.
>> This has the effect of negating the validity checks done earlier, making
>> it so btrfs could potentially try to mount invalid filesystems.
>>
>> Signed-off-by: Mark Harmstone <maharmstone@fb.com>
>> Cc: Qu Wenruo <wqu@suse.com>
>> Fixes: 2a9bb78cfd36 ("btrfs: validate system chunk array at btrfs_validate_super()")
>> ---
>>   fs/btrfs/disk-io.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
>> index 0afd3c0f2fab..4421c946a53c 100644
>> --- a/fs/btrfs/disk-io.c
>> +++ b/fs/btrfs/disk-io.c
>> @@ -2562,6 +2562,9 @@ int btrfs_validate_super(const struct btrfs_fs_info *fs_info,
>>                  ret = -EINVAL;
>>          }
>>
>> +       if (ret)
>> +               return ret;
>> +
>>          ret = validate_sys_chunk_array(fs_info, sb);
> 
> While this fixes the problem, the function is structured in a way that
> is easy to get into this sort of issue.
> Rather than set 'ret' to -EINVAL every time some check fails and then
> continue, I'd rather have it return -EINVAL immediately.
> 
> Anyway, this fixes a bug, so:
> 
> Reviewed-by: Filipe Manana <fdmanana@suse.com>

Thanks. Yes, I did think that, but if there's multiple reasons why your 
FS won't mount you probably want to know all of them.

> 
> Thanks.
> 
>>
>>          /*
>> --
>> 2.45.3
>>
>>


  reply	other threads:[~2025-03-11 18:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11 16:39 [PATCH] btrfs: don't clobber ret in btrfs_validate_super() Mark Harmstone
2025-03-11 16:54 ` Filipe Manana
2025-03-11 18:27   ` Mark Harmstone [this message]
2025-03-11 21:10 ` Qu Wenruo
2025-03-12 14:18   ` David Sterba
2025-03-12 14:26 ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f41a50af-bcdd-476d-8f08-bfc9f005b733@meta.com \
    --to=maharmstone@meta.com \
    --cc=fdmanana@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.