source: rtems-libbsd/rtemsbsd/rtems/rtems-kernel-jail.c @ 36e8ad4

5
Last change on this file since 36e8ad4 was 36e8ad4, checked in by Sebastian Huber <sebastian.huber@…>, on May 10, 2019 at 1:59:04 PM

Use static inline functions for jail and prison

This helps the compiler to optimize away dead code.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup rtems_bsd_rtems
5 *
6 * @brief This object is an minimal rtems implementation of kern_jail.c.
7 */
8
9/*
10 * Copyright (c) 2009, 2010 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 *    notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 *    notice, this list of conditions and the following disclaimer in the
25 *    documentation and/or other materials provided with the distribution.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 */
39
40#include <machine/rtems-bsd-kernel-space.h>
41
42/*#include <sys/types.h>
43#include <sys/systm.h>
44#include <sys/malloc.h>
45#include <sys/jail.h>
46#include <sys/lock.h>
47#include <sys/mutex.h>*/
48
49#include <sys/param.h>
50#include <sys/types.h>
51#include <sys/kernel.h>
52#include <sys/systm.h>
53#include <sys/errno.h>
54#include <sys/sysproto.h>
55#include <sys/malloc.h>
56#include <sys/osd.h>
57#include <sys/priv.h>
58#include <sys/proc.h>
59#include <sys/taskqueue.h>
60#include <sys/fcntl.h>
61#include <sys/jail.h>
62#include <sys/lock.h>
63#include <sys/mutex.h>
64#include <sys/sx.h>
65#include <sys/sysent.h>
66#include <sys/namei.h>
67#include <sys/mount.h>
68#include <sys/queue.h>
69#include <sys/socket.h>
70#include <sys/syscallsubr.h>
71#include <sys/sysctl.h>
72
73#define DEFAULT_HOSTUUID  "00000000-0000-0000-0000-000000000000"
74
75/* Keep struct prison prison0 and some code in kern_jail_set() readable. */
76#ifdef INET
77#ifdef INET6
78#define _PR_IP_SADDRSEL PR_IP4_SADDRSEL|PR_IP6_SADDRSEL
79#else
80#define _PR_IP_SADDRSEL PR_IP4_SADDRSEL
81#endif
82#else /* !INET */
83#ifdef INET6
84#define _PR_IP_SADDRSEL PR_IP6_SADDRSEL
85#else
86#define _PR_IP_SADDRSEL 0
87#endif
88#endif
89
90/* prison0 describes what is "real" about the system. */
91struct prison prison0 = {
92  .pr_id    = 0,
93  .pr_name  = "0",
94  .pr_ref   = 1,
95  .pr_uref  = 1,
96  .pr_path  = "/",
97  .pr_securelevel = -1,
98  .pr_childmax  = JAIL_MAX,
99  .pr_hostuuid  = DEFAULT_HOSTUUID,
100  .pr_children  = LIST_HEAD_INITIALIZER(prison0.pr_children),
101#ifdef VIMAGE
102  .pr_flags = PR_HOST|PR_VNET|_PR_IP_SADDRSEL,
103#else
104  .pr_flags = PR_HOST|_PR_IP_SADDRSEL,
105#endif
106  .pr_allow = PR_ALLOW_ALL_STATIC
107};
108MTX_SYSINIT(prison0, &prison0.pr_mtx, "jail mutex", MTX_DEF);
Note: See TracBrowser for help on using the repository browser.