LSM: do not initialize common_audit_data to 0
It isn't needed. If you don't set the type of the data associated with
that type it is a pretty obvious programming bug. So why waste the cycles?
Signed-off-by: Eric Paris <eparis@redhat.com>
diff --git a/security/apparmor/capability.c b/security/apparmor/capability.c
index b66a0e4..887a5e9 100644
--- a/security/apparmor/capability.c
+++ b/security/apparmor/capability.c
@@ -65,7 +65,7 @@
int type = AUDIT_APPARMOR_AUTO;
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
- COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_CAP);
+ sa.type = LSM_AUDIT_DATA_CAP;
sa.aad = &aad;
sa.u.cap = cap;
sa.aad->tsk = task;
diff --git a/security/apparmor/file.c b/security/apparmor/file.c
index 6ab264c..cf19d40 100644
--- a/security/apparmor/file.c
+++ b/security/apparmor/file.c
@@ -108,7 +108,7 @@
int type = AUDIT_APPARMOR_AUTO;
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
- COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
+ sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.op = op,
aad.fs.request = request;
diff --git a/security/apparmor/ipc.c b/security/apparmor/ipc.c
index dba449b..cf1071b 100644
--- a/security/apparmor/ipc.c
+++ b/security/apparmor/ipc.c
@@ -42,7 +42,7 @@
{
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
- COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
+ sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.op = OP_PTRACE;
aad.target = target;
diff --git a/security/apparmor/lib.c b/security/apparmor/lib.c
index b11a265..7430298 100644
--- a/security/apparmor/lib.c
+++ b/security/apparmor/lib.c
@@ -66,7 +66,7 @@
if (audit_enabled) {
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
- COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
+ sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.info = str;
aa_audit_msg(AUDIT_APPARMOR_STATUS, &sa, NULL);
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index 4f7bc07..032daab 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -589,7 +589,7 @@
} else {
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
- COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
+ sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.op = OP_SETPROCATTR;
aad.info = name;
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
index 03dbaef..421681c 100644
--- a/security/apparmor/policy.c
+++ b/security/apparmor/policy.c
@@ -965,7 +965,7 @@
{
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
- COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
+ sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.op = op;
aad.name = name;
diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c
index 504ba40..329b1fd 100644
--- a/security/apparmor/policy_unpack.c
+++ b/security/apparmor/policy_unpack.c
@@ -95,7 +95,7 @@
struct aa_profile *profile = __aa_current_profile();
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
- COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
+ sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
if (e)
aad.iface.pos = e->pos - e->start;
diff --git a/security/apparmor/resource.c b/security/apparmor/resource.c
index d06f57b..e1f3d7e 100644
--- a/security/apparmor/resource.c
+++ b/security/apparmor/resource.c
@@ -52,7 +52,7 @@
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
- COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
+ sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.op = OP_SETRLIMIT,
aad.rlim.rlim = resource;
diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index c04eea2..cd91e25 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -469,7 +469,7 @@
if (!a) {
a = &stack_data;
- COMMON_AUDIT_DATA_INIT(a, LSM_AUDIT_DATA_NONE);
+ a->type = LSM_AUDIT_DATA_NONE;
a->selinux_audit_data = &sad;
}
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index d797629..d9fa248 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1427,7 +1427,7 @@
u32 av = CAP_TO_MASK(cap);
int rc;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_CAP);
+ ad.type = LSM_AUDIT_DATA_CAP;
ad.selinux_audit_data = &sad;
ad.u.cap = cap;
@@ -1498,7 +1498,7 @@
struct common_audit_data ad;
struct selinux_audit_data sad = {0,};
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
+ ad.type = LSM_AUDIT_DATA_DENTRY;
ad.u.dentry = dentry;
ad.selinux_audit_data = &sad;
return inode_has_perm(cred, inode, av, &ad, 0);
@@ -1515,7 +1515,7 @@
struct common_audit_data ad;
struct selinux_audit_data sad = {0,};
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_PATH);
+ ad.type = LSM_AUDIT_DATA_PATH;
ad.u.path = *path;
ad.selinux_audit_data = &sad;
return inode_has_perm(cred, inode, av, &ad, 0);
@@ -1540,7 +1540,7 @@
u32 sid = cred_sid(cred);
int rc;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_PATH);
+ ad.type = LSM_AUDIT_DATA_PATH;
ad.u.path = file->f_path;
ad.selinux_audit_data = &sad;
@@ -1581,7 +1581,7 @@
sid = tsec->sid;
newsid = tsec->create_sid;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
+ ad.type = LSM_AUDIT_DATA_DENTRY;
ad.u.dentry = dentry;
ad.selinux_audit_data = &sad;
@@ -1636,7 +1636,7 @@
dsec = dir->i_security;
isec = dentry->d_inode->i_security;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
+ ad.type = LSM_AUDIT_DATA_DENTRY;
ad.u.dentry = dentry;
ad.selinux_audit_data = &sad;
@@ -1684,7 +1684,7 @@
old_is_dir = S_ISDIR(old_dentry->d_inode->i_mode);
new_dsec = new_dir->i_security;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
+ ad.type = LSM_AUDIT_DATA_DENTRY;
ad.selinux_audit_data = &sad;
ad.u.dentry = old_dentry;
@@ -2010,7 +2010,7 @@
return rc;
}
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_PATH);
+ ad.type = LSM_AUDIT_DATA_PATH;
ad.selinux_audit_data = &sad;
ad.u.path = bprm->file->f_path;
@@ -2134,7 +2134,7 @@
/* Revalidate access to inherited open files. */
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_INODE);
+ ad.type = LSM_AUDIT_DATA_INODE;
ad.selinux_audit_data = &sad;
spin_lock(&files->file_lock);
@@ -2484,7 +2484,7 @@
if (flags & MS_KERNMOUNT)
return 0;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
+ ad.type = LSM_AUDIT_DATA_DENTRY;
ad.selinux_audit_data = &sad;
ad.u.dentry = sb->s_root;
return superblock_has_perm(cred, sb, FILESYSTEM__MOUNT, &ad);
@@ -2496,7 +2496,7 @@
struct common_audit_data ad;
struct selinux_audit_data sad = {0,};
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
+ ad.type = LSM_AUDIT_DATA_DENTRY;
ad.selinux_audit_data = &sad;
ad.u.dentry = dentry->d_sb->s_root;
return superblock_has_perm(cred, dentry->d_sb, FILESYSTEM__GETATTR, &ad);
@@ -2666,7 +2666,7 @@
struct inode_security_struct *isec = inode->i_security;
int rc;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_INODE);
+ ad.type = LSM_AUDIT_DATA_INODE;
ad.selinux_audit_data = &sad;
ad.u.inode = inode;
@@ -2796,7 +2796,7 @@
if (!inode_owner_or_capable(inode))
return -EPERM;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
+ ad.type = LSM_AUDIT_DATA_DENTRY;
ad.selinux_audit_data = &sad;
ad.u.dentry = dentry;
@@ -3411,7 +3411,7 @@
sid = task_sid(current);
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_KMOD);
+ ad.type = LSM_AUDIT_DATA_KMOD;
ad.selinux_audit_data = &sad;
ad.u.kmod_name = kmod_name;
@@ -3792,7 +3792,7 @@
if (sksec->sid == SECINITSID_KERNEL)
return 0;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
+ ad.type = LSM_AUDIT_DATA_NET;
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->sk = sk;
@@ -3900,7 +3900,7 @@
snum, &sid);
if (err)
goto out;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
+ ad.type = LSM_AUDIT_DATA_NET;
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->sport = htons(snum);
@@ -3935,7 +3935,7 @@
if (err)
goto out;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
+ ad.type = LSM_AUDIT_DATA_NET;
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->sport = htons(snum);
@@ -3997,7 +3997,7 @@
perm = (sksec->sclass == SECCLASS_TCP_SOCKET) ?
TCP_SOCKET__NAME_CONNECT : DCCP_SOCKET__NAME_CONNECT;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
+ ad.type = LSM_AUDIT_DATA_NET;
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->dport = htons(snum);
@@ -4094,7 +4094,7 @@
struct lsm_network_audit net = {0,};
int err;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
+ ad.type = LSM_AUDIT_DATA_NET;
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->sk = other;
@@ -4127,7 +4127,7 @@
struct selinux_audit_data sad = {0,};
struct lsm_network_audit net = {0,};
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
+ ad.type = LSM_AUDIT_DATA_NET;
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->sk = other->sk;
@@ -4170,7 +4170,7 @@
struct lsm_network_audit net = {0,};
char *addrp;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
+ ad.type = LSM_AUDIT_DATA_NET;
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->netif = skb->skb_iif;
@@ -4226,7 +4226,7 @@
if (!secmark_active && !peerlbl_active)
return 0;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
+ ad.type = LSM_AUDIT_DATA_NET;
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->netif = skb->skb_iif;
@@ -4583,7 +4583,7 @@
if (selinux_skb_peerlbl_sid(skb, family, &peer_sid) != 0)
return NF_DROP;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
+ ad.type = LSM_AUDIT_DATA_NET;
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->netif = ifindex;
@@ -4683,7 +4683,7 @@
return NF_ACCEPT;
sksec = sk->sk_security;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
+ ad.type = LSM_AUDIT_DATA_NET;
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->netif = ifindex;
@@ -4756,7 +4756,7 @@
secmark_perm = PACKET__SEND;
}
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
+ ad.type = LSM_AUDIT_DATA_NET;
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->netif = ifindex;
@@ -4880,7 +4880,7 @@
isec = ipc_perms->security;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
+ ad.type = LSM_AUDIT_DATA_IPC;
ad.selinux_audit_data = &sad;
ad.u.ipc_id = ipc_perms->key;
@@ -4912,7 +4912,7 @@
isec = msq->q_perm.security;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
+ ad.type = LSM_AUDIT_DATA_IPC;
ad.selinux_audit_data = &sad;
ad.u.ipc_id = msq->q_perm.key;
@@ -4939,7 +4939,7 @@
isec = msq->q_perm.security;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
+ ad.type = LSM_AUDIT_DATA_IPC;
ad.selinux_audit_data = &sad;
ad.u.ipc_id = msq->q_perm.key;
@@ -5001,7 +5001,7 @@
return rc;
}
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
+ ad.type = LSM_AUDIT_DATA_IPC;
ad.selinux_audit_data = &sad;
ad.u.ipc_id = msq->q_perm.key;
@@ -5034,7 +5034,7 @@
isec = msq->q_perm.security;
msec = msg->security;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
+ ad.type = LSM_AUDIT_DATA_IPC;
ad.selinux_audit_data = &sad;
ad.u.ipc_id = msq->q_perm.key;
@@ -5061,7 +5061,7 @@
isec = shp->shm_perm.security;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
+ ad.type = LSM_AUDIT_DATA_IPC;
ad.selinux_audit_data = &sad;
ad.u.ipc_id = shp->shm_perm.key;
@@ -5088,7 +5088,7 @@
isec = shp->shm_perm.security;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
+ ad.type = LSM_AUDIT_DATA_IPC;
ad.selinux_audit_data = &sad;
ad.u.ipc_id = shp->shm_perm.key;
@@ -5157,7 +5157,7 @@
isec = sma->sem_perm.security;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
+ ad.type = LSM_AUDIT_DATA_IPC;
ad.selinux_audit_data = &sad;
ad.u.ipc_id = sma->sem_perm.key;
@@ -5184,7 +5184,7 @@
isec = sma->sem_perm.security;
- COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
+ ad.type = LSM_AUDIT_DATA_IPC;
ad.selinux_audit_data = &sad;
ad.u.ipc_id = sma->sem_perm.key;
diff --git a/security/smack/smack.h b/security/smack/smack.h
index 4ede719..b61e75f 100644
--- a/security/smack/smack.h
+++ b/security/smack/smack.h
@@ -319,7 +319,7 @@
static inline void smk_ad_init(struct smk_audit_info *a, const char *func,
char type)
{
- memset(a, 0, sizeof(*a));
+ memset(&a->sad, 0, sizeof(a->sad));
a->a.type = type;
a->a.smack_audit_data = &a->sad;
a->a.smack_audit_data->function = func;