Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lNPH6-0003yN-DI for mharc-grub-devel@gnu.org; Fri, 19 Mar 2021 20:15:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNPH4-0003xK-Av for grub-devel@gnu.org; Fri, 19 Mar 2021 20:15:26 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:45049) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lNPGw-0002hp-Fy for grub-devel@gnu.org; Fri, 19 Mar 2021 20:15:24 -0400 Received: by mail-pf1-x434.google.com with SMTP id b184so6989870pfa.11 for ; Fri, 19 Mar 2021 17:15:17 -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=2KEKQeZ8DwrbtaHPLcs4T8xTxheoqxTFMwC0leKM2L8=; b=SXvftoy+IL0W9dLYt2GbFMaDxWIpudOQ13V+0IfPELsD57TVoGS9UmfFml/iRTpipK pz49/2OYysMowhYboi/LRnVicaetzpHGJAdXl1tpdvTFZdtsq4xUM9uVtDHUQwBMbD0t nlNULWBkttbe8DthS8YbdCVywzti0Hyvl98jDaQ41lblpCKl17xBQMRO+AE3c8ZjuqcH pCDD6Vs7KYmU1Igr0agqkrDfleA2DgS2+1U0FDa71jdii/2erMQyls/uIdnlBuFah9lO q8aQ3fbGMTvN8bl5eWXa7OxHA25K0IFEPFqxGdZqWF2QwDzrNqOLnVD4dK0hQl/snlYM iCYw== 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=2KEKQeZ8DwrbtaHPLcs4T8xTxheoqxTFMwC0leKM2L8=; b=W9xB0FjbXM6KLA3pVuzLS70qfeHVYEa5EhJfu+eL1xdz0Ml+EaPAtY8Q3+O02s6w9S st2eyIjVRlyN1VkfKeBcVaVVNO+B6+oRaro9uJwhMoXfUtLZ/E88oZTy1PS4tH+GK8Tq w4okEAaGVvR0of/Mm9fm2CaE4VWB25ocqdqaWiIgW23cuI0WZLrxVz1z10kmVbmZL4/s YkSChQApVx8iqmHAwrKK3Q11liXBmbCe9mw+TYxnBhMR3GsHtxdleW17PN8i/J1lKZfd h4m6j34bPDK8tabFJ/PT1pyx393pY5XAg0T+NG6Z2IVJQD16B9zlVKtlt5SNZfHxtkCu vzzw== X-Gm-Message-State: AOAM530aRwCi9gwiojRjNJLf6Ard/PCCtt0G59KGWSAQh57ukmN5RYZL D83a+7q6ATJxcGlvets5SXKZ0RTVI2QdVQ== X-Google-Smtp-Source: ABdhPJyGbYzzuc9eg3cqeA1ICnRG3q2blz1nRElHkTG8qQ/5EtQoqqBxRVxtzhSegXbug5tUdOvCgg== X-Received: by 2002:a05:6a00:2292:b029:214:7a33:7f08 with SMTP id f18-20020a056a002292b02902147a337f08mr2056674pfe.15.1616199316721; Fri, 19 Mar 2021 17:15:16 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ab16:db00:2328:d973:f35b:5c6b]) by smtp.gmail.com with ESMTPSA id 2sm6400218pfi.116.2021.03.19.17.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 17:15:16 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH 1/4] luks2: Continue trying all keyslots even if there are some failures Date: Fri, 19 Mar 2021 19:14:48 -0500 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=2607:f8b0:4864:20::434; envelope-from=development@efficientek.com; helo=mail-pf1-x434.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: Sat, 20 Mar 2021 00:15:27 -0000 luks2_get_keyslot can fail for a variety of reasons that do not neccesarily mean the next keyslot should not be tried (eg. a new kdf type). So always try the next slot. This will make GRUB more resilient to non-spec json data that 3rd party systems may add. We do not care if some of the keyslots are unusable, only if there is at least one that is. Signed-off-by: Glenn Washburn --- grub-core/disk/luks2.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c index 125e8609a..199e11473 100644 --- a/grub-core/disk/luks2.c +++ b/grub-core/disk/luks2.c @@ -617,7 +617,15 @@ luks2_recover_key (grub_disk_t source, grub_errno = GRUB_ERR_NONE; ret = luks2_get_keyslot (&keyslot, &digest, &segment, json, json_idx); if (ret) - goto err; + { + /* + * luks2_get_keyslot can fail for a variety of reasons that do not + * neccesarily mean the next keyslot should not be tried (eg. a new + * kdf type). So always try the next slot. + */ + grub_dprintf ("luks2", "Failed to get keyslot %" PRIuGRUB_UINT64_T "\n", keyslot.idx); + continue; + } if (grub_errno != GRUB_ERR_NONE) grub_dprintf ("luks2", "Ignoring unhandled error %d from luks2_get_keyslot\n", grub_errno); -- 2.27.0