Skip to content

btrfs-progs: fix the filename sanitization of btrfs-image

Qu Wenruo linux-btrfs 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 0 repliesNew
  2. v14 patches 5 repliesSuperseded

Changes in v2 from the cover letter

- Various grammar fixes in the command docs
- Use _mktemp() and _log() when possible
- Use a dedicated filename list, and grep to find an exact match for them.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4btrfs-progs: add warning for -s option of btrfs-imageDocumentation/btrfs-image.rst+12 -70 replies
2/4btrfs-progs: image: fix the bug that filename sanitization not workingimage/sanitize.c+7 -10 replies
3/4btrfs-progs: misc-tests: add a basic resume test using error injectiontests/common tests/misc-tests/065-csum-conversion-inject/test.sh+52 -00 replies
4/4btrfs-progs: misc-tests: add a test case for filename sanitizationtests/misc-tests/065-image-filename/test.sh+38 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] btrfs-progs: fix the filename sanitization of btrfs-image

[CHANGELOG]
v2:
- Various grammar fixes in the command docs
- Use _mktemp() and _log() when possible
- Use a dedicated filename list, and grep to find an exact match for them.

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: misc-tests: add a basic resume test using error injection
btrfs-progs: misc-tests: add a test case for filename sanitization

 Documentation/btrfs-image.rst                 | 19 +++++---
 image/sanitize.c                              |  8 +++-
 tests/common                                  |  7 +++
 .../065-csum-conversion-inject/test.sh        | 45 +++++++++++++++++++
 tests/misc-tests/065-image-filename/test.sh   | 38 ++++++++++++++++
 5 files changed, 109 insertions(+), 8 deletions(-)
 create mode 100755 tests/misc-tests/065-csum-conversion-inject/test.sh
 create mode 100755 tests/misc-tests/065-image-filename/test.sh

--
2.45.2