erofs-utils: lib: fix global-buffer-overflow due to invalid device
PATCH 1/1 erofs-utils: lib: fix global-buffer-overflow due to invalid device
Fuzzer generates an image with crafted chunks of some invalid device. Also refine the printed message of EOD.
--- lib/io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
lib/io.c +6 -1
@@ -342,6 +342,10 @@ ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id,ssize_t read;if (device_id) { +if (device_id >= sbi->nblobs) { +erofs_err ("invalid device id %u" , device_id); +return -EIO ; + } read =erofs_io_pread (&((struct erofs_vfile ) { .fd = sbi->blobfd[device_id -1 ], }), buf, offset, len);
@@ -352,7 +356,8 @@ ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id,if (read <0 )return read;if (read < len) { -erofs_info ("reach EOF of device, pading with zeroes" ); +erofs_info ("reach EOF of device @ %llu, pading with zeroes" , + offset |0ULL );memset (buf + read,0 , len - read); }return 0 ;
Signature · 1 line
2.43.5
Quoted 27 lines · Gao Xiang
Fuzzer generates an image with crafted chunks of some invalid device. Also refine the printed message of EOD.
Signed-off-by Gao Xiang <[email protected]>--- lib/io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)lib/io.c +4
-0@@ -342,6 +342,10 @@ ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id,ssize_t read;if (device_id) { +if (device_id >= sbi->nblobs) { +erofs_err ("invalid device id %u" , device_id); +return -EIO ; + } read =erofs_io_pread (&((struct erofs_vfile ) { .fd = sbi->blobfd[device_id -1 ], }), buf, offset, len);
lib/io.c ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id, · line 360
Quoted 6 lines
lib/io.c +2
-1@@ -352,7 +356,8 @@ ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id,if (read <0 )return read;if (read < len) { -erofs_info ("reach EOF of device, pading with zeroes" ); +erofs_info ("reach EOF of device @ %llu, pading with zeroes" , + offset |0ULL );
nit: typo carried over from previous log. s/pading/padding
Quoted 6 lines
lib/io.c +0
-1memset (buf + read,0 , len - read); }return 0 ; --2.43.5
Thanks,
Sandeep.
Hi Sandeep,
Quoted 19 lines · Sandeep Dhavale via Linux-erofs
Quoted 18 lines · Gao Xiang
Fuzzer generates an image with crafted chunks of some invalid device. Also refine the printed message of EOD.
Signed-off-by Gao Xiang <[email protected]>--- lib/io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)lib/io.c +0
-0@@ -342,6 +342,10 @@ ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id,ssize_t read;
Quoted 16 lines
Quoted 9 lines
lib/io.c +4
-0if (device_id) { +if (device_id >= sbi->nblobs) { +erofs_err ("invalid device id %u" , device_id); +return -EIO ; + } read =erofs_io_pread (&((struct erofs_vfile ) { .fd = sbi->blobfd[device_id -1 ], }), buf, offset, len);lib/io.c ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id, · line 360
Quoted 6 lines
lib/io.c +2
-1@@ -352,7 +356,8 @@ ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id,if (read <0 )return read;if (read < len) { -erofs_info ("reach EOF of device, pading with zeroes" ); +erofs_info ("reach EOF of device @ %llu, pading with zeroes" , + offset |0ULL );nit: typo carried over from previous log. s/pading/padding
Thanks for catching this!
Quoted 9 lines
Quoted 7 lines
lib/io.c +0
-1memset (buf + read,0 , len - read); }return 0 ; --2.43.5
Reviewed-by Sandeep Dhavale <[email protected]>
I'm about to releasing erofs-utils 1.8 today (it already takes much long time than expected, I don't want to hold it anymore), so the code is freezed for now.
I will tag v1.8 soon, and write an announcement mail hours later.
Thanks,
Gao Xiang
Quoted 3 lines
Thanks,
Sandeep.
Quoted 50 lines · Gao Xiang
Hi Sandeep,
Quoted 19 lines · Sandeep Dhavale via Linux-erofs
Quoted 18 lines · Gao Xiang
Fuzzer generates an image with crafted chunks of some invalid device. Also refine the printed message of EOD.
Signed-off-by Gao Xiang <[email protected]>--- lib/io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)lib/io.c +0
-0@@ -342,6 +342,10 @@ ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id,ssize_t read;Quoted 16 lines
Quoted 9 lines
lib/io.c +4
-0if (device_id) { +if (device_id >= sbi->nblobs) { +erofs_err ("invalid device id %u" , device_id); +return -EIO ; + } read =erofs_io_pread (&((struct erofs_vfile ) { .fd = sbi->blobfd[device_id -1 ], }), buf, offset, len);lib/io.c ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id, · line 360
Quoted 6 lines
lib/io.c +2
-1@@ -352,7 +356,8 @@ ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id,if (read <0 )return read;if (read < len) { -erofs_info ("reach EOF of device, pading with zeroes" ); +erofs_info ("reach EOF of device @ %llu, pading with zeroes" , + offset |0ULL );nit: typo carried over from previous log. s/pading/padding
Thanks for catching this!
Quoted 8 lines
Quoted 7 lines
lib/io.c +0
-1memset (buf + read,0 , len - read); }return 0 ; --2.43.5
Quoted 6 lines
Quoted 1 line
Reviewed-by Sandeep Dhavale <[email protected]>I'm about to releasing erofs-utils 1.8 today (it already takes much long time than expected, I don't want to hold it anymore), so the code is freezed for now.
Hi Gao,
No problem. Just caught my eyes, it's only cosmetic anyways.
Quoted 2 lines
I will tag v1.8 soon, and write an announcement mail hours later.
Thank you!
Regards,
Sandeep.
Quoted 6 lines
Thanks,
Gao XiangQuoted 3 lines
Thanks,
Sandeep.