Skip to content
  • Masami Hiramatsu's avatar
    kprobes: Fix to free gone and unused optprobes · 7b959fc5
    Masami Hiramatsu authored
    Fix to free gone and unused optprobes. This bug will
    cause a kernel panic if the user reuses the killed and
    unused probe.
    
    Reported at:
    
      http://sourceware.org/ml/systemtap/2013-q2/msg00142.html
    
    In the normal path, an optprobe on an init function is
    unregistered when a module goes live.
    
    unregister_kprobe(kp)
     -> __unregister_kprobe_top
       ->__disable_kprobe
         ->disarm_kprobe(ap == op)
           ->__disarm_kprobe
            ->unoptimize_kprobe : the op is queued
                                  on unoptimizing_list
    and do nothing in __unregister_kprobe_bottom
    
    After a while (usually wait 5 jiffies), kprobe_optimizer
    runs to unoptimize and free optprobe.
    
    kprobe_optimizer
     ->do_unoptimize_kprobes
       ->arch_unoptimize_kprobes : moved to free_list
     ->do_free_cleaned_kprobes
       ->hlist_del: the op is removed
       ->free_aggr_kprobe
         ->arch_remove_optimized_kprobe
         ->arch_remove_kprobe
         ->kfree: the op is freed
    
    Here, if kprobes_module_callback is called and...
    7b959fc5