Skip to content

Commit

Permalink
LSM: BUILD_BUG_ON if the common_audit_data union ever grows
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Paris committed Apr 9, 2012
1 parent b466066 commit 07f62eb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions security/lsm_audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 07f62eb

Please sign in to comment.