~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/netlabel/netlabel_user.c

Version: ~ [ linux-6.3-rc3 ] ~ [ linux-6.2.7 ] ~ [ linux-6.1.20 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.103 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.175 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.237 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.278 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.310 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * NetLabel NETLINK Interface
  3  *
  4  * This file defines the NETLINK interface for the NetLabel system.  The
  5  * NetLabel system manages static and dynamic label mappings for network
  6  * protocols such as CIPSO and RIPSO.
  7  *
  8  * Author: Paul Moore <paul@paul-moore.com>
  9  *
 10  */
 11 
 12 /*
 13  * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
 14  *
 15  * This program is free software;  you can redistribute it and/or modify
 16  * it under the terms of the GNU General Public License as published by
 17  * the Free Software Foundation; either version 2 of the License, or
 18  * (at your option) any later version.
 19  *
 20  * This program is distributed in the hope that it will be useful,
 21  * but WITHOUT ANY WARRANTY;  without even the implied warranty of
 22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 23  * the GNU General Public License for more details.
 24  *
 25  * You should have received a copy of the GNU General Public License
 26  * along with this program;  if not, see <http://www.gnu.org/licenses/>.
 27  *
 28  */
 29 
 30 #include <linux/init.h>
 31 #include <linux/types.h>
 32 #include <linux/list.h>
 33 #include <linux/socket.h>
 34 #include <linux/audit.h>
 35 #include <linux/tty.h>
 36 #include <linux/security.h>
 37 #include <linux/gfp.h>
 38 #include <net/sock.h>
 39 #include <net/netlink.h>
 40 #include <net/genetlink.h>
 41 #include <net/netlabel.h>
 42 #include <asm/bug.h>
 43 
 44 #include "netlabel_mgmt.h"
 45 #include "netlabel_unlabeled.h"
 46 #include "netlabel_cipso_v4.h"
 47 #include "netlabel_calipso.h"
 48 #include "netlabel_user.h"
 49 
 50 /*
 51  * NetLabel NETLINK Setup Functions
 52  */
 53 
 54 /**
 55  * netlbl_netlink_init - Initialize the NETLINK communication channel
 56  *
 57  * Description:
 58  * Call out to the NetLabel components so they can register their families and
 59  * commands with the Generic NETLINK mechanism.  Returns zero on success and
 60  * non-zero on failure.
 61  *
 62  */
 63 int __init netlbl_netlink_init(void)
 64 {
 65         int ret_val;
 66 
 67         ret_val = netlbl_mgmt_genl_init();
 68         if (ret_val != 0)
 69                 return ret_val;
 70 
 71         ret_val = netlbl_cipsov4_genl_init();
 72         if (ret_val != 0)
 73                 return ret_val;
 74 
 75         ret_val = netlbl_calipso_genl_init();
 76         if (ret_val != 0)
 77                 return ret_val;
 78 
 79         return netlbl_unlabel_genl_init();
 80 }
 81 
 82 /*
 83  * NetLabel Audit Functions
 84  */
 85 
 86 /**
 87  * netlbl_audit_start_common - Start an audit message
 88  * @type: audit message type
 89  * @audit_info: NetLabel audit information
 90  *
 91  * Description:
 92  * Start an audit message using the type specified in @type and fill the audit
 93  * message with some fields common to all NetLabel audit messages.  Returns
 94  * a pointer to the audit buffer on success, NULL on failure.
 95  *
 96  */
 97 struct audit_buffer *netlbl_audit_start_common(int type,
 98                                                struct netlbl_audit *audit_info)
 99 {
100         struct audit_buffer *audit_buf;
101         char *secctx;
102         u32 secctx_len;
103 
104         if (audit_enabled == 0)
105                 return NULL;
106 
107         audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC, type);
108         if (audit_buf == NULL)
109                 return NULL;
110 
111         audit_log_format(audit_buf, "netlabel: auid=%u ses=%u",
112                          from_kuid(&init_user_ns, audit_info->loginuid),
113                          audit_info->sessionid);
114 
115         if (audit_info->secid != 0 &&
116             security_secid_to_secctx(audit_info->secid,
117                                      &secctx,
118                                      &secctx_len) == 0) {
119                 audit_log_format(audit_buf, " subj=%s", secctx);
120                 security_release_secctx(secctx, secctx_len);
121         }
122 
123         return audit_buf;
124 }
125 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp