lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Sun, 11 Dec 2016 03:50:56 +0300 From: Alexander Popov <alex.popov@...ux.com> To: Catalin Marinas <catalin.marinas@....com>, Will Deacon <will.deacon@....com>, Ard Biesheuvel <ard.biesheuvel@...aro.org>, Mark Rutland <mark.rutland@....com>, Rob Herring <robh@...nel.org>, Kefeng Wang <wangkefeng.wang@...wei.com>, AKASHI Takahiro <takahiro.akashi@...aro.org>, Jon Masters <jcm@...hat.com>, David Daney <david.daney@...ium.com>, Ganapatrao Kulkarni <gkulkarni@...iumnetworks.com>, Andrew Morton <akpm@...ux-foundation.org>, Dmitry Vyukov <dvyukov@...gle.com>, Nicolai Stange <nicstange@...il.com>, James Morse <james.morse@....com>, Andrey Ryabinin <aryabinin@...tuozzo.com>, Andrey Konovalov <andreyknvl@...gle.com>, Alexander Popov <alex.popov@...ux.com>, linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org, syzkaller <syzkaller@...glegroups.com> Subject: [PATCH 2/2] kcov: make kcov work properly with KASLR enabled Subtract KASLR offset from the kernel addresses reported by kcov. Tested on x86_64 and AArch64 (Hikey LeMaker). Signed-off-by: Alexander Popov <alex.popov@...ux.com> --- kernel/kcov.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/kcov.c b/kernel/kcov.c index 3cbb0c8..f8f3f4c 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -14,6 +14,7 @@ #include <linux/debugfs.h> #include <linux/uaccess.h> #include <linux/kcov.h> +#include <asm/setup.h> /* * kcov descriptor (one per opened debugfs file). @@ -68,6 +69,11 @@ void notrace __sanitizer_cov_trace_pc(void) if (mode == KCOV_MODE_TRACE) { unsigned long *area; unsigned long pos; + unsigned long ip = _RET_IP_; + +#ifdef CONFIG_RANDOMIZE_BASE + ip -= kaslr_offset(); +#endif /* * There is some code that runs in interrupts but for which @@ -81,7 +87,7 @@ void notrace __sanitizer_cov_trace_pc(void) /* The first word is number of subsequent PCs. */ pos = READ_ONCE(area[0]) + 1; if (likely(pos < t->kcov_size)) { - area[pos] = _RET_IP_; + area[pos] = ip; WRITE_ONCE(area[0], pos); } } -- 2.7.4
Powered by blists - more mailing lists