From: Richard Guy Briggs <rgb@redhat.com>
To: Alex Shi <alex.shi@linux.alibaba.com>
Cc: Paul Moore <paul@paul-moore.com>,
linux-audit@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] audit: remove unused macros
Date: Wed, 11 Nov 2020 08:17:59 -0500 [thread overview]
Message-ID: <20201111131759.GD55072@madcap2.tricolour.ca> (raw)
In-Reply-To: <bae6d2fa-64d9-623b-6729-3827d745ed7a@linux.alibaba.com>
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 <alex.shi@linux.alibaba.com>
> 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 <alex.shi@linux.alibaba.com>
> Cc: Paul Moore <paul@paul-moore.com>
> Cc: Eric Paris <eparis@redhat.com>
> Cc: linux-audit@redhat.com
> Cc: linux-kernel@vger.kernel.org
> ---
> 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 <rgb@redhat.com>
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
next prev parent reply other threads:[~2020-11-11 13:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-06 8:31 Alex Shi
2020-11-10 15:23 ` Richard Guy Briggs
2020-11-11 2:47 ` Paul Moore
2020-11-11 3:03 ` Richard Guy Briggs
2020-11-11 6:19 ` Alex Shi
2020-11-11 13:17 ` Richard Guy Briggs [this message]
2020-11-12 0:36 ` Alex Shi
2020-11-25 4:31 ` Paul Moore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201111131759.GD55072@madcap2.tricolour.ca \
--to=rgb@redhat.com \
--cc=alex.shi@linux.alibaba.com \
--cc=linux-audit@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@paul-moore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®