Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1097213ybt; Wed, 1 Jul 2020 18:56:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2lhP+hcXd8ImZSVLtlI9U1nXhlu1sRej4LW4lUVgN1S/3EFtRAAqKGDUptnduI6iAWaBl X-Received: by 2002:a05:6402:1605:: with SMTP id f5mr34156466edv.8.1593655009704; Wed, 01 Jul 2020 18:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593655009; cv=none; d=google.com; s=arc-20160816; b=aSGIHNY3DFrnIgVSqtY1kwFuDQJqMrdjGHWTd+actwG/mch/4yJkmtPk23AefOPwhK s2AmfwDKb0NXGfXdGTB/r4f6np+vBZELCRU9XpDWuqc354JaSYqsfI/vjdNM3qrrWF3v DgnNqTHBsbTsne/3tyYw/WEMfwxo8CkpufDOo9rN5jTQuN9y6/ju4vgaPSd3udXRP4OE xwyfqdNs2Pnltebzv+7NYt6vNLDORRSU2bYi4slvDE6A6Y0Zz9aw3SJHObwJfRst5hNL USwbqDjcZa8KZZAOcGCILsixRESaUuj41dcX1iGTRe85bkgTzpjcBrBDKjeWWdT1LbTL ZB8g== 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=xAITaULtdMDEOzvw+l2Rasjf1QfU0QQ930xQ9EFFDhw=; b=yvjVtlyaviQUUlSkkNP/k3HD0RCk+u8E9zteQZRFZeVzIokzmmf9x3GWZFqrMj4lyV OIDN1+qGFeJLPwknxfW1urrp4BhMg98FwDVnHD92fnbdhx/y7iKYx9JaWpDgkCQWzjul GgfHQOn+Gc5eI7ntpkZHl36CThIr3RV1wG2JldKt8+fbp7flBXXU7us7TWWt+EnTlgvj Rc5IiwGZMXi/2EM4NgOS6juRFo1jdAEa35YQJycI2EaG6FxhiOQsCH4ktq3ahACTmyWl MSwE43YyuAcUmAkLpo61wzrcprPaFe/yNc5+c02k017ocIavftdzR5KvkPzA6g0T5hs3 pCLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mJr6dns1; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dh1si4955800edb.54.2020.07.01.18.56.18; Wed, 01 Jul 2020 18:56:49 -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=@google.com header.s=20161025 header.b=mJr6dns1; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728014AbgGBB4M (ORCPT + 99 others); Wed, 1 Jul 2020 21:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726735AbgGBB4L (ORCPT ); Wed, 1 Jul 2020 21:56:11 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BA16C08C5C1 for ; Wed, 1 Jul 2020 18:56:11 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id e192so28033615ybf.17 for ; Wed, 01 Jul 2020 18:56:11 -0700 (PDT) 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=xAITaULtdMDEOzvw+l2Rasjf1QfU0QQ930xQ9EFFDhw=; b=mJr6dns1TdHPLaPk1l1nUCN4IUtvYtOpMd2odmYKWwr0/WbLXDSazaIVv1ciEv9fJ6 SutKMg5RIy1dEiGwT8tnYEFpjFd9W3ngQvNkiALl+UdZ0ZpNdu4FjIE80wjAdsRl8PXr qpPoSKhwncdhK0vfriwJb2pRIZrTdVXv1cetv5y7HizWBttesdKay1ggMdGpx0GXDBNT 5dmnOm8hmCDyzG+8x4qUxQgWyr8aQpbgx3O9tMQF8yy3S+D+8d8nHIzsCTwDEX5dtTE9 viXRGOQoHfzNzEwu76bLCC0Nna/lluLtAlSJGwqypdkfxZWTZKMdIexOw/mnSePGmjfr uazg== 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=xAITaULtdMDEOzvw+l2Rasjf1QfU0QQ930xQ9EFFDhw=; b=LlXYZphrqOwHvVYBi7riUYar9UgLMQe2V/bNpmYA2NUZULJZkLomIRNvoFNoLmqMk3 Fc29DzU/U1xUCXB9vyrq3gmWbJB6f2pnHF3u2HIqv87g8+svDLU4P+NoOoI0yWIBobVi 6jbhexnbjPfMJIemYpPqS0Ltk08D2tO+AWyITe8PXk5LZkzx3oz827mv8uVW9Xwp8UH8 k8MG8FAUSkoMxFmi5OFxLJHarzuE4+b1/hBFFIOOVi5NCHHE3txpRgR7CYDFjiFwCPSy qBeSlkCO8EfVd5uJSRukLB5vvr3+0u8v2Z2LD+jK80RcdnJeOrBGPIELcTV6xljbcDeD 9uuQ== X-Gm-Message-State: AOAM530F/zghw5ChdJ1BpX/ithdY0LljerZPczKqh6yvf76CHC8Q1+4x /vwFpavO9NHCO5NuLbLsrDq0K3Mqui0= X-Received: by 2002:a25:3bca:: with SMTP id i193mr46883130yba.182.1593654970400; Wed, 01 Jul 2020 18:56:10 -0700 (PDT) Date: Thu, 2 Jul 2020 01:56:03 +0000 Message-Id: <20200702015607.1215430-1-satyat@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH v4 0/4] Inline Encryption Support for fscrypt From: Satya Tangirala To: linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org Cc: Satya Tangirala 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 This patch series adds support for Inline Encryption to fscrypt, f2fs and ext4. It builds on the inline encryption support now present in the block layer, and has been rebased on v5.8-rc3. Note that Patches 1 and 2 can be applied independently of Patches 3 and 4 (and Patches 3 and 4 can be applied independently of each other). This patch series previously went though a number of iterations as part of the "Inline Encryption Support" patchset (last version was v13: https://lkml.kernel.org/r/20200514003727.69001-1-satyat@google.com). Patch 1 introduces the SB_INLINECRYPT sb options, which filesystems should set if they want to use blk-crypto for file content en/decryption. Patch 2 adds inline encryption support to fscrypt. To use inline encryption with fscrypt, the filesystem must set the above mentioned SB_INLINECRYPT sb option. When this option is set, the contents of encrypted files will be en/decrypted using blk-crypto. Patches 3 and 4 wire up f2fs and ext4 respectively to fscrypt support for inline encryption, and e.g ensure that bios are submitted with blocks that not only are contiguous, but also have continuous DUNs. This patchset was tested by running xfstests with the "inlinecrypt" mount option on ext4 and f2fs with test dummy encryption (the actual en/decryption of file contents was handled by the blk-crypto-fallback). It was also tested along with the UFS patches from the original series on some Qualcomm and Mediatek chipsets with hardware inline encryption support (refer to https://lkml.kernel.org/linux-scsi/20200501045111.665881-1-ebiggers@kernel.org/ and https://lkml.kernel.org/linux-scsi/20200304022101.14165-1-stanley.chu@mediatek.com/ for more details on those tests). Changes v3 => v4 - change the page_is_mergeable() check in add_ipu_page() to an f2fs_bug_on since the only caller of add_ipu_page() already checks page_is_mergeable - add reviewed by Changes v2 => v3 - Fix issue with inline encryption + IV_INO_LBLK_32 policy found by Eric - minor cleanup Changes v1 => v2 - SB_INLINECRYPT mount option is shown by individual filesystems instead of by the common VFS code since the option is parsed by filesystem specific code, and is not a mount option applicable generically to all filesystems. - Make fscrypt_select_encryption_impl() return error code when it fails to allocate memory. - cleanups Changes v13 in original patchset => v1 - rename struct fscrypt_info::ci_key to ci_enc_key - set dun bytes more precisely in fscrypt - cleanups Eric Biggers (1): ext4: add inline encryption support Satya Tangirala (3): fs: introduce SB_INLINECRYPT fscrypt: add inline encryption support f2fs: add inline encryption support Documentation/admin-guide/ext4.rst | 7 + Documentation/filesystems/f2fs.rst | 7 + Documentation/filesystems/fscrypt.rst | 3 + fs/buffer.c | 7 +- fs/crypto/Kconfig | 6 + fs/crypto/Makefile | 1 + fs/crypto/bio.c | 51 ++++ fs/crypto/crypto.c | 2 +- fs/crypto/fname.c | 4 +- fs/crypto/fscrypt_private.h | 115 +++++++- fs/crypto/inline_crypt.c | 364 ++++++++++++++++++++++++++ fs/crypto/keyring.c | 6 +- fs/crypto/keysetup.c | 70 +++-- fs/crypto/keysetup_v1.c | 16 +- fs/ext4/inode.c | 4 +- fs/ext4/page-io.c | 6 +- fs/ext4/readpage.c | 11 +- fs/ext4/super.c | 12 + fs/f2fs/compress.c | 2 +- fs/f2fs/data.c | 79 +++++- fs/f2fs/super.c | 35 +++ include/linux/fs.h | 1 + include/linux/fscrypt.h | 82 ++++++ 23 files changed, 820 insertions(+), 71 deletions(-) create mode 100644 fs/crypto/inline_crypt.c -- 2.27.0.212.ge8ba1cc988-goog