Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* topology: harden binary topology decoder against malformed input
       [not found] <alsa-project/alsa-lib/pr/526@alsa-project.org>
@ 2026-09-18 19:46 ` GitHub pull_request - opened
  2026-09-30 18:59 ` GitHub pull_request - reopened
  1 sibling, 0 replies; 2+ messages in thread
From: GitHub pull_request - opened @ 2026-09-18 19:46 UTC (permalink / raw)
  To: alsa-devel

alsa-project/alsa-lib pull request #526 was opened from HarshRajSinghania:

As discussed over email with Jaroslav, this hardens the binary topology decoder
against malformed / untrusted `.tplg` input. Three related issues, each confirmed
with AddressSanitizer:

1. `snd_tplg_decode()` (src/topology/decoder.c): `hdr->size + hdr->payload_size`
   is evaluated in 32-bit and can wrap, bypassing the payload bounds check; the
   block decoder is then called with the raw (huge) `payload_size`, causing an
   out-of-bounds read. Fixed by doing the arithmetic in 64-bit (and the advance
   in `size_t`).

2. `tplg_decode_dapm_widget()` (src/topology/dapm.c): the kcontrol loop reads the
   control header (`chdr->type`, then `mc/ec/bc->size` and `->priv.size`) before
   the `size2 > size` check, giving an out-of-bounds read on a truncated payload.
   Fixed by adding `size < sizeof(*chdr)` / `sizeof(*mc|ec|bc)` guards and
   computing `size2` in `size_t`.

3. `tplg_decode_dapm_graph()` (src/topology/dapm.c): `alloca()` is called with a
   size derived from the input payload, allowing stack exhaustion on large input.
   Fixed by switching to `calloc()` / `free()`, which fails gracefully.

Scope is the debug-oriented decode path only, as you noted. Standalone ASan PoC
harnesses are available if useful.

Signed-off-by: Harsh Raj Singhania <raj.harshraut@gmail.com>

Request URL   : https://github.com/alsa-project/alsa-lib/pull/526
Patch URL     : https://github.com/alsa-project/alsa-lib/pull/526.patch
Repository URL: https://github.com/alsa-project/alsa-lib

^ permalink raw reply	[flat|nested] 2+ messages in thread

* topology: harden binary topology decoder against malformed input
       [not found] <alsa-project/alsa-lib/pr/526@alsa-project.org>
  2026-09-18 19:46 ` topology: harden binary topology decoder against malformed input GitHub pull_request - opened
@ 2026-09-30 18:59 ` GitHub pull_request - reopened
  1 sibling, 0 replies; 2+ messages in thread
From: GitHub pull_request - reopened @ 2026-09-30 18:59 UTC (permalink / raw)
  To: alsa-devel

alsa-project/alsa-lib pull request #526 was reopened from HarshRajSinghania:

As discussed over email with Jaroslav, this hardens the binary topology decoder
against malformed / untrusted `.tplg` input. Three related issues, each confirmed
with AddressSanitizer:

1. `snd_tplg_decode()` (src/topology/decoder.c): `hdr->size + hdr->payload_size`
   is evaluated in 32-bit and can wrap, bypassing the payload bounds check; the
   block decoder is then called with the raw (huge) `payload_size`, causing an
   out-of-bounds read. Fixed by doing the arithmetic in 64-bit (and the advance
   in `size_t`).

2. `tplg_decode_dapm_widget()` (src/topology/dapm.c): the kcontrol loop reads the
   control header (`chdr->type`, then `mc/ec/bc->size` and `->priv.size`) before
   the `size2 > size` check, giving an out-of-bounds read on a truncated payload.
   Fixed by adding `size < sizeof(*chdr)` / `sizeof(*mc|ec|bc)` guards and
   computing `size2` in `size_t`.

3. `tplg_decode_dapm_graph()` (src/topology/dapm.c): `alloca()` is called with a
   size derived from the input payload, allowing stack exhaustion on large input.
   Fixed by switching to `calloc()` / `free()`, which fails gracefully.

Scope is the debug-oriented decode path only, as you noted. Standalone ASan PoC
harnesses are available if useful.

Signed-off-by: Harsh Raj Singhania <raj.harshraut@gmail.com>

Request URL   : https://github.com/alsa-project/alsa-lib/pull/526
Patch URL     : https://github.com/alsa-project/alsa-lib/pull/526.patch
Repository URL: https://github.com/alsa-project/alsa-lib

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-30 19:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <alsa-project/alsa-lib/pr/526@alsa-project.org>
2026-09-18 19:46 ` topology: harden binary topology decoder against malformed input GitHub pull_request - opened
2026-09-30 18:59 ` GitHub pull_request - reopened

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox