Commit Graph

43 Commits

Author SHA1 Message Date
Swathi K
311dd76d74 msm: adsprpc: Handle UAF in fastrpc debugfs read
Use lock to protect maps among multiple
threads to avoid race condition.

Change-Id: Ib0c83dd38ea8e5acb54a1478d10b02385c27ba31
Signed-off-by: Swathi K <quic_c_kataka@quicinc.com>
2022-01-28 03:55:47 +05:30
qctecmdr
42eeb1a6e9 Merge "msm: adsprpc: Protect maps using map mutex" 2022-01-24 16:50:14 -08:00
qctecmdr
695194640c Merge "msm:adsprpc: Fix number of arguments to QAIC" 2022-01-22 13:06:31 -08:00
Anirudh Raghavendra
54fdcd32f2 msm:adsprpc: Fix number of arguments to QAIC
Fix number of parameters being sent to QAIC. Fixes unsignedPD
issue.

Change-Id: I846513c907c3c289c5f95ba3e9ca632f2a6bdbdf
Signed-off-by: Anirudh Raghavendra <quic_araghave@quicinc.com>
2022-01-19 17:52:00 -08:00
Swathi K
6b7777829e msm: adsprpc: Protect maps using map mutex
Protect maps using map mutex as well as avoid
deadlock during SSR in case of legacy targets.

Change-Id: Ia972302a8830d501c40d06df79e7eb305327c5ad
Signed-off-by: Swathi K <kataka@codeaurora.org>
2022-01-12 14:24:09 -08:00
Swathi K
6d105fbb3c msm: adsprpc: Handle NULL pointer dereference
Add NPTR check for file, context
and channel.

Change-Id: Iac193bb5b8ca0d7d663b12bae9cd41070b595e34
Signed-off-by: Swathi K <kataka@codeaurora.org>
2022-01-12 14:23:44 -08:00
Edgar Flores
bc037aaa54 msm: adsprpc: move message for max fastrpc sessions outside mutex
Move message for max fastrpc sessions outside channel mutex
to avoid holding mutex for a long period of time which can
cause kernel panic due to SSR holding same mutex.
Change message level to warning.

Change-Id: I354c15d2024d32774a729846f790f75082b4a0b5
Signed-off-by: Edgar Flores <edgarf@codeaurora.org>
2022-01-12 14:20:47 -08:00
Jeya R
2943785dda msm: adsprpc: Validate the channel in file free
Validation done for channel id before
dereferencing channel mutex.

Change-Id: I957f08f11f8aad188e215320c2b782de775afa02
Acked-by: Krishnaiah Tadakamalla <ktadakam@qti.qualcomm.com>
Signed-off-by: Jeya R <jeyr@codeaurora.org>
2022-01-12 14:20:36 -08:00
Swathi K
de480f2d42 msm: adsprpc: Handle UAF in process shell memory
To avoid UAF or double free of memory
add flag to know the memory is mapped
in process initialization. It skips
unmap if it is fastrpc shell memory.

Change-Id: Ifa621dee171b3d1f98b82302c847f4d767f3e736
Signed-off-by: Swathi K <kataka@codeaurora.org>
2022-01-12 14:20:25 -08:00
Edgar Flores
f5a64f3b10 msm: adsprpc: fix session create error logs
When creating new fastrpc session, add channel ID to debugfs
file name to avoid creating duplicate node.

Change-Id: Ic13a4045c4a01d6581967500a99a833090fcc5fc
Signed-off-by: Edgar Flores <edgarf@codeaurora.org>
Signed-off-by: Himateja Reddy <hmreddy@codeaurora.org>
2022-01-12 14:20:12 -08:00
Vamsi krishna Gattupalli
34a4798dd2 msm: adsprpc: Clean DMA handles maps in case of error
Free DMA handle fd maps in case of error while creating
map for other handles.

Change-Id: Iae062bc958a58f38e4424fab88b451813478ae97
Acked-by: Deepika Singh <dsi@qti.qualcomm.com>
Signed-off-by: Vamsi krishna Gattupalli <vgattupa@codeaurora.org>
2022-01-12 14:20:00 -08:00
Himateja Reddy
1267023e42 msm: adsprpc: Fix race during process teardown
Currently file_close is being set after cleaning up DSP process
session. There could be a chance where kernel client process might
make a invocation call while user client process is tearing down
the session. Set file_close before freeing up DSP process.

Change-Id: I9daa74d10974fa6f00adefc8dccfb59886040ed3
Signed-off-by: Himateja Reddy <hmreddy@codeaurora.org>
2022-01-12 14:19:51 -08:00
Jeya R
eb9c5df18b msm: adsprpc: Validate the map mutex
Validation done for map mutex before
releasing it.

