OSDN Git Service

tracing/perf: Use strndup_user() instead of buggy open-coded version
authorJann Horn <jannh@google.com>
Wed, 20 Feb 2019 16:54:43 +0000 (17:54 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Mar 2019 19:09:56 +0000 (20:09 +0100)
commit24d5097655ebf33160880721b663041dea083110
treef5066c9ac97e389495b17818639abb9cf58a438a
parentf27077e5f5c5a468733b09893db86169c1c3b0a9
tracing/perf: Use strndup_user() instead of buggy open-coded version

commit 83540fbc8812a580b6ad8f93f4c29e62e417687e upstream.

The first version of this method was missing the check for
`ret == PATH_MAX`; then such a check was added, but it didn't call kfree()
on error, so there was still a small memory leak in the error case.
Fix it by using strndup_user() instead of open-coding it.

Link: http://lkml.kernel.org/r/20190220165443.152385-1-jannh@google.com
Cc: Ingo Molnar <mingo@kernel.org>
Cc: stable@vger.kernel.org
Fixes: 0eadcc7a7bc0 ("perf/core: Fix perf_uprobe_init()")
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/trace_event_perf.c