Skip to content

Commit 22f12a0

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-urgent-for-mingo-5.4-20191017' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes from Arnaldo Carvalho de Melo: perf buildid-cache: Adrian Hunter: - Fix mode setting in copyfile_mode_ns() when copying /proc/kcore. perf evlist: Andi Kleen: - Fix freeing id arrays. tools headers: - Sync sched.h anc kvm.h headers with the kernel sources. perf jvmti: Thomas Richter: - Link against tools/lib/ctype.o to have weak strlcpy(). perf annotate: Gustavo A. R. Silva: - Fix multiple memory and file descriptor leaks, found by coverity. perf c2c/kmem: Yunfeng Ye: - Fix leaks in error handling paths in 'perf c2c', 'perf kmem', found by internal static analysis tool. Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents 13301c6 + 1abecfc commit 22f12a0

File tree

12 files changed

+65
-17
lines changed

12 files changed

+65
-17
lines changed

tools/arch/x86/include/uapi/asm/svm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#define SVM_EXIT_MWAIT 0x08b
7676
#define SVM_EXIT_MWAIT_COND 0x08c
7777
#define SVM_EXIT_XSETBV 0x08d
78+
#define SVM_EXIT_RDPRU 0x08e
7879
#define SVM_EXIT_NPF 0x400
7980
#define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401
8081
#define SVM_EXIT_AVIC_UNACCELERATED_ACCESS 0x402

tools/arch/x86/include/uapi/asm/vmx.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
#define EXIT_REASON_PML_FULL 62
8787
#define EXIT_REASON_XSAVES 63
8888
#define EXIT_REASON_XRSTORS 64
89+
#define EXIT_REASON_UMWAIT 67
90+
#define EXIT_REASON_TPAUSE 68
8991

