xyve7 / mubsan

Minimal implementation of UBSAN

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mubsan

Minimal implementation of UBSAN, which can be utilized inside kernels.

Note

I understand some of the code is a bit repetitive and an eyesore, I'm currently thinking of ways to reduce the repetitive nature of the code, while also making sure it doesn't over complicated it

This isn't complete yet, however if you want to test it, fork the repository and run:

$ make

Usage

Statically link the mubsan.c file with your existing project.
Then, define a function with the following signature:

int mubsan_log(const char* format, ...) {
    // code
}

This function should accepting a formatted string and print it to the screen, however, how you implement it is up to you.

Running the test with the aforementioned instructions will yield this output, then exit:

mubsan @ test.c:21:8: array out of bounds, for type 'int [4]', by index type 'int' 4

Credit

So, finding documentation for this was pretty abysmal, so I had to utilize other implementations and using them as reference.
However, the only main reference I even used was GCC itself, however, I'll credit the others that I viewed anyways.

OSDev Wiki Page on UBSAN
GCC Mirror
Sortix
optee_os
tinyubsan
barebones
dgos

About

Minimal implementation of UBSAN

License:MIT License


Languages

Language:C 94.1%Language:Makefile 5.9%