• Zhou Chengming's avatar
    kprobes, x86/alternatives: Use text_mutex to protect smp_alt_modules · e846d139
    Zhou Chengming authored
    We use alternatives_text_reserved() to check if the address is in
    the fixed pieces of alternative reserved, but the problem is that
    we don't hold the smp_alt mutex when call this function. So the list
    traversal may encounter a deleted list_head if another path is doing
    alternatives_smp_module_del().
    
    One solution is that we can hold smp_alt mutex before call this
    function, but the difficult point is that the callers of this
    functions, arch_prepare_kprobe() and arch_prepare_optimized_kprobe(),
    are called inside the text_mutex. So we must hold smp_alt mutex
    before we go into these arch dependent code. But we can't now,
    the smp_alt mutex is the arch dependent part, only x86 has it.
    Maybe we can export another arch dependent callback to solve this.
    
    But there is a simpler way to handle this problem. We can reuse the
    text_mutex to protect smp_alt_modules instead of using another mutex.
    And all the arch dependent checks of kprobes are inside t...
    e846d139
extable.c 4.8 KB