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 Rather than ghecking system global state ...
details: https://anonhg.NetBSD.org/src/rev/dcf7f3db26ce
branches: trunk
changeset: 352304:dcf7f3db26ce
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sat Mar 25 01:39:20 2017 +0000
description:
Rather than ghecking system global state to see if mprotect might be
enabled, use the newly-committed sysctl proc.curproc.paxflags variable
diffstat:
tests/lib/libc/sys/t_mprotect.c | 19 ++++++-------------
1 files changed, 6 insertions(+), 13 deletions(-)
diffs (46 lines):
diff -r 266fc191183a -r dcf7f3db26ce tests/lib/libc/sys/t_mprotect.c
--- a/tests/lib/libc/sys/t_mprotect.c Fri Mar 24 21:44:13 2017 +0000
+++ b/tests/lib/libc/sys/t_mprotect.c Sat Mar 25 01:39:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mprotect.c,v 1.5 2017/03/24 08:18:27 martin Exp $ */
+/* $NetBSD: t_mprotect.c,v 1.6 2017/03/25 01:39:20 pgoyette Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mprotect.c,v 1.5 2017/03/24 08:18:27 martin Exp $");
+__RCSID("$NetBSD: t_mprotect.c,v 1.6 2017/03/25 01:39:20 pgoyette Exp $");
#include <sys/param.h>
#include <sys/mman.h>
@@ -62,23 +62,16 @@
paxinit(void)
{
size_t len = sizeof(int);
- int pax_global = -1;
- int pax_enabled = -1;
+ int pax_flags;
int rv;
- rv = sysctlbyname("security.pax.mprotect.global",
- &pax_global, &len, NULL, 0);
+ rv = sysctlbyname("proc.curproc.paxflags",
+ &pax_flags, &len, NULL, 0);
if (rv != 0)
return false;
- rv = sysctlbyname("security.pax.mprotect.enabled",
- &pax_enabled, &len, NULL, 0);
-
- if (rv != 0)
- return false;
-
- return pax_global == 1 && pax_enabled == 1;
+ return ((pax_flags & CTL_PROC_PAXFLAGS_MPROTECT) != 0);
}
ATF_TC_WITH_CLEANUP(mprotect_access);
Home |
Main Index |
Thread Index |
Old Index