Commit Graph

195 Commits

Author SHA1 Message Date
Monika Singh 265e1a22ad ARM: dts: msm: Untrusted pointer dereference
To avoid access of variable after being freed, using
list_first_entry_safe function to iterate over list
of given type, safe against removal of list entry.

Change-Id: I70611fddf3e9b80b1affa3e5235be24eac0d0a58
Signed-off-by: Monika Singh <monising@codeaurora.org>
CVE-2018-11988
2020-07-11 12:50:34 +02:00
jitendrathakare 9b32c32588 qseecom : Clear client handle after unmap the resources
When unloading the app, reset all client members to NULL
to protect from accessing the memory after being freed.

Change-Id: I573b9c6fde03539522d2b04724a2246660c62518
Signed-off-by: jitendra thakare <jitendrathakare@codeaurora.org>
2020-07-11 12:28:35 +02:00
Joe Maples 353f0539b5 micro-optimization: Use DSTRLEN to remove incorrect strlen uses
strlen is often used incorectly to get the length of strings
defined at compile time. In these cases, the behavior can be
replicated with sizeof(X) - 1, which is calculated at compile
time rather than runtime, reducing overhead. I've created a
simple macro to replace these instances and applied it to all
the files compiled into the angler kernel.

Signed-off-by: Joe Maples <joe@frap129.org>
2019-08-26 13:31:43 +02:00
Brahmaji K 0cee9126ce qseecom: Fix accessing userspace memory in kernel space
Use put_user API to write the data from kernel space to
userspace to avoid accessing userspace memory directly
in kernel space.

Bug: 65468973
Change-Id: I7bdd702225ed179af841db9a67cc7b93eadf9dcc
Signed-off-by: Brahmaji K <bkomma@codeaurora.org>
2017-10-12 19:44:05 -07:00
Zhen Kong b4e0e95c3f qseecom: add mutex around qseecom_set_client_mem_param
Add mutex around qseecom_set_client_mem_param to prevent an
ioctl thread modifying and corrupting data which is being
processed by another ioctl in the other thread

Bug: 34327981
Change-Id: I0cfb8afab4001c2913be693dfe44c761b9568893
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2017-04-10 22:53:49 +00:00
Ecco Park 0c289272eb Merge branch 'android-msm-bullhead-3.10-nyc-mr1' into android-msm-bullhead-3.10-nyc-mr2
May 2017.1

Bug: 36138302
2017-03-15 20:21:31 -07:00
Zhen Kong 73738cfa0a qseecom: improve input validatation for qseecom_send_service_cmd
Make change to improve input validation on request and response
buffers' address and length for qseecom_send_service_cmd.

Bug: 35400457
Change-Id: I047e3264333d767541e43b7dadd1727232fd48ef
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2017-03-16 00:54:35 +00:00
Zhen Kong 017ebf1329 qseecom: check buffer size when loading firmware images
Make change in __qseecom_load_fw() and qseecom_load_commonlib_image()
to check buffer size before copying img to buffer.

CRs-fixed: 1080290
Bug: 35399405
Change-Id: I0f48666ac948a9571e249598ae7cc19df9036b1d
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2017-03-16 00:54:06 +00:00
Biswajit Paul b41c6bfa46 qseecom: whitelist support for kernel client and listener
Add whitelist support for listener to send modified resp to TZ;
also add whitelist support for kernel client; and change the method
to check whitelist feature.

Bug: 31268796
CRs-Fixed: 1021945
Change-Id: I0030b0008d6224cda3fdc1f80308a7e9bcfe4405
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Biswajit Paul <biswajitpaul@codeaurora.org>
2017-02-13 14:07:35 -08:00
Biswajit Paul aa0fca3f5d qseecom: Change whitelist_support flag to false if TZ failed to check
The whitelist status is set default as true though TZ failed to check,
which in turn causing the send_command fail by passing whitelist commnd id.
So updating the support status flag to false when TZ fails to check.

