qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: fix possible int overflow
@ 2024-11-06  8:04 Dmitry Frolov
  2024-11-06  9:53 ` Kevin Wolf
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Frolov @ 2024-11-06  8:04 UTC (permalink / raw)
  To: stefanha, den; +Cc: sdl.qemu, qemu-devel, Dmitry Frolov

The sum "cluster_index + count" may overflow uint32_t.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
---
 block/parallels.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/parallels.c b/block/parallels.c
index 9205a0864f..071b6dcaf8 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -184,11 +184,11 @@ static int mark_used(BlockDriverState *bs, unsigned long *bitmap,
     BDRVParallelsState *s = bs->opaque;
     uint32_t cluster_index = host_cluster_index(s, off);
     unsigned long next_used;
-    if (cluster_index + count > bitmap_size) {
+    if ((uint64_t)cluster_index + count > bitmap_size) {
         return -E2BIG;
     }
     next_used = find_next_bit(bitmap, bitmap_size, cluster_index);
-    if (next_used < cluster_index + count) {
+    if (next_used < (uint64_t)cluster_index + count) {
         return -EBUSY;
     }
     bitmap_set(bitmap, cluster_index, count);
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-11-08 11:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-06  8:04 [PATCH] block: fix possible int overflow Dmitry Frolov
2024-11-06  9:53 ` Kevin Wolf
2024-11-06 15:45   ` Denis V. Lunev
2024-11-06 16:00     ` Kevin Wolf
2024-11-08 11:32       ` Denis V. Lunev
2024-11-08 11:36   ` Denis V. Lunev

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).