870b26fa2d
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/
45 lines
968 B
C
45 lines
968 B
C
/*
|
|
* example_tasklet.c
|
|
*/
|
|
#include <linux/delay.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
|
|
/* Macro DECLARE_TASKLET_OLD exists for compatibiity.
|
|
* See https://lwn.net/Articles/830964/
|
|
*/
|
|
#ifndef DECLARE_TASKLET_OLD
|
|
#define DECLARE_TASKLET_OLD(arg1, arg2) DECLARE_TASKLET(arg1, arg2, 0L)
|
|
#endif
|
|
|
|
static void tasklet_fn(unsigned long data)
|
|
{
|
|
pr_info("Example tasklet starts\n");
|
|
mdelay(5000);
|
|
pr_info("Example tasklet ends\n");
|
|
}
|
|
|
|
DECLARE_TASKLET_OLD(mytask, tasklet_fn);
|
|
|
|
static int example_tasklet_init(void)
|
|
{
|
|
pr_info("tasklet example init\n");
|
|
tasklet_schedule(&mytask);
|
|
mdelay(200);
|
|
pr_info("Example tasklet init continues...\n");
|
|
return 0;
|
|
}
|
|
|
|
static void example_tasklet_exit(void)
|
|
{
|
|
pr_info("tasklet example exit\n");
|
|
tasklet_kill(&mytask);
|
|
}
|
|
|
|
module_init(example_tasklet_init);
|
|
module_exit(example_tasklet_exit);
|
|
|
|
MODULE_DESCRIPTION("Tasklet example");
|
|
MODULE_LICENSE("GPL");
|