Uh oh!
There was an error while loading. Please reload this page.
Ro volatile byte kcontrol - #2368
Conversation
0b5c5b7 to
63e526dCompare
bardliao
left a comment
There was a problem hiding this comment.
Some comments based on SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE = (SNDRV_CTL_ELEM_ACCESS_TLV_READ|SNDRV_CTL_ELEM_ACCESS_TLV_WRITE), and checkpatch.pl errors
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
63e526d to
76e3a7fCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| SOF_CTRL_TYPE_DATA_GET, scontrol->cmd, false); | ||
| /* Prevent read of other kernel data or possibly corrupt response */ | ||
| data_size = cdata->data->size + sizeof(const struct sof_abi_hdr); |
There was a problem hiding this comment.
should you also include the size of tlv header in this calculation?
There was a problem hiding this comment.
Hi Ranjani,
I dont think TLV header is needed here. For get params IPC, fw sends the response as sof_abi_hdr + model data.
cdata->data->size is just the model data size. So, for the condition check here, cdata->data->size + sizeof(const struct sof_abi_hdr) becomes mandatory(data_size > be->max) be->max is from topology the max control size.
data_size will just hold the actual data size from the firmware(ABI_header + model_data).
The application reading data while allocating the buffer to read will add the size for tlv header.
eg: sof-ctl:
/*
* Allocate buffer for tlv write/read. The buffer needs a two
* words header with tag (SOF_CTRL_CMD_BINARY) and size in bytes.
*/
buffer_size = ctl_data->ctrl_size + 2 * sizeof(unsigned int);
There was a problem hiding this comment.
thanks for the explanation @RDharageswari .In that case the check looks fine.
There was a problem hiding this comment.
don't know how paranoid we want to be here, but in principle you have an overflow possibility here. If cdata->data->size is returned by the FW as a small negative number (-1), it'll pass the test, but obviously that's invalid.
kv2019i
left a comment
There was a problem hiding this comment.
Thanks @RDharageswari A couple of notes/questions inline.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
76e3a7f to
39ba17bCompare| /* vendor specific handlers found ? */ | ||
| if (k->put && k->get && k->info) | ||
| /* RW controls need to have both get/put IO handlers */ |
There was a problem hiding this comment.
@RDharageswari these checks are for the io_ops and not for the ext_ops right? Do we really need to check these here?
Uh oh!
There was an error while loading. Please reload this page.
This patch adds support for write-only and read-only TLV byte kcontrols by checking for appropriate get/put IO handlers. Signed-off-by: Dharageswari R <dharageswari.r@intel.com>
9ab1b78 to
86c21a6Compare
ranj063
left a comment
There was a problem hiding this comment.
Looks good now @RDharageswari . Thanks!
kv2019i
left a comment
There was a problem hiding this comment.
Looks good now, thanks @RDharageswari ! One CI fail, but that seems unrelated (BDW version not found -> need to debug this separately as a CI issue).
ranj063
commented
Aug 21, 2020
@bardliao you good with the changes now? |
| SOF_CTRL_TYPE_DATA_GET, scontrol->cmd, false); | ||
| /* Prevent read of other kernel data or possibly corrupt response */ | ||
| data_size = cdata->data->size + sizeof(const struct sof_abi_hdr); |
There was a problem hiding this comment.
don't know how paranoid we want to be here, but in principle you have an overflow possibility here. If cdata->data->size is returned by the FW as a small negative number (-1), it'll pass the test, but obviously that's invalid.
| struct sof_ipc_ctrl_data *cdata = scontrol->control_data; | ||
| struct snd_ctl_tlv header; | ||
| struct snd_ctl_tlv __user *tlvd = (struct snd_ctl_tlv __user *)binary_data; | ||
| int data_size; |
cad6e1f86c21a6 to
cad6e1fCompare| data_size = cdata->data->size + sizeof(const struct sof_abi_hdr); | ||
| /* check data size doesn't exceed max coming from topology */ | ||
| if (data_size > be->max) { |
There was a problem hiding this comment.
the point I was trying to make above is, that this test is incomplete. You're writing, that you want to check for corrupted data, but if, as I suggested, cdata->data->size == (uint32_t)-1, which is invalid, you won't catch it. Please have a look at #2383
This patch implements the snd_sof_bytes_ext_volatile_get() to read the actual parameters from DSP by sending the SOF_IPC_COMP_GET_DATA IPC for the kcontrol of type SOF_TPLG_KCTL_BYTES_VOLATILE_RO. Signed-off-by: Dharageswari R <dharageswari.r@intel.com>
cad6e1f to
769ca38Compare
This patch set allows a user to create Readonly and writeonly kcontrols. It also adds the snd_sof_bytes_ext_get_pm IO control to get the "actual values" of the requested parameters from DSP. These patches mainly help for the tuning purpose.