All of lore.kernel.org
 help / color / mirror / Atom feed
From: william.c.roberts@intel.com
To: selinux@tycho.nsa.gov, jwcart2@tycho.nsa.gov,
	seandroid-list@tycho.nsa.gov, sds@tycho.nsa.gov
Subject: [PATCH v2 1/5] libsepol: fix invalid access of NULL on type_val_to_struct
Date: Wed, 10 Aug 2016 15:35:56 -0700	[thread overview]
Message-ID: <1470868560-31328-1-git-send-email-william.c.roberts@intel.com> (raw)

From: William Roberts <william.c.roberts@intel.com>

In type_set_expand:
When nprim, the table index counter, is greater than the value of initizalized
entries in the type_val_to_struct[] array, detect this as invalid
and return an error.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
---
 libsepol/src/expand.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c
index 0ad57f5..e6d3ef1 100644
--- a/libsepol/src/expand.c
+++ b/libsepol/src/expand.c
@@ -2514,6 +2514,10 @@ int type_set_expand(type_set_t * set, ebitmap_t * t, policydb_t * p,
 				if (i > p->p_types.nprim - 1)
 					goto err_types;
 
+				if (!p->type_val_to_struct[i]) {
+					goto err_types;
+				}
+
 				if (p->type_val_to_struct[i]->flavor ==
 				    TYPE_ATTRIB) {
 					if (ebitmap_union
-- 
1.9.1

             reply	other threads:[~2016-08-10 22:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-10 22:35 william.c.roberts [this message]
2016-08-10 22:35 ` [PATCH v2 2/5] libsepol: ensure key is valid before doing search william.c.roberts
2016-08-10 22:35 ` [PATCH v2 3/5] ebitmap: detect invalid bitmap william.c.roberts
2016-08-10 22:35 ` [PATCH v2 4/5] genfs_read: fix use heap-use-after-free william.c.roberts
2016-08-10 22:36 ` [PATCH v2 5/5] libsepol: fix overflow and 0 length allocations william.c.roberts
2016-08-11 19:14   ` James Carter
2016-08-11 19:35     ` William Roberts
2016-08-11 21:22       ` William Roberts

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=1470868560-31328-1-git-send-email-william.c.roberts@intel.com \
    --to=william.c.roberts@intel.com \
    --cc=jwcart2@tycho.nsa.gov \
    --cc=sds@tycho.nsa.gov \
    --cc=seandroid-list@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.