Skip to contentSkip to conversation

selinux: change handling of invalid classes (Was: Re: 2.6.26-rc5-mm1 selinux whine)

PATCH Applied Stephen Smalley 3 participants 3 messages Jun 9, 2008 1 message not in the archive SELinux security module

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 selinux: change handling of invalid classes (Was: Re: 2.6.26-rc5-mm1 selinux whine)

Quoted 8 lines · Andrew Morton

Getting a few of these with FC5:

SELinux: context_struct_compute_av: unrecognized class 69
SELinux: context_struct_compute_av: unrecognized class 69

one came out when I logged in.

No other symptoms, yet.

Change handling of invalid classes by SELinux, reporting class values unknown to the kernel as errors (w/ ratelimit applied) and handling class values unknown to policy as normal denials.

---

 security/selinux/ss/services.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
security/selinux/ss/services.c +13 -3
index d06df33..b7b9baa 100644
@@ -408,9 +408,19 @@ static int context_struct_compute_av(struct context *scontext,
 	return 0;
 
 inval_class:
-	printk(KERN_ERR "SELinux: %s:  unrecognized class %d\n", __func__,
-		tclass);
-	return -EINVAL;
+	if (!tclass || tclass > kdefs->cts_len ||
+	    !kdefs->class_to_string[tclass]) {
+		if (printk_ratelimit())
+			printk(KERN_ERR "SELinux: %s:  unrecognized class %d\n",
+			       __func__, tclass);
+		return -EINVAL;
+	}
+
+	/*
+	 * Known to the kernel, but not to the policy.
+	 * Handle as a denial (allowed is 0).
+	 */
+	return 0;
 }
 
 /*
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
Acked-by on v1 1/1
#2 lore raw
Quoted 8 lines · Stephen Smalley
Quoted 7 lines · Andrew Morton

Getting a few of these with FC5:

SELinux: context_struct_compute_av: unrecognized class 69
SELinux: context_struct_compute_av: unrecognized class 69

one came out when I logged in.

Quoted 7 lines
Quoted 1 line

No other symptoms, yet.

Change handling of invalid classes by SELinux, reporting class values unknown to the kernel as errors (w/ ratelimit applied) and handling class values unknown to policy as normal denials.

Quoted 24 lines

---

 security/selinux/ss/services.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
security/selinux/ss/services.c +6 -3
index d06df33..b7b9baa 100644
@@ -408,9 +408,19 @@ static int context_struct_compute_av(struct context *scontext,
 	return 0;
 
 inval_class:
-	printk(KERN_ERR "SELinux: %s:  unrecognized class %d\n", __func__,
-		tclass);
-	return -EINVAL;
+	if (!tclass || tclass > kdefs->cts_len ||
+	    !kdefs->class_to_string[tclass]) {
+		if (printk_ratelimit())
+			printk(KERN_ERR "SELinux: %s:  unrecognized class %d\n",
+			       __func__, tclass);
+		return -EINVAL;

security/selinux/ss/services.c static int context_struct_compute_av(struct context *scontext, · line 426

Quoted 10 lines
security/selinux/ss/services.c +7 -0
+	}
+
+	/*
+	 * Known to the kernel, but not to the policy.
+	 * Handle as a denial (allowed is 0).
+	 */
+	return 0;
 }
 
 /*

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.