Re: [PATCH] zstd: Fix array-index-out-of-bounds UBSAN warning

From: Kees Cook
Date: Sat Oct 14 2023 - 22:31:43 EST


On Thu, Oct 12, 2023 at 02:34:28PM -0700, Nick Terrell wrote:
> From: Nick Terrell <terrelln@xxxxxx>
>
> Zstd used an array of length 1 to mean a flexible array for C89
> compatibility. Switch to a C99 flexible array to fix the UBSAN warning.
>
> Tested locally by booting the kernel and writing to and reading from a
> BtrFS filesystem with zstd compression enabled. I was unable to reproduce
> the issue before the fix, however it is a trivial change.
>
> Reported-by: syzbot+1f2eb3e8cd123ffce499@xxxxxxxxxxxxxxxxxxxxxxxxx
> Reported-by: Eric Biggers <ebiggers@xxxxxxxxxx>
> Reported-by: Kees Cook <keescook@xxxxxxxxxxxx>
> Signed-off-by: Nick Terrell <terrelln@xxxxxxxx>

Thanks! This 1-element conversion doesn't appear to need any sizeof()
related changes, so AFAICT this header change is sufficient.

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>


--
Kees Cook