All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul Moore" <paul.moore@hp.com>
To: selinux@tycho.nsa.gov
Cc: sds@tycho.nsa.gov, jmorris@namei.org, Paul Moore <paul.moore@hp.com>
Subject: [RFC 2/4] NetLabel: convert a BUG_ON in the CIPSO code to a runtime check
Date: Wed, 28 Feb 2007 15:14:21 -0500	[thread overview]
Message-ID: <20070228202031.473078320@hp.com> (raw)
In-Reply-To: 20070228201419.115784233@hp.com

This patch changes a BUG_ON in the CIPSO code to a runtime check.  It should
also increase the readability of the code as it replaces an unexplained
constant with a well defined macro.

Signed-off-by: Paul Moore <paul.moore@hp.com>
---
 net/ipv4/cipso_ipv4.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: net-2.6_future/net/ipv4/cipso_ipv4.c
===================================================================
--- net-2.6_future.orig/net/ipv4/cipso_ipv4.c
+++ net-2.6_future/net/ipv4/cipso_ipv4.c
@@ -1141,7 +1141,9 @@ static int cipso_v4_map_cat_rng_hton(con
 	u32 cat_size = 0;
 
 	/* make sure we don't overflow the 'array[]' variable */
-	BUG_ON(net_cat_len > 30);
+	if (net_cat_len >
+	    (CIPSO_V4_OPT_LEN_MAX - CIPSO_V4_HDR_LEN - CIPSO_V4_TAG_RNG_BLEN))
+		return -ENOSPC;
 
 	for (;;) {
 		iter = netlbl_secattr_catmap_walk(secattr->mls_cat, iter + 1);

--
paul moore
linux security @ hp

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  parent reply	other threads:[~2007-02-28 20:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-28 20:14 [RFC 0/4] NetLabel fixups/cleanups Paul Moore
2007-02-28 20:14 ` [RFC 1/4] NetLabel: cleanup and document CIPSO constants Paul Moore
2007-02-28 20:14 ` Paul Moore [this message]
2007-02-28 20:14 ` [RFC 3/4] SELinux: extract the NetLabel SELinux support from the security server Paul Moore
2007-03-01 12:40   ` Stephen Smalley
2007-03-01 12:52     ` Stephen Smalley
2007-03-01 13:27       ` Paul Moore
2007-02-28 20:14 ` [RFC 4/4] SELinux: rename selinux_netlabel.h to netlabel.h Paul Moore
2007-02-28 21:09 ` [RFC 0/4] NetLabel fixups/cleanups James Morris
2007-02-28 21:36   ` Paul Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070228202031.473078320@hp.com \
    --to=paul.moore@hp.com \
    --cc=jmorris@namei.org \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.