From e67b246734e37d1128fae0faecdd37806c5328ed Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Mon, 3 Oct 2022 16:10:43 -0700 Subject: [PATCH] libzpool: Disable -Wuse-after-free for dbuf.c. The debug traces for reference counting in ZFS use the pointer of the owning object as a "tag" for references to check that when an object drops a reference it had actually held one. In a couple of places ZFS drops references after freeing the owning object. In userland GCC realizes this is a use after free. However, since only the value of the pointer is used, and it isn't indirected, the use is harmless. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D36818 --- cddl/lib/libzpool/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile index b9ef6575c99a..13671752fe88 100644 --- a/cddl/lib/libzpool/Makefile +++ b/cddl/lib/libzpool/Makefile @@ -286,6 +286,10 @@ CSTD= c99 CFLAGS+= -g -DDEBUG=1 +# Pointer values are used as debugging "tags" to mark reference count +# ownerships and in some cases the tag reference is dropped after an +# object is freed. +CFLAGS.dbuf.c= ${NO_WUSE_AFTER_FREE} CFLAGS.entropy_common.c= -fno-tree-vectorize CFLAGS.entropy_common.c+= ${NO_WBITWISE_INSTEAD_OF_LOGICAL} CFLAGS.error_private.c= -fno-tree-vectorize