Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * NetLabel CALIPSO Support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * This file defines the CALIPSO functions for the NetLabel system.  The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * NetLabel system manages static and dynamic label mappings for network
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * protocols such as CIPSO and RIPSO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Authors: Paul Moore <paul@paul-moore.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *          Huw Davies <huw@codeweavers.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) /* (c) Copyright Hewlett-Packard Development Company, L.P., 2006
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * (c) Copyright Huw Davies <huw@codeweavers.com>, 2015
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #ifndef _NETLABEL_CALIPSO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define _NETLABEL_CALIPSO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <net/netlabel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <net/calipso.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) /* The following NetLabel payloads are supported by the CALIPSO subsystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * o ADD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *   Sent by an application to add a new DOI mapping table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *   Required attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *     NLBL_CALIPSO_A_DOI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *     NLBL_CALIPSO_A_MTYPE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *   If using CALIPSO_MAP_PASS no additional attributes are required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * o REMOVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *   Sent by an application to remove a specific DOI mapping table from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *   CALIPSO system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *   Required attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *     NLBL_CALIPSO_A_DOI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * o LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  *   Sent by an application to list the details of a DOI definition.  On
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  *   success the kernel should send a response using the following format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  *   Required attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  *     NLBL_CALIPSO_A_DOI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  *   The valid response message format depends on the type of the DOI mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  *   the defined formats are shown below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  *   Required attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  *     NLBL_CALIPSO_A_MTYPE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  *   If using CALIPSO_MAP_PASS no additional attributes are required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * o LISTALL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  *   This message is sent by an application to list the valid DOIs on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  *   system.  When sent by an application there is no payload and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  *   NLM_F_DUMP flag should be set.  The kernel should respond with a series of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  *   the following messages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  *   Required attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  *    NLBL_CALIPSO_A_DOI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  *    NLBL_CALIPSO_A_MTYPE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) /* NetLabel CALIPSO commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	NLBL_CALIPSO_C_UNSPEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	NLBL_CALIPSO_C_ADD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	NLBL_CALIPSO_C_REMOVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	NLBL_CALIPSO_C_LIST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	NLBL_CALIPSO_C_LISTALL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	__NLBL_CALIPSO_C_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) /* NetLabel CALIPSO attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	NLBL_CALIPSO_A_UNSPEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	NLBL_CALIPSO_A_DOI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	/* (NLA_U32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	 * the DOI value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	NLBL_CALIPSO_A_MTYPE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	/* (NLA_U32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	 * the mapping table type (defined in the calipso.h header as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	 * CALIPSO_MAP_*) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	__NLBL_CALIPSO_A_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) #define NLBL_CALIPSO_A_MAX (__NLBL_CALIPSO_A_MAX - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) /* NetLabel protocol functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) int netlbl_calipso_genl_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static inline int netlbl_calipso_genl_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) int calipso_doi_add(struct calipso_doi *doi_def,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		    struct netlbl_audit *audit_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) void calipso_doi_free(struct calipso_doi *doi_def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) int calipso_doi_remove(u32 doi, struct netlbl_audit *audit_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct calipso_doi *calipso_doi_getdef(u32 doi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) void calipso_doi_putdef(struct calipso_doi *doi_def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int calipso_doi_walk(u32 *skip_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		     int (*callback)(struct calipso_doi *doi_def, void *arg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		     void *cb_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int calipso_sock_getattr(struct sock *sk, struct netlbl_lsm_secattr *secattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) int calipso_sock_setattr(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			 const struct calipso_doi *doi_def,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			 const struct netlbl_lsm_secattr *secattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) void calipso_sock_delattr(struct sock *sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) int calipso_req_setattr(struct request_sock *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			const struct calipso_doi *doi_def,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			const struct netlbl_lsm_secattr *secattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) void calipso_req_delattr(struct request_sock *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) unsigned char *calipso_optptr(const struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) int calipso_getattr(const unsigned char *calipso,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		    struct netlbl_lsm_secattr *secattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) int calipso_skbuff_setattr(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 			   const struct calipso_doi *doi_def,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			   const struct netlbl_lsm_secattr *secattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int calipso_skbuff_delattr(struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) void calipso_cache_invalidate(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int calipso_cache_add(const unsigned char *calipso_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		      const struct netlbl_lsm_secattr *secattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #endif