2020-11-06 08:33:53

by Alex Shi

[permalink] [raw]
Subject: [PATCH] audit: remove unused macros

Some unused macros could cause gcc warning:
kernel/audit.c:68:0: warning: macro "AUDIT_UNINITIALIZED" is not used
[-Wunused-macros]
kernel/auditsc.c:104:0: warning: macro "AUDIT_AUX_IPCPERM" is not used
[-Wunused-macros]
kernel/auditsc.c:82:0: warning: macro "AUDITSC_INVALID" is not used
[-Wunused-macros]

remove them to tame gcc.

Signed-off-by: Alex Shi <[email protected]>
Cc: Paul Moore <[email protected]>
Cc: Eric Paris <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
kernel/audit.c | 1 -
kernel/auditsc.c | 3 ---
2 files changed, 4 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index ac0aeaa99937..dfac1e0ca887 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -65,7 +65,6 @@
/* No auditing will take place until audit_initialized == AUDIT_INITIALIZED.
* (Initialization happens after skb_init is called.) */
#define AUDIT_DISABLED -1
-#define AUDIT_UNINITIALIZED 0
#define AUDIT_INITIALIZED 1
static int audit_initialized;

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 183d79cc2e12..eeb4930d499f 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -80,7 +80,6 @@
#include "audit.h"

/* flags stating the success for a syscall */
-#define AUDITSC_INVALID 0
#define AUDITSC_SUCCESS 1
#define AUDITSC_FAILURE 2

@@ -102,8 +101,6 @@ struct audit_aux_data {
int type;
};

-#define AUDIT_AUX_IPCPERM 0
-
/* Number of target pids per aux struct. */
#define AUDIT_AUX_PIDS 16

--
1.8.3.1


2020-11-10 15:25:46

by Richard Guy Briggs

[permalink] [raw]
Subject: Re: [PATCH] audit: remove unused macros

On 2020-11-06 16:31, Alex Shi wrote:
> Some unused macros could cause gcc warning:
> kernel/audit.c:68:0: warning: macro "AUDIT_UNINITIALIZED" is not used
> [-Wunused-macros]
> kernel/auditsc.c:104:0: warning: macro "AUDIT_AUX_IPCPERM" is not used
> [-Wunused-macros]
> kernel/auditsc.c:82:0: warning: macro "AUDITSC_INVALID" is not used
> [-Wunused-macros]
>
> remove them to tame gcc.
>
> Signed-off-by: Alex Shi <[email protected]>
> Cc: Paul Moore <[email protected]>
> Cc: Eric Paris <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> kernel/audit.c | 1 -
> kernel/auditsc.c | 3 ---
> 2 files changed, 4 deletions(-)
>
> diff --git a/kernel/audit.c b/kernel/audit.c
> index ac0aeaa99937..dfac1e0ca887 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -65,7 +65,6 @@
> /* No auditing will take place until audit_initialized == AUDIT_INITIALIZED.
> * (Initialization happens after skb_init is called.) */
> #define AUDIT_DISABLED -1
> -#define AUDIT_UNINITIALIZED 0
> #define AUDIT_INITIALIZED 1
> static int audit_initialized;

This one is part of a set, so it feels like it should stay, but the code
is structured in such a way that it is not necessary.

> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 183d79cc2e12..eeb4930d499f 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -80,7 +80,6 @@
> #include "audit.h"
>
> /* flags stating the success for a syscall */
> -#define AUDITSC_INVALID 0
> #define AUDITSC_SUCCESS 1
> #define AUDITSC_FAILURE 2

Same here, but this one should really be fixed by using
AUDITSC_INVALID as the value assigned to context->return_valid in
__audit_free() to avoid using magic numbers. Similarly, the compared
values in audit_filter_rules() under the AUDIT_EXIT and AUDIT_SUCCESS
cases should be "ctx->return_valid != AUDITSC_INVALID" rather than just
"ctx->return_valid". Same in audit_log_exit().

> @@ -102,8 +101,6 @@ struct audit_aux_data {
> int type;
> };
>
> -#define AUDIT_AUX_IPCPERM 0
> -

Hmmm, this one looks like it was orphaned 15 years ago a couple of
months after it was introduced due to this commit:
c04049939f88 Steve Grubb <[email protected]> 2005-05-13
("AUDIT: Add message types to audit records")

