16 Commits

Author SHA1 Message Date
Jaegeuk Kim
b5bdb49f03 ICE, pfk: fix to set dio_inode precisely
When using loopback device with dio, we can't rely on page flag.

Bug: 141601405
Bug: 141860559
Bug: 140882488
Change-Id: I09526c25e8d5333853e777f29333f9fa8da37459
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2023-03-26 12:09:04 +01:00
Linux Build Service Account
d296696f81 Merge "dm-default-key, f2fs, ICE: support dm-default-key with f2fs/ICE" 2018-10-30 00:56:13 -07:00
Neeraj Soni
75e59c916e security: pfe: update data unit number for default key too
Default key will be used to encrypt the metadata of file
system. For metadata inode/bio file encryption type will be invalid
hence data unit number (dun) update in file system specific per file
key driver will not work.

Change-Id: Ib79c35d4b76be4b1cf3732673cc251bfca71f466
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2018-10-22 20:07:50 +05:30
Jaegeuk Kim
3bd012fff6 dm-default-key, f2fs, ICE: support dm-default-key with f2fs/ICE
This patch fixes assigning bi_crypt_key for moving data which was previously
encrypted by f2fs.

Note that, dm-default-key should not assign bi_crypt_key, if bi_crypt_skip is
set.

The issue sceanrios is:

1. write data with user key by f2fs
  -  ENC(KU, IVU, DATA)
