Changes in 4.9.276 ALSA: usb-audio: fix rate on Ozone Z90 USB headset media: dvb-usb: fix wrong definition Input: usbtouchscreen - fix control-request directions net: can: ems_usb: fix use-after-free in ems_usb_disconnect() usb: gadget: eem: fix echo command packet response issue USB: cdc-acm: blacklist Heimann USB Appset device ntfs: fix validity check for file name attribute iov_iter_fault_in_readable() should do nothing in xarray case Input: joydev - prevent use of not validated data in JSIOCSBTNMAP ioctl ARM: dts: at91: sama5d4: fix pinctrl muxing btrfs: clear defrag status of a root if starting transaction fails ext4: fix kernel infoleak via ext4_extent_header ext4: correct the cache_nr in tracepoint ext4_es_shrink_exit ext4: remove check for zero nr_to_scan in ext4_es_scan() ext4: fix avefreec in find_group_orlov SUNRPC: Fix the batch tasks count wraparound. SUNRPC: Should wake up the privileged task firstly. s390/cio: dont call css_wait_for_slow_path() inside a lock iio: ltr501: mark register holding upper 8 bits of ALS_DATA{0,1} and PS_DATA as volatile, too iio: ltr501: ltr559: fix initialization of LTR501_ALS_CONTR iio: ltr501: ltr501_read_ps(): add missing endianness conversion serial: sh-sci: Stop dmaengine transfer in sci_stop_tx() serial_cs: Add Option International GSM-Ready 56K/ISDN modem serial_cs: remove wrong GLOBETROTTER.cis entry ath9k: Fix kernel NULL pointer dereference during ath_reset_internal() ssb: sdio: Don't overwrite const buffer if block_write fails seq_buf: Make trace_seq_putmem_hex() support data longer than 8 fuse: check connected before queueing on fpq->io spi: spi-loopback-test: Fix 'tx_buf' might be 'rx_buf' spi: spi-topcliff-pch: Fix potential double free in pch_spi_process_messages() spi: omap-100k: Fix the length judgment problem crypto: nx - add missing MODULE_DEVICE_TABLE media: cpia2: fix memory leak in cpia2_usb_probe media: cobalt: fix race condition in setting HPD media: pvrusb2: fix warning in pvr2_i2c_core_done crypto: qat - check return code of qat_hal_rd_rel_reg() crypto: qat - remove unused macro in FW loader media: v4l2-core: Avoid the dangling pointer in v4l2_fh_release media: bt8xx: Fix a missing check bug in bt878_probe media: st-hva: Fix potential NULL pointer dereferences mmc: via-sdmmc: add a check against NULL pointer dereference crypto: shash - avoid comparing pointers to exported functions under CFI media: dvb_net: avoid speculation from net slot media: siano: fix device register error path btrfs: abort transaction if we fail to update the delayed inode btrfs: disable build on platforms having page size 256K regulator: da9052: Ensure enough delay time for .set_voltage_time_sel ACPI: processor idle: Fix up C-state latency if not ordered block_dump: remove block_dump feature in mark_inode_dirty() fs: dlm: cancel work sync othercon random32: Fix implicit truncation warning in prandom_seed_state() fs: dlm: fix memory leak when fenced ACPI: bus: Call kobject_put() in acpi_init() error path platform/x86: toshiba_acpi: Fix missing error code in toshiba_acpi_setup_keyboard() ACPI: tables: Add custom DSDT file as makefile prerequisite ia64: mca_drv: fix incorrect array size calculation media: s5p_cec: decrement usage count if disabled crypto: ixp4xx - dma_unmap the correct address crypto: ux500 - Fix error return code in hash_hw_final() sata_highbank: fix deferred probing pata_rb532_cf: fix deferred probing media: I2C: change 'RST' to "RSET" to fix multiple build errors pata_octeon_cf: avoid WARN_ON() in ata_host_activate() pata_ep93xx: fix deferred probing media: tc358743: Fix error return code in tc358743_probe_of() media: siano: Fix out-of-bounds warnings in smscore_load_firmware_family2() mmc: usdhi6rol0: fix error return code in usdhi6_probe() media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx hwmon: (max31722) Remove non-standard ACPI device IDs hwmon: (max31790) Fix fan speed reporting for fan7..12 spi: spi-sun6i: Fix chipselect/clock bug crypto: nx - Fix RCU warning in nx842_OF_upd_status ACPI: sysfs: Fix a buffer overrun problem with description_show() ocfs2: fix snprintf() checking net: pch_gbe: Propagate error from devm_gpio_request_one() ehea: fix error return code in ehea_restart_qps() RDMA/rxe: Fix failure during driver load drm: qxl: ensure surf.data is ininitialized wireless: carl9170: fix LEDS build errors & warnings brcmsmac: mac80211_if: Fix a resource leak in an error handling path ath10k: Fix an error code in ath10k_add_interface() netlabel: Fix memory leak in netlbl_mgmt_add_common netfilter: nft_exthdr: check for IPv6 packet before further processing net: ethernet: aeroflex: fix UAF in greth_of_remove net: ethernet: ezchip: fix UAF in nps_enet_remove net: ethernet: ezchip: fix error handling vxlan: add missing rcu_read_lock() in neigh_reduce() i40e: Fix error handling in i40e_vsi_open Bluetooth: mgmt: Fix slab-out-of-bounds in tlv_data_is_valid writeback: fix obtain a reference to a freeing memcg css net: sched: fix warning in tcindex_alloc_perfect_hash tty: nozomi: Fix a resource leak in an error handling function iio: adis_buffer: do not return ints in irq handlers iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: accel: bma220: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: accel: stk8ba50: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: adc: ti-ads1015: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: adc: vf610: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: gyro: bmg160: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: humidity: am2315: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: prox: pulsed-light: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: light: isl29125: Fix buffer alignment in iio_push_to_buffers_with_timestamp() iio: light: tcs3414: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Input: hil_kbd - fix error return code in hil_dev_connect() char: pcmcia: error out if 'num_bytes_read' is greater than 4 in set_protocol() tty: nozomi: Fix the error handling path of 'nozomi_card_init()' scsi: FlashPoint: Rename si_flags field s390: appldata depends on PROC_SYSCTL staging: gdm724x: check for buffer overflow in gdm_lte_multi_sdu_pkt() staging: gdm724x: check for overflow in gdm_lte_netif_rx() of: Fix truncation of memory sizes on 32-bit platforms scsi: mpt3sas: Fix error return value in _scsih_expander_add() phy: ti: dm816x: Fix the error handling path in 'dm816x_usb_phy_probe() extcon: sm5502: Drop invalid register write in sm5502_reg_data extcon: max8997: Add missing modalias string configfs: fix memleak in configfs_release_bin_file leds: ktd2692: Fix an error handling path mm/huge_memory.c: don't discard hugepage if other processes are mapping it selftests/vm/pkeys: fix alloc_random_pkey() to make it really, really random mmc: vub3000: fix control-request direction scsi: core: Retry I/O for Notify (Enable Spinup) Required error net: pch_gbe: Use proper accessors to BE data in pch_ptp_match() hugetlb: clear huge pte during flush function on mips platform atm: iphase: fix possible use-after-free in ia_module_exit() mISDN: fix possible use-after-free in HFC_cleanup() atm: nicstar: Fix possible use-after-free in nicstar_cleanup() net: Treat __napi_schedule_irqoff() as __napi_schedule() on PREEMPT_RT reiserfs: add check for invalid 1st journal block drm/virtio: Fix double free on probe failure udf: Fix NULL pointer dereference in udf_symlink function e100: handle eeprom as little endian clk: tegra: Ensure that PLLU configuration is applied properly ipv6: use prandom_u32() for ID generation RDMA/cxgb4: Fix missing error code in create_qp() dm space maps: don't reset space map allocation cursor when committing net: micrel: check return value after calling platform_get_resource() fjes: check return value after calling platform_get_resource() selinux: use __GFP_NOWARN with GFP_NOWAIT in the AVC xfrm: Fix error reporting in xfrm_state_construct. wlcore/wl12xx: Fix wl12xx get_mac error if device is in ELP wl1251: Fix possible buffer overflow in wl1251_cmd_scan cw1200: add missing MODULE_DEVICE_TABLE MIPS: add PMD table accounting into MIPS'pmd_alloc_one atm: nicstar: use 'dma_free_coherent' instead of 'kfree' atm: nicstar: register the interrupt handler in the right place RDMA/rxe: Don't overwrite errno from ib_umem_get() sfc: avoid double pci_remove of VFs sfc: error code if SRIOV cannot be disabled wireless: wext-spy: Fix out-of-bounds warning RDMA/cma: Fix rdma_resolve_route() memory leak Bluetooth: Fix the HCI to MGMT status conversion table Bluetooth: Shutdown controller after workqueues are flushed or cancelled Bluetooth: btusb: fix bt fiwmare downloading failure issue for qca btsoc. sctp: add size validation when walking chunks fuse: reject internal errno can: gw: synchronize rcu operations before removing gw job entry can: bcm: delay release of struct bcm_op after synchronize_rcu() mac80211: fix memory corruption in EAPOL handling powerpc/barrier: Avoid collision with clang's __lwsync macro pinctrl/amd: Add device HID for new AMD GPIO controller mmc: sdhci: Fix warning message when accessing RPMB in HS400 mode mmc: core: clear flags before allowing to retune ata: ahci_sunxi: Disable DIPM ASoC: tegra: Set driver_name=tegra for all machine drivers qemu_fw_cfg: Make fw_cfg_rev_attr a proper kobj_attribute ipmi/watchdog: Stop watchdog timer when the current action is 'none' power: supply: ab8500: Fix an old bug seq_buf: Fix overflow in seq_buf_putmem_hex() ipack/carriers/tpci200: Fix a double free in tpci200_pci_probe dm btree remove: assign new_root only when removal succeeds media: dtv5100: fix control-request directions media: zr364xx: fix memory leak in zr364xx_start_readpipe media: gspca/sq905: fix control-request direction media: gspca/sunplus: fix zero-length control requests media: uvcvideo: Fix pixel format change for Elgato Cam Link 4K jfs: fix GPF in diFree smackfs: restrict bytes count in smk_set_cipso() KVM: x86: Use guest MAXPHYADDR from CPUID.0x8000_0008 iff TDP is enabled KVM: X86: Disable hardware breakpoints unconditionally before kvm_x86->run() scsi: core: Fix bad pointer dereference when ehandler kthread is invalid tracing: Do not reference char * as a string in histograms fscrypt: don't ignore minor_hash when hash is 0 tty: serial: fsl_lpuart: fix the potential risk of division or modulo by zero misc/libmasm/module: Fix two use after free in ibmasm_init_one Revert "ALSA: bebob/oxfw: fix Kconfig entry for Mackie d.2 Pro" scsi: lpfc: Fix "Unexpected timeout" error in direct attach topology tty: serial: 8250: serial_cs: Fix a memory leak in error handling path fs/jfs: Fix missing error code in lmLogInit() scsi: iscsi: Add iscsi_cls_conn refcount helpers mfd: da9052/stmpe: Add and modify MODULE_DEVICE_TABLE s390/sclp_vt220: fix console name to match device ALSA: sb: Fix potential double-free of CSP mixer elements powerpc/ps3: Add dma_mask to ps3_dma_region gpio: zynq: Check return value of pm_runtime_get_sync ALSA: ppc: fix error return code in snd_pmac_probe() selftests/powerpc: Fix "no_handler" EBB selftest ASoC: soc-core: Fix the error return code in snd_soc_of_parse_audio_routing() ALSA: bebob: add support for ToneWeal FW66 usb: gadget: f_hid: fix endianness issue with descriptors usb: gadget: hid: fix error return code in hid_bind() powerpc/boot: Fixup device-tree on little endian backlight: lm3630a: Fix return code of .update_status() callback ALSA: hda: Add IRQ check for platform_get_irq() i2c: core: Disable client irq on reboot/shutdown lib/decompress_unlz4.c: correctly handle zero-padding around initrds. pwm: spear: Don't modify HW state in .remove callback power: supply: ab8500: Avoid NULL pointers power: reset: gpio-poweroff: add missing MODULE_DEVICE_TABLE ARM: 9087/1: kprobes: test-thumb: fix for LLVM_IAS=1 watchdog: Fix possible use-after-free in wdt_startup() watchdog: sc520_wdt: Fix possible use-after-free in wdt_turnoff() watchdog: Fix possible use-after-free by calling del_timer_sync() x86/fpu: Return proper error codes from user access functions orangefs: fix orangefs df output. ceph: remove bogus checks and WARN_ONs from ceph_set_page_dirty power: supply: charger-manager: add missing MODULE_DEVICE_TABLE power: supply: ab8500: add missing MODULE_DEVICE_TABLE pwm: tegra: Don't modify HW state in .remove callback ACPI: AMBA: Fix resource name in /proc/iomem virtio-blk: Fix memory leak among suspend/resume procedure virtio_console: Assure used length from device is limited PCI/sysfs: Fix dsm_label_utf16s_to_utf8s() buffer overrun power: supply: rt5033_battery: Fix device tree enumeration um: fix error return code in slip_open() um: fix error return code in winch_tramp() watchdog: aspeed: fix hardware timeout calculation nfs: fix acl memory leak of posix_acl_create() ubifs: Set/Clear I_LINKABLE under i_lock for whiteout inode x86/fpu: Limit xstate copy size in xstateregs_set() ALSA: isa: Fix error return code in snd_cmi8330_probe() hexagon: use common DISCARDS macro ARM: dts: exynos: fix PWM LED max brightness on Odroid XU/XU3 ARM: dts: exynos: fix PWM LED max brightness on Odroid XU4 rtc: fix snprintf() checking in is_rtc_hctosys() ARM: dts: r8a7779, marzen: Fix DU clock names reset: bail if try_module_get() fails memory: fsl_ifc: fix leak of IO mapping on probe failure memory: fsl_ifc: fix leak of private memory on probe failure ARM: dts: am335x: align ti,pindir-d0-out-d1-in property with dt-shema scsi: be2iscsi: Fix an error handling path in beiscsi_dev_probe() mips: always link byteswap helpers into decompressor mips: disable branch profiling in boot/decompress.o MIPS: vdso: Invalid GIC access through VDSO seq_file: disallow extremely large seq buffer allocations Linux 4.9.276 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I595c090068eb1b1934b15a0d54394abc38b4b0cc
855 lines
22 KiB
C
855 lines
22 KiB
C
/*
|
|
* NetLabel Management Support
|
|
*
|
|
* This file defines the management functions for the NetLabel system. The
|
|
* NetLabel system manages static and dynamic label mappings for network
|
|
* protocols such as CIPSO and RIPSO.
|
|
*
|
|
* Author: Paul Moore <paul@paul-moore.com>
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* (c) Copyright Hewlett-Packard Development Company, L.P., 2006, 2008
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
|
* the GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/socket.h>
|
|
#include <linux/string.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/in.h>
|
|
#include <linux/in6.h>
|
|
#include <linux/slab.h>
|
|
#include <net/sock.h>
|
|
#include <net/netlink.h>
|
|
#include <net/genetlink.h>
|
|
#include <net/ip.h>
|
|
#include <net/ipv6.h>
|
|
#include <net/netlabel.h>
|
|
#include <net/cipso_ipv4.h>
|
|
#include <net/calipso.h>
|
|
#include <linux/atomic.h>
|
|
|
|
#include "netlabel_calipso.h"
|
|
#include "netlabel_domainhash.h"
|
|
#include "netlabel_user.h"
|
|
#include "netlabel_mgmt.h"
|
|
|
|
/* NetLabel configured protocol counter */
|
|
atomic_t netlabel_mgmt_protocount = ATOMIC_INIT(0);
|
|
|
|
/* Argument struct for netlbl_domhsh_walk() */
|
|
struct netlbl_domhsh_walk_arg {
|
|
struct netlink_callback *nl_cb;
|
|
struct sk_buff *skb;
|
|
u32 seq;
|
|
};
|
|
|
|
/* NetLabel Generic NETLINK CIPSOv4 family */
|
|
static struct genl_family netlbl_mgmt_gnl_family = {
|
|
.id = GENL_ID_GENERATE,
|
|
.hdrsize = 0,
|
|
.name = NETLBL_NLTYPE_MGMT_NAME,
|
|
.version = NETLBL_PROTO_VERSION,
|
|
.maxattr = NLBL_MGMT_A_MAX,
|
|
};
|
|
|
|
/* NetLabel Netlink attribute policy */
|
|
static const struct nla_policy netlbl_mgmt_genl_policy[NLBL_MGMT_A_MAX + 1] = {
|
|
[NLBL_MGMT_A_DOMAIN] = { .type = NLA_NUL_STRING },
|
|
[NLBL_MGMT_A_PROTOCOL] = { .type = NLA_U32 },
|
|
[NLBL_MGMT_A_VERSION] = { .type = NLA_U32 },
|
|
[NLBL_MGMT_A_CV4DOI] = { .type = NLA_U32 },
|
|
[NLBL_MGMT_A_FAMILY] = { .type = NLA_U16 },
|
|
[NLBL_MGMT_A_CLPDOI] = { .type = NLA_U32 },
|
|
};
|
|
|
|
/*
|
|
* Helper Functions
|
|
*/
|
|
|
|
/**
|
|
* netlbl_mgmt_add - Handle an ADD message
|
|
* @info: the Generic NETLINK info block
|
|
* @audit_info: NetLabel audit information
|
|
*
|
|
* Description:
|
|
* Helper function for the ADD and ADDDEF messages to add the domain mappings
|
|
* from the message to the hash table. See netlabel.h for a description of the
|
|
* message format. Returns zero on success, negative values on failure.
|
|
*
|
|
*/
|
|
static int netlbl_mgmt_add_common(struct genl_info *info,
|
|
struct netlbl_audit *audit_info)
|
|
{
|
|
void *pmap = NULL;
|
|
int ret_val = -EINVAL;
|
|
struct netlbl_domaddr_map *addrmap = NULL;
|
|
struct cipso_v4_doi *cipsov4 = NULL;
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
struct calipso_doi *calipso = NULL;
|
|
#endif
|
|
u32 tmp_val;
|
|
struct netlbl_dom_map *entry = kzalloc(sizeof(*entry), GFP_KERNEL);
|
|
|
|
if (!entry)
|
|
return -ENOMEM;
|
|
entry->def.type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
|
|
if (info->attrs[NLBL_MGMT_A_DOMAIN]) {
|
|
size_t tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]);
|
|
entry->domain = kmalloc(tmp_size, GFP_KERNEL);
|
|
if (entry->domain == NULL) {
|
|
ret_val = -ENOMEM;
|
|
goto add_free_entry;
|
|
}
|
|
nla_strlcpy(entry->domain,
|
|
info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size);
|
|
}
|
|
|
|
/* NOTE: internally we allow/use a entry->def.type value of
|
|
* NETLBL_NLTYPE_ADDRSELECT but we don't currently allow users
|
|
* to pass that as a protocol value because we need to know the
|
|
* "real" protocol */
|
|
|
|
switch (entry->def.type) {
|
|
case NETLBL_NLTYPE_UNLABELED:
|
|
if (info->attrs[NLBL_MGMT_A_FAMILY])
|
|
entry->family =
|
|
nla_get_u16(info->attrs[NLBL_MGMT_A_FAMILY]);
|
|
else
|
|
entry->family = AF_UNSPEC;
|
|
break;
|
|
case NETLBL_NLTYPE_CIPSOV4:
|
|
if (!info->attrs[NLBL_MGMT_A_CV4DOI])
|
|
goto add_free_domain;
|
|
|
|
tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CV4DOI]);
|
|
cipsov4 = cipso_v4_doi_getdef(tmp_val);
|
|
if (cipsov4 == NULL)
|
|
goto add_free_domain;
|
|
entry->family = AF_INET;
|
|
entry->def.cipso = cipsov4;
|
|
break;
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
case NETLBL_NLTYPE_CALIPSO:
|
|
if (!info->attrs[NLBL_MGMT_A_CLPDOI])
|
|
goto add_free_domain;
|
|
|
|
tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CLPDOI]);
|
|
calipso = calipso_doi_getdef(tmp_val);
|
|
if (calipso == NULL)
|
|
goto add_free_domain;
|
|
entry->family = AF_INET6;
|
|
entry->def.calipso = calipso;
|
|
break;
|
|
#endif /* IPv6 */
|
|
default:
|
|
goto add_free_domain;
|
|
}
|
|
|
|
if ((entry->family == AF_INET && info->attrs[NLBL_MGMT_A_IPV6ADDR]) ||
|
|
(entry->family == AF_INET6 && info->attrs[NLBL_MGMT_A_IPV4ADDR]))
|
|
goto add_doi_put_def;
|
|
|
|
if (info->attrs[NLBL_MGMT_A_IPV4ADDR]) {
|
|
struct in_addr *addr;
|
|
struct in_addr *mask;
|
|
struct netlbl_domaddr4_map *map;
|
|
|
|
addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
|
|
if (addrmap == NULL) {
|
|
ret_val = -ENOMEM;
|
|
goto add_doi_put_def;
|
|
}
|
|
INIT_LIST_HEAD(&addrmap->list4);
|
|
INIT_LIST_HEAD(&addrmap->list6);
|
|
|
|
if (nla_len(info->attrs[NLBL_MGMT_A_IPV4ADDR]) !=
|
|
sizeof(struct in_addr)) {
|
|
ret_val = -EINVAL;
|
|
goto add_free_addrmap;
|
|
}
|
|
if (nla_len(info->attrs[NLBL_MGMT_A_IPV4MASK]) !=
|
|
sizeof(struct in_addr)) {
|
|
ret_val = -EINVAL;
|
|
goto add_free_addrmap;
|
|
}
|
|
addr = nla_data(info->attrs[NLBL_MGMT_A_IPV4ADDR]);
|
|
mask = nla_data(info->attrs[NLBL_MGMT_A_IPV4MASK]);
|
|
|
|
map = kzalloc(sizeof(*map), GFP_KERNEL);
|
|
if (map == NULL) {
|
|
ret_val = -ENOMEM;
|
|
goto add_free_addrmap;
|
|
}
|
|
pmap = map;
|
|
map->list.addr = addr->s_addr & mask->s_addr;
|
|
map->list.mask = mask->s_addr;
|
|
map->list.valid = 1;
|
|
map->def.type = entry->def.type;
|
|
if (cipsov4)
|
|
map->def.cipso = cipsov4;
|
|
|
|
ret_val = netlbl_af4list_add(&map->list, &addrmap->list4);
|
|
if (ret_val != 0)
|
|
goto add_free_map;
|
|
|
|
entry->family = AF_INET;
|
|
entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
|
|
entry->def.addrsel = addrmap;
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
} else if (info->attrs[NLBL_MGMT_A_IPV6ADDR]) {
|
|
struct in6_addr *addr;
|
|
struct in6_addr *mask;
|
|
struct netlbl_domaddr6_map *map;
|
|
|
|
addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
|
|
if (addrmap == NULL) {
|
|
ret_val = -ENOMEM;
|
|
goto add_doi_put_def;
|
|
}
|
|
INIT_LIST_HEAD(&addrmap->list4);
|
|
INIT_LIST_HEAD(&addrmap->list6);
|
|
|
|
if (nla_len(info->attrs[NLBL_MGMT_A_IPV6ADDR]) !=
|
|
sizeof(struct in6_addr)) {
|
|
ret_val = -EINVAL;
|
|
goto add_free_addrmap;
|
|
}
|
|
if (nla_len(info->attrs[NLBL_MGMT_A_IPV6MASK]) !=
|
|
sizeof(struct in6_addr)) {
|
|
ret_val = -EINVAL;
|
|
goto add_free_addrmap;
|
|
}
|
|
addr = nla_data(info->attrs[NLBL_MGMT_A_IPV6ADDR]);
|
|
mask = nla_data(info->attrs[NLBL_MGMT_A_IPV6MASK]);
|
|
|
|
map = kzalloc(sizeof(*map), GFP_KERNEL);
|
|
if (map == NULL) {
|
|
ret_val = -ENOMEM;
|
|
goto add_free_addrmap;
|
|
}
|
|
pmap = map;
|
|
map->list.addr = *addr;
|
|
map->list.addr.s6_addr32[0] &= mask->s6_addr32[0];
|
|
map->list.addr.s6_addr32[1] &= mask->s6_addr32[1];
|
|
map->list.addr.s6_addr32[2] &= mask->s6_addr32[2];
|
|
map->list.addr.s6_addr32[3] &= mask->s6_addr32[3];
|
|
map->list.mask = *mask;
|
|
map->list.valid = 1;
|
|
map->def.type = entry->def.type;
|
|
if (calipso)
|
|
map->def.calipso = calipso;
|
|
|
|
ret_val = netlbl_af6list_add(&map->list, &addrmap->list6);
|
|
if (ret_val != 0)
|
|
goto add_free_map;
|
|
|
|
entry->family = AF_INET6;
|
|
entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
|
|
entry->def.addrsel = addrmap;
|
|
#endif /* IPv6 */
|
|
}
|
|
|
|
ret_val = netlbl_domhsh_add(entry, audit_info);
|
|
if (ret_val != 0)
|
|
goto add_free_map;
|
|
|
|
return 0;
|
|
|
|
add_free_map:
|
|
kfree(pmap);
|
|
add_free_addrmap:
|
|
kfree(addrmap);
|
|
add_doi_put_def:
|
|
cipso_v4_doi_putdef(cipsov4);
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
calipso_doi_putdef(calipso);
|
|
#endif
|
|
add_free_domain:
|
|
kfree(entry->domain);
|
|
add_free_entry:
|
|
kfree(entry);
|
|
return ret_val;
|
|
}
|
|
|
|
/**
|
|
* netlbl_mgmt_listentry - List a NetLabel/LSM domain map entry
|
|
* @skb: the NETLINK buffer
|
|
* @entry: the map entry
|
|
*
|
|
* Description:
|
|
* This function is a helper function used by the LISTALL and LISTDEF command
|
|
* handlers. The caller is responsible for ensuring that the RCU read lock
|
|
* is held. Returns zero on success, negative values on failure.
|
|
*
|
|
*/
|
|
static int netlbl_mgmt_listentry(struct sk_buff *skb,
|
|
struct netlbl_dom_map *entry)
|
|
{
|
|
int ret_val = 0;
|
|
struct nlattr *nla_a;
|
|
struct nlattr *nla_b;
|
|
struct netlbl_af4list *iter4;
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
struct netlbl_af6list *iter6;
|
|
#endif
|
|
|
|
if (entry->domain != NULL) {
|
|
ret_val = nla_put_string(skb,
|
|
NLBL_MGMT_A_DOMAIN, entry->domain);
|
|
if (ret_val != 0)
|
|
return ret_val;
|
|
}
|
|
|
|
ret_val = nla_put_u16(skb, NLBL_MGMT_A_FAMILY, entry->family);
|
|
if (ret_val != 0)
|
|
return ret_val;
|
|
|
|
switch (entry->def.type) {
|
|
case NETLBL_NLTYPE_ADDRSELECT:
|
|
nla_a = nla_nest_start(skb, NLBL_MGMT_A_SELECTORLIST);
|
|
if (nla_a == NULL)
|
|
return -ENOMEM;
|
|
|
|
netlbl_af4list_foreach_rcu(iter4, &entry->def.addrsel->list4) {
|
|
struct netlbl_domaddr4_map *map4;
|
|
struct in_addr addr_struct;
|
|
|
|
nla_b = nla_nest_start(skb, NLBL_MGMT_A_ADDRSELECTOR);
|
|
if (nla_b == NULL)
|
|
return -ENOMEM;
|
|
|
|
addr_struct.s_addr = iter4->addr;
|
|
ret_val = nla_put_in_addr(skb, NLBL_MGMT_A_IPV4ADDR,
|
|
addr_struct.s_addr);
|
|
if (ret_val != 0)
|
|
return ret_val;
|
|
addr_struct.s_addr = iter4->mask;
|
|
ret_val = nla_put_in_addr(skb, NLBL_MGMT_A_IPV4MASK,
|
|
addr_struct.s_addr);
|
|
if (ret_val != 0)
|
|
return ret_val;
|
|
map4 = netlbl_domhsh_addr4_entry(iter4);
|
|
ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL,
|
|
map4->def.type);
|
|
if (ret_val != 0)
|
|
return ret_val;
|
|
switch (map4->def.type) {
|
|
case NETLBL_NLTYPE_CIPSOV4:
|
|
ret_val = nla_put_u32(skb, NLBL_MGMT_A_CV4DOI,
|
|
map4->def.cipso->doi);
|
|
if (ret_val != 0)
|
|
return ret_val;
|
|
break;
|
|
}
|
|
|
|
nla_nest_end(skb, nla_b);
|
|
}
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
netlbl_af6list_foreach_rcu(iter6, &entry->def.addrsel->list6) {
|
|
struct netlbl_domaddr6_map *map6;
|
|
|
|
nla_b = nla_nest_start(skb, NLBL_MGMT_A_ADDRSELECTOR);
|
|
if (nla_b == NULL)
|
|
return -ENOMEM;
|
|
|
|
ret_val = nla_put_in6_addr(skb, NLBL_MGMT_A_IPV6ADDR,
|
|
&iter6->addr);
|
|
if (ret_val != 0)
|
|
return ret_val;
|
|
ret_val = nla_put_in6_addr(skb, NLBL_MGMT_A_IPV6MASK,
|
|
&iter6->mask);
|
|
if (ret_val != 0)
|
|
return ret_val;
|
|
map6 = netlbl_domhsh_addr6_entry(iter6);
|
|
ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL,
|
|
map6->def.type);
|
|
if (ret_val != 0)
|
|
return ret_val;
|
|
|
|
switch (map6->def.type) {
|
|
case NETLBL_NLTYPE_CALIPSO:
|
|
ret_val = nla_put_u32(skb, NLBL_MGMT_A_CLPDOI,
|
|
map6->def.calipso->doi);
|
|
if (ret_val != 0)
|
|
return ret_val;
|
|
break;
|
|
}
|
|
|
|
nla_nest_end(skb, nla_b);
|
|
}
|
|
#endif /* IPv6 */
|
|
|
|
nla_nest_end(skb, nla_a);
|
|
break;
|
|
case NETLBL_NLTYPE_UNLABELED:
|
|
ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL,
|
|
entry->def.type);
|
|
break;
|
|
case NETLBL_NLTYPE_CIPSOV4:
|
|
ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL,
|
|
entry->def.type);
|
|
if (ret_val != 0)
|
|
return ret_val;
|
|
ret_val = nla_put_u32(skb, NLBL_MGMT_A_CV4DOI,
|
|
entry->def.cipso->doi);
|
|
break;
|
|
case NETLBL_NLTYPE_CALIPSO:
|
|
ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL,
|
|
entry->def.type);
|
|
if (ret_val != 0)
|
|
return ret_val;
|
|
ret_val = nla_put_u32(skb, NLBL_MGMT_A_CLPDOI,
|
|
entry->def.calipso->doi);
|
|
break;
|
|
}
|
|
|
|
return ret_val;
|
|
}
|
|
|
|
/*
|
|
* NetLabel Command Handlers
|
|
*/
|
|
|
|
/**
|
|
* netlbl_mgmt_add - Handle an ADD message
|
|
* @skb: the NETLINK buffer
|
|
* @info: the Generic NETLINK info block
|
|
*
|
|
* Description:
|
|
* Process a user generated ADD message and add the domains from the message
|
|
* to the hash table. See netlabel.h for a description of the message format.
|
|
* Returns zero on success, negative values on failure.
|
|
*
|
|
*/
|
|
static int netlbl_mgmt_add(struct sk_buff *skb, struct genl_info *info)
|
|
{
|
|
struct netlbl_audit audit_info;
|
|
|
|
if ((!info->attrs[NLBL_MGMT_A_DOMAIN]) ||
|
|
(!info->attrs[NLBL_MGMT_A_PROTOCOL]) ||
|
|
(info->attrs[NLBL_MGMT_A_IPV4ADDR] &&
|
|
info->attrs[NLBL_MGMT_A_IPV6ADDR]) ||
|
|
(info->attrs[NLBL_MGMT_A_IPV4MASK] &&
|
|
info->attrs[NLBL_MGMT_A_IPV6MASK]) ||
|
|
((info->attrs[NLBL_MGMT_A_IPV4ADDR] != NULL) ^
|
|
(info->attrs[NLBL_MGMT_A_IPV4MASK] != NULL)) ||
|
|
((info->attrs[NLBL_MGMT_A_IPV6ADDR] != NULL) ^
|
|
(info->attrs[NLBL_MGMT_A_IPV6MASK] != NULL)))
|
|
return -EINVAL;
|
|
|
|
netlbl_netlink_auditinfo(skb, &audit_info);
|
|
|
|
return netlbl_mgmt_add_common(info, &audit_info);
|
|
}
|
|
|
|
/**
|
|
* netlbl_mgmt_remove - Handle a REMOVE message
|
|
* @skb: the NETLINK buffer
|
|
* @info: the Generic NETLINK info block
|
|
*
|
|
* Description:
|
|
* Process a user generated REMOVE message and remove the specified domain
|
|
* mappings. Returns zero on success, negative values on failure.
|
|
*
|
|
*/
|
|
static int netlbl_mgmt_remove(struct sk_buff *skb, struct genl_info *info)
|
|
{
|
|
char *domain;
|
|
struct netlbl_audit audit_info;
|
|
|
|
if (!info->attrs[NLBL_MGMT_A_DOMAIN])
|
|
return -EINVAL;
|
|
|
|
netlbl_netlink_auditinfo(skb, &audit_info);
|
|
|
|
domain = nla_data(info->attrs[NLBL_MGMT_A_DOMAIN]);
|
|
return netlbl_domhsh_remove(domain, AF_UNSPEC, &audit_info);
|
|
}
|
|
|
|
/**
|
|
* netlbl_mgmt_listall_cb - netlbl_domhsh_walk() callback for LISTALL
|
|
* @entry: the domain mapping hash table entry
|
|
* @arg: the netlbl_domhsh_walk_arg structure
|
|
*
|
|
* Description:
|
|
* This function is designed to be used as a callback to the
|
|
* netlbl_domhsh_walk() function for use in generating a response for a LISTALL
|
|
* message. Returns the size of the message on success, negative values on
|
|
* failure.
|
|
*
|
|
*/
|
|
static int netlbl_mgmt_listall_cb(struct netlbl_dom_map *entry, void *arg)
|
|
{
|
|
int ret_val = -ENOMEM;
|
|
struct netlbl_domhsh_walk_arg *cb_arg = arg;
|
|
void *data;
|
|
|
|
data = genlmsg_put(cb_arg->skb, NETLINK_CB(cb_arg->nl_cb->skb).portid,
|
|
cb_arg->seq, &netlbl_mgmt_gnl_family,
|
|
NLM_F_MULTI, NLBL_MGMT_C_LISTALL);
|
|
if (data == NULL)
|
|
goto listall_cb_failure;
|
|
|
|
ret_val = netlbl_mgmt_listentry(cb_arg->skb, entry);
|
|
if (ret_val != 0)
|
|
goto listall_cb_failure;
|
|
|
|
cb_arg->seq++;
|
|
genlmsg_end(cb_arg->skb, data);
|
|
return 0;
|
|
|
|
listall_cb_failure:
|
|
genlmsg_cancel(cb_arg->skb, data);
|
|
return ret_val;
|
|
}
|
|
|
|
/**
|
|
* netlbl_mgmt_listall - Handle a LISTALL message
|
|
* @skb: the NETLINK buffer
|
|
* @cb: the NETLINK callback
|
|
*
|
|
* Description:
|
|
* Process a user generated LISTALL message and dumps the domain hash table in
|
|
* a form suitable for use in a kernel generated LISTALL message. Returns zero
|
|
* on success, negative values on failure.
|
|
*
|
|
*/
|
|
static int netlbl_mgmt_listall(struct sk_buff *skb,
|
|
struct netlink_callback *cb)
|
|
{
|
|
struct netlbl_domhsh_walk_arg cb_arg;
|
|
u32 skip_bkt = cb->args[0];
|
|
u32 skip_chain = cb->args[1];
|
|
|
|
cb_arg.nl_cb = cb;
|
|
cb_arg.skb = skb;
|
|
cb_arg.seq = cb->nlh->nlmsg_seq;
|
|
|
|
netlbl_domhsh_walk(&skip_bkt,
|
|
&skip_chain,
|
|
netlbl_mgmt_listall_cb,
|
|
&cb_arg);
|
|
|
|
cb->args[0] = skip_bkt;
|
|
cb->args[1] = skip_chain;
|
|
return skb->len;
|
|
}
|
|
|
|
/**
|
|
* netlbl_mgmt_adddef - Handle an ADDDEF message
|
|
* @skb: the NETLINK buffer
|
|
* @info: the Generic NETLINK info block
|
|
*
|
|
* Description:
|
|
* Process a user generated ADDDEF message and respond accordingly. Returns
|
|
* zero on success, negative values on failure.
|
|
*
|
|
*/
|
|
static int netlbl_mgmt_adddef(struct sk_buff *skb, struct genl_info *info)
|
|
{
|
|
struct netlbl_audit audit_info;
|
|
|
|
if ((!info->attrs[NLBL_MGMT_A_PROTOCOL]) ||
|
|
(info->attrs[NLBL_MGMT_A_IPV4ADDR] &&
|
|
info->attrs[NLBL_MGMT_A_IPV6ADDR]) ||
|
|
(info->attrs[NLBL_MGMT_A_IPV4MASK] &&
|
|
info->attrs[NLBL_MGMT_A_IPV6MASK]) ||
|
|
((info->attrs[NLBL_MGMT_A_IPV4ADDR] != NULL) ^
|
|
(info->attrs[NLBL_MGMT_A_IPV4MASK] != NULL)) ||
|
|
((info->attrs[NLBL_MGMT_A_IPV6ADDR] != NULL) ^
|
|
(info->attrs[NLBL_MGMT_A_IPV6MASK] != NULL)))
|
|
return -EINVAL;
|
|
|
|
netlbl_netlink_auditinfo(skb, &audit_info);
|
|
|
|
return netlbl_mgmt_add_common(info, &audit_info);
|
|
}
|
|
|
|
/**
|
|
* netlbl_mgmt_removedef - Handle a REMOVEDEF message
|
|
* @skb: the NETLINK buffer
|
|
* @info: the Generic NETLINK info block
|
|
*
|
|
* Description:
|
|
* Process a user generated REMOVEDEF message and remove the default domain
|
|
* mapping. Returns zero on success, negative values on failure.
|
|
*
|
|
*/
|
|
static int netlbl_mgmt_removedef(struct sk_buff *skb, struct genl_info *info)
|
|
{
|
|
struct netlbl_audit audit_info;
|
|
|
|
netlbl_netlink_auditinfo(skb, &audit_info);
|
|
|
|
return netlbl_domhsh_remove_default(AF_UNSPEC, &audit_info);
|
|
}
|
|
|
|
/**
|
|
* netlbl_mgmt_listdef - Handle a LISTDEF message
|
|
* @skb: the NETLINK buffer
|
|
* @info: the Generic NETLINK info block
|
|
*
|
|
* Description:
|
|
* Process a user generated LISTDEF message and dumps the default domain
|
|
* mapping in a form suitable for use in a kernel generated LISTDEF message.
|
|
* Returns zero on success, negative values on failure.
|
|
*
|
|
*/
|
|
static int netlbl_mgmt_listdef(struct sk_buff *skb, struct genl_info *info)
|
|
{
|
|
int ret_val = -ENOMEM;
|
|
struct sk_buff *ans_skb = NULL;
|
|
void *data;
|
|
struct netlbl_dom_map *entry;
|
|
u16 family;
|
|
|
|
if (info->attrs[NLBL_MGMT_A_FAMILY])
|
|
family = nla_get_u16(info->attrs[NLBL_MGMT_A_FAMILY]);
|
|
else
|
|
family = AF_INET;
|
|
|
|
ans_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
|
if (ans_skb == NULL)
|
|
return -ENOMEM;
|
|
data = genlmsg_put_reply(ans_skb, info, &netlbl_mgmt_gnl_family,
|
|
0, NLBL_MGMT_C_LISTDEF);
|
|
if (data == NULL)
|
|
goto listdef_failure;
|
|
|
|
rcu_read_lock();
|
|
entry = netlbl_domhsh_getentry(NULL, family);
|
|
if (entry == NULL) {
|
|
ret_val = -ENOENT;
|
|
goto listdef_failure_lock;
|
|
}
|
|
ret_val = netlbl_mgmt_listentry(ans_skb, entry);
|
|
rcu_read_unlock();
|
|
if (ret_val != 0)
|
|
goto listdef_failure;
|
|
|
|
genlmsg_end(ans_skb, data);
|
|
return genlmsg_reply(ans_skb, info);
|
|
|
|
listdef_failure_lock:
|
|
rcu_read_unlock();
|
|
listdef_failure:
|
|
kfree_skb(ans_skb);
|
|
return ret_val;
|
|
}
|
|
|
|
/**
|
|
* netlbl_mgmt_protocols_cb - Write an individual PROTOCOL message response
|
|
* @skb: the skb to write to
|
|
* @cb: the NETLINK callback
|
|
* @protocol: the NetLabel protocol to use in the message
|
|
*
|
|
* Description:
|
|
* This function is to be used in conjunction with netlbl_mgmt_protocols() to
|
|
* answer a application's PROTOCOLS message. Returns the size of the message
|
|
* on success, negative values on failure.
|
|
*
|
|
*/
|
|
static int netlbl_mgmt_protocols_cb(struct sk_buff *skb,
|
|
struct netlink_callback *cb,
|
|
u32 protocol)
|
|
{
|
|
int ret_val = -ENOMEM;
|
|
void *data;
|
|
|
|
data = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
|
|
&netlbl_mgmt_gnl_family, NLM_F_MULTI,
|
|
NLBL_MGMT_C_PROTOCOLS);
|
|
if (data == NULL)
|
|
goto protocols_cb_failure;
|
|
|
|
ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, protocol);
|
|
if (ret_val != 0)
|
|
goto protocols_cb_failure;
|
|
|
|
genlmsg_end(skb, data);
|
|
return 0;
|
|
|
|
protocols_cb_failure:
|
|
genlmsg_cancel(skb, data);
|
|
return ret_val;
|
|
}
|
|
|
|
/**
|
|
* netlbl_mgmt_protocols - Handle a PROTOCOLS message
|
|
* @skb: the NETLINK buffer
|
|
* @cb: the NETLINK callback
|
|
*
|
|
* Description:
|
|
* Process a user generated PROTOCOLS message and respond accordingly.
|
|
*
|
|
*/
|
|
static int netlbl_mgmt_protocols(struct sk_buff *skb,
|
|
struct netlink_callback *cb)
|
|
{
|
|
u32 protos_sent = cb->args[0];
|
|
|
|
if (protos_sent == 0) {
|
|
if (netlbl_mgmt_protocols_cb(skb,
|
|
cb,
|
|
NETLBL_NLTYPE_UNLABELED) < 0)
|
|
goto protocols_return;
|
|
protos_sent++;
|
|
}
|
|
if (protos_sent == 1) {
|
|
if (netlbl_mgmt_protocols_cb(skb,
|
|
cb,
|
|
NETLBL_NLTYPE_CIPSOV4) < 0)
|
|
goto protocols_return;
|
|
protos_sent++;
|
|
}
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
if (protos_sent == 2) {
|
|
if (netlbl_mgmt_protocols_cb(skb,
|
|
cb,
|
|
NETLBL_NLTYPE_CALIPSO) < 0)
|
|
goto protocols_return;
|
|
protos_sent++;
|
|
}
|
|
#endif
|
|
|
|
protocols_return:
|
|
cb->args[0] = protos_sent;
|
|
return skb->len;
|
|
}
|
|
|
|
/**
|
|
* netlbl_mgmt_version - Handle a VERSION message
|
|
* @skb: the NETLINK buffer
|
|
* @info: the Generic NETLINK info block
|
|
*
|
|
* Description:
|
|
* Process a user generated VERSION message and respond accordingly. Returns
|
|
* zero on success, negative values on failure.
|
|
*
|
|
*/
|
|
static int netlbl_mgmt_version(struct sk_buff *skb, struct genl_info *info)
|
|
{
|
|
int ret_val = -ENOMEM;
|
|
struct sk_buff *ans_skb = NULL;
|
|
void *data;
|
|
|
|
ans_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
|
if (ans_skb == NULL)
|
|
return -ENOMEM;
|
|
data = genlmsg_put_reply(ans_skb, info, &netlbl_mgmt_gnl_family,
|
|
0, NLBL_MGMT_C_VERSION);
|
|
if (data == NULL)
|
|
goto version_failure;
|
|
|
|
ret_val = nla_put_u32(ans_skb,
|
|
NLBL_MGMT_A_VERSION,
|
|
NETLBL_PROTO_VERSION);
|
|
if (ret_val != 0)
|
|
goto version_failure;
|
|
|
|
genlmsg_end(ans_skb, data);
|
|
return genlmsg_reply(ans_skb, info);
|
|
|
|
version_failure:
|
|
kfree_skb(ans_skb);
|
|
return ret_val;
|
|
}
|
|
|
|
|
|
/*
|
|
* NetLabel Generic NETLINK Command Definitions
|
|
*/
|
|
|
|
static const struct genl_ops netlbl_mgmt_genl_ops[] = {
|
|
{
|
|
.cmd = NLBL_MGMT_C_ADD,
|
|
.flags = GENL_ADMIN_PERM,
|
|
.policy = netlbl_mgmt_genl_policy,
|
|
.doit = netlbl_mgmt_add,
|
|
.dumpit = NULL,
|
|
},
|
|
{
|
|
.cmd = NLBL_MGMT_C_REMOVE,
|
|
.flags = GENL_ADMIN_PERM,
|
|
.policy = netlbl_mgmt_genl_policy,
|
|
.doit = netlbl_mgmt_remove,
|
|
.dumpit = NULL,
|
|
},
|
|
{
|
|
.cmd = NLBL_MGMT_C_LISTALL,
|
|
.flags = 0,
|
|
.policy = netlbl_mgmt_genl_policy,
|
|
.doit = NULL,
|
|
.dumpit = netlbl_mgmt_listall,
|
|
},
|
|
{
|
|
.cmd = NLBL_MGMT_C_ADDDEF,
|
|
.flags = GENL_ADMIN_PERM,
|
|
.policy = netlbl_mgmt_genl_policy,
|
|
.doit = netlbl_mgmt_adddef,
|
|
.dumpit = NULL,
|
|
},
|
|
{
|
|
.cmd = NLBL_MGMT_C_REMOVEDEF,
|
|
.flags = GENL_ADMIN_PERM,
|
|
.policy = netlbl_mgmt_genl_policy,
|
|
.doit = netlbl_mgmt_removedef,
|
|
.dumpit = NULL,
|
|
},
|
|
{
|
|
.cmd = NLBL_MGMT_C_LISTDEF,
|
|
.flags = 0,
|
|
.policy = netlbl_mgmt_genl_policy,
|
|
.doit = netlbl_mgmt_listdef,
|
|
.dumpit = NULL,
|
|
},
|
|
{
|
|
.cmd = NLBL_MGMT_C_PROTOCOLS,
|
|
.flags = 0,
|
|
.policy = netlbl_mgmt_genl_policy,
|
|
.doit = NULL,
|
|
.dumpit = netlbl_mgmt_protocols,
|
|
},
|
|
{
|
|
.cmd = NLBL_MGMT_C_VERSION,
|
|
.flags = 0,
|
|
.policy = netlbl_mgmt_genl_policy,
|
|
.doit = netlbl_mgmt_version,
|
|
.dumpit = NULL,
|
|
},
|
|
};
|
|
|
|
/*
|
|
* NetLabel Generic NETLINK Protocol Functions
|
|
*/
|
|
|
|
/**
|
|
* netlbl_mgmt_genl_init - Register the NetLabel management component
|
|
*
|
|
* Description:
|
|
* Register the NetLabel management component with the Generic NETLINK
|
|
* mechanism. Returns zero on success, negative values on failure.
|
|
*
|
|
*/
|
|
int __init netlbl_mgmt_genl_init(void)
|
|
{
|
|
return genl_register_family_with_ops(&netlbl_mgmt_gnl_family,
|
|
netlbl_mgmt_genl_ops);
|
|
}
|