From b720da78f4ed4158e7ce561391c88207e62b86b0 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 6 Nov 2018 07:49:39 +0000 Subject: new sysctl for userland malloc flags, kernel part. ok millert@ deraadt@ --- sys/kern/kern_pledge.c | 5 ++++- sys/uvm/uvm_meter.c | 7 ++++++- sys/uvm/uvmexp.h | 6 ++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c index 00ed0b3be67..60b4b1ef7ac 100644 --- a/sys/kern/kern_pledge.c +++ b/sys/kern/kern_pledge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_pledge.c,v 1.243 2018/09/13 07:49:33 mestre Exp $ */ +/* $OpenBSD: kern_pledge.c,v 1.244 2018/11/06 07:49:38 otto Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -971,6 +971,9 @@ pledge_sysctl(struct proc *p, int miblen, int *mib, void *new) if (miblen == 2 && /* vm.loadavg / getloadavg(3) */ mib[0] == CTL_VM && mib[1] == VM_LOADAVG) return (0); + if (miblen == 2 && /* vm.malloc_conf */ + mib[0] == CTL_VM && mib[1] == VM_MALLOC_CONF) + return (0); #ifdef CPU_SSE if (miblen == 2 && /* i386 libm tests for SSE */ mib[0] == CTL_MACHDEP && mib[1] == CPU_SSE) diff --git a/sys/uvm/uvm_meter.c b/sys/uvm/uvm_meter.c index e66267b12b7..794811366ba 100644 --- a/sys/uvm/uvm_meter.c +++ b/sys/uvm/uvm_meter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_meter.c,v 1.37 2017/05/09 09:36:04 mpi Exp $ */ +/* $OpenBSD: uvm_meter.c,v 1.38 2018/11/06 07:49:38 otto Exp $ */ /* $NetBSD: uvm_meter.c,v 1.21 2001/07/14 06:36:03 matt Exp $ */ /* @@ -139,6 +139,8 @@ uvm_loadav(struct loadavg *avg) } } +char malloc_conf[16]; + /* * uvm_sysctl: sysctl hook into UVM system. */ @@ -231,6 +233,9 @@ uvm_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case VM_USPACE: return (sysctl_rdint(oldp, oldlenp, newp, USPACE)); + case VM_MALLOC_CONF: + return (sysctl_string(oldp, oldlenp, newp, newlen, + malloc_conf, sizeof(malloc_conf))); default: return (EOPNOTSUPP); } diff --git a/sys/uvm/uvmexp.h b/sys/uvm/uvmexp.h index fb54027432e..b2a98379a64 100644 --- a/sys/uvm/uvmexp.h +++ b/sys/uvm/uvmexp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvmexp.h,v 1.3 2018/06/19 22:35:07 krw Exp $ */ +/* $OpenBSD: uvmexp.h,v 1.4 2018/11/06 07:49:38 otto Exp $ */ #ifndef _UVM_UVMEXP_ #define _UVM_UVMEXP_ @@ -17,7 +17,8 @@ #define VM_VNODEMIN 9 #define VM_MAXSLP 10 #define VM_USPACE 11 -#define VM_MAXID 12 /* number of valid vm ids */ +#define VM_MALLOC_CONF 12 /* config for userland malloc */ +#define VM_MAXID 13 /* number of valid vm ids */ #define CTL_VM_NAMES { \ { 0, 0 }, \ @@ -32,6 +33,7 @@ { "vnodemin", CTLTYPE_INT }, \ { "maxslp", CTLTYPE_INT }, \ { "uspace", CTLTYPE_INT }, \ + { "malloc_conf", CTLTYPE_STRING }, \ } /* -- cgit v1.2.3