Skip to content

Commit

Permalink
LSM: remove the COMMON_AUDIT_DATA_INIT type expansion
Browse files Browse the repository at this point in the history
Just open code it so grep on the source code works better.

Signed-off-by: Eric Paris <[email protected]>
  • Loading branch information
eparis committed Apr 9, 2012
1 parent d4cf970 commit bd5e50f
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion include/linux/lsm_audit.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int ipv6_skb_to_auditdata(struct sk_buff *skb,
/* Initialize an LSM audit data structure. */
#define COMMON_AUDIT_DATA_INIT(_d, _t) \
{ memset((_d), 0, sizeof(struct common_audit_data)); \
(_d)->type = LSM_AUDIT_DATA_##_t; }
(_d)->type = _t; }

void common_lsm_audit(struct common_audit_data *a,
void (*pre_audit)(struct audit_buffer *, void *),
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static int audit_caps(struct aa_profile *profile, struct task_struct *task,
int type = AUDIT_APPARMOR_AUTO;
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, CAP);
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_CAP);
sa.aad = &aad;
sa.tsk = task;
sa.u.cap = cap;
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int aa_audit_file(struct aa_profile *profile, struct file_perms *perms,
int type = AUDIT_APPARMOR_AUTO;
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, NONE);
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
sa.aad = &aad;
aad.op = op,
aad.fs.request = request;
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static int aa_audit_ptrace(struct aa_profile *profile,
{
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, NONE);
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
sa.aad = &aad;
aad.op = OP_PTRACE;
aad.target = target;
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void aa_info_message(const char *str)
if (audit_enabled) {
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, NONE);
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
sa.aad = &aad;
aad.info = str;
aa_audit_msg(AUDIT_APPARMOR_STATUS, &sa, NULL);
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ static int apparmor_setprocattr(struct task_struct *task, char *name,
} else {
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, NONE);
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
sa.aad = &aad;
aad.op = OP_SETPROCATTR;
aad.info = name;
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ static int audit_policy(int op, gfp_t gfp, const char *name, const char *info,
{
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, NONE);
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
sa.aad = &aad;
aad.op = op;
aad.name = name;
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/policy_unpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int audit_iface(struct aa_profile *new, const char *name,
struct aa_profile *profile = __aa_current_profile();
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, NONE);
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
sa.aad = &aad;
if (e)
aad.iface.pos = e->pos - e->start;
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int audit_resource(struct aa_profile *profile, unsigned int resource,
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};

COMMON_AUDIT_DATA_INIT(&sa, NONE);
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE);
sa.aad = &aad;
aad.op = OP_SETRLIMIT,
aad.rlim.rlim = resource;
Expand Down
2 changes: 1 addition & 1 deletion security/selinux/avc.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ noinline int slow_avc_audit(u32 ssid, u32 tsid, u16 tclass,

if (!a) {
a = &stack_data;
COMMON_AUDIT_DATA_INIT(a, NONE);
COMMON_AUDIT_DATA_INIT(a, LSM_AUDIT_DATA_NONE);
a->selinux_audit_data = &sad;
}

Expand Down
68 changes: 34 additions & 34 deletions security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ static int cred_has_capability(const struct cred *cred,
u32 av = CAP_TO_MASK(cap);
int rc;

COMMON_AUDIT_DATA_INIT(&ad, CAP);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_CAP);
ad.selinux_audit_data = &sad;
ad.tsk = current;
ad.u.cap = cap;
Expand Down Expand Up @@ -1499,7 +1499,7 @@ static inline int dentry_has_perm(const struct cred *cred,
struct common_audit_data ad;
struct selinux_audit_data sad = {0,};

COMMON_AUDIT_DATA_INIT(&ad, DENTRY);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
ad.u.dentry = dentry;
ad.selinux_audit_data = &sad;
return inode_has_perm(cred, inode, av, &ad, 0);
Expand All @@ -1516,7 +1516,7 @@ static inline int path_has_perm(const struct cred *cred,
struct common_audit_data ad;
struct selinux_audit_data sad = {0,};

COMMON_AUDIT_DATA_INIT(&ad, PATH);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_PATH);
ad.u.path = *path;
ad.selinux_audit_data = &sad;
return inode_has_perm(cred, inode, av, &ad, 0);
Expand All @@ -1541,7 +1541,7 @@ static int file_has_perm(const struct cred *cred,
u32 sid = cred_sid(cred);
int rc;

COMMON_AUDIT_DATA_INIT(&ad, PATH);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_PATH);
ad.u.path = file->f_path;
ad.selinux_audit_data = &sad;

Expand Down Expand Up @@ -1582,7 +1582,7 @@ static int may_create(struct inode *dir,
sid = tsec->sid;
newsid = tsec->create_sid;

COMMON_AUDIT_DATA_INIT(&ad, DENTRY);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
ad.u.dentry = dentry;
ad.selinux_audit_data = &sad;

Expand Down Expand Up @@ -1637,7 +1637,7 @@ static int may_link(struct inode *dir,
dsec = dir->i_security;
isec = dentry->d_inode->i_security;

COMMON_AUDIT_DATA_INIT(&ad, DENTRY);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
ad.u.dentry = dentry;
ad.selinux_audit_data = &sad;

Expand Down Expand Up @@ -1685,7 +1685,7 @@ static inline int may_rename(struct inode *old_dir,
old_is_dir = S_ISDIR(old_dentry->d_inode->i_mode);
new_dsec = new_dir->i_security;

COMMON_AUDIT_DATA_INIT(&ad, DENTRY);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
ad.selinux_audit_data = &sad;

ad.u.dentry = old_dentry;
Expand Down Expand Up @@ -2011,7 +2011,7 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
return rc;
}

COMMON_AUDIT_DATA_INIT(&ad, PATH);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_PATH);
ad.selinux_audit_data = &sad;
ad.u.path = bprm->file->f_path;

Expand Down Expand Up @@ -2135,7 +2135,7 @@ static inline void flush_unauthorized_files(const struct cred *cred,

/* Revalidate access to inherited open files. */

COMMON_AUDIT_DATA_INIT(&ad, INODE);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_INODE);
ad.selinux_audit_data = &sad;

spin_lock(&files->file_lock);
Expand Down Expand Up @@ -2485,7 +2485,7 @@ static int selinux_sb_kern_mount(struct super_block *sb, int flags, void *data)
if (flags & MS_KERNMOUNT)
return 0;

COMMON_AUDIT_DATA_INIT(&ad, DENTRY);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
ad.selinux_audit_data = &sad;
ad.u.dentry = sb->s_root;
return superblock_has_perm(cred, sb, FILESYSTEM__MOUNT, &ad);
Expand All @@ -2497,7 +2497,7 @@ static int selinux_sb_statfs(struct dentry *dentry)
struct common_audit_data ad;
struct selinux_audit_data sad = {0,};

COMMON_AUDIT_DATA_INIT(&ad, DENTRY);
COMMON_AUDIT_DATA_INIT(&ad, 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);
Expand Down Expand Up @@ -2667,7 +2667,7 @@ static noinline int audit_inode_permission(struct inode *inode,
struct inode_security_struct *isec = inode->i_security;
int rc;

COMMON_AUDIT_DATA_INIT(&ad, INODE);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_INODE);
ad.selinux_audit_data = &sad;
ad.u.inode = inode;

Expand Down Expand Up @@ -2797,7 +2797,7 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name,
if (!inode_owner_or_capable(inode))
return -EPERM;

COMMON_AUDIT_DATA_INIT(&ad, DENTRY);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_DENTRY);
ad.selinux_audit_data = &sad;
ad.u.dentry = dentry;

Expand Down Expand Up @@ -3412,7 +3412,7 @@ static int selinux_kernel_module_request(char *kmod_name)

sid = task_sid(current);

COMMON_AUDIT_DATA_INIT(&ad, KMOD);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_KMOD);
ad.selinux_audit_data = &sad;
ad.u.kmod_name = kmod_name;

Expand Down Expand Up @@ -3793,7 +3793,7 @@ static int sock_has_perm(struct task_struct *task, struct sock *sk, u32 perms)
if (sksec->sid == SECINITSID_KERNEL)
return 0;

COMMON_AUDIT_DATA_INIT(&ad, NET);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->sk = sk;
Expand Down Expand Up @@ -3901,7 +3901,7 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
snum, &sid);
if (err)
goto out;
COMMON_AUDIT_DATA_INIT(&ad, NET);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->sport = htons(snum);
Expand Down Expand Up @@ -3936,7 +3936,7 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
if (err)
goto out;

COMMON_AUDIT_DATA_INIT(&ad, NET);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->sport = htons(snum);
Expand Down Expand Up @@ -3998,7 +3998,7 @@ static int selinux_socket_connect(struct socket *sock, struct sockaddr *address,
perm = (sksec->sclass == SECCLASS_TCP_SOCKET) ?
TCP_SOCKET__NAME_CONNECT : DCCP_SOCKET__NAME_CONNECT;

COMMON_AUDIT_DATA_INIT(&ad, NET);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->dport = htons(snum);
Expand Down Expand Up @@ -4095,7 +4095,7 @@ static int selinux_socket_unix_stream_connect(struct sock *sock,
struct lsm_network_audit net = {0,};
int err;

COMMON_AUDIT_DATA_INIT(&ad, NET);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->sk = other;
Expand Down Expand Up @@ -4128,7 +4128,7 @@ static int selinux_socket_unix_may_send(struct socket *sock,
struct selinux_audit_data sad = {0,};
struct lsm_network_audit net = {0,};

COMMON_AUDIT_DATA_INIT(&ad, NET);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->sk = other->sk;
Expand Down Expand Up @@ -4171,7 +4171,7 @@ static int selinux_sock_rcv_skb_compat(struct sock *sk, struct sk_buff *skb,
struct lsm_network_audit net = {0,};
char *addrp;

COMMON_AUDIT_DATA_INIT(&ad, NET);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->netif = skb->skb_iif;
Expand Down Expand Up @@ -4227,7 +4227,7 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
if (!secmark_active && !peerlbl_active)
return 0;

COMMON_AUDIT_DATA_INIT(&ad, NET);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->netif = skb->skb_iif;
Expand Down Expand Up @@ -4584,7 +4584,7 @@ static unsigned int selinux_ip_forward(struct sk_buff *skb, int ifindex,
if (selinux_skb_peerlbl_sid(skb, family, &peer_sid) != 0)
return NF_DROP;

COMMON_AUDIT_DATA_INIT(&ad, NET);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->netif = ifindex;
Expand Down Expand Up @@ -4684,7 +4684,7 @@ static unsigned int selinux_ip_postroute_compat(struct sk_buff *skb,
return NF_ACCEPT;
sksec = sk->sk_security;

COMMON_AUDIT_DATA_INIT(&ad, NET);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->netif = ifindex;
Expand Down Expand Up @@ -4757,7 +4757,7 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex,
secmark_perm = PACKET__SEND;
}

COMMON_AUDIT_DATA_INIT(&ad, NET);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_NET);
ad.selinux_audit_data = &sad;
ad.u.net = &net;
ad.u.net->netif = ifindex;
Expand Down Expand Up @@ -4881,7 +4881,7 @@ static int ipc_has_perm(struct kern_ipc_perm *ipc_perms,

isec = ipc_perms->security;

COMMON_AUDIT_DATA_INIT(&ad, IPC);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
ad.selinux_audit_data = &sad;
ad.u.ipc_id = ipc_perms->key;

Expand Down Expand Up @@ -4913,7 +4913,7 @@ static int selinux_msg_queue_alloc_security(struct msg_queue *msq)

isec = msq->q_perm.security;

COMMON_AUDIT_DATA_INIT(&ad, IPC);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
ad.selinux_audit_data = &sad;
ad.u.ipc_id = msq->q_perm.key;

Expand All @@ -4940,7 +4940,7 @@ static int selinux_msg_queue_associate(struct msg_queue *msq, int msqflg)

isec = msq->q_perm.security;

COMMON_AUDIT_DATA_INIT(&ad, IPC);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
ad.selinux_audit_data = &sad;
ad.u.ipc_id = msq->q_perm.key;

Expand Down Expand Up @@ -5002,7 +5002,7 @@ static int selinux_msg_queue_msgsnd(struct msg_queue *msq, struct msg_msg *msg,
return rc;
}

COMMON_AUDIT_DATA_INIT(&ad, IPC);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
ad.selinux_audit_data = &sad;
ad.u.ipc_id = msq->q_perm.key;

Expand Down Expand Up @@ -5035,7 +5035,7 @@ static int selinux_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
isec = msq->q_perm.security;
msec = msg->security;

COMMON_AUDIT_DATA_INIT(&ad, IPC);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
ad.selinux_audit_data = &sad;
ad.u.ipc_id = msq->q_perm.key;

Expand All @@ -5062,7 +5062,7 @@ static int selinux_shm_alloc_security(struct shmid_kernel *shp)

isec = shp->shm_perm.security;

COMMON_AUDIT_DATA_INIT(&ad, IPC);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
ad.selinux_audit_data = &sad;
ad.u.ipc_id = shp->shm_perm.key;

Expand All @@ -5089,7 +5089,7 @@ static int selinux_shm_associate(struct shmid_kernel *shp, int shmflg)

isec = shp->shm_perm.security;

COMMON_AUDIT_DATA_INIT(&ad, IPC);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
ad.selinux_audit_data = &sad;
ad.u.ipc_id = shp->shm_perm.key;

Expand Down Expand Up @@ -5158,7 +5158,7 @@ static int selinux_sem_alloc_security(struct sem_array *sma)

isec = sma->sem_perm.security;

COMMON_AUDIT_DATA_INIT(&ad, IPC);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
ad.selinux_audit_data = &sad;
ad.u.ipc_id = sma->sem_perm.key;

Expand All @@ -5185,7 +5185,7 @@ static int selinux_sem_associate(struct sem_array *sma, int semflg)

isec = sma->sem_perm.security;

COMMON_AUDIT_DATA_INIT(&ad, IPC);
COMMON_AUDIT_DATA_INIT(&ad, LSM_AUDIT_DATA_IPC);
ad.selinux_audit_data = &sad;
ad.u.ipc_id = sma->sem_perm.key;

Expand Down

0 comments on commit bd5e50f

Please sign in to comment.