1
- // SPDX-License-Identifier: GPL-2.0-only
1
+ /* SPDX-License-Identifier: GPL-2.0-only */
2
2
/* Authors: Karl MacMillan <kmacmillan@tresys.com>
3
3
* Frank Mayer <mayerf@tresys.com>
4
- *
5
- * Copyright (C) 2003 - 2004 Tresys Technology, LLC
4
+ * Copyright (C) 2003 - 2004 Tresys Technology, LLC
6
5
*/
7
6
8
7
#include <linux/kernel.h>
@@ -166,9 +165,8 @@ void cond_policydb_destroy(struct policydb *p)
166
165
int cond_init_bool_indexes (struct policydb * p )
167
166
{
168
167
kfree (p -> bool_val_to_struct );
169
- p -> bool_val_to_struct = kmalloc_array (p -> p_bools .nprim ,
170
- sizeof (* p -> bool_val_to_struct ),
171
- GFP_KERNEL );
168
+ p -> bool_val_to_struct = kmalloc_array (
169
+ p -> p_bools .nprim , sizeof (* p -> bool_val_to_struct ), GFP_KERNEL );
172
170
if (!p -> bool_val_to_struct )
173
171
return - ENOMEM ;
174
172
return 0 ;
@@ -287,7 +285,8 @@ static int cond_insertf(struct avtab *a, const struct avtab_key *k,
287
285
if (other ) {
288
286
node_ptr = avtab_search_node (& p -> te_cond_avtab , k );
289
287
if (node_ptr ) {
290
- if (avtab_search_node_next (node_ptr , k -> specified )) {
288
+ if (avtab_search_node_next (node_ptr ,
289
+ k -> specified )) {
291
290
pr_err ("SELinux: too many conflicting type rules.\n" );
292
291
return - EINVAL ;
293
292
}
@@ -478,8 +477,8 @@ int cond_write_bool(void *vkey, void *datum, void *ptr)
478
477
* the conditional. This means that the avtab with the conditional
479
478
* rules will not be saved but will be rebuilt on policy load.
480
479
*/
481
- static int cond_write_av_list (struct policydb * p ,
482
- struct cond_av_list * list , struct policy_file * fp )
480
+ static int cond_write_av_list (struct policydb * p , struct cond_av_list * list ,
481
+ struct policy_file * fp )
483
482
{
484
483
__le32 buf [1 ];
485
484
u32 i ;
@@ -500,7 +499,7 @@ static int cond_write_av_list(struct policydb *p,
500
499
}
501
500
502
501
static int cond_write_node (struct policydb * p , struct cond_node * node ,
503
- struct policy_file * fp )
502
+ struct policy_file * fp )
504
503
{
505
504
__le32 buf [2 ];
506
505
int rc ;
@@ -555,15 +554,15 @@ int cond_write_list(struct policydb *p, void *fp)
555
554
}
556
555
557
556
void cond_compute_xperms (struct avtab * ctab , struct avtab_key * key ,
558
- struct extended_perms_decision * xpermd )
557
+ struct extended_perms_decision * xpermd )
559
558
{
560
559
struct avtab_node * node ;
561
560
562
561
if (!ctab || !key || !xpermd )
563
562
return ;
564
563
565
564
for (node = avtab_search_node (ctab , key ); node ;
566
- node = avtab_search_node_next (node , key -> specified )) {
565
+ node = avtab_search_node_next (node , key -> specified )) {
567
566
if (node -> key .specified & AVTAB_ENABLED )
568
567
services_compute_xperms_decision (xpermd , node );
569
568
}
@@ -572,38 +571,37 @@ void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key,
572
571
* av table, and if so, add them to the result
573
572
*/
574
573
void cond_compute_av (struct avtab * ctab , struct avtab_key * key ,
575
- struct av_decision * avd , struct extended_perms * xperms )
574
+ struct av_decision * avd , struct extended_perms * xperms )
576
575
{
577
576
struct avtab_node * node ;
578
577
579
578
if (!ctab || !key || !avd )
580
579
return ;
581
580
582
581
for (node = avtab_search_node (ctab , key ); node ;
583
- node = avtab_search_node_next (node , key -> specified )) {
584
- if ((u16 )(AVTAB_ALLOWED | AVTAB_ENABLED ) ==
585
- (node -> key .specified & (AVTAB_ALLOWED | AVTAB_ENABLED )))
582
+ node = avtab_search_node_next (node , key -> specified )) {
583
+ if ((u16 )(AVTAB_ALLOWED | AVTAB_ENABLED ) ==
584
+ (node -> key .specified & (AVTAB_ALLOWED | AVTAB_ENABLED )))
586
585
avd -> allowed |= node -> datum .u .data ;
587
- if ((u16 )(AVTAB_AUDITDENY | AVTAB_ENABLED ) ==
588
- (node -> key .specified & (AVTAB_AUDITDENY | AVTAB_ENABLED )))
586
+ if ((u16 )(AVTAB_AUDITDENY | AVTAB_ENABLED ) ==
587
+ (node -> key .specified & (AVTAB_AUDITDENY | AVTAB_ENABLED )))
589
588
/* Since a '0' in an auditdeny mask represents a
590
589
* permission we do NOT want to audit (dontaudit), we use
591
590
* the '&' operand to ensure that all '0's in the mask
592
591
* are retained (much unlike the allow and auditallow cases).
593
592
*/
594
593
avd -> auditdeny &= node -> datum .u .data ;
595
- if ((u16 )(AVTAB_AUDITALLOW | AVTAB_ENABLED ) ==
596
- (node -> key .specified & (AVTAB_AUDITALLOW | AVTAB_ENABLED )))
594
+ if ((u16 )(AVTAB_AUDITALLOW | AVTAB_ENABLED ) ==
595
+ (node -> key .specified & (AVTAB_AUDITALLOW | AVTAB_ENABLED )))
597
596
avd -> auditallow |= node -> datum .u .data ;
598
597
if (xperms && (node -> key .specified & AVTAB_ENABLED ) &&
599
- (node -> key .specified & AVTAB_XPERMS ))
598
+ (node -> key .specified & AVTAB_XPERMS ))
600
599
services_compute_xperms_drivers (xperms , node );
601
600
}
602
601
}
603
602
604
- static int cond_dup_av_list (struct cond_av_list * new ,
605
- struct cond_av_list * orig ,
606
- struct avtab * avtab )
603
+ static int cond_dup_av_list (struct cond_av_list * new , struct cond_av_list * orig ,
604
+ struct avtab * avtab )
607
605
{
608
606
u32 i ;
609
607
@@ -614,9 +612,8 @@ static int cond_dup_av_list(struct cond_av_list *new,
614
612
return - ENOMEM ;
615
613
616
614
for (i = 0 ; i < orig -> len ; i ++ ) {
617
- new -> nodes [i ] = avtab_insert_nonunique (avtab ,
618
- & orig -> nodes [i ]-> key ,
619
- & orig -> nodes [i ]-> datum );
615
+ new -> nodes [i ] = avtab_insert_nonunique (
616
+ avtab , & orig -> nodes [i ]-> key , & orig -> nodes [i ]-> datum );
620
617
if (!new -> nodes [i ])
621
618
return - ENOMEM ;
622
619
new -> len ++ ;
@@ -637,8 +634,7 @@ static int duplicate_policydb_cond_list(struct policydb *newp,
637
634
638
635
newp -> cond_list_len = 0 ;
639
636
newp -> cond_list = kcalloc (origp -> cond_list_len ,
640
- sizeof (* newp -> cond_list ),
641
- GFP_KERNEL );
637
+ sizeof (* newp -> cond_list ), GFP_KERNEL );
642
638
if (!newp -> cond_list )
643
639
goto error ;
644
640
@@ -649,7 +645,8 @@ static int duplicate_policydb_cond_list(struct policydb *newp,
649
645
newp -> cond_list_len ++ ;
650
646
651
647
newn -> cur_state = orign -> cur_state ;
652
- newn -> expr .nodes = kmemdup (orign -> expr .nodes ,
648
+ newn -> expr .nodes =
649
+ kmemdup (orign -> expr .nodes ,
653
650
orign -> expr .len * sizeof (* orign -> expr .nodes ),
654
651
GFP_KERNEL );
655
652
if (!newn -> expr .nodes )
@@ -658,12 +655,12 @@ static int duplicate_policydb_cond_list(struct policydb *newp,
658
655
newn -> expr .len = orign -> expr .len ;
659
656
660
657
rc = cond_dup_av_list (& newn -> true_list , & orign -> true_list ,
661
- & newp -> te_cond_avtab );
658
+ & newp -> te_cond_avtab );
662
659
if (rc )
663
660
goto error ;
664
661
665
662
rc = cond_dup_av_list (& newn -> false_list , & orign -> false_list ,
666
- & newp -> te_cond_avtab );
663
+ & newp -> te_cond_avtab );
667
664
if (rc )
668
665
goto error ;
669
666
}
@@ -683,7 +680,8 @@ static int cond_bools_destroy(void *key, void *datum, void *args)
683
680
return 0 ;
684
681
}
685
682
686
- static int cond_bools_copy (struct hashtab_node * new , struct hashtab_node * orig , void * args )
683
+ static int cond_bools_copy (struct hashtab_node * new , struct hashtab_node * orig ,
684
+ void * args )
687
685
{
688
686
struct cond_bool_datum * datum ;
689
687
@@ -709,7 +707,7 @@ static int cond_bools_index(void *key, void *datum, void *args)
709
707
}
710
708
711
709
static int duplicate_policydb_bools (struct policydb * newdb ,
712
- struct policydb * orig )
710
+ struct policydb * orig )
713
711
{
714
712
struct cond_bool_datum * * cond_bool_array ;
715
713
int rc ;
@@ -721,7 +719,7 @@ static int duplicate_policydb_bools(struct policydb *newdb,
721
719
return - ENOMEM ;
722
720
723
721
rc = hashtab_duplicate (& newdb -> p_bools .table , & orig -> p_bools .table ,
724
- cond_bools_copy , cond_bools_destroy , NULL );
722
+ cond_bools_copy , cond_bools_destroy , NULL );
725
723
if (rc ) {
726
724
kfree (cond_bool_array );
727
725
return - ENOMEM ;
0 commit comments