[–] HentaiOjisan 0 points 1 point 1 point (+1|-0) ago
Ohh. I see! That makes a lot of sense! So the point is to overwrite data after using it to avoid data leaks by another bug (for example a passphrase or something similar). But because you might not use again that data, the compiler will skip that part of the code.
I didn't know either that a deference will always work for the kernel. I expected it to panic or something if it was pointing to NULL. I'm reading about it now and it seems that it's because the physical memory does have a 0 address, so you can actually read or write to it if you are not in user space. In fact it makes sense, in a microcontroller I'm programming that address is reserved for a pointer to the top of the stack.
Thanks again!!
[–] NotSurvivingLife [S] 0 points 1 point 1 point (+1|-0) ago
The Linux kernel sometimes allows a NULL dereference, and sometimes doesn't (in which case it's a kernel oops). It depends if anything gets mapped to the bottom of the virtual address space.