Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kpJnE-0000Ti-I8 for mharc-grub-devel@gnu.org; Tue, 15 Dec 2020 18:31:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpJnB-0000Ms-Rs for grub-devel@gnu.org; Tue, 15 Dec 2020 18:31:41 -0500 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]:46327) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kpJn9-00012w-JH for grub-devel@gnu.org; Tue, 15 Dec 2020 18:31:41 -0500 Received: by mail-qt1-x842.google.com with SMTP id h19so15973617qtq.13 for ; Tue, 15 Dec 2020 15:31:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LX8VMILN3Gc3SEiTD+bg49NTZs1yGGZVssVMkK+pJf0=; b=C/KCT/iCc4KESNfC2MdJ4qVOrM7KnKLIc1JmR4KZENTTM4tCRJvFAI5LnG010iqlPo 1TAQmQod+zwjpsZBMlM2KQb7Y4RbwFc8wSXjQTWxoHwAJXaIYhBB8uZSsdNO4ASwFHAX RRxhSUHCjRRlO/FDQHYn74hAe/ijlIi4niQZeV3uxkgOHePSqj7a9N/mM4cmzgOUurCU qD1MTh0dvskYi+Cu3/UubaIEZE8XkW3FBe5z+8NOoAfGFRkFagN1ouZlCnYyEoorD7eh UDp5B3xO3EwkuItkQaR95ONNJRQjxhsld0cROXE8rjDiAU3SPdCLFy+Bv64EVoDDQLdw 7jYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LX8VMILN3Gc3SEiTD+bg49NTZs1yGGZVssVMkK+pJf0=; b=SammxE0Q+9ud/T7ggNhAvyAjwk3RJIlMyYzdUQL/dxk99LsVGhgYmbowhRJprhBz2u PvhY1TVjjURzURj9LVqlmpWyofteq+CippQCJ7nfamFHlM3Wwl4uMKsAJ+elm5MOA/81 v1P5ys0cU+ZAH80cqVkO34iUmJ4Fp4+hmTJYNK91L6uvrzALvJwcqZCfy3wUWIBDx1zL VPxcUc5bJO6zJzcBxjmfGTI7I9HmSezFAL3cedYs6dNrShAz/wEUKXkvqAFx5xelyQ2Y OH8OFWSddFTj7+nPeJLCPGJb08bYOhl80VcZ+lidzNXTpxjOz3Y6LnZtpDMigE01CU3L D76Q== X-Gm-Message-State: AOAM530vucVh+iw0JwKBaOLRyfY8mzcaHxVMDGOPlycwxbHr20/b7/LI UzRStQhB8E2XuepA6arficB/PSayMsmYWA== X-Google-Smtp-Source: ABdhPJy99ULgaEevN453whhqTyI1QHtKUsF5beBT2fxr3cpHnYkU7QYB26o93+qFhoNhFs4+SL2DPg== X-Received: by 2002:ac8:6897:: with SMTP id m23mr26002281qtq.264.1608075098183; Tue, 15 Dec 2020 15:31:38 -0800 (PST) Received: from localhost.localdomain ([136.49.211.192]) by smtp.gmail.com with ESMTPSA id x49sm45583qtx.6.2020.12.15.15.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 15:31:37 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org Cc: Patrick Steinhardt , Daniel Kiper , Glenn Washburn Subject: [PATCH v9 1/6] luks2: Convert to crypt sectors from grub native sectors Date: Tue, 15 Dec 2020 17:31:06 -0600 Message-Id: <2254f177df156e3390867165315b0d141464c2de.1608074337.git.development@efficientek.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::842; envelope-from=development@efficientek.com; helo=mail-qt1-x842.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-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: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Dec 2020 23:31:42 -0000 The function grub_disk_native_sectors(source) returns the number of sectors of source in grub native (512-byte) sectors, not source sized sectors. So the conversion needs to use GRUB_DISK_SECTOR_BITS. the grub native sector size. Signed-off-by: Glenn Washburn --- grub-core/disk/luks2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c index 8d2457557..8c1156dd0 100644 --- a/grub-core/disk/luks2.c +++ b/grub-core/disk/luks2.c @@ -631,7 +631,7 @@ luks2_recover_key (grub_disk_t source, crypt->log_sector_size = sizeof (unsigned int) * 8 - __builtin_clz ((unsigned int) segment.sector_size) - 1; if (grub_strcmp (segment.size, "dynamic") == 0) - crypt->total_sectors = (grub_disk_native_sectors (source) >> (crypt->log_sector_size - source->log_sector_size)) + crypt->total_sectors = (grub_disk_native_sectors (source) >> (crypt->log_sector_size - GRUB_DISK_SECTOR_BITS)) - crypt->offset_sectors; else crypt->total_sectors = grub_strtoull (segment.size, NULL, 10) >> crypt->log_sector_size; -- 2.27.0