• R/O
  • SSH
  • HTTPS

akari: Commit


Commit MetaInfo

Revision663 (tree)
Zeit2020-11-22 23:00:16
Autorkumaneko

Log Message

(empty log message)

Ändern Zusammenfassung

Diff

--- trunk/akari/Makefile (revision 662)
+++ trunk/akari/Makefile (revision 663)
@@ -55,4 +55,26 @@
5555
5656 $(obj)/lsm.o: $(obj)/check_umode_t.h $(obj)/config.h
5757
58+ifdef CONFIG_USERMODE_DRIVER
59+
60+# If you are sure that a shell script containing
61+# #!/bin/sh
62+# exec /bin/cat /proc/kallsyms
63+# can work when module is loaded, you may use such script as
64+# $(obj)/kallsyms_reader instead of a binary program obtained by
65+# compiling $(obj)/kallsyms_reader.c .
66+#
67+$(obj)/kallsyms_reader: $(obj)/kallsyms_reader.c
68+ @$(CC) -o $(obj)/kallsyms_reader $(obj)/kallsyms_reader.c
69+
70+$(obj)/kallsyms_reader.h: $(obj)/kallsyms_reader
71+ @echo -n 'static const char kallsyms_reader[] __initdata = "' > $(obj)/kallsyms_reader.h.tmp
72+ @hexdump -v -e '/1 "@%02X"' $(obj)/kallsyms_reader | sed -e 's/@/\\x/g' >> $(obj)/kallsyms_reader.h.tmp
73+ @echo '";' >> $(obj)/kallsyms_reader.h.tmp
74+ @mv $(obj)/kallsyms_reader.h.tmp $(obj)/kallsyms_reader.h
75+
76+$(obj)/probe.o: $(obj)/kallsyms_reader.h
77+
78+endif
79+
5880 .o: $(obj)/config.h
--- trunk/akari/kallsyms_reader.c (nonexistent)
+++ trunk/akari/kallsyms_reader.c (revision 663)
@@ -0,0 +1,23 @@
1+#define _GNU_SOURCE
2+#include <sys/types.h>
3+#include <sys/stat.h>
4+#include <fcntl.h>
5+#include <unistd.h>
6+#include <sys/mount.h>
7+#include <sched.h>
8+
9+int main(int argc, char *argv[])
10+{
11+ int fd = open("/proc/kallsyms", O_RDONLY);
12+ int len;
13+ char buffer[4096];
14+
15+ if (fd < 0 && unshare(CLONE_NEWNS) == 0 &&
16+ mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL) == 0 &&
17+ (umount2("/proc", MNT_DETACH), mkdir("/proc", 0755),
18+ mount(NULL, "/proc", "proc", 0, NULL) == 0))
19+ fd = open("/proc/kallsyms", O_RDONLY);
20+ while ((len = read(fd, buffer, sizeof(buffer))) > 0 &&
21+ write(1, buffer, len) == len);
22+ return !!len;
23+}
--- trunk/akari/probe.c (revision 662)
+++ trunk/akari/probe.c (revision 663)
@@ -42,6 +42,7 @@
4242 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
4343
4444 #include <linux/usermode_driver.h>
45+#include "kallsyms_reader.h"
4546
4647 /**
4748 * probe_find_symbol - Find function's address from /proc/kallsyms .
@@ -53,13 +54,12 @@
5354 static void *__init probe_find_symbol(const char *keyline)
5455 {
5556 unsigned long entry = 0;
56- static const char program[] = "#!/bin/sh\nexec /bin/cat /proc/kallsyms\n";
57- struct umd_info umd = { .driver_name = "umd_test" };
57+ struct umd_info umd = { .driver_name = "kallsyms_reader" };
5858 loff_t offset = 0;
5959 char *buf;
6060 int len;
6161
62- if (umd_load_blob(&umd, program, sizeof(program) - 1))
62+ if (umd_load_blob(&umd, kallsyms_reader, sizeof(kallsyms_reader) - 1))
6363 return NULL;
6464 buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
6565 if (!buf || fork_usermode_driver(&umd))
Show on old repository browser