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: lkmpg.tex
+32-23Lines changed: 32 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -93,7 +93,7 @@ \subsection{Authorship}
93
93
\subsection{Acknowledgements}
94
94
\label{sec:acknowledgements}
95
95
96
-
The following people have contributed corrections or good suggestions:
96
+
The following people have contributed corrections or good suggestions:
97
97
98
98
\begin{flushleft}
99
99
\input{contrib}
@@ -176,12 +176,12 @@ \subsection{Before We Begin}
176
176
Working on these tasks within the X Window System is discouraged.
177
177
178
178
Modules cannot directly print to the screen like \cpp|printf()| can,
179
-
but they can log information and warnings that are eventually displayed on the screen,
180
-
specifically within a console.
181
-
If a module is loaded from an\sh|xterm|, the information and warnings will be logged,
182
-
but solely within the systemd journal. These logs will not be visible unless consulting the \sh|journalctl|.
179
+
but they can log information and warnings to the kernel's log ring buffer.
180
+
This output is \emph{not} automatically displayed on any console or terminal.
181
+
To view kernel module messages, you must use\sh|dmesg| to read the kernel log ring buffer,
182
+
or check the systemd journal with \sh|journalctl -k| for kernel messages.
183
183
Refer to \ref{sec:helloworld} for more information.
184
-
For instant access to this information, it is advisable to perform all tasks from the console.
184
+
The terminal or environment from which you load the module does not affect where the output goes—it always goes to the kernel log.
185
185
\item SecureBoot.
186
186
Numerous modern computers arrive pre-configured with UEFI SecureBoot enabled—an essential security standard ensuring booting exclusively through trusted software endorsed by the original equipment manufacturer.
187
187
Certain Linux distributions even ship with the default Linux kernel configured to support SecureBoot.
In \verb|Makefile|, \verb|$(CURDIR)| can be set to the absolute pathname of the current working directory (after all \verb|-C| options are processed, if any).
268
+
In \verb|Makefile|, \verb|$(CURDIR)| can be set to the absolute pathname of the current working directory (after all \verb|-C| options are processed, if any).
269
269
See more about \verb|CURDIR| in \href{https://www.gnu.org/software/make/manual/make.html}{GNU make manual}.
If there is no \verb|PWD := $(CURDIR)| statement in the Makefile, then it may not compile correctly with \verb|sudo make|.
278
278
This is because some environment variables are specified by the security policy and cannot be inherited.
279
279
The default security policy is \verb|sudoers|.
280
-
In the \verb|sudoers| security policy, \verb|env_reset| is enabled by default, which restricts environment variables.
280
+
In the \verb|sudoers| security policy, \verb|env_reset| is enabled by default, which restricts environment variables.
281
281
Specifically, path variables are not retained from the user environment; they are set to default values (for more information see: \href{https://www.sudo.ws/docs/man/sudoers.man/}{sudoers manual}).
If \verb|KASLR| is enabled, we have to take care of the address from \verb|/proc/kallsyms| each time we reboot the machine.
@@ -1579,8 +1588,8 @@ \section{System Calls}
1579
1588
When A is removed, it sees that the system call was changed to \cpp|B_openat| so that it is no longer pointing to \cpp|A_openat|, so it will not restore it to \cpp|sys_openat| before it is removed from memory.
1580
1589
Unfortunately, \cpp|B_openat| will still try to call \cpp|A_openat| which is no longer there, so that even without removing B the system would crash.
1581
1590
1582
-
For x86 architecture, the system call table cannot be used to invoke a system call after commit
1583
-
\href{https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1e3ad78334a69b36e107232e337f9d693dcc9df2}{1e3ad78} since v6.9.
1591
+
For x86 architecture, the system call table cannot be used to invoke a system call after commit
1592
+
\href{https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1e3ad78334a69b36e107232e337f9d693dcc9df2}{1e3ad78} since v6.9.
1584
1593
This commit has been backported to long term stable kernels, like v5.15.154+, v6.1.85+, v6.6.26+ and v6.8.5+, see this \href{https://stackoverflow.com/a/78607015}{answer} for more details.
1585
1594
In this case, thanks to Kprobes, a hook can be used instead on the system call entry to intercept the system call.
1586
1595
@@ -1674,8 +1683,8 @@ \subsection{Completions}
1674
1683
1675
1684
Completions as code synchronization mechanism have three main parts, initialization of struct completion synchronization object, the waiting or barrier part through \cpp|wait_for_completion()|, and the signalling side through a call to \cpp|complete()|.
1676
1685
1677
-
In the subsequent example, two threads are initiated: crank and flywheel.
1678
-
It is imperative that the crank thread starts before the flywheel thread.
1686
+
In the subsequent example, two threads are initiated: crank and flywheel.
1687
+
It is imperative that the crank thread starts before the flywheel thread.
1679
1688
A completion state is established for each of these threads, with a distinct completion defined for both the crank and flywheel threads.
1680
1689
At the exit point of each thread the respective completion state is updated, and \cpp|wait_for_completion| is used by the flywheel thread to ensure that it does not begin prematurely.
1681
1690
The crank thread uses the \cpp|complete_all()| function to update the completion, which lets the flywheel thread continue.
0 commit comments