Change-Id: I0f50d47f25ae9a5516c0e469a7f49b22130e0e07
Acked-by: Krishnaiah Tadakamalla <ktadakam@qti.qualcomm.com>
Signed-off-by: Jeya R <jeyr@codeaurora.org>
2022-01-12 14:19:43 -08:00
Jeya R
e42b48cdc8 msm: adsprpc: Validate fastrpc channel ID
Validation of fastRPC channel is done in the fastRPC
buf free.

Change-Id: Ie711ef2c2428dbf190fdfb720f2ce0ed14976878
Acked-by: Krishnaiah Tadakamalla <ktadakam@qti.qualcomm.com>
Signed-off-by: Jeya R <jeyr@codeaurora.org>
2022-01-12 11:35:12 -08:00
Jeya R
4a5f22eb2f msm: adsprpc: Validate fastrpc channel ID
Validation of fastRPC channel is done in the context
free, fix improper access of spinlock.

Change-Id: Ia5a439bbfb4953076349d60954436adc61aa68f2
Acked-by: Krishnaiah Tadakamalla <ktadakam@qti.qualcomm.com>
Signed-off-by: Jeya R <jeyr@codeaurora.org>
2022-01-12 11:33:34 -08:00
Vamsi krishna Gattupalli
7ae91ee5ee msm: adsprpc: Check validity of perf pointer
Check context perf pointer before dereferencing it.

Change-Id: I1c4a96361264e17691edba21a3f1e6bd23602e3b
Acked-by: Deepika Singh <dsi@qti.qualcomm.com>
Signed-off-by: Vamsi krishna Gattupalli <vgattupa@codeaurora.org>
2022-01-12 11:32:37 -08:00
vgattupa
75d6607eab msm: adsprpc: Check for valid error returned from mini dump
Add check to verify if valid error code is returned from mini
dump add region.

Change-Id: I02e2cfef22ce5f812104d7dc05dbb623c5c1670f
Signed-off-by: vgattupa <vgattupa@codeaurora.org>
Signed-off-by: Edgar Flores <edgarf@codeaurora.org>
2022-01-12 10:08:51 -08:00
qctecmdr
05004aae70 Merge "msm: adsprpc: Disable routing rpc messages to guest OS" 2022-01-11 22:03:21 -08:00
qctecmdr
216c33ed43 Merge "msm: adsprpc: Verify mini-dump region is added and removed" 2022-01-11 18:46:38 -08:00
Edgar Flores
3736c50394 msm: adsprpc: Disable routing rpc messages to guest OS
While querying fastrpc capabilities the pd type is being set to
1 (guest OS) to forward query to guest OS. This is causing all
subsequent rpc calls to go to guest OS. This is causing issues
for sensor PD daemon because rpc calls for daemon need to go
to sensor PD.

Unset pd type when querying for fastrpc capabilities.
PD type will remain the same as it was set when session started.

Change-Id: I215ec0795078a9dd352e70c87aa02cbd1a34ddb5
Signed-off-by: Edgar Flores <edgarf@codeaurora.org>
2022-01-11 14:49:58 -08:00
Vamsi Krishna Gattupalli
36dbc8fe88 msm: adsprpc: Non fatal error check for perf data copy
Add non-fata error check for perf data copy to
avoid warnings.

Change-Id: I701fd15a383399996714dc249be87ffbb0d453da
Acked-by: Deepika Singh <dsi@qti.qualcomm.com>
Signed-off-by: Vamsi Krishna Gattupalli <quic_vgattupa@quicinc.com>
2022-01-06 16:24:09 +05:30
Vamsi krishna Gattupalli
69b99db789 msm: adsprpc: Verify mini-dump region is added and removed
Verify mini dump region is added and removed for same region.

Change-Id: I416d9fe0fd35e9eae7a9048241cce58086a01da1
Signed-off-by: Vamsi krishna Gattupalli <vgattupa@codeaurora.org>
Signed-off-by: Edgar Flores <edgarf@codeaurora.org>
2021-12-22 11:06:03 -08:00
Edgar Flores
6753be2ad2 msm: adsprpc: Validate fastrpc channel ID for internal invocation
Validating fastrpc channel ID for fastrpc internal invocation
before using it to dereference channel array.
Create macro for channel ID  validation.

Change-Id: If06bc7d1c300e3296dd9be62f7177497e85ddf58
Signed-off-by: Edgar Flores <edgarf@codeaurora.org>
2021-12-22 10:57:41 -08:00
Edgar Flores
2fec09c73e msm: adsprpc: reduce dsp mapping error logs
Reduce dsp mapping error logs.
Return correct errno code from fastrpc_mmap_create
and fastrpc_mmap_remove.

