linD026 [Sat, 4 Sep 2021 09:53:29 +0000 (17:53 +0800)]
Fix the warnings raised by Sparse (#92)
Sparse[1] is a semantic parser, capable of finding out the potential
problems of Linux kernel code. This patch fixed the warnings.
[1] https://www.kernel.org/doc/html/latest/dev-tools/sparse.html
Jim Huang [Fri, 3 Sep 2021 15:13:10 +0000 (23:13 +0800)]
Merge pull request #91 from ccs100203/master
Fix Typo
ccs100203 [Fri, 3 Sep 2021 15:02:17 +0000 (23:02 +0800)]
Fix Typo
from "mask" to "masks"
from "quick" to "quickly"
from "a" to "an"
linD026 [Thu, 2 Sep 2021 08:26:29 +0000 (16:26 +0800)]
Enforce consistent style for directory "other" (#89)
linD026 [Thu, 2 Sep 2021 07:15:07 +0000 (15:15 +0800)]
Enforce Linux kernel coding style (#88)
The only exception is to indent with four spaces rather than tabs
for sticking to compact layout of source listing.
Close #87
Jim Huang [Wed, 1 Sep 2021 04:07:25 +0000 (12:07 +0800)]
Rewrite the descriptions about bottom half
Jim Huang [Wed, 1 Sep 2021 01:44:45 +0000 (09:44 +0800)]
Merge pull request #86 from linD026/master
Fix typo
linzhien [Tue, 31 Aug 2021 23:44:40 +0000 (07:44 +0800)]
Fix typo
fennecJ [Tue, 31 Aug 2021 15:49:18 +0000 (23:49 +0800)]
Add GitHub buttons in rendered HTML (#85)
GitHub buttons are rendered in the generated HTML:
one is GitHub project page; another is PDF download.
Close #84
linD026 [Tue, 31 Aug 2021 03:07:01 +0000 (11:07 +0800)]
Fix disallowed cr0 write protection and close_fd (#80)
Since the commit
8dbec27a242cd3e2816eeb98d3237b9f57cf6232 [1]
(kernel version v5.3+ [2]) the sensitive CR0 bits in x86 is pinned,
we need to use the inline asm [3][4] to bypass it.
commit
8dbec27a242cd3e2816eeb98d3237b9f57cf6232 :
> With sensitive CR4 bits pinned now, it's possible that the WP bit for
> CR0 might become a target as well.
>
> Following the same reasoning for the CR4 pinning, pin CR0's WP
> bit. Contrary to the cpu feature dependend CR4 pinning this can be done
> with a constant value.
Also, getting "sys_call_table" [8] from the symbol lookup by using the address
of "close_fd" does not work for v5.11+ [5][6]. The reason is the entry of
"sys_call_table[__NR_close]" is not the address of "close_fd", actually
it is "__x64_sys_close" in x86.
Two solutions were proposed: using "kallsyms_lookup_name" [7] or just specifying
the address into the module. The symbol "kallsyms_lookup_name" is unexported
since v5.7; the address of "sys_call_table" can be found in
"/boot/System.map" or "/proc/kallsyms".
Since v5.7, the manual symbol lookup is not guaranteed to work
because of control-flow integrity (or control-flow enforcement [9][10]) is added
[11] for x86, but it is disabled since v5.11 [12][13]. To make sure manual symbol
lookup work, it only uses up to v5.4.
Reference:
[1] https://github.com/torvalds/linux/commit/
8dbec27a242cd3e2816eeb98d3237b9f57cf6232
[2] https://outflux.net/blog/archives/2019/11/14/security-things-in-linux-v5-3/
[3] https://patchwork.kernel.org/project/linux-kbuild/patch/
20200903203053.
3411268-3-samitolvanen@google.com/
[4] https://stackoverflow.com/questions/
58512430/how-to-write-to-protected-pages-in-the-linux-kernel
[5] https://lore.kernel.org/bpf/
20201120231441.29911-21-ebiederm@xmission.com/
[6] https://lore.kernel.org/bpf/87blj83ysq.fsf@x220.int.ebiederm.org/
[7] https://github.com/torvalds/linux/commit/
0bd476e6c67190b5eb7b6e105c8db8ff61103281
[8] https://github.com/torvalds/linux/commit/
8f27766a883149926e7c1f69d9f1d8f68efcd65f
[9] https://lore.kernel.org/lkml/
20200204171425.28073-1-yu-cheng.yu@intel.com/
[10] https://lore.kernel.org/linux-doc/
20201110162211.9207-1-yu-cheng.yu@intel.com/T/
[11] https://github.com/torvalds/linux/commit/
5790921bc18b1eb5c0c61371e31114fd4c4b0154
[12] https://github.com/torvalds/linux/commit/
20bf2b378729c4a0366a53e2018a0b70ace94bcd
[13] https://lore.kernel.org/bpf/
20210128123842.
c9e33949e62f504b84bfadf5@gmail.com/
Jim Huang [Sun, 29 Aug 2021 17:41:57 +0000 (01:41 +0800)]
print_string: Validate tty before accessing its operations
Close #81
Jim Huang [Thu, 26 Aug 2021 03:14:11 +0000 (11:14 +0800)]
Merge pull request #79 from xatier/patch-1
Update Arch Linux kernel headers information
xatier [Thu, 26 Aug 2021 03:11:27 +0000 (20:11 -0700)]
Update Archlinux kernel headers instructions
`linux-libre-headers` has been moved to AUR [1]. We can simply install `linux-headers` [2] instead.
[1] https://aur.archlinux.org/packages/linux-libre-headers/
[2] https://archlinux.org/packages/core/x86_64/linux-headers/
linD026 [Wed, 25 Aug 2021 19:16:17 +0000 (03:16 +0800)]
Fix incorrect major number registration in chardev (#77)
chardev2.c demonstrates the ioctl operation with static major
number MAJOR_NUM, but there also exists "Major," the dynamic
one, which results in registration and deregistration on different
device. Once the module remove, it cannot insert again:
$ sudo insmod chardev2.ko
$ sudo rmmod chardev2
$ cat /proc/devices
Character devices:
...
100 char_dev
$ sudo insmod chardev2.ko
insmod: ERROR: could not insert module chardev2.ko: Device or resource busy
This patch removed the use of dynamic major number.
Jim Huang [Tue, 24 Aug 2021 15:22:32 +0000 (23:22 +0800)]
Merge pull request #75 from tuckerpo/fix/errno_assignment
Fix: errno assignment should be comparison.
Tucker Polomik [Tue, 24 Aug 2021 15:16:25 +0000 (11:16 -0400)]
Fix: errno assignment should be comparison.
Jim Huang [Tue, 24 Aug 2021 11:00:17 +0000 (19:00 +0800)]
Get rid of the initial 0 that shows up in every (sub)section
Every section and subsection number can be eliminated by adding the
renewcommand.
Suggested by Lars Engebretsen.
Jim Huang [Tue, 24 Aug 2021 06:08:24 +0000 (14:08 +0800)]
Merge pull request #74 from brdbkr/master
Fixed typo
Brad Baker [Tue, 24 Aug 2021 04:15:47 +0000 (00:15 -0400)]
Fixing typo
Jim Huang [Mon, 23 Aug 2021 19:41:14 +0000 (03:41 +0800)]
Merge pull request #70 from fennecJ/patch
Adapt recent kernel changes
fennecJ [Mon, 23 Aug 2021 13:30:43 +0000 (21:30 +0800)]
Update several example code for newer kernel
Known issues with current example code:
If you using newer kernel(e.g linux 5.11.x) to compile the example code,
you may meet following error:
1. syscall.c:83:50: error: ‘ksys_close’ undeclared;
2. cryptosk.c:17:24: error: field ‘sg’ has incomplete type
3. cryptosk.c:143:9: error: implicit declaration of function
‘get_random_bytes’
4. error: macro "DECLARE_TASKLET" passed 3 arguments, but takes just 2
Solutions/workaround:
1. In syscall.c, replace #include <linux/syscalls.h> with
#include <linux/fdtable.h> and replace ksys_close with close_fd
if the kernel version >= 5.11. [1][2]
2. Add #include <linux/scatterlist.h> into cryptosk.c
3. Add #include <linux/random.h> into cryptosk.c
4. In bottomhalf.c and example_tasklet.c, replace DECLARE_TASKLET
with DECLARE_TASKLET_OLD and dispose third argument(0L). [3]
[1] - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=
1572bfdf21d4d50e51941498ffe0b56c2289f783
[2] - https://www.mail-archive.com/meta-arago@arago-project.org//msg11939.html
[3] - https://patchwork.kernel.org/project/kernel-hardening/patch/
20200716030847.
1564131-3-keescook@chromium.org/
Jim Huang [Sat, 21 Aug 2021 11:27:08 +0000 (19:27 +0800)]
Merge pull request #69 from gagachang/master
Update path to kernel v5.x
gagachang [Sat, 21 Aug 2021 06:51:37 +0000 (14:51 +0800)]
Update some file path to kernel v5.x+ in example/kbleds.c
1. drivers/char/vt_ioctl.c -> drivers/tty/vt/vt_ioctl.c
2. drivers/char/keyboard.c -> drivers/tty/vt/keyboard.c
Jim Huang [Thu, 19 Aug 2021 17:05:51 +0000 (01:05 +0800)]
Use recent kernel build messages
Jim Huang [Thu, 19 Aug 2021 17:02:20 +0000 (01:02 +0800)]
Revise the version magic descriptions for recent kernels
Jim Huang [Thu, 19 Aug 2021 16:29:43 +0000 (00:29 +0800)]
Fix wording
Jim Huang [Wed, 18 Aug 2021 12:43:51 +0000 (20:43 +0800)]
Neither latexmk nor dvipng is required
The package texlive-bin from extra also contains a dvipng binary.
Close #58
Jim Huang [Tue, 17 Aug 2021 09:37:08 +0000 (17:37 +0800)]
Merge pull request #67 from fennecJ/master
Add pdf download link in html only
fennecj [Tue, 17 Aug 2021 09:35:36 +0000 (17:35 +0800)]
Add PDF download link in html only
Close #64
Jim Huang [Tue, 17 Aug 2021 05:07:06 +0000 (13:07 +0800)]
Check coding style in CI
Jim Huang [Tue, 17 Aug 2021 00:56:55 +0000 (08:56 +0800)]
Merge pull request #66 from CyrilBrulebois/master
Proofreading and small improvements
Cyril Brulebois [Mon, 16 Aug 2021 19:22:53 +0000 (21:22 +0200)]
Adjust link to ioctl-number.rst
Cyril Brulebois [Mon, 16 Aug 2021 19:22:23 +0000 (21:22 +0200)]
Improve wording (avoid a send/sent repetition along the way)
Cyril Brulebois [Mon, 16 Aug 2021 19:21:42 +0000 (21:21 +0200)]
Use an https:// link for LWN
Cyril Brulebois [Mon, 16 Aug 2021 19:21:20 +0000 (21:21 +0200)]
Improve wording (statistics seem gathered, not stat-ed)
Cyril Brulebois [Mon, 16 Aug 2021 19:19:16 +0000 (21:19 +0200)]
Improve wording (there's only one kernel)
Cyril Brulebois [Mon, 16 Aug 2021 19:30:14 +0000 (21:30 +0200)]
Add emphasis for the y/m values
Cyril Brulebois [Mon, 16 Aug 2021 19:40:40 +0000 (21:40 +0200)]
Fix various typos
Cyril Brulebois [Mon, 16 Aug 2021 19:02:55 +0000 (21:02 +0200)]
Mention pr_info() rather than KERN_INFO
The latter might have been used along with printk() in an earlier
version, but pr_info() is getting used consistently so adjust the
#include comments accordingly.
For the avoidance of doubt, pr_info() actually comes from printk.h,
which gets #include'd by kernel.h.
fennecJ [Mon, 16 Aug 2021 16:23:22 +0000 (00:23 +0800)]
Improve the descriptions about reference count (#62)
The term "reference count" would be better than "use count."
In addition, the usage of module_refcount(THIS_MODULE) was appended
for the reference counter query.
Jim Huang [Mon, 16 Aug 2021 16:11:37 +0000 (00:11 +0800)]
Merge pull request #63 from fennecJ/patch2
Fix typo
fennecj [Mon, 16 Aug 2021 15:48:04 +0000 (23:48 +0800)]
Fix typo
Jim Huang [Mon, 16 Aug 2021 13:21:10 +0000 (21:21 +0800)]
Use \verb for the identifiers starting with "--"
Jim Huang [Mon, 16 Aug 2021 12:19:35 +0000 (20:19 +0800)]
Remove never implemented MODULE_SUPPORTED_DEVICE
MODULE_SUPPORTED_DEVICE is remove from upstream since March 17, 2021.
See linux.git commit
6417f03
Reported by Niklas Lantau <niklaslantau@gmail.com>
Close #61
Chih-Yu Chen [Mon, 16 Aug 2021 10:45:43 +0000 (18:45 +0800)]
Avoid incorrectly separated words (#55)
This patch fixed some typos and added the missing punctuation.
Jim Huang [Mon, 16 Aug 2021 09:24:26 +0000 (17:24 +0800)]
Merge pull request #60 from fennecJ/patch
Fix grammar and typo
fennecj [Sun, 15 Aug 2021 16:47:23 +0000 (00:47 +0800)]
Fix grammar and typo
Jim Huang [Thu, 12 Aug 2021 17:02:21 +0000 (01:02 +0800)]
Annotate more directories/files
Jim Huang [Thu, 12 Aug 2021 16:53:24 +0000 (00:53 +0800)]
Merge pull request #57 from fennecJ/patch
Fix typo
fennecj [Thu, 12 Aug 2021 16:52:33 +0000 (00:52 +0800)]
Fix typo
Jim Huang [Thu, 12 Aug 2021 16:28:37 +0000 (00:28 +0800)]
Merge pull request #56 from bbenno/fix/typo
Fix typo: concurent -> concurrent
Benno Bielmeier [Thu, 12 Aug 2021 07:43:38 +0000 (07:43 +0000)]
Fix typo: concurent -> concurrent
Jim Huang [Wed, 11 Aug 2021 13:01:07 +0000 (21:01 +0800)]
Merge pull request #54 from fennecJ/patch
Fix typo
fennecj [Wed, 11 Aug 2021 10:34:23 +0000 (18:34 +0800)]
Fix typo
Jim Huang [Wed, 11 Aug 2021 07:08:08 +0000 (15:08 +0800)]
Make insmod/rmmod more consistent
Jim Huang [Tue, 10 Aug 2021 10:24:17 +0000 (18:24 +0800)]
Merge pull request #53 from fennecJ/patch
Fix incorrect path
fennecj [Tue, 10 Aug 2021 10:22:33 +0000 (18:22 +0800)]
Fix incorrect path
There should be a space between uname and -r
Jim Huang [Mon, 9 Aug 2021 16:55:56 +0000 (00:55 +0800)]
Merge pull request #51 from ChinYikMing/fix-init-mesg
Fix init message
ChinYikMing [Mon, 9 Aug 2021 16:48:19 +0000 (00:48 +0800)]
Fix init message
Jim Huang [Mon, 9 Aug 2021 15:59:59 +0000 (23:59 +0800)]
Remove out-of-date information
Jim Huang [Mon, 9 Aug 2021 15:57:30 +0000 (23:57 +0800)]
Annotate NULL
Jim Huang [Mon, 9 Aug 2021 15:46:37 +0000 (23:46 +0800)]
Fix wording
Jim Huang [Mon, 9 Aug 2021 15:26:01 +0000 (23:26 +0800)]
Point to corresponding kernel header
Jim Huang [Mon, 9 Aug 2021 15:23:08 +0000 (23:23 +0800)]
Annotate more commands
Jim Huang [Mon, 9 Aug 2021 15:01:34 +0000 (23:01 +0800)]
Introduce \src to generate Linux kernel source hyperlinks
The new command \src was introduced for preliminary hyperlink generation
which points to Linux kernel source code. At present, stable/linux.git
was referred:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
We might switch to specific LTS kernels once requested.
Jim Huang [Mon, 9 Aug 2021 14:37:20 +0000 (22:37 +0800)]
Revise the path of Linux kernel headers
This patch uses the relative path to Linux kernel headers in source tree
rather than what they are usually inclused in LKM. It would be great to
introduce \href with appropriate hyperlinks to Linux kernel tree.
Jim Huang [Mon, 9 Aug 2021 14:05:08 +0000 (22:05 +0800)]
Clarify kernel header inclusion
Both <linux/module.h> and <linux/kernel.h> are essential headers, and
LKM should include them. Here, we do not use the fully qualified path
specifying the headers.
Jim Huang [Mon, 9 Aug 2021 14:00:57 +0000 (22:00 +0800)]
Change the header file which defines sys_delete_module
Jim Huang [Mon, 9 Aug 2021 13:41:50 +0000 (21:41 +0800)]
Annotate function calls
Jim Huang [Mon, 9 Aug 2021 13:35:19 +0000 (21:35 +0800)]
Annotate more commands
Jim Huang [Mon, 9 Aug 2021 13:19:40 +0000 (21:19 +0800)]
Annotate 'mknod' command
Jim Huang [Mon, 9 Aug 2021 13:17:22 +0000 (21:17 +0800)]
Add hyperlinks to microkernel examples
Jim Huang [Mon, 9 Aug 2021 13:12:04 +0000 (21:12 +0800)]
Update tLDP hyperlink
Jim Huang [Mon, 9 Aug 2021 13:11:15 +0000 (21:11 +0800)]
Add hyperlink to Understanding The Linux Kernel
Jim Huang [Mon, 9 Aug 2021 13:07:35 +0000 (21:07 +0800)]
Fix layout with \LaTeX
Jim Huang [Mon, 9 Aug 2021 12:53:35 +0000 (20:53 +0800)]
Always mention \LaTeX rather than plain text form
Jim Huang [Mon, 9 Aug 2021 12:51:12 +0000 (20:51 +0800)]
Fix cross reference
Jim Huang [Mon, 9 Aug 2021 12:40:09 +0000 (20:40 +0800)]
Use the newer entries for Linux kernel documentation
Jim Huang [Mon, 9 Aug 2021 12:35:24 +0000 (20:35 +0800)]
Annotate the path
Jim Huang [Mon, 9 Aug 2021 12:31:03 +0000 (20:31 +0800)]
Remove out-of-date kernel source descriptions
Jim Huang [Mon, 9 Aug 2021 12:23:12 +0000 (20:23 +0800)]
Update .gitignore
Jim Huang [Mon, 9 Aug 2021 12:20:38 +0000 (20:20 +0800)]
Unify the annotations
This patch enforces the annotations by means of the following:
* \cpp : C/C++ code, functions, variables, macros, symbols
* \sh : commands, executable files
* \verb : path and filenames
Jim Huang [Mon, 9 Aug 2021 11:20:35 +0000 (19:20 +0800)]
Merge pull request #49 from henrybear327/latex/add_very_style_inline_code
Add \cpp and \sh syntax for inline code
Chun-Hung Tseng [Mon, 9 Aug 2021 06:37:46 +0000 (23:37 -0700)]
Add inline code blocks by using newmintinline
We can now use \cpp|...| and \sh|...| to add inline code blocks, which
resembles the \verb|...| syntax
Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
Jim Huang [Mon, 9 Aug 2021 09:27:05 +0000 (17:27 +0800)]
Merge pull request #50 from VxTeemo/patch-1
Fix minor typo
VxTeemo [Mon, 9 Aug 2021 09:21:56 +0000 (17:21 +0800)]
fix minor typo
verb warp wrong at line 330 "linux/.config"
Jim Huang [Mon, 9 Aug 2021 05:24:13 +0000 (13:24 +0800)]
Merge pull request #48 from fennecJ/patch
Temporary fix release action failed issue
fennecj [Mon, 9 Aug 2021 05:04:12 +0000 (13:04 +0800)]
Temporary fix release action failed issue
Jim Huang [Sun, 8 Aug 2021 18:37:34 +0000 (02:37 +0800)]
Merge pull request #47 from fennecJ/patch
Remove _minted-lkmpg directory after compiled pdf
fennecj [Sun, 8 Aug 2021 18:14:24 +0000 (02:14 +0800)]
Remove _minted-lkmpg directory after compiled pdf
The _minted-lkmpg directory should be removed AFTER all compile work is
done.
Jim Huang [Sat, 7 Aug 2021 20:59:03 +0000 (04:59 +0800)]
Merge pull request #46 from arushsharma24/patch-1
Fix typo
Arush Sharma [Sat, 7 Aug 2021 20:53:07 +0000 (02:23 +0530)]
fix minor typo
Fixes a very minor typo.
Jim Huang [Sat, 7 Aug 2021 17:50:42 +0000 (01:50 +0800)]
Make program style consistent again
Hsin-Hsiang Peng [Sat, 7 Aug 2021 17:29:50 +0000 (01:29 +0800)]
Fix alignment problem in code block (#45)
In rendered HTML, the line number should be right aligned, and
code should be left aligned accordingly.
In addition, this patch added the basic build instructions, so that
someone can generated the PDF and HTML files.
Close #44
Jim Huang [Sat, 7 Aug 2021 17:24:59 +0000 (01:24 +0800)]
Apply editorial changes
This patch makes source listing shorter and more compact, that helps
when browsing.
Jim Huang [Sat, 7 Aug 2021 16:29:24 +0000 (00:29 +0800)]
Drop the deprecated init_module() and cleanup_module()
Jim Huang [Sat, 7 Aug 2021 15:33:37 +0000 (23:33 +0800)]
Enforce consistent style
Execute "make indent" before submitting patches.
Jim Huang [Sat, 7 Aug 2021 10:53:06 +0000 (18:53 +0800)]
Mention the availability of PDF pre-release
Jim Huang [Sat, 7 Aug 2021 10:49:24 +0000 (18:49 +0800)]
Tweak pdfLaTeX related commands
Jim Huang [Sat, 7 Aug 2021 10:35:28 +0000 (18:35 +0800)]
Tidy the rest of chapters