]> Git Repo - linux.git/commitdiff
soundwire: qcom: fix storing port config out-of-bounds
authorKrzysztof Kozlowski <[email protected]>
Thu, 1 Jun 2023 10:25:25 +0000 (12:25 +0200)
committerVinod Koul <[email protected]>
Wed, 21 Jun 2023 11:01:44 +0000 (16:31 +0530)
The 'qcom_swrm_ctrl->pconfig' has size of QCOM_SDW_MAX_PORTS (14),
however we index it starting from 1, not 0, to match real port numbers.
This can lead to writing port config past 'pconfig' bounds and
overwriting next member of 'qcom_swrm_ctrl' struct.  Reported also by
smatch:

  drivers/soundwire/qcom.c:1269 qcom_swrm_get_port_config() error: buffer overflow 'ctrl->pconfig' 14 <= 14

Fixes: 9916c02ccd74 ("soundwire: qcom: cleanup internal port config indexing")
Cc: <[email protected]>
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Link: https://lore.kernel.org/r/[email protected]/
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Reviewed-by: Konrad Dybcio <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Vinod Koul <[email protected]>
drivers/soundwire/qcom.c

index f6adf2c6c1ac1fa8f8bf00367285bcf0b708ad7a..7970fdb27ba02330555c0a9a0d4c3b5d9e484c98 100644 (file)
@@ -202,7 +202,8 @@ struct qcom_swrm_ctrl {
        u32 intr_mask;
        u8 rcmd_id;
        u8 wcmd_id;
-       struct qcom_swrm_port_config pconfig[QCOM_SDW_MAX_PORTS];
+       /* Port numbers are 1 - 14 */
+       struct qcom_swrm_port_config pconfig[QCOM_SDW_MAX_PORTS + 1];
        struct sdw_stream_runtime *sruntime[SWRM_MAX_DAIS];
        enum sdw_slave_status status[SDW_MAX_DEVICES + 1];
        int (*reg_read)(struct qcom_swrm_ctrl *ctrl, int reg, u32 *val);
This page took 0.0555 seconds and 4 git commands to generate.