From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1klEis-0008S1-8V for mharc-grub-devel@gnu.org; Fri, 04 Dec 2020 12:18:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1klEdw-0007ea-IG for grub-devel@gnu.org; Fri, 04 Dec 2020 12:13:18 -0500 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]:32958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1klEcE-0007Cr-2e for grub-devel@gnu.org; Fri, 04 Dec 2020 12:12:59 -0500 Received: by mail-io1-xd32.google.com with SMTP id o8so6501270ioh.0 for ; Fri, 04 Dec 2020 09:10:51 -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=oxqhAaaElLvlWkM/jFjHonl2bE9X1YA8mBk5bE3hqiA=; b=rMC+mt9zU26WoOVmf27aoc5qA+sZTFO80koQD0J6UA2V2Sf0PD1ToeGhmyU6tpyucr ouf3EMBkCjtPhLkVY5spqM88O5tl8YxOWf3GTK3rYsqj+zBkMhqRgfpdTXMo+K2mbQFC Q3xi8DFqRd7JSiwz8JzVZ66l5LYG3gx0DjSlvxoiR4Or8lRHNu3+SBNNB8q7EJSHY9C4 mqE6LhgKgsmQhTk9SevKQgSkA9TnlvNkujlxaq38InLjzgb5coRP2wFZW1T+QXRKn4O8 8ZV51hPGtgINYwtGcCWThyem5gTO1RGO4seWlNmqNAQOr/D8XVrAnGm3RSCJhrLJPVmz xX4g== 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=oxqhAaaElLvlWkM/jFjHonl2bE9X1YA8mBk5bE3hqiA=; b=XwfcAhBlHeyTQECOqBiePKeqW2l45iDh0ecjUpDFgV1bTS6HnXEsSzkKNwXVOG92E9 Z/cTZhQCODNZfpOBHFfCYuiISkcPbnW0MkSHTPcXHXjNSJzlfFwqGy7AHRD5ZIdhrgko cDq7GQBOTmtW/rHVqFy/GOjakuVlQvMIFp5VrS+4Z01ae18HcfdEM23naa1iTg5aeNdN QQ0e554sxn3ryJBCITWHJJgu8nZTawkQ1IBrcRhTXJWikDF5XsitdNRSmLC9ubuXyn5J syJgHzx5zRR0DclCj2kUTT72dDSZB0Izntuq4RDlvOEF3NLq5X2YiNUK9UOR/1m84T2q dHmg== X-Gm-Message-State: AOAM533zS4ChNL/uKx8VQjFmgMFakrwIW7qDGZMUr7b06RM7RwSYEXgZ CAYjmkzGKkCachW+2iCNlqexnt5UAOSBaw== X-Google-Smtp-Source: ABdhPJz13ZONpEJhCwJ1Ame0T8ElDd1JG6uH7dy8k8fRr9xCZZTQwYlb+wtCEDN5UrMlsTS9LIcaPA== X-Received: by 2002:a02:6c50:: with SMTP id w77mr7611809jab.68.1607100268216; Fri, 04 Dec 2020 08:44:28 -0800 (PST) Received: from localhost.localdomain ([136.49.211.192]) by smtp.gmail.com with ESMTPSA id w3sm1754909iol.9.2020.12.04.08.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 08:44:27 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org Cc: Patrick Steinhardt , Daniel Kiper , Glenn Washburn , Daniel Kiper Subject: [PATCH v7 13/17] luks2: Error check segment.sector_size Date: Fri, 4 Dec 2020 10:43:42 -0600 Message-Id: <2fcef44b6465090f6b779ba040c6ee8a5ff101b0.1607098915.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::d32; envelope-from=development@efficientek.com; helo=mail-io1-xd32.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: Fri, 04 Dec 2020 17:13:18 -0000 X-List-Received-Date: Fri, 04 Dec 2020 17:13:18 -0000 Reviewed-by: Daniel Kiper 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 1bb3a333d..499c9330b 100644 --- a/grub-core/disk/luks2.c +++ b/grub-core/disk/luks2.c @@ -629,6 +629,17 @@ luks2_recover_key (grub_disk_t source, grub_dprintf ("luks2", "Trying keyslot \"%"PRIuGRUB_UINT64_T"\"\n", keyslot.json_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.json_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