Introduced here:
8e633c3fb2a2 David Woodhouse <[email protected]> 2005-03-01
("Audit IPC object owner/permission changes.")

I agree, remove it.

> /* Number of target pids per aux struct. */
> #define AUDIT_AUX_PIDS 16
>
> --
> 1.8.3.1
>
> --
> Linux-audit mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/linux-audit

- RGB

--
Richard Guy Briggs <[email protected]>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635

2020-11-11 02:51:46

by Paul Moore

[permalink] [raw]
Subject: Re: [PATCH] audit: remove unused macros

On Tue, Nov 10, 2020 at 10:23 AM Richard Guy Briggs <[email protected]> wrote:
> On 2020-11-06 16:31, Alex Shi wrote:
> > Some unused macros could cause gcc warning:
> > kernel/audit.c:68:0: warning: macro "AUDIT_UNINITIALIZED" is not used
> > [-Wunused-macros]
> > kernel/auditsc.c:104:0: warning: macro "AUDIT_AUX_IPCPERM" is not used
> > [-Wunused-macros]
> > kernel/auditsc.c:82:0: warning: macro "AUDITSC_INVALID" is not used
> > [-Wunused-macros]
> >
> > remove them to tame gcc.
> >
> > Signed-off-by: Alex Shi <[email protected]>
> > Cc: Paul Moore <[email protected]>
> > Cc: Eric Paris <[email protected]>
> > Cc: [email protected]
> > Cc: [email protected]
> > ---
> > kernel/audit.c | 1 -
> > kernel/auditsc.c | 3 ---
> > 2 files changed, 4 deletions(-)
> >
> > diff --git a/kernel/audit.c b/kernel/audit.c
> > index ac0aeaa99937..dfac1e0ca887 100644
> > --- a/kernel/audit.c
> > +++ b/kernel/audit.c
> > @@ -65,7 +65,6 @@
> > /* No auditing will take place until audit_initialized == AUDIT_INITIALIZED.
> > * (Initialization happens after skb_init is called.) */
> > #define AUDIT_DISABLED -1
> > -#define AUDIT_UNINITIALIZED 0
> > #define AUDIT_INITIALIZED 1
> > static int audit_initialized;
>
> This one is part of a set, so it feels like it should stay, but the code
> is structured in such a way that it is not necessary.

Yes, I'd like for us to find a way to keep this if possible. Let's
simply initialize "audit_initialized" to AUDIT_UNINITIALIZED in this
file. At some point someone will surely complain about not needing to
initialize to zero, but we can deal with that later.

> > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > index 183d79cc2e12..eeb4930d499f 100644
> > --- a/kernel/auditsc.c
> > +++ b/kernel/auditsc.c
> > @@ -80,7 +80,6 @@
> > #include "audit.h"
> >
> > /* flags stating the success for a syscall */
> > -#define AUDITSC_INVALID 0
> > #define AUDITSC_SUCCESS 1
> > #define AUDITSC_FAILURE 2
>
> Same here, but this one should really be fixed by using
> AUDITSC_INVALID as the value assigned to context->return_valid in
> __audit_free() to avoid using magic numbers.

Agreed.

We could probably explicitly set it in audit_alloc_context() as well
if we wanted to be complete.

> Similarly, the compared
> values in audit_filter_rules() under the AUDIT_EXIT and AUDIT_SUCCESS
> cases should be "ctx->return_valid != AUDITSC_INVALID" rather than just
> "ctx->return_valid". Same in audit_log_exit().

Agreed.

> > @@ -102,8 +101,6 @@ struct audit_aux_data {
> > int type;
> > };
> >
> > -#define AUDIT_AUX_IPCPERM 0
> > -
>
> Hmmm, this one looks like it was orphaned 15 years ago a couple of
> months after it was introduced due to this commit:
> c04049939f88 Steve Grubb <[email protected]> 2005-05-13
> ("AUDIT: Add message types to audit records")
>
> Introduced here:
> 8e633c3fb2a2 David Woodhouse <[email protected]> 2005-03-01
> ("Audit IPC object owner/permission changes.")
>
> I agree, remove it.

No arguments from me.

--
paul moore
http://www.paul-moore.com

2020-11-11 03:06:44

by Richard Guy Briggs

[permalink] [raw]
Subject: Re: [PATCH] audit: remove unused macros

