Skip to contentSkip to conversation

libsepol: free ibendport device names

PATCH In review Jan Zarsky 2 participants 2 messages Oct 23, 2017 SELinux security module

lore
Share & tools
lore

Jan Zarsky

author
#0 lore raw

PATCH 1/1 libsepol: free ibendport device names

When reading policy, ibendport device names are allocated in ocontext_read_selinux() but they are not freed when calling sepol_policydb_free();

Fix this by freeing them in ocontext_selinux_free().

---
 libsepol/src/policydb.c | 2 ++
 1 file changed, 2 insertions(+)
libsepol/src/policydb.c +2 -0
index 37788f36..c7521235 100644
@@ -1420,6 +1420,8 @@ void ocontext_selinux_free(ocontext_t **ocontexts)
 			if (i == OCON_ISID || i == OCON_FS || i == OCON_NETIF
 				|| i == OCON_FSUSE)
 				free(ctmp->u.name);
+			else if (i == OCON_IBENDPORT)
+				free(ctmp->u.ibendport.dev_name);
 			free(ctmp);
 		}
 	}
Signature · 1 line
2.14.2
#1 lore raw
Quoted 7 lines · Jan Zarsky

When reading policy, ibendport device names are allocated in ocontext_read_selinux() but they are not freed when calling sepol_policydb_free();

Fix this by freeing them in ocontext_selinux_free().

Thanks, this looks correct to me; I'm wondering if we have the same leak in the kernel code (I think so).

Quoted 19 lines

---
 libsepol/src/policydb.c | 2 ++

 1 file changed, 2 insertions(+)
libsepol/src/policydb.c +0 -0
index 37788f36..c7521235 100644
@@ -1420,6 +1420,8 @@ void ocontext_selinux_free(ocontext_t
 **ocontexts)

  if (i == OCON_ISID || i == OCON_FS || i == OCON_NETIF
  || i == OCON_FSUSE) free(ctmp->u.name);

libsepol/src/policydb.c +2 -0
+			else if (i == OCON_IBENDPORT)
+				free(ctmp->u.ibendport.dev_name);

  free(ctmp);
  }
  }