From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1klEbJ-0007AF-K7 for mharc-grub-devel@gnu.org; Fri, 04 Dec 2020 12:10:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1klEbE-00076H-Bc for grub-devel@gnu.org; Fri, 04 Dec 2020 12:10:29 -0500 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]:37912) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1klEaQ-00067N-EA for grub-devel@gnu.org; Fri, 04 Dec 2020 12:10:11 -0500 Received: by mail-qt1-x844.google.com with SMTP id o1so4410836qtp.5 for ; Fri, 04 Dec 2020 09:07: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=dtZlW8Zz+rI5vnpsbBRbDGLQ8Jfhj4KEqthLN/+KfPI=; b=JqxRbRFO/xXYhsQMly5KhXmxEiPzXP6PW5LBHchLbEa58AZCh1cctqWpw2EGqpoZlQ vHuHM7Jci2/g8nI3EmBJphCV4SYs4VaY8FWdyj7anySNd0cUXRZa6UHEm2f0CNbQzZBr uWLpiSWlijpZUZNO46uMu2zn0iWb4WDb7nbRGqzvHkuuzwNg3KBG/06e7M80maqhrlNp SuHx5JKFlWR2pG9U9nX5dscL0gu7DqZQWN9G6Kd9e6urr1syefhgvq0LPY9tJOkFKuqO pt3Wi8Gu3qff7wOYY0WrcfpPmOFJeg4UgN4Wf62O6/+QgnKBf1bTHcj78UKtWB3g9B8u bD3w== 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=dtZlW8Zz+rI5vnpsbBRbDGLQ8Jfhj4KEqthLN/+KfPI=; b=gISXrrAlydovcDQfe8zxG8MvJSplnjM7qZFtkeV2sRTVYerys4CXYLYtS/ItYba8+N VZIRoVxPDMepLppiwnLQR3rUINJnrSlMhKma8C5OECMSLgSrseJ6GejUNXFbaMSsB/NB 8LvUq1pS5bIwU0lbZtseohQdsNYrnRwB4voC8bTOCTGxmZfWA4bclkEkwm/zG4ppE+V4 Zv9xCV1yHVv9b+WN6iJGtQSCZOQHvU15hvuA3vaG/SjloGgBhZlwouUW45fyP4y/rOlm q4h+wCBxqRaXTKSwq99aOP0PKFqH4VvUYyN4TOdzTRYANbxo6sJxzCzRRigNxM8/J4Tf eqxA== X-Gm-Message-State: AOAM530gfUEtb9inCS47T/q3w/o32seUQafflBzalM6x29s3/kZHjxV2 m6ipkYc7lhnXDZs+czHBMd7MNZ3cnt/8HQ== X-Google-Smtp-Source: ABdhPJxmKr74f13plDICCCxe72wpBm/8gdxgJxYd+KTe7gbqu+GzNgiHzyro5fFCOus/2D6v3IzMiw== X-Received: by 2002:a02:5148:: with SMTP id s69mr7838145jaa.8.1607100256035; Fri, 04 Dec 2020 08:44:16 -0800 (PST) Received: from localhost.localdomain ([136.49.211.192]) by smtp.gmail.com with ESMTPSA id w3sm1754909iol.9.2020.12.04.08.44.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 08:44:15 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org Cc: Patrick Steinhardt , Daniel Kiper , Glenn Washburn Subject: [PATCH v7 04/17] luks2: Make sure all fields of output argument in luks2_parse_digest() are written to Date: Fri, 4 Dec 2020 10:43:33 -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=2607:f8b0:4864:20::844; envelope-from=development@efficientek.com; helo=mail-qt1-x844.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=unavailable 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:10:30 -0000 We should assume that the output argument "out" is uninitialized and could have random data. So, make sure to initialize the segments and keyslots bit fields because potentially not all bits of those fields are written to. Otherwise, the digest could say it belongs to keyslots and segments that it does not. Signed-off-by: Glenn Washburn --- grub-core/disk/luks2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c index bdb90e4b6..eadd529e9 100644 --- a/grub-core/disk/luks2.c +++ b/grub-core/disk/luks2.c @@ -230,6 +230,7 @@ luks2_parse_digest (grub_luks2_digest_t *out, const grub_json_t *digest) return grub_error (GRUB_ERR_BAD_ARGUMENT, "Digest references no segments"); + out->segments = 0; for (i = 0; i < size; i++) { if (grub_json_getchild (&o, &segments, i) || @@ -242,6 +243,7 @@ luks2_parse_digest (grub_luks2_digest_t *out, const grub_json_t *digest) return grub_error (GRUB_ERR_BAD_ARGUMENT, "Digest references no keyslots"); + out->keyslots = 0; for (i = 0; i < size; i++) { if (grub_json_getchild (&o, &keyslots, i) || -- 2.27.0