[PATCH] ufs: core: Fix heap corruption due to out of bounds write

Neil Armstrong neil.armstrong at linaro.org
Wed Apr 22 10:10:03 CEST 2026


Hi,

On Mon, 30 Mar 2026 01:11:36 +0200, Marek Vasut wrote:
> The ufshcd_read_string_desc() can perform out of bounds write and
> corrupt heap in case the input utf-16 string contains code points
> which convert to anything more than plain 7-bit ASCII string.
> 
> This occurs because utf16_to_utf8(dst, src, size) in U-Boot behaves
> differently than Linux utf16s_to_utf8s(..., maxlen), but the porting
> process did not take that into consideration. The U-Boot variant of
> the function converts up to $size utf-16 fixed-length 16-bit input
> characters into as many 1..4 Byte long variable-length utf-8 output
> characters. That means for 16 Byte input, the output can be up to 64
> Bytes long. The Linux variant converts up utf-16 input into up to
> $maxlen Bytes worth of utf-8 output, but stops at the $maxlen limit.
> That means for 16 Byte input with maxlen=32, the processing will stop
> after writing 32 output Bytes.
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-ufs (u-boot-ufs-next)

[1/1] ufs: core: Fix heap corruption due to out of bounds write
      https://source.denx.de/u-boot/custodians/u-boot-ufs/-/commit/c7ebdb9871dfd6e170a6dfeee39be234c37a4b53

-- 
Neil



More information about the U-Boot mailing list