btrfs: remove the inode_need_compress() call in
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 5 repliesIn review
- v12 patches 0 repliesSuperseded
Changes in v2 from the cover letter
- Fix a bad commit merge
Which merges the commit message for the first patch, though the content is still correct.
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | btrfs: prevent NULL pointer dereference in compress_file_range() when btrfs_compress_pages() hits default casefs/ | +7 | 2 replies | |
| 2/2 | btrfs: inode: don't re-evaluate inode_need_compress() in compress_file_extent()fs/ | +52 | 1 reply |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by.
| Patch | Josef Bacik |
|---|---|
| 1/2 | R-b |
| 2/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 0/2] btrfs: remove the inode_need_compress() call in
This is an attempt to remove the inode_need_compress() call in compress_file_extent().
As that compress_file_extent() can race with inode ioctl or bad compression ratio, to cause NULL pointer dereferecen for @pages, it's nature to try to remove that inode_need_compress() to remove the race completely.
However that's not that easy, we have the following problems:
- We still need to check @pages anyway
That @pages check is for kcalloc() failure, so what we really get is just removing one indent from the if (inode_need_compress()). Everything else is still the same (in fact, even worse, see below problems)
- Behavior change
Before that change, every async_chunk does their check on INODE_NO_COMPRESS flags.
If we hit any bad compression ratio, all incoming async_chunk will fall back to plain text write.
But if we remove that inode_need_compress() check, then we still try to compress, and lead to potentially wasted CPU times.
- Still race between compression disable and NULL pointer dereferecen There is a hidden race, mostly exposed by btrfs/071 test case, that we have "compress_type = fs_info->compress_type", so we can still hit case where that compress_type is NONE (caused by remount -o nocompress), and then btrfs_compress_pages() will return -E2BIG, without modifying @nr_pages
Then later when we cleanup @pages, we try to access pages[i]->mapping, triggering NULL pointer dereference.
This will be address in the first patch though.
Changelog:
v2:
- Fix a bad commit merge
Which merges the commit message for the first patch, though the content is still correct.
Qu Wenruo (2):
btrfs: prevent NULL pointer dereference in compress_file_range() when
btrfs_compress_pages() hits default case
btrfs: inode: don't re-evaluate inode_need_compress() in
compress_file_extent()
fs/btrfs/compression.c | 10 ++-- fs/btrfs/inode.c | 106 ++++++++++++++++++++--------------------- 2 files changed, 59 insertions(+), 57 deletions(-)
Signature · 1 line
2.28.0