Commit graph

68 commits

Author SHA1 Message Date
codeworkx
15f81a19b5 Merge tag 'LA.UM.7.4.r1-05300-8x98.0' into lineage-16.0
"LA.UM.7.4.r1-05300-8x98.0"

Change-Id: I8e27939efccb7d0bda0ac7c4e32afdf3c6d62507
2019-06-16 08:15:21 +02:00
Neeraj Soni
07c5f7c8c9 msm: ice: check for crypto engine availability
There can be many ice instances present in dtsi file but
not all of them will be initialized by storage driver.
Check if crypto instance is initialized before setting
it up for data encryption/decryption usage.

Change-Id: I7c9227007474052513b277dec5963a973781c524
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2019-04-08 12:15:48 -07:00
codeworkx
6861312cbe Merge tag 'LA.UM.7.4.r1-04700-8x98.0' into auto
"LA.UM.7.4.r1-04700-8x98.0"

Change-Id: I777ab5e199fb463581fbfaf4750c8358d6f9e56f
2019-03-10 16:59:28 +01:00
liochen
8148b9d900 Synchronize codes for OnePlus5 & 5T OxygenOS 9.0.0
kernel device tree source code for OnePlus 5 & 5T P device

Change-Id: I84f40e66833ea1ce30eb1d9a710d6e1529e9e637
2018-12-26 11:02:39 +08:00
Monika Singh
9432c10726 ARM: dts: msm: Remove Out-of-Bound access
Remove the out of bound access vulnerability in the qce
driver reachable via ioctl.

Change-Id: I4320cd27334eaae975f4a6ad07fb7b2e5ebccffd
Signed-off-by: Monika Singh <monising@codeaurora.org>
2018-12-05 13:25:49 +05:30
Ramandeep Trehan
6523651f7d wqcrypto: qcedev: Add null pointer check on sg_src
Add a null pointer check on sg_src to avoid a possible
null pointer dereference in qcedev driver.

Change-Id: I9d4f9147ae6c340064110381c98d064f29fd9444
Signed-off-by: Ramandeep Trehan <rtrehan@codeaurora.org>
2018-09-21 16:11:40 +05:30
Parai Wang
7fcca62cb3 crypto: msm: reset pointer before returning from the function
Reset cipher_req.creq.dst and cipher_req.creq.src pointer to NULL
before returning from the function, and initialize scatterlist
variable before using it.

Change-Id: I5d5eee06a5213a05b20bf459ef0bf0c433fadbdd
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Parai Wang <fpwang@codeaurora.org>
2018-03-27 01:10:29 -07:00
Zhen Kong
4062e30ed3 crypto: msm: fix authdata copy issue in qcedev_sha_req_cb
qcedev_sha_req_cb() is only called by _sha_complete() during sha
operation, and will copy byte_count value from authdata array.
This array size is two, and only contains two byte_count value
that are used for sha operation. So make change to only copy the
first two elements from this array.

Change-Id: I535f2ec0e358870a9a2163b3c0bf154b2c8d003f
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2017-10-13 10:07:58 -07:00
Neeraj Soni
71a440a0c8 crypto: ice: Sanitize the ice device return address.
Even if ICE device is not found it is possible
for list device API to return non NULL pointer
which will pass all NULL checks in code. Ensure
to return proper address or NULL.

Change-Id: I1465614b86f1415376b2adffeec6e4da1a33ddd5
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2017-10-03 12:17:37 +05:30
Linux Build Service Account
c19a0c49cb Merge "crypto: msm: Fix several race condition issues in crypto drivers" 2017-08-03 20:50:58 -07:00
Linux Build Service Account
a9009e8dd5 Merge "qcom: scm: update function return value and input parameter type" 2017-08-03 10:07:53 -07:00
Linux Build Service Account
e85a3cbb06 Merge "crypto: ice: Remove redundant checks" 2017-07-22 04:08:02 -07:00
Neeraj Soni
c1ab2e8a1a crypto: ice: Remove redundant checks
Check is implemented in required function as part of
new implementation.

