• J
    ftrace: Clear hashes of stale ips of init memory · 8715b108
    Joel Fernandes 提交于
    Filters should be cleared of init functions during freeing of init
    memory when the ftrace dyn records are released. However in current
    code, the filters are left as is. This patch clears the hashes of the
    saved init functions when the init memory is freed. This fixes the
    following issue reproducible with the following sequence of commands for
    a test module:
    ================================================
    
    void bar(void)
    {
        printk(KERN_INFO "bar!\n");
    }
    
    void foo(void)
    {
        printk(KERN_INFO "foo!\n");
        bar();
    }
    
    static int __init hello_init(void)
    {
        printk(KERN_INFO "Hello world!\n");
        foo();
        return 0;
    }
    
    static void __exit hello_cleanup(void)
    {
        printk(KERN_INFO "Cleaning up module.\n");
    }
    
    module_init(hello_init);
    module_exit(hello_cleanup);
    ================================================
    
    Commands:
    echo '*:mod:test' > /d/tracing/set_ftrace_filter
    echo function > /d/tracing/current_tracer
    modprobe test
    rmmod test
    sleep 1
    modprobe test
    cat /d/tracing/set_ftrace_filter
    
    Behavior without patch: Init function is still in the filter
    Expected behavior: Shouldn't have any of the filters set
    
    Link: http://lkml.kernel.org/r/20171009192931.56401-1-joelaf@google.comSigned-off-by: NJoel Fernandes <joelaf@google.com>
    Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
    8715b108
ftrace.c 167.1 KB