Re: [PATCH] btrfs: Fix avail_in bytes for s390 zlib HW compression path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





在 2024/12/13 00:20, Mikhail Zaslonko 写道:
Since the input data length passed to zlib_compress_folios() can be
arbitrary, always setting strm.avail_in to a multiple of PAGE_SIZE may
cause read-in bytes to exceed the input range. Currently this triggers
an assert in btrfs_compress_folios() on the debug kernel. But it may
potentially lead to data corruption.

Mind to provide the real world ASSERT() call trace?

AFAIK the range passed into btrfs_compress_folios() should always have
its start/length aligned to sector size.

Since s390 only supports 4K page size, that means the range is always
aligned to page size, and the existing code is also doing full page copy
anyway, thus I see no problem with the existing read.

Thanks,
Qu

Fix strm.avail_in calculation for S390 hardware acceleration path.

Signed-off-by: Mikhail Zaslonko <zaslonko@xxxxxxxxxxxxx>
Fixes: fd1e75d0105d ("btrfs: make compression path to be subpage compatible")
---
  fs/btrfs/zlib.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index ddf0d5a448a7..c9e92c6941ec 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -174,10 +174,10 @@ int zlib_compress_folios(struct list_head *ws, struct address_space *mapping,
  					copy_page(workspace->buf + i * PAGE_SIZE,
  						  data_in);
  					start += PAGE_SIZE;
-					workspace->strm.avail_in =
-						(in_buf_folios << PAGE_SHIFT);
  				}
  				workspace->strm.next_in = workspace->buf;
+				workspace->strm.avail_in = min(bytes_left,
+							       in_buf_folios << PAGE_SHIFT);
  			} else {
  				unsigned int pg_off;
  				unsigned int cur_len;






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux