All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libsepol: Skip duplicate filename_trans rules in state->out policy.
@ 2014-04-15 16:27 Richard Haines
  2014-04-15 16:40 ` Stephen Smalley
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Haines @ 2014-04-15 16:27 UTC (permalink / raw)
  To: selinux

The current detection of duplicate rules does not cover the state->out
policy and therefore will duplicate filename transition rules if already
present.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
---
 libsepol/src/expand.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c
index acb6906..e908fdb 100644
--- a/libsepol/src/expand.c
+++ b/libsepol/src/expand.c
@@ -1534,6 +1534,20 @@ static int expand_filename_trans(expand_state_t *state, filename_trans_rule_t *r
 				if (cur_trans)
 					continue;
 
+				/* Now check if duplicate rule in state->out policy */
+				cur_trans = state->out->filename_trans;
+
+				while (cur_trans) {
+					if (cur_trans->stype == (i + 1) &&
+					    cur_trans->ttype == (j + 1) &&
+					    cur_trans->tclass == cur_rule->tclass &&
+					    !strcmp(cur_trans->name, cur_rule->name))
+						break;
+					cur_trans = cur_trans->next;
+				}
+				if (cur_trans)
+					continue;
+
 				new_trans = malloc(sizeof(*new_trans));
 				if (!new_trans) {
 					ERR(state->handle, "Out of memory!");
-- 
1.9.0

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

end of thread, other threads:[~2014-04-15 19:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-15 16:27 [PATCH] libsepol: Skip duplicate filename_trans rules in state->out policy Richard Haines
2014-04-15 16:40 ` Stephen Smalley
2014-04-15 18:21   ` Stephen Smalley
2014-04-15 18:27     ` Eric Paris
2014-04-15 18:34       ` Stephen Smalley
2014-04-15 18:43         ` Eric Paris
2014-04-15 18:46           ` Stephen Smalley
2014-04-15 19:07           ` Stephen Smalley
2014-04-15 19:18             ` Eric Paris
2014-04-15 19:19               ` Stephen Smalley
2014-04-15 19:37                 ` Eric Paris

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.