[patch 1/1] selinux: Fix NULL deref in policydb_destroy

From: Stephen Smalley
Date: Thu Oct 20 2005 - 15:28:57 EST


This patch fixes a possible NULL dereference in policydb_destroy, where
p->type_attr_map can be NULL if policydb_destroy is called to clean up a
partially loaded policy upon an error during policy load. Please apply.

Signed-off-by: Stephen Smalley <sds@xxxxxxxxxxxxx>
Acked-by: James Morris <jmorris@xxxxxxxxx>

---

security/selinux/ss/policydb.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

Index: linux-2.6/security/selinux/ss/policydb.c
===================================================================
RCS file: /nfshome/pal/CVS/linux-2.6/security/selinux/ss/policydb.c,v
retrieving revision 1.44
diff -u -p -r1.44 policydb.c
--- linux-2.6/security/selinux/ss/policydb.c 29 Aug 2005 14:13:22 -0000 1.44
+++ linux-2.6/security/selinux/ss/policydb.c 20 Oct 2005 19:11:06 -0000
@@ -650,8 +650,10 @@ void policydb_destroy(struct policydb *p
}
if (lrt) kfree(lrt);

- for (i = 0; i < p->p_types.nprim; i++)
- ebitmap_destroy(&p->type_attr_map[i]);
+ if (p->type_attr_map) {
+ for (i = 0; i < p->p_types.nprim; i++)
+ ebitmap_destroy(&p->type_attr_map[i]);
+ }
kfree(p->type_attr_map);

return;

--
Stephen Smalley
National Security Agency

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/