Re: [f2fs-dev] [PATCH v6 6/9] scsi: ufs: Add inline encryption support to UFS

2020-01-17 Thread Eric Biggers
On Fri, Jan 17, 2020 at 05:58:08AM -0800, Christoph Hellwig wrote: > On Wed, Dec 18, 2019 at 06:51:33AM -0800, Satya Tangirala wrote: > > Wire up ufshcd.c with the UFS Crypto API, the block layer inline > > encryption additions and the keyslot manager. > > I think this patch should be merged into

Re: [f2fs-dev] [PATCH v6 2/9] block: Add encryption context to struct bio

2020-01-17 Thread Eric Biggers
On Fri, Jan 17, 2020 at 12:32:21AM -0800, Christoph Hellwig wrote: > > File systems don't move data around all that often (saying that with my > fs developer hat on). In traditional file systems only defragmentation > will move data around, with extent refcounting it can also happen for > dedup,

Re: [f2fs-dev] [PATCH v6 6/9] scsi: ufs: Add inline encryption support to UFS

2020-01-17 Thread Eric Biggers
On Wed, Dec 18, 2019 at 06:51:33AM -0800, Satya Tangirala wrote: > @@ -4654,6 +4686,8 @@ static int ufshcd_slave_configure(struct scsi_device > *sdev) > if (ufshcd_is_rpm_autosuspend_allowed(hba)) > sdev->rpm_autosuspend = 1; > > + ufshcd_crypto_setup_rq_keyslot_manager(h

[f2fs-dev] [PATCH v3 4/9] fscrypt: Only create hash key when needed

2020-01-17 Thread Daniel Rosenberg via Linux-f2fs-devel
If a directory isn't casefolded, it doesn't need the hash key. Skip deriving it unless we enable it later. Signed-off-by: Daniel Rosenberg --- fs/crypto/keysetup.c | 2 +- fs/crypto/policy.c | 25 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/fs/cryp

[f2fs-dev] [PATCH v3 6/9] f2fs: Handle casefolding with Encryption

2020-01-17 Thread Daniel Rosenberg via Linux-f2fs-devel
This expands f2fs's casefolding support to include encrypted directories. For encrypted directories, we use the siphash of the casefolded name. This ensures there is no direct way to go from an unencrypted name to the stored hash on disk without knowledge of the encryption policy keys. Additionall

[f2fs-dev] [PATCH v3 1/9] fscrypt: Add siphash and hash key for policy v2

2020-01-17 Thread Daniel Rosenberg via Linux-f2fs-devel
With encryption and casefolding, we cannot simply take the hash of the ciphertext because of case insensitivity, and we can't take the hash of the unencrypted name since that would leak information about the encrypted name. Instead we can use siphash to compute a keyed hash of the file names. When

[f2fs-dev] [PATCH v3 3/9] fscrypt: Change format of no-key token

2020-01-17 Thread Daniel Rosenberg via Linux-f2fs-devel
Fscrypt supplies a no-key token in place of file names when the name is encrypted and the key is not present. In the current scheme, the no-key token is the base64 encoded ciphertext of the name, unless the name is longer than a certain amount, after which it uses an alternative scheme which includ

[f2fs-dev] [PATCH v3 2/9] fscrypt: Don't allow v1 policies with casefolding

2020-01-17 Thread Daniel Rosenberg via Linux-f2fs-devel
Casefolding currently requires a derived key for computing the siphash. This is available for v2 policies, but not v1, so we disallow it for v1. Signed-off-by: Daniel Rosenberg --- fs/crypto/policy.c | 28 fs/inode.c | 3 ++- include/linux/fscrypt.

[f2fs-dev] [PATCH v3 5/9] vfs: Fold casefolding into vfs

2020-01-17 Thread Daniel Rosenberg via Linux-f2fs-devel
Ext4 and F2fs are both using casefolding, and they, along with any other filesystem that adds the feature, will be using identical dentry_ops. Additionally, those dentry ops interfere with the dentry_ops required for fscrypt once we add support for casefolding and encryption. Moving this into the v

[f2fs-dev] [PATCH v3 8/9] ext4: Hande casefolding with encryption

2020-01-17 Thread Daniel Rosenberg via Linux-f2fs-devel
This adds support for encryption with casefolding. Since the name on disk is case preserving, and also encrypted, we can no longer just recompute the hash on the fly. Additionally, to avoid leaking extra information from the hash of the unencrypted name, we use siphash via an fscrypt v2 policy. T

[f2fs-dev] [PATCH v3 7/9] ext4: Use struct super_blocks' casefold data

2020-01-17 Thread Daniel Rosenberg via Linux-f2fs-devel
Switch over to using the struct entries added to the VFS Signed-off-by: Daniel Rosenberg --- fs/ext4/dir.c | 47 --- fs/ext4/ext4.h | 4 fs/ext4/hash.c | 2 +- fs/ext4/namei.c | 20 fs/ext4/super.c | 15 +--

[f2fs-dev] [PATCH v3 9/9] ext4: Optimize match for casefolded encrypted dirs

2020-01-17 Thread Daniel Rosenberg via Linux-f2fs-devel
Matching names with casefolded encrypting directories requires decrypting entries to confirm case since we are case preserving. We can avoid needing to decrypt if our hash values don't match. Signed-off-by: Daniel Rosenberg --- fs/ext4/ext4.h | 17 --- fs/ext4/namei.c | 55 +

[f2fs-dev] [PATCH v3 0/9] Support for Casefolding and Encryption

2020-01-17 Thread Daniel Rosenberg via Linux-f2fs-devel
These patches are all on top of fscrypt's developement branch 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 u

Re: [f2fs-dev] [PATCH] fscrypt: reserve flags for hardware-wrapped keys feature

2020-01-17 Thread Greg KH
On Fri, Jan 17, 2020 at 11:40:54AM -0500, Theodore Y. Ts'o wrote: > On Fri, Jan 17, 2020 at 12:12:46AM -0800, Christoph Hellwig wrote: > > On Thu, Jan 16, 2020 at 11:20:08AM -0800, Eric Biggers wrote: > > > From: Eric Biggers > > > > > > Reserve flags for the hardware-wrapped keys feature which i

Re: [f2fs-dev] [PATCH] fscrypt: reserve flags for hardware-wrapped keys feature

2020-01-17 Thread Theodore Y. Ts'o
On Fri, Jan 17, 2020 at 12:12:46AM -0800, Christoph Hellwig wrote: > On Thu, Jan 16, 2020 at 11:20:08AM -0800, Eric Biggers wrote: > > From: Eric Biggers > > > > Reserve flags for the hardware-wrapped keys feature which is being > > worked on [1]. FSCRYPT_POLICY_FLAG_HW_WRAPPED_KEY will denote t

Re: [f2fs-dev] [PATCH v6 6/9] scsi: ufs: Add inline encryption support to UFS

2020-01-17 Thread Christoph Hellwig
On Wed, Dec 18, 2019 at 06:51:33AM -0800, Satya Tangirala wrote: > Wire up ufshcd.c with the UFS Crypto API, the block layer inline > encryption additions and the keyslot manager. I think this patch should be merged into the previous patch, as the previous one isn't useful without wiring it up. >

Re: [f2fs-dev] [PATCH v6 5/9] scsi: ufs: UFS crypto API

2020-01-17 Thread Christoph Hellwig
> index 94c6c5d7334b..e88cdcde83fd 100644 > --- a/drivers/scsi/ufs/Makefile > +++ b/drivers/scsi/ufs/Makefile > @@ -12,3 +12,4 @@ obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o > obj-$(CONFIG_SCSI_UFS_HISI) += ufs-hisi.o > obj-$(CONFIG_SCSI_UFS_MEDIATEK) += ufs-mediatek.o > obj-$(CONFIG_S

Re: [f2fs-dev] [PATCH v6 4/9] scsi: ufs: UFS driver v2.1 spec crypto additions

2020-01-17 Thread Christoph Hellwig
On Wed, Dec 18, 2019 at 06:51:31AM -0800, Satya Tangirala wrote: > Add the crypto registers and structs defined in v2.1 of the JEDEC UFSHCI > specification in preparation to add support for inline encryption to > UFS. > > Signed-off-by: Satya Tangirala > --- > drivers/scsi/ufs/ufshcd.c | 2 ++ >

Re: [f2fs-dev] [PATCH v6 1/9] block: Keyslot Manager for Inline Encryption

2020-01-17 Thread Christoph Hellwig
> +struct keyslot_manager { > + unsigned int num_slots; > + struct keyslot_mgmt_ll_ops ksm_ll_ops; > + unsigned int crypto_mode_supported[BLK_ENCRYPTION_MODE_MAX]; > + void *ll_priv_data; > + > + /* Protects programming and evicting keys from the device */ > + struct rw_sema

Re: [f2fs-dev] [PATCH v6 0/9] Inline Encryption Support

2020-01-17 Thread Christoph Hellwig
Hi Satya, On Wed, Jan 08, 2020 at 10:43:05AM -0800, Satya Tangirala wrote: > The fallback actually is in a separate file, and the software only fields > are not allocated in the hardware case anymore, either - I should have > made that clear(er) in the coverletter. I see this now, thanks. Either

Re: [f2fs-dev] [PATCH v6 2/9] block: Add encryption context to struct bio

2020-01-17 Thread Christoph Hellwig
Hi Eric, On Wed, Jan 08, 2020 at 09:26:29AM -0800, Eric Biggers wrote: > The NVMe "key per I/O" draft is heavily flawed, and I don't think it will be > useful at all in the Linux kernel context. The problem is that, as far as I > can tell, it doesn't allow the encryption algorithm and IVs to be s

Re: [f2fs-dev] [PATCH] fscrypt: reserve flags for hardware-wrapped keys feature

2020-01-17 Thread Christoph Hellwig
On Thu, Jan 16, 2020 at 11:20:08AM -0800, Eric Biggers wrote: > From: Eric Biggers > > Reserve flags for the hardware-wrapped keys feature which is being > worked on [1]. FSCRYPT_POLICY_FLAG_HW_WRAPPED_KEY will denote that the > encryption policy needs a hardware-wrapped key to be unlocked. > FS

[f2fs-dev] [PATCH] f2fs: compress: fix to avoid NULL pointer dereference

2020-01-17 Thread Chao Yu
If cluster has only one compressed page, race condition as below will trigger NULL pointer dereference: - f2fs_write_compressed_pages - cic->rpages[0] = cc->rpages[0]; - f2fs_outplace_write_data - f2fs_compress_write_end_io