public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] selinux: simple cleanup for cond_read_node()
@ 2014-06-14 16:19 Namhyung Kim
  2014-06-14 16:19 ` [PATCH 2/2] selinux: fix a possible memory leak in cond_read_node() Namhyung Kim
  2014-06-18 19:36 ` [PATCH 1/2] selinux: simple cleanup for cond_read_node() Paul Moore
  0 siblings, 2 replies; 7+ messages in thread
From: Namhyung Kim @ 2014-06-14 16:19 UTC (permalink / raw)
  To: Paul Moore, Stephen Smalley, Eric Paris; +Cc: selinux, LKML

The node->cur_state and len can be read in a single call of next_entry().
And setting len before reading is a dead write so can be eliminated.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 security/selinux/ss/conditional.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
index 377d148e7157..4766a38fae9a 100644
--- a/security/selinux/ss/conditional.c
+++ b/security/selinux/ss/conditional.c
@@ -402,19 +402,14 @@ static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp)
 	int rc;
 	struct cond_expr *expr = NULL, *last = NULL;
 
-	rc = next_entry(buf, fp, sizeof(u32));
+	rc = next_entry(buf, fp, sizeof(buf));
 	if (rc)
 		return rc;
 
 	node->cur_state = le32_to_cpu(buf[0]);
 
-	len = 0;
-	rc = next_entry(buf, fp, sizeof(u32));
-	if (rc)
-		return rc;
-
 	/* expr */
-	len = le32_to_cpu(buf[0]);
+	len = le32_to_cpu(buf[1]);
 
 	for (i = 0; i < len; i++) {
 		rc = next_entry(buf, fp, sizeof(u32) * 2);
-- 
2.0.0


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

end of thread, other threads:[~2014-06-19 18:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-14 16:19 [PATCH 1/2] selinux: simple cleanup for cond_read_node() Namhyung Kim
2014-06-14 16:19 ` [PATCH 2/2] selinux: fix a possible memory leak in cond_read_node() Namhyung Kim
2014-06-18 19:41   ` Paul Moore
2014-06-18 19:36 ` [PATCH 1/2] selinux: simple cleanup for cond_read_node() Paul Moore
2014-06-18 23:58   ` Namhyung Kim
2014-06-19 18:59     ` Paul Moore
2014-06-19 12:03   ` Stephen Smalley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox