Add CONFIG_SWAP_KERNEL_IMMUTABLE support 91/144191/3
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Mon, 14 Aug 2017 11:51:33 +0000 (14:51 +0300)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Fri, 18 Aug 2017 11:40:16 +0000 (14:40 +0300)
Add some includes to other files, because they were indirectly
included from removed

Change-Id: I9c78d60d6f42d91a154050515bad8118a06ecb68
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
21 files changed:
Kbuild
energy/energy.c
got_patcher/gt_module.c
kprobe/Kbuild
kprobe/arch/arm/swap-asm/swap_kprobes.c
kprobe/arch/arm64/swap-asm/dbg_interface.c
kprobe/arch/arm64/swap-asm/swap_kprobes.c
kprobe/arch/x86/swap-asm/swap_kprobes.c
kprobe/swap_kprobes.h
kprobe/swap_ktd.c
kprobe/swap_no_kprobes.c [new file with mode: 0644]
ks_features/ks_feature_hook.c
ks_features/ks_features.c
loader/loader_module.c
preload/preload_control.c
uprobe/arch/arm64/swap-asm/swap_uprobes.c
uprobe/arch/x86/swap-asm/swap_uprobes.c
uprobe/swap_uprobes.h
us_manager/probes/probe_info_new.h
us_manager/sspt/sspt_debug.h
writer/swap_msg.c

diff --git a/Kbuild b/Kbuild
index 71380c2..b1a0574 100644 (file)
--- a/Kbuild
+++ b/Kbuild
@@ -9,7 +9,6 @@ obj-m := master/ \
          driver/ \
          writer/ \
          kprobe/ \
-         ks_manager/ \
          uprobe/ \
          us_manager/ \
          ks_features/ \
@@ -26,3 +25,7 @@ obj-m := master/ \
          task_ctx/ \
          uihv/ \
          got_patcher/
+
+ifneq ($(CONFIG_SWAP_KERNEL_IMMUTABLE), y)
+obj-m += ks_manager/
+endif # CONFIG_SWAP_KERNEL_IMMUTABLE
index 97e48a9..32e4680 100644 (file)
 #include <linux/string.h>
 #include <linux/fdtable.h>
 #include <net/sock.h>
-#include <kprobe/swap_kprobes.h>
 #include <ksyms/ksyms.h>
 #include <master/swap_deps.h>
+#include <swap-asm/swap_kprobes.h>
 #include <us_manager/sspt/sspt_proc.h>
 #include <us_manager/sspt/sspt_feature.h>
 #include <linux/atomic.h>
 
 #ifdef CONFIG_SWAP_HOOK_SWITCH_TO
 # include <swap/hook_switch_to.h>
+#else /* CONFIG_SWAP_HOOK_SWITCH_TO */
+# include <kprobe/swap_kprobes.h>
 #endif /* CONFIG_SWAP_HOOK_SWITCH_TO */
 
 #ifdef CONFIG_SWAP_HOOK_ENERGY
 # include <swap/hook_syscall.h>
 # include <swap/hook_energy.h>
 # include <kprobe/swap_td_raw.h>
+#else /* CONFIG_SWAP_HOOK_ENERGY */
+# include <kprobe/swap_kprobes.h>
 #endif /* CONFIG_SWAP_HOOK_ENERGY */
 
 #include "energy.h"
index 30a9bb3..7125cc6 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/string.h>
 #include <linux/namei.h>
 #include <linux/slab.h>
+#include <linux/limits.h>
 #include <kprobe/swap_ktd.h>
 #include <us_manager/pf/pf_group.h>
 #include <us_manager/sspt/sspt_page.h>
index 00ac8f9..adc6cac 100644 (file)
@@ -1,11 +1,26 @@
 EXTRA_CFLAGS := $(extra_cflags)
 
 obj-m := swap_kprobe.o
-swap_kprobe-y := swap_kprobes.o \
-                 swap_kprobes_deps.o \
-                 swap_slots.o \
-                 swap_td_raw.o \
-                 swap_ktd.o
+swap_kprobe-y := \
+       swap_kprobes_deps.o \
+       swap_slots.o \
+       swap_td_raw.o \
+       swap_ktd.o
+
+
+### ARM64
+swap_kprobe-$(CONFIG_ARM64) += \
+       arch/arm64/swap-asm/simulate-insn.o \
+       arch/arm64/swap-asm/condn-helpers.o
+
+
+ifeq ($(CONFIG_SWAP_KERNEL_IMMUTABLE), y)
+
+swap_kprobe-y += swap_no_kprobes.o
+
+else # CONFIG_SWAP_KERNEL_IMMUTABLE
+
+swap_kprobe-y += swap_kprobes.o
 
 ### ARM
 swap_kprobe-$(CONFIG_ARM) += \
@@ -21,10 +36,10 @@ endif #ifeq ($(CONFIG_STRICT_MEMORY_RWX), y)
 ### ARM64
 swap_kprobe-$(CONFIG_ARM64) += arch/arm64/swap-asm/swap_kprobes.o \
                                arch/arm64/swap-asm/dbg_interface.o \
