<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/trace/ftrace.c, branch v4.14</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.14</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.14'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2017-10-03T14:27:32Z</updated>
<entry>
<title>ftrace: Fix kmemleak in unregister_ftrace_graph</title>
<updated>2017-10-03T14:27:32Z</updated>
<author>
<name>Shu Wang</name>
<email>shuwang@redhat.com</email>
</author>
<published>2017-09-12T02:14:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2b0b8499ae75df91455bbeb7491d45affc384fb0'/>
<id>urn:sha1:2b0b8499ae75df91455bbeb7491d45affc384fb0</id>
<content type='text'>
The trampoline allocated by function tracer was overwriten by function_graph
tracer, and caused a memory leak. The save_global_trampoline should have
saved the previous trampoline in register_ftrace_graph() and restored it in
unregister_ftrace_graph(). But as it is implemented, save_global_trampoline was
only used in unregister_ftrace_graph as default value 0, and it overwrote the
previous trampoline's value. Causing the previous allocated trampoline to be
lost.

kmmeleak backtrace:
    kmemleak_vmalloc+0x77/0xc0
    __vmalloc_node_range+0x1b5/0x2c0
    module_alloc+0x7c/0xd0
    arch_ftrace_update_trampoline+0xb5/0x290
    ftrace_startup+0x78/0x210
    register_ftrace_function+0x8b/0xd0
    function_trace_init+0x4f/0x80
    tracing_set_tracer+0xe6/0x170
    tracing_set_trace_write+0x90/0xd0
    __vfs_write+0x37/0x170
    vfs_write+0xb2/0x1b0
    SyS_write+0x55/0xc0
    do_syscall_64+0x67/0x180
    return_from_SYSCALL_64+0x0/0x6a

