Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

Fixes #18 -- call the kernel's BUG macro when we panic #19

Merged
merged 2 commits into from
May 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ script:
- cd $MODULE_DIR
- RUST_TARGET_PATH="$(pwd)/.." cargo xbuild --target x86_64-linux-kernel-module
- make
- sudo dmesg -C
- sudo insmod "${MODULE}.ko"
- sudo rmmod "$MODULE"

after_failure:
- dmesg

notifications:
email: false
8 changes: 7 additions & 1 deletion src/helpers.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include <linux/bug.h>
#include <linux/printk.h>

int printk_helper(const unsigned char *s, int len)
{
return printk(KERN_INFO "%.*s", len, (const char *)s);
return printk(KERN_INFO "%.*s", len, (const char *)s);
}

void bug_helper(void)
{
BUG();
}
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,18 @@ pub trait KernelModule: Sized {
fn init() -> KernelResult<Self>;
}

extern "C" {
fn bug_helper() -> !;
}

#[lang = "eh_personality"]
extern "C" fn eh_personality() {}

#[lang = "panic_fmt"]
extern "C" fn panic_fmt() -> ! {
loop {}
unsafe {
bug_helper();
}
}

#[global_allocator]
Expand Down