Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
From 02bcb5a7a3dc63346c14fc7aaae3102db548542d Mon Sep 17 00:00:00 2001
From: Al Viro <viro@zeniv.linux.org.uk>
Date: Sat, 10 Sep 2016 16:50:00 -0400
Subject: [PATCH] BACKPORT: arm64: don't zero in __copy_from_user{,_inatomic}

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
arch/arm64/include/asm/uaccess.h | 11 +++++++----
arch/arm64/lib/copy_from_user.S | 7 +------
2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index d0919bcb1953..b26ad8507e93 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -410,12 +410,15 @@ static inline unsigned long __must_check __copy_to_user(void __user *to, const v

static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
{
+ unsigned long res = n;
+
if (access_ok(VERIFY_READ, from, n)) {
check_object_size(to, n, false);
- n = __arch_copy_from_user(to, from, n);
- } else /* security hole - plug it */
- memset(to, 0, n);
- return n;
+ res = __arch_copy_from_user(to, from, n);
+ }
+ if (unlikely(res))
+ memset(to + (n - res), 0, res);
+ return res;
}

static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
diff --git a/arch/arm64/lib/copy_from_user.S b/arch/arm64/lib/copy_from_user.S
index 683adc358be7..c7a7d9689e8f 100644
--- a/arch/arm64/lib/copy_from_user.S
+++ b/arch/arm64/lib/copy_from_user.S
@@ -74,11 +74,6 @@ ENDPROC(__arch_copy_from_user)

.section .fixup,"ax"
.align 2
-9998:
- sub x0, end, dst
-9999:
- strb wzr, [dst], #1 // zero remaining buffer space
- cmp dst, end
- b.lo 9999b
+9998: sub x0, end, dst // bytes not copied
ret
.previous
--
2.27.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 7cdd201761fea40d7467b97fb9f2e2bcd5ec63c4 Mon Sep 17 00:00:00 2001
From: Gleb Mazovetskiy <glex.spb@gmail.com>
Date: Mon, 25 Jan 2021 00:41:55 +0000
Subject: [PATCH 01/12] perf: cs-etm: fix duplicate def of traceid_list

Backport of 168200b6d6ea0cb5765943ec5da5b8149701f36a upstream

Signed-off-by: Gleb Mazovetskiy <glex.spb@gmail.com>
---
tools/perf/util/cs-etm.c | 3 +++
tools/perf/util/cs-etm.h | 3 ---
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index ca93257a6cb7..ee23fd37f241 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -91,6 +91,9 @@ struct cs_etm_queue {
bool kernel_mapped;
};

+/* RB tree for quick conversion between traceID and metadata pointers */
+static struct intlist *traceid_list;
+
static int cs_etm__get_trace(struct cs_etm_buffer *buff, struct cs_etm_queue *etmq);
static int cs_etm__update_queues(struct cs_etm_auxtrace *);
static int cs_etm__process_queues(struct cs_etm_auxtrace *, u64);
diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h
index ec6ff78f1905..1f785a92fb20 100644
--- a/tools/perf/util/cs-etm.h
+++ b/tools/perf/util/cs-etm.h
@@ -65,9 +65,6 @@ enum {
CS_ETMV4_PRIV_MAX,
};

-/* RB tree for quick conversion between traceID and CPUs */
-struct intlist *traceid_list;
-
#define KiB(x) ((x) * 1024)
#define MiB(x) ((x) * 1024 * 1024)

--
2.27.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
From 62b75df5f013d9f7b5b47ff5369dd4b3143ab965 Mon Sep 17 00:00:00 2001
From: Gleb Mazovetskiy <glex.spb@gmail.com>
Date: Mon, 25 Jan 2021 00:52:10 +0000
Subject: [PATCH 02/12] perf bench: Share some global variables to fix build
with gcc 10

Based on https://git.yoctoproject.org/cgit/cgit.cgi/meta-arm/tree/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0003-perf-bench-Share-some-global-variables-to-fix-build-.patch

Signed-off-by: Gleb Mazovetskiy <glex.spb@gmail.com>
---
tools/perf/bench/bench.h | 4 ++++
tools/perf/bench/futex-hash.c | 12 ++++++------
tools/perf/bench/futex-lock-pi.c | 11 +++++------
3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h
index a50df86f2b9b..e758896f4995 100644
--- a/tools/perf/bench/bench.h
+++ b/tools/perf/bench/bench.h
@@ -1,6 +1,10 @@
#ifndef BENCH_H
#define BENCH_H

+#include <sys/time.h>
+
+extern struct timeval bench__start, bench__end, bench__runtime;
+
/*
* The madvise transparent hugepage constants were added in glibc
* 2.13. For compatibility with older versions of glibc, define these
diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c
index fc9bebd2cca0..80313b40d324 100644
--- a/tools/perf/bench/futex-hash.c
+++ b/tools/perf/bench/futex-hash.c
@@ -28,7 +28,7 @@ static unsigned int nfutexes = 1024;
static bool fshared = false, done = false, silent = false;
static int futex_flag = 0;

-struct timeval start, end, runtime;
+struct timeval bench__start, bench__end, bench__runtime;
static pthread_mutex_t thread_lock;
static unsigned int threads_starting;
static struct stats throughput_stats;
@@ -92,8 +92,8 @@ static void toggle_done(int sig __maybe_unused,
{
/* inform all threads that we're done for the day */
done = true;
- gettimeofday(&end, NULL);
- timersub(&end, &start, &runtime);
+ gettimeofday(&bench__end, NULL);
+ timersub(&bench__end, &bench__start, &bench__runtime);
}

static void print_summary(void)
@@ -103,7 +103,7 @@ static void print_summary(void)

printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n",
!silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg),
- (int) runtime.tv_sec);
+ (int) bench__runtime.tv_sec);
}

