PERFORCE change 41647 for review
Andrew Reisse
areisse at FreeBSD.org
Fri Nov 7 17:34:48 GMT 2003
http://perforce.freebsd.org/chv.cgi?CH=41647
Change 41647 by areisse at 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_ */
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list