Commit 07f62eb66c6626aa5653a0fcb34c9c040d0bd032

Authored by Eric Paris
1 parent b466066f9b

LSM: BUILD_BUG_ON if the common_audit_data union ever grows

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>

Showing 1 changed file with 7 additions and 0 deletions Side-by-side Diff

security/lsm_audit.c
... ... @@ -213,6 +213,13 @@
213 213 {
214 214 struct task_struct *tsk = current;
215 215  
  216 + /*
  217 + * To keep stack sizes in check force programers to notice if they
  218 + * start making this union too large! See struct lsm_network_audit
  219 + * as an example of how to deal with large data.
  220 + */
  221 + BUILD_BUG_ON(sizeof(a->u) > sizeof(void *)*2);
  222 +
216 223 audit_log_format(ab, " pid=%d comm=", tsk->pid);
217 224 audit_log_untrustedstring(ab, tsk->comm);
218 225