Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp200272pxj; Thu, 10 Jun 2021 19:27:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycNwvdJeSyNDeiZQl35g4LGDv2k8ONxayEwPfcO8BF42UtcHj7QNkcVovrQKPH/Gc6vYWD X-Received: by 2002:a17:906:f285:: with SMTP id gu5mr1352294ejb.226.1623378456289; Thu, 10 Jun 2021 19:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623378456; cv=none; d=google.com; s=arc-20160816; b=gzYT/uvVgzsUpR/Bx+EAzI82i4xiSQ3ew+vMUdyMhS5j6dcXogtmNRCYuj1HAd2BnN 8tkcnqVhAByv4duG1P0j5E+nqXOGQQSlmgkTjv2L9Wud18juhjDx07KVeIAgpGisDYFu vBdGn7jI7H/FeMwOxRroYNX34AvV6Dd3XoXKvxRLcGlTRSH6CK1O2Zv0NompYAEz5jCd PR/YQ+9B78CURL4a3YfOqTw4jQ2Q+ju4boClPYWr8WNMLfes0tf6vTl484H/IprDoxBL FdsAQuZgefwCwfZ6p/QLoHWSQMiBhmukVQh8eTzQy3H+e7Cp8nkB3Lw07GmpydXZO7EH 1ExA== 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=6SmDDmcHsiLQXQNTrX0A9KnFe0+5NlAMJUDIsFOyPjs=; b=DPNbL8G41t8GUtd4GQFHWIhZ3cjvNjDKuLjkGn+jWZtLex2erxHv8wcoGIj5OLKiSN 99rLOXo/85arExie+VcIlb+r3uFDPBxQOc0KOpzrDF8JB5PAaJX1FPz/aIDm7HHH6zIg sO52HbH93gjZulCwZSOu+VRwFpHd0T9RbyUNPCs5sPOKc+eWa4WEnfUgaAFlvAuNp9Gk +9/TpjC8nIiy66aJv/xObMQqr6CfHf8C/h1Qi7gOm2zvGoTgFHdvf0SDsM4qLEdIt4bU TQnCyyLb43B5sPIaYtpov0IHONxXBlfbU4E/x/dT9UUEhiT+eK+t8gSSnlj22wGijKHe MgZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V4msDiLz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-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 n2si3850256edi.195.2021.06.10.19.27.06; Thu, 10 Jun 2021 19:27:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=V4msDiLz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-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 S231415AbhFKC1R (ORCPT + 99 others); Thu, 10 Jun 2021 22:27:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:57138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbhFKC1Q (ORCPT ); Thu, 10 Jun 2021 22:27:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 253BC6124C; Fri, 11 Jun 2021 02:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623378319; bh=j3FDr9xnJcCgR07zql+OK4VkeLxdJj8Zl8SGv4olxds=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V4msDiLz9LmE5aELx0LYd9HBwB8gSJ1pfSUBRfhmsPE9KQ2VrI0Uo5x7cCMwraUHJ 9Y2xxRkPxwjrVLLakCttfFnNm4yKxj8GDTcfVk6f+gFb8B+EADbCNsyntlOJ5/oi/Y uXmzvZmi2MnPhuv/n0jgg1NhC+hO8HOdXJEyc0tSd4rwzEeW0v3knLq9S7qaZcV5um Q4ZqJGlKsoy1gMy/v07LBIIhG58rtWVl0YTxazLLHZOJbVnfxaIWxpCaeWsawnViAZ 5alMaKoRg70mfjdFbWtRDcHDWhYvlKiGHQXE5aT/NS1Pgbe57kpajo9NF2s31eLTTO jovtxVxNjtAGg== Date: Thu, 10 Jun 2021 19:25:17 -0700 From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Daniel Rosenberg , stable@vger.kernel.org Subject: Re: [PATCH v2] fscrypt: fix derivation of SipHash keys on big endian CPUs Message-ID: References: <20210605075033.54424-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210605075033.54424-1-ebiggers@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Sat, Jun 05, 2021 at 12:50:33AM -0700, Eric Biggers wrote: > From: Eric Biggers > > Typically, the cryptographic APIs that fscrypt uses take keys as byte > arrays, which avoids endianness issues. However, siphash_key_t is an > exception. It is defined as 'u64 key[2];', i.e. the 128-bit key is > expected to be given directly as two 64-bit words in CPU endianness. > > fscrypt_derive_dirhash_key() and fscrypt_setup_iv_ino_lblk_32_key() > forgot to take this into account. Therefore, the SipHash keys used to > index encrypted+casefolded directories differ on big endian vs. little > endian platforms, as do the SipHash keys used to hash inode numbers for > IV_INO_LBLK_32-encrypted directories. This makes such directories > non-portable between these platforms. > > Fix this by always using the little endian order. This is a breaking > change for big endian platforms, but this should be fine in practice > since these features (encrypt+casefold support, and the IV_INO_LBLK_32 > flag) aren't known to actually be used on any big endian platforms yet. > > Fixes: aa408f835d02 ("fscrypt: derive dirhash key for casefolded directories") > Fixes: e3b1078bedd3 ("fscrypt: add support for IV_INO_LBLK_32 policies") > Cc: # v5.6+ > Signed-off-by: Eric Biggers > --- > > v2: Fixed fscrypt_setup_iv_ino_lblk_32_key() too, not just > fscrypt_derive_dirhash_key(). > > fs/crypto/keysetup.c | 40 ++++++++++++++++++++++++++++++++-------- > 1 file changed, 32 insertions(+), 8 deletions(-) > Applied to fscrypt.git#master for 5.14. - Eric