99 * Author : Stephen Smalley, <[email protected] > 1010 */
1111
12- /* Updated: Frank Mayer <[email protected] > and Karl MacMillan <[email protected] > 13- *
14- * Added conditional policy language extensions
15- *
16- * Copyright (C) 2003 Tresys Technology, LLC
12+ /* Updated: Frank Mayer <[email protected] > and 13+ * Karl MacMillan <[email protected] > 14+ * Added conditional policy language extensions
15+ * Copyright (C) 2003 Tresys Technology, LLC
1716 *
1817 * Updated: Yuichi Nakamura <[email protected] > 19- * Tuned number of hash slots for avtab to reduce memory usage
18+ * Tuned number of hash slots for avtab to reduce memory usage
2019 */
20+
2121#ifndef _SS_AVTAB_H_
2222#define _SS_AVTAB_H_
2323
2424#include "security.h"
2525
2626struct avtab_key {
27- u16 source_type ; /* source type */
28- u16 target_type ; /* target type */
29- u16 target_class ; /* target object class */
30- #define AVTAB_ALLOWED 0x0001
31- #define AVTAB_AUDITALLOW 0x0002
32- #define AVTAB_AUDITDENY 0x0004
33- #define AVTAB_AV (AVTAB_ALLOWED | AVTAB_AUDITALLOW | AVTAB_AUDITDENY)
34- #define AVTAB_TRANSITION 0x0010
35- #define AVTAB_MEMBER 0x0020
36- #define AVTAB_CHANGE 0x0040
37- #define AVTAB_TYPE (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE)
27+ u16 source_type ; /* source type */
28+ u16 target_type ; /* target type */
29+ u16 target_class ; /* target object class */
30+ #define AVTAB_ALLOWED 0x0001
31+ #define AVTAB_AUDITALLOW 0x0002
32+ #define AVTAB_AUDITDENY 0x0004
33+ #define AVTAB_AV (AVTAB_ALLOWED | AVTAB_AUDITALLOW | AVTAB_AUDITDENY)
34+ #define AVTAB_TRANSITION 0x0010
35+ #define AVTAB_MEMBER 0x0020
36+ #define AVTAB_CHANGE 0x0040
37+ #define AVTAB_TYPE (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE)
3838/* extended permissions */
3939#define AVTAB_XPERMS_ALLOWED 0x0100
40- #define AVTAB_XPERMS_AUDITALLOW 0x0200
40+ #define AVTAB_XPERMS_AUDITALLOW 0x0200
4141#define AVTAB_XPERMS_DONTAUDIT 0x0400
42- #define AVTAB_XPERMS (AVTAB_XPERMS_ALLOWED | \
43- AVTAB_XPERMS_AUDITALLOW | \
44- AVTAB_XPERMS_DONTAUDIT)
45- #define AVTAB_ENABLED_OLD 0x80000000 /* reserved for used in cond_avtab */
46- #define AVTAB_ENABLED 0x8000 /* reserved for used in cond_avtab */
47- u16 specified ; /* what field is specified */
42+ #define AVTAB_XPERMS \
43+ (AVTAB_XPERMS_ALLOWED | AVTAB_XPERMS_AUDITALLOW | \
44+ AVTAB_XPERMS_DONTAUDIT)
45+ #define AVTAB_ENABLED_OLD 0x80000000 /* reserved for used in cond_avtab */
46+ #define AVTAB_ENABLED 0x8000 /* reserved for used in cond_avtab */
47+ u16 specified ; /* what field is specified */
4848};
4949
5050/*
@@ -53,8 +53,8 @@ struct avtab_key {
5353 */
5454struct avtab_extended_perms {
5555/* These are not flags. All 256 values may be used */
56- #define AVTAB_XPERMS_IOCTLFUNCTION 0x01
57- #define AVTAB_XPERMS_IOCTLDRIVER 0x02
56+ #define AVTAB_XPERMS_IOCTLFUNCTION 0x01
57+ #define AVTAB_XPERMS_IOCTLDRIVER 0x02
5858 /* extension of the avtab_key specified */
5959 u8 specified ; /* ioctl, netfilter, ... */
6060 /*
@@ -82,16 +82,19 @@ struct avtab_node {
8282
8383struct avtab {
8484 struct avtab_node * * htable ;
85- u32 nel ; /* number of elements */
86- u32 nslot ; /* number of hash slots */
87- u32 mask ; /* mask to compute hash func */
85+ u32 nel ; /* number of elements */
86+ u32 nslot ; /* number of hash slots */
87+ u32 mask ; /* mask to compute hash func */
8888};
8989
9090void avtab_init (struct avtab * h );
9191int avtab_alloc (struct avtab * , u32 );
9292int avtab_alloc_dup (struct avtab * new , const struct avtab * orig );
9393void avtab_destroy (struct avtab * h );
9494
95+ #define MAX_AVTAB_HASH_BITS 16
96+ #define MAX_AVTAB_HASH_BUCKETS (1 << MAX_AVTAB_HASH_BITS)
97+
9598#ifdef CONFIG_SECURITY_SELINUX_DEBUG
9699void avtab_hash_eval (struct avtab * h , const char * tag );
97100#else
@@ -107,7 +110,8 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
107110 void * p );
108111
109112int avtab_read (struct avtab * a , void * fp , struct policydb * pol );
110- int avtab_write_item (struct policydb * p , const struct avtab_node * cur , void * fp );
113+ int avtab_write_item (struct policydb * p , const struct avtab_node * cur ,
114+ void * fp );
111115int avtab_write (struct policydb * p , struct avtab * a , void * fp );
112116
113117struct avtab_node * avtab_insert_nonunique (struct avtab * h ,
@@ -116,11 +120,7 @@ struct avtab_node *avtab_insert_nonunique(struct avtab *h,
116120
117121struct avtab_node * avtab_search_node (struct avtab * h ,
118122 const struct avtab_key * key );
123+ struct avtab_node * avtab_search_node_next (struct avtab_node * node ,
124+ u16 specified );
119125
120- struct avtab_node * avtab_search_node_next (struct avtab_node * node , u16 specified );
121-
122- #define MAX_AVTAB_HASH_BITS 16
123- #define MAX_AVTAB_HASH_BUCKETS (1 << MAX_AVTAB_HASH_BITS)
124-
125- #endif /* _SS_AVTAB_H_ */
126-
126+ #endif /* _SS_AVTAB_H_ */
0 commit comments