3

The Linux Debian family 4.10 and later seem to have some rules affecting kernel modules. When trying to add a hook list while building a kernel module, we get an undefined symbolic link error as shown below.

WARNING: "security_add_hooks" [home/kernel/driver.ko] undefined!

In the /include/linux/lsm_hook.h file, functions that were previously implemented as inline have been changed to extern so that the implementation is omitted and dependent on the object.

extern void security_add_hooks(struct security_hook_list *hooks, int count, char *lsm);

How should I solve it?

Thanks in advance.

Charles
  • 31
  • 1
  • 1
    The function `security_add_hooks` **cannot be used** in kernel **modules** in any Linux kernel version. Before 4.11 version the function was `static inline` but uses `extern` variable `security_hook_heads` which is **not exported** for modules (via `EXPORT_SYMBOL`). Since 4.11 version the function become `extern` and is not exported for modules. Moreover, [it has](https://elixir.bootlin.com/linux/v5.4.10/source/security/security.c#L443) `__init` attribute, so it can be called only at the kernel's initialization stage. – Tsyvarev Jan 10 '20 at 09:06

0 Answers0