netlabel.h (701a90bad99b8081a824cca52c178c8fc8f46bb2) netlabel.h (02752760359db6b00a3ffb1acfc13ef8d9eb1e3f)
1/*
2 * NetLabel System
3 *
4 * The NetLabel system manages static and dynamic label mappings for network
5 * protocols such as CIPSO and RIPSO.
6 *
7 * Author: Paul Moore <paul.moore@hp.com>
8 *

--- 97 unchanged lines hidden (view full) ---

106int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info);
107
108/* LSM security attributes */
109struct netlbl_lsm_cache {
110 atomic_t refcount;
111 void (*free) (const void *data);
112 void *data;
113};
1/*
2 * NetLabel System
3 *
4 * The NetLabel system manages static and dynamic label mappings for network
5 * protocols such as CIPSO and RIPSO.
6 *
7 * Author: Paul Moore <paul.moore@hp.com>
8 *

--- 97 unchanged lines hidden (view full) ---

106int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info);
107
108/* LSM security attributes */
109struct netlbl_lsm_cache {
110 atomic_t refcount;
111 void (*free) (const void *data);
112 void *data;
113};
114/* The catmap bitmap field MUST be a power of two in length and large
115 * enough to hold at least 240 bits. Special care (i.e. check the code!)
116 * should be used when changing these values as the LSM implementation
117 * probably has functions which rely on the sizes of these types to speed
118 * processing. */
119#define NETLBL_CATMAP_MAPTYPE u64
120#define NETLBL_CATMAP_MAPCNT 4
121#define NETLBL_CATMAP_MAPSIZE (sizeof(NETLBL_CATMAP_MAPTYPE) * 8)
122#define NETLBL_CATMAP_SIZE (NETLBL_CATMAP_MAPSIZE * \
123 NETLBL_CATMAP_MAPCNT)
124#define NETLBL_CATMAP_BIT (NETLBL_CATMAP_MAPTYPE)0x01
125struct netlbl_lsm_secattr_catmap {
126 u32 startbit;
127 NETLBL_CATMAP_MAPTYPE bitmap[NETLBL_CATMAP_MAPCNT];
128 struct netlbl_lsm_secattr_catmap *next;
129};
114#define NETLBL_SECATTR_NONE 0x00000000
115#define NETLBL_SECATTR_DOMAIN 0x00000001
116#define NETLBL_SECATTR_CACHE 0x00000002
117#define NETLBL_SECATTR_MLS_LVL 0x00000004
118#define NETLBL_SECATTR_MLS_CAT 0x00000008
119struct netlbl_lsm_secattr {
120 u32 flags;
121
122 char *domain;
123
124 u32 mls_lvl;
130#define NETLBL_SECATTR_NONE 0x00000000
131#define NETLBL_SECATTR_DOMAIN 0x00000001
132#define NETLBL_SECATTR_CACHE 0x00000002
133#define NETLBL_SECATTR_MLS_LVL 0x00000004
134#define NETLBL_SECATTR_MLS_CAT 0x00000008
135struct netlbl_lsm_secattr {
136 u32 flags;
137
138 char *domain;
139
140 u32 mls_lvl;
125 unsigned char *mls_cat;
126 size_t mls_cat_len;
141 struct netlbl_lsm_secattr_catmap *mls_cat;
127
128 struct netlbl_lsm_cache *cache;
129};
130
131/*
132 * LSM security attribute operations
133 */
134

--- 31 unchanged lines hidden (view full) ---

166 return;
167
168 if (cache->free)
169 cache->free(cache->data);
170 kfree(cache);
171}
172
173/**
142
143 struct netlbl_lsm_cache *cache;
144};
145
146/*
147 * LSM security attribute operations
148 */
149

--- 31 unchanged lines hidden (view full) ---

181 return;
182
183 if (cache->free)
184 cache->free(cache->data);
185 kfree(cache);
186}
187
188/**
189 * netlbl_secattr_catmap_alloc - Allocate a LSM secattr catmap
190 * @flags: memory allocation flags
191 *
192 * Description:
193 * Allocate memory for a LSM secattr catmap, returns a pointer on success, NULL
194 * on failure.
195 *
196 */
197static inline struct netlbl_lsm_secattr_catmap *netlbl_secattr_catmap_alloc(
198 gfp_t flags)
199{
200 return kzalloc(sizeof(struct netlbl_lsm_secattr_catmap), flags);
201}
202
203/**
204 * netlbl_secattr_catmap_free - Free a LSM secattr catmap
205 * @catmap: the category bitmap
206 *
207 * Description:
208 * Free a LSM secattr catmap.
209 *
210 */
211static inline void netlbl_secattr_catmap_free(
212 struct netlbl_lsm_secattr_catmap *catmap)
213{
214 struct netlbl_lsm_secattr_catmap *iter;
215
216 do {
217 iter = catmap;
218 catmap = catmap->next;
219 kfree(iter);
220 } while (catmap);
221}
222
223/**
174 * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct
175 * @secattr: the struct to initialize
176 *
177 * Description:
178 * Initialize an already allocated netlbl_lsm_secattr struct.
179 *
180 */
181static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)

--- 13 unchanged lines hidden (view full) ---

195 * The struct must be reset with a call to netlbl_secattr_init() before reuse.
196 *
197 */
198static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
199{
200 if (secattr->cache)
201 netlbl_secattr_cache_free(secattr->cache);
202 kfree(secattr->domain);
224 * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct
225 * @secattr: the struct to initialize
226 *
227 * Description:
228 * Initialize an already allocated netlbl_lsm_secattr struct.
229 *
230 */
231static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)

--- 13 unchanged lines hidden (view full) ---

245 * The struct must be reset with a call to netlbl_secattr_init() before reuse.
246 *
247 */
248static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
249{
250 if (secattr->cache)
251 netlbl_secattr_cache_free(secattr->cache);
252 kfree(secattr->domain);
203 kfree(secattr->mls_cat);
253 if (secattr->mls_cat)
254 netlbl_secattr_catmap_free(secattr->mls_cat);
204}
205
206/**
207 * netlbl_secattr_alloc - Allocate and initialize a netlbl_lsm_secattr struct
208 * @flags: the memory allocation flags
209 *
210 * Description:
211 * Allocate and initialize a netlbl_lsm_secattr struct. Returns a valid

--- 14 unchanged lines hidden (view full) ---

226 *
227 */
228static inline void netlbl_secattr_free(struct netlbl_lsm_secattr *secattr)
229{
230 netlbl_secattr_destroy(secattr);
231 kfree(secattr);
232}
233
255}
256
257/**
258 * netlbl_secattr_alloc - Allocate and initialize a netlbl_lsm_secattr struct
259 * @flags: the memory allocation flags
260 *
261 * Description:
262 * Allocate and initialize a netlbl_lsm_secattr struct. Returns a valid

--- 14 unchanged lines hidden (view full) ---

277 *
278 */
279static inline void netlbl_secattr_free(struct netlbl_lsm_secattr *secattr)
280{
281 netlbl_secattr_destroy(secattr);
282 kfree(secattr);
283}
284
285#ifdef CONFIG_NETLABEL
286int netlbl_secattr_catmap_walk(struct netlbl_lsm_secattr_catmap *catmap,
287 u32 offset);
288int netlbl_secattr_catmap_walk_rng(struct netlbl_lsm_secattr_catmap *catmap,
289 u32 offset);
290int netlbl_secattr_catmap_setbit(struct netlbl_lsm_secattr_catmap *catmap,
291 u32 bit,
292 gfp_t flags);
293int netlbl_secattr_catmap_setrng(struct netlbl_lsm_secattr_catmap *catmap,
294 u32 start,
295 u32 end,
296 gfp_t flags);
297#else
298static inline int netlbl_secattr_catmap_walk(
299 struct netlbl_lsm_secattr_catmap *catmap,
300 u32 offset)
301{
302 return -ENOENT;
303}
304
305static inline int netlbl_secattr_catmap_walk_rng(
306 struct netlbl_lsm_secattr_catmap *catmap,
307 u32 offset)
308{
309 return -ENOENT;
310}
311
312static inline int netlbl_secattr_catmap_setbit(
313 struct netlbl_lsm_secattr_catmap *catmap,
314 u32 bit,
315 gfp_t flags)
316{
317 return 0;
318}
319
320static inline int netlbl_secattr_catmap_setrng(
321 struct netlbl_lsm_secattr_catmap *catmap,
322 u32 start,
323 u32 end,
324 gfp_t flags)
325{
326 return 0;
327}
328#endif
329
234/*
235 * LSM protocol operations
236 */
237
238#ifdef CONFIG_NETLABEL
239int netlbl_socket_setattr(const struct socket *sock,
240 const struct netlbl_lsm_secattr *secattr);
241int netlbl_sock_getattr(struct sock *sk,

--- 59 unchanged lines hidden ---
330/*
331 * LSM protocol operations
332 */
333
334#ifdef CONFIG_NETLABEL
335int netlbl_socket_setattr(const struct socket *sock,
336 const struct netlbl_lsm_secattr *secattr);
337int netlbl_sock_getattr(struct sock *sk,

--- 59 unchanged lines hidden ---