1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2021-2022 Klara Systems
5 *
6 * This software was developed by Mitchell Horne <mhorne@FreeBSD.org>
7 * under sponsorship from Juniper Networks and Klara Systems.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 #include "opt_mac.h"
31
32 #include <sys/param.h>
33 #include <sys/kernel.h>
34 #include <sys/module.h>
35
36 #include <ddb/ddb.h>
37
38 #include <security/mac/mac_framework.h>
39 #include <security/mac/mac_internal.h>
40 #include <security/mac/mac_policy.h>
41
42 int
mac_kdb_grant_backend(struct kdb_dbbe * be)43 mac_kdb_grant_backend(struct kdb_dbbe *be)
44 {
45 int error = 0;
46
47 MAC_POLICY_GRANT_NOSLEEP(kdb_check_backend, be);
48 return (error);
49 }
50
51 int
mac_kdb_check_backend(struct kdb_dbbe * be)52 mac_kdb_check_backend(struct kdb_dbbe *be)
53 {
54 int error = 0;
55
56 MAC_POLICY_CHECK_NOSLEEP(kdb_check_backend, be);
57 return (error);
58 }
59
60 int
mac_ddb_command_register(struct db_command_table * table,struct db_command * cmd)61 mac_ddb_command_register(struct db_command_table *table, struct db_command *cmd)
62 {
63 int error = 0;
64
65 MAC_POLICY_CHECK_NOSLEEP(ddb_command_register, table, cmd);
66 return (error);
67 }
68
69 int
mac_ddb_command_exec(struct db_command * cmd,db_expr_t addr,bool have_addr,db_expr_t count,char * modif)70 mac_ddb_command_exec(struct db_command *cmd, db_expr_t addr,
71 bool have_addr, db_expr_t count, char *modif)
72 {
73 int error = 0;
74
75 MAC_POLICY_CHECK_NOSLEEP(ddb_command_exec, cmd, addr, have_addr,
76 count, modif);
77 return (error);
78 }
79