Re: [PATCH v2] ALSA: firewire-motu: fix buffer overflow in hwdep read for DSP events
From: Takashi Iwai
Date: Mon Dec 08 2025 - 07:23:04 EST
On Mon, 08 Dec 2025 13:09:09 +0100,
Junrui Luo wrote:
>
> The DSP event handling code in hwdep_read() could write more bytes to
> the user buffer than requested, when a user provides a buffer smaller
> than the event header size (8 bytes).
>
> In the put_user() loop that copies event data, when the user buffer
> size is not aligned to 4 bytes, it could overwrite beyond the buffer
> boundary.
>
> Fix by:
> - using min_t() to clamp the copy size
> - Adding a bounds check before put_user()
>
> This ensures we never write more than the user requested.
>
> Fixes: 634ec0b2906e ("ALSA: firewire-motu: notify event for parameter change in register DSP model")
> Signed-off-by: Junrui Luo <moonafterrain@xxxxxxxxxxx>
> ---
> Changes in v2:
> - Also fix the similar issue in the put_user() loop suggested by Takashi Iwai
> - Link to v1: https://lore.kernel.org/all/SYBPR01MB78810656377E79E58350D951AFD9A@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/T/#u
v1 was already merged. Please submit an incremental fix on top of
sound.git tree for-linus branch.
thanks,
Takashi