int bench_futex_hash(int argc, const char **argv,
@@ -148,7 +148,7 @@ int bench_futex_hash(int argc, const char **argv,

threads_starting = nthreads;
pthread_attr_init(&thread_attr);
- gettimeofday(&start, NULL);
+ gettimeofday(&bench__start, NULL);
for (i = 0; i < nthreads; i++) {
worker[i].tid = i;
worker[i].futex = calloc(nfutexes, sizeof(*worker[i].futex));
@@ -191,7 +191,7 @@ int bench_futex_hash(int argc, const char **argv,
pthread_mutex_destroy(&thread_lock);

for (i = 0; i < nthreads; i++) {
- unsigned long t = worker[i].ops/runtime.tv_sec;
+ unsigned long t = worker[i].ops/bench__runtime.tv_sec;
update_stats(&throughput_stats, t);
if (!silent) {
if (nfutexes == 1)
diff --git a/tools/perf/bench/futex-lock-pi.c b/tools/perf/bench/futex-lock-pi.c
index bc6a16adbca8..8d0f60456a95 100644
--- a/tools/perf/bench/futex-lock-pi.c
+++ b/tools/perf/bench/futex-lock-pi.c
@@ -29,7 +29,6 @@ static bool silent = false, multi = false;
static bool done = false, fshared = false;
static unsigned int ncpus, nthreads = 0;
static int futex_flag = 0;
-struct timeval start, end, runtime;
static pthread_mutex_t thread_lock;
static unsigned int threads_starting;
static struct stats throughput_stats;
@@ -56,7 +55,7 @@ static void print_summary(void)

printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n",
!silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg),
- (int) runtime.tv_sec);
+ (int) bench__runtime.tv_sec);
}

static void toggle_done(int sig __maybe_unused,
@@ -65,8 +64,8 @@ static void toggle_done(int sig __maybe_unused,
{
/* inform all threads that we're done for the day */
done = true;
- gettimeofday(&end, NULL);
- timersub(&end, &start, &runtime);
+ gettimeofday(&bench__end, NULL);
+ timersub(&bench__end, &bench__start, &bench__runtime);
}

static void *workerfn(void *arg)
@@ -172,7 +171,7 @@ int bench_futex_lock_pi(int argc, const char **argv,

threads_starting = nthreads;
pthread_attr_init(&thread_attr);
- gettimeofday(&start, NULL);
+ gettimeofday(&bench__start, NULL);

create_threads(worker, thread_attr);
pthread_attr_destroy(&thread_attr);
@@ -198,7 +197,7 @@ int bench_futex_lock_pi(int argc, const char **argv,
pthread_mutex_destroy(&thread_lock);

for (i = 0; i < nthreads; i++) {
- unsigned long t = worker[i].ops/runtime.tv_sec;
+ unsigned long t = worker[i].ops/bench__runtime.tv_sec;

update_stats(&throughput_stats, t);
if (!silent)
--
2.27.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
From 89b28cc5ae940970fa4530722c1419dd728a6e15 Mon Sep 17 00:00:00 2001
From: Gleb Mazovetskiy <glex.spb@gmail.com>
Date: Mon, 25 Jan 2021 00:57:06 +0000
Subject: [PATCH 03/12] perf: Make perf able to build with latest libbfd

Based on http://lore.kernel.org/lkml/20200128152938.31413-1-changbin.du@gmail.com

Signed-off-by: Gleb Mazovetskiy <glex.spb@gmail.com>
---
tools/perf/util/srcline.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index b4db3f48e3b0..2853d4728ab9 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -86,16 +86,30 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data)
bfd_vma pc, vma;
bfd_size_type size;
struct a2l_data *a2l = data;
+ flagword flags;

if (a2l->found)
return;

- if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
+#ifdef bfd_get_section_flags
+ flags = bfd_get_section_flags(abfd, section);
+#else
+ flags = bfd_section_flags(section);
+#endif
+ if ((flags & SEC_ALLOC) == 0)
return;

pc = a2l->addr;
+#ifdef bfd_get_section_vma
vma = bfd_get_section_vma(abfd, section);
+#else
+ vma = bfd_section_vma(section);
+#endif
+#ifdef bfd_get_section_size
size = bfd_get_section_size(section);
+#else
+ size = bfd_section_size(section);
+#endif

if (pc < vma || pc >= vma + size)
return;
--
2.27.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
From 186f5ff69e29e0b1add523bb03462a690b2348c0 Mon Sep 17 00:00:00 2001
From: Andrey Zhizhikin <andrey.z@gmail.com>
Date: Wed, 11 Dec 2019 08:01:09 +0000
Subject: [PATCH 04/12] tools lib api fs: Fix gcc9 stringop-truncation
compilation error

GCC9 introduced string hardening mechanisms, which exhibits the error
during fs api compilation:

error: '__builtin_strncpy' specified bound 4096 equals destination size
[-Werror=stringop-truncation]

This comes when the length of copy passed to strncpy is is equal to
destination size, which could potentially lead to buffer overflow.

There is a need to mitigate this potential issue by limiting the size of
destination by 1 and explicitly terminate the destination with NULL.

Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Song Liu <songliubraving@fb.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org
Link: http://lore.kernel.org/lkml/20191211080109.18765-1-andrey.zhizhikin@leica-geosystems.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/api/fs/fs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 459599d1b6c4..58f05748dd39 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -179,6 +179,7 @@ static bool fs__env_override(struct fs *fs)
size_t name_len = strlen(fs->name);
/* name + "_PATH" + '\0' */
char upper_name[name_len + 5 + 1];
+
memcpy(upper_name, fs->name, name_len);
mem_toupper(upper_name, name_len);
strcpy(&upper_name[name_len], "_PATH");
@@ -188,7 +189,8 @@ static bool fs__env_override(struct fs *fs)
return false;

fs->found = true;
- strncpy(fs->path, override_path, sizeof(fs->path));
+ strncpy(fs->path, override_path, sizeof(fs->path) - 1);
+ fs->path[sizeof(fs->path) - 1] = '\0';
return true;
}

--
2.27.0

Loading