Bug: 31268796
CRs-Fixed: 1021945
Change-Id: I78a7600506b4d2457bb1c38f8a39888a9cf9467c
Signed-off-by: Mallikarjuna Reddy Amireddy <mamire@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Biswajit Paul <biswajitpaul@codeaurora.org>
2017-02-13 14:07:25 -08:00
Biswajit Paul 9776ffdfa1 qseecom: allocate sglistinfo buffer for kernel clients
To support whitelist feature, sglistinfo table should also
be allocated from qseecom kernel APIs used by kernel client.
Besides, initialize sg in __qseecom_update_cmd_buf_64 to
address a static analysis warning.

Bug: 31268796
CRs-Fixed: 1021945
Change-Id: I1f1967fd9e95444cca728f09e3e8f4914b2abb95
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Biswajit Paul <biswajitpaul@codeaurora.org>
2017-02-13 14:07:15 -08:00
Biswajit Paul 903dbbabd0 qseecom: support whitelist memory for qseecom_send_modfd_cmd
qseecom_send_modfd_cmd converts ION buffer's virtual address to
scatter gather(SG) list and then sends them to TA by populating
SG list into message buffer. As the physical memory address in
SG list is used directly by TA, this allows a malicious TA to
access/corrupt arbitrary physical memory and may lead to the
process gaining kernel/root privileges. Thus, make changes to
have the QSEEComm driver passing a list of whitelist buffers
that is allowed to be mapped by TA, and the QSEE kernel, in turn,
should add checks to the register_shared_buffer syscall to make
sure the shared buffers an application is mapping falls within
one of these whitelist buffers.

Bug: 31268796
CRs-fixed: 1021945
Change-Id: I776ead0030cad167afcf41ab985db7151a42d126
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Biswajit Paul <biswajitpaul@codeaurora.org>
2017-02-13 14:06:56 -08:00
Mallikarjuna Reddy Amireddy f7fdce7e4a qseecom: remove entry from qseecom_registered_app_list
In an error handling case, the QSEECOM_IOCTL_LOAD_APP_REQ ioctl
freed the entry for new TA, but didn't removed it from
qseecom_registered_app_list. Make change to remove it.

Bug: 31804432
Change-Id: Id681fbf3c923027d3db875d506cbe3f971919a8d
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Mallikarjuna Reddy Amireddy <mamire@codeaurora.org>
2016-12-07 07:42:32 +00:00
Roopesh Rajashekharaiah Nataraja da84eb7182 qseecom: Fix ion memory issue during unload app failure
qseecom still needs to free ion memory if unload app failed.
The previous xpu violation related to unload app failure is
actually due to race condition between send command, which
is fixed and now it is safe to free ion memory in error cases.

Change-Id: I7a09c753360eb015ece15c48ae1bb34e30479560

Bug: 31220655
Signed-off-by: Roopesh Rajashekharaiah Nataraja <roopeshr@codeaurora.org>
2016-09-26 18:31:22 +00:00
Roopesh Rajashekharaiah Nataraja 3ff44bb13f qseecom: don't release ion share memory if scm_call unload TA failed
If a scm_call request to shutdown a TA fails, the TA is not shut down
and still in use, and the resources aren't necessarily leaked. Since
shared memory are still locked in this situation, ion shared memory
cannot be released, otherwise XPU violation occurs. Only need to
release shared memory if TA is unloaded success or that TA cannot
be found.

Change-Id: I971485fb541193f77960cc7ca14b5b09de938a43

Bug: 31220655
Signed-off-by: Roopesh Rajashekharaiah Nataraja <roopeshr@codeaurora.org>
2016-09-26 18:31:12 +00:00
Roopesh Rajashekharaiah Nataraja 45255af9f1 qseecom: release ION memory if qseecom failed to unload app
To avoid memory leakage, make change to release ION memory if qseecom
failed to unload TZ app, which is allocated when starting app.

CRs-Fixed: 977073
Change-Id: Ic4c9a7d7a118ff5026ce6ce7769a4c053906ed2d

Bug: 31220655
Signed-off-by: Roopesh Rajashekharaiah Nataraja <roopeshr@codeaurora.org>
2016-09-26 18:30:55 +00:00
Mallikarjuna Reddy Amireddy d471b05f0d qseecom: 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.
So that %pK will not leak kernel pointers to unprivileged users.
So change the format specifier from %p to %pK.

