/*1* NetLabel NETLINK Interface2*3* This file defines the NETLINK interface for the NetLabel system. The4* NetLabel system manages static and dynamic label mappings for network5* protocols such as CIPSO and RIPSO.6*7* Author: Paul Moore <[email protected]>8*9*/1011/*12* (c) Copyright Hewlett-Packard Development Company, L.P., 200613*14* This program is free software; you can redistribute it and/or modify15* it under the terms of the GNU General Public License as published by16* the Free Software Foundation; either version 2 of the License, or17* (at your option) any later version.18*19* This program is distributed in the hope that it will be useful,20* but WITHOUT ANY WARRANTY; without even the implied warranty of21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See22* the GNU General Public License for more details.23*24* You should have received a copy of the GNU General Public License25* along with this program; if not, write to the Free Software26* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA27*28*/2930#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>4344#include "netlabel_mgmt.h"45#include "netlabel_unlabeled.h"46#include "netlabel_cipso_v4.h"47#include "netlabel_user.h"4849/*50* NetLabel NETLINK Setup Functions51*/5253/**54* netlbl_netlink_init - Initialize the NETLINK communication channel55*56* Description:57* Call out to the NetLabel components so they can register their families and58* commands with the Generic NETLINK mechanism. Returns zero on success and59* non-zero on failure.60*61*/62int __init netlbl_netlink_init(void)63{64int ret_val;6566ret_val = netlbl_mgmt_genl_init();67if (ret_val != 0)68return ret_val;6970ret_val = netlbl_cipsov4_genl_init();71if (ret_val != 0)72return ret_val;7374ret_val = netlbl_unlabel_genl_init();75if (ret_val != 0)76return ret_val;7778return 0;79}8081/*82* NetLabel Audit Functions83*/8485/**86* netlbl_audit_start_common - Start an audit message87* @type: audit message type88* @audit_info: NetLabel audit information89*90* Description:91* Start an audit message using the type specified in @type and fill the audit92* message with some fields common to all NetLabel audit messages. Returns93* a pointer to the audit buffer on success, NULL on failure.94*95*/96struct audit_buffer *netlbl_audit_start_common(int type,97struct netlbl_audit *audit_info)98{99struct audit_buffer *audit_buf;100char *secctx;101u32 secctx_len;102103if (audit_enabled == 0)104return NULL;105106audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC, type);107if (audit_buf == NULL)108return NULL;109110audit_log_format(audit_buf, "netlabel: auid=%u ses=%u",111audit_info->loginuid,112audit_info->sessionid);113114if (audit_info->secid != 0 &&115security_secid_to_secctx(audit_info->secid,116&secctx,117&secctx_len) == 0) {118audit_log_format(audit_buf, " subj=%s", secctx);119security_release_secctx(secctx, secctx_len);120}121122return audit_buf;123}124125126