Commit cea78dc4 authored by Eric Paris's avatar Eric Paris Committed by James Morris

SELinux: fix off by 1 reference of class_to_string in context_struct_compute_av

The class_to_string array is referenced by tclass.  My code mistakenly
was using tclass - 1.  If the proceeding class is a userspace class
rather than kernel class this may cause a denial/EINVAL even if unknown
handling is set to allow.  The bug shouldn't be allowing excess
privileges since those are given based on the contents of another array
which should be correctly referenced.

At this point in time its pretty unlikely this is going to cause
problems.  The most recently added kernel classes which could be
affected are association, dccp_socket, and peer.  Its pretty unlikely
any policy with handle_unknown=allow doesn't have association and
dccp_socket undefined (they've been around longer than unknown handling)
and peer is conditionalized on a policy cap which should only be defined
if that class exists in policy.
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
Acked-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent bdd581c1
...@@ -325,7 +325,7 @@ static int context_struct_compute_av(struct context *scontext, ...@@ -325,7 +325,7 @@ static int context_struct_compute_av(struct context *scontext,
goto inval_class; goto inval_class;
if (unlikely(tclass > policydb.p_classes.nprim)) if (unlikely(tclass > policydb.p_classes.nprim))
if (tclass > kdefs->cts_len || if (tclass > kdefs->cts_len ||
!kdefs->class_to_string[tclass - 1] || !kdefs->class_to_string[tclass] ||
!policydb.allow_unknown) !policydb.allow_unknown)
goto inval_class; goto inval_class;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment