Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohit Chourasia committed Nov 26, 2021
0 parents commit 39fe466
Show file tree
Hide file tree
Showing 8 changed files with 1,222 additions and 0 deletions.
1 change: 1 addition & 0 deletions .built-in.a.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmd_my_precious/built-in.a := rm -f my_precious/built-in.a; ar cDPrST my_precious/built-in.a my_precious/my_precious.o
1 change: 1 addition & 0 deletions .modules.order.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmd_my_precious/modules.order := { :; } | awk '!x[$$0]++' - > my_precious/modules.order
1,186 changes: 1,186 additions & 0 deletions .my_precious.o.cmd

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj-y := my_precious.o
5 changes: 5 additions & 0 deletions built-in.a
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
!<thin>
// 16 `
my_precious.o/

/0 0 0 0 644 329472 `
Empty file added modules.order
Empty file.
28 changes: 28 additions & 0 deletions my_precious.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <linux/kernel.h>
#include <linux/syscalls.h>
#include <linux/sched.h>
#include <linux/mm_types.h>
#include <linux/mm.h>
#include <linux/uaccess.h>
#include <linux/slab.h>
#include <linux/gfp.h>

SYSCALL_DEFINE1(my_precious, void *, kaddress)
{
struct task_struct *p = current;
struct vm_area_struct *q = p->mm->mmap;
struct vm_area_struct *vm_pointer = q;

while(!vma_is_anonymous(vm_pointer))
vm_pointer = vm_pointer->vm_next;

unsigned long size = vm_pointer->vm_end - vm_pointer->vm_start;
kaddress = kmalloc(size, GFP_USER);
unsigned long a = copy_from_user(kaddress, vm_pointer->vm_start, size);
if(a == 0) {
printk("System call executed successfully\n");
return 0;
}
else
return -1;
}
Binary file added my_precious.o
Binary file not shown.

0 comments on commit 39fe466

Please sign in to comment.