On 2020-11-10 21:47, Paul Moore wrote:
> On Tue, Nov 10, 2020 at 10:23 AM Richard Guy Briggs <[email protected]> wrote:
> > On 2020-11-06 16:31, Alex Shi wrote:
> > > Some unused macros could cause gcc warning:
> > > kernel/audit.c:68:0: warning: macro "AUDIT_UNINITIALIZED" is not used
> > > [-Wunused-macros]
> > > kernel/auditsc.c:104:0: warning: macro "AUDIT_AUX_IPCPERM" is not used
> > > [-Wunused-macros]
> > > kernel/auditsc.c:82:0: warning: macro "AUDITSC_INVALID" is not used
> > > [-Wunused-macros]
> > >
> > > remove them to tame gcc.
> > >
> > > Signed-off-by: Alex Shi <[email protected]>
> > > Cc: Paul Moore <[email protected]>
> > > Cc: Eric Paris <[email protected]>
> > > Cc: [email protected]
> > > Cc: [email protected]
> > > ---
> > > kernel/audit.c | 1 -
> > > kernel/auditsc.c | 3 ---
> > > 2 files changed, 4 deletions(-)
> > >
> > > diff --git a/kernel/audit.c b/kernel/audit.c
> > > index ac0aeaa99937..dfac1e0ca887 100644
> > > --- a/kernel/audit.c
> > > +++ b/kernel/audit.c
> > > @@ -65,7 +65,6 @@
> > > /* No auditing will take place until audit_initialized == AUDIT_INITIALIZED.
> > > * (Initialization happens after skb_init is called.) */
> > > #define AUDIT_DISABLED -1
> > > -#define AUDIT_UNINITIALIZED 0
> > > #define AUDIT_INITIALIZED 1
> > > static int audit_initialized;
> >
> > This one is part of a set, so it feels like it should stay, but the code
> > is structured in such a way that it is not necessary.
>
> Yes, I'd like for us to find a way to keep this if possible. Let's
> simply initialize "audit_initialized" to AUDIT_UNINITIALIZED in this
> file. At some point someone will surely complain about not needing to
> initialize to zero, but we can deal with that later.

We could change them to an enum of 1,2,3. ;-)

> > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > > index 183d79cc2e12..eeb4930d499f 100644
> > > --- a/kernel/auditsc.c
> > > +++ b/kernel/auditsc.c
> > > @@ -80,7 +80,6 @@
> > > #include "audit.h"
> > >
> > > /* flags stating the success for a syscall */
> > > -#define AUDITSC_INVALID 0
> > > #define AUDITSC_SUCCESS 1
> > > #define AUDITSC_FAILURE 2
> >
> > Same here, but this one should really be fixed by using
> > AUDITSC_INVALID as the value assigned to context->return_valid in
> > __audit_free() to avoid using magic numbers.
>
> Agreed.
>
> We could probably explicitly set it in audit_alloc_context() as well
> if we wanted to be complete.

Agreed.

> > Similarly, the compared
> > values in audit_filter_rules() under the AUDIT_EXIT and AUDIT_SUCCESS
> > cases should be "ctx->return_valid != AUDITSC_INVALID" rather than just
> > "ctx->return_valid". Same in audit_log_exit().
>
> Agreed.
>
> > > @@ -102,8 +101,6 @@ struct audit_aux_data {
> > > int type;
> > > };
> > >
> > > -#define AUDIT_AUX_IPCPERM 0
> > > -
> >
> > Hmmm, this one looks like it was orphaned 15 years ago a couple of
> > months after it was introduced due to this commit:
> > c04049939f88 Steve Grubb <[email protected]> 2005-05-13
> > ("AUDIT: Add message types to audit records")
> >
> > Introduced here:
> > 8e633c3fb2a2 David Woodhouse <[email protected]> 2005-03-01
> > ("Audit IPC object owner/permission changes.")
> >
> > I agree, remove it.
>
> No arguments from me.
>
> --
> paul moore

- RGB

--
Richard Guy Briggs <[email protected]>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635

2020-11-11 06:24:23

by Alex Shi

[permalink] [raw]
Subject: Re: [PATCH] audit: remove unused macros

Thanks for comments!
So here is the v2 according to your suggestion!

From 033425b6072ff4cee05d6bbffc97cd6a4c13166c Mon Sep 17 00:00:00 2001
From: Alex Shi <[email protected]>
Date: Fri, 6 Nov 2020 16:31:22 +0800
Subject: [PATCH v2] kernel/audit: fix macros warning

