Skip to content

Commit 2575428

Browse files
tmlemanlgirdwood
authored andcommitted
audio: smart_amp: validate DSM parameter id before db write
maxim_dsm_set_param() masks the host-supplied parameter id with DSM_CH_MASK() and uses the result directly as an index into the model database db[], which is sized for hspk->param.max_param parameters. A larger id leads to an out-of-bounds write. Reject id values that are not below max_param before indexing db[]. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
1 parent 569e54f commit 2575428

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/audio/smart_amp/smart_amp_maxim_dsm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,13 @@ static int maxim_dsm_set_param(struct smart_amp_mod_struct_t *hspk,
385385
id = DSM_CH_MASK(param->param.id);
386386
ch = (param->param.id & DSM_CH1_BITMASK) ? 0 : 1;
387387

388+
/* id indexes the model database; reject values past its size */
389+
if (id >= hspk->param.max_param) {
390+
comp_err(dev, "[DSM] invalid param id:%x max:%d",
391+
id, hspk->param.max_param);
392+
return -EINVAL;
393+
}
394+
388395
/* 2nd channel has (hspk->param.max_param * DSM_PARAM_MAX) sized offset */
389396
db[(id + ch * hspk->param.max_param) * DSM_PARAM_MAX + DSM_PARAM_VALUE] =
390397
param->param.value;

0 commit comments

Comments
 (0)