]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] kprobe handler: discard user space trap
authorbibo,mao <bibo.mao@intel.com>
Sun, 26 Mar 2006 09:38:21 +0000 (01:38 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 26 Mar 2006 16:57:04 +0000 (08:57 -0800)
Currently kprobe handler traps only happen in kernel space, so function
kprobe_exceptions_notify should skip traps which happen in user space.
This patch modifies this, and it is based on 2.6.16-rc4.

Signed-off-by: bibo mao <bibo.mao@intel.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: "Keshavamurthy, Anil S" <anil.s.keshavamurthy@intel.com>
Cc: <hiramatu@sdl.hitachi.co.jp>
Signed-off-by: Prasanna S Panchamukhi <prasanna@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/i386/kernel/kprobes.c
arch/ia64/kernel/kprobes.c
arch/powerpc/kernel/kprobes.c
arch/sparc64/kernel/kprobes.c
arch/x86_64/kernel/kprobes.c

index acdcc640a72a31ab5f2583c8a2ec20a3854f3548..df1b346d36ffe3c8a4604401b905f8df63b90a25 100644 (file)
@@ -203,13 +203,14 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
 {
        struct kprobe *p;
        int ret = 0;
-       kprobe_opcode_t *addr = NULL;
-       unsigned long *lp;
+       kprobe_opcode_t *addr;
        struct kprobe_ctlblk *kcb;
 #ifdef CONFIG_PREEMPT
        unsigned pre_preempt_count = preempt_count();
 #endif /* CONFIG_PREEMPT */
 
+       addr = (kprobe_opcode_t *)(regs->eip - sizeof(kprobe_opcode_t));
+
        /*
         * We don't want to be preempted for the entire
         * duration of kprobe processing
@@ -217,17 +218,6 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
        preempt_disable();
        kcb = get_kprobe_ctlblk();
 
-       /* Check if the application is using LDT entry for its code segment and
-        * calculate the address by reading the base address from the LDT entry.
-        */
-       if ((regs->xcs & 4) && (current->mm)) {
-               lp = (unsigned long *) ((unsigned long)((regs->xcs >> 3) * 8)
-                                       + (char *) current->mm->context.ldt);
-               addr = (kprobe_opcode_t *) (get_desc_base(lp) + regs->eip -
-                                               sizeof(kprobe_opcode_t));
-       } else {
-               addr = (kprobe_opcode_t *)(regs->eip - sizeof(kprobe_opcode_t));
-       }
        /* Check we're not actually recursing */
        if (kprobe_running()) {
                p = get_kprobe(addr);
@@ -579,6 +569,9 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
        struct die_args *args = (struct die_args *)data;
        int ret = NOTIFY_DONE;
 
+       if (args->regs && user_mode(args->regs))
+               return ret;
+
        switch (val) {
        case DIE_INT3:
                if (kprobe_handler(args->regs))
index 50ae8c7d453d5075641a191dcfdf5bf0d4087ece..45b8479c9864ddddddff763778babaaaa47246a6 100644 (file)
@@ -740,6 +740,9 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
        struct die_args *args = (struct die_args *)data;
        int ret = NOTIFY_DONE;
 
+       if (args->regs && user_mode(args->regs))
+               return ret;
+
        switch(val) {
        case DIE_BREAK:
                /* err is break number from ia64_bad_break() */
index cb1fe5878e8b73724ef86056962e2d5dc37e58fe..aea25dd18daee9f2886e4b9bef184103f4690328 100644 (file)
@@ -396,6 +396,9 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
        struct die_args *args = (struct die_args *)data;
        int ret = NOTIFY_DONE;
 
+       if (args->regs && user_mode(args->regs))
+               return ret;
+
        switch (val) {
        case DIE_BPT:
                if (kprobe_handler(args->regs))
index b9a9ce70e55c1f281ff4759b47abc6d03e10ae49..d91c31870ac897f1185b7e24bb83302f70f457df 100644 (file)
@@ -324,6 +324,9 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
        struct die_args *args = (struct die_args *)data;
        int ret = NOTIFY_DONE;
 
+       if (args->regs && user_mode(args->regs))
+               return ret;
+
        switch (val) {
        case DIE_DEBUG:
                if (kprobe_handler(args->regs))
index 14f0ced613b683706f6d360c8ef835b2b9243d08..218e015c319545a60d6d49f3f97fbe476235e82b 100644 (file)
@@ -601,6 +601,9 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
        struct die_args *args = (struct die_args *)data;
        int ret = NOTIFY_DONE;
 
+       if (args->regs && user_mode(args->regs))
+               return ret;
+
        switch (val) {
        case DIE_INT3:
                if (kprobe_handler(args->regs))