mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
bring CONFIG_FORTIFY_SOURCE back from accidental removal...
Notice that it is not working anymore. Rename pci.c into qemu_edu.c Organize kernel_module readmes further
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
= kernel_module
|
||||
|
||||
Our kernel modules!
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#directory-structure
|
||||
|
||||
. Asynchronous
|
||||
.. link:irq.c[]
|
||||
@@ -9,7 +7,3 @@ Our kernel modules!
|
||||
.. link:timer.c[]
|
||||
.. link:work_from_work.c[]
|
||||
.. link:workqueue_cheat.c[]
|
||||
. Hardening
|
||||
.. link:strlen_overflow.c[]
|
||||
. Tracing
|
||||
.. link:kprobe_example.c[]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#file-operations */
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/errno.h> /* EFAULT */
|
||||
#include <linux/fs.h> /* file_operations */
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#kprobes
|
||||
*
|
||||
* Adapted from: https://github.com/torvalds/linux/blob/v4.17/samples/kprobes/kprobe_example.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE: This example is works on x86 and powerpc.
|
||||
* Here's a sample kernel module showing the use of kprobes to dump a
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#pci_min */
|
||||
|
||||
#include <linux/cdev.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
ARM only.
|
||||
*/
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#pmccntr */
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/errno.h> /* EFAULT */
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#qemu-edu */
|
||||
|
||||
#include <linux/cdev.h> /* cdev_ */
|
||||
#include <linux/fs.h>
|
||||
#include <linux/init.h>
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
https://www.reddit.com/r/hacking/comments/8h4qxk/what_a_buffer_overflow_in_the_linux_kernel_looks/
|
||||
*/
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#config_fortify_source */
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
@@ -8,6 +6,7 @@ https://www.reddit.com/r/hacking/comments/8h4qxk/what_a_buffer_overflow_in_the_l
|
||||
|
||||
static int myinit(void)
|
||||
{
|
||||
/* Missing terminaing NUL '\0'. */
|
||||
char buf[] = {'p', 'w', 'n'};
|
||||
pr_info("%llu\n", (long long unsigned)strlen(buf));
|
||||
return 0;
|
||||
|
||||
@@ -1,25 +1,15 @@
|
||||
= user
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#rootfs_overlay
|
||||
|
||||
Userland C programs used to test our kernel modules.
|
||||
|
||||
`sh` programs are simpler, and installed by copying directly with an overlay.
|
||||
|
||||
C programs require cross compiling, but give us more control over system calls.
|
||||
|
||||
These programs can also be compiled and used on host.
|
||||
|
||||
. Standalone
|
||||
.. link:hello.c[]
|
||||
.. link:hello_cpp.cpp[]
|
||||
.. link:sched_getaffinity.c[]
|
||||
.. link:usermem.c[]
|
||||
... link:pagemap_dump.c[]
|
||||
.. inits
|
||||
.... link:sleep_forever.c[]
|
||||
.... link:poweroff.c[]
|
||||
.... link:init_dev_kmsg.c[]
|
||||
.. link:uio_read.c[]
|
||||
.. link:rand_check.c[]
|
||||
.. x86_64
|
||||
... link:rdtsc.c[]
|
||||
... link:ring0.c[]
|
||||
. link:hello.c[]
|
||||
. link:hello_cpp.cpp[]
|
||||
. link:sched_getaffinity.c[]
|
||||
. link:usermem.c[]
|
||||
.. link:pagemap_dump.c[]
|
||||
. inits
|
||||
... link:sleep_forever.c[]
|
||||
... link:poweroff.c[]
|
||||
... link:init_dev_kmsg.c[]
|
||||
. link:uio_read.c[]
|
||||
. link:rand_check.c[]
|
||||
. x86_64
|
||||
.. link:rdtsc.c[]
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
This file is licensed under the GPL v2 (http://www.gnu.org/licenses/gpl2.txt) (some parts was originally borrowed from proc events example)
|
||||
|
||||
https://stackoverflow.com/questions/6075013/detect-launching-of-programs-on-linux-platform/8255487#8255487
|
||||
*/
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#config_proc_events
|
||||
*
|
||||
* Adapted from: https://stackoverflow.com/questions/6075013/detect-launching-of-programs-on-linux-platform/8255487#8255487
|
||||
*/
|
||||
|
||||
#if defined(__aarch64__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user