From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kh4Kv-0008Od-Cg for mharc-grub-devel@gnu.org; Mon, 23 Nov 2020 00:24:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kh4Kq-0008K7-Do for grub-devel@gnu.org; Mon, 23 Nov 2020 00:24:22 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:34022) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kh4Kn-0006ZM-GX for grub-devel@gnu.org; Mon, 23 Nov 2020 00:24:20 -0500 Received: by mail-wr1-x441.google.com with SMTP id r17so17380863wrw.1 for ; Sun, 22 Nov 2020 21:24:17 -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=baoCpJ1JLOU0fQTWR1+85T520OTwhcqFBWVyqBqxDF8=; b=zQMrmovsczx72qiJKLAusUtH4Puml/PGnLOi9KGUTJ9qI4AQn7WjFFZoVlNps0KJ35 x9gw5CzInAuRhE9KiSYjBH/dIpSkG7H0fH6ll1zmU15I6tcBV82bMlq8BYGITzyqqMik YBi2NnbziTgzqvcNhrohBKUm0j7OZYKTIDK1I7436+ZDbrbXEeIJAnS55dU5JMc4jIXq axgH7VRUG21uEE9atBKJ/589vQ68nhS5pvCxZ1JufWqBfQBKX8gXBvmnPlLIbL10Ar03 0oDlir1E+pFum1VII4UiQN0bQDm7fo3JcFuWVO7QrxirUFXJ4MIL++liZDgJC6pb0nDe iOyA== 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=baoCpJ1JLOU0fQTWR1+85T520OTwhcqFBWVyqBqxDF8=; b=jMOVe3QQuvSaTQ4/aZDkgLVjIEhMmwcd9aWmbAB76Jpqsd7+/nazIsINNBbiAT7neD Oet4zFJ4EeuqejRY/QGl0R8Hgclc8c14LYGNJoNQirsHsKE0UQMkYF4M5pr6u7xY4c8A mny3X2KCr4NDpzjQYvjCwKUiKnObrQZbx8QcgcoMGOInzLLh1Y9egtmO2EhtR+RiNSh1 uJG/NzMuaEMx5zTiWkthDrmy5ESqFDqFQQLKRhqR9x2lH6wEAj0yTM+KBi9/mndSZvE9 9L09uWhX1CSGvgjsreWFfaqp6DBV1wyMT966arKehslSQ29aI0LaX5l7j9L3Kvyzj/Cg +W8g== X-Gm-Message-State: AOAM531DmTESnUH7GZfzw7Q6nX9MgxaQQPOTqt+DqM1vuYoy7LsTeb+B h53gKwDMmeu2eBxVykhjxPJGwGIfl8hy9Q== X-Google-Smtp-Source: ABdhPJxD5Yov0M2mi6uTqbN07fIejhqItlbYcw408NRxOSwPxY+jkkuQ1izAeuX4diuRSUUOC8yyvQ== X-Received: by 2002:adf:ea03:: with SMTP id q3mr27602048wrm.141.1606109056088; Sun, 22 Nov 2020 21:24:16 -0800 (PST) Received: from localhost.localdomain ([136.49.211.192]) by smtp.gmail.com with ESMTPSA id f16sm11631780wmh.7.2020.11.22.21.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2020 21:24:15 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org Cc: Patrick Steinhardt , Daniel Kiper , Glenn Washburn Subject: [PATCH v5 07/11] luks2: Error check segment.sector_size Date: Sun, 22 Nov 2020 23:23:20 -0600 Message-Id: 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=2a00:1450:4864:20::441; envelope-from=development@efficientek.com; helo=mail-wr1-x441.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: Mon, 23 Nov 2020 05:24:22 -0000 Signed-off-by: Glenn Washburn --- grub-core/disk/luks2.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c index 2f2515fb6..0d838f2e0 100644 --- a/grub-core/disk/luks2.c +++ b/grub-core/disk/luks2.c @@ -626,6 +626,17 @@ luks2_recover_key (grub_disk_t source, grub_dprintf ("luks2", "Trying keyslot %"PRIuGRUB_UINT64_T"\n", keyslot.slot_key); + /* Sector size should be one of 512, 1024, 2048, or 4096. */ + if (!(segment.sector_size == 512 || segment.sector_size == 1024 || + segment.sector_size == 2048 || segment.sector_size == 4096)) + { + grub_dprintf ("luks2", "Segment \"%"PRIuGRUB_UINT64_T"\" sector" + " size %"PRIuGRUB_UINT64_T" is not one of" + " 512, 1024, 2048, or 4096\n", + segment.slot_key, segment.sector_size); + continue; + } + /* Set up disk according to keyslot's segment. */ crypt->offset_sectors = grub_divmod64 (segment.offset, segment.sector_size, NULL); crypt->log_sector_size = sizeof (unsigned int) * 8 -- 2.27.0