Change-Id: I346cd27cb254abe7d9706f01a9b463750614245e
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2017-07-21 19:19:53 +05:30
Brahmaji K
34331528b0 crypto: msm: Fix several race condition issues in crypto drivers
Check areq before referencing, replace xchg to automic_xchg and
verify return values of set key during SHA operations.

Change-Id: Ife01372ba4990bfefe52b82db4ab33ef76190944
Signed-off-by: Brahmaji K <bkomma@codeaurora.org>
2017-07-20 04:44:26 -07:00
Mohammed Khajapasha
18ae33111d qcom: scm: update function return value and input parameter type
Update the function return value and input scm_ret variable
type for restore secure configuration in scm_restore_sec_cfg() fn.
Adding scm_ret input variable for scm_get_feat_version() fn.  

Change-Id: Ideef914ded8dfdb4c780fd27d7273986eeb41f5c
Signed-off-by: Mohammed Khajapasha <mkhaja@codeaurora.org>
2017-07-19 14:22:44 +05:30
Linux Build Service Account
0c44f3c838 Merge "crypto: Change format specifier %p to %pK" 2017-07-06 12:32:05 -07:00
Linux Build Service Account
0f6cf457b2 Merge "compat_qcedev: Fix accessing userspace memory in kernel space" 2017-07-05 10:28:43 -07:00
Linux Build Service Account
40f83efeab Merge "scsi: ufs: Unblock UFS while ICE HW configuration" 2017-06-29 11:34:46 -07:00
mohamed sunfeer
2ec173df69 crypto: Change format specifier %p to %pK
Format specifier %p can leak kernel addresses while not valuing the
kptr_restrict system settings. When kptr_restrict is set to (1), kernel
pointers printed using the %pK format specifier will be replaced with 0's

Change-Id: Iff8d82b12e958b938fc767bf3e8c3a3c8fc65c2a
Signed-off-by: mohamed sunfeer <msunfeer@codeaurora.org>
2017-06-29 15:13:34 +05:30
mohamed sunfeer
34d8f74832 compat_qcedev: Fix accessing userspace memory in kernel space
Use put_user API to write the data to userspace from kernel
space to avoid accessing userspace memory directly in
kernel space.

Change-Id: I4dd73872ab8c374793268cef2b9a2dfccf3454c9
Signed-off-by: mohamed sunfeer <msunfeer@codeaurora.org>
2017-06-21 23:47:06 -07:00
Neeraj Soni
2e4bedb43c scsi: ufs: Unblock UFS while ICE HW configuration
Blocking UFS requests while ICE HW is getting
configured is not required as block layer requeues
the requests anyway.

Change-Id: I5aacf772c93eb134a3e48c79b3fbdaefd8378581
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2017-06-20 18:06:19 +05:30
Zhen Kong
0ddb3d1fcf crypto: msm: fix rfc4309(ccm(aes)) issue on msm-4.4
In newer kernel (msm-4.4 or later), for AEAD ciphering, crypto api has
been re-worked and the assoclen defines the length of association data
and iv together. But for rfc4309(ccm(aes)), iv is not part of AAD.
Therefore, change qcrypto driver to remove the iv, by subtract 8 from
assoclen for rfc4309(ccm(aes)).

Change-Id: I37eb1934d7817b5b5c33440122b68e5d37854960
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2017-06-13 11:37:43 -07:00
Brahmaji K
df7052e30b qcdev: Check the digest length during the SHA operations
Check the digest length to avoid buffer overflow while
doing the SHA operations.

Change-Id: I4d3fb20723f59e905a672edaf84ee5d0865905b1
Signed-off-by: Brahmaji K <bkomma@codeaurora.org>
2017-05-16 03:02:33 -07:00
Brahmaji K
0ef4f1a1b8 ota_crypto: Add NULL pointer check for new_req variable
Add NULL pointer check before accessing the new_req
variable.

Change-Id: I8460115ccb16a2c43c45394275e9519ed3c6b045
Signed-off-by: Brahmaji K <bkomma@codeaurora.org>
2017-05-11 12:22:43 +05:30
AnilKumar Chimata
17b7ffbc13 crypto: msm: Fix buffer overflow issue
In multi-threaded environment diglen variable could be modified
by multiple threads at the same time. Buffer overflow might
happen in current thread if another thread changes the diglen
variable. So add mutex locks to avoid this issue.