Debugging Note : &pK prints only Zeros as address. if you need actual
address information, pls echo 0 to kptr_restrict.
$ echo 0 > /proc/sys/kernel/kptr_restrict

Bug: 31498159
Change-Id: I0baf2be2d5a476e2e4267f20b99d0ddf5492469e
Signed-off-by: Mallikarjuna Reddy Amireddy <mamire@codeaurora.org>
2016-09-16 18:03:30 +00:00
Biswajit Paul 770a5954c0 qseecom: validate the inputs of __qseecom_send_modfd_resp
The resp_len and resp_buf_ptr of qseecom_send_modfd_listener_resp
are not checked, then an userspace application that manipulates
resp_len can corrupt the kernel memory. Thus make changes to
validate these parameters.

Bug: 29157595
CRs-fixed: 1036418
Change-Id: Id43ec6b55b332d0dac09a9abb998a410f49b44f7
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Biswajit Paul <biswajitpaul@codeaurora.org>
2016-08-22 15:57:33 -07:00
Zhen Kong e1daf4900c qseecom: Do not try to load commonlib when loaded in lk
Remove the loading of commonlib when loaded by lk

Change-Id: Id8fcce391fc313fa6f2cbfa483358a0e73704895
Acked-by: Baranidharan Muthukumaran <bmuthuku@qti.qualcomm.com>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2015-06-19 15:54:00 -07:00
Zhen Kong bbdfd3aa53 qseecom: Register the existing app if it is loaded by appsbl
Register the app in qseecom driver if it has been already loaded
by appsbl before.

Change-Id: Iec39137a7e18dc703c731e55955ab84d1b9c97f3
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2015-06-09 16:40:55 -07:00
Zhen Kong 4d407ac367 qseecom: Change to work with appsbl qseecom
Do not send app regin notification if qseecom in appsbl has
already done it.

Change-Id: I81ae9a991a5d8ec582d9320e18be1b6f8e8ee7fd
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2015-06-09 16:40:53 -07:00
William Clark 0d8c855055 qseecom: Fix NULL pointer dereference
Application name passed from the user space might be NULL or
corrupted, which if accessed later on might end up in NULL
pointer dereference.

Change-Id: I3c91c19a60cee209436218dd9ea370ef53c8c8b6
Signed-off-by: William Clark <wclark@codeaurora.org>
2015-05-04 22:45:15 -07:00
William Clark 5b0943b884 qseecom: avoid buffer over-write when copying app_name
Change memcpy to strlcpy to only copy the string for app_name.

Change-Id: I46cf34c2d2fdbf24e9e65008555f762761c81dd7
Signed-off-by: William Clark <wclark@codeaurora.org>
2015-03-12 15:48:52 -07:00
Dinesh K Garg 124909553e qseecom: wipe_key failing
While wiping the keys from multiple crypto, it is wiping keys from
same crypto due to wrong loop variable. Fixed the issue by using
correct variable.

Change-Id: I8e7f9d3a773ff1809fe9b71d8e7bee75e789deca
Signed-off-by: Dinesh K Garg <dineshg@codeaurora.org>
2015-01-20 11:30:56 -08:00
Linux Build Service Account 9b973c484d Merge "qseecom: change sg_entry phy address to 32bit" 2015-01-07 19:38:11 -08:00
Zhen Kong 69d17c5abd qseecom: Save appname in qseecom when loading app by kernel client
We've made changes on app session managements to save app name in
qseecom when loading app by userspace client. This change is to save
app name when loading app by kernel client, then qseecom can compare
the app name correctly when sending commands to TZ.

CRs-Fixed: 748491
Change-Id: I341a1a89f0e8a45056be7a5ce0a6a540842bc5dd
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-12-23 10:41:48 -08:00
Linux Build Service Account e4d39e9edb Merge "qseecom: Update GP QTEEC related APIs" 2014-12-18 20:49:32 -08:00
Zhen Kong dbb151538e qseecom: change sg_entry phy address to 32bit
Change sg_entry phys address to 32bit, so that QSEECom will send
32bit phy address to TZ as 8994 TZ APP will be remained as 32bit.