Change-Id: I5140e73f65a42b6df461e6ffdbc8bc59d1a015db
Signed-off-by: Edgar Flores <edgarf@codeaurora.org>
2021-12-22 10:55:19 -08:00
Edgar Flores
33ba63bfbc msm: adsprpc: Validate fastrpc session ctx
Validate fastrpc session ctx before dereferencing since
it may be not be initialized when reading debug file.

Change-Id: I6eccf3c17ced9c0d3a2678bf39634f984302e3a8
Signed-off-by: Edgar Flores <edgarf@codeaurora.org>
2021-12-22 10:54:43 -08:00
Edgar Flores
74c86adb11 msm: adsprpc: Change PM default latency
Change PM QoS request and update default value from PM_QOS_DEFAULT_VALUE
to PM_QOS_RESUME_LATENCY_DEFAULT_VALUE to avoid warning message
from apply_constraint.

Change-Id: If6018ce2135793915195cb8a402be1627e6b696a
Signed-off-by: Edgar Flores <edgarf@codeaurora.org>
2021-12-22 10:54:24 -08:00
Anirudh Raghavendra
7d6ef6be02 msm: adsprpc: map memory for unsigned pd from userspace only
Signed PDs can allocate kernel memory and map to DSP.
Unsigned PDs can allocate memory from userspace only and map it
to DSP.

Change-Id: I26a6fdf6bbf3d71010caea54c7029584b09ae537
Signed-off-by: Edgar Flores <edgarf@codeaurora.org>
Signed-off-by: Anirudh Raghavendra <quic_araghave@quicinc.com>
2021-12-13 11:19:11 -08:00
Himateja Reddy
169d69505e msm: adsprpc: do not return error to rpmsg for duplicate responses
In case of fallback glink responses from remote subsystem, do not
return an error to rpmsg driver from the interrupt callback to
avoid flooding of kernel logs with false errors.

Change-Id: If593a4d5e4ccb949a93442e816de0a901231afd6
Acked-by: Thyagarajan Venkatanarayanan <venkatan@qti.qualcomm.com>
Signed-off-by: Himateja Reddy <hmreddy@codeaurora.org>
2021-12-13 11:18:58 -08:00
Himateja Reddy
c27d782142 msm: adsprpc: ignore rpmsg callback errors for duplicate responses
When an application is running in poll mode, the backup glink
response from the remote subsystem will usually arrive after the
RPC call is already completed by updating of shared memory buffer.
In such cases, do not print any error if that call's context has
already been reassigned to the next RPC call to avoid flooding of
the kernel logs.

Change-Id: I6f32ebd309f5ae2eadc287397e98c9b7cd4bde84
Acked-by: Thyagarajan Venkatanarayanan <venkatan@qti.qualcomm.com>
Signed-off-by: Himateja Reddy <hmreddy@codeaurora.org>
2021-12-13 11:18:37 -08:00
Himateja Reddy
9b4e97d6c7 msm: adsprpc: poll for specified timeout instead of constant value
Currently, polling for remote subsystem response is always being
done for a constant value of 4 ms. Instead, poll for specified
timeout value for different scenarios like early response and poll
mode.

Change-Id: Id28330cfa1e8fb7e853417329f6142100e9b8b2c
Acked-by: Thyagarajan Venkatanarayanan <venkatan@qti.qualcomm.com>
Signed-off-by: Himateja Reddy <hmreddy@codeaurora.org>
2021-12-08 17:22:46 -08:00
Jeya R
a5229705d8 msm: adsprpc: Handle out-of-bounds read in debugfs
Removed fixing the Title size which may not terminate
the NULL character end of Title. And, this would fix the
possible out-of-bounds read when reading debug-fs.

Change-Id: Ib3ff2b0106a25232c7a766baaaaca5bd9d306533
Acked-by: Krishnaiah Tadakamalla <ktadakam@qti.qualcomm.com>
Signed-off-by: Jeya R <jeyr@codeaurora.org>
2021-12-08 17:22:02 -08:00
Edgar Flores
dd1c8c03b9 msm: adsprpc: validate fastrpc channel when initializing remote process
When starting remote process, fastrpc channel is obtained from the
device file and channel ID is being used without validation to
dereference channel array. This could lead to array out of bounds
if channel ID is invalid.

Change is to validate channel ID before using it to dereference
channel array.

