Commit Graph

423 Commits

Author SHA1 Message Date
linD026
eb2c766da4 Improve the compatibility with kernel < v5.10
min()/max() splited from kernel.h to minmax.h since v5.10-rc1.
Before v5.10, minmax.h doesn't exist [1].

[1] b296a6d533
2022-09-21 13:53:06 +08:00
Jim Huang
c69eff9d1f
Merge pull request #163 from linD026/read-write
procfs{2, 3}: Change to use offset parameter
2022-09-08 22:24:20 +08:00
linD026
39a313dc20 procfs{2, 3}: Change to use offset parameter
To make sure the behavior of the read and write operations are correct
with offset, update it each time. Also, since it is using the offset,
modify the part of read for removing unnecessary variable.
2022-09-08 12:53:29 +08:00
Jim Huang
53c2794fdb
Merge pull request #164 from linD026/file-proc_ops
Improve the description of proc in file-ops
2022-09-08 12:22:12 +08:00
Jim Huang
d79fdc8559
Merge pull request #162 from linD026/master
Fix the buffer length may cause a read error
2022-09-08 12:19:42 +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
linD026
95a7ca513f Fix the buffer length may cause a read error
Since The length of the message buffer is BUF_LEN. When writing the
BUF_LEN length of the string it will overwrite the last character
(usually it is '\0' from the initialization). And, because the read
operation uses the character in the message buffer ('\0') to stop the
read loop. It will cause the read operation will read out of the
message buffer when the length parameter of read() is not lower than
or equal to BUF_LEN. So add one more byte space to avoid this problem.
2022-09-08 06:08:04 +08:00
Cheng-En Lee
637e707a1a
Add additional macos installation instruction in README.md (#157)
Signed-off-by: Cheng-En Lee <chengenl@usc.edu>
2022-08-27 10:14:17 +08:00
Jim Huang
cd2ba2447d
Merge pull request #156 from linD026/master
Adjust "in the mean time" description of tasklet
2022-07-02 22:38: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
Jim Huang
2a2cfb5188
Merge pull request #155 from linD026/master
Add more information about the CFI of timer API
2022-07-02 13:49:15 +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
Jim Huang
08eee1abf1
Merge pull request #154 from leovincentseles/master
module_init and module_exit are defined in module.h
2022-06-25 23:39:19 +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
Jim Huang
63ac35dd4f CI: Bump dependency versions 2022-04-28 19:19:29 +08:00
Jim Huang
96e522cb36
Merge pull request #150 from asas1asas200/zeng-feat-attributes
Add description of sysfs attribute
2022-04-19 03:22:04 +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
Jim Huang
565a599342
Merge pull request #149 from linD026/master
Fix potential concurrent problems in chardev2.c
2022-04-17 02:52:15 +08:00
linD026
beb1ff1595 Fix potential concurrent problems in chardev2.c
After forking, Each file descriptor in the child refers to the same
open file description as the parent. So when calling open() before
fork(), the child can access the device file without checking by
exclusive access in device_open(). It may cause race conditions
in device_ioctl().

Because of that, it is unnecessary to check the multiple access
in device_open(). It just needs check in device_ioctl(), since
read(), write(), seek() system call are atomic [1][2].

Related discussion:
- https://github.com/sysprog21/lkmpg/issues/148

[1] https://lore.kernel.org/lkml/53022DB1.4070805@gmail.com/
[2] https://www.kernel.org/doc/html/latest/filesystems/files.html

Close #148
2022-04-17 02:41:25 +08:00
Jim Huang
aa4b5d7421
Merge pull request #147 from linD026/master
Fix wrong regular expression of clang-format
2022-04-10 22:59:12 +08:00
linD026
9f92fe4d6a Fix wrong regular expression of clang-format 2022-04-10 22:51:59 +08:00
Jim Huang
afc4f6bf56
Merge pull request #146 from linD026/master
Fix typo
2022-04-10 21:38:52 +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
413c7d54cd
Merge pull request #144 from henrybear327/improvement/latexmk
Use latexmk instead of pdflatex for PDF generation
2022-03-18 20:20:41 +01:00
Chun-Hung Tseng
16fe2e9eb0 Update README and Makefile for the latexmk existence check
Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2022-03-18 20:16:02 +01:00
Jim Huang
d78afd22ac Tweak the style of sudoers file 2022-03-19 02:26:43 +08:00
Chun-Hung Tseng
d27d2c2301 Update .gitignore files to ignore latexmk tmp files
Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2022-03-18 19:10:23 +01:00
Chun-Hung Tseng
adb2d21af2 Fix the pdf generation code in Makefile
The current Makefile is missing one more pdflatex pass.

The correct steps are : pdflatex -> bibtex -> pdflatex -> pdflatex [1]. Otherwise, bib items will not be showing properly.

[1] https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#latex-recipes

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2022-03-18 19:10:23 +01:00
Jim Huang
60bed94bad
Merge pull request #143 from linD026/master
Improve the description of finding syscall table
2022-03-17 08:13:26 +08:00
linD026
85ee0ec67b Improve the description of finding syscall table
Presently, the representation of showing which version will use the
method to find out the system call table is vague.

Related discussion:
* sysprog21/lkmpg: https://github.com/sysprog21/lkmpg/pull/142
2022-03-17 07:51:59 +08:00
Jim Huang
19521bc60a Refine wording on module loading
Close #134
2022-03-16 14:32:08 +08:00
Jim Huang
356723c824
Merge pull request #141 from steven1lung/master
Fix grammar and typo
2022-03-09 14:23:17 +08:00
Steven Lung
d771c50166 Fix grammar 2022-03-09 14:14:08 +08:00
Jim Huang
ef2939ef61
Merge pull request #140 from steven1lung/master
Fix typo, grammar and remove duplicated words
2022-03-07 17:11:05 +08:00
Steven Lung
5ca9b642a4 Fix typo, grammar and remove duplicated words
Replaced 'a' with 'an' since a vowel sound is after.
2022-03-07 16:56:13 +08:00
Bob Lee
844beed5d7
Fix a logic error in examples/ioctl.c (#137)
Change the "alloc_ret" and "cdev_ret" initial values to non-zero.
According to the source code, "alloc_chrdev_region" and "cdev_add"
return zero on success, and negative code on failure.

So, if the "alloc_chrdev_region" failed, the if condition becomes true,
then we will jump to the label "error" by goto, checking each return
value whether is a success state from both functions mentioned above
and dealing with it properly for exiting the process.

However, it checks the success state by comparing the return value
with zero (means success), and we got "cdev_ret == 0" is true from
the initial value zero, while we didn't execute "cdev_add" yet.
Hence, there was a logic error when the initial value is zero.

Co-authored-by: NOVBobLee <defru04002@gamil.com>
2022-02-21 00:58:47 +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
Jim Huang
785c2fe600
Merge pull request #135 from RinHizakura/master
Revise chardev registration
2021-12-25 14:48:13 +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
Jim Huang
b4ba4cfc9b
Merge pull request #130 from lyctw/master
Fix typo
2021-11-16 16:01:56 +08:00
lyctw
e2a6fcdae9 Fix typo 2021-11-16 14:50:01 +08:00
Jim Huang
17162018fe
Merge pull request #128 from sudoliyang/patch-2
Fix typo
2021-11-08 22:30:20 +08:00
Jim Huang
19b4d4bd22
Merge pull request #127 from sudoliyang/patch-1
Fix typo
2021-11-08 22:14:16 +08:00
Liyang Zhang
f07d5d564d
Fix typo 2021-11-08 22:10:21 +08:00
Liyang Zhang
f5600a4ead
Fix typo 2021-11-08 22:07:08 +08:00