Commit graph

21 commits

Author SHA1 Message Date
Neeraj Soni
a3b28d68a2 security: pfe: Return proper error code
ICE clock funciton masks the error code from
scm call. This might introduce unwanted issues
in device. Ensure to return proper error code
to storage frameworks.

Change-Id: Ibd7358c3b19d23d5995cf267f56ef3bacf166569
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2017-11-08 16:49:51 +05:30
Neeraj Soni
2b364203d6 security: pfe: Synchronize the file key usage
Reference count is maintained to track the usage
of file key. This is required to avoid invalidate
operation while a file key is in active usage.

Change-Id: I8f6f562ec9a006e585503413c2196685535a5098
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2017-07-18 16:33:31 +05:30
Stephen Boyd
670225d620 security: pfe: Remove __exit annotation to fix section mismatch
pfk_ext4_deinit() is called from init code and we throw away
__exit marked code when modules are built-in. Remove the __exit
markings here so that we can always call this function even from
__init code. Similarly for pfk_ecryptfs_deinit().

Change-Id: I80a3304d84cdf18772879efe6c4a955d873b89c4
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
2017-04-04 16:25:57 -07:00
Neeraj Soni
77eeced18f security: pfe: Adapt ICE engine setup call for eMMC
Ice setup operation will work indpendent of storage
type. Command line parameters will be read to find out
storage type before doing ICE HW Configuration.

Change-Id: I90a520f6d80e92505464fcde04980d858b34b455
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2017-03-20 17:01:21 +05:30
Andrey Markovytch
a1cd6239e4 ice: fix issue with losing ICE key configuration during reset
TZ is called to restore key configuration in case of UFS reset

Change-Id: Id434e7f9ec6befdce97f52fd350957b66adcb15f
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2017-02-08 04:35:20 -08:00
Linux Build Service Account
9335a12bb0 Merge "ufs: fixed bugs in ice related to key syncronization" 2017-01-22 01:16:27 -08:00
Andrey Markovytch
d751a8d90f ufs: fixed bugs in ice related to key syncronization
1. Added reference count for requests in HW queue for particular key
2. Fixed race between block/unblock requests with asynchronous job
for key configuration in ice

Change-Id: Iaefc25739b420b2e5feae1895c7c2495b4850539
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2017-01-19 19:53:03 +02:00
Andrey Markovytch
3eab9b61f3 security: switched to stackable model for PFT/PFK module
Moved hooks from SELINUX framework to general SECURITY framework.

Change-Id: I37e701b4925c4993f724c32b258c5088f4dcbe4d
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2017-01-09 11:23:03 +02:00
Andrey Markovytch
a8059e6d39 ext4 crypto: enable HW based encryption with ICE
Numerous changes were introduced to various layers:
Block: removed dependency on selinux module for decision on bio merge
EXT4: Added feature controlled support for HW encryption
PFK: Major re-factoring, separation to eCryptfs and EXT4 sub-layers

Change-Id: I9256c8736e1c16175fe3f94733dda430ccc57980
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2016-09-15 00:36:43 -07:00
Srinivas Ramana
5b07573627 security: pfe: Fix the qualifier used to print size_t
Use the correct type qualifier to print size_t
and ssize_t. This will fix the compilation errors when
compiling for ARM. While at it, fix the compilation errors
in pfk_kc.c for sched functions by including sched.h.

Change-Id: I4fac4530dd4b31baf62ef3719535fd662dc2ae37
Signed-off-by: Srinivas Ramana <sramana@codeaurora.org>
2016-06-22 14:42:18 -07:00
Andrey Markovytch
14bc610d32 pfk: fixed crash that occurred because of bio's without data
bio's without data are not relevant, bio_had_data checks this,
replaced redundant checks to call to this function.
Also, additional clean ups performed

Change-Id: I315bcf43cf3d32e78d53b818571da1f5175f8ac3
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2016-06-21 15:15:47 -07:00
Andrey Markovytch
110aebe867 scsi: ufs: ICE 3.0 changes
ICE 3.0 crypto sequences were changed, CTRL_INFO register
no longer exists and doesn't need to be configured. The configuration
is done via utrd.