-                               arch/arm64/swap-asm/kprobes-arm64.o \
-                               arch/arm64/swap-asm/condn-helpers.o \
-                               arch/arm64/swap-asm/simulate-insn.o
+                               arch/arm64/swap-asm/kprobes-arm64.o
 
 
 ### X86
 swap_kprobe-$(CONFIG_X86) += arch/x86/swap-asm/swap_kprobes.o
+
+endif # CONFIG_SWAP_KERNEL_IMMUTABLE
index 07c27eb..5b510cf 100644 (file)
  * SWAP kprobe implementation for ARM architecture.
  */
 
+
+#include <linux/kconfig.h>
+
+#ifdef CONFIG_SWAP_KERNEL_IMMUTABLE
+# error "Kernel is immutable"
+#endif /* CONFIG_SWAP_KERNEL_IMMUTABLE */
+
+
 #include <linux/module.h>
 #include <asm/cacheflush.h>
 #include <asm/traps.h>
index 438b7b8..56543b7 100644 (file)
  */
 
 
+#include <linux/kconfig.h>
+
+#ifdef CONFIG_SWAP_KERNEL_IMMUTABLE
+# error "Kernel is immutable"
+#endif /* CONFIG_SWAP_KERNEL_IMMUTABLE */
+
+
 #include <linux/module.h>
 #include <linux/rwlock.h>
 #include <asm/debug-monitors.h>
index 298984c..77970ef 100644 (file)
  */
 
 
+#include <linux/kconfig.h>
+
+#ifdef CONFIG_SWAP_KERNEL_IMMUTABLE
+# error "Kernel is immutable"
+#endif /* CONFIG_SWAP_KERNEL_IMMUTABLE */
+
+
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <asm/cacheflush.h>
index 70c35a4..72b47e1 100644 (file)
  * SWAP krpobes arch-dependend part for x86.
  */
 
+
+#include <linux/kconfig.h>
+
+#ifdef CONFIG_SWAP_KERNEL_IMMUTABLE
+# error "Kernel is immutable"
+#endif /* CONFIG_SWAP_KERNEL_IMMUTABLE */
+
+
 #include<linux/module.h>
 #include <linux/kdebug.h>
 
index 52d5b45..3fae497 100644 (file)
 #ifndef _SWAP_KPROBES_H
 #define _SWAP_KPROBES_H
 
+
+#include <linux/kconfig.h>
+
+#ifdef CONFIG_SWAP_KERNEL_IMMUTABLE
+# error "Kernel is immutable"
+#endif /* CONFIG_SWAP_KERNEL_IMMUTABLE */
+
+
 #include <linux/version.h>     /*  LINUX_VERSION_CODE, KERNEL_VERSION() */
 #include <linux/notifier.h>
 #include <linux/percpu.h>
index 53591b6..4947d37 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <kprobe/swap_kprobes.h>
 #include <kprobe/swap_kprobes_deps.h>
 #include <ksyms/ksyms.h>
 #include "swap_ktd.h"
diff --git a/kprobe/swap_no_kprobes.c b/kprobe/swap_no_kprobes.c
new file mode 100644 (file)
index 0000000..ecec419
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) Samsung Electronics, 2015
+ *
+ * 2016         Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#include <linux/module.h>
+#include <kprobe/swap_ktd.h>
+#include <kprobe/swap_kprobes_deps.h>
+#include <master/swap_initializer.h>
+
+
+static void ktd_uninit(void)
+{
+       swap_ktd_uninit_top();
+       swap_ktd_uninit_bottom();
+}
+
+SWAP_LIGHT_INIT_MODULE(init_module_dependencies, swap_ktd_init, ktd_uninit, NULL, NULL);
+
+MODULE_LICENSE("GPL");
index 60e7ea2..a0e60f7 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/slab.h>
 #include <linux/errno.h>
 #include <ksyms/ksyms.h>
-#include <kprobe/swap_kprobes.h>
 #include <master/swap_initializer.h>
 #include <writer/event_filter.h>
 #include <swap/hook_syscall.h>
index 181389e..aa2adab 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/slab.h>
 #include <linux/errno.h>
 #include <ksyms/ksyms.h>
-#include <kprobe/swap_kprobes.h>
 #include <master/swap_initializer.h>
 #include <writer/event_filter.h>
 #include "ksf_msg.h"
 
 
 /* ====================== SWITCH_CONTEXT ======================= */
-static int switch_entry_handler(struct kretprobe_instance *ri,
-                               struct pt_regs *regs)
-{
-       if (check_event(current))
-               ksf_switch_entry(current);
-
-       return 0;
-}
-
-static int switch_ret_handler(struct kretprobe_instance *ri,
-                             struct pt_regs *regs)
-{
-       if (check_event(current))
-               ksf_switch_exit(current);
-
-       return 0;
-}
-
-/**
- * @var switch_rp
- * Kretprobe for scheduler.
- */
-struct kretprobe switch_rp = {
-       .entry_handler = switch_entry_handler,
-       .handler = switch_ret_handler
-};
-
 static DEFINE_MUTEX(mutex_sc_enable);
 static int sc_enable;
 
