Guest User

Untitled

a guest
Nov 16th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <linux/module.h>
  2. #include <linux/kernel.h>
  3. #include <linux/init.h>
  4.  
  5. static void blatant_div_by_zero(void)
  6. {
  7. int q, d;
  8.  
  9. d = 0;
  10. asm volatile ("movl $20, %%eax;"
  11. "movl $0, %%edx;"
  12. "1: div %1;"
  13. "movl %%eax, %0;"
  14. "2:\t\n"
  15. "\t.section .fixup,\"ax\"\n"
  16. "3:\tmov\t$-1, %0\n"
  17. "\tjmp\t2b\n"
  18. "\t.previous\n"
  19. _ASM_EXTABLE(1b, 3b)
  20. : "=r"(q)
  21. : "b"(d)
  22. :"%eax"
  23. );
  24.  
  25. pr_debug("q = %d\n", q);
  26. }
  27.  
  28. static int __init hello_init(void)
  29. {
  30. blatant_div_by_zero();
  31.  
  32. return 0;
  33. }
  34.  
  35. static void __exit hello_exit(void)
  36. {
  37. pr_info("hello_exit\n");
  38. }
  39.  
  40. module_init(hello_init);
  41. module_exit(hello_exit);
  42.  
  43. MODULE_LICENSE("GPL");
  44. MODULE_AUTHOR("Okash Khawaja");
  45. MODULE_DESCRIPTION("hello world");
Add Comment
Please, Sign In to add comment