Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp722171pxf; Thu, 1 Apr 2021 11:47:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhtiAvIpJK5zUXEHAc0G8qbuj8LQ4CtmJu13ItsHzjiFJaL2x4Aq+Mzn1+cO/FRC9YO7Si X-Received: by 2002:a17:906:5611:: with SMTP id f17mr10804451ejq.208.1617302866659; Thu, 01 Apr 2021 11:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617302866; cv=none; d=google.com; s=arc-20160816; b=HVkw9VL/4KNtOJyj0L+1ew5JUKWx3mRntInvbaD16W4RUiLM2JG5DxNaokHEVk4fK/ xxJY11mra2cCnD4/tOVTamlUZp97dqdJZh/IEKC6b+5+hg9r81qkWsgYc4u1YXfpEBUE xgm1dXZf6zLvU0Bpb+Gz/CiMApU+mQEQYYJvkIS1wFWj+ANveqaTxYw1CjqgUebGwol2 fBBNqP0+1x995dITkWkRqsthtY1iw5J8NK3Vl4YsEXT3ne5zEVb0cQmoE3Vd4/BVYhxR CLMUlvRyYFrfKWkYMiVfN3W0HssyCOuoeIge2poHNQmi7JMBGOrGTSOQaDpyTowD/ZD4 KRcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CW/Lco/gGaOyF4s14EhnKMMleP2guUau+OE0H2tOWYY=; b=wMsAawE3ovuBtEMSAZTlR1G7jVXw3bxRcBilNLQr2USznEKWcuD1AWxeC021WcOaMW YJRRh+itWKSsrCYJiiP97o8sqyh2dyIbo6QgaU5WYi0+j81IKHwDNCWann2dS/T9mrIH QncmxxojDs3ltUU9nk6iNWltUXnnhihVQCorMgxRrCna7YD59B+ruB0/zQhgR239PWcg di27R5XbSpg6KxveXMJClsRpiwVhNEvzjGhVHoYFd4Q8WdrrJ9fxh74oR0WT5JTKu2d2 RyR5a3yZDHDVfA/Vyo7Q6bN48A4EqCCmSbn80rAgza8ygM6F1gPrBvsepQFIG1dVy9cH Ez4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FhAOqSK+; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mj11si4876083ejb.589.2021.04.01.11.47.20; Thu, 01 Apr 2021 11:47:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FhAOqSK+; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237785AbhDASrG (ORCPT + 99 others); Thu, 1 Apr 2021 14:47:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:38238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238975AbhDASpE (ORCPT ); Thu, 1 Apr 2021 14:45:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 81EF461006; Thu, 1 Apr 2021 18:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617302588; bh=gPMdy3d4CLHzKWzfd7ezMz440irTyvpHOZ8nXWr+MbY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FhAOqSK+iKAH6Jy26UnFwYDMYsX8UjoW2i5Az4epG4PKe/d8+W6zTUhGrNFbCT9Z/ A14SNnLScohYBEfGUbHaRwYyXdXjGbWUm2k9yQBbd7gLhD1lVg85rYjtmrDjnkShaE XChaJLEjnW5ET2qqbx2ZnAImyAATpBBY8343uTqg0VZTqgRi/Kz4/U9NFc9GWRIhEH qKde8gmVL0HefCwwhjxYIbdKzsj5/uh1wCIHhZZhpCCC/hA6dmsmR/zKwK/feE6Fec KzA2RsRxECMAk8fk+bhqtPUMowUrNFh14pmNsdf5BSYTJKHSPGiaNIC7S9pa+BV1lx c99J8lft+HQaQ== Date: Thu, 1 Apr 2021 11:43:07 -0700 From: Eric Biggers To: "Rafael J. Wysocki" Cc: Ard Biesheuvel , Chris von Recklinghausen , Simo Sorce , Dexuan Cui , Linux PM , Linux Crypto Mailing List , Linux Kernel Mailing List Subject: Re: [PATCH 1/1] use crc32 instead of md5 for hibernation e820 integrity check Message-ID: References: <20210401122458.12663-1-crecklin@redhat.com> <20210401122458.12663-2-crecklin@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Apr 01, 2021 at 06:19:57PM +0200, Rafael J. Wysocki wrote: > On Thu, Apr 1, 2021 at 3:59 PM Ard Biesheuvel wrote: > > > > On Thu, 1 Apr 2021 at 15:34, Rafael J. Wysocki wrote: > > > > > > On Thu, Apr 1, 2021 at 2:25 PM Chris von Recklinghausen > > > wrote: > > > > > > > > Suspend fails on a system in fips mode because md5 is used for the e820 > > > > integrity check and is not available. Use crc32 instead. > > > > > > > > Fixes: 62a03defeabd ("PM / hibernate: Verify the consistent of e820 memory map > > > > by md5 digest") > > > > Signed-off-by: Chris von Recklinghausen > > > > --- > > > > arch/x86/power/hibernate.c | 31 +++++++++++++++++-------------- > > > > 1 file changed, 17 insertions(+), 14 deletions(-) > > > > > > > > diff --git a/arch/x86/power/hibernate.c b/arch/x86/power/hibernate.c > > > > index cd3914fc9f3d..6a3f4e32e49c 100644 > > > > --- a/arch/x86/power/hibernate.c > > > > +++ b/arch/x86/power/hibernate.c > > > > @@ -55,31 +55,31 @@ int pfn_is_nosave(unsigned long pfn) > > > > } > > > > > > > > > > > > -#define MD5_DIGEST_SIZE 16 > > > > +#define CRC32_DIGEST_SIZE 16 > > > > > > > > struct restore_data_record { > > > > unsigned long jump_address; > > > > unsigned long jump_address_phys; > > > > unsigned long cr3; > > > > unsigned long magic; > > > > - u8 e820_digest[MD5_DIGEST_SIZE]; > > > > + u8 e820_digest[CRC32_DIGEST_SIZE]; > > > > }; > > > > > > No. > > > > > > CRC32 was used here before and it was deemed insufficient. > > > > > > > Why? The git commit log does not have an explanation of this. > > IIRC there was an example of a memory map that would produce the same > CRC32 value as the original or something like that. Collisions can easily be found for MD5 as well, as it is heavily broken. Either you need a cryptographic hash function, *or* a (non-cryptographic) checksum would be sufficient. There isn't really any in-between. And if a checksum suffices, MD5 is a bad choice because it was designed as a cryptographic hash function, so it is much slower than a checksum. > > But that said this code is all about failing more gracefully, so I > guess it isn't a big deal if the failure is more graceful in fewer > cases ... If the 1 in 2^32 chance of a CRC-32 collision is too high, then use CRC-64 or xxHash64 for a 1 in 2^64 chance of a collision. - Eric