Some unused macros could cause gcc warning:
kernel/audit.c:68:0: warning: macro "AUDIT_UNINITIALIZED" is not used
[-Wunused-macros]
kernel/auditsc.c:104:0: warning: macro "AUDIT_AUX_IPCPERM" is not used
[-Wunused-macros]
kernel/auditsc.c:82:0: warning: macro "AUDITSC_INVALID" is not used
[-Wunused-macros]

AUDIT_UNINITIALIZED and AUDITSC_INVALID are still meaningful and could
be used in code.

Just remove AUDIT_AUX_IPCPERM.

Thanks comments from Richard Guy Briggs and Paul Moore.

Signed-off-by: Alex Shi <[email protected]>
Cc: Paul Moore <[email protected]>
Cc: Eric Paris <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
kernel/audit.c | 2 +-
kernel/auditsc.c | 10 ++++------
2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index ac0aeaa99937..e22f22bdc000 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -67,7 +67,7 @@
#define AUDIT_DISABLED -1
#define AUDIT_UNINITIALIZED 0
#define AUDIT_INITIALIZED 1
-static int audit_initialized;
+static int audit_initialized = AUDIT_UNINITIALIZED;

u32 audit_enabled = AUDIT_OFF;
bool audit_ever_enabled = !!AUDIT_OFF;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 183d79cc2e12..ea0ed81ddee0 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -102,8 +102,6 @@ struct audit_aux_data {
int type;
};

-#define AUDIT_AUX_IPCPERM 0
-
/* Number of target pids per aux struct. */
#define AUDIT_AUX_PIDS 16

