From 92fca1c2d0ea743c4c92e54df028f1639634b776 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 26 Aug 2024 16:24:59 +1000 Subject: [PATCH] zstream: build with debug to fix stack overruns abd_t differs in size depending on whether or not ZFS_DEBUG is set. It turns out that libzpool is built with FORCEDEBUG_CPPFLAGS, which sets -DZFS_DEBUG, and so it always has a larger abd_t with extra debug fields, regardless of whether or not --enable-debug is set. zdb, ztest and zhack are also all built with FORCEDEBUG_CPPFLAGS, so had the same idea of the size of abd_t, but zstream was not, and used the "smaller" abd_t. In practice this didn't matter because it never used abd_t directly. This changed in b4d81b1a6, zstream was switched to use stack ABDs for compression. When built with --enable-debug, zstream implicitly gets ZFS_DEBUG, and everything was fine. Productions builds without that flag ends up with the smaller abd_t, which is now mismatched with libzpool, and causes stack overruns in zstream recompress. The simplest fix for now is to compile zstream with FORCEDEBUG_CPPFLAGS like the other binaries. This commit does that. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Allan Jude Reviewed-by: Rich Ercolani Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Issue #16476 Closes #16477 --- cmd/zstream/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/zstream/Makefile.am b/cmd/zstream/Makefile.am index 8506b35116..f9d0b0cfd2 100644 --- a/cmd/zstream/Makefile.am +++ b/cmd/zstream/Makefile.am @@ -1,3 +1,5 @@ +zstream_CPPFLAGS = $(AM_CPPFLAGS) $(FORCEDEBUG_CPPFLAGS) + sbin_PROGRAMS += zstream CPPCHECKTARGETS += zstream