9092
#define VMX_EXIT_REASONS \
9193
{ EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \
@@ -144,7 +146,9 @@
144146
{ EXIT_REASON_RDSEED, "RDSEED" }, \
145147
{ EXIT_REASON_PML_FULL, "PML_FULL" }, \
146148
{ EXIT_REASON_XSAVES, "XSAVES" }, \
147-
{ EXIT_REASON_XRSTORS, "XRSTORS" }
149+
{ EXIT_REASON_XRSTORS, "XRSTORS" }, \
150+
{ EXIT_REASON_UMWAIT, "UMWAIT" }, \
151+
{ EXIT_REASON_TPAUSE, "TPAUSE" }
148152

149153
#define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1
150154
#define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2

tools/include/uapi/linux/kvm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ struct kvm_ppc_resize_hpt {
999999
#define KVM_CAP_ARM_PTRAUTH_GENERIC 172
10001000
#define KVM_CAP_PMU_EVENT_FILTER 173
10011001
#define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174
1002+
#define KVM_CAP_HYPERV_DIRECT_TLBFLUSH 175
10021003

10031004
#ifdef KVM_CAP_IRQ_ROUTING
10041005

@@ -1145,6 +1146,7 @@ struct kvm_dirty_tlb {
11451146
#define KVM_REG_S390 0x5000000000000000ULL
11461147
#define KVM_REG_ARM64 0x6000000000000000ULL
11471148
#define KVM_REG_MIPS 0x7000000000000000ULL
1149+
#define KVM_REG_RISCV 0x8000000000000000ULL
11481150

11491151
#define KVM_REG_SIZE_SHIFT 52
11501152
#define KVM_REG_SIZE_MASK 0x00f0000000000000ULL

tools/include/uapi/linux/sched.h

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,31 @@
3333
#define CLONE_NEWNET 0x40000000 /* New network namespace */
3434
#define CLONE_IO 0x80000000 /* Clone io context */
3535

36-
/*
37-
* Arguments for the clone3 syscall
36+
#ifndef __ASSEMBLY__
37+
/**
38+
* struct clone_args - arguments for the clone3 syscall
39+
* @flags: Flags for the new process as listed above.
40+
* All flags are valid except for CSIGNAL and
41+
* CLONE_DETACHED.
42+
* @pidfd: If CLONE_PIDFD is set, a pidfd will be
43+
* returned in this argument.
44+
* @child_tid: If CLONE_CHILD_SETTID is set, the TID of the
45+
* child process will be returned in the child's
46+
* memory.
47+
* @parent_tid: If CLONE_PARENT_SETTID is set, the TID of
48+
* the child process will be returned in the
49+
* parent's memory.
50+
* @exit_signal: The exit_signal the parent process will be
51+
* sent when the child exits.
52+
* @stack: Specify the location of the stack for the
53+
* child process.
54+
* @stack_size: The size of the stack for the child process.
55+
* @tls: If CLONE_SETTLS is set, the tls descriptor
56+
* is set to tls.
57+
*
58+
* The structure is versioned by size and thus extensible.
59+
* New struct members must go at the end of the struct and
60+
* must be properly 64bit aligned.
3861
*/
3962
struct clone_args {
4063
__aligned_u64 flags;
@@ -46,6 +69,9 @@ struct clone_args {
4669
__aligned_u64 stack_size;
4770
__aligned_u64 tls;
4871
};
72+
#endif
73+
74+
#define CLONE_ARGS_SIZE_VER0 64 /* sizeof first published struct */
4975

5076
/*
5177
* Scheduling policies

tools/perf/builtin-c2c.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,6 +2635,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
26352635
bool add_sym = false;
26362636
bool add_dso = false;
26372637
bool add_src = false;
2638+
int ret = 0;
26382639

26392640
if (!buf)
26402641
return -ENOMEM;
@@ -2653,7 +2654,8 @@ static int build_cl_output(char *cl_sort, bool no_source)
26532654
add_dso = true;
26542655
} else if (strcmp(tok, "offset")) {
26552656
pr_err("unrecognized sort token: %s\n", tok);
2656-
return -EINVAL;
2657+
ret = -EINVAL;
2658+
goto err;
26572659
}
26582660
}
26592661

@@ -2676,13 +2678,15 @@ static int build_cl_output(char *cl_sort, bool no_source)
26762678
add_sym ? "symbol," : "",
26772679
add_dso ? "dso," : "",
26782680
add_src ? "cl_srcline," : "",
2679-
"node") < 0)
2680-
return -ENOMEM;
2681+
"node") < 0) {
2682+
ret = -ENOMEM;
2683+
goto err;
2684+
}
26812685

26822686
c2c.show_src = add_src;
2683-
2687+
err:
26842688
free(buf);
2685-
return 0;
2689+
return ret;
26862690
}
26872691

26882692
static int setup_coalesce(const char *coalesce, bool no_source)

tools/perf/builtin-kmem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ static char *compact_gfp_flags(char *gfp_flags)
691691
new = realloc(new_flags, len + strlen(cpt) + 2);
692692
if (new == NULL) {
693693
free(new_flags);
694+
free(orig_flags);
694695
return NULL;
695696
}
696697

tools/perf/jvmti/Build

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ jvmti-y += libjvmti.o
22
jvmti-y += jvmti_agent.o
33

44
# For strlcpy
5-
jvmti-y += libstring.o
5+
jvmti-y += libstring.o libctype.o
66

77
CFLAGS_jvmti = -fPIC -DPIC -I$(JDIR)/include -I$(JDIR)/include/linux
88
CFLAGS_REMOVE_jvmti = -Wmissing-declarations
@@ -15,3 +15,7 @@ CFLAGS_libstring.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PE
1515
$(OUTPUT)jvmti/libstring.o: ../lib/string.c FORCE
1616
$(call rule_mkdir)
1717
$(call if_changed_dep,cc_o_c)
18+
19+
$(OUTPUT)jvmti/libctype.o: ../lib/ctype.c FORCE
20+
$(call rule_mkdir)
21+
$(call if_changed_dep,cc_o_c)

tools/perf/util/annotate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,7 @@ static int symbol__disassemble_bpf(struct symbol *sym,
17581758
info_node = perf_env__find_bpf_prog_info(dso->bpf_prog.env,
17591759
dso->bpf_prog.id);
17601760
if (!info_node) {
1761-
return SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
1761+
ret = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
17621762
goto out;
17631763
}
17641764
info_linear = info_node->info_linear;

tools/perf/util/copyfile.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,16 @@ static int copyfile_mode_ns(const char *from, const char *to, mode_t mode,
101101
if (tofd < 0)
102102
goto out;
103103

104-
if (fchmod(tofd, mode))
105-
goto out_close_to;
106-
107104
if (st.st_size == 0) { /* /proc? do it slowly... */
108105
err = slow_copyfile(from, tmp, nsi);
106+
if (!err && fchmod(tofd, mode))
107+
err = -1;
109108
goto out_close_to;
110109
}
111110

111+
if (fchmod(tofd, mode))
112+
goto out_close_to;
113+
112114
nsinfo__mountns_enter(nsi, &nsc);
113115
fromfd = open(from, O_RDONLY);
114116
nsinfo__mountns_exit(&nsc);

tools/perf/util/evlist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ struct evsel *perf_evlist__reset_weak_group(struct evlist *evsel_list,
16591659
is_open = false;
16601660
if (c2->leader == leader) {
16611661
if (is_open)
1662-
perf_evsel__close(&evsel->core);
1662+
perf_evsel__close(&c2->core);
16631663
c2->leader = c2;
16641664
c2->core.nr_members = 0;
16651665
}

0 commit comments

Comments
 (0)