zstd: Fix array-index-out-of-bounds UBSAN warning
authorNick Terrell <terrelln@fb.com>
Thu, 12 Oct 2023 19:55:34 +0000 (12:55 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Dec 2023 17:44:58 +0000 (18:44 +0100)
commit90ed718d6a8e40ea58573f9fd90c8ebda20ca58d
tree9dca0151d93352d62bd248e68ede4624bd5f3c48
parentf5fb5ac7cee29cea9156e734fd652a66417d32fc
zstd: Fix array-index-out-of-bounds UBSAN warning

[ Upstream commit 77618db346455129424fadbbaec596a09feaf3bb ]

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.

Link: https://lkml.kernel.org/r/20231012213428.1390905-1-nickrterrell@gmail.com
Reported-by: syzbot+1f2eb3e8cd123ffce499@syzkaller.appspotmail.com
Reported-by: Eric Biggers <ebiggers@kernel.org>
Reported-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Nick Terrell <terrelln@fb.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
lib/zstd/common/fse_decompress.c