Skip to content

ASoC: mediatek: mtk-btcvsd: fix 0xdeadfeed check and bt_sram_addr bounds

Ilia Snezhkov b4-sent linux-arm-kernel linux-mediatek linux-sound lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 0 repliesNew

Changes in v2 from the cover letter

- Replaced the ineffective check on cached virtual addresses bt_sram_addr[i] with a check on the live *bt->bt_reg_pkt_w register (returning 0 early when num_valid_addr == 0).
- Dropped the unrelated Fixes: d067b3378a78 tag; kept only

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2ASoC: mediatek: mtk-btcvsd: check bt_reg_pkt_w for 0xdeadfeed in btcvsd_tx_clean_buffer()sound/soc/mediatek/common/mtk-btcvsd.c+9 -00 replies
2/2ASoC: mediatek: mtk-btcvsd: bound bt_sram_addr[] writes in mtk_btcvsd_write_to_bt()sound/soc/mediatek/common/mtk-btcvsd.c+13 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] ASoC: mediatek: mtk-btcvsd: fix 0xdeadfeed check and bt_sram_addr bounds

This two-patch v2 series addresses two safety issues in sound/soc/mediatek/common/mtk-btcvsd.c:

1. Check the live *bt->bt_reg_pkt_w register for 0xdeadfeed under tx_lock in btcvsd_tx_clean_buffer() (after skipping the empty num_valid_addr case), matching mtk_btcvsd_read_from_bt() and mtk_btcvsd_write_to_bt().
2. Bound bt_sram_addr[] writes in mtk_btcvsd_write_to_bt() against ARRAY_SIZE(bt->tx->buffer_info.bt_sram_addr) to prevent an out-of-bounds write past the 20-entry array.

Changes in v2:
- Replaced the ineffective check on cached virtual addresses bt_sram_addr[i] with a check on the live *bt->bt_reg_pkt_w register (returning 0 early when num_valid_addr == 0).
- Dropped the unrelated Fixes: d067b3378a78 tag; kept only

Fixes 4bd8597dc36c.

- Added patch 2/2 fixing the unbounded bt_sram_addr[] write spotted while auditing mtk_btcvsd_write_to_bt().
- Link to v1: https://lore.kernel.org/r/[email protected]

Found and drafted with an AI coding assistant while bringing up MT6789.

Ilia Snezhkov (2):
ASoC: mediatek: mtk-btcvsd: check bt_reg_pkt_w for 0xdeadfeed in
btcvsd_tx_clean_buffer()
ASoC: mediatek: mtk-btcvsd: bound bt_sram_addr[] writes in
mtk_btcvsd_write_to_bt()

 sound/soc/mediatek/common/mtk-btcvsd.c | 28 ++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)
Signature · 1 line
2.54.0 (Apple Git-157)