Change-Id: I62c63c55c028dedb1dd0eec862851bd8e818a5d3
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2017-04-08 03:54:02 +05:30
Neeraj Soni
adc03ee05b crypto: msm: Use appropriate logging function
Dynamic debug can be used to get the logs

Change-Id: I6510da111019022149190fd753a5da1cc816fffa
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2017-04-05 11:57:57 +05:30
Zhen Kong
2bcc512e4f crypto: msm: check invalid src and dst vbuf in qcedev.c
src and dst vbuf address and length are provided from userspace,
and they are invalid if vbuf address is NULL but length is not zero.
Add additional checks in qcedev_check_cipher_params to prevent it.

Change-Id: Iadc1a0c1c5b2f7a56acd03a23c08e45b5a671b19
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2017-02-25 01:15:22 -08:00
AnilKumar Chimata
fee158d588 ice: Sent proper storage type for ICE configuration during reset
Read instance type from device tree node to know the storage type
for ICE configuration, which is used to program the corresponding
ICE register during ICE reset.

Change-Id: I0eb423fb84dc89115227abc7c5688df7ae9a4a3c
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2017-02-14 20:50:16 +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
b1615eab2b Merge "qcrypto: protect potential integer overflow." 2017-02-03 22:59:39 -08:00
Linux Build Service Account
e3a533c911 Merge "crypto: msm: check length before copying to buf in _debug_stats_read" 2017-02-02 21:33:13 -08:00
Brahmaji K
fb77e96735 crypto: ice: Fix NULL pointer exception in ice.
While enabling ICE setup and on error conditions, the regulator
is disabled. Before disabling the regulator, check if the
regulator is up and able to access the registers of regulator.

Change-Id: I94dd2b3e25444818f7bdf2f791f4fa9efaefce15
Signed-off-by: Brahmaji K <bkomma@codeaurora.org>
2017-02-02 12:56:34 +05:30
Zhen Kong
08a969c0e4 crypto: msm: check length before copying to buf in _debug_stats_read
Make sure that `len` is not larger than `count` before copying data
to userspace `buf` in _debug_stats_read().

Change-Id: Iafb7cfa3828653f8c28183c812797c3d9a183da1
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2017-02-01 15:08:22 -08:00
Zhen Kong
34e32863a1 qcrypto: protect potential integer overflow.
Adding user passed parameters without check might
lead to Integer overflow and unpredictable system
behaviour.

Change-Id: Iaf8259e3c4a157e1790f1447b1b62a646988b7c4
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2017-01-25 10:29:50 -08:00
Linux Build Service Account
314869eb56 Merge "crypto: msm: check integer overflow on total data len in qcedev.c" 2017-01-23 12:54:11 -08:00
Zhen Kong
29ba268e0e crypto: msm: check integer overflow on total data len in qcedev.c
qcedev_vbuf_ablk_cipher will calculate total data length. It starts
with the value of "areq->cipher_op_req.byteoffset", which is controlled
by the user. Make change to check if this total data length has integer
overflow issue in qcedev_check_cipher_params.

Change-Id: Ice42dca6d47eb8febfe8a34e566c69e4799fab57
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2017-01-19 15:17:39 -08:00
Zhen Kong
92200ab455 crypto: msm: remove extraneous parentheses in qcedev.c
remove extraneous parentheses around the comparison to resolve
static analysis warning.

Change-Id: I67c755f028a8bf27e0b924cd636a1cce27e149fc
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2017-01-19 12:27:43 -08:00
Andrey Markovytch
ebd74eee2d ice: fix security issue with validating error in pointer
get_ice_device_from_storage_type can return error pointer which is
not NULL in case of error, this was not checked, changes fixes this.

Change-Id: I7dd8a068454a7bd250189ff9467c685af449f81b
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2016-12-25 23:06:12 -08:00
Linux Build Service Account
87ffee40c5 Merge "msm: crypto: fix AEAD issues for HW crypto driver on msm-4.4" 2016-12-23 03:55:03 -08:00
Zhen Kong
654eb19d41 msm: crypto: fix AEAD issues for HW crypto driver on msm-4.4
Make change to fix AEAD operation issues due to incorrect usage of
new aead interface introduced into kernel msm-4.4.