@@ -118,6 +90,33 @@ static void unregister_ctx_handler(void)
 
 #else  /* CONFIG_SWAP_HOOK_SWITCH_TO */
 
+static int switch_entry_handler(struct kretprobe_instance *ri,
+                               struct pt_regs *regs)
+{
+       if (check_event(current))
+               ksf_switch_entry(current);
+
+       return 0;
+}
+
+static int switch_ret_handler(struct kretprobe_instance *ri,
+                             struct pt_regs *regs)
+{
+       if (check_event(current))
+               ksf_switch_exit(current);
+
+       return 0;
+}
+
+/**
+ * @var switch_rp
+ * Kretprobe for scheduler.
+ */
+struct kretprobe switch_rp = {
+       .entry_handler = switch_entry_handler,
+       .handler = switch_ret_handler
+};
+
 /**
  * @brief Get scheduler address.
  *
index 71d94af..5d00cdb 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/mman.h>
 #include <linux/err.h>
 #include <linux/types.h>
+#include <linux/fs.h>
 #include <us_manager/sspt/sspt_proc.h>
 #include <us_manager/sspt/sspt_ip.h>
 #include <us_manager/callbacks.h>
index 019d8a1..43b92d0 100644 (file)
@@ -2,6 +2,7 @@
 #include <linux/spinlock.h>
 #include <linux/limits.h>
 #include <linux/list.h>
+#include <linux/fs.h>
 
 #include <us_manager/sspt/sspt_ip.h>
 #include <us_manager/us_common_file.h>
index c5cf79e..d5e2627 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <linux/kconfig.h>
 #include <linux/types.h>
 #include <asm/traps.h>
 #include <arch/arm/uprobe/swap_uprobe.h>
@@ -700,10 +701,14 @@ int swap_arch_init_uprobes(void)
        if (ret)
                return ret;
 
-       /* for aarch64 */
-       dbg_brk_hook_reg(&dbg_up_ss);
-       dbg_brk_hook_reg(&dbg_up_bp);
-       dbg_brk_hook_reg(&dbg_urp_bp);
+       if (!IS_ENABLED(CONFIG_SWAP_KERNEL_IMMUTABLE)) {
+               /* for aarch64 */
+               dbg_brk_hook_reg(&dbg_up_ss);
+               dbg_brk_hook_reg(&dbg_up_bp);
+               dbg_brk_hook_reg(&dbg_urp_bp);
+       } else {
+               pr_err("64-bit uprobes doesn't supported in case of Immutable kernel\n");
+       }
 
        /* for aarch32 */
        __register_undef_hook(&undef_hook_arm);
@@ -718,9 +723,12 @@ void swap_arch_exit_uprobes(void)
        __unregister_undef_hook(&undef_hook_thumb);
        __unregister_undef_hook(&undef_hook_arm);
 
-       /* for aarch64 */
-       dbg_brk_hook_unreg(&dbg_urp_bp);
-       dbg_brk_hook_unreg(&dbg_up_bp);
-       dbg_brk_hook_unreg(&dbg_up_ss);
+       if (!IS_ENABLED(CONFIG_SWAP_KERNEL_IMMUTABLE)) {
+               /* for aarch64 */
+               dbg_brk_hook_unreg(&dbg_urp_bp);
+               dbg_brk_hook_unreg(&dbg_up_bp);
+               dbg_brk_hook_unreg(&dbg_up_ss);
+       }
+
        swap_td_raw_unreg(&td_raw);
 }
index 046bbb1..db413ca 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <kprobe/swap_slots.h>
 #include <kprobe/swap_td_raw.h>
+#include <kprobe/swap_kprobes.h>
 #include <uprobe/swap_uprobes.h>
 
 #include "swap_uprobes.h"
index 54b3758..ad0affb 100644 (file)
@@ -35,7 +35,6 @@
 
 
 #include <master/wait.h>
-#include <kprobe/swap_kprobes.h>
 #include <swap-asm/swap_uprobes.h>
 
 
index 978bfe9..6c43481 100644 (file)
@@ -23,7 +23,6 @@
  */
 
 
-#include <kprobe/swap_kprobes.h>
 #include <uprobe/swap_uprobes.h>
 #include "probes.h"
 
index 18e34b9..afd9595 100644 (file)
 #include <kprobe/swap_kprobes_deps.h>
 #include <us_manager/probes/probes.h>
 
-static inline void print_jprobe(struct jprobe *jp)
-{
-       printk(KERN_INFO "###         JP: entry=%lx, pre_entry=%lx\n",
-                       (unsigned long)jp->entry, (unsigned long)jp->pre_entry);
-}
 
 static inline void print_retprobe(struct uretprobe *rp)
 {
index a965ee1..cf20fd6 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/module.h>
 #include <linux/vmalloc.h>
 #include <linux/spinlock.h>
-#include <kprobe/swap_kprobes.h>
 #include <buffer/swap_buffer_module.h>
 #include <swap-asm/swap_kprobes.h>
 #include <swap-asm/swap_uprobes.h>