Change-Id: I9e486c7ee36869ab818389d4b656c86cc6aeb899
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-12-17 17:01:51 -08:00
Mona Hossain 17c3151ed1 qseecom: Update GP QTEEC related APIs
Updated GP related code:
-Decouple GP related functionality from QSEE
-Add support for processing command in open session call
-Fix Invoke Command API to support contiguous memory only
-Add support for request cancellation command

Change-Id: I827e8fcdb09493266a21d3c4ae9456c2aa8457b3
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2014-12-08 09:15:00 -08:00
Dinesh K Garg df3e6052b6 qseecom: Adding support of ICE in Key Management System
Storage hardware can have embedded inline crypto engine(ICE). Current
key management system supports key storage mechanism for GPCE. ICE HW
requires a little differnt key management. Modifying exisiting KMS to
support ICE HW.

Change-Id: Ibcdbbffad71927c91ceb5d24939e0a80630ce466
Signed-off-by: Dinesh K Garg <dineshg@codeaurora.org>
2014-12-07 23:26:54 -08:00
Mona Hossain 64147b2da4 qseecom: Fix clk initialization
Add checks for clock_no_support flag check before
initializing/enabling/disabling CLK_CE_DRV related clk.

Change-Id: I099cc4e3d4716b42a2a9fbaa12b44a9de6f45f63
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2014-12-02 12:10:46 -08:00
Mona Hossain a953577dd8 qseecom: Add checks for send_cmd inputs
Improve user input validation across send cmd APIs. Add new
API  __validate_send_cmd_inputs() to validate all user provided
inputs.

Change-Id: Ibbb0c0e7e5483f653bd59b927562b63c1e43c365
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2014-11-06 12:14:10 -08:00
Mona Hossain dcde6b6e34 qseecom: Add boundary checks for offset within message
Qseecom driver does not have boundary checks for offset within the
message. So this patch add checks to validate the offsets sent by
client to modify data within the command request message and it
should not exceed the memory allocated for that message.

Change-Id: I29bfbdc154eebb4f3f4bfbb31789562e37fa5886
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: Mallikarjuna Reddy Amireddy <mamire@codeaurora.org>
2014-10-27 20:53:29 +05:30
Linux Build Service Account 299a626285 Merge "qseecom: Just check current bus scaling mode in qseecom_suspend" 2014-10-23 11:54:06 -07:00
Zhen Kong b77ae70ca4 qseecom: Just check current bus scaling mode in qseecom_suspend
In current qseecom_suspend function, qseecom will scale down bus
bandwidth if both of accumultive mode and current mode are not
INACTIVE. But if device goes into suspend before bus scaling timeout
happens, the accumulative mode may be zero but current mode is
still not INACTIVE. This may prevent the device going to suspend,
thus, make a change to just check current bus scaling mode in
qseecom_suspend.

CRs-Fixed: 740287
Change-Id: I60e90000aa9efe428b144fb766e19e81312af66f
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-10-16 11:00:10 -07:00
Linux Build Service Account 2e272c5bbd Merge "qseecom: Enable/disable clock for client if bus scaling is not enabled" 2014-10-14 03:48:55 -07:00
Linux Build Service Account 926f03e964 Merge "qseecom: Add new parameter to pass ce frequency" 2014-10-11 14:53:38 -07:00
Zhen Kong 369a4ace5e qseecom: Enable/disable clock for client if bus scaling is not enabled
To avoid the service failure on a target where bus scaling flag is not
enabled in target device tree file by mistake, make a change to enable/
disable crypto clocks when the client calls to scale up bus bandwidth
and send command even if bus scaling feature is not enabled.

CRs-Fixed: 726840
Change-Id: Ib33a535051b68561bde5ab6a23ad0f02dc27ab13
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-10-10 18:03:05 -07:00
Linux Build Service Account ed42648f00 Merge "qseecom: Check if ce clock is enabled before sending cmd to TZ" 2014-10-08 06:10:45 -07:00
Mallikarjuna Reddy Amireddy c5c19c1079 qseecom: Add new parameter to pass ce frequency
Crypto operating frequency varies from target to target. So platform
specific data needs to provide the value.

