Code Monkey home page Code Monkey logo

lunatik-ng's Introduction

lunatik-ng

This repository contains the ongoing effort of porting the Lunatik Lua engine to current Linux kernels. There are a few differences between the original lunatik and lunatik-ng:

  • Lunatik-ng works on x86_64
  • It is memory-leak free
  • It can be built as loadable modules
  • A few interfaces to the kernel are provided by default:
    • buffer for allocating memory regions in kernel space
    • crypto which provides bindings to the SHA1 implementation in the kernel (a more advanced interface to the kernel which allows selection of the cipher is in the works) and the random number generator.
    • printk as a direct binding to the kernels printk
    • type and gc_count as bindings to parts of the default Lua library

Uses

This work originated as part of the research project Towards Dynamic Scripted pNFS Layouts (pdf). It is used there to provide "flexible, script based file layouts that describe a logical file's mapping to its storage locations by an interpreted script instead of a fixed mapping".

Try it out

  • Grab the latest Linux kernel tarball from kernel.org (e.g. from here)
  • Extract it to some_folder
  • Copy the contents of this directory structure to some_folder: cp -R this_folder some_folder
  • Build the kernel as usual, make sure to check Library functions -> Lunatik Lua engine
  • The patches add syscall #359 to the kernel. The syscall has the following prototype: SYS_LUA (const char *code, size_t code_sz, char *result, size_t result_sz)
  • To make sure lunatik is working, you can execute the following lua code via the syscall: return type({ 123 }) which should place the string number in result.

Known Bugs

  • Modifying tables with constructs such as buf = { 123 }; buf = foo(buf) may or may not cause the kernel to BUG(). A variant code path that does not expose this bug is contained, which code path disables asynchronous execution of Lua code. This problem is currently investigated.

The buffer library

Calling buffer.new(x) returns a new buffer object of size x. The buffer object represents a char * of length x. Modifying and reading the buffer follows the familiar table interface:

buf = buffer.new(16)
buf[1]  = 100
buf[16] = 255

Buffer objects are used and returned by some of the provided bindings, such as crypto.sha1 and crypto.random.

The Crypto library

The crypto library contains two functions, crypto.sha1 and crypto.random. crypto.random(x) returns a buffer object of size x filled with random data. The function is an almost direct mapping to the kernel's get_random_bytes function.

crypto.sha1(x) returns a buffer of size 20 bytes (one SHA1 hash) and takes as its parameter x a buffer of data to be hashed. At the moment, the size of x is limited to PAGE_SZ, which is 4Kb on most x86 machines.

lunatik-ng's People

Contributors

dbausch avatar farhaven avatar grawinkel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.