]> Pileus Git - ~andy/linux/commitdiff
LSM: BUILD_BUG_ON if the common_audit_data union ever grows
authorEric Paris <eparis@redhat.com>
Wed, 4 Apr 2012 19:01:43 +0000 (15:01 -0400)
committerEric Paris <eparis@redhat.com>
Mon, 9 Apr 2012 16:23:03 +0000 (12:23 -0400)
We did a lot of work to shrink the common_audit_data.  Add a BUILD_BUG_ON
so future programers (let's be honest, probably me) won't do something
foolish like make it large again!

Signed-off-by: Eric Paris <eparis@redhat.com>
security/lsm_audit.c

index e796d2517653a262d8f37992558ed1218d17cbee..8d8d97dbb389b1d305352cee29e4dbcc0191af64 100644 (file)
@@ -213,6 +213,13 @@ static void dump_common_audit_data(struct audit_buffer *ab,
 {
        struct task_struct *tsk = current;
 
+       /*
+        * To keep stack sizes in check force programers to notice if they
+        * start making this union too large!  See struct lsm_network_audit
+        * as an example of how to deal with large data.
+        */
+       BUILD_BUG_ON(sizeof(a->u) > sizeof(void *)*2);
+
        audit_log_format(ab, " pid=%d comm=", tsk->pid);
        audit_log_untrustedstring(ab, tsk->comm);