Skip to content

Commit 35e857e

Browse files
committed
audio: copier: avoid serializing uninitialized stream position to host
copier_get_configuration() returns LLP/position data to the host over IPC4 for IPC4_COPIER_MODULE_CFG_PARAM_LLP_READING and _EXTENDED. It declared the source 'posn' on the stack without initialization and called comp_position() ignoring its return value. On Zephyr-native DAI builds dai_common_position() writes posn.comp_posn only after a successful dma_get_status(); on a DMA-status error it returns early, leaving comp_posn uninitialized. The unchecked return then let convert_u64_to_u32s() serialize uninitialized stack bytes into the host reply (information disclosure) and report a fabricated stream position. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent 0f9fa75 commit 35e857e

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/audio/copier/copier.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)
360360
{
361361
struct processing_module *mod = comp_mod(dev);
362362
struct copier_data *cd = module_get_private_data(mod);
363-
struct sof_ipc_stream_posn posn;
363+
struct sof_ipc_stream_posn posn = { 0 };
364364
struct comp_dev *dai_copier;
365365
struct comp_buffer *buffer;
366366
uint32_t latency;
@@ -930,8 +930,9 @@ __cold static int copier_get_configuration(struct processing_module *mod,
930930
struct copier_data *cd = module_get_private_data(mod);
931931
struct ipc4_llp_reading_extended llp_ext;
932932
struct comp_dev *dev = mod->dev;
933-
struct sof_ipc_stream_posn posn;
933+
struct sof_ipc_stream_posn posn = { 0 };
934934
struct ipc4_llp_reading llp;
935+
int ret;
935936

936937
assert_can_be_cold();
937938

@@ -961,7 +962,9 @@ __cold static int copier_get_configuration(struct processing_module *mod,
961962
}
962963

963964
/* get llp from dai */
964-
comp_position(dev, &posn);
965+
ret = comp_position(dev, &posn);
966+
if (ret < 0)
967+
return ret;
965968

966969
convert_u64_to_u32s(posn.comp_posn, &llp.llp_l, &llp.llp_u);
967970
convert_u64_to_u32s(posn.wallclock, &llp.wclk_l, &llp.wclk_u);
@@ -991,7 +994,9 @@ __cold static int copier_get_configuration(struct processing_module *mod,
991994
}
992995

993996
/* get llp from dai */
994-
comp_position(dev, &posn);
997+
ret = comp_position(dev, &posn);
998+
if (ret < 0)
999+
return ret;
9951000

9961001
convert_u64_to_u32s(posn.comp_posn, &llp_ext.llp_reading.llp_l,
9971002
&llp_ext.llp_reading.llp_u);

0 commit comments

Comments
 (0)