2. log out user key
3. read data #1 w/o user key from LBA #a
4. dm-default-key assigns default key
  - DEC(KD, LBA#a, ENC(KU, IVU, DATA))
5. write data #1 w/o user key into LBA #b
6. dm-default-key assigns default key
  - ENC(KD, LBA#b, DEC(KD, LBA#a, ENC(KU, IVU, DATA)))
7. Read DATA out with valid logged-in user key
  - DEC(KU, IVU, ENC(KD, LBA#b, DEC(KD, LBA#a, ENC(KU, IVU, DATA))))

So, this patch introduces bi_crypt_skip to avoid 4. ~ 6 with right flow:
1. write data with user key by f2fs
  -  ENC(KU, IVU, DATA)
2. log out user key
3. read data #1 w/o user key from LBA #a
4. dm-default-key skip to assign default key
  - ENC(KU, IVU, DATA)
5. write data #1 w/o user key into LBA #b
6. dm-default-key skips to assign default key
  - ENC(KU, IVU, DATA)
7. Try to read DATA with valid logged-in user key
  - DEC(KU, IVU, ENC(KU, IVU, DATA))

Issue: 68721442
Change-Id: Icefe85f608b7c3c84beb2bfa4267efd0f3787453
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Signed-off-by: Shivaprasad Hongal <shongal@codeaurora.org>
[neersoni@codeaurora.corg: resolved merged conflicts, compilation issues.]
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2018-10-16 16:37:07 +05:30
Neeraj Soni
e3af8d5f64 security: pfe: make inline crypto engine scm call based on version
Inline Crypto Engine dun setting is done based on its version.
For version <= 2 storage driver handles the dun setting.
For version > 2 dun is handled in trustzone ice driver.

Change-Id: If88ea132c4151712e8402b64b3b88bd3daf2fd18
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2018-09-06 19:00:52 +05:30
Neeraj Soni
efb3311d13 security: pfe: Set DUN size accroding to file system and storage type
EXT4 FS and F2FS has different way of setting Data Unit Number (DUN)
size value for UFS and eMMC storage devices. EXT4 FS uses sector number
while F2FS uses inode|pgidx. Check Storage and file system type
before setting the DUN value in Inline Crypto Engine (ICE).

Change-Id: If822863893fc0725a5ff0410e7418c352ad70fc1
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2018-09-03 00:46:31 -07:00
Linux Build Service Account
92ae1289f7 Merge "security: pfk: use page_mapping to avoid wrong memory access" 2018-08-21 03:49:38 -07:00
Jaegeuk Kim
1158db3525 security: pfk: use page_mapping to avoid wrong memory access
This patch fixes potentially wrong memory access when doing ICE operations.

Change-Id: I4893d106877f6313bbcd2218d7c4ad12f63a0cbe
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2018-08-16 18:27:44 +05:30
Neeraj Soni
cce088b123 security: pfe: Disable clocks for crypto engine
Even if invalidate key scm call is failed crypto
engine clocks should be disabled as fresh set key
call will any way enable clocks again. This will
also help in power savings.

Change-Id: I640150228112a3d36f49cb52a7de0df6cc6a4662
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2018-07-25 15:52:51 +05:30
Neeraj Soni
dee86cba52 security: pfe: Use non blocking scm call
Use non-retrying version of scm calls to
configure ICE keys. This ensures that control is
returned to upper layer as quickly as possible.

Change-Id: Idbecd9301d2f361c17a720c4ac0dcdc393985676
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2018-06-07 00:04:12 -07:00
Neeraj Soni
36c6512ecd Enable hardware based FBE on f2fs and adapt ext4 fs
Hardware File Based Encryption (FBE) uses crypto engine to
encrypt the user data with unique key for each file.
File name and data both are encrypted with this feature.
1. security/pfk: changes to support per file
   encryption for f2fs using hardware crypto engine.
2. fs/ext4: adapted crypto APIs for generic crypto layer.
3. fs/f2fs: support hardware crypto engine based per file
   encryption.
4. fs/crypto: export APIs to support hardware crypto
   engine based per file encryption.
Other changes made to provide support framework for per
file encryption.

Change-Id: I7981fa7f8f0c4bc058b80b7b8e342cfd81697c74
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2018-05-28 10:56:49 +05:30
Neeraj Soni
c692cb9609 Resolve merge conflict and enable HW FBE for ext4 fs
HW File Based Encryption (FBE) uses Crypto Engine to
encrypt the user data with unique key for each file.
File name and data both are encrypted with this feature.
 - security/pfk: New module to support per file
   encryption using CE.
 - fs/ext4: changes made to support using crypto engine
   to encyrpt the data.
Other changes made to provide support framework for per
file encryption.

Change-Id: I82b05a73b10ad8c26b0e400cdf246c67a8060f0e
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2018-05-22 12:58:05 +05:30
Blagovest Kolenichev
fe5289af24 Revert "Enable HW File Based Encryption on ext4 file system"
This reverts commit 7b939265f4.

This is temporary due to hard conflicts against android-4.9.84.

Intake is switched from android-4.9-o to android-4.9 with LSK
tag 4.9.84 and more time is needed to rework the FBE changeset
[1] according to the new upstream changes coming from
android-4.9.

[1] c23efa5 security: pfk: Error code was overwritten
    7b93926 Enable HW File Based Encryption on ext4 file system

Change-Id: I6b539a549fe0016339558025807910c3946f1daf
Signed-off-by: Blagovest Kolenichev <bkolenichev@codeaurora.org>
2018-03-19 04:09:28 -07:00
Blagovest Kolenichev
f689e9e0a4 Revert "security: pfk: Error code was overwritten"
This reverts commit c23efa56f6.

This is temporary due to hard conflicts against android-4.9.84.

Intake is switched from android-4.9-o to android-4.9 with LSK
tag 4.9.84 and more time is needed to rework the FBE changeset
[1] according to the new upstream changes coming from
android-4.9.

[1] c23efa5 security: pfk: Error code was overwritten
    7b93926 Enable HW File Based Encryption on ext4 file system

Change-Id: Iadb627691de77c195eb8644b2e9329ed9b764d64
Signed-off-by: Blagovest Kolenichev <bkolenichev@codeaurora.org>
2018-03-19 03:41:27 -07:00
Neeraj Soni
c23efa56f6 security: pfk: Error code was overwritten
Invalidate scm calls overwrites set key call
error code in case set key call has failed.

Change-Id: I9c9d9026ab1f5c593f78fd0e592e2270aa28292c
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2018-02-08 16:22:55 +05:30
Neeraj Soni
7b939265f4 Enable HW File Based Encryption on ext4 file system
HW File Based Encryption (FBE) uses Crypto Engine to
encrypt the user data with unique key for each file.
File name and data both are encrypted with this feature.
1. security/pfk: New module to support per file
   encryption using CE.
2. fs/ext4: changes made to support using crypto engine
   to encyrpt the data.
Other changes made to provide support framework for per
file encryption.

Change-Id: I90d1a6df69ab30fd2476d9aad661e3ae1375e01d
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2017-11-15 16:31:27 +05:30