From nobody Fri Jul 24 05:22:28 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62F5E2F9C37; Thu, 23 Jul 2026 14:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784815392; cv=none; b=IziipunX/LynL/U1LGrDGJPueu24fKVx4prSoVYeIycDi8P71hsEU21weVV1teGHyUPQ7GFBj61z44cemdIi3NP9VRZT9txCvYCk95275jFECMAI7PI15mcaWnD8X/p3/s4PJS8AR1gqEERN+eJBx6R5rgnmuKCNefWgycZjSt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784815392; c=relaxed/simple; bh=FB/13ltZdXOxfveDQVADDT6Dt0VdO0sIqOSo+8r5Hrc=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=pXBWfe0WR086+Uu9TMTSrtqNGVsoVCgtQWw/v8zW9B2p6LfKhjnKRGfXVmuFlwIt8s2+Cs06K5gy59YRINdMztUJzSITHS5ROJhi3SmRm+rUmoHfCat4o+uxNFYel+vEfY0BqOmAnF0UO1k8Jmcyiwk0bPEj6sVXa8K5q2DV+qo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Vbg5jrIL; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=AR8yfC34; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Vbg5jrIL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="AR8yfC34" Date: Thu, 23 Jul 2026 14:03:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1784815389; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0QmnItvHj8Kh5O6xvshUVM8z52XxR+zooGoAzA/BJjw=; b=Vbg5jrILqpPiEfv8Pery+tm5R2JN3ctbEcvdpKV8/wNF6RwWdIxIJPaqQtDNInS9oT68Nv sukam2jFFhGBIljLbEAl7VcyKjAPo9sZmxMkbTlgi2jLHH6L5dLmQy9UluDhIdGnxGmaAP IlGcYpMQQcOxkedMAuO76/jSeg6m9YEBu1noD5Y2StyXEqRKFooXZLbBERDkQWDeLGy8Ss tG7rDqd8U9IL/HQOOe6ynwwVhCN53XPzm2ZXKNdgpINs/cnVP8gpSgTOUoGtnGBRdvOOiu wgpKt3CmJQgx93omGqkWnT1JS0dbIqBI3nKaQV5tg+kpzSVmChqST6LgR99D4A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1784815389; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0QmnItvHj8Kh5O6xvshUVM8z52XxR+zooGoAzA/BJjw=; b=AR8yfC34vrXqyQ/zndX692YkOUJKA8o3zWGdChgQK+0G0p79GF/lDmiqWwAaYQoskcIvmS gLRfb0qcfpHAUDDA== From: "tip-bot2 for Thorsten Blum" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/boot] x86/purgatory: Return bool from verify_sha256_digest() Cc: Thorsten Blum , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260723133634.161598-3-thorsten.blum@linux.dev> References: <20260723133634.161598-3-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178481538732.2943223.1677248479855072850.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/boot branch of tip: Commit-ID: 10a357ce443dad3ec985506485c6b37d34c382f2 Gitweb: https://git.kernel.org/tip/10a357ce443dad3ec985506485c6b37d3= 4c382f2 Author: Thorsten Blum AuthorDate: Thu, 23 Jul 2026 15:36:34 +02:00 Committer: Ingo Molnar CommitterDate: Thu, 23 Jul 2026 15:45:02 +02:00 x86/purgatory: Return bool from verify_sha256_digest() Change the function's return type from 'int' to 'bool' and return the result of memcmp() directly to simplify the code. While at it, cast ->start to const u8 * to better match the expected type. Also inline the verify_sha256_digest() check and remove the redundant local 'ret' variable in purgatory(). No change in functionality expected. Signed-off-by: Thorsten Blum Signed-off-by: Ingo Molnar Cc: "H. Peter Anvin" Link: https://patch.msgid.link/20260723133634.161598-3-thorsten.blum@linux.= dev --- arch/x86/purgatory/purgatory.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/arch/x86/purgatory/purgatory.c b/arch/x86/purgatory/purgatory.c index 655139d..45836ac 100644 --- a/arch/x86/purgatory/purgatory.c +++ b/arch/x86/purgatory/purgatory.c @@ -21,7 +21,7 @@ u8 purgatory_sha256_digest[SHA256_DIGEST_SIZE] __section(= ".kexec-purgatory"); =20 struct kexec_sha_region purgatory_sha_regions[KEXEC_SEGMENT_MAX] __section= (".kexec-purgatory"); =20 -static int verify_sha256_digest(void) +static bool verify_sha256_digest(void) { struct kexec_sha_region *ptr, *end; u8 digest[SHA256_DIGEST_SIZE]; @@ -31,22 +31,16 @@ static int verify_sha256_digest(void) end =3D purgatory_sha_regions + ARRAY_SIZE(purgatory_sha_regions); =20 for (ptr =3D purgatory_sha_regions; ptr < end; ptr++) - sha256_update(&sctx, (uint8_t *)(ptr->start), ptr->len); + sha256_update(&sctx, (const u8 *)(ptr->start), ptr->len); =20 sha256_final(&sctx, digest); =20 - if (memcmp(digest, purgatory_sha256_digest, sizeof(digest))) - return 1; - - return 0; + return !memcmp(digest, purgatory_sha256_digest, sizeof(digest)); } =20 void purgatory(void) { - int ret; - - ret =3D verify_sha256_digest(); - if (ret) { + if (!verify_sha256_digest()) { /* loop forever */ for (;;) ;