Add a (weak aliased) machdep_init() as a place to do machdep initialization
that can't happen as early as the other init functions as called from cpu_startup() -- for example, register kauth(9) listeners. Put unprivileged policy in the x86 code; used by i386, amd64, and xen.
This commit is contained in:
parent
14dd40c754
commit
2cb56be586
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: x86_machdep.c,v 1.34 2009/10/05 23:59:31 rmind Exp $ */
|
||||
/* $NetBSD: x86_machdep.c,v 1.35 2009/10/06 21:07:05 elad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.34 2009/10/05 23:59:31 rmind Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.35 2009/10/06 21:07:05 elad Exp $");
|
||||
|
||||
#include "opt_modular.h"
|
||||
|
||||
|
@ -74,6 +74,8 @@ struct bootinfo bootinfo;
|
|||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
static kauth_listener_t x86_listener;
|
||||
|
||||
/*
|
||||
* Given the type of a bootinfo entry, looks for a matching item inside
|
||||
* the bootinfo structure. If found, returns a pointer to it (which must
|
||||
|
@ -816,3 +818,35 @@ x86_reset(void)
|
|||
DELAY(500000); /* wait 0.5 sec to see if that did it */
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
x86_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie,
|
||||
void *arg0, void *arg1, void *arg2, void *arg3)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = KAUTH_RESULT_DEFER;
|
||||
|
||||
switch (action) {
|
||||
case KAUTH_MACHDEP_IOPERM_GET:
|
||||
case KAUTH_MACHDEP_LDT_GET:
|
||||
case KAUTH_MACHDEP_LDT_SET:
|
||||
case KAUTH_MACHDEP_MTRR_GET:
|
||||
result = KAUTH_RESULT_ALLOW;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
machdep_init(void)
|
||||
{
|
||||
|
||||
x86_listener = kauth_listen_scope(KAUTH_SCOPE_MACHDEP,
|
||||
x86_listener_cb, NULL);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: init_main.c,v 1.405 2009/10/03 22:32:56 elad Exp $ */
|
||||
/* $NetBSD: init_main.c,v 1.406 2009/10/06 21:07:05 elad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
|
||||
|
@ -97,7 +97,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.405 2009/10/03 22:32:56 elad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.406 2009/10/06 21:07:05 elad Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_ipsec.h"
|
||||
|
@ -569,6 +569,8 @@ main(void)
|
|||
wapbl_init();
|
||||
#endif
|
||||
|
||||
machdep_init();
|
||||
|
||||
/*
|
||||
* Create process 1 (init(8)). We do this now, as Unix has
|
||||
* historically had init be process 1, and changing this would
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_stub.c,v 1.19 2009/07/19 02:50:44 rmind Exp $ */
|
||||
/* $NetBSD: kern_stub.c,v 1.20 2009/10/06 21:07:06 elad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -62,7 +62,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_stub.c,v 1.19 2009/07/19 02:50:44 rmind Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_stub.c,v 1.20 2009/10/06 21:07:06 elad Exp $");
|
||||
|
||||
#include "opt_ptrace.h"
|
||||
#include "opt_ktrace.h"
|
||||
|
@ -130,6 +130,8 @@ __weak_alias(ktruser,enosys);
|
|||
__weak_alias(ktr_point,nullop);
|
||||
#endif /* KTRACE */
|
||||
|
||||
__weak_alias(machdep_init,nullop);
|
||||
|
||||
#if !defined(KERN_SA)
|
||||
/*
|
||||
* Scheduler activations system calls. These need to remain, even when
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: secmodel_suser.c,v 1.28 2009/10/06 20:34:22 elad Exp $ */
|
||||
/* $NetBSD: secmodel_suser.c,v 1.29 2009/10/06 21:07:06 elad Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2006 Elad Efrat <elad@NetBSD.org>
|
||||
* All rights reserved.
|
||||
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.28 2009/10/06 20:34:22 elad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.29 2009/10/06 21:07:06 elad Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -800,9 +800,6 @@ secmodel_suser_machdep_cb(kauth_cred_t cred, kauth_action_t action,
|
|||
case KAUTH_MACHDEP_LDT_GET:
|
||||
case KAUTH_MACHDEP_LDT_SET:
|
||||
case KAUTH_MACHDEP_MTRR_GET:
|
||||
result = KAUTH_RESULT_ALLOW;
|
||||
break;
|
||||
|
||||
case KAUTH_MACHDEP_CACHEFLUSH:
|
||||
case KAUTH_MACHDEP_IOPERM_SET:
|
||||
case KAUTH_MACHDEP_IOPL:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: systm.h,v 1.235 2009/03/29 10:58:28 ad Exp $ */
|
||||
/* $NetBSD: systm.h,v 1.236 2009/10/06 21:07:05 elad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1988, 1991, 1993
|
||||
|
@ -397,6 +397,8 @@ void cpu_dumpconf(void);
|
|||
void kmstartup(void);
|
||||
#endif
|
||||
|
||||
void machdep_init(void);
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <lib/libkern/libkern.h>
|
||||
|
||||
|
|
Loading…
Reference in New Issue