Commit Graph

411 Commits

Author SHA1 Message Date
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
Jim Huang
a284eabdb5
Merge pull request #202 from linD026/master
CI: Switch Smatch source code to GitHub mirror
2023-05-01 23:48:53 +08:00
Chih-En Lin
16e0656b2d CI: Switch Smatch source code to GitHub mirror
Since the Smatch repository is unavailable recently [1], let's switch
to GitHub mirror, https://github.com/error27/smatch.git [2], instead
of using https://repo.or.cz/smatch.git.

[1] https://lore.kernel.org/all/Y1qf7w%2Fjo8FH5I8G@kadam/
[2] https://lore.kernel.org/all/20220810105926.GS3460@kadam/
2023-05-01 23:36:23 +08:00
Jim Huang
ed0b93c152
Merge pull request #198 from linD026/master
Remove sleep_on family
2023-04-27 11:28:05 +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
Jim Huang
cc37e59a63 Fix macOS prerequisites 2023-03-26 09:21:53 +08:00
Jim Huang
6eb7bd5d23
Merge pull request #193 from linD026/master
procfs: Enforce Linux naming style
2023-03-24 12:23:24 +08:00
Chih-En Lin
23c0a73c78 procfs: Enforce Linux naming style 2023-03-24 11:36:33 +08:00
Jim Huang
45ac4087d0
Merge pull request #189 from linD026/master
Improve the compatibility and fix the missing header
2023-03-14 09:01:22 +08:00
linD026
4ee80a3e16 completion: Improve the compatibility with v5.17+
Since v5.17-rc1, particularly after the commit cead1855266 ("exit:
Rename complete_and_exit to kthread_complete_and_exit"),
complete_and_exit() is renamed to kthread_complete_and_exit().

Close #188
2023-03-14 08:26:19 +08:00
linD026
8a5879a0fa chardev2: Fix missing header for {get, put}_user 2023-03-14 08:15:06 +08:00
Jim Huang
cdf7b42ac1
Merge pull request #187 from linD026/master
Relocate Archlinux code snippet to avoid confusion
2023-02-23 21:58:20 +08:00
Chih-En Lin
b0d4204405 Relocate Archlinux code snippet to avoid confusion
Close #185
2023-02-23 21:03:49 +08:00
Jim Huang
a91431a2e3
Merge pull request #186 from ashevche/kernel.h
Discourage kernel.h usage and other header cleanups
2023-02-23 20:33:11 +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
Andy Shevchenko
e62dff0df4 treewide: Clean up the headers
The rule of thumb is to include the headers we are the direct user of.
In particular, if we need an atomic API, we include <linux/atomic.h>.

On the other hand we should not use headers for no reason. In particular,
if we are not doing any IRQ job, why is the <linux/irq.h> included?

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2023-02-23 12:54:30 +02:00
Andy Shevchenko
e07bf16bfd devicemodel: Remove duplicate owner assignment
platform_driver_register() macro already does the correct assignment for
the owner of the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2023-02-21 23:04:41 +02:00
Jim Huang
53f4b4c640
Merge pull request #184 from linD026/master
syscall: Use openat() instead of open()
2022-12-25 20:24:10 +08: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
Jim Huang
2f5fd9a75d
Merge pull request #183 from linD026/master
example/syscall: Fix typo and unmatch types
2022-12-25 12:50:15 +08:00
linD026
6062f64bcf example/syscall: Fix typo and unmatch types 2022-12-25 12:33:52 +08:00
Jim Huang
0decb83073
Merge pull request #182 from lyctw/master
Add error message when sha256 algorithm is not supported
2022-12-13 01:11:45 +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
Jim Huang
d249317c87
Merge pull request #181 from lyctw/master
Fix typo in interrupt handlers section
2022-12-11 16:49:44 +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
Jim Huang
1c916a79a9 CI: Bump validation host versioning
The CI is now running on Ubuntu 22.04-LTS along with gcc-11 and
clang-format-12 .
2022-12-10 06:21:02 +08:00
Jim Huang
c6b59d2a8f CI: Bump dependency versions 2022-12-10 06:11:09 +08:00
Jim Huang
0fe984fd04 Make the naming for GitHub Actions more consistent 2022-12-10 06:07:56 +08:00
Iûnn Kiàn-îng
9c25e59b43
Convey secure boot specific considerations (#177) 2022-11-10 22:24:37 +08:00
Jim Huang
910715dab6
Merge pull request #176 from linD026/master
vinput: Fix missing error code
2022-11-04 01:35:33 +08:00
Chih-En Lin
d81d968b0e vinput: Fix missing error code
Fix the missing error code when register_chrdev() failed.
The report is from Smatch:

Smatch failed: 1 warning(s), 0 error(s)
/home/runner/work/lkmpg/lkmpg/examples/vinput.c:372 vinput_init() warn: missing error code 'err'
2022-11-04 01:16:14 +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
Jim Huang
d2ddcccce3 Fix dead link
Close #173
2022-10-21 09:36:47 +08:00
Kohei Otsuka
7b38f3713a
Fix typo (#169) 2022-10-05 00:52:07 +08:00
Jim Huang
760df73743
Merge pull request #168 from linD026/master
Fix dereference NULL pointer with proc_lseek
2022-09-23 13:52:06 +08:00
Jim Huang
422f387ae3
Merge pull request #167 from linD026/minmax
Improve the compatibility with kernel < v5.10
2022-09-23 13:51:25 +08:00
linD026
0f9c72631c Fix dereference NULL pointer with proc_lseek
Since the operations are static storage duration, the pointer in
operation structures will initialize with NULL. But, the kernel
doesn't check whether the pointer is NULL or not when calling it.

Related Discussion:
- https://github.com/sysprog21/lkmpg/issues/165
- https://github.com/sysprog21/lkmpg/issues/160

Close #165
2022-09-21 16:57:23 +08:00
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