mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-01 12:04:08 +00:00
selinux: fix error codes in cond_read_node()
Originally cond_read_node() returned -1 (-EPERM) on errors which was incorrect. Now it either propagates the error codes from lower level functions next_entry() or cond_read_av_list() or it returns -ENOMEM or -EINVAL. next_entry() returns -EINVAL. cond_read_av_list() returns -EINVAL or -ENOMEM. Signed-off-by: Dan Carpenter <error27@gmail.com> Acked-by: Stephen D. Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
parent
9d623b17a7
commit
fc5c126e47
1 changed files with 12 additions and 8 deletions
|
@ -392,24 +392,25 @@ static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp)
|
||||||
struct cond_expr *expr = NULL, *last = NULL;
|
struct cond_expr *expr = NULL, *last = NULL;
|
||||||
|
|
||||||
rc = next_entry(buf, fp, sizeof(u32));
|
rc = next_entry(buf, fp, sizeof(u32));
|
||||||
if (rc < 0)
|
if (rc)
|
||||||
return -1;
|
return rc;
|
||||||
|
|
||||||
node->cur_state = le32_to_cpu(buf[0]);
|
node->cur_state = le32_to_cpu(buf[0]);
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
rc = next_entry(buf, fp, sizeof(u32));
|
rc = next_entry(buf, fp, sizeof(u32));
|
||||||
if (rc < 0)
|
if (rc)
|
||||||
return -1;
|
return rc;
|
||||||
|
|
||||||
/* expr */
|
/* expr */
|
||||||
len = le32_to_cpu(buf[0]);
|
len = le32_to_cpu(buf[0]);
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
rc = next_entry(buf, fp, sizeof(u32) * 2);
|
rc = next_entry(buf, fp, sizeof(u32) * 2);
|
||||||
if (rc < 0)
|
if (rc)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
rc = -ENOMEM;
|
||||||
expr = kzalloc(sizeof(struct cond_expr), GFP_KERNEL);
|
expr = kzalloc(sizeof(struct cond_expr), GFP_KERNEL);
|
||||||
if (!expr)
|
if (!expr)
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -418,6 +419,7 @@ static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp)
|
||||||
expr->bool = le32_to_cpu(buf[1]);
|
expr->bool = le32_to_cpu(buf[1]);
|
||||||
|
|
||||||
if (!expr_isvalid(p, expr)) {
|
if (!expr_isvalid(p, expr)) {
|
||||||
|
rc = -EINVAL;
|
||||||
kfree(expr);
|
kfree(expr);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -429,14 +431,16 @@ static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp)
|
||||||
last = expr;
|
last = expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cond_read_av_list(p, fp, &node->true_list, NULL) != 0)
|
rc = cond_read_av_list(p, fp, &node->true_list, NULL);
|
||||||
|
if (rc)
|
||||||
goto err;
|
goto err;
|
||||||
if (cond_read_av_list(p, fp, &node->false_list, node->true_list) != 0)
|
rc = cond_read_av_list(p, fp, &node->false_list, node->true_list);
|
||||||
|
if (rc)
|
||||||
goto err;
|
goto err;
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
cond_node_destroy(node);
|
cond_node_destroy(node);
|
||||||
return -1;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cond_read_list(struct policydb *p, void *fp)
|
int cond_read_list(struct policydb *p, void *fp)
|
||||||
|
|
Loading…
Add table
Reference in a new issue