@@ -552,11 +550,11 @@ static int audit_filter_rules(struct task_struct *tsk,
break;

case AUDIT_EXIT:
- if (ctx && ctx->return_valid)
+ if (ctx && ctx->return_valid != AUDITSC_INVALID)
result = audit_comparator(ctx->return_code, f->op, f->val);
break;
case AUDIT_SUCCESS:
- if (ctx && ctx->return_valid) {
+ if (ctx && ctx->return_valid != AUDITSC_INVALID) {
if (f->val)
result = audit_comparator(ctx->return_valid, f->op, AUDITSC_SUCCESS);
else
@@ -1488,7 +1486,7 @@ static void audit_log_exit(void)
context->arch, context->major);
if (context->personality != PER_LINUX)
audit_log_format(ab, " per=%lx", context->personality);
- if (context->return_valid)
+ if (context->return_valid != AUDITSC_INVALID)
audit_log_format(ab, " success=%s exit=%ld",
(context->return_valid==AUDITSC_SUCCESS)?"yes":"no",
context->return_code);
@@ -1625,7 +1623,7 @@ void __audit_free(struct task_struct *tsk)
* need to log via audit_log_exit().
*/
if (tsk == current && !context->dummy && context->in_syscall) {
- context->return_valid = 0;
+ context->return_valid = AUDITSC_INVALID;
context->return_code = 0;

audit_filter_syscall(tsk, context,
--
1.8.3.1

2020-11-11 13:22:32

by Richard Guy Briggs

[permalink] [raw]
Subject: Re: [PATCH] audit: remove unused macros

On 2020-11-11 14:19, Alex Shi wrote:
> Thanks for comments!
> So here is the v2 according to your suggestion!
>
> From 033425b6072ff4cee05d6bbffc97cd6a4c13166c Mon Sep 17 00:00:00 2001
> From: Alex Shi <[email protected]>
> Date: Fri, 6 Nov 2020 16:31:22 +0800
> Subject: [PATCH v2] kernel/audit: fix macros warning
>
> Some unused macros could cause gcc warning:
> kernel/audit.c:68:0: warning: macro "AUDIT_UNINITIALIZED" is not used
> [-Wunused-macros]
> kernel/auditsc.c:104:0: warning: macro "AUDIT_AUX_IPCPERM" is not used
> [-Wunused-macros]
> kernel/auditsc.c:82:0: warning: macro "AUDITSC_INVALID" is not used
> [-Wunused-macros]
>
> AUDIT_UNINITIALIZED and AUDITSC_INVALID are still meaningful and could
> be used in code.

"and should be incorporated"

> Just remove AUDIT_AUX_IPCPERM.
>
> Thanks comments from Richard Guy Briggs and Paul Moore.
>
> Signed-off-by: Alex Shi <[email protected]>
> Cc: Paul Moore <[email protected]>
> Cc: Eric Paris <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> kernel/audit.c | 2 +-
> kernel/auditsc.c | 10 ++++------
> 2 files changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/audit.c b/kernel/audit.c
> index ac0aeaa99937..e22f22bdc000 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -67,7 +67,7 @@
> #define AUDIT_DISABLED -1
> #define AUDIT_UNINITIALIZED 0
> #define AUDIT_INITIALIZED 1
> -static int audit_initialized;
> +static int audit_initialized = AUDIT_UNINITIALIZED;
>
> u32 audit_enabled = AUDIT_OFF;
> bool audit_ever_enabled = !!AUDIT_OFF;
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 183d79cc2e12..ea0ed81ddee0 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -102,8 +102,6 @@ struct audit_aux_data {
> int type;
> };
>
> -#define AUDIT_AUX_IPCPERM 0
> -
> /* Number of target pids per aux struct. */
> #define AUDIT_AUX_PIDS 16
>
> @@ -552,11 +550,11 @@ static int audit_filter_rules(struct task_struct *tsk,
> break;
>
> case AUDIT_EXIT:
> - if (ctx && ctx->return_valid)
> + if (ctx && ctx->return_valid != AUDITSC_INVALID)
> result = audit_comparator(ctx->return_code, f->op, f->val);
> break;
> case AUDIT_SUCCESS:
> - if (ctx && ctx->return_valid) {
> + if (ctx && ctx->return_valid != AUDITSC_INVALID) {
> if (f->val)
> result = audit_comparator(ctx->return_valid, f->op, AUDITSC_SUCCESS);
> else
> @@ -1488,7 +1486,7 @@ static void audit_log_exit(void)
> context->arch, context->major);
> if (context->personality != PER_LINUX)
> audit_log_format(ab, " per=%lx", context->personality);
> - if (context->return_valid)
> + if (context->return_valid != AUDITSC_INVALID)
> audit_log_format(ab, " success=%s exit=%ld",
> (context->return_valid==AUDITSC_SUCCESS)?"yes":"no",
> context->return_code);
> @@ -1625,7 +1623,7 @@ void __audit_free(struct task_struct *tsk)
> * need to log via audit_log_exit().
> */
> if (tsk == current && !context->dummy && context->in_syscall) {
> - context->return_valid = 0;
> + context->return_valid = AUDITSC_INVALID;
> context->return_code = 0;
>
> audit_filter_syscall(tsk, context,

This all looks good, but I don't see the initialization of
context->return_valid in audit_alloc_context() that was mentioned for
completeness.

> --
> 1.8.3.1
>

- RGB

--
Richard Guy Briggs <[email protected]>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635

2020-11-12 01:42:18

by Alex Shi

[permalink] [raw]
Subject: Re: [PATCH] audit: remove unused macros



?? 2020/11/11 ????9:17, Richard Guy Briggs ะด??:
>>
>> audit_filter_syscall(tsk, context,
> This all looks good, but I don't see the initialization of
> context->return_valid in audit_alloc_context() that was mentioned for
> completeness.
>

Sorry for missing that. Here they are.

From 5fef5f1b7b745b52bedc9c7eec9fc163202ad421 Mon Sep 17 00:00:00 2001
From: Alex Shi <[email protected]>
Date: Fri, 6 Nov 2020 16:31:22 +0800
Subject: [PATCH v3] audit: fix macros warnings

Some unused macros could cause gcc warning:
kernel/audit.c:68:0: warning: macro "AUDIT_UNINITIALIZED" is not used
[-Wunused-macros]
kernel/auditsc.c:104:0: warning: macro "AUDIT_AUX_IPCPERM" is not used
[-Wunused-macros]
kernel/auditsc.c:82:0: warning: macro "AUDITSC_INVALID" is not used
[-Wunused-macros]

AUDIT_UNINITIALIZED and AUDITSC_INVALID are still meaningful and should
be in incorporated.

Just remove AUDIT_AUX_IPCPERM.

Thanks comments from Richard Guy Briggs and Paul Moore.

Signed-off-by: Alex Shi <[email protected]>
Cc: Paul Moore <[email protected]>
Cc: Richard Guy Briggs <[email protected]>
Cc: Eric Paris <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
kernel/audit.c | 2 +-
kernel/auditsc.c | 11 +++++------
2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index ac0aeaa99937..e22f22bdc000 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -67,7 +67,7 @@
#define AUDIT_DISABLED -1
#define AUDIT_UNINITIALIZED 0
#define AUDIT_INITIALIZED 1
-static int audit_initialized;
+static int audit_initialized = AUDIT_UNINITIALIZED;

u32 audit_enabled = AUDIT_OFF;
bool audit_ever_enabled = !!AUDIT_OFF;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 183d79cc2e12..9cbe6d5437be 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -102,8 +102,6 @@ struct audit_aux_data {
int type;
};

-#define AUDIT_AUX_IPCPERM 0
-
/* Number of target pids per aux struct. */
#define AUDIT_AUX_PIDS 16

@@ -552,11 +550,11 @@ static int audit_filter_rules(struct task_struct *tsk,
break;

case AUDIT_EXIT:
- if (ctx && ctx->return_valid)
+ if (ctx && ctx->return_valid != AUDITSC_INVALID)
result = audit_comparator(ctx->return_code, f->op, f->val);
break;
case AUDIT_SUCCESS:
- if (ctx && ctx->return_valid) {
+ if (ctx && ctx->return_valid != AUDITSC_INVALID) {
if (f->val)
result = audit_comparator(ctx->return_valid, f->op, AUDITSC_SUCCESS);
else
@@ -930,6 +928,7 @@ static inline struct audit_context *audit_alloc_context(enum audit_state state)
INIT_LIST_HEAD(&context->killed_trees);
INIT_LIST_HEAD(&context->names_list);
context->fds[0] = -1;
+ context->return_valid = AUDITSC_INVALID;
return context;
}

@@ -1488,7 +1487,7 @@ static void audit_log_exit(void)
context->arch, context->major);
if (context->personality != PER_LINUX)
audit_log_format(ab, " per=%lx", context->personality);
- if (context->return_valid)
+ if (context->return_valid != AUDITSC_INVALID)
audit_log_format(ab, " success=%s exit=%ld",
(context->return_valid==AUDITSC_SUCCESS)?"yes":"no",
context->return_code);
@@ -1625,7 +1624,7 @@ void __audit_free(struct task_struct *tsk)
* need to log via audit_log_exit().
*/
if (tsk == current && !context->dummy && context->in_syscall) {
- context->return_valid = 0;
+ context->return_valid = AUDITSC_INVALID;
context->return_code = 0;

audit_filter_syscall(tsk, context,
--
1.8.3.1

2020-11-25 04:35:37

by Paul Moore

[permalink] [raw]
Subject: Re: [PATCH] audit: remove unused macros

On Wed, Nov 11, 2020 at 7:38 PM Alex Shi <[email protected]> wrote:
> From 5fef5f1b7b745b52bedc9c7eec9fc163202ad421 Mon Sep 17 00:00:00 2001
> From: Alex Shi <[email protected]>
> Date: Fri, 6 Nov 2020 16:31:22 +0800
> Subject: [PATCH v3] audit: fix macros warnings
>
> Some unused macros could cause gcc warning:
> kernel/audit.c:68:0: warning: macro "AUDIT_UNINITIALIZED" is not used
> [-Wunused-macros]
> kernel/auditsc.c:104:0: warning: macro "AUDIT_AUX_IPCPERM" is not used
> [-Wunused-macros]
> kernel/auditsc.c:82:0: warning: macro "AUDITSC_INVALID" is not used
> [-Wunused-macros]
>
> AUDIT_UNINITIALIZED and AUDITSC_INVALID are still meaningful and should
> be in incorporated.
>
> Just remove AUDIT_AUX_IPCPERM.
>
> Thanks comments from Richard Guy Briggs and Paul Moore.
>
> Signed-off-by: Alex Shi <[email protected]>
> Cc: Paul Moore <[email protected]>
> Cc: Richard Guy Briggs <[email protected]>
> Cc: Eric Paris <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> kernel/audit.c | 2 +-
> kernel/auditsc.c | 11 +++++------
> 2 files changed, 6 insertions(+), 7 deletions(-)

Sorry for the delay, this was buried in my inbox but I've just merged
it into audit/next. Thanks for your help and patience with this!

--
paul moore
http://www.paul-moore.com