I tried to run `make buildkernel' with clang21 on macOS. I get the error: --- imgact_elf.o --- sys/kern/imgact_elf.c:2722:18: error: variable 'structsize' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer] 2722 | sbuf_bcat(sb, &structsize, sizeof(structsize)); clang21 is right, it is not a good idea to copy an uninitialized local int variable.
Created attachment 269403 [details] Initialize structsize to 0 in note_procstat_auxv The attached patch resolves the uninitialized variable warning and prevents potential stack data leakage into ELF notes.
(In reply to Wolfram Schneider from comment #0) Can confirm this issue is still present on 16.0-CURRENT. I hit this exact same build failure while cross-compiling on Fedora Linux. Initializing the variable to 0 solved the issue
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=8a68c2509c00ae0dbeab64064bb600cfac787a73 commit 8a68c2509c00ae0dbeab64064bb600cfac787a73 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2026-04-08 04:19:56 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2026-04-08 14:04:29 +0000 imgact_elf: Unconditionally initialize a variable in a note handler In the sb == NULL case, we are computing the size of the note using a dummy sbuf drain handler which counts bytes and discards the contents of the buffer, so the fact that "structsize" is uninitialized doesn't matter. But, the compiler may complain about this, so we might as well just initialize it unconditionally to silence the warning, as other handlers already do. PR: 292811 MFC after: 1 week sys/kern/imgact_elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=1379cde85f6177fa457aec9bd7a100424a990a60 commit 1379cde85f6177fa457aec9bd7a100424a990a60 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2026-04-08 04:19:56 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2026-04-16 15:56:26 +0000 imgact_elf: Unconditionally initialize a variable in a note handler In the sb == NULL case, we are computing the size of the note using a dummy sbuf drain handler which counts bytes and discards the contents of the buffer, so the fact that "structsize" is uninitialized doesn't matter. But, the compiler may complain about this, so we might as well just initialize it unconditionally to silence the warning, as other handlers already do. PR: 292811 MFC after: 1 week (cherry picked from commit 8a68c2509c00ae0dbeab64064bb600cfac787a73) sys/kern/imgact_elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=62fbb17e0dd03ece12e3e4baad5d0c65bdbde3da commit 62fbb17e0dd03ece12e3e4baad5d0c65bdbde3da Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2026-04-08 04:19:56 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2026-04-16 16:48:20 +0000 imgact_elf: Unconditionally initialize a variable in a note handler In the sb == NULL case, we are computing the size of the note using a dummy sbuf drain handler which counts bytes and discards the contents of the buffer, so the fact that "structsize" is uninitialized doesn't matter. But, the compiler may complain about this, so we might as well just initialize it unconditionally to silence the warning, as other handlers already do. PR: 292811 MFC after: 1 week (cherry picked from commit 8a68c2509c00ae0dbeab64064bb600cfac787a73) sys/kern/imgact_elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)