10 #include <linux/kernel.h>
11 #include <linux/errno.h>
12 #include <linux/string.h>
14 #include <linux/slab.h>
32 for (cur = expr;
cur; cur = cur->
next) {
67 s[
sp] = (s[
sp] == s[sp + 1]);
73 s[
sp] = (s[
sp] != s[sp + 1]);
94 new_state = cond_evaluate_expr(p, node->
expr);
98 printk(
KERN_ERR "SELinux: expression result was undefined - disabling all rules.\n");
135 for (cur = list;
cur; cur =
next) {
146 for (cur_expr = node->
expr; cur_expr; cur_expr = next_expr) {
147 next_expr = cur_expr->
next;
155 static void cond_list_destroy(
struct cond_node *list)
162 for (cur = list;
cur; cur =
next) {
164 cond_node_destroy(cur);
201 if (!booldatum->
value || booldatum->
value > p->p_bools.nprim)
232 rc = next_entry(buf, fp,
sizeof buf);
240 if (!bool_isvalid(booldatum))
249 rc = next_entry(key, fp, len);
286 printk(
KERN_ERR "SELinux: type rule already exists outside of a conditional.\n");
305 for (cur = other;
cur; cur = cur->
next) {
306 if (cur->node == node_ptr) {
318 printk(
KERN_ERR "SELinux: conflicting type rules when adding type rule for true.\n");
337 list->node = node_ptr;
346 cond_av_list_destroy(data->
head);
361 rc = next_entry(buf, fp,
sizeof(
u32));
373 for (i = 0; i < len; i++) {
380 *ret_list = data.
head;
387 printk(
KERN_ERR "SELinux: conditional expressions uses unknown operator.\n");
391 if (expr->
bool > p->p_bools.nprim) {
392 printk(
KERN_ERR "SELinux: conditional expressions uses unknown bool.\n");
405 rc = next_entry(buf, fp,
sizeof(
u32));
412 rc = next_entry(buf, fp,
sizeof(
u32));
419 for (i = 0; i < len; i++) {
420 rc = next_entry(buf, fp,
sizeof(
u32) * 2);
432 if (!expr_isvalid(p, expr)) {
453 cond_node_destroy(node);
464 rc = next_entry(buf, fp,
sizeof buf);
474 for (i = 0; i < len; i++) {
480 rc = cond_read_node(p, node, fp);
511 rc = put_entry(buf,
sizeof(
u32), 3, fp);
514 rc = put_entry(key, 1, len, fp);
529 static int cond_write_av_list(
struct policydb *p,
538 for (cur_list = list; cur_list !=
NULL; cur_list = cur_list->
next)
542 rc = put_entry(buf,
sizeof(
u32), 1, fp);
549 for (cur_list = list; cur_list !=
NULL; cur_list = cur_list->
next) {
567 rc = put_entry(buf,
sizeof(
u32), 1, fp);
571 for (cur_expr = node->
expr; cur_expr !=
NULL; cur_expr = cur_expr->
next)
575 rc = put_entry(buf,
sizeof(
u32), 1, fp);
579 for (cur_expr = node->
expr; cur_expr !=
NULL; cur_expr = cur_expr->
next) {
582 rc = put_entry(buf,
sizeof(
u32), 2, fp);
587 rc = cond_write_av_list(p, node->
true_list, fp);
590 rc = cond_write_av_list(p, node->
false_list, fp);
605 for (cur = list; cur !=
NULL; cur = cur->
next)
608 rc = put_entry(buf,
sizeof(
u32), 1, fp);
612 for (cur = list; cur !=
NULL; cur = cur->
next) {
613 rc = cond_write_node(p, cur, fp);
627 if (!ctab || !key || !avd)