kprobes: Do not increment probe miss count in the fault handler
authorNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Tue, 1 Jun 2021 12:01:50 +0000 (17:31 +0530)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 3 Jun 2021 13:47:26 +0000 (15:47 +0200)
Kprobes has a counter 'nmissed', that is used to count the number of
times a probe handler was not called. This generally happens when we hit
a kprobe while handling another kprobe.

However, if one of the probe handlers causes a fault, we are currently
incrementing 'nmissed'. The comment in fault handler indicates that this
can be used to account faults taken by the probe handlers. But, this has
never been the intention as is evident from the comment above 'nmissed'
in 'struct kprobe':

/*count the number of times this probe was temporarily disarmed */
unsigned long nmissed;

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Link: https://lkml.kernel.org/r/20210601120150.672652-1-naveen.n.rao@linux.vnet.ibm.com
arch/arc/kernel/kprobes.c
arch/arm/probes/kprobes/core.c
arch/arm64/kernel/probes/kprobes.c
arch/csky/kernel/probes/kprobes.c
arch/ia64/kernel/kprobes.c
arch/powerpc/kernel/kprobes.c
arch/riscv/kernel/probes/kprobes.c
arch/s390/kernel/kprobes.c
arch/sh/kernel/kprobes.c
arch/sparc/kernel/kprobes.c
arch/x86/kernel/kprobes/core.c

index 9f5b39f387362e64a073ef6b859135e6bda180ee..5f0415fc73287b9ac849123c029a50281fe7bc60 100644 (file)
@@ -317,12 +317,6 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned long trapnr)
                 * caused the fault.
                 */
 
-               /* We increment the nmissed count for accounting,
-                * we can also use npre/npostfault count for accounting
-                * these specific fault cases.
-                */
-               kprobes_inc_nmissed_count(cur);
-
                /*
                 * In case the user-specified fault handler returned zero,
                 * try to fix up.
index 7b9b9a5a409bb8b44cbce7b2613f0c56022a2d60..27e0af78e88b022b18f26f1d64e6110610a4a883 100644 (file)
@@ -348,20 +348,6 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr)
                        reset_current_kprobe();
                }
                break;
-
-       case KPROBE_HIT_ACTIVE:
-       case KPROBE_HIT_SSDONE:
-               /*
-                * We increment the nmissed count for accounting,
-                * we can also use npre/npostfault count for accounting
-                * these specific fault cases.
-                */
-               kprobes_inc_nmissed_count(cur);
-
-               break;
-
-       default:
-               break;
        }
 
        return 0;
index f6b088e9fa70e6da242721e9d1e363ef08ae71ce..004b86eff9c2d9c7133997373a87a56273981a99 100644 (file)
@@ -276,13 +276,6 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr)
                break;
        case KPROBE_HIT_ACTIVE:
        case KPROBE_HIT_SSDONE:
