You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,12 +40,12 @@ $ brew install mactex
40
40
$ sudo tlmgr update --self
41
41
```
42
42
43
-
Note that `latexmk` is required to generated PDF, and it probably has been installed on your OS already. If not, please follow the [installation guide](https://mg.readthedocs.io/latexmk.html#installation).
43
+
Note that `latexmk` is required to generate PDF, and it probably has been installed on your OS already. If not, please follow the [installation guide](https://mg.readthedocs.io/latexmk.html#installation).
44
44
45
-
In macOS systems, package `Pygments` may not be pre-installed. If not, please refer to the [installation guide](https://pygments.org/download/) before generate documents.
45
+
In macOS systems, package `Pygments` may not be pre-installed. If not, please refer to the [installation guide](https://pygments.org/download/) before generating documents.
46
46
47
47
Alternatively, using [Docker](https://docs.docker.com/) is recommended, as it guarantees the same dependencies with our GitHub Actions workflow.
48
-
After install[docker engine](https://docs.docker.com/engine/install/) on your machine, pull the docker image [twtug/lkmpg](https://hub.docker.com/r/twtug/lkmpg) and run in isolated containers.
48
+
After installing[docker engine](https://docs.docker.com/engine/install/) on your machine, pull the docker image [twtug/lkmpg](https://hub.docker.com/r/twtug/lkmpg) and run in isolated containers.
The Linux Kernel Module Programming Guide is a free book; you may reproduce and/or modify it under the terms of the [Open Software License](https://opensource.org/licenses/OSL-3.0).
71
71
Use of this work is governed by a copyleft license that can be found in the `LICENSE` file.
72
72
73
-
The complementary sample code is licensed under GNU GPL version 2, as same as Linux kernel.
73
+
The complementary sample code is licensed under GNU GPL version 2, the same as the Linux kernel.
An instance of \cpp|struct file_operations| containing pointers to functions that are used to implement \cpp|read|, \cpp|write|, \cpp|open|, \ldots{} system calls is commonly named \cpp|fops|.
1343
1343
1344
-
Since Linux v3.14, the read, write and seek operations are guaranteed for thread-safe by using the \cpp|f_pos| specific lock, which makes the file position update to become the mutual exclusion.
1344
+
Since Linux v3.14, the read, write and seek operations are guaranteed to be thread-safe by using the \cpp|f_pos| specific lock, which makes the file position update to become the mutual exclusion.
1345
1345
So, we can safely implement those operations without unnecessary locking.
1346
1346
1347
1347
Additionally, since Linux v5.6, the \cpp|proc_ops| structure was introduced to replace the use of the \cpp|file_operations| structure when registering proc handlers.
@@ -1812,8 +1812,8 @@ \section{Talking To Device Files}
1812
1812
However, this leaves open the question of what to do when you need to talk to the serial port itself, for example to configure the rate at which data is sent and received.
1813
1813
1814
1814
The answer in Unix is to use a special function called \cpp|ioctl| (short for Input Output ConTroL).
1815
-
Every device can have its own \cpp|ioctl| commands, which can be read ioctl's (to send information from a process to the kernel), write ioctl's (to return information to a process), both or neither.
1816
-
Notice here the roles of read and write are reversed again, so in ioctl's read is to send information to the kernel and write is to receive information from the kernel.
1815
+
Every device can have its own \cpp|ioctl| commands, which can be read ioctls (to send information from a process to the kernel), write ioctls (to return information to a process), both or neither.
1816
+
Notice here the roles of read and write are reversed again, so in ioctls read is to send information to the kernel and write is to receive information from the kernel.
1817
1817
1818
1818
The ioctl function is called with three parameters: the file descriptor of the appropriate device file, the ioctl number, and a parameter, which is of type long so you can use a cast to use it to pass anything.
1819
1819
You will not be able to pass a structure this way, but you will be able to pass a pointer to the structure.
@@ -1825,7 +1825,7 @@ \section{Talking To Device Files}
1825
1825
It is the ioctl number.
1826
1826
The ioctl number encodes the major device number, the type of the ioctl, the command, and the type of the parameter.
1827
1827
This ioctl number is usually created by a macro call (\cpp|_IO|, \cpp|_IOR|, \cpp|_IOW| or \cpp|_IOWR| --- depending on the type) in a header file.
1828
-
This header file should then be included both by the programs which will use ioctl (so they can generate the appropriate ioctl's) and by the kernel module (so it can understand it).
1828
+
This header file should then be included both by the programs which will use ioctl (so they can generate the appropriate ioctls) and by the kernel module (so it can understand it).
1829
1829
In the example below, the header file is \verb|chardev.h| and the program which uses it is \verb|userspace_ioctl.c|.
1830
1830
1831
1831
If you want to use ioctls in your own kernel modules, it is best to receive an official ioctl assignment, so if you accidentally get somebody else's ioctls, or if they get yours, you'll know something is wrong.
@@ -2010,7 +2010,7 @@ \section{System Calls}
2010
2010
Without \verb|KASLR|, the attacker may find the target address in the fixed address easily.
2011
2011
Then the attacker can use return-oriented programming to insert some malicious codes to execute or receive the target data by a tampered pointer.
2012
2012
\verb|KASLR| mitigates these kinds of attacks because the attacker cannot immediately know the target address, but a brute-force attack can still work.
2013
-
If the address of a symbol in \verb|/proc/kallsyms| is different from the address in \verb|/boot/System.map|, \verb|KASLR| is enabled with the kernel, which your system running on.
2013
+
If the address of a symbol in \verb|/proc/kallsyms| is different from the address in \verb|/boot/System.map|, \verb|KASLR| is enabled with the kernel, on which your system is running.
If none of the examples in this chapter fit your debugging needs, there might yet be some other tricks to try.
2390
2390
Ever wondered what \cpp|CONFIG_DEBUG_LL| in \sh|make menuconfig| is good for?
2391
2391
If you activate that you get low level access to the serial port.
2392
-
While this might not sound very powerful by itself, you can patch \src{kernel/printk/printk.c} or any other essential kernel function to print ASCII characters, thus making it possible to trace virtually everything what your code does over a serial line.
2392
+
While this might not sound very powerful by itself, you can patch \src{kernel/printk/printk.c} or any other essential kernel function to print ASCII characters, thus making it possible to trace virtually everything that your code does over a serial line.
2393
2393
If you find yourself porting the kernel to some new and former unsupported architecture, this is usually amongst the first things that should be implemented.
2394
2394
Logging over a netconsole might also be worth a try.
To take advantage of them requires handlers to be written in assembly language, so they do not really fit into the kernel.
2890
2890
They can be made to work similar to the others, but after that procedure, they are no longer any faster than "common" IRQs.
2891
2891
SMP enabled kernels running on systems with more than one processor need to solve another truckload of problems.
2892
-
It is not enough to know if a certain IRQs has happened, it's also important to know what CPU(s) it was for.
2892
+
It is not enough to know if a certain IRQ has happened, it's also important to know what CPU(s) it was for.
2893
2893
People still interested in more details, might want to refer to "APIC" now.
2894
2894
2895
2895
This function receives the IRQ number, the name of the function, flags, a name for \verb|/proc/interrupts| and a parameter to be passed to the interrupt handler.
0 commit comments