On Wed, 2 Apr 2025 at 10:39, Steven Rostedt <rost...@goodmis.org> 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