Change-Id: I5d69436ec59476fc5cd427458d79f8c99266f243
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2016-06-09 15:12:13 -07:00
Andrey Markovytch
ab2b3d7aba PFK: ice: change to non-atomic scm calls
These scm calls may take a long time to complete on TZ side,
switch to non-atomic calls.

Change-Id: If98ef69e2474f1c50670c2605afe9769a4e0fb39
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2016-05-03 15:48:01 -07:00
Andrey Markovytch
e29851c910 PFK: fix race between key set and key invalidate in TZ
When working with multiple files and multiple threads, the following
scenario can occur:
1. File Close -> Key cache removal -> context switch
2. Open new file -> occupy the entry cleaned in 1
   -> TZ_ES_SET_ICE_KEY -> context switch
3. Back to 1 -> TZ_ES_INVALIDATE_ICE_KEY
4. Back to 2 -> ICE uses the key that is already invalid
5. Crash due to PARTIALLY_SET_KEY_USED

To fix this, pfk must know when requests using some key are completed.
Only then key removal shall be allowed and until then key invalidation
must wait.
A new callback was added to let clients inform PFK when requests end.

Change-Id: Id7f8a3302fac9fafd1203d8d56ca13d59b45bbd5
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2016-04-25 17:45:36 -07:00
Gilad Broner
f50a4a1dc7 eCryptfs: fixed bug in cipher handling
Cipher was sometimes not treated properly, causing valid
requests belonging to eCryptfs to be treated as regular.

Change-Id: Iabfb93cc4c9e9e167901043482eb99613ed70343
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-25 16:04:06 -07:00
Andrey Markovytch
aaf495b3ab pfk: added some additional debug prints
Also added useful function for translation between inode to filename

Change-Id: If0d5db3545a71c85223ef53980ee61f9dbd002d9
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2016-03-23 21:24:10 -07:00
Andrey Markovytch
5c84da193d pfk: fixed bug that caused eCryptfs ignore some of its files
Our logic that distinguished eCryptfs files from non eCryptfs ones
checked bi_vcnt field in bio to make sure it has valid bio vecs.
Apparently this field is not updated in some cases by block layer
and in general can't be trusted outside of code that own bio.
There is another field that need to be used for this purpose - bi_size

Change-Id: Ibf225543618373699a0d5adc3295daf9ded6169a
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2016-03-23 21:24:09 -07:00
Andrey Markovytch
f707680de8 PFK: fixed bug where key was cleared without turning on clocks first
ICE clocks need to be turned on to clear the key, fixed

Change-Id: I1cd5a10899c2f128b138fe380beb34a5a310fa05
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2016-03-23 21:24:08 -07:00
Andrey Markovytch
8928f8683b PFK: fixed issue where key in TZ was not set properly
When key is set in ICE via TZ, HLOS should send two parts, SALT and
the KEY itself according to AES standards. KEY was used for both parts.

Change-Id: I453dea289b01bdf49352d5209255966052f5dc1b
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2016-03-23 21:24:07 -07:00
Andrey Markovytch
584531e72e PFK: new module to work with ecryptfs
PFK is a new module that accompanies eCryptfs and
enables it to utilize ICE hw encryption engine. Module
is responsible for storing encryption/decryption keys
inside eCryptfs inodes for each file and loading them
to ICE

Change-Id: I6e755ca657164919147fe0d9482477e14a4be5eb
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflicts, adapted LSM hooks
and added missing qseecom headers to fix compilation]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-23 21:24:06 -07:00
Andrey Markovytch
eaf3acf0d2 PFT: moved to a new directory
QCOM security components were moved to security folder inside
kernel which is more appropriate

Change-Id: I4e450a23583ceac929a3980b1b5998f4e0c7cfa9
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
[gbroner@codeaurora.org: fix merge conflicts and updated ARCH_QCOM]
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-03-23 21:24:04 -07:00