Commit Graph

146 Commits

Author SHA1 Message Date
Tyler Fanelli
4f0fa3b17c headers: Update header installation for Fedora 2023-07-08 00:00:20 -04:00
Peter Lin
421b9b04fe Introduce static key in optimizations section
This patch introduces static key technique and adds a kernel module
to demostrate how to use static key to optimize an almost unlikely
branch, the module can interact with userspace thru a character device.

Signed-off-by: Peter Lin <peterlin@qilai.dev>
2023-05-02 10:33:36 +08:00
Chih-En Lin
d2d54ca639 Remove sleep_on family
Since the commit b8780c363d80 ("sched: remove sleep_on() and friends
"), the description about sleep_on is incorrect and the example code has
been fixed by replacing it with wait_event family. Let's also fix the
description to match the corrected code.
2023-04-27 10:20:48 +08:00
Chih-En Lin
b0d4204405 Relocate Archlinux code snippet to avoid confusion
Close #185
2023-02-23 21:03:49 +08:00
Andy Shevchenko
b8bbcd8a07 treewide: Replace kernel.h by printk.h
The kernel.h should be discouraged for use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2023-02-23 12:54:30 +02:00
linD026
78e3e062c4 syscall: Use openat() instead of open()
Since sys_open is deprecated and some architectures don't support it.
We switch the implementation to sys_openat.

Moreover, in some architectures like x86-64, the prototype of syscall,
for example, openat(), might have been changed to struct pt_regs [1]
but we cannot promise that so support the two types
(sys_openat and pt_regs).

Also, to prevent other untraced tasks print out the information, add
the uid checking in our_sys_openat().

[1] https://lore.kernel.org/lkml/20180405095307.3730-1-linux@dominikbrodowski.net/

Close #159
2022-12-25 14:27:03 +08:00
Peter Lin
3133ee5293 Add error message when sha256 algorithm is not supported
It failed silently when crypto_alloc_tfm() failed, so add an error
message to inform the developer to enable sha256 algorithm support.

Signed-off-by: Yu Chien Peter Lin <peterlin.tw@pm.me>
2022-12-12 23:07:20 +08:00
Peter Lin
55e7a155fa Fix typo in interrupt handlers section
%s/assembler/assembly language/

Signed-off-by: Yu Chien Peter Lin <peterlin.tw@pm.me>
2022-12-11 14:46:08 +08:00
Iûnn Kiàn-îng
9c25e59b43
Convey secure boot specific considerations (#177) 2022-11-10 22:24:37 +08:00
Johan Calle
9892214764
Fix typo (line 1019) (#174)
Changed "The choose of two different functions depend on whether ..." to
"The choice between two different functions depends on whether ..."
2022-10-24 21:52:05 +08:00
Jim Huang
b950a100f6
Merge pull request #124 from tzuyichan/patch
Fix grammar
2022-10-23 00:28:11 +08:00
Kohei Otsuka
7b38f3713a
Fix typo (#169) 2022-10-05 00:52:07 +08:00
linD026
9db8c92cf5 Improve the description of proc in file-ops
Currently, the description of the proc_ops in the file operation section
will confuse the reader with registering the device. Add more hints to
avoid it.
2022-09-08 08:34:06 +08:00
Chih-En Lin
87bd9ceb34 Adjust "in the mean time" description of tasklet
Since the init function may be interrupted. Tweak the description of
"in the mean time".

Close #152
2022-07-02 22:31:48 +08:00
Chih-En Lin
3d1fb29070 Add more information about the CFI of timer API
Currently, in 13.2 Flashing keyboard LEDs, the description of the
control-flow integrity, "Furthermore, the function prototype with
unsigned long argument may be an obstacle to the control-flow integrity
.", will confuse the reader.

It may lead the reader to think about hardware-assisted CFI like Intel
CET uses the shadow stack attack for ROP (backward-edge protection). But
the description of CFI here talks about the function pointer checking
with the prototype (forward-edge protection).

So add more information to make it more clear.

Close #151
2022-07-01 21:31:08 +08:00
leovincentseles
22ebabe297 module_init and module_exit are defined in module.h
Both module_init and module_exit are defined in
include/linux/module.h
2022-06-25 23:15:48 +08:00
asas1asas200
04465b1a44 Add description of sysfs attribute
The description of the attribute was added in sysfs section and referenced in vinput section.

In vinput section, just described the class_attribute and some macros about sysfs class.

Add file name at vinput-related examples begin.
2022-04-19 01:54:24 +08:00
linD026
6e7eda6398 Fix typo 2022-04-10 20:31:19 +08:00
Jim Huang
3beae490ee
Merge pull request #145 from linD026/master
Introduce Virtual Input Device Driver
2022-04-08 18:15:57 +08:00
linD026
636c1e702d Introduce Virtual Input Device Driver
Add the new section of input device driver, vinput[1].

Also, update the Acknowledgements.

[1] https://github.com/sysprog21/vinput
2022-04-06 17:13:29 +08:00
Jim Huang
d78afd22ac Tweak the style of sudoers file 2022-03-19 02:26:43 +08:00
Jim Huang
19521bc60a Refine wording on module loading
Close #134
2022-03-16 14:32:08 +08:00
Steven Lung
d771c50166 Fix grammar 2022-03-09 14:14:08 +08:00
linD026
d8216ff7b6
Fix incoherent ioctl examples (#139)
Previously ioctl.c is a userspace program for chardev2.c and chardev.h [1].
But now, this file is an independent kernel module, and the original code
disappear.
This patch adds back the original userspace code and renames it to
userspace_ioctl.c.

[1] https://tldp.org/LDP/lkmpg/2.4/html/x856.html
2022-02-21 00:53:29 +08:00
Ching-Hua (Vivian) Lin
fb15882377
Add book cover (#136)
Both PDF and HTML generation are supported.
2022-01-09 20:26:07 +08:00
萌新阿岩
5c0f9b0abc
Update Makefile and Add explanation (#133)
Add `PWD := $(CURDIR)` in Makefile and the explanation about `sudo make`
when only having `PWD`.
2021-12-28 20:45:50 +08:00
RinHizakura
2cc4264f72 Introduce the new method for chardev registration
Instead of using the old register_chrdev / unregister_chrdev API,
cdev interface which is newer and would be better for new driver programmers
in most cases. This commit is trying to give the brief overview for
this different interface.
2021-12-23 21:12:14 -08:00
Jim Huang
e4016013b2 modinfo does not require superuser permission 2021-12-04 16:13:22 +00:00
lyctw
e2a6fcdae9 Fix typo 2021-11-16 14:50:01 +08:00
Jim Huang
d88d0cd227
Merge pull request #123 from fennecJ/patch
Generate contributor list as a modular inclusion
2021-11-08 12:07:57 +08:00
manbing
07a9741f79
Adjust the position of Figure 1 (#126) 2021-11-08 12:06:19 +08:00
fennecJ
af09a8a1e5 Add script to gen contributor list and contrib.tex
This script do mainly 2 things:
1.
Generate file `Contributors` with git log in following format:
Contributor's name,<1-st e-mail>[,<2nd e-mail>][,<3rd e-mail>]...
The 2-nd email and so on are based on file `.mailmap` in the root
directory of the repo.
Note that it will also append contributors in File `Include`; and
will NOT append contributors in File `Exclude`.
If there are new contributors, script will sort `Contributor` after
append new contributors into each file; Otherwise it do nothing.

2.
Generate contrib.tex based on `Contributors` into lib/contrib.tex in
following format:
[name], (reasonable width) % [1-st e-mail]
Which is inspired by The Not So Short Introduction to Latex 2e[1]

We need to maintain `.mailmap`, `Exclude` and `Include` manually.
All Chinese name should be converted into English/Pinyin in `.mailmap`,
otherwise we may need extra pkg for latex to parse Chinese characters.

[1] - https://tobi.oetiker.ch/lshort/lshort.pdf

Close #68
2021-11-03 19:32:48 +08:00
tzuyichan
b95f6f5cf6
Fix grammar
in the hope ... will -> in the hope that ... would
get -> got
where are ... gone -> where have ... gone
For those not -> For those who are not
2021-10-27 05:00:05 +08:00
demonsome
67149719a4
Explain inode at the first occurrence (#115)
The explanation of "inode" should appear at the first occurrence to which readers
can refer.
2021-10-25 22:46:02 +08:00
Jim Huang
28018227fc Remove out-of-date syscall information
Close #121
2021-10-14 20:51:09 +08:00
Jim Huang
151a91ecf4 Fix wording 2021-10-10 21:45:12 +08:00
Marconi Jiang
89755e146a Correct English gramma 2021-09-29 06:41:31 -07:00
Jim Huang
0a176fbb19 Simplify the epilog 2021-09-25 19:53:13 +08:00
Jim Huang
707e193cbe Always run "dmesg" with sudo
The dmesg command allows you to review the messages that are stored in the
ring buffer. Some Linux distributions have strict requirements for
dmesg, and you need to use sudo to use dmesg.
2021-09-25 02:09:13 +08:00
Jim Huang
11e40dc8ef Remove unintended code block 2021-09-25 02:06:26 +08:00
Marconi Jiang
a1c3cca6db
Dump the message of hello-5 explicitly (#112)
Close #111
2021-09-25 02:03:44 +08:00
linD026
1a6fb67cf2
Fix potential concurrent access problems with VFS (#108)
Since Linux v3.14, the read, write and seek operations of "struct file" are
guaranteed for thread safety [1][2]. This patch added an explanation.

Here are the potential problems:
chardev.c:
- Move the "msg_ptr" pointer into the read function to remove unnecessary usage.
- List the clear states of "already_open" by using mnemonic enumeration.

chardev2.c:
- The "buffer" in the write function is user space data. It cannot use in the
  kernel space.
- Reduce the redundant type transformation.
- List the states of "already_open". Same as chardev.c.

[1] https://lore.kernel.org/lkml/20140303210359.26624.qmail@science.horizon.com/T/#u
[2] 9c225f2655
2021-09-23 12:20:10 +08:00
Jim Huang
027f39c0c1 Denote LWN hyperlink 2021-09-23 00:36:42 +08:00
Ylowy
24257e837e
Typo. 2021-09-19 20:39:56 +08:00
Stacy Prowell
728b7fd432
Fixed parameter name for hello-5.
Parameters are case-sensitive, so myintArray is different from myintarray, and people who are running the example with copy/paste will find it doesn't work as described in the text.
2021-09-15 16:05:26 -04:00
Gilad Reti
e8d5bf7fd4
fix typo: compatibiity -> compatibility 2021-09-12 08:54:53 +03:00
Jim Huang
c519f57403 Simplify the wording 2021-09-10 14:19:22 +00:00
linD026
62dbb1b7b8
Adapt the timer API Usage (#98)
Since v4.14 [1], the timer API has been changed to improve memory safety.
The series of improvements ended up at v4.15 [2].

Reference: https://lwn.net/Articles/735887/

Close #97

[1] 686fef928b
[2] 841b86f328
2021-09-10 12:29:48 +08:00
linD026
148fb013ee
Avoid unexpected concurrent access (#94)
In file {chardev,chardev2,sleep}.c, the variable to determine
the exclusive access was of integer type, which led to race
condition.

This patch rewrote the above with atomic CAS respectively
to eliminate the race.

Close #93
2021-09-07 23:42:06 +08:00
ccs100203
56c99328b3 Fix Typo
from "mask" to "masks"
from "quick" to "quickly"
from "a" to "an"
2021-09-03 23:02:17 +08:00