From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1k0tze-00031q-7N for mharc-grub-devel@gnu.org; Wed, 29 Jul 2020 17:52:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k0tza-0002uq-7V for grub-devel@gnu.org; Wed, 29 Jul 2020 17:52:06 -0400 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]:38557) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k0tzS-0006Ku-Gg for grub-devel@gnu.org; Wed, 29 Jul 2020 17:52:05 -0400 Received: by mail-qk1-x744.google.com with SMTP id e13so23793863qkg.5 for ; Wed, 29 Jul 2020 14:51:56 -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=Zn83R68lRc75BR/om6IXcrcktZL1qkbSwGuOynexmVg=; b=bxtFNtCABkJGS0qW4VSK3XYcoqQUOBWLTAyPHghoVsqVzip4nNFgs8wnbYeqH8Mb1N USoiVaDPLPzT5dBENL9aDvhKsvYL3fJCB7edSTnSXk5W+tvJtpzYvwClF66QOs4aoEKj SmooigwbcDUYBW25gLJwsH3c14SUSdLHpnyTUjaWKil00rM4GytaWD5zK1nQLgdBYiv7 ZhmuvzMbDmPDLbWg6aWKUvy6FVrp1sn4qbY0b0b0X2PRdvRD+qdu59BQ9kKfEnDAiHKr 29w2SuWtJoEgIBF8l38VbjAY2a90ah7o4bqAuv1MsrwRiqib8pUS6Dc0Dn3Avsfi17VA pPRQ== 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=Zn83R68lRc75BR/om6IXcrcktZL1qkbSwGuOynexmVg=; b=rCQOfarnT/mJprlET800KMDkqqwvpBj0Ic1sfKC092RME2PEhFsxhK9FgrzzHURzke NjPxpqXQ7LKfpGjYaIDGs9fufGipeoAoKRyZqfOEM1Ek8xGWxV0aZpPf3fW27YygAgjp 8MFI6Ltiyq1FetbWYRm7SzKmPAhnRj9neP8m5W82fO23TsCYwEkoeTQMCCT3uM2iQA0D zRav9GyFosCHNe69MDCMNKKP+ojXRMUQ3aESHQcxBaJe3RYcBFXIu4VmA9Rutm/0S6mf iXtVPUP9YKFh/jDsw/Ty110wPWX4sckx67TVRcI2Vf5as+wLIb71OPhAIDVp42mpRKAh 118Q== X-Gm-Message-State: AOAM532yatgPgWH0ons45GL5zkqGJZLCpHK61A2l67RVeq91lxzHgUu7 /VjefSUoU3yFDOBc7Op+yOdsnmTLLUPRbw== X-Google-Smtp-Source: ABdhPJzS0opagD3S/EhQyTXlB2UqI6PxseK1vGXCGsIQIcEPVrtdOEHa7N5tbqvXC64+bStC+qZbGA== X-Received: by 2002:a37:64d7:: with SMTP id y206mr34121124qkb.133.1596059516064; Wed, 29 Jul 2020 14:51:56 -0700 (PDT) Received: from localhost.localdomain ([189.216.105.24]) by smtp.gmail.com with ESMTPSA id n127sm2804165qke.29.2020.07.29.14.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2020 14:51:55 -0700 (PDT) From: development@efficientek.com To: grub-devel@gnu.org Cc: Glenn Washburn , Daniel Kiper , Patrick Steinhardt Subject: [PATCH 09/17] fs: 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. Date: Wed, 29 Jul 2020 16:50:14 -0500 Message-Id: <8da016945d48f0cf8452ea005f5be79bddde57a0.1596056714.git.development@efficientek.com> 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::744; envelope-from=development@efficientek.com; helo=mail-qk1-x744.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: Wed, 29 Jul 2020 21:52:06 -0000 From: Glenn Washburn 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