From patchwork Thu Jul 21 11:52:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 592130 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp387287mab; Thu, 21 Jul 2022 04:53:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sEYfcLfpHVIYoWfHv2yW+zmqXU9zxCHKUNUhFUu26dX9T70THmheyOWw+5XkrCGJKxvoPb X-Received: by 2002:a05:6214:cac:b0:474:7d2:3d41 with SMTP id s12-20020a0562140cac00b0047407d23d41mr5177049qvs.98.1658404390362; Thu, 21 Jul 2022 04:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658404390; cv=none; d=google.com; s=arc-20160816; b=MLWSl6KtRpBglvRRHhDYcb1cowtgn1FR3Y7ayYe9E22otQuJAaseG5CmCyGMi7lax7 YPQUnnjI91s2dwzjva9FRVnAQfujUVD3H2llIJeSOYDewL4cfdaE6tCycBGEr0hWslLv E0oE+ncgjDgxGiAKTaBMsPLnvoJjtk4GccncAfL0ykckj3UAGzxGLLN8deU/ZqUkcp3V 5sbVSwXCKbFJPneJc9TEFbEgD0jAcNGhuYnPPd9VYdQ5pLGJwhLMF995HZWoNHfQVMK5 slyIQn2EDoQ8K8AX8L/T+YlLMGJxoXY45ozv6iXeju14plSpU+gEgL/M1rsi/prUlXM9 WzDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PxJwjVAzbS0o6r9Gh4EM7dFWlXeZcq5sXf7+Lmnjej4=; b=JgzsvLj0UBp9KetrXPjYjNFhuTRbmo+Yav0vBUWGaT11Vz5WQcK14ih+V/hZc+Jlp9 PJaSYjrpX+jfjytxoBgWsp52Q9hc8ME2AqA7kvJnbr0FctJWiwgBDaWK6Rfucg99TwcZ f9sNVTWdhMmS4hmnTaXnFY3KA3yvBIS1MlkJLNIadwM7dGYjfZ3Ij4H5Zht1Fcr35S7+ KEoW3S7WLUJE7H+hru73h9wjRojdX6au4eMUcjOVYneGa1/7hII9mIoFVF4jOPBEuF5B +UJMgCQp35fEzFcNa77hECu2xUBbsQYdZXnw23FriQ3siHmLgbz4YkiZ7r7Ci3XKGjP6 ohQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JAlrrGIh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k14-20020ac8140e000000b00318e15694fcsi955207qtj.619.2022.07.21.04.53.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Jul 2022 04:53:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JAlrrGIh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEUjt-0005wV-T3 for patch@linaro.org; Thu, 21 Jul 2022 07:53:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEUj3-0005uk-79 for qemu-devel@nongnu.org; Thu, 21 Jul 2022 07:52:17 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:47085) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEUj0-0006YS-BV for qemu-devel@nongnu.org; Thu, 21 Jul 2022 07:52:16 -0400 Received: by mail-wr1-x434.google.com with SMTP id z13so1869787wro.13 for ; Thu, 21 Jul 2022 04:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PxJwjVAzbS0o6r9Gh4EM7dFWlXeZcq5sXf7+Lmnjej4=; b=JAlrrGIhijtxWfz2ZGXU1tU9NQqC6Mus2tb/9erwjDra90zriFK4jWhHTRa8f0RR18 6xFcD/uNm1xjwRDVKym0toUF21QunzYNcR8/EBQ/iYLDNVFvaT6Fs5I0bIfjzmFT1EHB HFe8x5I9CS4PlvF+mT+U3E8AMN5dcoD45m+/ld1MEbJN9ZQTjXbMo3J4hEqd7O5jCxjM Mo+mRHohEqPJs4WfTEOa1txasr7u02DsIj0k7KmAMJa+odhgT29962XTLeZ54IcgZmVo UHVbqZ3ZM5H9axyMtfJ6NiXQZtaz1KfWAhaArTHY0p5aKVohHqPYtYx5CKfJ8aBIcky2 Xwfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PxJwjVAzbS0o6r9Gh4EM7dFWlXeZcq5sXf7+Lmnjej4=; b=S6TuTMJsbaOo92khFXn29vqCEJRgxKnanHQdYs8APOnGuU+5xxRY/slOWxD3QDzYsg PYiCYGfqtta3RB2LMFHOXxOtjNHMJtxIfANiwe43b4aln9IqxXZW7rqrz4otgUX0B9P0 TVyQST47vmoXKYIGnOGzh25hPp0uMlCSWToKApgUso/Snm2Gy5yiENn5PbHI+vpm67U7 iO9dwOK4lPfp7ogYEKFb2J8joQTXacfxh+i72M726EQQmoFQY2mcqo5pf9bG+lG9+te2 j+ID2VRGq0dAq76vmae87K3YdemY1ofzLW4RniKwYpMCgi5g8leTo63CgS5X+YyZSfHW Sy3w== X-Gm-Message-State: AJIora9cLqk7yeFh7A88TsGgSxgABkhOp9DLGvlE448fOq/HdkNDPzwx XRqjHB4XG966y4XlgUuJuHTjnMtoZg/5Aw== X-Received: by 2002:a5d:64c2:0:b0:21e:2e1b:d031 with SMTP id f2-20020a5d64c2000000b0021e2e1bd031mr10664854wri.8.1658404332957; Thu, 21 Jul 2022 04:52:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id l18-20020a05600c1d1200b003a04d19dab3sm11772745wms.3.2022.07.21.04.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 04:52:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Dr. David Alan Gilbert" , Juan Quintela , Fam Zheng , Stefan Hajnoczi Subject: [PATCH 2/2] migration: Define BLK_MIG_BLOCK_SIZE as unsigned long long Date: Thu, 21 Jul 2022 12:52:07 +0100 Message-Id: <20220721115207.729615-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220721115207.729615-1-peter.maydell@linaro.org> References: <20220721115207.729615-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.google.com 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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When we use BLK_MIG_BLOCK_SIZE in expressions like block_mig_state.submitted * BLK_MIG_BLOCK_SIZE, this multiplication is done as 32 bits, because both operands are 32 bits. Coverity complains about possible overflows because we then accumulate that into a 64 bit variable. Define BLK_MIG_BLOCK_SIZE as unsigned long long using the ULL suffix. The only two current uses of it with this problem are both in block_save_pending(), so we could just cast to uint64_t there, but using the ULL suffix is simpler and ensures that we don't accidentally introduce new variants of the same issue in future. Resolves: Coverity CID 1487136, 1487175 Signed-off-by: Peter Maydell Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- I haven't tried to analyse the code to see if the multiplications could ever actually end up overflowing, but I would assume probably not. migration/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/block.c b/migration/block.c index 9e5aae58982..3577c815a94 100644 --- a/migration/block.c +++ b/migration/block.c @@ -28,7 +28,7 @@ #include "sysemu/block-backend.h" #include "trace.h" -#define BLK_MIG_BLOCK_SIZE (1 << 20) +#define BLK_MIG_BLOCK_SIZE (1ULL << 20) #define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> BDRV_SECTOR_BITS) #define BLK_MIG_FLAG_DEVICE_BLOCK 0x01