netlabel.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  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. struct lsm_prop prop;
  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_remove: remove a CALIPSO DOI
  197. * @doi_getdef: returns a reference to a DOI
  198. * @doi_putdef: releases a reference of a DOI
  199. * @doi_walk: enumerate the DOI list
  200. * @sock_getattr: retrieve the socket's attr
  201. * @sock_setattr: set the socket's attr
  202. * @sock_delattr: remove the socket's attr
  203. * @req_setattr: set the req socket's attr
  204. * @req_delattr: remove the req socket's attr
  205. * @opt_getattr: retrieve attr from memory block
  206. * @skbuff_optptr: find option in packet
  207. * @skbuff_setattr: set the skbuff's attr
  208. * @skbuff_delattr: remove the skbuff's attr
  209. * @cache_invalidate: invalidate cache
  210. * @cache_add: add cache entry
  211. *
  212. * Description:
  213. * This structure is filled out by the CALIPSO engine and passed
  214. * to the NetLabel core via a call to netlbl_calipso_ops_register().
  215. * It enables the CALIPSO engine (and hence IPv6) to be compiled
  216. * as a module.
  217. */
  218. struct netlbl_calipso_ops {
  219. int (*doi_add)(struct calipso_doi *doi_def,
  220. struct netlbl_audit *audit_info);
  221. void (*doi_free)(struct calipso_doi *doi_def);
  222. int (*doi_remove)(u32 doi, struct netlbl_audit *audit_info);
  223. struct calipso_doi *(*doi_getdef)(u32 doi);
  224. void (*doi_putdef)(struct calipso_doi *doi_def);
  225. int (*doi_walk)(u32 *skip_cnt,
  226. int (*callback)(struct calipso_doi *doi_def, void *arg),
  227. void *cb_arg);
  228. int (*sock_getattr)(struct sock *sk,
  229. struct netlbl_lsm_secattr *secattr);
  230. int (*sock_setattr)(struct sock *sk,
  231. const struct calipso_doi *doi_def,
  232. const struct netlbl_lsm_secattr *secattr);
  233. void (*sock_delattr)(struct sock *sk);
  234. int (*req_setattr)(struct request_sock *req,
  235. const struct calipso_doi *doi_def,
  236. const struct netlbl_lsm_secattr *secattr);
  237. void (*req_delattr)(struct request_sock *req);
  238. int (*opt_getattr)(const unsigned char *calipso,
  239. struct netlbl_lsm_secattr *secattr);
  240. unsigned char *(*skbuff_optptr)(const struct sk_buff *skb);
  241. int (*skbuff_setattr)(struct sk_buff *skb,
  242. const struct calipso_doi *doi_def,
  243. const struct netlbl_lsm_secattr *secattr);
  244. int (*skbuff_delattr)(struct sk_buff *skb);
  245. void (*cache_invalidate)(void);
  246. int (*cache_add)(const unsigned char *calipso_ptr,
  247. const struct netlbl_lsm_secattr *secattr);
  248. };
  249. /*
  250. * LSM security attribute operations (inline)
  251. */
  252. /**
  253. * netlbl_secattr_cache_alloc - Allocate and initialize a secattr cache
  254. * @flags: the memory allocation flags
  255. *
  256. * Description:
  257. * Allocate and initialize a netlbl_lsm_cache structure. Returns a pointer
  258. * on success, NULL on failure.
  259. *
  260. */
  261. static inline struct netlbl_lsm_cache *netlbl_secattr_cache_alloc_noprof(gfp_t flags)
  262. {
  263. struct netlbl_lsm_cache *cache;
  264. cache = kzalloc_noprof(sizeof(*cache), flags);
  265. if (cache)
  266. refcount_set(&cache->refcount, 1);
  267. return cache;
  268. }
  269. #define netlbl_secattr_cache_alloc(...) \
  270. alloc_hooks(netlbl_secattr_cache_alloc_noprof(__VA_ARGS__))
  271. /**
  272. * netlbl_secattr_cache_free - Frees a netlbl_lsm_cache struct
  273. * @cache: the struct to free
  274. *
  275. * Description:
  276. * Frees @secattr including all of the internal buffers.
  277. *
  278. */
  279. static inline void netlbl_secattr_cache_free(struct netlbl_lsm_cache *cache)
  280. {
  281. if (!refcount_dec_and_test(&cache->refcount))
  282. return;
  283. if (cache->free)
  284. cache->free(cache->data);
  285. kfree(cache);
  286. }
  287. /**
  288. * netlbl_catmap_alloc - Allocate a LSM secattr catmap
  289. * @flags: memory allocation flags
  290. *
  291. * Description:
  292. * Allocate memory for a LSM secattr catmap, returns a pointer on success, NULL
  293. * on failure.
  294. *
  295. */
  296. static inline struct netlbl_lsm_catmap *netlbl_catmap_alloc_noprof(gfp_t flags)
  297. {
  298. return kzalloc_noprof(sizeof(struct netlbl_lsm_catmap), flags);
  299. }
  300. #define netlbl_catmap_alloc(...) alloc_hooks(netlbl_catmap_alloc_noprof(__VA_ARGS__))
  301. /**
  302. * netlbl_catmap_free - Free a LSM secattr catmap
  303. * @catmap: the category bitmap
  304. *
  305. * Description:
  306. * Free a LSM secattr catmap.
  307. *
  308. */
  309. static inline void netlbl_catmap_free(struct netlbl_lsm_catmap *catmap)
  310. {
  311. struct netlbl_lsm_catmap *iter;
  312. while (catmap) {
  313. iter = catmap;
  314. catmap = catmap->next;
  315. kfree(iter);
  316. }
  317. }
  318. /**
  319. * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct
  320. * @secattr: the struct to initialize
  321. *
  322. * Description:
  323. * Initialize an already allocated netlbl_lsm_secattr struct.
  324. *
  325. */
  326. static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)
  327. {
  328. memset(secattr, 0, sizeof(*secattr));
  329. }
  330. /**
  331. * netlbl_secattr_destroy - Clears a netlbl_lsm_secattr struct
  332. * @secattr: the struct to clear
  333. *
  334. * Description:
  335. * Destroys the @secattr struct, including freeing all of the internal buffers.
  336. * The struct must be reset with a call to netlbl_secattr_init() before reuse.
  337. *
  338. */
  339. static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
  340. {
  341. if (secattr->flags & NETLBL_SECATTR_FREE_DOMAIN)
  342. kfree(secattr->domain);
  343. if (secattr->flags & NETLBL_SECATTR_CACHE)
  344. netlbl_secattr_cache_free(secattr->cache);
  345. if (secattr->flags & NETLBL_SECATTR_MLS_CAT)
  346. netlbl_catmap_free(secattr->attr.mls.cat);
  347. }
  348. /**
  349. * netlbl_secattr_alloc - Allocate and initialize a netlbl_lsm_secattr struct
  350. * @flags: the memory allocation flags
  351. *
  352. * Description:
  353. * Allocate and initialize a netlbl_lsm_secattr struct. Returns a valid
  354. * pointer on success, or NULL on failure.
  355. *
  356. */
  357. static inline struct netlbl_lsm_secattr *netlbl_secattr_alloc_noprof(gfp_t flags)
  358. {
  359. return kzalloc_noprof(sizeof(struct netlbl_lsm_secattr), flags);
  360. }
  361. #define netlbl_secattr_alloc(...) alloc_hooks(netlbl_secattr_alloc_noprof(__VA_ARGS__))
  362. /**
  363. * netlbl_secattr_free - Frees a netlbl_lsm_secattr struct
  364. * @secattr: the struct to free
  365. *
  366. * Description:
  367. * Frees @secattr including all of the internal buffers.
  368. *
  369. */
  370. static inline void netlbl_secattr_free(struct netlbl_lsm_secattr *secattr)
  371. {
  372. netlbl_secattr_destroy(secattr);
  373. kfree(secattr);
  374. }
  375. #ifdef CONFIG_NETLABEL
  376. /*
  377. * LSM configuration operations
  378. */
  379. int netlbl_cfg_map_del(const char *domain,
  380. u16 family,
  381. const void *addr,
  382. const void *mask,
  383. struct netlbl_audit *audit_info);
  384. int netlbl_cfg_unlbl_map_add(const char *domain,
  385. u16 family,
  386. const void *addr,
  387. const void *mask,
  388. struct netlbl_audit *audit_info);
  389. int netlbl_cfg_unlbl_static_add(struct net *net,
  390. const char *dev_name,
  391. const void *addr,
  392. const void *mask,
  393. u16 family,
  394. u32 secid,
  395. struct netlbl_audit *audit_info);
  396. int netlbl_cfg_unlbl_static_del(struct net *net,
  397. const char *dev_name,
  398. const void *addr,
  399. const void *mask,
  400. u16 family,
  401. struct netlbl_audit *audit_info);
  402. int netlbl_cfg_cipsov4_add(struct cipso_v4_doi *doi_def,
  403. struct netlbl_audit *audit_info);
  404. void netlbl_cfg_cipsov4_del(u32 doi, struct netlbl_audit *audit_info);
  405. int netlbl_cfg_cipsov4_map_add(u32 doi,
  406. const char *domain,
  407. const struct in_addr *addr,
  408. const struct in_addr *mask,
  409. struct netlbl_audit *audit_info);
  410. int netlbl_cfg_calipso_add(struct calipso_doi *doi_def,
  411. struct netlbl_audit *audit_info);
  412. void netlbl_cfg_calipso_del(u32 doi, struct netlbl_audit *audit_info);
  413. int netlbl_cfg_calipso_map_add(u32 doi,
  414. const char *domain,
  415. const struct in6_addr *addr,
  416. const struct in6_addr *mask,
  417. struct netlbl_audit *audit_info);
  418. /*
  419. * LSM security attribute operations
  420. */
  421. int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap, u32 offset);
  422. int netlbl_catmap_walkrng(struct netlbl_lsm_catmap *catmap, u32 offset);
  423. int netlbl_catmap_getlong(struct netlbl_lsm_catmap *catmap,
  424. u32 *offset,
  425. unsigned long *bitmap);
  426. int netlbl_catmap_setbit(struct netlbl_lsm_catmap **catmap,
  427. u32 bit,
  428. gfp_t flags);
  429. int netlbl_catmap_setrng(struct netlbl_lsm_catmap **catmap,
  430. u32 start,
  431. u32 end,
  432. gfp_t flags);
  433. int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap,
  434. u32 offset,
  435. unsigned long bitmap,
  436. gfp_t flags);
  437. /* Bitmap functions
  438. */
  439. int netlbl_bitmap_walk(const unsigned char *bitmap, u32 bitmap_len,
  440. u32 offset, u8 state);
  441. void netlbl_bitmap_setbit(unsigned char *bitmap, u32 bit, u8 state);
  442. /*
  443. * LSM protocol operations (NetLabel LSM/kernel API)
  444. */
  445. int netlbl_enabled(void);
  446. int netlbl_sock_setattr(struct sock *sk,
  447. u16 family,
  448. const struct netlbl_lsm_secattr *secattr,
  449. bool sk_locked);
  450. void netlbl_sock_delattr(struct sock *sk);
  451. int netlbl_sock_getattr(struct sock *sk,
  452. struct netlbl_lsm_secattr *secattr);
  453. int netlbl_conn_setattr(struct sock *sk,
  454. struct sockaddr *addr,
  455. const struct netlbl_lsm_secattr *secattr);
  456. int netlbl_req_setattr(struct request_sock *req,
  457. const struct netlbl_lsm_secattr *secattr);
  458. void netlbl_req_delattr(struct request_sock *req);
  459. int netlbl_skbuff_setattr(struct sk_buff *skb,
  460. u16 family,
  461. const struct netlbl_lsm_secattr *secattr);
  462. int netlbl_skbuff_getattr(const struct sk_buff *skb,
  463. u16 family,
  464. struct netlbl_lsm_secattr *secattr);
  465. void netlbl_skbuff_err(struct sk_buff *skb, u16 family, int error, int gateway);
  466. bool netlbl_sk_lock_check(struct sock *sk);
  467. /*
  468. * LSM label mapping cache operations
  469. */
  470. void netlbl_cache_invalidate(void);
  471. int netlbl_cache_add(const struct sk_buff *skb, u16 family,
  472. const struct netlbl_lsm_secattr *secattr);
  473. /*
  474. * Protocol engine operations
  475. */
  476. struct audit_buffer *netlbl_audit_start(int type,
  477. struct netlbl_audit *audit_info);
  478. #else
  479. static inline int netlbl_cfg_map_del(const char *domain,
  480. u16 family,
  481. const void *addr,
  482. const void *mask,
  483. struct netlbl_audit *audit_info)
  484. {
  485. return -ENOSYS;
  486. }
  487. static inline int netlbl_cfg_unlbl_map_add(const char *domain,
  488. u16 family,
  489. void *addr,
  490. void *mask,
  491. struct netlbl_audit *audit_info)
  492. {
  493. return -ENOSYS;
  494. }
  495. static inline int netlbl_cfg_unlbl_static_add(struct net *net,
  496. const char *dev_name,
  497. const void *addr,
  498. const void *mask,
  499. u16 family,
  500. u32 secid,
  501. struct netlbl_audit *audit_info)
  502. {
  503. return -ENOSYS;
  504. }
  505. static inline int netlbl_cfg_unlbl_static_del(struct net *net,
  506. const char *dev_name,
  507. const void *addr,
  508. const void *mask,
  509. u16 family,
  510. struct netlbl_audit *audit_info)
  511. {
  512. return -ENOSYS;
  513. }
  514. static inline int netlbl_cfg_cipsov4_add(struct cipso_v4_doi *doi_def,
  515. struct netlbl_audit *audit_info)
  516. {
  517. return -ENOSYS;
  518. }
  519. static inline void netlbl_cfg_cipsov4_del(u32 doi,
  520. struct netlbl_audit *audit_info)
  521. {
  522. return;
  523. }
  524. static inline int netlbl_cfg_cipsov4_map_add(u32 doi,
  525. const char *domain,
  526. const struct in_addr *addr,
  527. const struct in_addr *mask,
  528. struct netlbl_audit *audit_info)
  529. {
  530. return -ENOSYS;
  531. }
  532. static inline int netlbl_cfg_calipso_add(struct calipso_doi *doi_def,
  533. struct netlbl_audit *audit_info)
  534. {
  535. return -ENOSYS;
  536. }
  537. static inline void netlbl_cfg_calipso_del(u32 doi,
  538. struct netlbl_audit *audit_info)
  539. {
  540. return;
  541. }
  542. static inline int netlbl_cfg_calipso_map_add(u32 doi,
  543. const char *domain,
  544. const struct in6_addr *addr,
  545. const struct in6_addr *mask,
  546. struct netlbl_audit *audit_info)
  547. {
  548. return -ENOSYS;
  549. }
  550. static inline int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap,
  551. u32 offset)
  552. {
  553. return -ENOENT;
  554. }
  555. static inline int netlbl_catmap_walkrng(struct netlbl_lsm_catmap *catmap,
  556. u32 offset)
  557. {
  558. return -ENOENT;
  559. }
  560. static inline int netlbl_catmap_getlong(struct netlbl_lsm_catmap *catmap,
  561. u32 *offset,
  562. unsigned long *bitmap)
  563. {
  564. return 0;
  565. }
  566. static inline int netlbl_catmap_setbit(struct netlbl_lsm_catmap **catmap,
  567. u32 bit,
  568. gfp_t flags)
  569. {
  570. return 0;
  571. }
  572. static inline int netlbl_catmap_setrng(struct netlbl_lsm_catmap **catmap,
  573. u32 start,
  574. u32 end,
  575. gfp_t flags)
  576. {
  577. return 0;
  578. }
  579. static inline int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap,
  580. u32 offset,
  581. unsigned long bitmap,
  582. gfp_t flags)
  583. {
  584. return 0;
  585. }
  586. static inline int netlbl_enabled(void)
  587. {
  588. return 0;
  589. }
  590. static inline int netlbl_sock_setattr(struct sock *sk,
  591. u16 family,
  592. const struct netlbl_lsm_secattr *secattr,
  593. bool sk_locked)
  594. {
  595. return -ENOSYS;
  596. }
  597. static inline void netlbl_sock_delattr(struct sock *sk)
  598. {
  599. }
  600. static inline int netlbl_sock_getattr(struct sock *sk,
  601. struct netlbl_lsm_secattr *secattr)
  602. {
  603. return -ENOSYS;
  604. }
  605. static inline int netlbl_conn_setattr(struct sock *sk,
  606. struct sockaddr *addr,
  607. const struct netlbl_lsm_secattr *secattr)
  608. {
  609. return -ENOSYS;
  610. }
  611. static inline int netlbl_req_setattr(struct request_sock *req,
  612. const struct netlbl_lsm_secattr *secattr)
  613. {
  614. return -ENOSYS;
  615. }
  616. static inline void netlbl_req_delattr(struct request_sock *req)
  617. {
  618. return;
  619. }
  620. static inline int netlbl_skbuff_setattr(struct sk_buff *skb,
  621. u16 family,
  622. const struct netlbl_lsm_secattr *secattr)
  623. {
  624. return -ENOSYS;
  625. }
  626. static inline int netlbl_skbuff_getattr(const struct sk_buff *skb,
  627. u16 family,
  628. struct netlbl_lsm_secattr *secattr)
  629. {
  630. return -ENOSYS;
  631. }
  632. static inline void netlbl_skbuff_err(struct sk_buff *skb,
  633. int error,
  634. int gateway)
  635. {
  636. return;
  637. }
  638. static inline void netlbl_cache_invalidate(void)
  639. {
  640. return;
  641. }
  642. static inline int netlbl_cache_add(const struct sk_buff *skb, u16 family,
  643. const struct netlbl_lsm_secattr *secattr)
  644. {
  645. return 0;
  646. }
  647. static inline struct audit_buffer *netlbl_audit_start(int type,
  648. struct netlbl_audit *audit_info)
  649. {
  650. return NULL;
  651. }
  652. static inline bool netlbl_sk_lock_check(struct sock *sk)
  653. {
  654. return true;
  655. }
  656. #endif /* CONFIG_NETLABEL */
  657. const struct netlbl_calipso_ops *
  658. netlbl_calipso_ops_register(const struct netlbl_calipso_ops *ops);
  659. #endif /* _NETLABEL_H */