* [PATCH] parallels: fix ext_off assertion failure due to overflow
@ 2024-12-12 10:41 gerben
2024-12-12 10:41 ` gerben
0 siblings, 1 reply; 3+ messages in thread
From: gerben @ 2024-12-12 10:41 UTC (permalink / raw)
To: den, stefanha, qemu-devel; +Cc: sdl.qemu
Hi,
If necessary, I can provide an image file to reproduce the error.
Regards,
Denis Rastyogin
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] parallels: fix ext_off assertion failure due to overflow
2024-12-12 10:41 [PATCH] parallels: fix ext_off assertion failure due to overflow gerben
@ 2024-12-12 10:41 ` gerben
2024-12-12 11:43 ` Denis V. Lunev
0 siblings, 1 reply; 3+ messages in thread
From: gerben @ 2024-12-12 10:41 UTC (permalink / raw)
To: den, stefanha, qemu-devel; +Cc: sdl.qemu, Denis Rastyogin, Leonid Reviakin
From: Denis Rastyogin <gerben@altlinux.org>
This error was discovered by fuzzing qemu-img.
When ph.ext_off has a sufficiently large value, the operation
le64_to_cpu(ph.ext_off) << BDRV_SECTOR_BITS in
parallels_read_format_extension() can cause an overflow in int64_t.
This overflow triggers the assert(ext_off > 0)
check in block/parallels-ext.c: parallels_read_format_extension(),
leading to a crash.
This commit adds a check to prevent overflow when shifting ph.ext_off
by BDRV_SECTOR_BITS, ensuring that the value remains within a valid range.
Reported-by: Leonid Reviakin <L.reviakin@fobos-nt.ru>
Signed-off-by: Denis Rastyogin <gerben@altlinux.org>
---
block/parallels.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/block/parallels.c b/block/parallels.c
index 9205a0864f..8f2b58e1c9 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -1298,6 +1298,10 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
error_setg(errp, "Catalog too large");
return -EFBIG;
}
+ if (le64_to_cpu(ph.ext_off) >= (INT64_MAX >> BDRV_SECTOR_BITS)) {
+ error_setg(errp, "Invalid image: Too big offset");
+ return -EFBIG;
+ }
size = bat_entry_off(s->bat_size);
s->header_size = ROUND_UP(size, bdrv_opt_mem_align(bs->file->bs));
--
2.42.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] parallels: fix ext_off assertion failure due to overflow
2024-12-12 10:41 ` gerben
@ 2024-12-12 11:43 ` Denis V. Lunev
0 siblings, 0 replies; 3+ messages in thread
From: Denis V. Lunev @ 2024-12-12 11:43 UTC (permalink / raw)
To: gerben, den, stefanha, qemu-devel; +Cc: sdl.qemu, Leonid Reviakin
On 12/12/24 11:41, gerben@altlinux.org wrote:
> From: Denis Rastyogin <gerben@altlinux.org>
>
> This error was discovered by fuzzing qemu-img.
>
> When ph.ext_off has a sufficiently large value, the operation
> le64_to_cpu(ph.ext_off) << BDRV_SECTOR_BITS in
> parallels_read_format_extension() can cause an overflow in int64_t.
> This overflow triggers the assert(ext_off > 0)
> check in block/parallels-ext.c: parallels_read_format_extension(),
> leading to a crash.
>
> This commit adds a check to prevent overflow when shifting ph.ext_off
> by BDRV_SECTOR_BITS, ensuring that the value remains within a valid range.
>
> Reported-by: Leonid Reviakin <L.reviakin@fobos-nt.ru>
> Signed-off-by: Denis Rastyogin <gerben@altlinux.org>
> ---
> block/parallels.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/block/parallels.c b/block/parallels.c
> index 9205a0864f..8f2b58e1c9 100644
> --- a/block/parallels.c
> +++ b/block/parallels.c
> @@ -1298,6 +1298,10 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
> error_setg(errp, "Catalog too large");
> return -EFBIG;
> }
> + if (le64_to_cpu(ph.ext_off) >= (INT64_MAX >> BDRV_SECTOR_BITS)) {
> + error_setg(errp, "Invalid image: Too big offset");
> + return -EFBIG;
> + }
>
> size = bat_entry_off(s->bat_size);
> s->header_size = ROUND_UP(size, bdrv_opt_mem_align(bs->file->bs));
Reviewed-by: Denis V. Lunev <den@openvz.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-12 14:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-12 10:41 [PATCH] parallels: fix ext_off assertion failure due to overflow gerben
2024-12-12 10:41 ` gerben
2024-12-12 11:43 ` Denis V. Lunev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.