Change-Id: Iccb1f627d45bfd5a2d2996b34a38eda389252aeb
Signed-off-by: Mallikarjuna Reddy Amireddy <mamire@codeaurora.org>
2014-10-08 10:35:52 +05:30
Linux Build Service Account 970ab027fb Merge "qseecom: Free ion memory even if keymaster app is not unloaded" 2014-10-07 15:00:16 -07:00
Linux Build Service Account 52e8c17337 Merge "qseecom: Check response result if KMS related scm call returns failure" 2014-10-07 15:00:15 -07:00
Zhen Kong d1094572e1 qseecom: Free ion memory even if keymaster app is not unloaded
Make a change to free the ion memory allocated for keymaster client
even if keymaster app doesn't need to be unloaded from TZ, so as to
avoid memory leak.

CRs-Fixed: 724638
Change-Id: I3ddb68c8a3f96b0a44afc3efc63e93f0a8be51bb
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-10-06 16:37:51 -07:00
Zhen Kong 7cd0a8c569 qseecom: Check if ce clock is enabled before sending cmd to TZ
Make change to check if ce clock is enabled before sending command
to TZ, then to prevent data aborting if clock is not enabled for
TZ crypto operation.

CRs-Fixed: 726840
Change-Id: I55b5b10ad80e741c39f8cf411f67e6b83887f3bb
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-10-06 11:55:45 -07:00
Zhen Kong ab37cc73ef qseecom: Check response result if KMS related scm call returns failure
On the target supporting ARMv8 smc interface, the scm call will return
failure if scm parsing failed or the syscall response result is negative.
Then when qseecom calls __qseecom_generate_and_save_key on a device that
the key is already created, scm call will return failure directly as the
syscall response result value in this case is negative. Thus, generate key
failed and set key will not be called. So, we make changes to check syscall
response results for key management APIs even when scm call return failure.

CRs-Fixed: 723967
Change-Id: Ibade34dfc8ad90b25f2712ed0cc3faae91daab51
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-09-24 13:17:41 -07:00
Jon Ronen-Drori 9ebfe7b506 qseecom: ARMv8: support qseecom_save_partition_hash
Implementing the ARMv8 version of qseecom_save_partition_hash
by calling scm_call2 with the proper paramaters

Until this change, only the ARMv7 version was implemented
(by calling scm_call) and ARMv8 version was missing

Without this change, ioctl QSEECOM_IOCTL_SAVE_PARTITION_HASH_REQ
fails on ARMv8 platforms and only works on ARMv7

CRs-Fixed: 714330
Change-Id: I855ca847d62a0ffd8dc59207b7ea3a0ac6f79d99
Signed-off-by: Jon Ronen-Drori <jonr@codeaurora.org>
2014-09-23 06:24:32 -07:00
AnilKumar Chimata 20190307dd qseecom: Move checks to start of __qseecom_send_cmd()
data pointer validation is done after dereferencing it which might
throw an exception. This patch moves the data pointer validation
checks to starting of the function.

Change-Id: I12d201e53ad1d3098bf45c427553b048ca4d8ac0
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2014-09-17 16:22:01 -07:00
Linux Build Service Account 352a3a2494 Merge "qseecom: New cmd to support fuse writes" 2014-09-07 08:21:51 -07:00
Linux Build Service Account 5ad55e64d8 Merge "qseecom: improve secure app session management" 2014-08-31 08:25:24 -07:00
Gilad Avidov 54d008d5e9 qseecom: New cmd to support fuse writes
Add new command to support QFPROM writes. This operation
can no longer be performed from the Linux kernel.

Change-Id: Ifeb599b7019f8568ebbcfd7222f5c5ce11e9143b
Acked-by: Kaushik Sikdar <ksikdar@qti.qualcomm.com>
Signed-off-by: Gilad Avidov <gavidov@codeaurora.org>
2014-08-29 13:27:42 -06:00