Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1250440ybv; Fri, 7 Feb 2020 17:36:29 -0800 (PST) X-Google-Smtp-Source: APXvYqzse/2yXceiYnwKgapGLRIxuxs7an6K9trT79ZYVCyzJbjmB7VBM/zbX+ayZU/hcpzrJo3I X-Received: by 2002:aca:fd16:: with SMTP id b22mr4053937oii.73.1581125789824; Fri, 07 Feb 2020 17:36:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581125789; cv=none; d=google.com; s=arc-20160816; b=dEIH8XD6K/Szu+UDbUbTCM2Mu39xEIyDVZoqhVCcT5WywBbRzKJVJmzieaAHO5jhIB USeeshpZVAatxYedoHxGsJAAmpXdOTiB3ct/mu8BV7CeneYozN3GLr1x5pDEABBMvcCY xFMY5OuLQKHkY1mKJoho1JilVaPSQjQHL2qwvCHtD+p76BmBxeIxkzHlJaZmP3nPtZuG vTyu/bO5+aIBhPl5P0t9jqSVVIFbpcR9FDwin7/VKeICycuctgcX57ICgJw4ShCpPaQb 5X84KIH3ey8i2CLvjxS5SWElZXnkF2B9ospXW9IGDxi7En7W5HpajdH0R79yc+S+XQPD Mxug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=GmdJt27134kNRYXiKp4wrB+O4TXMZQXM52BZBGOfEtM=; b=mhlqTMBvtuZVTiLA2vcefyjEUWEF9qNmQsAorE9nhaJhap3CUfn/XFgpx9JBpJr2wK l65upZhQfH5XF+XTgWc0D8mVU2iJkojd4dzTMdBiYiDx1SKWvn5jZvWP3dHqm1iQt6cq 4K9yE6/KeLNMI5R1KuuU/nMsfyOv3mUvQhNSm0Ev8pU29au2dAUHhXtCtC+18uEQdbgt X7OTQ46I5BOyYFyup3D2SSVHTSbR2ZNXcanjdIZpy4E8kvtQMpbqyg69c+cBbyHk3oYl ko7v9+bxf/nCRSxzPbT+M4/cRUMGCsOCcUTjhQtm7RjYwovAqQsmwBXAQpoXKocnw8aH 3A+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZzptqxUs; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q65si4716100oic.123.2020.02.07.17.36.19; Fri, 07 Feb 2020 17:36:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZzptqxUs; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727131AbgBHBeq (ORCPT + 99 others); Fri, 7 Feb 2020 20:34:46 -0500 Received: from mail-pj1-f73.google.com ([209.85.216.73]:37691 "EHLO mail-pj1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727118AbgBHBep (ORCPT ); Fri, 7 Feb 2020 20:34:45 -0500 Received: by mail-pj1-f73.google.com with SMTP id dw15so2350884pjb.2 for ; Fri, 07 Feb 2020 17:34:45 -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=GmdJt27134kNRYXiKp4wrB+O4TXMZQXM52BZBGOfEtM=; b=ZzptqxUsermKYJMyiUDjvBiGxUIdwqTzJfy+wNJraQ/fqxPgGbS6BGRKrTpYZT99NP LQVDbxgl6rqVunRCW0ICPGiKpNThIj+TdvQ5TjjeSLkpDlJtuWqpEnxBlBrS2HEtG+RW 9z2HN6g50wLJeFY9fmYqHHVVeKmyWOB0q7ii4xnMViegdwpFM70+FfqSZe7YAxDz9qPz rQI68XvesZcSELHJhYuD8Anx5KlcByOodivzB6VfODhyuo8qsoR7iOlqkI0zS2IW8J1A G74nrd0ARErEc3uP+liYKFfxifqkv4AUuLVaYmPTGE7ECQxADA+maD2kLEzIxEDZMkLy HKfQ== 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=GmdJt27134kNRYXiKp4wrB+O4TXMZQXM52BZBGOfEtM=; b=JEu5ZePbwn997tJ7wZCjDo2a8BR0PNR8HVaBhqrT+iAee93db2KjA65Vbb8f6IgI7G 53I7uDptYn0sdIki9sTzV6wjgmtX4qaqQ6gRqPoGAKhhMJ+eGRo0g85YrL3dC+xR080H rIojG5LY3eNEhWS4J24MUqs6Y4tMOhDqvnu+4B2VELcVDuhAImRhYDUm936hJxo/QzBS qrONsp7VIRVGLyhHWCzW4cNwZQIEyCslIim+4lr9ClWxQ8jeaXbKfV2i8LcjuZWsckQr VTJbrqZcDk5mB+dBRJdMrhMZCC8R8KT3XJKBoVgppf2iMCnoAdpxENHKcN9rBGMDEaIz o18A== X-Gm-Message-State: APjAAAVpzMNFuIRf5mSKBjz9m29c/smk/t9tHA3N1M3KS0qWRuNV64eh NKm6/cVtricBE7Mp5RDBT10gjGfg6Bk= X-Received: by 2002:a63:1c1d:: with SMTP id c29mr2121466pgc.14.1581125684457; Fri, 07 Feb 2020 17:34:44 -0800 (PST) Date: Fri, 7 Feb 2020 17:34:30 -0800 Message-Id: <20200208013438.240137-1-drosen@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v7 0/8] Support fof 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 , Richard Weinberger Cc: linux-mtd@lists.infradead.org, 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-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org These patches are all on top of torvalds/master Ext4 and F2FS currently both support casefolding and encryption, but not at the same time. These patches aim to rectify that. I moved the identical casefolding dcache operations for ext4 and f2fs into fs/libfs.c, as all filesystems using casefolded names will want them. I've also adjust fscrypt to not set it's d_revalidate operation during it's prepare lookup, instead having the calling filesystem set it up. This is done to that the filesystem may have it's own dentry_operations. Also added a helper function in libfs.c that will work for filesystems supporting both casefolding and fscrypt. For Ext4, since the hash for encrypted casefolded directory names cannot be computed without the key, 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 be 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 ext4's fsck's, although without access to the keys, neither fsck will be able to verify the hashes of casefolded and encrypted names. v7 chances: Moved dentry operations from unicode to libfs, added new iterator function to unicode to allow this. Added libfs function for setting dentries to remove code duplication between ext4 and f2fs. v6 changes: Went back to using dentry_operations for casefolding. Provided standard implementations in fs/unicode, avoiding extra allocation in d_hash op. Moved fscrypt d_ops setting to be filesystem's responsibility to maintain compatibility with casefolding and overlayfs if casefolding is not used fixes some f2fs error handling v4-5: patches submitted on fscrypt v3 changes: fscrypt patch only creates hash key if it will be needed. Rebased on top of fscrypt branch, reconstified match functions in ext4/f2fs v2 changes: fscrypt moved to separate thread to rebase on fscrypt dev branch addressed feedback, plus some minor fixes Daniel Rosenberg (8): unicode: Add utf8_casefold_iter fs: Add standard casefolding support f2fs: Use generic casefolding support ext4: Use generic casefolding support fscrypt: Have filesystems handle their d_ops f2fs: Handle casefolding with Encryption ext4: Hande casefolding with encryption ext4: Optimize match for casefolded encrypted dirs Documentation/filesystems/ext4/directory.rst | 27 ++ fs/crypto/fname.c | 7 +- fs/crypto/fscrypt_private.h | 1 - fs/crypto/hooks.c | 1 - fs/ext4/dir.c | 78 +---- fs/ext4/ext4.h | 93 ++++-- fs/ext4/hash.c | 26 +- fs/ext4/ialloc.c | 5 +- fs/ext4/inline.c | 41 ++- fs/ext4/namei.c | 325 ++++++++++++------- fs/ext4/super.c | 21 +- fs/f2fs/dir.c | 127 +++----- fs/f2fs/f2fs.h | 15 +- fs/f2fs/hash.c | 25 +- fs/f2fs/inline.c | 9 +- fs/f2fs/namei.c | 1 + fs/f2fs/super.c | 17 +- fs/f2fs/sysfs.c | 10 +- fs/libfs.c | 127 ++++++++ fs/ubifs/dir.c | 18 + fs/unicode/utf8-core.c | 25 +- include/linux/f2fs_fs.h | 3 - include/linux/fs.h | 24 ++ include/linux/fscrypt.h | 6 +- include/linux/unicode.h | 10 + 25 files changed, 671 insertions(+), 371 deletions(-) -- 2.25.0.341.g760bfbb309-goog