Generating a simple kernel bug and Oops
You've heard the quote It takes a thief to catch a thief. So, let's first learn how to generate a kernel bug (it shouldn't be too much of a challenge).
As you'll know, the classic pedagogical bug is the (in)famous NULL pointer dereference (the upcoming section, What's this NULL trap page anyway? elaborates on it). So, here's the plan:
- We'll first write a very simple kernel module that performs the cardinal sin of dereferencing the NULL pointer (the address
0x0
). We'll call it our version 1oops_tryv1
module. - Once you try it out, we'll move on to a slightly more sophisticated version 2
oops_tryv2
module. Within it, we'll provide three distinct ways to generate an Oops!
Before embarking on our generate-an-Oops quest, let's better understand what the procmap
utility does and what the NULL trap page is. First, let's go with the utility.
The procmap utility
Being...