Commit 50c205f5 authored by Eric Paris's avatar Eric Paris

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: default avatarEric Paris <eparis@redhat.com>
parent 07f62eb6
...@@ -92,11 +92,6 @@ int ipv4_skb_to_auditdata(struct sk_buff *skb, ...@@ -92,11 +92,6 @@ int ipv4_skb_to_auditdata(struct sk_buff *skb,
int ipv6_skb_to_auditdata(struct sk_buff *skb, int ipv6_skb_to_auditdata(struct sk_buff *skb,
struct common_audit_data *ad, u8 *proto); struct common_audit_data *ad, u8 *proto);
/* Initialize an LSM audit data structure. */
#define COMMON_AUDIT_DATA_INIT(_d, _t) \
{ memset((_d), 0, sizeof(struct common_audit_data)); \
(_d)->type = _t; }
void common_lsm_audit(struct common_audit_data *a, void common_lsm_audit(struct common_audit_data *a,
void (*pre_audit)(struct audit_buffer *, void *), void (*pre_audit)(struct audit_buffer *, void *),
void (*post_audit)(struct audit_buffer *, void *)); void (*post_audit)(struct audit_buffer *, void *));
......
...@@ -65,7 +65,7 @@ static int audit_caps(struct aa_profile *profile, struct task_struct *task, ...@@ -65,7 +65,7 @@ static int audit_caps(struct aa_profile *profile, struct task_struct *task,
int type = AUDIT_APPARMOR_AUTO; int type = AUDIT_APPARMOR_AUTO;
struct common_audit_data sa; struct common_audit_data sa;
struct apparmor_audit_data aad = {0,}; 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.aad = &aad;
sa.u.cap = cap; sa.u.cap = cap;
sa.aad->tsk = task; sa.aad->tsk = task;
......
...@@ -108,7 +108,7 @@ int aa_audit_file(struct aa_profile *profile, struct file_perms *perms, ...@@ -108,7 +108,7 @@ int aa_audit_file(struct aa_profile *profile, struct file_perms *perms,
int type = AUDIT_APPARMOR_AUTO; int type = AUDIT_APPARMOR_AUTO;
struct common_audit_data sa; struct common_audit_data sa;
struct apparmor_audit_data aad = {0,}; struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE); sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad; sa.aad = &aad;
aad.op = op, aad.op = op,
aad.fs.request = request; aad.fs.request = request;
......
...@@ -42,7 +42,7 @@ static int aa_audit_ptrace(struct aa_profile *profile, ...@@ -42,7 +42,7 @@ static int aa_audit_ptrace(struct aa_profile *profile,
{ {
struct common_audit_data sa; struct common_audit_data sa;
struct apparmor_audit_data aad = {0,}; struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE); sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad; sa.aad = &aad;
aad.op = OP_PTRACE; aad.op = OP_PTRACE;
aad.target = target; aad.target = target;
......
...@@ -66,7 +66,7 @@ void aa_info_message(const char *str) ...@@ -66,7 +66,7 @@ void aa_info_message(const char *str)
if (audit_enabled) { if (audit_enabled) {
struct common_audit_data sa; struct common_audit_data sa;
struct apparmor_audit_data aad = {0,}; struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE); sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad; sa.aad = &aad;
aad.info = str; aad.info = str;
aa_audit_msg(AUDIT_APPARMOR_STATUS, &sa, NULL); aa_audit_msg(AUDIT_APPARMOR_STATUS, &sa, NULL);
......
...@@ -589,7 +589,7 @@ static int apparmor_setprocattr(struct task_struct *task, char *name, ...@@ -589,7 +589,7 @@ static int apparmor_setprocattr(struct task_struct *task, char *name,
} else { } else {
struct common_audit_data sa; struct common_audit_data sa;
struct apparmor_audit_data aad = {0,}; struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE); sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad; sa.aad = &aad;
aad.op = OP_SETPROCATTR; aad.op = OP_SETPROCATTR;
aad.info = name; aad.info = name;
......
...@@ -965,7 +965,7 @@ static int audit_policy(int op, gfp_t gfp, const char *name, const char *info, ...@@ -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 common_audit_data sa;
struct apparmor_audit_data aad = {0,}; struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE); sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad; sa.aad = &aad;
aad.op = op; aad.op = op;
aad.name = name; aad.name = name;
......
...@@ -95,7 +95,7 @@ static int audit_iface(struct aa_profile *new, const char *name, ...@@ -95,7 +95,7 @@ static int audit_iface(struct aa_profile *new, const char *name,
struct aa_profile *profile = __aa_current_profile(); struct aa_profile *profile = __aa_current_profile();
struct common_audit_data sa; struct common_audit_data sa;
struct apparmor_audit_data aad = {0,}; struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE); sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad; sa.aad = &aad;
if (e) if (e)
aad.iface.pos = e->pos - e->start; aad.iface.pos = e->pos - e->start;
......
...@@ -52,7 +52,7 @@ static int audit_resource(struct aa_profile *profile, unsigned int resource, ...@@ -52,7 +52,7 @@ static int audit_resource(struct aa_profile *profile, unsigned int resource,
struct common_audit_data sa; struct common_audit_data sa;
struct apparmor_audit_data aad = {0,}; struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, LSM_AUDIT_DATA_NONE); sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad; sa.aad = &aad;
aad.op = OP_SETRLIMIT, aad.op = OP_SETRLIMIT,
aad.rlim.rlim = resource; aad.rlim.rlim = resource;
......
...@@ -469,7 +469,7 @@ noinline int slow_avc_audit(u32 ssid, u32 tsid, u16 tclass, ...@@ -469,7 +469,7 @@ noinline int slow_avc_audit(u32 ssid, u32 tsid, u16 tclass,
if (!a) { if (!a) {
a = &stack_data; a = &stack_data;
COMMON_AUDIT_DATA_INIT(a, LSM_AUDIT_DATA_NONE); a->type = LSM_AUDIT_DATA_NONE;
a->selinux_audit_data = &sad; a->selinux_audit_data = &sad;
} }
......
This diff is collapsed.
...@@ -319,7 +319,7 @@ void smack_log(char *subject_label, char *object_label, ...@@ -319,7 +319,7 @@ void smack_log(char *subject_label, char *object_label,
static inline void smk_ad_init(struct smk_audit_info *a, const char *func, static inline void smk_ad_init(struct smk_audit_info *a, const char *func,
char type) char type)
{ {
memset(a, 0, sizeof(*a)); memset(&a->sad, 0, sizeof(a->sad));
a->a.type = type; a->a.type = type;
a->a.smack_audit_data = &a->sad; a->a.smack_audit_data = &a->sad;
a->a.smack_audit_data->function = func; a->a.smack_audit_data->function = func;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment