Skip to content

Commit

Permalink
selinux: genheaders should fail if too many permissions are defined
Browse files Browse the repository at this point in the history
Ensure that genheaders fails with an error if too many permissions
are defined in a class to fit within an access vector. This is similar
to a check performed by checkpolicy when compiling the policy.

Also, fix the suffix on the permission constants generated by this program.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <paul@paul-moore.com>
  • Loading branch information
Stephen Smalley authored and Paul Moore committed Jul 31, 2017
1 parent cd0d877 commit 20a8d62
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/selinux/genheaders/genheaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,16 @@ int main(int argc, char *argv[])
for (i = 0; secclass_map[i].name; i++) {
struct security_class_mapping *map = &secclass_map[i];
for (j = 0; map->perms[j]; j++) {
if (j >= 32) {
fprintf(stderr, "Too many permissions to fit into an access vector at (%s, %s).\n",
map->name, map->perms[j]);
exit(5);
}
fprintf(fout, "#define %s__%s", map->name,
map->perms[j]);
for (k = 0; k < max(1, 40 - strlen(map->name) - strlen(map->perms[j])); k++)
fprintf(fout, " ");
fprintf(fout, "0x%08xUL\n", (1<<j));
fprintf(fout, "0x%08xU\n", (1<<j));
}
}

Expand Down

0 comments on commit 20a8d62

Please sign in to comment.