Skip to contentSkip to conversation

libsepol: reset pointer after free

PATCH Applied Jan Zarsky 2 participants 2 messages Aug 25, 2017 – Aug 28, 2017 SELinux security module

lore
Share & tools
lore

Jan Zarsky

author
#0 lore raw

PATCH 1/1 libsepol: reset pointer after free

In cil_strpool_destroy(), cil_strpool_tab is freed but it is not reset to NULL. When cil_strpool_init() is called again it assumes that cil_strpool_tab was already initialized. Other functions then work with invalid data.

---
 libsepol/cil/src/cil_strpool.c | 1 +
 1 file changed, 1 insertion(+)
libsepol/cil/src/cil_strpool.c +1 -0
index b1396d2..97d4c4b 100644
@@ -119,6 +119,7 @@ void cil_strpool_destroy(void)
 	if (cil_strpool_readers == 0) {
 		hashtab_map(cil_strpool_tab, cil_strpool_entry_destroy, NULL);
 		hashtab_destroy(cil_strpool_tab);
+		cil_strpool_tab = NULL;
 	}
 	pthread_mutex_unlock(&cil_strpool_mutex);
 }
Signature · 1 line
2.9.5
Applied
#1 lore raw
Quoted 5 lines · Jan Zarsky

In cil_strpool_destroy(), cil_strpool_tab is freed but it is not reset to NULL. When cil_strpool_init() is called again it assumes that cil_strpool_tab was already initialized. Other functions then work with invalid data.

Applied.

Thanks,
Jim

Quoted 17 lines
---
  libsepol/cil/src/cil_strpool.c | 1 +
  1 file changed, 1 insertion(+)
libsepol/cil/src/cil_strpool.c +1 -0
index b1396d2..97d4c4b 100644
@@ -119,6 +119,7 @@ void cil_strpool_destroy(void)
  	if (cil_strpool_readers == 0) {
  		hashtab_map(cil_strpool_tab, cil_strpool_entry_destroy, NULL);
  		hashtab_destroy(cil_strpool_tab);
+		cil_strpool_tab = NULL;
  	}
  	pthread_mutex_unlock(&cil_strpool_mutex);
  }
Signature · 2 lines
James Carter <[email protected]>
National Security Agency