Skip to content

Commit d3bceb8

Browse files
Shrusti-pklgirdwood
authored andcommitted
ipc4: handler-user: leave room for the TLV header in vendor config get
ipc4_get_vendor_config_module_instance() checks that produced_data plus the host max_length fits in MAILBOX_DSPBOX_SIZE, but the sof_tlv header is written at produced_data and the getter's output starts after it. A getter that honours max_length can therefore end 8 bytes past the DSPBOX, and the header write itself goes past it when produced_data is within 8 bytes of the end. For the first block of a multi-block get max_length is passed on unbounded while the output also starts after the header. Count the header in the multi-TLV bound and clamp the first block max_length to what is left after the header, so the in/out size a getter sees is the room it really has. Signed-off-by: Shrushti P K <shrusthi@labs.digiscrypt.com>
1 parent 9c6494b commit d3bceb8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎src/ipc/ipc4/handler-user.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,11 @@ __cold int ipc4_get_vendor_config_module_instance(struct comp_dev *dev,
783783
uint32_t data_off_size_local;
784784
struct sof_tlv *output_tlv = (struct sof_tlv *)(data_out + produced_data);
785785

786-
if (produced_data + input_tl[i].max_length > MAILBOX_DSPBOX_SIZE) {
786+
/* the TLV header is written in front of the value, so it
787+
* must fit in the DSPBOX together with max_length
788+
*/
789+
if (produced_data + sizeof(*output_tlv) + input_tl[i].max_length >
790+
MAILBOX_DSPBOX_SIZE) {
787791
tr_err(&ipc_tr, "error: response payload bigger than DSPBOX size");
788792
return IPC4_FAILURE;
789793
}
@@ -818,7 +822,9 @@ __cold int ipc4_get_vendor_config_module_instance(struct comp_dev *dev,
818822
struct sof_tlv *tl_header;
819823

820824
if (init_block) {
821-
*data_off_size = input_tl->max_length;
825+
/* the first block carries the TL header in front of the value */
826+
*data_off_size = MIN(input_tl->max_length,
827+
MAILBOX_DSPBOX_SIZE - sizeof(*tl_header));
822828
output_buffer = data_out + sizeof(*tl_header);
823829
} else {
824830
output_buffer = data_out;

0 commit comments

Comments
 (0)