From patchwork Tue Jul 23 20:38:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813980 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2489401wro; Tue, 23 Jul 2024 13:41:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVl18q4WGVd2itl2oi0BLqUWRsCcJSu61R7GziJnS4rB+Cl4ghE+J0GVXDH08T8j9d0F1IJ9zf4Uyj6/ddKxgz6 X-Google-Smtp-Source: AGHT+IHY8YVBSraeGkT4FlXhTwY9SL6Q9lObkBYTRMq4Eb7zOK1PO+nCsrH5x/ExPAJ2bis5L9rg X-Received: by 2002:a05:6214:f0f:b0:6b5:4aa9:9687 with SMTP id 6a1803df08f44-6b961116423mr146696466d6.50.1721767305239; Tue, 23 Jul 2024 13:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721767305; cv=none; d=google.com; s=arc-20160816; b=IGv4IWzfTfPA7w2hsm4hA0Cjen1nZfgIceRvD5Tmznc3FI7dPA4pziD+TAP39RJlBr Sfz69QfVVnch2xnQyS5AKE3dizIlcJCidzgm+DYAksHcKueaxNpzB8VxChq7HTwzNvhn vGyA+Y/fT7ZUGjlr+NWmam5E2Hlu7LULIhunXfnyiIWaerAgNyGmOzVuRfIk6nfWOIvK O29Guju5cJh8gRNvz0d1cr+frXDRb+85RrUTOpYcyF+wzKaArn1iBkmhSvYPUPXJx8LR kfBmypQUPYvS3UIYVw9rSGM6BBP/zYOP5nlOAWKnrR1Efe7E8Rph+KVzn6OoZLR8fBhX WiUA== 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=bELfHk4oMv9ib41OJIdVRWkzH2ywz3o3d2vSZHxMu3U=; fh=s2ggtbMcJ8IF7v/es+PJyDYG6fs/fHVgIEhHgmNbwWY=; b=C/lBQnq3nyN+cNX4KlUrdvmgHlDkuklqLCf5GTkxHi56aCoUUlNIqBzTwtkDwhsqz2 KZsiOzmYKkO4uYiEZji0SelVhU9pv5r8YTGCyKiz5DnCCV6eLgASsizaOMBEpRkyOA8+ 6suGhr/W8G2142eunYCQfnwOgoQDgeboTWAy1A94m4B+IJE8OflAAOIUuE0yc2cmZTJg 0rzwisAX7o9i/iC24KO6MRb6ygbegtC2Lq2TUuK3vt/RquGgq6pNchKhwLG9WFYg/6Tg QgWBmgtiHrPwpiZtp0ehidJg5EeIqE12IDDU0c9zuYgwLXwkmGlLo7YRvDmIvPMllher pSgA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RK+UIhVt; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b7ac9e8747si112303726d6.397.2024.07.23.13.41.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jul 2024 13:41:45 -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=RK+UIhVt; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWMJJ-0001C9-Ph; Tue, 23 Jul 2024 16:40:38 -0400 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 1sWMJE-0000be-TZ for qemu-devel@nongnu.org; Tue, 23 Jul 2024 16:40:33 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWMJC-0004M5-EA for qemu-devel@nongnu.org; Tue, 23 Jul 2024 16:40:32 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4266eda81c5so52350225e9.0 for ; Tue, 23 Jul 2024 13:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721767228; x=1722372028; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bELfHk4oMv9ib41OJIdVRWkzH2ywz3o3d2vSZHxMu3U=; b=RK+UIhVtK8hxHlkoBAmgJcTms9ifmyMR+w1i3VlRsCkDVAOB7vVQ9BPe8Q4wHxMBVE pmlHZk6MHoob8y21NL3t+bxkIEjXsXg03qn8RvXI5mh9Ih4PejDFJ1gtqYTu18dGsXE8 cBx5HDwyEm7NtCKPAZSWw3S7pcRM/jbn13xdlDfeBKiuPE7JNe1F+r0PyeXaILhZQ56X oRmfCsMyL0ZYVm27R0yTozYFxlwRO8bh33gSym+X/Z+yiiTfLkHdnXNGXZpHwX+OXATm biMpin/xjzsAD+2q3hD5fxx9BBXDvYmTV0e0l+MYPRWKbqGOIihB/xMyx17qAyNdKSWL zXag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721767228; x=1722372028; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bELfHk4oMv9ib41OJIdVRWkzH2ywz3o3d2vSZHxMu3U=; b=Wjr9tpxKa54/eJCVOdbqZ/EEhRxwoD+pokqZ8rYBu1hU9Yw1qCK+nyaVgXGJQ+vkPo 6TbHc1P2qZOAejQTSBVwMXXfXhJd48ldkzSnOmlDQK5mqavzRM7eSMBnvCkJuTBfQpeK jYIcQDQsA10WurXDGnQShu0OydH1+7hZ9fw6sSaI23bT57K8pRRCb33Jgl6Atm4ztTMH 1g6tAffrK7s/8floQrT8qZUXhABeETG72IANZJEgPt4EhPNaBceU6P6bRlFyFXs/RYwm bec9b8xzWJxsYbv1e74Ft6QKnIPsV58wx1D/u8IbFNdAtUCxVW0PIKDH+5bYKIUs4u4J jO/A== X-Gm-Message-State: AOJu0YyiTohyy98aeSGjhPAZ/LK4KyUWfmjhcQfQJA4t8cnFlHzTYmFr wLX4izZyRvD0IpsFk8X7W4EQZ13TMxEHIHF1c1+qkIv9BEB5BELtBCcKrDcecnid8WN3f3xAw0D h0yo= X-Received: by 2002:a05:600c:1d24:b0:426:6416:aa83 with SMTP id 5b1f17b1804b1-427f7ab6468mr4940655e9.6.1721767228163; Tue, 23 Jul 2024 13:40:28 -0700 (PDT) Received: from localhost.localdomain (vbo91-h01-176-184-50-4.dsl.sta.abo.bbox.fr. [176.184.50.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f93e5eeasm362685e9.38.2024.07.23.13.40.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Jul 2024 13:40:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Yao Xingtao , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Daniel_P_=2E_Berrang?= =?utf-8?q?=C3=A9?= Subject: [PULL 16/28] crypto/block-luks: make range overlap check more readable Date: Tue, 23 Jul 2024 22:38:43 +0200 Message-ID: <20240723203855.65033-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240723203855.65033-1-philmd@linaro.org> References: <20240723203855.65033-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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 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-bounces+patch=linaro.org@nongnu.org From: Yao Xingtao use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé Message-ID: <20240722040742.11513-12-yaoxt.fnst@fujitsu.com> Signed-off-by: Philippe Mathieu-Daudé --- crypto/block-luks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 5b777c15d3c..45347adeeb7 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -33,6 +33,7 @@ #include "qemu/uuid.h" #include "qemu/bitmap.h" +#include "qemu/range.h" /* * Reference for the LUKS format implemented here is @@ -572,7 +573,7 @@ qcrypto_block_luks_check_header(const QCryptoBlockLUKS *luks, header_sectors, slot2->stripes); - if (start1 + len1 > start2 && start2 + len2 > start1) { + if (ranges_overlap(start1, len1, start2, len2)) { error_setg(errp, "Keyslots %zu and %zu are overlapping in the header", i, j);