mbox series

[0/4] btrfs-progs: fix the filename sanitization of btrfs-image

Message ID cover.1720415116.git.wqu@suse.com (mailing list archive)
Headers show
Series btrfs-progs: fix the filename sanitization of btrfs-image | expand

Message

Qu Wenruo July 8, 2024, 5:14 a.m. UTC
There are several bugs in btrfs-image filename sanitization:

- Ensured kernel path resolution bug
  Since during path resolution btrfs uses hash to find the child inode,
  with garbage filled DIR_ITEMs, it's definitely unable to properly
  resolve the path.

  A warning is added to the man page by the first patch.

- Only the last item got properly sanitized
  All the remaining INODE_REF/DIR_INDEX/DIR_ITEM are not sanitized at
  all.

  This is fixed by the second patch.

- Sanitized filename contains non-ASCII chars
  This is fixed by the third patch.


Finally a new test case is introduced to verify the filename
sanitization behavior of btrfs-image.

Qu Wenruo (4):
  btrfs-progs: add warning for -s option of btrfs-image
  btrfs-progs: image: fix the bug that filename sanitization not working
  btrfs-progs: fix rand_range()
  btrfs-progs: misc-tests: add a test case for filename sanitization

 Documentation/btrfs-image.rst               | 17 ++++++-----
 common/utils.c                              | 10 +++----
 image/sanitize.c                            |  8 ++++-
 tests/misc-tests/065-image-filename/test.sh | 33 +++++++++++++++++++++
 4 files changed, 55 insertions(+), 13 deletions(-)
 create mode 100755 tests/misc-tests/065-image-filename/test.sh

--
2.45.2

Comments

Qu Wenruo July 14, 2024, 10:09 p.m. UTC | #1
Ping?

Any update on this?

Thanks,
Qu

在 2024/7/8 14:44, Qu Wenruo 写道:
> There are several bugs in btrfs-image filename sanitization:
> 
> - Ensured kernel path resolution bug
>    Since during path resolution btrfs uses hash to find the child inode,
>    with garbage filled DIR_ITEMs, it's definitely unable to properly
>    resolve the path.
> 
>    A warning is added to the man page by the first patch.
> 
> - Only the last item got properly sanitized
>    All the remaining INODE_REF/DIR_INDEX/DIR_ITEM are not sanitized at
>    all.
> 
>    This is fixed by the second patch.
> 
> - Sanitized filename contains non-ASCII chars
>    This is fixed by the third patch.
> 
> 
> Finally a new test case is introduced to verify the filename
> sanitization behavior of btrfs-image.
> 
> Qu Wenruo (4):
>    btrfs-progs: add warning for -s option of btrfs-image
>    btrfs-progs: image: fix the bug that filename sanitization not working
>    btrfs-progs: fix rand_range()
>    btrfs-progs: misc-tests: add a test case for filename sanitization
> 
>   Documentation/btrfs-image.rst               | 17 ++++++-----
>   common/utils.c                              | 10 +++----
>   image/sanitize.c                            |  8 ++++-
>   tests/misc-tests/065-image-filename/test.sh | 33 +++++++++++++++++++++
>   4 files changed, 55 insertions(+), 13 deletions(-)
>   create mode 100755 tests/misc-tests/065-image-filename/test.sh
> 
> --
> 2.45.2
> 
>
David Sterba July 18, 2024, 3:47 p.m. UTC | #2
On Mon, Jul 15, 2024 at 07:39:32AM +0930, Qu Wenruo wrote:
> Ping?
> 
> Any update on this?

Tracked as https://github.com/kdave/btrfs-progs/pull/837
Qu Wenruo July 18, 2024, 10:38 p.m. UTC | #3
在 2024/7/19 01:17, David Sterba 写道:
> On Mon, Jul 15, 2024 at 07:39:32AM +0930, Qu Wenruo wrote:
>> Ping?
>>
>> Any update on this?
>
> Tracked as https://github.com/kdave/btrfs-progs/pull/837
>

Just to mention, since the github review system is working now, do you
prefer me to still send the updated patches to the ML?
I'm mostly using the ML as a way to track the work...

Thanks,
Qu
David Sterba July 18, 2024, 10:55 p.m. UTC | #4
On Fri, Jul 19, 2024 at 08:08:30AM +0930, Qu Wenruo wrote:
> 在 2024/7/19 01:17, David Sterba 写道:
> > On Mon, Jul 15, 2024 at 07:39:32AM +0930, Qu Wenruo wrote:
> >> Ping?
> >>
> >> Any update on this?
> >
> > Tracked as https://github.com/kdave/btrfs-progs/pull/837
> 
> Just to mention, since the github review system is working now, do you
> prefer me to still send the updated patches to the ML?
> I'm mostly using the ML as a way to track the work...

You don't need to send it to the mailinglist if there's a PR, for
tracking purposes it's ok to send it. It would be good to keep
dicsussion at one place but I think this won't be common or we'll
manage.
Qu Wenruo July 19, 2024, 12:46 a.m. UTC | #5
在 2024/7/19 08:25, David Sterba 写道:
> On Fri, Jul 19, 2024 at 08:08:30AM +0930, Qu Wenruo wrote:
>> 在 2024/7/19 01:17, David Sterba 写道:
>>> On Mon, Jul 15, 2024 at 07:39:32AM +0930, Qu Wenruo wrote:
>>>> Ping?
>>>>
>>>> Any update on this?
>>>
>>> Tracked as https://github.com/kdave/btrfs-progs/pull/837
>>
>> Just to mention, since the github review system is working now, do you
>> prefer me to still send the updated patches to the ML?
>> I'm mostly using the ML as a way to track the work...
> 
> You don't need to send it to the mailinglist if there's a PR, for
> tracking purposes it's ok to send it. It would be good to keep
> dicsussion at one place but I think this won't be common or we'll
> manage.

Got it. Would mention the PR URL in the future cover letters, so 
discussion would still happen there.

Thanks,
Qu