Date: Fri, 07 Nov 2003 17:34:50 -0000 From: Andrew Reisse <areisse@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 41647 for review Message-ID: <200311071734.hA7HYmvP063658@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=41647 Change 41647 by areisse@areisse_ibook on 2003/11/07 09:34:11 sebsd doesn't leak (as much) memory Affected files ... .. //depot/projects/trustedbsd/sedarwin/apsl/xnu/security/sebsd/linux-compat.h#5 edit .. //depot/projects/trustedbsd/sedarwin/apsl/xnu/security/sebsd/sebsd.c#9 edit .. //depot/projects/trustedbsd/sedarwin/apsl/xnu/security/sebsd/ss/security.h#3 edit Differences ... ==== //depot/projects/trustedbsd/sedarwin/apsl/xnu/security/sebsd/linux-compat.h#5 (text+ko) ==== @@ -119,10 +119,11 @@ #ifdef __APPLE__ -extern void *sebsd_malloc (size_t size, int flags); +extern void *sebsd_ss_malloc (size_t size, int flags); +extern void sebsd_ss_free (void *); -#define malloc(size,type,flags) sebsd_malloc (size,flags) -#define free(addr,type) +#define malloc(size,type,flags) sebsd_ss_malloc (size,flags) +#define free(addr,type) sebsd_ss_free (addr) #define M_SEBSD M_MACTEMP #else @@ -132,10 +133,10 @@ #endif #endif /* __APPLE__ */ -#define kmalloc(size,flags) sebsd_malloc(size, flags) -#define kfree(v) /*free(v, M_SEBSD)*/ +#define kmalloc(size,flags) sebsd_ss_malloc(size, flags) +#define kfree(v) sebsd_ss_free(v) /* XXX need page size */ -#define __get_free_page(flags) sebsd_malloc(4096, flags) +#define __get_free_page(flags) sebsd_ss_malloc(4096, flags) #define GFP_ATOMIC M_NOWAIT #define GFP_KERNEL M_NOWAIT ==== //depot/projects/trustedbsd/sedarwin/apsl/xnu/security/sebsd/sebsd.c#9 (text+ko) ==== @@ -97,6 +97,19 @@ kmem_free (kernel_map, v, size); } +void *sebsd_ss_malloc (size_t size, int flags) +{ + size_t *v = sebsd_malloc (size + sizeof (size_t), flags); + v[0] = size; + return v+1; +} + +void sebsd_ss_free (void *v) +{ + size_t *vs = (size_t *) v; + sebsd_free (vs-1, vs[-1]); +} + #else MALLOC_DEFINE(M_SEBSD, "sebsd", "Security Enhanced BSD"); #endif ==== //depot/projects/trustedbsd/sedarwin/apsl/xnu/security/sebsd/ss/security.h#3 (text+ko) ==== @@ -67,7 +67,7 @@ int security_genfs_sid(const char *fstype, char *name, security_class_t sclass, security_id_t *sid); -#define security_free_context(ctx) /*({ if (ctx) free(ctx, M_SEBSD); })*/ +#define security_free_context(ctx) ({ if (ctx) sebsd_ss_free(ctx); }) #endif /* _SELINUX_SECURITY_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200311071734.hA7HYmvP063658>