[
  Looking further into this, I found that this was left over from when the
  function and function graph tracers shared the same ftrace_ops. But in
  commit 5f151b2401 ("ftrace: Fix function_profiler and function tracer
  together"), the two were separated, and the save_global_trampoline no
  longer was necessary (and it may have been broken back then too).
  -- Steven Rostedt
]

Link: http://lkml.kernel.org/r/20170912021454.5976-1-shuwang@redhat.com

Cc: stable@vger.kernel.org
Fixes: 5f151b2401 ("ftrace: Fix function_profiler and function tracer together")
Signed-off-by: Shu Wang &lt;shuwang@redhat.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Fix memleak when unregistering dynamic ops when tracing disabled</title>
<updated>2017-09-01T17:55:49Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2017-09-01T16:18:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=edb096e00724f02db5f6ec7900f3bbd465c6c76f'/>
<id>urn:sha1:edb096e00724f02db5f6ec7900f3bbd465c6c76f</id>
<content type='text'>
If function tracing is disabled by the user via the function-trace option or
the proc sysctl file, and a ftrace_ops that was allocated on the heap is
unregistered, then the shutdown code exits out without doing the proper
clean up. This was found via kmemleak and running the ftrace selftests, as
one of the tests unregisters with function tracing disabled.

 # cat kmemleak
unreferenced object 0xffffffffa0020000 (size 4096):
  comm "swapper/0", pid 1, jiffies 4294668889 (age 569.209s)
  hex dump (first 32 bytes):
    55 ff 74 24 10 55 48 89 e5 ff 74 24 18 55 48 89  U.t$.UH...t$.UH.
    e5 48 81 ec a8 00 00 00 48 89 44 24 50 48 89 4c  .H......H.D$PH.L
  backtrace:
    [&lt;ffffffff81d64665&gt;] kmemleak_vmalloc+0x85/0xf0
    [&lt;ffffffff81355631&gt;] __vmalloc_node_range+0x281/0x3e0
    [&lt;ffffffff8109697f&gt;] module_alloc+0x4f/0x90
    [&lt;ffffffff81091170&gt;] arch_ftrace_update_trampoline+0x160/0x420
    [&lt;ffffffff81249947&gt;] ftrace_startup+0xe7/0x300
    [&lt;ffffffff81249bd2&gt;] register_ftrace_function+0x72/0x90
    [&lt;ffffffff81263786&gt;] trace_selftest_ops+0x204/0x397
    [&lt;ffffffff82bb8971&gt;] trace_selftest_startup_function+0x394/0x624
    [&lt;ffffffff81263a75&gt;] run_tracer_selftest+0x15c/0x1d7
    [&lt;ffffffff82bb83f1&gt;] init_trace_selftests+0x75/0x192
    [&lt;ffffffff81002230&gt;] do_one_initcall+0x90/0x1e2
    [&lt;ffffffff82b7d620&gt;] kernel_init_freeable+0x350/0x3fe
    [&lt;ffffffff81d61ec3&gt;] kernel_init+0x13/0x122
    [&lt;ffffffff81d72c6a&gt;] ret_from_fork+0x2a/0x40
    [&lt;ffffffffffffffff&gt;] 0xffffffffffffffff

Cc: stable@vger.kernel.org
Fixes: 12cce594fa ("ftrace/x86: Allow !CONFIG_PREEMPT dynamic ops to use allocated trampolines")
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Zero out ftrace hashes when a module is removed</title>
<updated>2017-08-31T23:55:12Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2017-08-31T21:36:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2a5bfe47624bfc835aa0632a0505ba55576c98db'/>
<id>urn:sha1:2a5bfe47624bfc835aa0632a0505ba55576c98db</id>
<content type='text'>
When a ftrace filter has a module function, and that module is removed, the
filter still has its address as being enabled. This can cause interesting
side effects. Nothing dangerous, but unwanted functions can be traced
because of it.

 # cd /sys/kernel/tracing
 # echo ':mod:snd_seq' &gt; set_ftrace_filter
 # cat set_ftrace_filter
snd_use_lock_sync_helper [snd_seq]
check_event_type_and_length [snd_seq]
snd_seq_ioctl_pversion [snd_seq]
snd_seq_ioctl_client_id [snd_seq]
snd_seq_ioctl_get_queue_tempo [snd_seq]
update_timestamp_of_queue [snd_seq]
snd_seq_ioctl_get_queue_status [snd_seq]
snd_seq_set_queue_tempo [snd_seq]
snd_seq_ioctl_set_queue_tempo [snd_seq]
snd_seq_ioctl_get_queue_timer [snd_seq]
seq_free_client1 [snd_seq]
[..]
 # rmmod snd_seq
 # cat set_ftrace_filter

 # modprobe kvm
 # cat set_ftrace_filter
kvm_set_cr4 [kvm]
kvm_emulate_hypercall [kvm]
kvm_set_dr [kvm]

This is because removing the snd_seq module after it was being filtered,
left the address of the snd_seq functions in the hash. When the kvm module
was loaded, some of its functions were loaded at the same address as the
snd_seq module. This would enable them to be filtered and traced.

Now we don't want to clear the hash completely. That would cause removing a
module where only its functions are filtered, to cause the tracing to enable
all functions, as an empty filter means to trace all functions. Instead,
just set the hash ip address to zero. Then it will never match any function.

Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Check for null ret_stack on profile function graph entry function</title>
<updated>2017-08-24T14:04:01Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2017-08-17T20:37:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a8f0f9e49956a74718874b800251455680085600'/>
<id>urn:sha1:a8f0f9e49956a74718874b800251455680085600</id>
<content type='text'>
There's a small race when function graph shutsdown and the calling of the
registered function graph entry callback. The callback must not reference
the task's ret_stack without first checking that it is not NULL. Note, when
a ret_stack is allocated for a task, it stays allocated until the task exits.
The problem here, is that function_graph is shutdown, and a new task was
created, which doesn't have its ret_stack allocated. But since some of the
functions are still being traced, the callbacks can still be called.

The normal function_graph code handles this, but starting with commit
8861dd303c ("ftrace: Access ret_stack-&gt;subtime only in the function
profiler") the profiler code references the ret_stack on function entry, but
doesn't check if it is NULL first.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=196611

Cc: stable@vger.kernel.org
Fixes: 8861dd303c ("ftrace: Access ret_stack-&gt;subtime only in the function profiler")
Reported-by: lilydjwg@gmail.com
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>trace: fix the errors caused by incompatible type of RCU variables</title>
<updated>2017-07-20T13:27:29Z</updated>
<author>
<name>Chunyan Zhang</name>
<email>zhang.chunyan@linaro.org</email>
</author>
<published>2017-06-07T08:12:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f86f418059b94aa01f9342611a272ca60c583e89'/>
<id>urn:sha1:f86f418059b94aa01f9342611a272ca60c583e89</id>
<content type='text'>
The variables which are processed by RCU functions should be annotated
as RCU, otherwise sparse will report the errors like below:

"error: incompatible types in comparison expression (different
address spaces)"

Link: http://lkml.kernel.org/r/1496823171-7758-1-git-send-email-zhang.chunyan@linaro.org

Signed-off-by: Chunyan Zhang &lt;zhang.chunyan@linaro.org&gt;
[ Updated to not be 100% 80 column strict ]
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Fix uninitialized variable in match_records()</title>
<updated>2017-07-12T13:48:31Z</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2017-07-12T07:35:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2e028c4fe12907f226b8221815f16c2486ad3aa7'/>
<id>urn:sha1:2e028c4fe12907f226b8221815f16c2486ad3aa7</id>
<content type='text'>
My static checker complains that if "func" is NULL then "clear_filter"
is uninitialized.  This seems like it could be true, although it's
possible something subtle is happening that I haven't seen.

    kernel/trace/ftrace.c:3844 match_records()
    error: uninitialized symbol 'clear_filter'.

Link: http://lkml.kernel.org/r/20170712073556.h6tkpjcdzjaozozs@mwanda

Cc: stable@vger.kernel.org
Fixes: f0a3b154bd7 ("ftrace: Clarify code for mod command")
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Remove an unneeded NULL check</title>
<updated>2017-07-12T13:45:42Z</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2017-07-12T07:33:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=44925dfff05fd1a897992d278b15a6b6b55e79a7'/>
<id>urn:sha1:44925dfff05fd1a897992d278b15a6b6b55e79a7</id>
<content type='text'>
"func" can't be NULL and it doesn't make sense to check because we've
already derefenced it.

Link: http://lkml.kernel.org/r/20170712073340.4enzeojeoupuds5a@mwanda

Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Hide cached module code for !CONFIG_MODULES</title>
<updated>2017-07-11T23:29:04Z</updated>
<author>
<name>Arnd Bergmann</name>
<email>arnd@arndb.de</email>
</author>
<published>2017-07-10T08:44:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=69449bbd65687e8e5fb968a5a0c46089f6af6001'/>
<id>urn:sha1:69449bbd65687e8e5fb968a5a0c46089f6af6001</id>
<content type='text'>
When modules are disabled, we get a harmless build warning:

kernel/trace/ftrace.c:4051:13: error: 'process_cached_mods' defined but not used [-Werror=unused-function]

This adds the same #ifdef around the new code that exists around
its caller.

Link: http://lkml.kernel.org/r/20170710084413.1820568-1-arnd@arndb.de

Fixes: d7fbf8df7ca0 ("ftrace: Implement cached modules tracing on module load")
Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Test for NULL iter-&gt;tr in regex for stack_trace_filter changes</title>
<updated>2017-07-05T13:52:18Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2017-07-05T13:45:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=69d71879d2cf67a381055f698a1d7def00dc4ed7'/>
<id>urn:sha1:69d71879d2cf67a381055f698a1d7def00dc4ed7</id>
<content type='text'>
As writing into stack_trace_filter, the iter-tr is not set and is NULL.
Check if it is NULL before dereferencing it in ftrace_regex_release().

Fixes: 8c08f0d5c6fb ("ftrace: Have cached module filters be an active filter")
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>Merge commit '0f17976568b3f72e676450af0c0db6f8752253d6' into trace/ftrace/core</title>
<updated>2017-07-05T13:51:24Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2017-07-05T13:51:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4dce17b26b6ac3bf29aa0eae1d28e14debe37747'/>
<id>urn:sha1:4dce17b26b6ac3bf29aa0eae1d28e14debe37747</id>
<content type='text'>
Need to get the changes from 0f17976568b3 ("ftrace: Fix regression with
module command in stack_trace_filter") as it is required to fix some other
changes with stack_trace_filter and the new development code.

Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
</feed>