Change-Id: Id0a42938ff53e92ffc243f9e0f643153b856137f
Signed-off-by: Edgar Flores <edgarf@codeaurora.org>
2021-12-07 18:33:54 -08:00
Himateja Reddy
380c8c2b1c msm: adsprpc: Unlock map mutex in case of failure
Currently in case of failure mutex is not being released. Unlock the mutex
if there is any failure while the DMA buffer is being mapped on DSP.

Change-Id: I0e422b0ab115a891273055544e885ca5942882d1
Signed-off-by: Himateja Reddy <hmreddy@codeaurora.org>
2021-12-06 14:55:47 -08:00
Himateja Reddy
22805f3fe2 msm: adsprpc: add ftrace events for early response and poll mode
Add new ftrace events for early response and polling mode for the
breakdown tool to analyze.

Change-Id: Ife34e723c67e69a0675c2dc5ef92b0738a1dc6be
Acked-by: Thyagarajan Venkatanarayanan <venkatan@qti.qualcomm.com>
Signed-off-by: Himateja Reddy <hmreddy@codeaurora.org>
2021-11-30 15:34:11 -08:00
Himateja Reddy
f2a26052c6 msm: adsprpc: return correct value for pm qos request
PM qos apis can return 0 or 1 on success. Currently, this value is
being returned to userspace which results in a false failure if 1
is returned as userspace expects the ioctl call to return 0 on
success. Always return 0 on success.

Change-Id: I8f165657fb911c3f66829e638bf97c104bf70864
Acked-by: Thyagarajan Venkatanarayanan <venkatan@qti.qualcomm.com>
Signed-off-by: Himateja Reddy <hmreddy@codeaurora.org>
2021-10-18 09:16:25 -07:00
Anirudh Raghavendra
953f9b71fb msm: adsprpc: Add temporary stub for compat_alloc_userspace
The function compat_alloc_user_space has been removed from the Linux
kernel. Adding stubs to this function till a permanent solution
is found. Additionally, the bus remove function has been modified
in the Linux kernel to have a return type of void. Making appropriate
changes to accommodate these updates.

Change-Id: Id2ddc2198e0f6726c5db83181bb8b96c17bae896
Signed-off-by: Anirudh Raghavendra <araghave@codeaurora.org>
2021-10-13 15:09:04 -07:00
Anirudh Raghavendra
9a2a9264c1 msm: adsprpc: Cleanup minidump code
Remove deprecated functions from ramdump and cleaned up the code

Change-Id: Ia892ff006f833b12b49f94eb1e038dd6600837bd
Signed-off-by: Anirudh Raghavendra <araghave@codeaurora.org>
2021-09-29 10:06:36 -07:00
qctecmdr
cddaf91807 Merge "msm: ADSPRPC: Fix to avoid Use after free in create_dynamic_process" 2021-08-30 03:05:58 -07:00
vgattupa
4459518371 msm: ADSPRPC: Fix to avoid Use after free in create_dynamic_process
Allow single thread to execute fastrpc_init_create_dynamic_process
to avoid UAF scenario.

Change-Id: Id4ba1a406ace04d46482cd8b14c9d9ef5c96c4a1
Acked-by: Nishant Chaubey <chaubey@qti.qualcomm.com>
Signed-off-by: vgattupa <vgattupa@codeaurora.org>
2021-08-30 14:35:05 +05:30
qctecmdr
d0ec41e7f0 Merge "msm: adsprpc: Remove DMA_ATTR_EXEC_MAPPING usage" 2021-08-25 07:15:07 -07:00
Isaac J. Manjarres
be536d2037 msm: adsprpc: Remove DMA_ATTR_EXEC_MAPPING usage
DMA_ATTR_EXEC_MAPPING is used to convey that the memory that is being
DMA mapped should have executable permissions. However, memory that is
mapped through the DMA layer is mapped as executable by default, so
there is no reason to use this attribute. Remove it.

Change-Id: I1969a7a6df580c9cddb45ea2259367f5c1bf900f
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
2021-08-24 16:38:36 -07:00
Isaac J. Manjarres
3d24d40690 msm: adsprpc: Remove DMA_ATTR_SKIP_ZEROING usage
DMA_ATTR_SKIP_ZEROING has no impact on the behavior of
dma_alloc_attrs(), so remove its usage.

Change-Id: I701ba0017e70b33392087f8cf0c08e3549bed2d4
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
2021-08-24 16:32:00 -07:00
Anirudh Raghavendra
2de6f0417b msm: adsprpc: Add adsprpc driver files to new driver branch
Add Waipio fastrpc code to new target driver folder

Change-Id: I6ab871760011b0cb06c1c8408f9c8477867897c8
Signed-off-by: Anirudh Raghavendra <araghave@codeaurora.org>
2021-07-22 11:14:39 -07:00