summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Terrell <terrelln@fb.com>2023-10-12 12:55:34 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-12-13 18:39:04 +0100
commit62c6d82bac2bb900a24c3b64f1a83fb04fd6df64 (patch)
tree8b27e9d3e518bcc37b87cb02898e7c68a9257dcf
parent875ee3a09e27b7adb7006ca6d16faf7f33415aa5 (diff)
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>
-rw-r--r--lib/zstd/common/fse_decompress.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/zstd/common/fse_decompress.c b/lib/zstd/common/fse_decompress.c
index 2c8bbe3e4c148..f37b7aec088ec 100644
--- a/lib/zstd/common/fse_decompress.c
+++ b/lib/zstd/common/fse_decompress.c
@@ -312,7 +312,7 @@ size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size
typedef struct {
short ncount[FSE_MAX_SYMBOL_VALUE + 1];
- FSE_DTable dtable[1]; /* Dynamically sized */
+ FSE_DTable dtable[]; /* Dynamically sized */
} FSE_DecompressWksp;