Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1k1TkO-00072k-1r for mharc-grub-devel@gnu.org; Fri, 31 Jul 2020 08:02:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1TkN-000709-3l for grub-devel@gnu.org; Fri, 31 Jul 2020 08:02:47 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:42431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k1TkL-0005WZ-DR for grub-devel@gnu.org; Fri, 31 Jul 2020 08:02:46 -0400 Received: by mail-pl1-x644.google.com with SMTP id q17so17167799pls.9 for ; Fri, 31 Jul 2020 05:02:44 -0700 (PDT) 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=OhZ4LehAd1gopQ/LqugXsCuKyZjLR3k8pFF7wUzD10g=; b=xGqu6FrIk2v2oXjGiNuj1Lo2TbMPFXttiwADJcCObgeZXPz+0Zj5TqsgbXVOb94uFo b5DZLqzQgCxiSpZs7AJpxuJTJ039P7rroD3yi5Vxcw/GnbIeQEUyQ+faRz88CJt/82Ax 079Dd5T6AE/UtjcXnTprSmlw1M3nV/aZr7BBNqbCnAPy7XUVfPmFKMiBh6kT1ZgHy/7Q qt7ArmFiLnTfJv+KYhQ1dFcd9Vf+am2HAHnFl7PW9MDt57/dOxmPEoAgOADwtmMDMWAH tzpcKJ8b9sQlOlHqiXx02ArzRLdreO85MPRCFV0Im0bnY9YF0mWEEl0I2qIOv9pnHFYg 9N0A== 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=OhZ4LehAd1gopQ/LqugXsCuKyZjLR3k8pFF7wUzD10g=; b=rBnmTta9UomDEIxwyUarHnkazg/IKDYkIMxX2JjfEZhi7V/LRf7dr+RHRTGJT68dGR 3stazYS+Cht6xLNFu468CxaqpvBxxmqk4F21/0HwW4WFy74Rcp6UOHVa7nBVqK2LDMt7 ZrtJPP9lytDM4SX5DT45p54MmvETxPjpgODFeNCbJ99zIbRNUaIQPTYk5Rqz9GgFGdyV /GrKTxUGWcbyDwuKbRiZabqm/kRRSelB8h5B7gSk9lNW6uW4chcUJCWaKVYk0YSJu3rg wrTiBIA7rmygyoqrVVPQRXfa5uEokqDUoArphCdnaVtdOI13pkkQ6yIzAel7BgN+oAsk W94w== X-Gm-Message-State: AOAM533djq5pBCM1Wa3yGlWP1sERXf5bxUdZCgcjjQ27b+YGmtvOfWVY t4lQvcdHuJCVCa8subT8XyOGnUP+NXc= X-Google-Smtp-Source: ABdhPJykQ0v/P2ej68OGMrwm/k+QVtnbXuk8jIQcEjiHWlfibFuohNpyJvcjZAZZQgY6hU2kuzyIyw== X-Received: by 2002:a62:5a45:: with SMTP id o66mr3190186pfb.43.1596196963323; Fri, 31 Jul 2020 05:02:43 -0700 (PDT) Received: from localhost.localdomain ([189.216.105.24]) by smtp.gmail.com with ESMTPSA id o4sm9781590pfd.25.2020.07.31.05.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:02:42 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org Cc: Glenn Washburn , Daniel Kiper , Patrick Steinhardt Subject: [CRYPTO-LUKS v1 10/19] fs: Fix block lists not being able to address to end of disk sometimes. Date: Fri, 31 Jul 2020 07:01:51 -0500 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=development@efficientek.com; helo=mail-pl1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: Fri, 31 Jul 2020 12:02:47 -0000 When checking if a block list goes past the end of the disk, make sure the total size of the disk is in grub native sector sizes, otherwise there will be blocks at the end of the disk unaccessible by block lists. Signed-off-by: Glenn Washburn --- grub-core/kern/fs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c index fb30da9f4..14c17df74 100644 --- a/grub-core/kern/fs.c +++ b/grub-core/kern/fs.c @@ -139,6 +139,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name) unsigned i; grub_disk_t disk = file->device->disk; struct grub_fs_block *blocks; + grub_size_t total_native_sectors; /* First, count the number of blocks. */ do @@ -156,6 +157,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name) return 0; file->size = 0; + total_native_sectors = disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS); p = (char *) name; for (i = 0; i < num; i++) { @@ -181,7 +183,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name) goto fail; } - if (disk->total_sectors < blocks[i].offset + blocks[i].length) + if (total_native_sectors < blocks[i].offset + blocks[i].length) { grub_error (GRUB_ERR_BAD_FILENAME, "beyond the total sectors"); goto fail; -- 2.25.1