-               /*
-                * We increment the nmissed count for accounting,
-                * we can also use npre/npostfault count for accounting
-                * these specific fault cases.
-                */
-               kprobes_inc_nmissed_count(cur);
-
                /*
                 * In case the user-specified fault handler returned
                 * zero, try to fix up.
index e0e973e49770375299ab557176ecb50c0287b33f..68b22b499aebf7f68677ddfe67e02dab466635f0 100644 (file)
@@ -294,13 +294,6 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned int trapnr)
                break;
        case KPROBE_HIT_ACTIVE:
        case KPROBE_HIT_SSDONE:
-               /*
-                * We increment the nmissed count for accounting,
-                * we can also use npre/npostfault count for accounting
-                * these specific fault cases.
-                */
-               kprobes_inc_nmissed_count(cur);
-
                /*
                 * In case the user-specified fault handler returned
                 * zero, try to fix up.
index 6efed4ecff9e92f649057aaf54470cc997157b18..441ed04b103785680b9021a5d6edef4f8420dfcb 100644 (file)
@@ -843,13 +843,6 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
                break;
        case KPROBE_HIT_ACTIVE:
        case KPROBE_HIT_SSDONE:
-               /*
-                * We increment the nmissed count for accounting,
-                * we can also use npre/npostfault count for accounting
-                * these specific fault cases.
-                */
-               kprobes_inc_nmissed_count(cur);
-
                /*
                 * In case the user-specified fault handler returned
                 * zero, try to fix up.
index 75b4e874269d4862d21836fe7f3823d1e3c2dac3..3f700830169fad5cba0c404e1f11bb9cb1fa3747 100644 (file)
@@ -501,13 +501,6 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
                break;
        case KPROBE_HIT_ACTIVE:
        case KPROBE_HIT_SSDONE:
-               /*
-                * We increment the nmissed count for accounting,
-                * we can also use npre/npostfault count for accounting
-                * these specific fault cases.
-                */
-               kprobes_inc_nmissed_count(cur);
-
                /*
                 * In case the user-specified fault handler returned
                 * zero, try to fix up.
index 923b5ea396eab36d35acadc7936001fdeb6e0ad7..9b71a6363bdaa2e4faa3c6143a02976116f6fc5f 100644 (file)
@@ -276,13 +276,6 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned int trapnr)
                break;
        case KPROBE_HIT_ACTIVE:
        case KPROBE_HIT_SSDONE:
-               /*
-                * We increment the nmissed count for accounting,
-                * we can also use npre/npostfault count for accounting
-                * these specific fault cases.
-                */
-               kprobes_inc_nmissed_count(cur);
-
                /*
                 * In case the user-specified fault handler returned
                 * zero, try to fix up.
index ad631e33df24f3e89c07604029afca3c4c344829..74b0bd2c24d4c134691e5a3e2b5b88f5ace913fb 100644 (file)
@@ -445,13 +445,6 @@ static int kprobe_trap_handler(struct pt_regs *regs, int trapnr)
                break;
        case KPROBE_HIT_ACTIVE:
        case KPROBE_HIT_SSDONE:
-               /*
-                * We increment the nmissed count for accounting,
-                * we can also use npre/npostfault count for accounting
-                * these specific fault cases.
-                */
-               kprobes_inc_nmissed_count(p);
-
                /*
                 * In case the user-specified fault handler returned
                 * zero, try to fix up.
index 58263420ad2a5834665e74c116cf160f65fc51e8..1c7f358ef0be1c5e0bb2429a6b6685c9ef0732e3 100644 (file)
@@ -382,13 +382,6 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
                break;
        case KPROBE_HIT_ACTIVE:
        case KPROBE_HIT_SSDONE:
-               /*
-                * We increment the nmissed count for accounting,
-                * we can also use npre/npostfault count for accounting
-                * these specific fault cases.
-                */
-               kprobes_inc_nmissed_count(cur);
-
                /*
                 * In case the user-specified fault handler returned
                 * zero, try to fix up.
index db4e341b4b6ea8b89338a2b202b9513769500dcb..4c05a4ee6a0e7144544db3732a6d7a8cc7bcb2a5 100644 (file)
@@ -345,13 +345,6 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
                break;
        case KPROBE_HIT_ACTIVE:
        case KPROBE_HIT_SSDONE:
-               /*
-                * We increment the nmissed count for accounting,
-                * we can also use npre/npostfault count for accounting
-                * these specific fault cases.
-                */
-               kprobes_inc_nmissed_count(cur);
-
                /*
                 * In case the user-specified fault handler returned
                 * zero, try to fix up.
index cfcdf4b8a306f34a1ead58935b0bd396db78b146..1b3fe0edd3299fa844f6b4bac6f369f1bb27b175 100644 (file)
@@ -1102,14 +1102,6 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
                        restore_previous_kprobe(kcb);
                else
                        reset_current_kprobe();
-       } else if (kcb->kprobe_status == KPROBE_HIT_ACTIVE ||
-                  kcb->kprobe_status == KPROBE_HIT_SSDONE) {
-               /*
-                * We increment the nmissed count for accounting,
-                * we can also use npre/npostfault count for accounting
-                * these specific fault cases.
-                */
-               kprobes_inc_nmissed_count(cur);
        }
 
        return 0;