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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Network port table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * SELinux must keep a mapping of network ports to labels/SIDs.  This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * mapping is maintained as part of the normal policy but a fast cache is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * needed to reduce the lookup overhead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Author: Paul Moore <paul@paul-moore.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * This code is heavily based on the "netif" concept originally developed by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * James Morris <jmorris@redhat.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *   (see security/selinux/netif.c for more information)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  */
^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)  * (c) Copyright Hewlett-Packard Development Company, L.P., 2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/rcupdate.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/in6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/ip.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <linux/ipv6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <net/ip.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <net/ipv6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include "netport.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include "objsec.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define SEL_NETPORT_HASH_SIZE       256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define SEL_NETPORT_HASH_BKT_LIMIT   16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) struct sel_netport_bkt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) struct sel_netport {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	struct netport_security_struct psec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) /* NOTE: we are using a combined hash table for both IPv4 and IPv6, the reason
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * for this is that I suspect most users will not make heavy use of both
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * address families at the same time so one table will usually end up wasted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * if this becomes a problem we can always add a hash table for each address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * family later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) static LIST_HEAD(sel_netport_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static DEFINE_SPINLOCK(sel_netport_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) static struct sel_netport_bkt sel_netport_hash[SEL_NETPORT_HASH_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * sel_netport_hashfn - Hashing function for the port table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * @pnum: port number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * This is the hashing function for the port table, it returns the bucket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  * number for the given port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) static unsigned int sel_netport_hashfn(u16 pnum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	return (pnum & (SEL_NETPORT_HASH_SIZE - 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * sel_netport_find - Search for a port record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * @protocol: protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * @port: pnum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * Search the network port table and return the matching record.  If an entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * can not be found in the table return NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static struct sel_netport *sel_netport_find(u8 protocol, u16 pnum)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	unsigned int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct sel_netport *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	idx = sel_netport_hashfn(pnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	list_for_each_entry_rcu(port, &sel_netport_hash[idx].list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		if (port->psec.port == pnum && port->psec.protocol == protocol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			return port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * sel_netport_insert - Insert a new port into the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  * @port: the new port record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  * Add a new port record to the network address hash table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static void sel_netport_insert(struct sel_netport *port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	unsigned int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	/* we need to impose a limit on the growth of the hash table so check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	 * this bucket to make sure it is within the specified bounds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	idx = sel_netport_hashfn(port->psec.port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	list_add_rcu(&port->list, &sel_netport_hash[idx].list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if (sel_netport_hash[idx].size == SEL_NETPORT_HASH_BKT_LIMIT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		struct sel_netport *tail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		tail = list_entry(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			rcu_dereference_protected(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 				sel_netport_hash[idx].list.prev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 				lockdep_is_held(&sel_netport_lock)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			struct sel_netport, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		list_del_rcu(&tail->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		kfree_rcu(tail, rcu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		sel_netport_hash[idx].size++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * sel_netport_sid_slow - Lookup the SID of a network address using the policy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * @protocol: protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  * @pnum: port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  * @sid: port SID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  * This function determines the SID of a network port by querying the security
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * policy.  The result is added to the network port table to speedup future
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  * queries.  Returns zero on success, negative values on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) static int sel_netport_sid_slow(u8 protocol, u16 pnum, u32 *sid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	struct sel_netport *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	struct sel_netport *new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	spin_lock_bh(&sel_netport_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	port = sel_netport_find(protocol, pnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	if (port != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		*sid = port->psec.sid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		spin_unlock_bh(&sel_netport_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	ret = security_port_sid(&selinux_state, protocol, pnum, sid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	new = kzalloc(sizeof(*new), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	if (new) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		new->psec.port = pnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		new->psec.protocol = protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		new->psec.sid = *sid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		sel_netport_insert(new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	spin_unlock_bh(&sel_netport_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	if (unlikely(ret))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		pr_warn("SELinux: failure in %s(), unable to determine network port label\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 			__func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  * sel_netport_sid - Lookup the SID of a network port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  * @protocol: protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * @pnum: port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  * @sid: port SID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  * This function determines the SID of a network port using the fastest method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  * possible.  First the port table is queried, but if an entry can't be found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  * then the policy is queried and the result is added to the table to speedup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  * future queries.  Returns zero on success, negative values on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) int sel_netport_sid(u8 protocol, u16 pnum, u32 *sid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	struct sel_netport *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	port = sel_netport_find(protocol, pnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	if (port != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		*sid = port->psec.sid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	return sel_netport_sid_slow(protocol, pnum, sid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)  * sel_netport_flush - Flush the entire network port table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)  * Remove all entries from the network address table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) void sel_netport_flush(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	unsigned int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	struct sel_netport *port, *port_tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	spin_lock_bh(&sel_netport_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	for (idx = 0; idx < SEL_NETPORT_HASH_SIZE; idx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		list_for_each_entry_safe(port, port_tmp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 					 &sel_netport_hash[idx].list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 			list_del_rcu(&port->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 			kfree_rcu(port, rcu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		sel_netport_hash[idx].size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	spin_unlock_bh(&sel_netport_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) static __init int sel_netport_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	int iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	if (!selinux_enabled_boot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	for (iter = 0; iter < SEL_NETPORT_HASH_SIZE; iter++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		INIT_LIST_HEAD(&sel_netport_hash[iter].list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		sel_netport_hash[iter].size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) __initcall(sel_netport_init);