1. 20 Apr, 2019 29 commits
    • Changbin Du's avatar
      perf tests: Fix a memory leak in test__perf_evsel__tp_sched_test() · b1930a27
      Changbin Du authored
      [ Upstream commit d982b331 ]
      
        =================================================================
        ==20875==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 1160 byte(s) in 1 object(s) allocated from:
            #0 0x7f1b6fc84138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
            #1 0x55bd50005599 in zalloc util/util.h:23
            #2 0x55bd500068f5 in perf_evsel__newtp_idx util/evsel.c:327
            #3 0x55bd4ff810fc in perf_evsel__newtp /home/work/linux/tools/perf/util/evsel.h:216
            #4 0x55bd4ff81608 in test__perf_evsel__tp_sched_test tests/evsel-tp-sched.c:69
            #5 0x55bd4ff528e6 in run_test tests/builtin-test.c:358
            #6 0x55bd4ff52baf in test_and_print tests/builtin-test.c:388
            #7 0x55bd4ff543fe in __cmd_test tests/builtin-test.c:583
            #8 0x55bd4ff5572f in cmd_test tests/builtin-test.c:722
            #9 0x55bd4ffc4087 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #10 0x55bd4ffc45c6 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #11 0x55bd4ffc49ca in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #12 0x55bd4ffc5138 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #13 0x7f1b6e34809a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      
        Indirect leak of 19 byte(s) in 1 object(s) allocated from:
            #0 0x7f1b6fc83f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
            #1 0x7f1b6e3ac30f in vasprintf (/lib/x86_64-linux-gnu/libc.so.6+0x8830f)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 6a6cd11d ("perf test: Add test for the sched tracepoint format fields")
      Link: http://lkml.kernel.org/r/20190316080556.3075-17-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b1930a27
    • Changbin Du's avatar
      perf tests: Fix memory leak by expr__find_other() in test__expr() · 4c66a273
      Changbin Du authored
      [ Upstream commit f97a8991 ]
      
        =================================================================
        ==7506==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 13 byte(s) in 3 object(s) allocated from:
            #0 0x7f03339d6070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
            #1 0x5625e53aaef0 in expr__find_other util/expr.y:221
            #2 0x5625e51bcd3f in test__expr tests/expr.c:52
            #3 0x5625e51528e6 in run_test tests/builtin-test.c:358
            #4 0x5625e5152baf in test_and_print tests/builtin-test.c:388
            #5 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
            #6 0x5625e515572f in cmd_test tests/builtin-test.c:722
            #7 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #8 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #9 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #10 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #11 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 07516736 ("perf tools: Add a simple expression parser for JSON")
      Link: http://lkml.kernel.org/r/20190316080556.3075-16-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4c66a273
    • Changbin Du's avatar
      perf tests: Fix a memory leak of cpu_map object in the openat_syscall_event_on_all_cpus test · a0898f57
      Changbin Du authored
      [ Upstream commit 93faa52e ]
      
        =================================================================
        ==7497==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 40 byte(s) in 1 object(s) allocated from:
            #0 0x7f0333a88f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
            #1 0x5625e5326213 in cpu_map__trim_new util/cpumap.c:45
            #2 0x5625e5326703 in cpu_map__read util/cpumap.c:103
            #3 0x5625e53267ef in cpu_map__read_all_cpu_map util/cpumap.c:120
            #4 0x5625e5326915 in cpu_map__new util/cpumap.c:135
            #5 0x5625e517b355 in test__openat_syscall_event_on_all_cpus tests/openat-syscall-all-cpus.c:36
            #6 0x5625e51528e6 in run_test tests/builtin-test.c:358
            #7 0x5625e5152baf in test_and_print tests/builtin-test.c:388
            #8 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
            #9 0x5625e515572f in cmd_test tests/builtin-test.c:722
            #10 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #11 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #12 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #13 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #14 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: f30a79b0 ("perf tools: Add reference counting for cpu_map object")
      Link: http://lkml.kernel.org/r/20190316080556.3075-15-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a0898f57
    • Arnaldo Carvalho de Melo's avatar
      perf evsel: Free evsel->counts in perf_evsel__exit() · 952d449d
      Arnaldo Carvalho de Melo authored
      [ Upstream commit 42dfa451 ]
      
      Using gcc's ASan, Changbin reports:
      
        =================================================================
        ==7494==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 48 byte(s) in 1 object(s) allocated from:
            #0 0x7f0333a89138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
            #1 0x5625e5330a5e in zalloc util/util.h:23
            #2 0x5625e5330a9b in perf_counts__new util/counts.c:10
            #3 0x5625e5330ca0 in perf_evsel__alloc_counts util/counts.c:47
            #4 0x5625e520d8e5 in __perf_evsel__read_on_cpu util/evsel.c:1505
            #5 0x5625e517a985 in perf_evsel__read_on_cpu /home/work/linux/tools/perf/util/evsel.h:347
            #6 0x5625e517ad1a in test__openat_syscall_event tests/openat-syscall.c:47
            #7 0x5625e51528e6 in run_test tests/builtin-test.c:358
            #8 0x5625e5152baf in test_and_print tests/builtin-test.c:388
            #9 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
            #10 0x5625e515572f in cmd_test tests/builtin-test.c:722
            #11 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #12 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #13 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #14 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #15 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      
        Indirect leak of 72 byte(s) in 1 object(s) allocated from:
            #0 0x7f0333a89138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
            #1 0x5625e532560d in zalloc util/util.h:23
            #2 0x5625e532566b in xyarray__new util/xyarray.c:10
            #3 0x5625e5330aba in perf_counts__new util/counts.c:15
            #4 0x5625e5330ca0 in perf_evsel__alloc_counts util/counts.c:47
            #5 0x5625e520d8e5 in __perf_evsel__read_on_cpu util/evsel.c:1505
            #6 0x5625e517a985 in perf_evsel__read_on_cpu /home/work/linux/tools/perf/util/evsel.h:347
            #7 0x5625e517ad1a in test__openat_syscall_event tests/openat-syscall.c:47
            #8 0x5625e51528e6 in run_test tests/builtin-test.c:358
            #9 0x5625e5152baf in test_and_print tests/builtin-test.c:388
            #10 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
            #11 0x5625e515572f in cmd_test tests/builtin-test.c:722
            #12 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #13 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #14 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #15 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #16 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      
      His patch took care of evsel->prev_raw_counts, but the above backtraces
      are about evsel->counts, so fix that instead.
      Reported-by: default avatarChangbin Du <changbin.du@gmail.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Link: https://lkml.kernel.org/n/tip-hd1x13g59f0nuhe4anxhsmfp@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      952d449d
    • Changbin Du's avatar
      perf hist: Add missing map__put() in error case · ff22178b
      Changbin Du authored
      [ Upstream commit cb6186ae ]
      
      We need to map__put() before returning from failure of
      sample__resolve_callchain().
      
      Detected with gcc's ASan.
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Krister Johansen <kjlx@templeofstupid.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 9c68ae98 ("perf callchain: Reference count maps")
      Link: http://lkml.kernel.org/r/20190316080556.3075-10-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ff22178b
    • Changbin Du's avatar
      perf top: Fix error handling in cmd_top() · dac5fedf
      Changbin Du authored
      [ Upstream commit 70c819e4 ]
      
      We should go to the cleanup path, to avoid leaks, detected using gcc's
      ASan.
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/20190316080556.3075-9-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dac5fedf
    • Changbin Du's avatar
      perf build-id: Fix memory leak in print_sdt_events() · 801a5901
      Changbin Du authored
      [ Upstream commit 8bde8516 ]
      
      Detected with gcc's ASan:
      
        Direct leak of 4356 byte(s) in 120 object(s) allocated from:
            #0 0x7ff1a2b5a070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
            #1 0x55719aef4814 in build_id_cache__origname util/build-id.c:215
            #2 0x55719af649b6 in print_sdt_events util/parse-events.c:2339
            #3 0x55719af66272 in print_events util/parse-events.c:2542
            #4 0x55719ad1ecaa in cmd_list /home/changbin/work/linux/tools/perf/builtin-list.c:58
            #5 0x55719aec745d in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #6 0x55719aec7d1a in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #7 0x55719aec8184 in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #8 0x55719aeca41a in main /home/changbin/work/linux/tools/perf/perf.c:520
            #9 0x7ff1a07ae09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 40218dae ("perf list: Show SDT and pre-cached events")
      Link: http://lkml.kernel.org/r/20190316080556.3075-7-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      801a5901
    • Changbin Du's avatar
      perf config: Fix a memory leak in collect_config() · b820793a
      Changbin Du authored
      [ Upstream commit 54569ba4 ]
      
      Detected with gcc's ASan:
      
        Direct leak of 66 byte(s) in 5 object(s) allocated from:
            #0 0x7ff3b1f32070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
            #1 0x560c8761034d in collect_config util/config.c:597
            #2 0x560c8760d9cb in get_value util/config.c:169
            #3 0x560c8760dfd7 in perf_parse_file util/config.c:285
            #4 0x560c8760e0d2 in perf_config_from_file util/config.c:476
            #5 0x560c876108fd in perf_config_set__init util/config.c:661
            #6 0x560c87610c72 in perf_config_set__new util/config.c:709
            #7 0x560c87610d2f in perf_config__init util/config.c:718
            #8 0x560c87610e5d in perf_config util/config.c:730
            #9 0x560c875ddea0 in main /home/changbin/work/linux/tools/perf/perf.c:442
            #10 0x7ff3afb8609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Fixes: 20105ca1 ("perf config: Introduce perf_config_set class")
      Link: http://lkml.kernel.org/r/20190316080556.3075-6-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b820793a
    • Changbin Du's avatar
      perf config: Fix an error in the config template documentation · 0d85f280
      Changbin Du authored
      [ Upstream commit 9b40dff7 ]
      
      The option 'sort-order' should be 'sort_order'.
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 893c5c79 ("perf config: Show default report configuration in example and docs")
      Link: http://lkml.kernel.org/r/20190316080556.3075-5-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0d85f280
    • Changbin Du's avatar
      perf list: Don't forget to drop the reference to the allocated thread_map · 96f74822
      Changbin Du authored
      [ Upstream commit 39df730b ]
      
      Detected via gcc's ASan:
      
        Direct leak of 2048 byte(s) in 64 object(s) allocated from:
          6     #0 0x7f606512e370 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee370)
          7     #1 0x556b0f1d7ddd in thread_map__realloc util/thread_map.c:43
          8     #2 0x556b0f1d84c7 in thread_map__new_by_tid util/thread_map.c:85
          9     #3 0x556b0f0e045e in is_event_supported util/parse-events.c:2250
         10     #4 0x556b0f0e1aa1 in print_hwcache_events util/parse-events.c:2382
         11     #5 0x556b0f0e3231 in print_events util/parse-events.c:2514
         12     #6 0x556b0ee0a66e in cmd_list /home/changbin/work/linux/tools/perf/builtin-list.c:58
         13     #7 0x556b0f01e0ae in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
         14     #8 0x556b0f01e859 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
         15     #9 0x556b0f01edc8 in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
         16     #10 0x556b0f01f71f in main /home/changbin/work/linux/tools/perf/perf.c:520
         17     #11 0x7f6062ccf09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 89896051 ("perf tools: Do not put a variable sized type not at the end of a struct")
      Link: http://lkml.kernel.org/r/20190316080556.3075-3-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      96f74822
    • David Arcari's avatar
      tools/power turbostat: return the exit status of a command · 182d2649
      David Arcari authored
      [ Upstream commit 2a954966 ]
      
      turbostat failed to return a non-zero exit status even though the
      supplied command (turbostat <command>) failed.  Currently when turbostat
      forks a command it returns zero instead of the actual exit status of the
      command.  Modify the code to return the exit status.
      Signed-off-by: default avatarDavid Arcari <darcari@redhat.com>
      Acked-by: default avatarLen Brown <len.brown@intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      182d2649
    • Matteo Croce's avatar
      x86/mm: Don't leak kernel addresses · 3fb2d0a2
      Matteo Croce authored
      [ Upstream commit a3151724 ]
      
      Since commit:
      
        ad67b74d ("printk: hash addresses printed with %p")
      
      at boot "____ptrval____" is printed instead of actual addresses:
      
          found SMP MP-table at [mem 0x000f5cc0-0x000f5ccf] mapped at [(____ptrval____)]
      
      Instead of changing the print to "%px", and leaking a kernel addresses,
      just remove the print completely, like in:
      
        071929db ("arm64: Stop printing the virtual memory layout").
      Signed-off-by: default avatarMatteo Croce <mcroce@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3fb2d0a2
    • Maurizio Lombardi's avatar
      scsi: iscsi: flush running unbind operations when removing a session · 58ad2f1b
      Maurizio Lombardi authored
      [ Upstream commit 165aa2bf ]
      
      In some cases, the iscsi_remove_session() function is called while an
      unbind_work operation is still running.  This may cause a situation where
      sysfs objects are removed in an incorrect order, triggering a kernel
      warning.
      
      [  605.249442] ------------[ cut here ]------------
      [  605.259180] sysfs group 'power' not found for kobject 'target2:0:0'
      [  605.321371] WARNING: CPU: 1 PID: 26794 at fs/sysfs/group.c:235 sysfs_remove_group+0x76/0x80
      [  605.341266] Modules linked in: dm_service_time target_core_user target_core_pscsi target_core_file target_core_iblock iscsi_target_mod target_core_mod nls_utf8 isofs ppdev bochs_drm nfit ttm libnvdimm drm_kms_helper syscopyarea sysfillrect sysimgblt joydev pcspkr fb_sys_fops drm i2c_piix4 sg parport_pc parport xfs libcrc32c dm_multipath sr_mod sd_mod cdrom ata_generic 8021q garp mrp ata_piix stp crct10dif_pclmul crc32_pclmul llc libata crc32c_intel virtio_net net_failover ghash_clmulni_intel serio_raw failover sunrpc dm_mirror dm_region_hash dm_log dm_mod be2iscsi bnx2i cnic uio cxgb4i cxgb4 libcxgbi libcxgb qla4xxx iscsi_boot_sysfs iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi
      [  605.627479] CPU: 1 PID: 26794 Comm: kworker/u32:2 Not tainted 4.18.0-60.el8.x86_64 #1
      [  605.721401] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20180724_192412-buildhw-07.phx2.fedoraproject.org-1.fc29 04/01/2014
      [  605.823651] Workqueue: scsi_wq_2 __iscsi_unbind_session [scsi_transport_iscsi]
      [  605.830940] RIP: 0010:sysfs_remove_group+0x76/0x80
      [  605.922907] Code: 48 89 df 5b 5d 41 5c e9 38 c4 ff ff 48 89 df e8 e0 bf ff ff eb cb 49 8b 14 24 48 8b 75 00 48 c7 c7 38 73 cb a7 e8 24 77 d7 ff <0f> 0b 5b 5d 41 5c c3 0f 1f 00 0f 1f 44 00 00 41 56 41 55 41 54 55
      [  606.122304] RSP: 0018:ffffbadcc8d1bda8 EFLAGS: 00010286
      [  606.218492] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
      [  606.326381] RDX: ffff98bdfe85eb40 RSI: ffff98bdfe856818 RDI: ffff98bdfe856818
      [  606.514498] RBP: ffffffffa7ab73e0 R08: 0000000000000268 R09: 0000000000000007
      [  606.529469] R10: 0000000000000000 R11: ffffffffa860d9ad R12: ffff98bdf978e838
      [  606.630535] R13: ffff98bdc2cd4010 R14: ffff98bdc2cd3ff0 R15: ffff98bdc2cd4000
      [  606.824707] FS:  0000000000000000(0000) GS:ffff98bdfe840000(0000) knlGS:0000000000000000
      [  607.018333] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  607.117844] CR2: 00007f84b78ac024 CR3: 000000002c00a003 CR4: 00000000003606e0
      [  607.117844] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  607.420926] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  607.524236] Call Trace:
      [  607.530591]  device_del+0x56/0x350
      [  607.624393]  ? ata_tlink_match+0x30/0x30 [libata]
      [  607.727805]  ? attribute_container_device_trigger+0xb4/0xf0
      [  607.829911]  scsi_target_reap_ref_release+0x39/0x50
      [  607.928572]  scsi_remove_target+0x1a2/0x1d0
      [  608.017350]  __iscsi_unbind_session+0xb3/0x160 [scsi_transport_iscsi]
      [  608.117435]  process_one_work+0x1a7/0x360
      [  608.132917]  worker_thread+0x30/0x390
      [  608.222900]  ? pwq_unbound_release_workfn+0xd0/0xd0
      [  608.323989]  kthread+0x112/0x130
      [  608.418318]  ? kthread_bind+0x30/0x30
      [  608.513821]  ret_from_fork+0x35/0x40
      [  608.613909] ---[ end trace 0b98c310c8a6138c ]---
      Signed-off-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
      Acked-by: default avatarChris Leech <cleech@redhat.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      58ad2f1b
    • Zhang Rui's avatar
      thermal/intel_powerclamp: fix truncated kthread name · f1e062e8
      Zhang Rui authored
      [ Upstream commit e925b5be ]
      
      kthread name only allows 15 characters (TASK_COMMON_LEN is 16).
      Thus rename the kthreads created by intel_powerclamp driver from
      "kidle_inject/ + decimal cpuid" to "kidle_inj/ + decimal cpuid"
      to avoid truncated kthead name for cpu 100 and later.
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f1e062e8
    • Matthew Garrett's avatar
      thermal/int340x_thermal: fix mode setting · 637f86d2
      Matthew Garrett authored
      [ Upstream commit 396ee4d0 ]
      
      int3400 only pushes the UUID into the firmware when the mode is flipped
      to "enable". The current code only exposes the mode flag if the firmware
      supports the PASSIVE_1 UUID, which not all machines do. Remove the
      restriction.
      Signed-off-by: default avatarMatthew Garrett <mjg59@google.com>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      637f86d2
    • Matthew Garrett's avatar
      thermal/int340x_thermal: Add additional UUIDs · f37079c7
      Matthew Garrett authored
      [ Upstream commit 16fc8eca ]
      
      Add more supported DPTF policies than the driver currently exposes.
      Signed-off-by: default avatarMatthew Garrett <mjg59@google.com>
      Cc: Nisha Aram <nisha.aram@intel.com>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f37079c7
    • Phil Elwell's avatar
      thermal: bcm2835: Fix crash in bcm2835_thermal_debugfs · 6aa84e8a
      Phil Elwell authored
      [ Upstream commit 35122495 ]
      
      "cat /sys/kernel/debug/bcm2835_thermal/regset" causes a NULL pointer
      dereference in bcm2835_thermal_debugfs. The driver makes use of the
      implementation details of the thermal framework to retrieve a pointer
      to its private data from a struct thermal_zone_device, and gets it
      wrong - leading to the crash. Instead, store its private data as the
      drvdata and retrieve the thermal_zone_device pointer from it.
      
      Fixes: bcb7dd9e ("thermal: bcm2835: add thermal driver for bcm2835 SoC")
      Signed-off-by: default avatarPhil Elwell <phil@raspberrypi.org>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6aa84e8a
    • Luc Van Oostenryck's avatar
      thermal/intel_powerclamp: fix __percpu declaration of worker_data · 643deb59
      Luc Van Oostenryck authored
      [ Upstream commit aa36e361 ]
      
      This variable is declared as:
      	static struct powerclamp_worker_data * __percpu worker_data;
      In other words, a percpu pointer to struct ...
      
      But this variable not used like so but as a pointer to a percpu
      struct powerclamp_worker_data.
      
      So fix the declaration as:
      	static struct powerclamp_worker_data __percpu *worker_data;
      
      This also quiets Sparse's warnings from __verify_pcpu_ptr(), like:
        494:49: warning: incorrect type in initializer (different address spaces)
        494:49:    expected void const [noderef] <asn:3> *__vpp_verify
        494:49:    got struct powerclamp_worker_data *
      Signed-off-by: default avatarLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      643deb59
    • Colin Ian King's avatar
      ALSA: opl3: fix mismatch between snd_opl3_drum_switch definition and declaration · 4467b4fd
      Colin Ian King authored
      [ Upstream commit b4748e7a ]
      
      The function snd_opl3_drum_switch declaration in the header file
      has the order of the two arguments on_off and vel swapped when
      compared to the definition arguments of vel and on_off.  Fix this
      by swapping them around to match the definition.
      
      This error predates the git history, so no idea when this error
      was introduced.
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4467b4fd
    • Arnd Bergmann's avatar
      mmc: davinci: remove extraneous __init annotation · eebec30d
      Arnd Bergmann authored
      [ Upstream commit 9ce58dd7 ]
      
      Building with clang finds a mistaken __init tag:
      
      WARNING: vmlinux.o(.text+0x5e4250): Section mismatch in reference from the function davinci_mmcsd_probe() to the function .init.text:init_mmcsd_host()
      The function davinci_mmcsd_probe() references
      the function __init init_mmcsd_host().
      This is often because davinci_mmcsd_probe lacks a __init
      annotation or the annotation of init_mmcsd_host is wrong.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eebec30d
    • Jack Morgenstein's avatar
      IB/mlx4: Fix race condition between catas error reset and aliasguid flows · e04dc07f
      Jack Morgenstein authored
      [ Upstream commit 587443e7 ]
      
      Code review revealed a race condition which could allow the catas error
      flow to interrupt the alias guid query post mechanism at random points.
      Thiis is fixed by doing cancel_delayed_work_sync() instead of
      cancel_delayed_work() during the alias guid mechanism destroy flow.
      
      Fixes: a0c64a17 ("mlx4: Add alias_guid mechanism")
      Signed-off-by: default avatarJack Morgenstein <jackm@dev.mellanox.co.il>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e04dc07f
    • Andy Shevchenko's avatar
      auxdisplay: hd44780: Fix memory leak on ->remove() · bfd5834e
      Andy Shevchenko authored
      [ Upstream commit 41c8d0ad ]
      
      We have to free on ->remove() the allocated resources on ->probe().
      
      Fixes: d47d8836 ("auxdisplay: Add HD44780 Character LCD support")
      Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bfd5834e
    • Kangjie Lu's avatar
      ALSA: sb8: add a check for request_region · b042245b
      Kangjie Lu authored
      [ Upstream commit dcd0feac ]
      
      In case request_region fails, the fix returns an error code to
      avoid NULL pointer dereference.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b042245b
    • Kangjie Lu's avatar
      ALSA: echoaudio: add a check for ioremap_nocache · 7d831a05
      Kangjie Lu authored
      [ Upstream commit 6ade657d ]
      
      In case ioremap_nocache fails, the fix releases chip and returns
      an error code upstream to avoid NULL pointer dereference.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7d831a05
    • Lukas Czerner's avatar
      ext4: report real fs size after failed resize · ce1bdbed
      Lukas Czerner authored
      [ Upstream commit 6c732840 ]
      
      Currently when the file system resize using ext4_resize_fs() fails it
      will report into log that "resized filesystem to <requested block
      count>".  However this may not be true in the case of failure.  Use the
      current block count as returned by ext4_blocks_count() to report the
      block count.
      
      Additionally, report a warning that "error occurred during file system
      resize"
      Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ce1bdbed
    • Lukas Czerner's avatar
      ext4: add missing brelse() in add_new_gdb_meta_bg() · 7a82651d
      Lukas Czerner authored
      [ Upstream commit d64264d6 ]
      
      Currently in add_new_gdb_meta_bg() there is a missing brelse of gdb_bh
      in case ext4_journal_get_write_access() fails.
      Additionally kvfree() is missing in the same error path. Fix it by
      moving the ext4_journal_get_write_access() before the ext4 sb update as
      Ted suggested and release n_group_desc and gdb_bh in case it fails.
      
      Fixes: 61a9c11e ("ext4: add missing brelse() add_new_gdb_meta_bg()'s error path")
      Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7a82651d
    • Stephane Eranian's avatar
      perf/core: Restore mmap record type correctly · 103eb70c
      Stephane Eranian authored
      [ Upstream commit d9c1bb2f ]
      
      On mmap(), perf_events generates a RECORD_MMAP record and then checks
      which events are interested in this record. There are currently 2
      versions of mmap records: RECORD_MMAP and RECORD_MMAP2. MMAP2 is larger.
      The event configuration controls which version the user level tool
      accepts.
      
      If the event->attr.mmap2=1 field then MMAP2 record is returned.  The
      perf_event_mmap_output() takes care of this. It checks attr->mmap2 and
      corrects the record fields before putting it in the sampling buffer of
      the event.  At the end the function restores the modified MMAP record
      fields.
      
      The problem is that the function restores the size but not the type.
      Thus, if a subsequent event only accepts MMAP type, then it would
      instead receive an MMAP2 record with a size of MMAP record.
      
      This patch fixes the problem by restoring the record type on exit.
      Signed-off-by: default avatarStephane Eranian <eranian@google.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Fixes: 13d7a241 ("perf: Add attr->mmap2 attribute to an event")
      Link: http://lkml.kernel.org/r/20190307185233.225521-1-eranian@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      103eb70c
    • Corentin Labbe's avatar
      arc: hsdk_defconfig: Enable CONFIG_BLK_DEV_RAM · 2d6453a3
      Corentin Labbe authored
      [ Upstream commit 0728aeb7 ]
      
      We have now a HSDK device in our kernelci lab, but kernel builded via
      the hsdk_defconfig lacks ramfs supports, so it cannot boot kernelci jobs
      yet.
      
      So this patch enable CONFIG_BLK_DEV_RAM in hsdk_defconfig.
      Signed-off-by: default avatarCorentin Labbe <clabbe@baylibre.com>
      Acked-by: default avatarAlexey Brodkin <abrodkin@synopsys.com>
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2d6453a3
    • Eugeniy Paltsev's avatar
      ARC: u-boot args: check that magic number is correct · 8232cdfd
      Eugeniy Paltsev authored
      [ Upstream commit edb64bca ]
      
      In case of devboards we really often disable bootloader and load
      Linux image in memory via JTAG. Even if kernel tries to verify
      uboot_tag and uboot_arg there is sill a chance that we treat some
      garbage in registers as valid u-boot arguments in JTAG case.
      E.g. it is enough to have '1' in r0 to treat any value in r2 as
      a boot command line.
      
      So check that magic number passed from u-boot is correct and drop
      u-boot arguments otherwise. That helps to reduce the possibility
      of using garbage as u-boot arguments in JTAG case.
      
      We can safely check U-boot magic value (0x0) in linux passed via
      r1 register as U-boot pass it from the beginning. So there is no
      backward-compatibility issues.
      Signed-off-by: default avatarEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8232cdfd
  2. 17 Apr, 2019 11 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.14.112 · 58b454eb
      Greg Kroah-Hartman authored
      58b454eb
    • Tomohiro Mayama's avatar
      arm64: dts: rockchip: Fix vcc_host1_5v GPIO polarity on rk3328-rock64 · aadf6028
      Tomohiro Mayama authored
      commit a8772e5d upstream.
      
      This patch makes USB ports functioning again.
      
      Fixes: 955bebde ("arm64: dts: rockchip: add rk3328-rock64 board")
      Cc: stable@vger.kernel.org
      Suggested-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: default avatarTomohiro Mayama <parly-gh@iris.mystia.org>
      Tested-by: default avatarKatsuhiro Suzuki <katsuhiro@katsuster.net>
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aadf6028
    • Katsuhiro Suzuki's avatar
      arm64: dts: rockchip: fix vcc_host1_5v pin assign on rk3328-rock64 · 1debe428
      Katsuhiro Suzuki authored
      commit ef05bcb6 upstream.
      
      This patch fixes pin assign of vcc_host1_5v. This regulator is
      controlled by USB20_HOST_DRV signal.
      
      ROCK64 schematic says that GPIO0_A2 pin is used as USB20_HOST_DRV.
      GPIO0_D3 pin is for SPDIF_TX_M0.
      Signed-off-by: default avatarKatsuhiro Suzuki <katsuhiro@katsuster.net>
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1debe428
    • Ilya Dryomov's avatar
      dm table: propagate BDI_CAP_STABLE_WRITES to fix sporadic checksum errors · 2f513431
      Ilya Dryomov authored
      commit eb40c0ac upstream.
      
      Some devices don't use blk_integrity but still want stable pages
      because they do their own checksumming.  Examples include rbd and iSCSI
      when data digests are negotiated.  Stacking DM (and thus LVM) on top of
      these devices results in sporadic checksum errors.
      
      Set BDI_CAP_STABLE_WRITES if any underlying device has it set.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f513431
    • Andre Przywara's avatar
      PCI: Add function 1 DMA alias quirk for Marvell 9170 SATA controller · 5b5832ca
      Andre Przywara authored
      commit 9cde402a upstream.
      
      There is a Marvell 88SE9170 PCIe SATA controller I found on a board here.
      Some quick testing with the ARM SMMU enabled reveals that it suffers from
      the same requester ID mixup problems as the other Marvell chips listed
      already.
      
      Add the PCI vendor/device ID to the list of chips which need the
      workaround.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      CC: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5b5832ca
    • Lendacky, Thomas's avatar
      x86/perf/amd: Remove need to check "running" bit in NMI handler · 52abad47
      Lendacky, Thomas authored
      commit 3966c3fe upstream.
      
      Spurious interrupt support was added to perf in the following commit, almost
      a decade ago:
      
        63e6be6d ("perf, x86: Catch spurious interrupts after disabling counters")
      
      The two previous patches (resolving the race condition when disabling a
      PMC and NMI latency mitigation) allow for the removal of this older
      spurious interrupt support.
      
      Currently in x86_pmu_stop(), the bit for the PMC in the active_mask bitmap
      is cleared before disabling the PMC, which sets up a race condition. This
      race condition was mitigated by introducing the running bitmap. That race
      condition can be eliminated by first disabling the PMC, waiting for PMC
      reset on overflow and then clearing the bit for the PMC in the active_mask
      bitmap. The NMI handler will not re-enable a disabled counter.
      
      If x86_pmu_stop() is called from the perf NMI handler, the NMI latency
      mitigation support will guard against any unhandled NMI messages.
      Signed-off-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: <stable@vger.kernel.org> # 4.14.x-
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: https://lkml.kernel.org/r/Message-ID:
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      52abad47
    • Lendacky, Thomas's avatar
      x86/perf/amd: Resolve NMI latency issues for active PMCs · b09d7548
      Lendacky, Thomas authored
      commit 6d3edaae upstream.
      
      On AMD processors, the detection of an overflowed PMC counter in the NMI
      handler relies on the current value of the PMC. So, for example, to check
      for overflow on a 48-bit counter, bit 47 is checked to see if it is 1 (not
      overflowed) or 0 (overflowed).
      
      When the perf NMI handler executes it does not know in advance which PMC
      counters have overflowed. As such, the NMI handler will process all active
      PMC counters that have overflowed. NMI latency in newer AMD processors can
      result in multiple overflowed PMC counters being processed in one NMI and
      then a subsequent NMI, that does not appear to be a back-to-back NMI, not
      finding any PMC counters that have overflowed. This may appear to be an
      unhandled NMI resulting in either a panic or a series of messages,
      depending on how the kernel was configured.
      
      To mitigate this issue, add an AMD handle_irq callback function,
      amd_pmu_handle_irq(), that will invoke the common x86_pmu_handle_irq()
      function and upon return perform some additional processing that will
      indicate if the NMI has been handled or would have been handled had an
      earlier NMI not handled the overflowed PMC. Using a per-CPU variable, a
      minimum value of the number of active PMCs or 2 will be set whenever a
      PMC is active. This is used to indicate the possible number of NMIs that
      can still occur. The value of 2 is used for when an NMI does not arrive
      at the LAPIC in time to be collapsed into an already pending NMI. Each
      time the function is called without having handled an overflowed counter,
      the per-CPU value is checked. If the value is non-zero, it is decremented
      and the NMI indicates that it handled the NMI. If the value is zero, then
      the NMI indicates that it did not handle the NMI.
      Signed-off-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: <stable@vger.kernel.org> # 4.14.x-
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: https://lkml.kernel.org/r/Message-ID:
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b09d7548
    • Lendacky, Thomas's avatar
      x86/perf/amd: Resolve race condition when disabling PMC · 58d78a43
      Lendacky, Thomas authored
      commit 914123fa upstream.
      
      On AMD processors, the detection of an overflowed counter in the NMI
      handler relies on the current value of the counter. So, for example, to
      check for overflow on a 48 bit counter, bit 47 is checked to see if it
      is 1 (not overflowed) or 0 (overflowed).
      
      There is currently a race condition present when disabling and then
      updating the PMC. Increased NMI latency in newer AMD processors makes this
      race condition more pronounced. If the counter value has overflowed, it is
      possible to update the PMC value before the NMI handler can run. The
      updated PMC value is not an overflowed value, so when the perf NMI handler
      does run, it will not find an overflowed counter. This may appear as an
      unknown NMI resulting in either a panic or a series of messages, depending
      on how the kernel is configured.
      
      To eliminate this race condition, the PMC value must be checked after
      disabling the counter. Add an AMD function, amd_pmu_disable_all(), that
      will wait for the NMI handler to reset any active and overflowed counter
      after calling x86_pmu_disable_all().
      Signed-off-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: <stable@vger.kernel.org> # 4.14.x-
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: https://lkml.kernel.org/r/Message-ID:
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58d78a43
    • Max Filippov's avatar
      xtensa: fix return_address · 9ab04e84
      Max Filippov authored
      commit ada770b1 upstream.
      
      return_address returns the address that is one level higher in the call
      stack than requested in its argument, because level 0 corresponds to its
      caller's return address. Use requested level as the number of stack
      frames to skip.
      
      This fixes the address reported by might_sleep and friends.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9ab04e84
    • Mel Gorman's avatar
      sched/fair: Do not re-read ->h_load_next during hierarchical load calculation · b711ae12
      Mel Gorman authored
      commit 0e9f0245 upstream.
      
      A NULL pointer dereference bug was reported on a distribution kernel but
      the same issue should be present on mainline kernel. It occured on s390
      but should not be arch-specific.  A partial oops looks like:
      
        Unable to handle kernel pointer dereference in virtual kernel address space
        ...
        Call Trace:
          ...
          try_to_wake_up+0xfc/0x450
          vhost_poll_wakeup+0x3a/0x50 [vhost]
          __wake_up_common+0xbc/0x178
          __wake_up_common_lock+0x9e/0x160
          __wake_up_sync_key+0x4e/0x60
          sock_def_readable+0x5e/0x98
      
      The bug hits any time between 1 hour to 3 days. The dereference occurs
      in update_cfs_rq_h_load when accumulating h_load. The problem is that
      cfq_rq->h_load_next is not protected by any locking and can be updated
      by parallel calls to task_h_load. Depending on the compiler, code may be
      generated that re-reads cfq_rq->h_load_next after the check for NULL and
      then oops when reading se->avg.load_avg. The dissassembly showed that it
      was possible to reread h_load_next after the check for NULL.
      
      While this does not appear to be an issue for later compilers, it's still
      an accident if the correct code is generated. Full locking in this path
      would have high overhead so this patch uses READ_ONCE to read h_load_next
      only once and check for NULL before dereferencing. It was confirmed that
      there were no further oops after 10 days of testing.
      
      As Peter pointed out, it is also necessary to use WRITE_ONCE() to avoid any
      potential problems with store tearing.
      Signed-off-by: default avatarMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarValentin Schneider <valentin.schneider@arm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: <stable@vger.kernel.org>
      Fixes: 68520796 ("sched: Move h_load calculation to task_h_load()")
      Link: https://lkml.kernel.org/r/20190319123610.nsivgf3mjbjjesxb@techsingularity.netSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b711ae12
    • Dan Carpenter's avatar
      xen: Prevent buffer overflow in privcmd ioctl · 4f0b27cf
      Dan Carpenter authored
      commit 42d8644b upstream.
      
      The "call" variable comes from the user in privcmd_ioctl_hypercall().
      It's an offset into the hypercall_page[] which has (PAGE_SIZE / 32)
      elements.  We need to put an upper bound on it to prevent an out of
      bounds access.
      
      Cc: stable@vger.kernel.org
      Fixes: 1246ae0b ("xen: add variable hypercall caller")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4f0b27cf