From nobody Sat Nov 23 22:04:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=swemel.ru ARC-Seal: i=1; a=rsa-sha256; t=1730880468; cv=none; d=zohomail.com; s=zohoarc; b=nf7cOek9YJHYIJ3eOvgjisNxnB7Yj6ebsrgeJFO2omU8DgpwFzrGoTLr5wJvyXX1oo6VwmWYB9aHUOUWhBYttgMBEaHgiey7K8z4W1dSqRxkC6Y/+qd4T8YIwYy991RotgmQKfy3ecpZvQspnGqBrfN8b+5ihw/KNOt43vFKV3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730880468; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+BpYk0/f9xRXQ5ni3JK4b/TZPN7+UGhRZg9BcBe59dk=; b=EcNWAr4+XrMzrvUwqaqPXi/JMkyx4egSAytLLOzgFagoL7QYf10Rw2JtSvOFqlooOVfuEdEb0pYSVqg2hmIZynjXdjpOcrXqHNbZ5xNaW9ENWWU9V0Kz+N9pV06Ctwy5Dnq7o5yN7gK+bNDZTY/0/GWhqIa+8WqgcCNCSbWAbvc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730880468238795.9385848863732; Wed, 6 Nov 2024 00:07:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8b49-0000DP-EQ; Wed, 06 Nov 2024 03:07:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t8b46-0000DG-Hl for qemu-devel@nongnu.org; Wed, 06 Nov 2024 03:06:58 -0500 Received: from mx.swemel.ru ([95.143.211.150]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t8b44-0003i3-F1 for qemu-devel@nongnu.org; Wed, 06 Nov 2024 03:06:58 -0500 From: Dmitry Frolov DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1730880409; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=+BpYk0/f9xRXQ5ni3JK4b/TZPN7+UGhRZg9BcBe59dk=; b=sOTSnKU6poAUWwKwlAfNIIczagdsJK2hdYiDnUBcM7iKfuUWnwbVX9suxl3qCp30L2wsws 6gJt1xWACtQ1dHM56gx+b/wawKpWfa9sF7t7Wuyw8VqY4qwgbEXzYa8rPah2ssfzoRgcOd +P13UzLbX50wtFehV0dCHbcNPO30nOY= To: stefanha@redhat.com, den@openvz.org Cc: sdl.qemu@linuxtesting.org, qemu-devel@nongnu.org, Dmitry Frolov Subject: [PATCH] block: fix possible int overflow Date: Wed, 6 Nov 2024 11:04:36 +0300 Message-ID: <20241106080521.219255-2-frolov@swemel.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=95.143.211.150; envelope-from=frolov@swemel.ru; helo=mx.swemel.ru X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @swemel.ru) X-ZM-MESSAGEID: 1730880471462116600 Content-Type: text/plain; charset="utf-8" The sum "cluster_index + count" may overflow uint32_t. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Dmitry Frolov --- 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 l= ong *bitmap, BDRVParallelsState *s =3D bs->opaque; uint32_t cluster_index =3D 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 =3D 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); --=20 2.43.0