linux – writing simple lsm in kernel 5.x

I’m trying to write a simple lsm module that also do nothing. but I have several problems.

static int rdwn_task_kill(
    struct task_struct* p,
    struct siginfo *info,
    int sig, 
    u32 secid
) {
        return 0;

static struct security_hook_list rdwn_hooks() = {
        LSM_HOOK_INIT(task_kill, rdwn_task_kill)

static __init rdwn_init(void) {
    security_add_hooks(rdwn_hooks, ARRAY_SIZE(rdwn_hooks), "rdwn");

    printk(KERN_INFO "RDWN:  Initializing.n");

    return 0;

// How to load module??     

as you know, writing and loading lsm was more simple in the previous versions of kernel.
but now, acutely I’m confused about this. before, there was some functions like security_initcall. but what about now??? how can I load lsm in kernel 5 and later?? I had a look at other lsm codes like selinux and apparmor and they was used macro DEFINE_LSM that defines a struct and nothing more (actually I don’t see any more). Is it enough? and is it right way to loading lsm? what’s happens if I use module_init instance all of them??? finally what is true way to register and load a lsm into kernel?

other question: when I compile above code (when I complete that), I get something like this errors:

error modpost: security_add_hooks undefined! 

error modpost: security_hook_heads undefined! 

what is this? and why I getting this errors?? the interesting note is when I implement my own struct_add_hooks and security_hook_heads (exactly same but changing in their names), this error disappeared. why?

any one can help me to implement a good lsm? 🙂