Project Lunatik: Using Lua to Expand Linux Kernel Functionality
Project Lunatik is developing tools that allow users to utilize Lua’s language to enhance the functionality of the Linux kernel and quickly create scripts that operate at the kernel level. In order to execute the code, a modified Lua interpreter, available here, is used to work at the kernel level. The project’s code is written in the SI language and distributed under the MIT license.
A special driver is utilized to load and execute Lua scripts at the kernel level, along with a command line utility provided to manage Lua operations within the kernel from user space. Additionally, the project offers an API for controlling the loading and execution of Lua scripts from the Linux kernel, enabling users to implement Lua handlers from traditional kernel modules written in the SI language. Lua API and a set of bindings are available to interact with the kernel functions from Lua code.
When writing Lua scripts, users are limited to a subset of library functions and capabilities due to the constraints of working within the kernel. Some functionalities are not supported, such as file operations and the libraries Io, os, and various functions in the Math library. The API does not include support for lual_stream, lual_execressult, lual_fileresult, luaopen_io, and luaopen_os functions.
The command line utility offers various functions such as loading, unloading, and restarting Lunatik modules in the kernel, displaying the status of loaded modules, listing executed scripts in the kernel, starting and stopping the Runtime Lua in the kernel, and using the interactive Read-Eval-Print Loop (Repl).
In addition to these features, the project provides a set of examples to showcase Lunatik’s capabilities. These examples include scripts implementing a symbolic device driver, a network sniffer with MAC address logging, a key/value data storage database, an ECHO protocol server, keyloggers, a keyboard lock feature, monitoring system calls