Thomas Gleixner | 1ccea77 | 2019-05-19 15:51:43 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 2 | /* |
| 3 | * NetLabel CIPSO/IPv4 Support |
| 4 | * |
| 5 | * This file defines the CIPSO/IPv4 functions for the NetLabel system. The |
| 6 | * NetLabel system manages static and dynamic label mappings for network |
| 7 | * protocols such as CIPSO and RIPSO. |
| 8 | * |
Paul Moore | 82c21bf | 2011-08-01 11:10:33 +0000 | [diff] [blame] | 9 | * Author: Paul Moore <paul@paul-moore.com> |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | /* |
| 13 | * (c) Copyright Hewlett-Packard Development Company, L.P., 2006 |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef _NETLABEL_CIPSO_V4 |
| 17 | #define _NETLABEL_CIPSO_V4 |
| 18 | |
| 19 | #include <net/netlabel.h> |
| 20 | |
| 21 | /* |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 22 | * The following NetLabel payloads are supported by the CIPSO subsystem. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 23 | * |
| 24 | * o ADD: |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 25 | * Sent by an application to add a new DOI mapping table. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 26 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 27 | * Required attributes: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 28 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 29 | * NLBL_CIPSOV4_A_DOI |
| 30 | * NLBL_CIPSOV4_A_MTYPE |
| 31 | * NLBL_CIPSOV4_A_TAGLST |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 32 | * |
Paul Moore | 15c45f7 | 2008-10-10 10:16:34 -0400 | [diff] [blame] | 33 | * If using CIPSO_V4_MAP_TRANS the following attributes are required: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 34 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 35 | * NLBL_CIPSOV4_A_MLSLVLLST |
| 36 | * NLBL_CIPSOV4_A_MLSCATLST |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 37 | * |
Paul Moore | d91d407 | 2008-10-10 10:16:34 -0400 | [diff] [blame] | 38 | * If using CIPSO_V4_MAP_PASS or CIPSO_V4_MAP_LOCAL no additional attributes |
| 39 | * are required. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 40 | * |
| 41 | * o REMOVE: |
| 42 | * Sent by an application to remove a specific DOI mapping table from the |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 43 | * CIPSO V4 system. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 44 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 45 | * Required attributes: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 46 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 47 | * NLBL_CIPSOV4_A_DOI |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 48 | * |
| 49 | * o LIST: |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 50 | * Sent by an application to list the details of a DOI definition. On |
| 51 | * success the kernel should send a response using the following format. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 52 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 53 | * Required attributes: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 54 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 55 | * NLBL_CIPSOV4_A_DOI |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 56 | * |
| 57 | * The valid response message format depends on the type of the DOI mapping, |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 58 | * the defined formats are shown below. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 59 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 60 | * Required attributes: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 61 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 62 | * NLBL_CIPSOV4_A_MTYPE |
| 63 | * NLBL_CIPSOV4_A_TAGLST |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 64 | * |
Paul Moore | 15c45f7 | 2008-10-10 10:16:34 -0400 | [diff] [blame] | 65 | * If using CIPSO_V4_MAP_TRANS the following attributes are required: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 66 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 67 | * NLBL_CIPSOV4_A_MLSLVLLST |
| 68 | * NLBL_CIPSOV4_A_MLSCATLST |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 69 | * |
Paul Moore | d91d407 | 2008-10-10 10:16:34 -0400 | [diff] [blame] | 70 | * If using CIPSO_V4_MAP_PASS or CIPSO_V4_MAP_LOCAL no additional attributes |
| 71 | * are required. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 72 | * |
| 73 | * o LISTALL: |
| 74 | * This message is sent by an application to list the valid DOIs on the |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 75 | * system. When sent by an application there is no payload and the |
| 76 | * NLM_F_DUMP flag should be set. The kernel should respond with a series of |
| 77 | * the following messages. |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 78 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 79 | * Required attributes: |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 80 | * |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 81 | * NLBL_CIPSOV4_A_DOI |
| 82 | * NLBL_CIPSOV4_A_MTYPE |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 83 | * |
| 84 | */ |
| 85 | |
| 86 | /* NetLabel CIPSOv4 commands */ |
| 87 | enum { |
| 88 | NLBL_CIPSOV4_C_UNSPEC, |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 89 | NLBL_CIPSOV4_C_ADD, |
| 90 | NLBL_CIPSOV4_C_REMOVE, |
| 91 | NLBL_CIPSOV4_C_LIST, |
| 92 | NLBL_CIPSOV4_C_LISTALL, |
| 93 | __NLBL_CIPSOV4_C_MAX, |
| 94 | }; |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 95 | |
Paul Moore | fd38585 | 2006-09-25 15:56:37 -0700 | [diff] [blame] | 96 | /* NetLabel CIPSOv4 attributes */ |
| 97 | enum { |
| 98 | NLBL_CIPSOV4_A_UNSPEC, |
| 99 | NLBL_CIPSOV4_A_DOI, |
| 100 | /* (NLA_U32) |
| 101 | * the DOI value */ |
| 102 | NLBL_CIPSOV4_A_MTYPE, |
| 103 | /* (NLA_U32) |
| 104 | * the mapping table type (defined in the cipso_ipv4.h header as |
| 105 | * CIPSO_V4_MAP_*) */ |
| 106 | NLBL_CIPSOV4_A_TAG, |
| 107 | /* (NLA_U8) |
| 108 | * a CIPSO tag type, meant to be used within a NLBL_CIPSOV4_A_TAGLST |
| 109 | * attribute */ |
| 110 | NLBL_CIPSOV4_A_TAGLST, |
| 111 | /* (NLA_NESTED) |
| 112 | * the CIPSO tag list for the DOI, there must be at least one |
| 113 | * NLBL_CIPSOV4_A_TAG attribute, tags listed first are given higher |
| 114 | * priorirty when sending packets */ |
| 115 | NLBL_CIPSOV4_A_MLSLVLLOC, |
| 116 | /* (NLA_U32) |
| 117 | * the local MLS sensitivity level */ |
| 118 | NLBL_CIPSOV4_A_MLSLVLREM, |
| 119 | /* (NLA_U32) |
| 120 | * the remote MLS sensitivity level */ |
| 121 | NLBL_CIPSOV4_A_MLSLVL, |
| 122 | /* (NLA_NESTED) |
| 123 | * a MLS sensitivity level mapping, must contain only one attribute of |
| 124 | * each of the following types: NLBL_CIPSOV4_A_MLSLVLLOC and |
| 125 | * NLBL_CIPSOV4_A_MLSLVLREM */ |
| 126 | NLBL_CIPSOV4_A_MLSLVLLST, |
| 127 | /* (NLA_NESTED) |
| 128 | * the CIPSO level mappings, there must be at least one |
| 129 | * NLBL_CIPSOV4_A_MLSLVL attribute */ |
| 130 | NLBL_CIPSOV4_A_MLSCATLOC, |
| 131 | /* (NLA_U32) |
| 132 | * the local MLS category */ |
| 133 | NLBL_CIPSOV4_A_MLSCATREM, |
| 134 | /* (NLA_U32) |
| 135 | * the remote MLS category */ |
| 136 | NLBL_CIPSOV4_A_MLSCAT, |
| 137 | /* (NLA_NESTED) |
| 138 | * a MLS category mapping, must contain only one attribute of each of |
| 139 | * the following types: NLBL_CIPSOV4_A_MLSCATLOC and |
| 140 | * NLBL_CIPSOV4_A_MLSCATREM */ |
| 141 | NLBL_CIPSOV4_A_MLSCATLST, |
| 142 | /* (NLA_NESTED) |
| 143 | * the CIPSO category mappings, there must be at least one |
| 144 | * NLBL_CIPSOV4_A_MLSCAT attribute */ |
| 145 | __NLBL_CIPSOV4_A_MAX, |
| 146 | }; |
| 147 | #define NLBL_CIPSOV4_A_MAX (__NLBL_CIPSOV4_A_MAX - 1) |
| 148 | |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 149 | /* NetLabel protocol functions */ |
| 150 | int netlbl_cipsov4_genl_init(void); |
| 151 | |
Paul Moore | eda61d3 | 2008-02-04 22:29:47 -0800 | [diff] [blame] | 152 | /* Free the memory associated with a CIPSOv4 DOI definition */ |
| 153 | void netlbl_cipsov4_doi_free(struct rcu_head *entry); |
| 154 | |
Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 155 | #endif |