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

From
Steven Rostedt <rostedt@goodmis.org>
Date
2025-12-17 20:10:32
Also in
lkml
Reply to
Kees Cook, 2025-11-17
On Mon, 17 Nov 2025 13:28:59 -0800
Kees Cook [off-list ref] 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).
  
Thread (3 messages) 3 messages, 2 authors, last reply 2025-12-17
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help