Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libc/sys Add get_user_va0_disable() in t_ptrace_wa...



details:   https://anonhg.NetBSD.org/src/rev/beacd0794d96
branches:  trunk
changeset: 841591:beacd0794d96
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sat May 25 03:22:53 2019 +0000

description:
Add get_user_va0_disable() in t_ptrace_wait.h

Add a utility function to check vm.user_va0_disable.

diffstat:

 tests/lib/libc/sys/t_ptrace_wait.h |  22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diffs (36 lines):

diff -r 8d9cf8d344a9 -r beacd0794d96 tests/lib/libc/sys/t_ptrace_wait.h
--- a/tests/lib/libc/sys/t_ptrace_wait.h        Sat May 25 03:20:43 2019 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.h        Sat May 25 03:22:53 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.h,v 1.16 2019/04/25 19:15:23 kamil Exp $ */
+/*     $NetBSD: t_ptrace_wait.h,v 1.17 2019/05/25 03:22:53 kamil Exp $ */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -553,6 +553,26 @@
 #endif
 
 static bool __used
+get_user_va0_disable(void)
+{
+       static int user_va0_disable = -1;
+       size_t user_va0_disable_len = sizeof(user_va0_disable);
+
+       if (user_va0_disable == -1) {
+               if (sysctlbyname("vm.user_va0_disable",
+                       &user_va0_disable, &user_va0_disable_len, NULL, 0)
+                       == -1) {
+                       return true;
+               }
+       }
+
+       if (user_va0_disable > 0)
+               return true;
+       else
+               return false;
+}
+
+static bool __used
 can_we_write_to_text(pid_t pid)
 {
        int mib[3];



Home | Main Index | Thread Index | Old Index