Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kpJnE-0000UN-Pk for mharc-grub-devel@gnu.org; Tue, 15 Dec 2020 18:31:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpJnC-0000Oe-OM for grub-devel@gnu.org; Tue, 15 Dec 2020 18:31:42 -0500 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]:46272) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kpJnB-000137-2B for grub-devel@gnu.org; Tue, 15 Dec 2020 18:31:42 -0500 Received: by mail-qk1-x744.google.com with SMTP id d14so20282853qkc.13 for ; Tue, 15 Dec 2020 15:31:40 -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=yGT4lsyucXiqE9r6tEf20T54n+0JVKxGibeHGG2xX8U=; b=hw9Thtg5VrkbmPJRypEWFQho8wvVgDGlsviSt5nJFM/3Sj97d1DIXkzdP+aMoqt+UJ FcIaYZaa8JJmr67y71dVwDYZ4Q1YxgjVTWENnyUU2gw8keHS5gvAYhNvd0l3csWZ4+50 Qv4j5woWkzrtHqWbwfpeoV2rtJLZedQTpOV7q7q9qrTkfXEzosXAds1Mw5EU1una6jiz ryFjHSzUHFxGgpiTXb5DM+AJaHZwQiXY6uJIpGa3Rd+aEpmDY2Cv0+zf5g07Eu0yfwGA KpPBZ115vP8/ELzkF2jZmin58U1lzHrZBsUlUZdv1gaxQE5GWtrFx1G1DhfuAqxx6zbN Uv7Q== 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=yGT4lsyucXiqE9r6tEf20T54n+0JVKxGibeHGG2xX8U=; b=l7sDU5M78QxLxVqbHeM/WcB8A8llBWKJuzia1PTRt3hgK+ps6+ySKEBe37FkyTPpbl lY1uaAwm6XXypJOOPlyr2wK5VLH3ifQY1Tz6ZIcmNNwTskSQo2Oj9L1CC5Ey8Hfx3rMy /GZmNNF1mF5VztAI5YdkjOYNdbtDrr9X/4drG3H3l+qpR57RdQnNNKMJXv7igEnjOzIt jL4SQPou/kEwfrc2EZmV78pWmLNlzoJFcMjaYiwZ/AXm9uIGllVBxG+aaQ9QEAo7WNzT LiS2yd08EuFn7yiaH/YZeMp/Tq8Hyp69sPagj7vhzcmhMVN80Pn/hFauwHOI3wEELx0/ y00Q== X-Gm-Message-State: AOAM533bA+pmwazcO5E53CO9ZKvLztpz9/blGLM7FFg6ZusHJc3JIAte L6Vs0IBV9yBewihx0QquI3ygDDe+nhBPUw== X-Google-Smtp-Source: ABdhPJyzQm5ZPbF89B/IcwJLABKvySN+OBkMlNXM8R9rWvdteC9LIMwML58ACNN7xNGf25ZFZXRaTQ== X-Received: by 2002:a37:a7d5:: with SMTP id q204mr40002437qke.254.1608075099872; Tue, 15 Dec 2020 15:31:39 -0800 (PST) Received: from localhost.localdomain ([136.49.211.192]) by smtp.gmail.com with ESMTPSA id x49sm45583qtx.6.2020.12.15.15.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 15:31:38 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org Cc: Patrick Steinhardt , Daniel Kiper , Glenn Washburn Subject: [PATCH v9 2/6] luks2: Do not handle disks of size GRUB_DISK_SIZE_UNKNOWN for now Date: Tue, 15 Dec 2020 17:31:07 -0600 Message-Id: <1b52233d10ed0e52dfecb44da268c079607f84d8.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::744; envelope-from=development@efficientek.com; helo=mail-qk1-x744.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:43 -0000 Check to make sure that source disk has a known size. If not, print debug message and return error. There are 4 cases where GRUB_DISK_SIZE_UNKNOWN is set (biosdisk, obdisk, ofdisk, and uboot), and in all those cases processing continues. So this is probably a bit conservative. However, 3 of the cases seem pathological, and the other, biosdisk, happens when booting from a cd. Since I doubt booting from a LUKS2 volume on a cd is a big use case, we'll error until someone complains. Signed-off-by: Glenn Washburn --- grub-core/disk/luks2.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c index 8c1156dd0..d30c3bfff 100644 --- a/grub-core/disk/luks2.c +++ b/grub-core/disk/luks2.c @@ -600,6 +600,15 @@ luks2_recover_key (grub_disk_t source, goto err; } + if (grub_disk_native_sectors(source) == GRUB_DISK_SIZE_UNKNOWN) + { + /* FIXME: Allow use of source disk, and maybe cause errors in read. */ + grub_dprintf ("luks2", "Source disk %s has an unknown size, " + "conservatively returning error\n", source->name); + ret = grub_error (GRUB_ERR_BUG, "Unknown size of luks2 source device"); + goto err; + } + /* Try all keyslot */ for (json_idx = 0; json_idx < size; json_idx++) { -- 2.27.0