* [PATCH] zstd: Fix array-index-out-of-bounds UBSAN warning
@ 2023-10-12 21:34 Nick Terrell
2023-10-15 2:31 ` Kees Cook
0 siblings, 1 reply; 2+ messages in thread
From: Nick Terrell @ 2023-10-12 21:34 UTC (permalink / raw)
To: linux-kernel
Cc: Nick Terrell, Nick Terrell, Kernel Team, Nick Terrell,
syzbot+1f2eb3e8cd123ffce499, Eric Biggers, Kees Cook
From: Nick Terrell <terrelln@fb.com>
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@syzkaller.appspotmail.com
Reported-by: Eric Biggers <ebiggers@kernel.org>
Reported-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Nick Terrell <terrelln@meta.com>
---
lib/zstd/common/fse_decompress.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/zstd/common/fse_decompress.c b/lib/zstd/common/fse_decompress.c
index a0d06095be83..8dcb8ca39767 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;
--
2.42.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] zstd: Fix array-index-out-of-bounds UBSAN warning
2023-10-12 21:34 [PATCH] zstd: Fix array-index-out-of-bounds UBSAN warning Nick Terrell
@ 2023-10-15 2:31 ` Kees Cook
0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2023-10-15 2:31 UTC (permalink / raw)
To: Nick Terrell
Cc: linux-kernel, Nick Terrell, Kernel Team, Nick Terrell,
syzbot+1f2eb3e8cd123ffce499, Eric Biggers
On Thu, Oct 12, 2023 at 02:34:28PM -0700, Nick Terrell wrote:
> From: Nick Terrell <terrelln@fb.com>
>
> 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@syzkaller.appspotmail.com
> Reported-by: Eric Biggers <ebiggers@kernel.org>
> Reported-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Nick Terrell <terrelln@meta.com>
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@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-15 2:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-12 21:34 [PATCH] zstd: Fix array-index-out-of-bounds UBSAN warning Nick Terrell
2023-10-15 2:31 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox