7
7
*
8
8
* Copyright (C) 2018 Red Hat, Inc.
9
9
*/
10
+
10
11
#include <linux/errno.h>
11
12
#include <linux/kernel.h>
12
13
#include <linux/list.h>
@@ -29,7 +30,7 @@ struct sidtab_str_cache {
29
30
};
30
31
31
32
#define index_to_sid (index ) ((index) + SECINITSID_NUM + 1)
32
- #define sid_to_index (sid ) ((sid) - (SECINITSID_NUM + 1))
33
+ #define sid_to_index (sid ) ((sid) - (SECINITSID_NUM + 1))
33
34
34
35
int sidtab_init (struct sidtab * s )
35
36
{
@@ -140,9 +141,11 @@ int sidtab_hash_stats(struct sidtab *sidtab, char *page)
140
141
if (chain_len > max_chain_len )
141
142
max_chain_len = chain_len ;
142
143
143
- return scnprintf (page , PAGE_SIZE , "entries: %d\nbuckets used: %d/%d\n"
144
- "longest chain: %d\n" , entries ,
145
- slots_used , SIDTAB_HASH_BUCKETS , max_chain_len );
144
+ return scnprintf (page , PAGE_SIZE ,
145
+ "entries: %d\nbuckets used: %d/%d\n"
146
+ "longest chain: %d\n" ,
147
+ entries , slots_used , SIDTAB_HASH_BUCKETS ,
148
+ max_chain_len );
146
149
}
147
150
148
151
static u32 sidtab_level_from_count (u32 count )
@@ -162,15 +165,15 @@ static int sidtab_alloc_roots(struct sidtab *s, u32 level)
162
165
u32 l ;
163
166
164
167
if (!s -> roots [0 ].ptr_leaf ) {
165
- s -> roots [0 ].ptr_leaf = kzalloc ( SIDTAB_NODE_ALLOC_SIZE ,
166
- GFP_ATOMIC );
168
+ s -> roots [0 ].ptr_leaf =
169
+ kzalloc ( SIDTAB_NODE_ALLOC_SIZE , GFP_ATOMIC );
167
170
if (!s -> roots [0 ].ptr_leaf )
168
171
return - ENOMEM ;
169
172
}
170
173
for (l = 1 ; l <= level ; ++ l )
171
174
if (!s -> roots [l ].ptr_inner ) {
172
- s -> roots [l ].ptr_inner = kzalloc ( SIDTAB_NODE_ALLOC_SIZE ,
173
- GFP_ATOMIC );
175
+ s -> roots [l ].ptr_inner =
176
+ kzalloc ( SIDTAB_NODE_ALLOC_SIZE , GFP_ATOMIC );
174
177
if (!s -> roots [l ].ptr_inner )
175
178
return - ENOMEM ;
176
179
s -> roots [l ].ptr_inner -> entries [0 ] = s -> roots [l - 1 ];
@@ -203,16 +206,16 @@ static struct sidtab_entry *sidtab_do_lookup(struct sidtab *s, u32 index,
203
206
204
207
if (!entry -> ptr_inner ) {
205
208
if (alloc )
206
- entry -> ptr_inner = kzalloc (SIDTAB_NODE_ALLOC_SIZE ,
207
- GFP_ATOMIC );
209
+ entry -> ptr_inner = kzalloc (
210
+ SIDTAB_NODE_ALLOC_SIZE , GFP_ATOMIC );
208
211
if (!entry -> ptr_inner )
209
212
return NULL ;
210
213
}
211
214
}
212
215
if (!entry -> ptr_leaf ) {
213
216
if (alloc )
214
- entry -> ptr_leaf = kzalloc ( SIDTAB_NODE_ALLOC_SIZE ,
215
- GFP_ATOMIC );
217
+ entry -> ptr_leaf =
218
+ kzalloc ( SIDTAB_NODE_ALLOC_SIZE , GFP_ATOMIC );
216
219
if (!entry -> ptr_leaf )
217
220
return NULL ;
218
221
}
@@ -262,8 +265,7 @@ struct sidtab_entry *sidtab_search_entry_force(struct sidtab *s, u32 sid)
262
265
return sidtab_search_core (s , sid , 1 );
263
266
}
264
267
265
- int sidtab_context_to_sid (struct sidtab * s , struct context * context ,
266
- u32 * sid )
268
+ int sidtab_context_to_sid (struct sidtab * s , struct context * context , u32 * sid )
267
269
{
268
270
unsigned long flags ;
269
271
u32 count , hash = context_compute_hash (context );
@@ -327,8 +329,8 @@ int sidtab_context_to_sid(struct sidtab *s, struct context *context,
327
329
goto out_unlock ;
328
330
}
329
331
330
- rc = services_convert_context (convert -> args ,
331
- context , & dst_convert -> context ,
332
+ rc = services_convert_context (convert -> args , context ,
333
+ & dst_convert -> context ,
332
334
GFP_ATOMIC );
333
335
if (rc ) {
334
336
context_destroy (& dst -> context );
@@ -338,8 +340,8 @@ int sidtab_context_to_sid(struct sidtab *s, struct context *context,
338
340
dst_convert -> hash = context_compute_hash (& dst_convert -> context );
339
341
target -> count = count + 1 ;
340
342
341
- hash_add_rcu (target -> context_to_sid ,
342
- & dst_convert -> list , dst_convert -> hash );
343
+ hash_add_rcu (target -> context_to_sid , & dst_convert -> list ,
344
+ dst_convert -> hash );
343
345
}
344
346
345
347
if (context -> len )
@@ -373,17 +375,17 @@ static void sidtab_convert_hashtable(struct sidtab *s, u32 count)
373
375
}
374
376
375
377
static int sidtab_convert_tree (union sidtab_entry_inner * edst ,
376
- union sidtab_entry_inner * esrc ,
377
- u32 * pos , u32 count , u32 level ,
378
+ union sidtab_entry_inner * esrc , u32 * pos ,
379
+ u32 count , u32 level ,
378
380
struct sidtab_convert_params * convert )
379
381
{
380
382
int rc ;
381
383
u32 i ;
382
384
383
385
if (level != 0 ) {
384
386
if (!edst -> ptr_inner ) {
385
- edst -> ptr_inner = kzalloc ( SIDTAB_NODE_ALLOC_SIZE ,
386
- GFP_KERNEL );
387
+ edst -> ptr_inner =
388
+ kzalloc ( SIDTAB_NODE_ALLOC_SIZE , GFP_KERNEL );
387
389
if (!edst -> ptr_inner )
388
390
return - ENOMEM ;
389
391
}
@@ -399,17 +401,18 @@ static int sidtab_convert_tree(union sidtab_entry_inner *edst,
399
401
}
400
402
} else {
401
403
if (!edst -> ptr_leaf ) {
402
- edst -> ptr_leaf = kzalloc ( SIDTAB_NODE_ALLOC_SIZE ,
403
- GFP_KERNEL );
404
+ edst -> ptr_leaf =
405
+ kzalloc ( SIDTAB_NODE_ALLOC_SIZE , GFP_KERNEL );
404
406
if (!edst -> ptr_leaf )
405
407
return - ENOMEM ;
406
408
}
407
409
i = 0 ;
408
410
while (i < SIDTAB_LEAF_ENTRIES && * pos < count ) {
409
- rc = services_convert_context (convert -> args ,
410
- & esrc -> ptr_leaf -> entries [i ].context ,
411
- & edst -> ptr_leaf -> entries [i ].context ,
412
- GFP_KERNEL );
411
+ rc = services_convert_context (
412
+ convert -> args ,
413
+ & esrc -> ptr_leaf -> entries [i ].context ,
414
+ & edst -> ptr_leaf -> entries [i ].context ,
415
+ GFP_KERNEL );
413
416
if (rc )
414
417
return rc ;
415
418
(* pos )++ ;
@@ -489,13 +492,15 @@ void sidtab_cancel_convert(struct sidtab *s)
489
492
spin_unlock_irqrestore (& s -> lock , flags );
490
493
}
491
494
492
- void sidtab_freeze_begin (struct sidtab * s , unsigned long * flags ) __acquires (& s - > lock )
495
+ void sidtab_freeze_begin (struct sidtab * s , unsigned long * flags )
496
+ __acquires (& s - > lock )
493
497
{
494
498
spin_lock_irqsave (& s -> lock , * flags );
495
499
s -> frozen = true;
496
500
s -> convert = NULL ;
497
501
}
498
- void sidtab_freeze_end (struct sidtab * s , unsigned long * flags ) __releases (& s - > lock )
502
+ void sidtab_freeze_end (struct sidtab * s , unsigned long * flags )
503
+ __releases (& s - > lock )
499
504
{
500
505
spin_unlock_irqrestore (& s -> lock , * flags );
501
506
}
@@ -600,8 +605,8 @@ void sidtab_sid2str_put(struct sidtab *s, struct sidtab_entry *entry,
600
605
kfree_rcu (victim , rcu_member );
601
606
}
602
607
603
- int sidtab_sid2str_get (struct sidtab * s , struct sidtab_entry * entry ,
604
- char * * out , u32 * out_len )
608
+ int sidtab_sid2str_get (struct sidtab * s , struct sidtab_entry * entry , char * * out ,
609
+ u32 * out_len )
605
610
{
606
611
struct sidtab_str_cache * cache ;
607
612
int rc = 0 ;
0 commit comments