netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][SECURITY] secmark: nul-terminate secdata
@ 2006-07-28 21:00 James Morris
  2006-07-29  1:19 ` Patrick McHardy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: James Morris @ 2006-07-28 21:00 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Stephen Smalley, Eric Paris, Patrick McHardy,
	Chris Wright

The patch below fixes a problem in the iptables SECMARK target, where the 
user-supplied 'selctx' string may not be nul-terminated.

>From initial analysis, it seems that the strlen() called from 
selinux_string_to_sid() could run until it arbitrarily finds a zero, and 
possibly cause a kernel oops before then.

The impact of this appears limited because the operation requires 
CAP_NET_ADMIN, which is essentially always root.  Also, the module is not 
yet in wide use.

Please apply.

Note: some other iptables modules which handle strings supplied from 
userspace may require a similar fix (e.g. xt_string looks suspect at first 
glance).

cc'd Chris Wright, as this patch seems like a candidate for the stable 
tree.

Signed-off-by: James Morris <jmorris@namei.org>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>

---

diff -purN -X dontdiff linux-2.6.18-rc2-mm1.o/net/netfilter/xt_SECMARK.c linux-2.6.18-rc2-mm1.w/net/netfilter/xt_SECMARK.c
--- linux-2.6.18-rc2-mm1.o/net/netfilter/xt_SECMARK.c	2006-07-28 11:01:46.000000000 -0400
+++ linux-2.6.18-rc2-mm1.w/net/netfilter/xt_SECMARK.c	2006-07-28 11:15:44.000000000 -0400
@@ -57,6 +57,8 @@ static int checkentry_selinux(struct xt_
 {
 	int err;
 	struct xt_secmark_target_selinux_info *sel = &info->u.sel;
+	
+	sel->selctx[SECMARK_SELCTX_MAX - 1] = '\0';
 
 	err = selinux_string_to_sid(sel->selctx, &sel->selsid);
 	if (err) {

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-08-02 18:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-28 21:00 [PATCH][SECURITY] secmark: nul-terminate secdata James Morris
2006-07-29  1:19 ` Patrick McHardy
2006-07-31  3:47 ` David Miller
2006-08-02 18:28 ` Chris Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).