xref: /openbmc/linux/include/net/netlabel.h (revision 75e22910cf0c26802b09dac2e34c13e648d3ed02)
111a03f78SPaul Moore /*
211a03f78SPaul Moore  * NetLabel System
311a03f78SPaul Moore  *
411a03f78SPaul Moore  * The NetLabel system manages static and dynamic label mappings for network
511a03f78SPaul Moore  * protocols such as CIPSO and RIPSO.
611a03f78SPaul Moore  *
711a03f78SPaul Moore  * Author: Paul Moore <paul.moore@hp.com>
811a03f78SPaul Moore  *
911a03f78SPaul Moore  */
1011a03f78SPaul Moore 
1111a03f78SPaul Moore /*
1211a03f78SPaul Moore  * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
1311a03f78SPaul Moore  *
1411a03f78SPaul Moore  * This program is free software;  you can redistribute it and/or modify
1511a03f78SPaul Moore  * it under the terms of the GNU General Public License as published by
1611a03f78SPaul Moore  * the Free Software Foundation; either version 2 of the License, or
1711a03f78SPaul Moore  * (at your option) any later version.
1811a03f78SPaul Moore  *
1911a03f78SPaul Moore  * This program is distributed in the hope that it will be useful,
2011a03f78SPaul Moore  * but WITHOUT ANY WARRANTY;  without even the implied warranty of
2111a03f78SPaul Moore  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
2211a03f78SPaul Moore  * the GNU General Public License for more details.
2311a03f78SPaul Moore  *
2411a03f78SPaul Moore  * You should have received a copy of the GNU General Public License
2511a03f78SPaul Moore  * along with this program;  if not, write to the Free Software
2611a03f78SPaul Moore  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2711a03f78SPaul Moore  *
2811a03f78SPaul Moore  */
2911a03f78SPaul Moore 
3011a03f78SPaul Moore #ifndef _NETLABEL_H
3111a03f78SPaul Moore #define _NETLABEL_H
3211a03f78SPaul Moore 
3311a03f78SPaul Moore #include <linux/types.h>
347a0e1d60SPaul Moore #include <linux/net.h>
3511a03f78SPaul Moore #include <linux/skbuff.h>
3611a03f78SPaul Moore #include <net/netlink.h>
37ffb733c6Spaul.moore@hp.com #include <asm/atomic.h>
3811a03f78SPaul Moore 
3911a03f78SPaul Moore /*
4011a03f78SPaul Moore  * NetLabel - A management interface for maintaining network packet label
4111a03f78SPaul Moore  *            mapping tables for explicit packet labling protocols.
4211a03f78SPaul Moore  *
4311a03f78SPaul Moore  * Network protocols such as CIPSO and RIPSO require a label translation layer
4411a03f78SPaul Moore  * to convert the label on the packet into something meaningful on the host
4511a03f78SPaul Moore  * machine.  In the current Linux implementation these mapping tables live
4611a03f78SPaul Moore  * inside the kernel; NetLabel provides a mechanism for user space applications
4711a03f78SPaul Moore  * to manage these mapping tables.
4811a03f78SPaul Moore  *
4911a03f78SPaul Moore  * NetLabel makes use of the Generic NETLINK mechanism as a transport layer to
5011a03f78SPaul Moore  * send messages between kernel and user space.  The general format of a
5111a03f78SPaul Moore  * NetLabel message is shown below:
5211a03f78SPaul Moore  *
5311a03f78SPaul Moore  *  +-----------------+-------------------+--------- --- -- -
5411a03f78SPaul Moore  *  | struct nlmsghdr | struct genlmsghdr | payload
5511a03f78SPaul Moore  *  +-----------------+-------------------+--------- --- -- -
5611a03f78SPaul Moore  *
5711a03f78SPaul Moore  * The 'nlmsghdr' and 'genlmsghdr' structs should be dealt with like normal.
5811a03f78SPaul Moore  * The payload is dependent on the subsystem specified in the
5911a03f78SPaul Moore  * 'nlmsghdr->nlmsg_type' and should be defined below, supporting functions
6011a03f78SPaul Moore  * should be defined in the corresponding net/netlabel/netlabel_<subsys>.h|c
61fcd48280SPaul Moore  * file.  All of the fields in the NetLabel payload are NETLINK attributes, see
62fcd48280SPaul Moore  * the include/net/netlink.h file for more information on NETLINK attributes.
6311a03f78SPaul Moore  *
6411a03f78SPaul Moore  */
6511a03f78SPaul Moore 
6611a03f78SPaul Moore /*
6711a03f78SPaul Moore  * NetLabel NETLINK protocol
6811a03f78SPaul Moore  */
6911a03f78SPaul Moore 
7011a03f78SPaul Moore #define NETLBL_PROTO_VERSION            1
7111a03f78SPaul Moore 
7211a03f78SPaul Moore /* NetLabel NETLINK types/families */
7311a03f78SPaul Moore #define NETLBL_NLTYPE_NONE              0
7411a03f78SPaul Moore #define NETLBL_NLTYPE_MGMT              1
7511a03f78SPaul Moore #define NETLBL_NLTYPE_MGMT_NAME         "NLBL_MGMT"
7611a03f78SPaul Moore #define NETLBL_NLTYPE_RIPSO             2
7711a03f78SPaul Moore #define NETLBL_NLTYPE_RIPSO_NAME        "NLBL_RIPSO"
7811a03f78SPaul Moore #define NETLBL_NLTYPE_CIPSOV4           3
7911a03f78SPaul Moore #define NETLBL_NLTYPE_CIPSOV4_NAME      "NLBL_CIPSOv4"
8011a03f78SPaul Moore #define NETLBL_NLTYPE_CIPSOV6           4
8111a03f78SPaul Moore #define NETLBL_NLTYPE_CIPSOV6_NAME      "NLBL_CIPSOv6"
8211a03f78SPaul Moore #define NETLBL_NLTYPE_UNLABELED         5
8311a03f78SPaul Moore #define NETLBL_NLTYPE_UNLABELED_NAME    "NLBL_UNLBL"
8411a03f78SPaul Moore 
8511a03f78SPaul Moore /*
8611a03f78SPaul Moore  * NetLabel - Kernel API for accessing the network packet label mappings.
8711a03f78SPaul Moore  *
8811a03f78SPaul Moore  * The following functions are provided for use by other kernel modules,
8911a03f78SPaul Moore  * specifically kernel LSM modules, to provide a consistent, transparent API
9011a03f78SPaul Moore  * for dealing with explicit packet labeling protocols such as CIPSO and
9111a03f78SPaul Moore  * RIPSO.  The functions defined here are implemented in the
9211a03f78SPaul Moore  * net/netlabel/netlabel_kapi.c file.
9311a03f78SPaul Moore  *
9411a03f78SPaul Moore  */
9511a03f78SPaul Moore 
9695d4e6beSPaul Moore /* NetLabel audit information */
9795d4e6beSPaul Moore struct netlbl_audit {
9895d4e6beSPaul Moore 	u32 secid;
9995d4e6beSPaul Moore 	uid_t loginuid;
10095d4e6beSPaul Moore };
10195d4e6beSPaul Moore 
10211a03f78SPaul Moore /* Domain mapping definition struct */
10311a03f78SPaul Moore struct netlbl_dom_map;
10411a03f78SPaul Moore 
10511a03f78SPaul Moore /* Domain mapping operations */
10695d4e6beSPaul Moore int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info);
10711a03f78SPaul Moore 
10816efd454SPaul Moore /*
10916efd454SPaul Moore  * LSM security attributes
11016efd454SPaul Moore  */
11116efd454SPaul Moore 
11216efd454SPaul Moore /**
11316efd454SPaul Moore  * struct netlbl_lsm_cache - NetLabel LSM security attribute cache
11416efd454SPaul Moore  * @refcount: atomic reference counter
11516efd454SPaul Moore  * @free: LSM supplied function to free the cache data
11616efd454SPaul Moore  * @data: LSM supplied cache data
11716efd454SPaul Moore  *
11816efd454SPaul Moore  * Description:
11916efd454SPaul Moore  * This structure is provided for LSMs which wish to make use of the NetLabel
12016efd454SPaul Moore  * caching mechanism to store LSM specific data/attributes in the NetLabel
12116efd454SPaul Moore  * cache.  If the LSM has to perform a lot of translation from the NetLabel
12216efd454SPaul Moore  * security attributes into it's own internal representation then the cache
12316efd454SPaul Moore  * mechanism can provide a way to eliminate some or all of that translation
12416efd454SPaul Moore  * overhead on a cache hit.
12516efd454SPaul Moore  *
12616efd454SPaul Moore  */
12711a03f78SPaul Moore struct netlbl_lsm_cache {
128ffb733c6Spaul.moore@hp.com 	atomic_t refcount;
12911a03f78SPaul Moore 	void (*free) (const void *data);
13011a03f78SPaul Moore 	void *data;
13111a03f78SPaul Moore };
13216efd454SPaul Moore 
13316efd454SPaul Moore /**
13416efd454SPaul Moore  * struct netlbl_lsm_secattr_catmap - NetLabel LSM secattr category bitmap
13516efd454SPaul Moore  * @startbit: the value of the lowest order bit in the bitmap
13616efd454SPaul Moore  * @bitmap: the category bitmap
13716efd454SPaul Moore  * @next: pointer to the next bitmap "node" or NULL
13816efd454SPaul Moore  *
13916efd454SPaul Moore  * Description:
14016efd454SPaul Moore  * This structure is used to represent category bitmaps.  Due to the large
14116efd454SPaul Moore  * number of categories supported by most labeling protocols it is not
14216efd454SPaul Moore  * practical to transfer a full bitmap internally so NetLabel adopts a sparse
14316efd454SPaul Moore  * bitmap structure modeled after SELinux's ebitmap structure.
14416efd454SPaul Moore  * The catmap bitmap field MUST be a power of two in length and large
14502752760SPaul Moore  * enough to hold at least 240 bits.  Special care (i.e. check the code!)
14602752760SPaul Moore  * should be used when changing these values as the LSM implementation
14702752760SPaul Moore  * probably has functions which rely on the sizes of these types to speed
14816efd454SPaul Moore  * processing.
14916efd454SPaul Moore  *
15016efd454SPaul Moore  */
15102752760SPaul Moore #define NETLBL_CATMAP_MAPTYPE           u64
15202752760SPaul Moore #define NETLBL_CATMAP_MAPCNT            4
15302752760SPaul Moore #define NETLBL_CATMAP_MAPSIZE           (sizeof(NETLBL_CATMAP_MAPTYPE) * 8)
15402752760SPaul Moore #define NETLBL_CATMAP_SIZE              (NETLBL_CATMAP_MAPSIZE * \
15502752760SPaul Moore 					 NETLBL_CATMAP_MAPCNT)
15602752760SPaul Moore #define NETLBL_CATMAP_BIT               (NETLBL_CATMAP_MAPTYPE)0x01
15702752760SPaul Moore struct netlbl_lsm_secattr_catmap {
15802752760SPaul Moore 	u32 startbit;
15902752760SPaul Moore 	NETLBL_CATMAP_MAPTYPE bitmap[NETLBL_CATMAP_MAPCNT];
16002752760SPaul Moore 	struct netlbl_lsm_secattr_catmap *next;
16102752760SPaul Moore };
16216efd454SPaul Moore 
16316efd454SPaul Moore /**
16416efd454SPaul Moore  * struct netlbl_lsm_secattr - NetLabel LSM security attributes
16516efd454SPaul Moore  * @flags: indicate which attributes are contained in this structure
16616efd454SPaul Moore  * @type: indicate the NLTYPE of the attributes
16716efd454SPaul Moore  * @domain: the NetLabel LSM domain
16816efd454SPaul Moore  * @cache: NetLabel LSM specific cache
16916efd454SPaul Moore  * @attr.mls: MLS sensitivity label
17016efd454SPaul Moore  * @attr.mls.cat: MLS category bitmap
17116efd454SPaul Moore  * @attr.mls.lvl: MLS sensitivity level
17216efd454SPaul Moore  * @attr.secid: LSM specific secid token
17316efd454SPaul Moore  *
17416efd454SPaul Moore  * Description:
17516efd454SPaul Moore  * This structure is used to pass security attributes between NetLabel and the
17616efd454SPaul Moore  * LSM modules.  The flags field is used to specify which fields within the
17716efd454SPaul Moore  * struct are valid and valid values can be created by bitwise OR'ing the
17816efd454SPaul Moore  * NETLBL_SECATTR_* defines.  The domain field is typically set by the LSM to
17916efd454SPaul Moore  * specify domain specific configuration settings and is not usually used by
18016efd454SPaul Moore  * NetLabel itself when returning security attributes to the LSM.
18116efd454SPaul Moore  *
18216efd454SPaul Moore  */
183701a90baSPaul Moore #define NETLBL_SECATTR_NONE             0x00000000
184701a90baSPaul Moore #define NETLBL_SECATTR_DOMAIN           0x00000001
185701a90baSPaul Moore #define NETLBL_SECATTR_CACHE            0x00000002
186701a90baSPaul Moore #define NETLBL_SECATTR_MLS_LVL          0x00000004
187701a90baSPaul Moore #define NETLBL_SECATTR_MLS_CAT          0x00000008
18816efd454SPaul Moore #define NETLBL_SECATTR_SECID            0x00000010
1899534f71cSPaul Moore #define NETLBL_SECATTR_CACHEABLE        (NETLBL_SECATTR_MLS_LVL | \
19016efd454SPaul Moore 					 NETLBL_SECATTR_MLS_CAT | \
19116efd454SPaul Moore 					 NETLBL_SECATTR_SECID)
19211a03f78SPaul Moore struct netlbl_lsm_secattr {
193701a90baSPaul Moore 	u32 flags;
19416efd454SPaul Moore 	u32 type;
19511a03f78SPaul Moore 	char *domain;
196ffb733c6Spaul.moore@hp.com 	struct netlbl_lsm_cache *cache;
19716efd454SPaul Moore 	union {
19816efd454SPaul Moore 		struct {
19916efd454SPaul Moore 			struct netlbl_lsm_secattr_catmap *cat;
20016efd454SPaul Moore 			u32 lvl;
20116efd454SPaul Moore 		} mls;
20216efd454SPaul Moore 		u32 secid;
20316efd454SPaul Moore 	} attr;
20411a03f78SPaul Moore };
20511a03f78SPaul Moore 
20611a03f78SPaul Moore /*
20723bcdc1aSPaul Moore  * LSM security attribute operations (inline)
20811a03f78SPaul Moore  */
20911a03f78SPaul Moore 
21011a03f78SPaul Moore /**
211ffb733c6Spaul.moore@hp.com  * netlbl_secattr_cache_alloc - Allocate and initialize a secattr cache
212ffb733c6Spaul.moore@hp.com  * @flags: the memory allocation flags
213ffb733c6Spaul.moore@hp.com  *
214ffb733c6Spaul.moore@hp.com  * Description:
215ffb733c6Spaul.moore@hp.com  * Allocate and initialize a netlbl_lsm_cache structure.  Returns a pointer
216ffb733c6Spaul.moore@hp.com  * on success, NULL on failure.
217ffb733c6Spaul.moore@hp.com  *
218ffb733c6Spaul.moore@hp.com  */
219645408d1SAl Viro static inline struct netlbl_lsm_cache *netlbl_secattr_cache_alloc(gfp_t flags)
220ffb733c6Spaul.moore@hp.com {
221ffb733c6Spaul.moore@hp.com 	struct netlbl_lsm_cache *cache;
222ffb733c6Spaul.moore@hp.com 
223ffb733c6Spaul.moore@hp.com 	cache = kzalloc(sizeof(*cache), flags);
224ffb733c6Spaul.moore@hp.com 	if (cache)
225ffb733c6Spaul.moore@hp.com 		atomic_set(&cache->refcount, 1);
226ffb733c6Spaul.moore@hp.com 	return cache;
227ffb733c6Spaul.moore@hp.com }
228ffb733c6Spaul.moore@hp.com 
229ffb733c6Spaul.moore@hp.com /**
230ffb733c6Spaul.moore@hp.com  * netlbl_secattr_cache_free - Frees a netlbl_lsm_cache struct
231ffb733c6Spaul.moore@hp.com  * @cache: the struct to free
232ffb733c6Spaul.moore@hp.com  *
233ffb733c6Spaul.moore@hp.com  * Description:
234ffb733c6Spaul.moore@hp.com  * Frees @secattr including all of the internal buffers.
235ffb733c6Spaul.moore@hp.com  *
236ffb733c6Spaul.moore@hp.com  */
237ffb733c6Spaul.moore@hp.com static inline void netlbl_secattr_cache_free(struct netlbl_lsm_cache *cache)
238ffb733c6Spaul.moore@hp.com {
239ffb733c6Spaul.moore@hp.com 	if (!atomic_dec_and_test(&cache->refcount))
240ffb733c6Spaul.moore@hp.com 		return;
241ffb733c6Spaul.moore@hp.com 
242ffb733c6Spaul.moore@hp.com 	if (cache->free)
243ffb733c6Spaul.moore@hp.com 		cache->free(cache->data);
244ffb733c6Spaul.moore@hp.com 	kfree(cache);
245ffb733c6Spaul.moore@hp.com }
246ffb733c6Spaul.moore@hp.com 
247ffb733c6Spaul.moore@hp.com /**
24802752760SPaul Moore  * netlbl_secattr_catmap_alloc - Allocate a LSM secattr catmap
24902752760SPaul Moore  * @flags: memory allocation flags
25002752760SPaul Moore  *
25102752760SPaul Moore  * Description:
25202752760SPaul Moore  * Allocate memory for a LSM secattr catmap, returns a pointer on success, NULL
25302752760SPaul Moore  * on failure.
25402752760SPaul Moore  *
25502752760SPaul Moore  */
25602752760SPaul Moore static inline struct netlbl_lsm_secattr_catmap *netlbl_secattr_catmap_alloc(
25702752760SPaul Moore 	                                                           gfp_t flags)
25802752760SPaul Moore {
25902752760SPaul Moore 	return kzalloc(sizeof(struct netlbl_lsm_secattr_catmap), flags);
26002752760SPaul Moore }
26102752760SPaul Moore 
26202752760SPaul Moore /**
26302752760SPaul Moore  * netlbl_secattr_catmap_free - Free a LSM secattr catmap
26402752760SPaul Moore  * @catmap: the category bitmap
26502752760SPaul Moore  *
26602752760SPaul Moore  * Description:
26702752760SPaul Moore  * Free a LSM secattr catmap.
26802752760SPaul Moore  *
26902752760SPaul Moore  */
27002752760SPaul Moore static inline void netlbl_secattr_catmap_free(
27102752760SPaul Moore 	                              struct netlbl_lsm_secattr_catmap *catmap)
27202752760SPaul Moore {
27302752760SPaul Moore 	struct netlbl_lsm_secattr_catmap *iter;
27402752760SPaul Moore 
27502752760SPaul Moore 	do {
27602752760SPaul Moore 		iter = catmap;
27702752760SPaul Moore 		catmap = catmap->next;
27802752760SPaul Moore 		kfree(iter);
27902752760SPaul Moore 	} while (catmap);
28002752760SPaul Moore }
28102752760SPaul Moore 
28202752760SPaul Moore /**
28311a03f78SPaul Moore  * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct
28411a03f78SPaul Moore  * @secattr: the struct to initialize
28511a03f78SPaul Moore  *
28611a03f78SPaul Moore  * Description:
287c6fa82a9SPaul Moore  * Initialize an already allocated netlbl_lsm_secattr struct.
28811a03f78SPaul Moore  *
28911a03f78SPaul Moore  */
290c6fa82a9SPaul Moore static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)
29111a03f78SPaul Moore {
29216efd454SPaul Moore 	memset(secattr, 0, sizeof(*secattr));
29311a03f78SPaul Moore }
29411a03f78SPaul Moore 
29511a03f78SPaul Moore /**
29611a03f78SPaul Moore  * netlbl_secattr_destroy - Clears a netlbl_lsm_secattr struct
29711a03f78SPaul Moore  * @secattr: the struct to clear
29811a03f78SPaul Moore  *
29911a03f78SPaul Moore  * Description:
30011a03f78SPaul Moore  * Destroys the @secattr struct, including freeing all of the internal buffers.
301ffb733c6Spaul.moore@hp.com  * The struct must be reset with a call to netlbl_secattr_init() before reuse.
30211a03f78SPaul Moore  *
30311a03f78SPaul Moore  */
304ffb733c6Spaul.moore@hp.com static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
30511a03f78SPaul Moore {
30611a03f78SPaul Moore 	kfree(secattr->domain);
30716efd454SPaul Moore 	if (secattr->flags & NETLBL_SECATTR_CACHE)
30816efd454SPaul Moore 		netlbl_secattr_cache_free(secattr->cache);
30916efd454SPaul Moore 	if (secattr->flags & NETLBL_SECATTR_MLS_CAT)
31016efd454SPaul Moore 		netlbl_secattr_catmap_free(secattr->attr.mls.cat);
31111a03f78SPaul Moore }
31211a03f78SPaul Moore 
31311a03f78SPaul Moore /**
31411a03f78SPaul Moore  * netlbl_secattr_alloc - Allocate and initialize a netlbl_lsm_secattr struct
31511a03f78SPaul Moore  * @flags: the memory allocation flags
31611a03f78SPaul Moore  *
31711a03f78SPaul Moore  * Description:
31811a03f78SPaul Moore  * Allocate and initialize a netlbl_lsm_secattr struct.  Returns a valid
31911a03f78SPaul Moore  * pointer on success, or NULL on failure.
32011a03f78SPaul Moore  *
32111a03f78SPaul Moore  */
3221f758d93SPaul Moore static inline struct netlbl_lsm_secattr *netlbl_secattr_alloc(gfp_t flags)
32311a03f78SPaul Moore {
32411a03f78SPaul Moore 	return kzalloc(sizeof(struct netlbl_lsm_secattr), flags);
32511a03f78SPaul Moore }
32611a03f78SPaul Moore 
32711a03f78SPaul Moore /**
32811a03f78SPaul Moore  * netlbl_secattr_free - Frees a netlbl_lsm_secattr struct
32911a03f78SPaul Moore  * @secattr: the struct to free
33011a03f78SPaul Moore  *
33111a03f78SPaul Moore  * Description:
332ffb733c6Spaul.moore@hp.com  * Frees @secattr including all of the internal buffers.
33311a03f78SPaul Moore  *
33411a03f78SPaul Moore  */
335ffb733c6Spaul.moore@hp.com static inline void netlbl_secattr_free(struct netlbl_lsm_secattr *secattr)
33611a03f78SPaul Moore {
337ffb733c6Spaul.moore@hp.com 	netlbl_secattr_destroy(secattr);
33811a03f78SPaul Moore 	kfree(secattr);
33911a03f78SPaul Moore }
34011a03f78SPaul Moore 
34102752760SPaul Moore #ifdef CONFIG_NETLABEL
34223bcdc1aSPaul Moore /*
34323bcdc1aSPaul Moore  * LSM security attribute operations
34423bcdc1aSPaul Moore  */
34502752760SPaul Moore int netlbl_secattr_catmap_walk(struct netlbl_lsm_secattr_catmap *catmap,
34602752760SPaul Moore 			       u32 offset);
34702752760SPaul Moore int netlbl_secattr_catmap_walk_rng(struct netlbl_lsm_secattr_catmap *catmap,
34802752760SPaul Moore 				   u32 offset);
34902752760SPaul Moore int netlbl_secattr_catmap_setbit(struct netlbl_lsm_secattr_catmap *catmap,
35002752760SPaul Moore 				 u32 bit,
35102752760SPaul Moore 				 gfp_t flags);
35202752760SPaul Moore int netlbl_secattr_catmap_setrng(struct netlbl_lsm_secattr_catmap *catmap,
35302752760SPaul Moore 				 u32 start,
35402752760SPaul Moore 				 u32 end,
35502752760SPaul Moore 				 gfp_t flags);
35623bcdc1aSPaul Moore 
35723bcdc1aSPaul Moore /*
35816efd454SPaul Moore  * LSM protocol operations (NetLabel LSM/kernel API)
35923bcdc1aSPaul Moore  */
36023bcdc1aSPaul Moore int netlbl_enabled(void);
36123bcdc1aSPaul Moore int netlbl_sock_setattr(struct sock *sk,
36223bcdc1aSPaul Moore 			const struct netlbl_lsm_secattr *secattr);
36323bcdc1aSPaul Moore int netlbl_sock_getattr(struct sock *sk,
36423bcdc1aSPaul Moore 			struct netlbl_lsm_secattr *secattr);
36523bcdc1aSPaul Moore int netlbl_skbuff_getattr(const struct sk_buff *skb,
366*75e22910SPaul Moore 			  u16 family,
36723bcdc1aSPaul Moore 			  struct netlbl_lsm_secattr *secattr);
36823bcdc1aSPaul Moore void netlbl_skbuff_err(struct sk_buff *skb, int error);
36923bcdc1aSPaul Moore 
37023bcdc1aSPaul Moore /*
37123bcdc1aSPaul Moore  * LSM label mapping cache operations
37223bcdc1aSPaul Moore  */
37323bcdc1aSPaul Moore void netlbl_cache_invalidate(void);
37423bcdc1aSPaul Moore int netlbl_cache_add(const struct sk_buff *skb,
37523bcdc1aSPaul Moore 		     const struct netlbl_lsm_secattr *secattr);
37602752760SPaul Moore #else
37702752760SPaul Moore static inline int netlbl_secattr_catmap_walk(
37802752760SPaul Moore 	                              struct netlbl_lsm_secattr_catmap *catmap,
37902752760SPaul Moore 				      u32 offset)
38002752760SPaul Moore {
38102752760SPaul Moore 	return -ENOENT;
38202752760SPaul Moore }
38302752760SPaul Moore static inline int netlbl_secattr_catmap_walk_rng(
38402752760SPaul Moore 				      struct netlbl_lsm_secattr_catmap *catmap,
38502752760SPaul Moore 				      u32 offset)
38602752760SPaul Moore {
38702752760SPaul Moore 	return -ENOENT;
38802752760SPaul Moore }
38902752760SPaul Moore static inline int netlbl_secattr_catmap_setbit(
39002752760SPaul Moore 	                              struct netlbl_lsm_secattr_catmap *catmap,
39102752760SPaul Moore 				      u32 bit,
39202752760SPaul Moore 				      gfp_t flags)
39302752760SPaul Moore {
39402752760SPaul Moore 	return 0;
39502752760SPaul Moore }
39602752760SPaul Moore static inline int netlbl_secattr_catmap_setrng(
39702752760SPaul Moore 	                              struct netlbl_lsm_secattr_catmap *catmap,
39802752760SPaul Moore 				      u32 start,
39902752760SPaul Moore 				      u32 end,
40002752760SPaul Moore 				      gfp_t flags)
40102752760SPaul Moore {
40202752760SPaul Moore 	return 0;
40302752760SPaul Moore }
40423bcdc1aSPaul Moore static inline int netlbl_enabled(void)
40523bcdc1aSPaul Moore {
40623bcdc1aSPaul Moore 	return 0;
40723bcdc1aSPaul Moore }
408ba6ff9f2SPaul Moore static inline int netlbl_sock_setattr(struct sock *sk,
40911a03f78SPaul Moore 				     const struct netlbl_lsm_secattr *secattr)
41011a03f78SPaul Moore {
41111a03f78SPaul Moore 	return -ENOSYS;
41211a03f78SPaul Moore }
41314a72f53SPaul Moore static inline int netlbl_sock_getattr(struct sock *sk,
41414a72f53SPaul Moore 				      struct netlbl_lsm_secattr *secattr)
41514a72f53SPaul Moore {
41614a72f53SPaul Moore 	return -ENOSYS;
41714a72f53SPaul Moore }
41811a03f78SPaul Moore static inline int netlbl_skbuff_getattr(const struct sk_buff *skb,
419*75e22910SPaul Moore 					u16 family,
42011a03f78SPaul Moore 					struct netlbl_lsm_secattr *secattr)
42111a03f78SPaul Moore {
42211a03f78SPaul Moore 	return -ENOSYS;
42311a03f78SPaul Moore }
42411a03f78SPaul Moore static inline void netlbl_skbuff_err(struct sk_buff *skb, int error)
42511a03f78SPaul Moore {
42611a03f78SPaul Moore 	return;
42711a03f78SPaul Moore }
42811a03f78SPaul Moore static inline void netlbl_cache_invalidate(void)
42911a03f78SPaul Moore {
43011a03f78SPaul Moore 	return;
43111a03f78SPaul Moore }
43211a03f78SPaul Moore static inline int netlbl_cache_add(const struct sk_buff *skb,
43311a03f78SPaul Moore 				   const struct netlbl_lsm_secattr *secattr)
43411a03f78SPaul Moore {
43511a03f78SPaul Moore 	return 0;
43611a03f78SPaul Moore }
43711a03f78SPaul Moore #endif /* CONFIG_NETLABEL */
43811a03f78SPaul Moore 
43911a03f78SPaul Moore #endif /* _NETLABEL_H */
440