Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64/amd64 Improve the detection on global variabl...



details:   https://anonhg.NetBSD.org/src/rev/a4b5656d91fe
branches:  trunk
changeset: 992299:a4b5656d91fe
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Aug 23 11:56:10 2018 +0000

description:
Improve the detection on global variables, no need to round up.

diffstat:

 sys/arch/amd64/amd64/asan.c |  25 +++++++++----------------
 1 files changed, 9 insertions(+), 16 deletions(-)

diffs (54 lines):

diff -r d64df5c507e1 -r a4b5656d91fe sys/arch/amd64/amd64/asan.c
--- a/sys/arch/amd64/amd64/asan.c       Thu Aug 23 11:53:15 2018 +0000
+++ b/sys/arch/amd64/amd64/asan.c       Thu Aug 23 11:56:10 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: asan.c,v 1.5 2018/08/22 17:25:02 maxv Exp $    */
+/*     $NetBSD: asan.c,v 1.6 2018/08/23 11:56:10 maxv Exp $    */
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.5 2018/08/22 17:25:02 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.6 2018/08/23 11:56:10 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -579,28 +579,21 @@
 void __asan_register_globals(struct __asan_global *, size_t);
 void __asan_unregister_globals(struct __asan_global *, size_t);
 
-static void
-kasan_register_global(struct __asan_global *global)
-{
-       size_t aligned_size = roundup(global->size, KASAN_SHADOW_SCALE_SIZE);
-
-       /* Poison the redzone following the var. */
-       kasan_shadow_fill((void *)((uintptr_t)global->beg + aligned_size),
-           global->size_with_redzone - aligned_size, KASAN_GLOBAL_REDZONE);
-}
-
 void
-__asan_register_globals(struct __asan_global *globals, size_t size)
+__asan_register_globals(struct __asan_global *globals, size_t n)
 {
        size_t i;
-       for (i = 0; i < size; i++) {
-               kasan_register_global(&globals[i]);
+
+       for (i = 0; i < n; i++) {
+               kasan_alloc(globals[i].beg, globals[i].size,
+                   globals[i].size_with_redzone);
        }
 }
 
 void
-__asan_unregister_globals(struct __asan_global *globals, size_t size)
+__asan_unregister_globals(struct __asan_global *globals, size_t n)
 {
+       /* never called */
 }
 
 #define ASAN_LOAD_STORE(size)                                  \



Home | Main Index | Thread Index | Old Index