16 Commits

Author SHA1 Message Date
Neeraj Soni
1924eafba6 Remove Per File Key based hardware crypto framework
Remove the Per File Key logic based inline crypto support
for file encryption framework.

Change-Id: I90071562ba5c41b9db470363edac35c9fe5e4efa
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2020-08-18 04:50:20 -07:00
Shay
9a9deef71b pfk: Fixed ICE slot number for bare metal
Set the number of available ICE slots to 30, as the
first two are occupied by FDE.

Change-Id: I24b0e6efa5195697d120430f709c9465e8514f19
Signed-off-by: Shay <shayn@codeaurora.org>
2020-03-11 09:39:25 +02:00
Shay
8416f71c41 pfk: Added support for virtualized ICE
Added pfk_ice_virt.c which sends hab requests to BE in host,
instead of sending scm calls directly to TZ.
Also, removed the hardcoded size of key cache table,
and made it configurable.

Change-Id: I942c3886c2fb93846bcdf15b19eabb3bc83e05ba
Signed-off-by: Shay <shayn@codeaurora.org>
2019-12-02 13:50:58 -08:00
Sahitya Tummala
ce25ea95b8 pfk: use cached mapping at all places in pfk_bio_get_inode()
The page->mapping will be set to NULL when it is truncated.
The same metadata page if it is currently under processing by
ext4/jbd2, then it is possible for pfk_bio_get_inode() to see
inconsistent page->mapping, for the requests submitted by jbd2
on this page. To avoid this inconsistency, use cached mapping at
all places in pfk_bio_get_inode(). It doesn't matter whether the
pfk driver sees the mapping or sees null mapping for metadata
requests because, pfk_allow_merge_bio() will always return true
for 2 journal metadata requests and  for one journal and one
non-journal request, it always returns false (independent of
the metadata page mapping state).

Change-Id: Ia452f972346e1ba3b25560ffa140d023dbb3409d
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2019-10-22 08:41:02 +05:30
Neeraj Soni
104d99ba6d 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-11-14 05:07:28 -08:00
Shivaprasad Hongal
4884d5cd6c pfk: clean up code to remove keymaster calls
Remove code related to keymaster calls for setting
ICE as we now wrap/unwrap FBE keys in trustzone
kernel rather than keymaster.

Change-Id: Ib1812de84e6d1a380f87f93fd0f414b4ea24e03a
Signed-off-by: Shivaprasad Hongal <shongal@codeaurora.org>
2018-11-08 10:02:53 -08:00
Shivaprasad Hongal
686016dc17 pfk: add changes for clear key support
Add support for clearing FBE key and all it's
corresponding data from kernel, trustzone and ICE
when a user is locked or deleted.

Change-Id: I0c1afc1a7fcf2e76cd8e268fea31e68d2efe0130
Signed-off-by: Shivaprasad Hongal <shongal@codeaurora.org>
2018-10-30 11:01:12 -07:00
Neeraj Soni
c35ee75968 security: pfe: Set DUN size according 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: I2de18ddd8908ce63b6d54b34b21d750d79f49cc2
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
Signed-off-by: Shivaprasad Hongal <shongal@codeaurora.org>
2018-10-10 11:22:03 -07:00
qctecmdr Service
942ab60077 Merge "security: pfk: use page_mapping to avoid wrong memory access" 2018-10-03 17:44:17 -07:00
Jaegeuk Kim
243b3d4fea 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-09-26 00:11:31 -07:00
Shivaprasad Hongal
97e4a55cf0 pfk_ice: Check km version before ICE calls
Check the keymaster version to decide where the wrapped
keys are unwrapped.

Change-Id: Id91bfd33d9719d99de5e5cf39938bc148de7da5c
Signed-off-by: Shivaprasad Hongal <shongal@codeaurora.org>
2018-09-25 08:32:50 -07:00
Jaegeuk Kim
af4ef71b89 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 bug 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))

Bug: 68721442
Change-Id: Icefe85f608b7c3c84beb2bfa4267efd0f3787453
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Signed-off-by: Shivaprasad Hongal <shongal@codeaurora.org>
2018-08-24 10:36:55 -07:00
Shivaprasad Hongal
367c46b11c Enable hardware based FBE on f2fs and adapt ext4 fs
Hardware File Based Encryption (FBE) uses inline crypto
engine to encrypt the user data.
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.
5. security/pfe: added wrapped key support based on
   upstream changes.
Other changes made to provide support framework for per
file encryption.

Reverting commit e02a4e21f640 ("ext4: Add HW File Based
Encryption on ext4 file system") and adding changes to
have FBE in sync with upstream implementation of FBE.

Change-Id: I17f9909c43ba744eb874f6d237745fbf88a2b848
Signed-off-by: Shivaprasad Hongal <shongal@codeaurora.org>
2018-08-22 10:56:07 -07:00
Shivaprasad Hongal
2129ce57d7 Revert "pfk: keymaster support to set/clear ice keys"
This reverts commit cd1be5fac519d6089289e513deb3b50ae3df9637.

Reverting to have FBE in sync with upstream implementation.

Change-Id: I21d84211c0469d1a4b3d8685033a64cc04854109
Signed-off-by: Shivaprasad Hongal <shongal@codeaurora.org>
2018-08-22 10:56:07 -07:00
Shivaprasad Hongal
cd1be5fac5 pfk: keymaster support to set/clear ice keys
With new FBE key management changes, the keys are not
available in the clear, but wrapped with an ephemeral key
from keymaster. We cannot use a direct call to the qsee
kernel to set/clear keys as they need to be unwrapped by
keymaster first, which would then call in to the qsee kernel
to set/clear the keys.

Change-Id: Ie3fba8c0613d246efb5577ef6a0254171f082bfe
Signed-off-by: Shivaprasad Hongal <shongal@codeaurora.org>
2018-08-09 13:28:50 -07:00
Dinesh K Garg
e02a4e21f6 ext4: Add 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: Idea3f6f8bf954c60c3c6caa3d9b048d87fcacbe4
Signed-off-by: Dinesh K Garg <dineshg@codeaurora.org>
2018-06-11 23:09:54 -07:00