Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 201885
b: refs/heads/master
c: 9e0bd4c
h: refs/heads/master
i:
  201883: 439ba7e
v: v3
  • Loading branch information
Dan Carpenter authored and James Morris committed Aug 2, 2010
1 parent 071b723 commit 89157ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dce3a3d2ee038d230323fe06b061dbaace6b8f94
refs/heads/master: 9e0bd4cba4460bff64fb07cfb07849cdfd4d325a
39 changes: 19 additions & 20 deletions trunk/security/selinux/ss/avtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,53 +342,53 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,

if (vers < POLICYDB_VERSION_AVTAB) {
rc = next_entry(buf32, fp, sizeof(u32));
if (rc < 0) {
if (rc) {
printk(KERN_ERR "SELinux: avtab: truncated entry\n");
return -1;
return rc;
}
items2 = le32_to_cpu(buf32[0]);
if (items2 > ARRAY_SIZE(buf32)) {
printk(KERN_ERR "SELinux: avtab: entry overflow\n");
return -1;
return -EINVAL;

}
rc = next_entry(buf32, fp, sizeof(u32)*items2);
if (rc < 0) {
if (rc) {
printk(KERN_ERR "SELinux: avtab: truncated entry\n");
return -1;
return rc;
}
items = 0;

val = le32_to_cpu(buf32[items++]);
key.source_type = (u16)val;
if (key.source_type != val) {
printk(KERN_ERR "SELinux: avtab: truncated source type\n");
return -1;
return -EINVAL;
}
val = le32_to_cpu(buf32[items++]);
key.target_type = (u16)val;
if (key.target_type != val) {
printk(KERN_ERR "SELinux: avtab: truncated target type\n");
return -1;
return -EINVAL;
}
val = le32_to_cpu(buf32[items++]);
key.target_class = (u16)val;
if (key.target_class != val) {
printk(KERN_ERR "SELinux: avtab: truncated target class\n");
return -1;
return -EINVAL;
}

val = le32_to_cpu(buf32[items++]);
enabled = (val & AVTAB_ENABLED_OLD) ? AVTAB_ENABLED : 0;

if (!(val & (AVTAB_AV | AVTAB_TYPE))) {
printk(KERN_ERR "SELinux: avtab: null entry\n");
return -1;
return -EINVAL;
}
if ((val & AVTAB_AV) &&
(val & AVTAB_TYPE)) {
printk(KERN_ERR "SELinux: avtab: entry has both access vectors and types\n");
return -1;
return -EINVAL;
}

for (i = 0; i < ARRAY_SIZE(spec_order); i++) {
Expand All @@ -403,15 +403,15 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,

if (items != items2) {
printk(KERN_ERR "SELinux: avtab: entry only had %d items, expected %d\n", items2, items);
return -1;
return -EINVAL;
}
return 0;
}

rc = next_entry(buf16, fp, sizeof(u16)*4);
if (rc < 0) {
if (rc) {
printk(KERN_ERR "SELinux: avtab: truncated entry\n");
return -1;
return rc;
}

items = 0;
Expand All @@ -424,7 +424,7 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
!policydb_type_isvalid(pol, key.target_type) ||
!policydb_class_isvalid(pol, key.target_class)) {
printk(KERN_ERR "SELinux: avtab: invalid type or class\n");
return -1;
return -EINVAL;
}

set = 0;
Expand All @@ -434,19 +434,19 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
}
if (!set || set > 1) {
printk(KERN_ERR "SELinux: avtab: more than one specifier\n");
return -1;
return -EINVAL;
}

rc = next_entry(buf32, fp, sizeof(u32));
if (rc < 0) {
if (rc) {
printk(KERN_ERR "SELinux: avtab: truncated entry\n");
return -1;
return rc;
}
datum.data = le32_to_cpu(*buf32);
if ((key.specified & AVTAB_TYPE) &&
!policydb_type_isvalid(pol, datum.data)) {
printk(KERN_ERR "SELinux: avtab: invalid type\n");
return -1;
return -EINVAL;
}
return insertf(a, &key, &datum, p);
}
Expand Down Expand Up @@ -487,8 +487,7 @@ int avtab_read(struct avtab *a, void *fp, struct policydb *pol)
printk(KERN_ERR "SELinux: avtab: out of memory\n");
else if (rc == -EEXIST)
printk(KERN_ERR "SELinux: avtab: duplicate entry\n");
else
rc = -EINVAL;

goto bad;
}
}
Expand Down

0 comments on commit 89157ca

Please sign in to comment.