LWSS / Cartographer

Linux Kernel Module to spoof /proc maps
66 stars 8 forks source link

Looks like broken on linux 5.6 kernel #7

Closed kolay-v closed 4 years ago

kolay-v commented 4 years ago

It fails with compilation error.

 error: passing argument 4 of ‘proc_create’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  299 |     struct proc_dir_entry *entry = proc_create(PROC_FILENAME, 0, NULL, &file_ops);
      |                                                                        ^~~~~~~~~
      |                                                                        |
      |                                                                        struct file_operations 

My kernel is Linux kolay-arch 5.6.2-1-MANJARO #1 SMP PREEMPT Thu Apr 2 11:32:09 UTC 2020 x86_64 GNU/Linux

aw1cks commented 4 years ago

Problem seems to be due to deprecation of file_operations. Solution is to move to proc_ops. Below patch should work although it's inelegant (won't work on older kernel versions where proc_ops does not exist - I'll make it nicer later and send over a PR)


index 763a3c4..565bea1 100644
--- a/cartographer.c
+++ b/cartographer.c
@@ -245,7 +245,9 @@ end:
 }

 static struct ftrace_hook show_map_vma_hook;
-static struct file_operations file_ops;
+static struct proc_ops file_ops = {
+    .proc_write = on_write,
+};

 /* Search for a symbol in kallsyms. Some contain version specific suffixes */
 static int on_each_symbol(void *data, const char *name,
@@ -309,9 +311,6 @@ static int cart_startup(void)
         return -ENOMEM;
     }

-    file_ops.owner = THIS_MODULE;
-    file_ops.write = on_write;
-
     cart_print("Cartographer Loading complete.\n");
     return 0;
 }
aw1cks commented 4 years ago

https://github.com/LWSS/Cartographer/pull/8 fixes this.