From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4A1FC33C99 for ; Tue, 7 Jan 2020 05:16:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 965EA207FD for ; Tue, 7 Jan 2020 05:16:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Q40BGR+M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726276AbgAGFQr (ORCPT ); Tue, 7 Jan 2020 00:16:47 -0500 Received: from mail-ua1-f73.google.com ([209.85.222.73]:49238 "EHLO mail-ua1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725601AbgAGFQq (ORCPT ); Tue, 7 Jan 2020 00:16:46 -0500 Received: by mail-ua1-f73.google.com with SMTP id j16so4806580uak.16 for ; Mon, 06 Jan 2020 21:16:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=cfX1tvKpjBFaGwVknnvW2VBwxewGwbcoGgPS02CBSEM=; b=Q40BGR+McgMbCgqtKK+XRsRmJJBj/BH4LjOY1inQamlLz1Onc25gJfKSbGCbLp3BV6 kKbmIcg1Qs8OlNWNQNQVhlpP5eQeWpb8bdcg/T1uA1M21Nwy3AmiDfyWJt0tvnczfV4l F5+GHxcTVIFp5EjxqoKHbB5BR5AscstZMpWufBT8/BJSWPsoka2tUFUerrjyIkmcUjjK wZ3VxyoNX/QvFD5IuLtoVSHr99qrCNN1Y+s01aUz0lsnsY4sqo6j8cw1VnQNt7bNfDGH /9+qGi2HEFX3SqvMkNy9rSPpAhx5BvUPP3MMTK/c1L92gGjvYGn+U5QaEIouLcVwROXe FVsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=cfX1tvKpjBFaGwVknnvW2VBwxewGwbcoGgPS02CBSEM=; b=EgVwR7TumOOiZ7gxX+HP+zJIiXN0m+V+8RgKRYzKqWzEZLVNX1xeghxoEq9AfYD7f4 egMh/IEVErDK2GsO4b0JphObjh593A1QHJUj5bmktsDfNIzFKwOwK71DNGkfpo4dGCBc tOV9W4QlQKuqSEPwX2jqxyD2eZZqJeom0Vh+hEYDcs4zWVjb59ck4sjHA1jaZJFGdqSJ NaHnuDr9yec48h6Jnz3pCgwJgnEe/XgCPkC2nZncY//XFONjvjg24ctr2Q0uVOADqPiA 2XfMRjFAHQKmuDw3DfEmicOh3A8mGQSlZltf/pmdctyIgSrNb1tc888BREJ2t0U3B8AQ TYxg== X-Gm-Message-State: APjAAAUtqEbMvT9gDPC6tAe7JfO6iXJXYF4IIdrmSkxcehOHWK/zi9TG iWCQw0IDN/HjYfJb0xa8Vj/RLl7ULQ8= X-Google-Smtp-Source: APXvYqzc67czlLj1xc/BSkQkduLdtiKKbLVUdrPq7hUPjUVp5UmYvrkDtchUfmBzIECNLQOquU+7Qzeor7M= X-Received: by 2002:a1f:8d57:: with SMTP id p84mr56402733vkd.65.1578374205529; Mon, 06 Jan 2020 21:16:45 -0800 (PST) Date: Mon, 6 Jan 2020 21:16:32 -0800 Message-Id: <20200107051638.40893-1-drosen@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v2 0/6] Support for Casefolding and Encryption From: Daniel Rosenberg To: "Theodore Ts'o" , linux-ext4@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, Eric Biggers , linux-fscrypt@vger.kernel.org, Alexander Viro Cc: Andreas Dilger , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , kernel-team@android.com, Daniel Rosenberg Content-Type: text/plain; charset="UTF-8" Sender: linux-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org Ext4 and F2FS currently both support casefolding and encryption, but not at the same time. These patches aim to rectify that. Since directory names are stored case preserved, we cannot just take the hash of the ciphertext. Instead we use the siphash of the casefolded name. With this we no longer have a direct path from an encrypted name to the hash without the key. To deal with this, fscrypt now always includes the hash in the name it presents when the key is not present. There is a pre-existing bug where you can change parts of the hash and still match the name so long as the disruption to the hash does not happen to affect lookup on that filesystem. I'm not sure how to fix that without making ext4 lookups slower in the more common case. I moved the identical dcache operations for ext4 and f2fs into the VFS, as any filesystem that uses casefolding will need the same code. This will also allow further optimizations to that path, although my current changes don't take advantage of that yet. For Ext4, this also means that we need to store the hash on disk. We only do so for encrypted and casefolded directories to avoid on disk format changes. Previously encryption and casefolding could not live on the same filesystem, and we're relaxing that requirement. F2fs is a bit more straightforward since it already stores hashes on disk. I've updated the related tools with just enough to enable the feature. I still need to adjust their respective fsck's, although without access to the keys, they won't be able to verify the hashes of casefolded and encrypted names. changes: fscrypt moved to separate thread to rebase on fscrypt dev branch addressed feedback, plus some minor fixes Daniel Rosenberg (6): TMP: fscrypt: Add support for casefolding with encryption vfs: Fold casefolding into vfs f2fs: Handle casefolding with Encryption ext4: Use struct super_blocks' casefold data ext4: Hande casefolding with encryption ext4: Optimize match for casefolded encrypted dirs Documentation/filesystems/ext4/directory.rst | 27 ++ fs/crypto/Kconfig | 1 + fs/crypto/fname.c | 234 ++++++++++--- fs/crypto/fscrypt_private.h | 9 + fs/crypto/keysetup.c | 32 +- fs/crypto/policy.c | 45 ++- fs/dcache.c | 28 ++ fs/ext4/dir.c | 75 +---- fs/ext4/ext4.h | 87 +++-- fs/ext4/hash.c | 26 +- fs/ext4/ialloc.c | 5 +- fs/ext4/inline.c | 41 ++- fs/ext4/namei.c | 326 ++++++++++++------- fs/ext4/super.c | 21 +- fs/f2fs/dir.c | 114 +++---- fs/f2fs/f2fs.h | 14 +- fs/f2fs/hash.c | 25 +- fs/f2fs/inline.c | 9 +- fs/f2fs/super.c | 17 +- fs/f2fs/sysfs.c | 8 +- fs/inode.c | 7 + fs/namei.c | 41 ++- include/linux/fs.h | 10 + include/linux/fscrypt.h | 96 ++---- include/linux/unicode.h | 14 + 25 files changed, 835 insertions(+), 477 deletions(-) -- 2.24.1.735.g03f4e72817-goog