From nobody Sun Feb 8 20:12:55 2026 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1662457199; cv=none; d=zohomail.com; s=zohoarc; b=HCnbigeQwx5EtHLvBxpEAFbo1sPPYBBcxSRyIjkOdfUo1u3zRlpV5pp1qXzrRyIn0oq7yvXq7J/19ulb+kSJZU+WPwijRv9I7xm2CjB2vdbPJj3BMO4779ajVAIIrL3QIdR3BxIdg/zez21andXxZLYiQMPKJpPp95qNYOe7cYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662457199; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W44bhcl3++vy3DCiR/fD6+2nHRgCHTSPRLiU5Z7kSqU=; b=cQlvWgcGsWFlcGZY77TtI8hFI9/MOE7zRdli9HI4vymUBR7LzPNPi5BGO1T30JGRwbgRH9JN4W5KK5CAmJdyILsIYtGUk6jpTtVIbtJX9xCyGWGl4t8hQVU38rA4naMYd8b8sq6RB1JmbA3TxfyLZmlwJaQXd5AmbjGs+EgkW48= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166245719917973.51660408301939; Tue, 6 Sep 2022 02:39:59 -0700 (PDT) Received: from localhost ([::1]:44938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVV3m-0006dX-1Z for importer@patchew.org; Tue, 06 Sep 2022 05:39:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVU9o-0006rz-7q for qemu-devel@nongnu.org; Tue, 06 Sep 2022 04:42:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVU9a-0006Ma-PM for qemu-devel@nongnu.org; Tue, 06 Sep 2022 04:42:07 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-2UykbJ62OSqYJFzEO_cl5g-1; Tue, 06 Sep 2022 04:41:53 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DDAF11C13944 for ; Tue, 6 Sep 2022 08:41:52 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id F243CC15BB3; Tue, 6 Sep 2022 08:41:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662453714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W44bhcl3++vy3DCiR/fD6+2nHRgCHTSPRLiU5Z7kSqU=; b=Y5HzZfXA4WRXVmqnit6DAsxs8jT/79CxgJqm1tPBsF10xZfD52xzjTET/GKqlJ7mENgMcO MjTCX575Lfyr4Kbz6fRyD9Olg54HQGX0YjsEGIUok2Qku8mA11l+ODrTps+bUphkD91adv KeUiovGSypGit5LJhDJUpPxBoO/+sPY= X-MC-Unique: 2UykbJ62OSqYJFzEO_cl5g-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Richard W.M. Jones" Subject: [PATCH 03/11] crypto: enforce that key material doesn't overlap with LUKS header Date: Tue, 6 Sep 2022 09:41:39 +0100 Message-Id: <20220906084147.1423045-4-berrange@redhat.com> In-Reply-To: <20220906084147.1423045-1-berrange@redhat.com> References: <20220906084147.1423045-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1662457200155100001 We already check that key material doesn't overlap between key slots, and that it doesn't overlap with the payload. We didn't check for overlap with the LUKS header. Signed-off-by: Daniel P. Berrang=C3=A9 --- crypto/block-luks.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 81744e2a8e..6ef9a89ffa 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -595,6 +595,14 @@ qcrypto_block_luks_check_header(const QCryptoBlockLUKS= *luks, Error **errp) return -1; } =20 + if (start1 < DIV_ROUND_UP(sizeof(QCryptoBlockLUKSHeader), + QCRYPTO_BLOCK_LUKS_SECTOR_SIZE)) { + error_setg(errp, + "Keyslot %zu is overlapping with the LUKS header", + i); + return -1; + } + if (start1 + len1 > luks->header.payload_offset_sector) { error_setg(errp, "Keyslot %zu is overlapping with the encrypted payl= oad", --=20 2.37.2