Re: [PATCH] unwind: Show that entries of struct unwind_cache is not bound by nr_entries

From: Steven Rostedt

Date: Wed Dec 17 2025 - 15:10:40 EST


On Mon, 17 Nov 2025 13:28:59 -0800
Kees Cook <kees@xxxxxxxxxx> wrote:

> struct unwind_cache {
> struct_group_tagged(unwind_cache_hdr, hdr,
> unsigned long unwind_completed;
> unsigned int nr_entries;
> );
> unsigned long entries[(SZ_4K - sizeof(struct unwind_cache_hdr)) / sizeof(long)];
> };

This may help automated tooling, but it is horrendous to read. I value
readability much higher than static analyzers.

Hence, I'm leaving the code as is, and just keep NAKing patches that try to
add __counted_by() to entries.

-- Steve


>
> #define UNWIND_MAX_ENTRIES ARRAY_SIZE(((struct unwind_cache*)NULL)->entries)
>
> And this checks out for me:
>
> UNWIND_MAX_ENTRIES:510
> sizeof(struct unwind_cache):4096
>
> No hiding things from the compiler, and you can treat "entries" like a
> real array (since it is one now).