* [PATCH 1/2] erofs-utils: refuse block sizes larger than EROFS_MAX_BLOCK_SIZE
@ 2023-06-03 13:31 Gao Xiang
2023-06-03 13:31 ` [PATCH 2/2] erofs-utils: fix EOD behavior when len is too large Gao Xiang
0 siblings, 1 reply; 2+ messages in thread
From: Gao Xiang @ 2023-06-03 13:31 UTC (permalink / raw)
To: linux-erofs; +Cc: Gao Xiang
The maximum supported block size is EROFS_MAX_BLOCK_SIZE.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
lib/super.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/super.c b/lib/super.c
index 17f849e..5f70686 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -88,15 +88,14 @@ int erofs_read_superblock(void)
sbi.feature_compat = le32_to_cpu(dsb->feature_compat);
sbi.blkszbits = dsb->blkszbits;
- /* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */
- if (sbi.blkszbits < 9) {
+ if (sbi.blkszbits < 9 ||
+ (1 << sbi.blkszbits) > EROFS_MAX_BLOCK_SIZE) {
erofs_err("blksize %d isn't supported on this platform",
erofs_blksiz());
return ret;
- }
-
- if (!check_layout_compatibility(&sbi, dsb))
+ } else if (!check_layout_compatibility(&sbi, dsb)) {
return ret;
+ }
sbi.primarydevice_blocks = le32_to_cpu(dsb->blocks);
sbi.meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr);
--
2.24.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] erofs-utils: fix EOD behavior when len is too large
2023-06-03 13:31 [PATCH 1/2] erofs-utils: refuse block sizes larger than EROFS_MAX_BLOCK_SIZE Gao Xiang
@ 2023-06-03 13:31 ` Gao Xiang
0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2023-06-03 13:31 UTC (permalink / raw)
To: linux-erofs; +Cc: Gao Xiang
Otherwise, read_count could be overflow and causes unexpected
behaviors.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
lib/io.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/io.c b/lib/io.c
index 9e30b7e..9d718ab 100644
--- a/lib/io.c
+++ b/lib/io.c
@@ -289,7 +289,7 @@ int dev_read(int device_id, void *buf, u64 offset, size_t len)
erofs_info("Reach EOF of device - %s:[%" PRIu64 ", %zd].",
erofs_devname, offset, len);
memset(buf, 0, len);
- read_count = len;
+ return 0;
} else if (errno != EINTR) {
erofs_err("Failed to read data from device - %s:[%" PRIu64 ", %zd].",
erofs_devname, offset, len);
--
2.24.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-03 13:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-03 13:31 [PATCH 1/2] erofs-utils: refuse block sizes larger than EROFS_MAX_BLOCK_SIZE Gao Xiang
2023-06-03 13:31 ` [PATCH 2/2] erofs-utils: fix EOD behavior when len is too large Gao Xiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).