Re: [PATCH v5 3/4] tracing: Use vmap_page_range() to map memmap ring buffer
From: Linus Torvalds
Date: Wed Apr 02 2025 - 13:55:05 EST
On Wed, 2 Apr 2025 at 10:39, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> This has nothing to do with admins. This would only occur if the kernel
> itself created a buffer from some random physical address and then tried to
> mmap it to user space (which would be a bug).
Do *not* try to check for bugs like that with virt_addr_valid().
It literally snakes debugging harder.
You're much better off getting an oops,. and then you have stack
traces, distro bug trackers, and various other automated tools that
give you information.
Trying to "validate" buggy data is crazy. It's absolutely the opposite
of safety. It's going to cause more bugs, it's going to only work for
the validation scenarios you thought about, and it's going to make it
harder to debug the cases it actually catches.
And if you are trying to catch kernel bugs, *any* data could be that
buggy data. So the whole concept is insane.
Yes, you could make every single line be a "WARN_ON()" with some
random check for the particular data you are using.
Or you could just write good solid code that is actually readable and
maintainable, and doesn't have random pointless checks in it.
Linus