netlabel.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * NetLabel System
  4. *
  5. * The 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. * (c) Copyright Hewlett-Packard Development Company, L.P., 2006, 2008
  12. */
  13. #ifndef _NETLABEL_H
  14. #define _NETLABEL_H
  15. #include <linux/types.h>
  16. #include <linux/slab.h>
  17. #include <linux/net.h>
  18. #include <linux/skbuff.h>
  19. #include <linux/in.h>
  20. #include <linux/in6.h>
  21. #include <net/netlink.h>
  22. #include <net/request_sock.h>
  23. #include <linux/refcount.h>
  24. struct cipso_v4_doi;
  25. struct calipso_doi;
  26. /*
  27. * NetLabel - A management interface for maintaining network packet label
  28. * mapping tables for explicit packet labeling protocols.
  29. *
  30. * Network protocols such as CIPSO and RIPSO require a label translation layer
  31. * to convert the label on the packet into something meaningful on the host
  32. * machine. In the current Linux implementation these mapping tables live
  33. * inside the kernel; NetLabel provides a mechanism for user space applications
  34. * to manage these mapping tables.
  35. *
  36. * NetLabel makes use of the Generic NETLINK mechanism as a transport layer to
  37. * send messages between kernel and user space. The general format of a
  38. * NetLabel message is shown below:
  39. *
  40. * +-----------------+-------------------+--------- --- -- -
  41. * | struct nlmsghdr | struct genlmsghdr | payload
  42. * +-----------------+-------------------+--------- --- -- -
  43. *
  44. * The 'nlmsghdr' and 'genlmsghdr' structs should be dealt with like normal.
  45. * The payload is dependent on the subsystem specified in the
  46. * 'nlmsghdr->nlmsg_type' and should be defined below, supporting functions
  47. * should be defined in the corresponding net/netlabel/netlabel_<subsys>.h|c
  48. * file. All of the fields in the NetLabel payload are NETLINK attributes, see
  49. * the include/net/netlink.h file for more information on NETLINK attributes.
  50. *
  51. */
  52. /*
  53. * NetLabel NETLINK protocol
  54. */
  55. /* NetLabel NETLINK protocol version
  56. * 1: initial version
  57. * 2: added static labels for unlabeled connections
  58. * 3: network selectors added to the NetLabel/LSM domain mapping and the
  59. * CIPSO_V4_MAP_LOCAL CIPSO mapping was added
  60. */
  61. #define NETLBL_PROTO_VERSION 3
  62. /* NetLabel NETLINK types/families */
  63. #define NETLBL_NLTYPE_NONE 0
  64. #define NETLBL_NLTYPE_MGMT 1
  65. #define NETLBL_NLTYPE_MGMT_NAME "NLBL_MGMT"
  66. #define NETLBL_NLTYPE_RIPSO 2
  67. #define NETLBL_NLTYPE_RIPSO_NAME "NLBL_RIPSO"
  68. #define NETLBL_NLTYPE_CIPSOV4 3
  69. #define NETLBL_NLTYPE_CIPSOV4_NAME "NLBL_CIPSOv4"
  70. #define NETLBL_NLTYPE_CIPSOV6 4
  71. #define NETLBL_NLTYPE_CIPSOV6_NAME "NLBL_CIPSOv6"
  72. #define NETLBL_NLTYPE_UNLABELED 5
  73. #define NETLBL_NLTYPE_UNLABELED_NAME "NLBL_UNLBL"
  74. #define NETLBL_NLTYPE_ADDRSELECT 6
  75. #define NETLBL_NLTYPE_ADDRSELECT_NAME "NLBL_ADRSEL"
  76. #define NETLBL_NLTYPE_CALIPSO 7
  77. #define NETLBL_NLTYPE_CALIPSO_NAME "NLBL_CALIPSO"
  78. /*
  79. * NetLabel - Kernel API for accessing the network packet label mappings.
  80. *
  81. * The following functions are provided for use by other kernel modules,
  82. * specifically kernel LSM modules, to provide a consistent, transparent API
  83. * for dealing with explicit packet labeling protocols such as CIPSO and
  84. * RIPSO. The functions defined here are implemented in the
  85. * net/netlabel/netlabel_kapi.c file.
  86. *
  87. */
  88. /* NetLabel audit information */
  89. struct netlbl_audit {
  90. u32 secid;
  91. kuid_t loginuid;
  92. unsigned int sessionid;
  93. };
  94. /*
  95. * LSM security attributes
  96. */
  97. /**
  98. * struct netlbl_lsm_cache - NetLabel LSM security attribute cache
  99. * @refcount: atomic reference counter
  100. * @free: LSM supplied function to free the cache data
  101. * @data: LSM supplied cache data
  102. *
  103. * Description:
  104. * This structure is provided for LSMs which wish to make use of the NetLabel
  105. * caching mechanism to store LSM specific data/attributes in the NetLabel
  106. * cache. If the LSM has to perform a lot of translation from the NetLabel
  107. * security attributes into it's own internal representation then the cache
  108. * mechanism can provide a way to eliminate some or all of that translation
  109. * overhead on a cache hit.
  110. *
  111. */
  112. struct netlbl_lsm_cache {
  113. refcount_t refcount;
  114. void (*free) (const void *data);
  115. void *data;
  116. };
  117. /**
  118. * struct netlbl_lsm_catmap - NetLabel LSM secattr category bitmap
  119. * @startbit: the value of the lowest order bit in the bitmap
  120. * @bitmap: the category bitmap
  121. * @next: pointer to the next bitmap "node" or NULL
  122. *
  123. * Description:
  124. * This structure is used to represent category bitmaps. Due to the large
  125. * number of categories supported by most labeling protocols it is not
  126. * practical to transfer a full bitmap internally so NetLabel adopts a sparse
  127. * bitmap structure modeled after SELinux's ebitmap structure.
  128. * The catmap bitmap field MUST be a power of two in length and large
  129. * enough to hold at least 240 bits. Special care (i.e. check the code!)
  130. * should be used when changing these values as the LSM implementation
  131. * probably has functions which rely on the sizes of these types to speed
  132. * processing.
  133. *
  134. */
  135. #define NETLBL_CATMAP_MAPCNT 4
  136. #define NETLBL_CATMAP_MAPSIZE (sizeof(u64) * 8)
  137. #define NETLBL_CATMAP_SIZE (NETLBL_CATMAP_MAPSIZE * \
  138. NETLBL_CATMAP_MAPCNT)
  139. #define NETLBL_CATMAP_BIT ((u64)0x01)
  140. struct netlbl_lsm_catmap {
  141. u32 startbit;
  142. u64 bitmap[NETLBL_CATMAP_MAPCNT];
  143. struct netlbl_lsm_catmap *next;
  144. };
  145. /**
  146. * struct netlbl_lsm_secattr - NetLabel LSM security attributes
  147. * @flags: indicate structure attributes, see NETLBL_SECATTR_*
  148. * @type: indicate the NLTYPE of the attributes
  149. * @domain: the NetLabel LSM domain
  150. * @cache: NetLabel LSM specific cache
  151. * @attr.mls: MLS sensitivity label
  152. * @attr.mls.cat: MLS category bitmap
  153. * @attr.mls.lvl: MLS sensitivity level
  154. * @attr.secid: LSM specific secid token
  155. *
  156. * Description:
  157. * This structure is used to pass security attributes between NetLabel and the
  158. * LSM modules. The flags field is used to specify which fields within the
  159. * struct are valid and valid values can be created by bitwise OR'ing the
  160. * NETLBL_SECATTR_* defines. The domain field is typically set by the LSM to
  161. * specify domain specific configuration settings and is not usually used by
  162. * NetLabel itself when returning security attributes to the LSM.
  163. *
  164. */
  165. struct netlbl_lsm_secattr {
  166. u32 flags;
  167. /* bitmap values for 'flags' */
  168. #define NETLBL_SECATTR_NONE 0x00000000
  169. #define NETLBL_SECATTR_DOMAIN 0x00000001
  170. #define NETLBL_SECATTR_DOMAIN_CPY (NETLBL_SECATTR_DOMAIN | \
  171. NETLBL_SECATTR_FREE_DOMAIN)
  172. #define NETLBL_SECATTR_CACHE 0x00000002
  173. #define NETLBL_SECATTR_MLS_LVL 0x00000004
  174. #define NETLBL_SECATTR_MLS_CAT 0x00000008
  175. #define NETLBL_SECATTR_SECID 0x00000010
  176. /* bitmap meta-values for 'flags' */
  177. #define NETLBL_SECATTR_FREE_DOMAIN 0x01000000
  178. #define NETLBL_SECATTR_CACHEABLE (NETLBL_SECATTR_MLS_LVL | \
  179. NETLBL_SECATTR_MLS_CAT | \
  180. NETLBL_SECATTR_SECID)
  181. u32 type;
  182. char *domain;
  183. struct netlbl_lsm_cache *cache;
  184. struct {
  185. struct {
  186. struct netlbl_lsm_catmap *cat;
  187. u32 lvl;
  188. } mls;
  189. u32 secid;
  190. } attr;
  191. };
  192. /**
  193. * struct netlbl_calipso_ops - NetLabel CALIPSO operations
  194. * @doi_add: add a CALIPSO DOI
  195. * @doi_free: free a CALIPSO DOI
  196. * @doi_getdef: returns a reference to a DOI
  197. * @doi_putdef: releases a reference of a DOI
  198. * @doi_walk: enumerate the DOI list
  199. * @sock_getattr: retrieve the socket's attr
  200. * @sock_setattr: set the socket's attr
  201. * @sock_delattr: remove the socket's attr
  202. * @req_setattr: set the req socket's attr
  203. * @req_delattr: remove the req socket's attr
  204. * @opt_getattr: retrieve attr from memory block
  205. * @skbuff_optptr: find option in packet
  206. * @skbuff_setattr: set the skbuff's attr
  207. * @skbuff_delattr: remove the skbuff's attr
  208. * @cache_invalidate: invalidate cache
  209. * @cache_add: add cache entry
  210. *
  211. * Description:
  212. * This structure is filled out by the CALIPSO engine and passed
  213. * to the NetLabel core via a call to netlbl_calipso_ops_register().
  214. * It enables the CALIPSO engine (and hence IPv6) to be compiled
  215. * as a module.
  216. */
  217. struct netlbl_calipso_ops {
  218. int (*doi_add)(struct calipso_doi *doi_def,
  219. struct netlbl_audit *audit_info);
  220. void (*doi_free)(struct calipso_doi *doi_def);
  221. int (*doi_remove)(u32 doi, struct netlbl_audit *audit_info);
  222. struct calipso_doi *(*doi_getdef)(u32 doi);
  223. void (*doi_putdef)(struct calipso_doi *doi_def);
  224. int (*doi_walk)(u32 *skip_cnt,
  225. int (*callback)(struct calipso_doi *doi_def, void *arg),
  226. void *cb_arg);
  227. int (*sock_getattr)(struct sock *sk,
  228. struct netlbl_lsm_secattr *secattr);
  229. int (*sock_setattr)(struct sock *sk,
  230. const struct calipso_doi *doi_def,
  231. const struct netlbl_lsm_secattr *secattr);
  232. void (*sock_delattr)(struct sock *sk);
  233. int (*req_setattr)(struct request_sock *req,
  234. const struct calipso_doi *doi_def,
  235. const struct netlbl_lsm_secattr *secattr);
  236. void (*req_delattr)(struct request_sock *req);
  237. int (*opt_getattr)(const unsigned char *calipso,
  238. struct netlbl_lsm_secattr *secattr);
  239. unsigned char *(*skbuff_optptr)(const struct sk_buff *skb);
  240. int (*skbuff_setattr)(struct sk_buff *skb,
  241. const struct calipso_doi *doi_def,
  242. const struct netlbl_lsm_secattr *secattr);
  243. int (*skbuff_delattr)(struct sk_buff *skb);
  244. void (*cache_invalidate)(void);
  245. int (*cache_add)(const unsigned char *calipso_ptr,
  246. const struct netlbl_lsm_secattr *secattr);
  247. };
  248. /*
  249. * LSM security attribute operations (inline)
  250. */
  251. /**
  252. * netlbl_secattr_cache_alloc - Allocate and initialize a secattr cache
  253. * @flags: the memory allocation flags
  254. *
  255. * Description:
  256. * Allocate and initialize a netlbl_lsm_cache structure. Returns a pointer
  257. * on success, NULL on failure.
  258. *
  259. */
  260. static inline struct netlbl_lsm_cache *netlbl_secattr_cache_alloc_noprof(gfp_t flags)
  261. {
  262. struct netlbl_lsm_cache *cache;
  263. cache = kzalloc_noprof(sizeof(*cache), flags);
  264. if (cache)
  265. refcount_set(&cache->refcount, 1);
  266. return cache;
  267. }
  268. #define netlbl_secattr_cache_alloc(...) \
  269. alloc_hooks(netlbl_secattr_cache_alloc_noprof(__VA_ARGS__))
  270. /**
  271. * netlbl_secattr_cache_free - Frees a netlbl_lsm_cache struct
  272. * @cache: the struct to free
  273. *
  274. * Description:
  275. * Frees @secattr including all of the internal buffers.
  276. *
  277. */
  278. static inline void netlbl_secattr_cache_free(struct netlbl_lsm_cache *cache)
  279. {
  280. if (!refcount_dec_and_test(&cache->refcount))
  281. return;
  282. if (cache->free)
  283. cache->free(cache->data);
  284. kfree(cache);
  285. }
  286. /**
  287. * netlbl_catmap_alloc - Allocate a LSM secattr catmap
  288. * @flags: memory allocation flags
  289. *
  290. * Description:
  291. * Allocate memory for a LSM secattr catmap, returns a pointer on success, NULL
  292. * on failure.
  293. *
  294. */
  295. static inline struct netlbl_lsm_catmap *netlbl_catmap_alloc_noprof(gfp_t flags)
  296. {
  297. return kzalloc_noprof(sizeof(struct netlbl_lsm_catmap), flags);
  298. }
  299. #define netlbl_catmap_alloc(...) alloc_hooks(netlbl_catmap_alloc_noprof(__VA_ARGS__))
  300. /**
  301. * netlbl_catmap_free - Free a LSM secattr catmap
  302. * @catmap: the category bitmap
  303. *
  304. * Description:
  305. * Free a LSM secattr catmap.
  306. *
  307. */
  308. static inline void netlbl_catmap_free(struct netlbl_lsm_catmap *catmap)
  309. {
  310. struct netlbl_lsm_catmap *iter;
  311. while (catmap) {
  312. iter = catmap;
  313. catmap = catmap->next;
  314. kfree(iter);
  315. }
  316. }
  317. /**
  318. * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct
  319. * @secattr: the struct to initialize
  320. *
  321. * Description:
  322. * Initialize an already allocated netlbl_lsm_secattr struct.
  323. *
  324. */
  325. static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)
  326. {
  327. memset(secattr, 0, sizeof(*secattr));
  328. }
  329. /**
  330. * netlbl_secattr_destroy - Clears a netlbl_lsm_secattr struct
  331. * @secattr: the struct to clear
  332. *
  333. * Description:
  334. * Destroys the @secattr struct, including freeing all of the internal buffers.
  335. * The struct must be reset with a call to netlbl_secattr_init() before reuse.
  336. *
  337. */
  338. static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
  339. {
  340. if (secattr->flags & NETLBL_SECATTR_FREE_DOMAIN)
  341. kfree(secattr->domain);
  342. if (secattr->flags & NETLBL_SECATTR_CACHE)
  343. netlbl_secattr_cache_free(secattr->cache);
  344. if (secattr->flags & NETLBL_SECATTR_MLS_CAT)
  345. netlbl_catmap_free(secattr->attr.mls.cat);
  346. }
  347. /**
  348. * netlbl_secattr_alloc - Allocate and initialize a netlbl_lsm_secattr struct
  349. * @flags: the memory allocation flags
  350. *
  351. * Description:
  352. * Allocate and initialize a netlbl_lsm_secattr struct. Returns a valid
  353. * pointer on success, or NULL on failure.
  354. *
  355. */
  356. static inline struct netlbl_lsm_secattr *netlbl_secattr_alloc_noprof(gfp_t flags)
  357. {
  358. return kzalloc_noprof(sizeof(struct netlbl_lsm_secattr), flags);
  359. }
  360. #define netlbl_secattr_alloc(...) alloc_hooks(netlbl_secattr_alloc_noprof(__VA_ARGS__))
  361. /**
  362. * netlbl_secattr_free - Frees a netlbl_lsm_secattr struct
  363. * @secattr: the struct to free
  364. *
  365. * Description:
  366. * Frees @secattr including all of the internal buffers.
  367. *
  368. */
  369. static inline void netlbl_secattr_free(struct netlbl_lsm_secattr *secattr)
  370. {
  371. netlbl_secattr_destroy(secattr);
  372. kfree(secattr);
  373. }
  374. #ifdef CONFIG_NETLABEL
  375. /*
  376. * LSM configuration operations
  377. */
  378. int netlbl_cfg_map_del(const char *domain,
  379. u16 family,
  380. const void *addr,
  381. const void *mask,
  382. struct netlbl_audit *audit_info);
  383. int netlbl_cfg_unlbl_map_add(const char *domain,
  384. u16 family,
  385. const void *addr,
  386. const void *mask,
  387. struct netlbl_audit *audit_info);
  388. int netlbl_cfg_unlbl_static_add(struct net *net,
  389. const char *dev_name,
  390. const void *addr,
  391. const void *mask,
  392. u16 family,
  393. u32 secid,
  394. struct netlbl_audit *audit_info);
  395. int netlbl_cfg_unlbl_static_del(struct net *net,
  396. const char *dev_name,
  397. const void *addr,
  398. const void *mask,
  399. u16 family,
  400. struct netlbl_audit *audit_info);
  401. int netlbl_cfg_cipsov4_add(struct cipso_v4_doi *doi_def,
  402. struct netlbl_audit *audit_info);
  403. void netlbl_cfg_cipsov4_del(u32 doi, struct netlbl_audit *audit_info);
  404. int netlbl_cfg_cipsov4_map_add(u32 doi,
  405. const char *domain,
  406. const struct in_addr *addr,
  407. const struct in_addr *mask,
  408. struct netlbl_audit *audit_info);
  409. int netlbl_cfg_calipso_add(struct calipso_doi *doi_def,
  410. struct netlbl_audit *audit_info);
  411. void netlbl_cfg_calipso_del(u32 doi, struct netlbl_audit *audit_info);
  412. int netlbl_cfg_calipso_map_add(u32 doi,
  413. const char *domain,
  414. const struct in6_addr *addr,
  415. const struct in6_addr *mask,
  416. struct netlbl_audit *audit_info);
  417. /*
  418. * LSM security attribute operations
  419. */
  420. int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap, u32 offset);
  421. int netlbl_catmap_walkrng(struct netlbl_lsm_catmap *catmap, u32 offset);
  422. int netlbl_catmap_getlong(struct netlbl_lsm_catmap *catmap,
  423. u32 *offset,
  424. unsigned long *bitmap);
  425. int netlbl_catmap_setbit(struct netlbl_lsm_catmap **catmap,
  426. u32 bit,
  427. gfp_t flags);
  428. int netlbl_catmap_setrng(struct netlbl_lsm_catmap **catmap,
  429. u32 start,
  430. u32 end,
  431. gfp_t flags);
  432. int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap,
  433. u32 offset,
  434. unsigned long bitmap,
  435. gfp_t flags);
  436. /* Bitmap functions
  437. */
  438. int netlbl_bitmap_walk(const unsigned char *bitmap, u32 bitmap_len,
  439. u32 offset, u8 state);
  440. void netlbl_bitmap_setbit(unsigned char *bitmap, u32 bit, u8 state);
  441. /*
  442. * LSM protocol operations (NetLabel LSM/kernel API)
  443. */
  444. int netlbl_enabled(void);
  445. int netlbl_sock_setattr(struct sock *sk,
  446. u16 family,
  447. const struct netlbl_lsm_secattr *secattr,
  448. bool sk_locked);
  449. void netlbl_sock_delattr(struct sock *sk);
  450. int netlbl_sock_getattr(struct sock *sk,
  451. struct netlbl_lsm_secattr *secattr);
  452. int netlbl_conn_setattr(struct sock *sk,
  453. struct sockaddr *addr,
  454. const struct netlbl_lsm_secattr *secattr);
  455. int netlbl_req_setattr(struct request_sock *req,
  456. const struct netlbl_lsm_secattr *secattr);
  457. void netlbl_req_delattr(struct request_sock *req);
  458. int netlbl_skbuff_setattr(struct sk_buff *skb,
  459. u16 family,
  460. const struct netlbl_lsm_secattr *secattr);
  461. int netlbl_skbuff_getattr(const struct sk_buff *skb,
  462. u16 family,
  463. struct netlbl_lsm_secattr *secattr);
  464. void netlbl_skbuff_err(struct sk_buff *skb, u16 family, int error, int gateway);
  465. bool netlbl_sk_lock_check(struct sock *sk);
  466. /*
  467. * LSM label mapping cache operations
  468. */
  469. void netlbl_cache_invalidate(void);
  470. int netlbl_cache_add(const struct sk_buff *skb, u16 family,
  471. const struct netlbl_lsm_secattr *secattr);
  472. /*
  473. * Protocol engine operations
  474. */
  475. struct audit_buffer *netlbl_audit_start(int type,
  476. struct netlbl_audit *audit_info);
  477. #else
  478. static inline int netlbl_cfg_map_del(const char *domain,
  479. u16 family,
  480. const void *addr,
  481. const void *mask,
  482. struct netlbl_audit *audit_info)
  483. {
  484. return -ENOSYS;
  485. }
  486. static inline int netlbl_cfg_unlbl_map_add(const char *domain,
  487. u16 family,
  488. void *addr,
  489. void *mask,
  490. struct netlbl_audit *audit_info)
  491. {
  492. return -ENOSYS;
  493. }
  494. static inline int netlbl_cfg_unlbl_static_add(struct net *net,
  495. const char *dev_name,
  496. const void *addr,
  497. const void *mask,
  498. u16 family,
  499. u32 secid,
  500. struct netlbl_audit *audit_info)
  501. {
  502. return -ENOSYS;
  503. }
  504. static inline int netlbl_cfg_unlbl_static_del(struct net *net,
  505. const char *dev_name,
  506. const void *addr,
  507. const void *mask,
  508. u16 family,
  509. struct netlbl_audit *audit_info)
  510. {
  511. return -ENOSYS;
  512. }
  513. static inline int netlbl_cfg_cipsov4_add(struct cipso_v4_doi *doi_def,
  514. struct netlbl_audit *audit_info)
  515. {
  516. return -ENOSYS;
  517. }
  518. static inline void netlbl_cfg_cipsov4_del(u32 doi,
  519. struct netlbl_audit *audit_info)
  520. {
  521. return;
  522. }
  523. static inline int netlbl_cfg_cipsov4_map_add(u32 doi,
  524. const char *domain,
  525. const struct in_addr *addr,
  526. const struct in_addr *mask,
  527. struct netlbl_audit *audit_info)
  528. {
  529. return -ENOSYS;
  530. }
  531. static inline int netlbl_cfg_calipso_add(struct calipso_doi *doi_def,
  532. struct netlbl_audit *audit_info)
  533. {
  534. return -ENOSYS;
  535. }
  536. static inline void netlbl_cfg_calipso_del(u32 doi,
  537. struct netlbl_audit *audit_info)
  538. {
  539. return;
  540. }
  541. static inline int netlbl_cfg_calipso_map_add(u32 doi,
  542. const char *domain,
  543. const struct in6_addr *addr,
  544. const struct in6_addr *mask,
  545. struct netlbl_audit *audit_info)
  546. {
  547. return -ENOSYS;
  548. }
  549. static inline int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap,
  550. u32 offset)
  551. {
  552. return -ENOENT;
  553. }
  554. static inline int netlbl_catmap_walkrng(struct netlbl_lsm_catmap *catmap,
  555. u32 offset)
  556. {
  557. return -ENOENT;
  558. }
  559. static inline int netlbl_catmap_getlong(struct netlbl_lsm_catmap *catmap,
  560. u32 *offset,
  561. unsigned long *bitmap)
  562. {
  563. return 0;
  564. }
  565. static inline int netlbl_catmap_setbit(struct netlbl_lsm_catmap **catmap,
  566. u32 bit,
  567. gfp_t flags)
  568. {
  569. return 0;
  570. }
  571. static inline int netlbl_catmap_setrng(struct netlbl_lsm_catmap **catmap,
  572. u32 start,
  573. u32 end,
  574. gfp_t flags)
  575. {
  576. return 0;
  577. }
  578. static inline int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap,
  579. u32 offset,
  580. unsigned long bitmap,
  581. gfp_t flags)
  582. {
  583. return 0;
  584. }
  585. static inline int netlbl_enabled(void)
  586. {
  587. return 0;
  588. }
  589. static inline int netlbl_sock_setattr(struct sock *sk,
  590. u16 family,
  591. const struct netlbl_lsm_secattr *secattr,
  592. bool sk_locked)
  593. {
  594. return -ENOSYS;
  595. }
  596. static inline void netlbl_sock_delattr(struct sock *sk)
  597. {
  598. }
  599. static inline int netlbl_sock_getattr(struct sock *sk,
  600. struct netlbl_lsm_secattr *secattr)
  601. {
  602. return -ENOSYS;
  603. }
  604. static inline int netlbl_conn_setattr(struct sock *sk,
  605. struct sockaddr *addr,
  606. const struct netlbl_lsm_secattr *secattr)
  607. {
  608. return -ENOSYS;
  609. }
  610. static inline int netlbl_req_setattr(struct request_sock *req,
  611. const struct netlbl_lsm_secattr *secattr)
  612. {
  613. return -ENOSYS;
  614. }
  615. static inline void netlbl_req_delattr(struct request_sock *req)
  616. {
  617. return;
  618. }
  619. static inline int netlbl_skbuff_setattr(struct sk_buff *skb,
  620. u16 family,
  621. const struct netlbl_lsm_secattr *secattr)
  622. {
  623. return -ENOSYS;
  624. }
  625. static inline int netlbl_skbuff_getattr(const struct sk_buff *skb,
  626. u16 family,
  627. struct netlbl_lsm_secattr *secattr)
  628. {
  629. return -ENOSYS;
  630. }
  631. static inline void netlbl_skbuff_err(struct sk_buff *skb,
  632. int error,
  633. int gateway)
  634. {
  635. return;
  636. }
  637. static inline void netlbl_cache_invalidate(void)
  638. {
  639. return;
  640. }
  641. static inline int netlbl_cache_add(const struct sk_buff *skb, u16 family,
  642. const struct netlbl_lsm_secattr *secattr)
  643. {
  644. return 0;
  645. }
  646. static inline struct audit_buffer *netlbl_audit_start(int type,
  647. struct netlbl_audit *audit_info)
  648. {
  649. return NULL;
  650. }
  651. static inline bool netlbl_sk_lock_check(struct sock *sk)
  652. {
  653. return true;
  654. }
  655. #endif /* CONFIG_NETLABEL */
  656. const struct netlbl_calipso_ops *
  657. netlbl_calipso_ops_register(const struct netlbl_calipso_ops *ops);
  658. #endif /* _NETLABEL_H */