Change-Id: I472449c52bff40d48f7d65b05e145cc47cba9357
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2016-12-21 15:14:52 -08:00
Linux Build Service Account
0f596458d4 Merge "msm: crypto: set CLR_CNTXT bit for crypto operations" 2016-11-30 05:40:56 -08:00
Linux Build Service Account
4df93480e8 Merge "msm: crypto: fix issues on digest buf and copy_from_user in qcedev.c" 2016-11-25 17:46:58 -08:00
Zhen Kong
ccd2741348 msm: crypto: fix issues on digest buf and copy_from_user in qcedev.c
Make the digest length not larger than the size of the buffer
qcedev_areq.sha_op_req.digest; and use the checked variants of
the copy_from/to_user() APIs to avoid small race window of their
unchecked variants.

Change-Id: I3db0c20ac5fa47ed278f3d60368c406f472430c1
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2016-11-14 15:26:52 -08:00
Zhen Kong
64551bccab msm: crypto: set CLR_CNTXT bit for crypto operations
HLOS Crypto driver needs to set CLR_CNTXT bit for operations with
legacy software key registers

Change-Id: Iff482f726d106e99a4006f7077a171da3c7ca9c3
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2016-11-14 13:50:08 -08:00
Yasir Malik
8ae62993fc crypto: msm: qce50: Prevent deadlock during timeout
Lock out interrupts during issuing dummy request in timeout to prevent from
a potential deadlock happening.

Change-Id: I986d8c36c839a1dee23761465ad331ffc31dd6ac
CRs-Fixed: 1008319
Acked-by: Che-Min Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Yasir Malik <ymalik@codeaurora.org>
2016-11-09 09:43:31 -08:00
AnilKumar Chimata
45da966c60 qcedev: Validate Source and Destination addresses
Source and Destination addresses passed by user space apps/clients
are validated independent of type of operation to mitigate kernel
address space exploitation.

Change-Id: I9ecb0103d7a73eedb2e0d1db1d5613b18dd77e59
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2016-11-04 11:35:15 +05:30
Zhen Kong
492459ec60 msm: crypto: Fix integer over flow check in qce driver
Integer overflow check is invalid when ULONG_MAX is used,
as ULONG_MAX has typeof 'unsigned long', while areq->assoclen,
q_req->crytlen, and qreq.ivsize are 'unsigned int'. Make change
to use UINT_MAX instead of ULONG_MAX.

Change-Id: If2bb1900c07af1ea162da362c913d4880b0bc755
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2016-10-27 12:14:09 -07:00
Sivanesan Rajapupathi
61ef7e42ca crypto: msm: qce50: DMA-API buffers limitations
Not all memory are DMA'able. See DMA-API-HOWTO.txt. The dummy hash
request input buffer is changed to be acquired from coherent memory
to kzalloc().

Change-Id: If6961217df08bcf0506eedacb07874dfafd7c1ca
CRs-Fixed: 1064055
Acked-by: Che-Min Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Sivanesan Rajapupathi <srajap@codeaurora.org>
2016-09-14 10:50:12 -07:00
Sivanesan Rajapupathi
653339dbcd crypto: msm: qce50: allocate iovec out of cacheable memory
iovec memory for each pipe is only accessed by crypto and BAM drivers from
the CPU. It won't be accessed by crypto device. Change allocation of iovec
from coherent memory space to kernel memory space to improve performance.

Change-Id: I97162c00c37716be8b9a20393f67bda8da41e99d
Acked-by: Che-Min Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Sivanesan Rajapupathi <srajap@codeaurora.org>
2016-09-12 16:12:52 -07:00
Andrey Markovytch
32d2461585 ice: added missing register dump in case of error for ICE 3.0
QCOM_ICE_INVALID_CCFG_ERR_STTS is now also dumped in case of error
for ICE 3.0

Change-Id: Ib7f522d0143f5131880c8c1badf4e64461810e72
Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
2016-08-11 03:13:58 -07:00