Skip to content

Commit 89d4d7c

Browse files
WOnder93pcmoore
authored andcommitted
selinux: generalize evaluate_cond_node()
Both callers iterate the cond_list and call it for each node - turn it into evaluate_cond_nodes(), which does the iteration for them. Signed-off-by: Ondrej Mosnacek <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 8794d78 commit 89d4d7c

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

security/selinux/ss/conditional.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static int cond_evaluate_expr(struct policydb *p, struct cond_expr *expr)
8686
* list appropriately. If the result of the expression is undefined
8787
* all of the rules are disabled for safety.
8888
*/
89-
void evaluate_cond_node(struct policydb *p, struct cond_node *node)
89+
static void evaluate_cond_node(struct policydb *p, struct cond_node *node)
9090
{
9191
struct avtab_node *avnode;
9292
int new_state;
@@ -117,6 +117,14 @@ void evaluate_cond_node(struct policydb *p, struct cond_node *node)
117117
}
118118
}
119119

120+
void evaluate_cond_nodes(struct policydb *p)
121+
{
122+
u32 i;
123+
124+
for (i = 0; i < p->cond_list_len; i++)
125+
evaluate_cond_node(p, &p->cond_list[i]);
126+
}
127+
120128
int cond_policydb_init(struct policydb *p)
121129
{
122130
int rc;

security/selinux/ss/conditional.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key,
7878
struct av_decision *avd, struct extended_perms *xperms);
7979
void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key,
8080
struct extended_perms_decision *xpermd);
81-
void evaluate_cond_node(struct policydb *p, struct cond_node *node);
81+
void evaluate_cond_nodes(struct policydb *p);
8282

8383
#endif /* _CONDITIONAL_H_ */

security/selinux/ss/services.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,8 +2957,7 @@ int security_set_bools(struct selinux_state *state, u32 len, int *values)
29572957
policydb->bool_val_to_struct[i]->state = 0;
29582958
}
29592959

2960-
for (i = 0; i < policydb->cond_list_len; i++)
2961-
evaluate_cond_node(policydb, &policydb->cond_list[i]);
2960+
evaluate_cond_nodes(policydb);
29622961

29632962
seqno = ++state->ss->latest_granting;
29642963
rc = 0;
@@ -3011,8 +3010,7 @@ static int security_preserve_bools(struct selinux_state *state,
30113010
if (booldatum)
30123011
booldatum->state = bvalues[i];
30133012
}
3014-
for (i = 0; i < policydb->cond_list_len; i++)
3015-
evaluate_cond_node(policydb, &policydb->cond_list[i]);
3013+
evaluate_cond_nodes(policydb);
30163014

30173015
out:
30183016
if (bnames) {

0 commit comments

Comments
 (0)