All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Justin Stitt <justinstitt@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Tom Rix <trix@redhat.com>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] x86/audit: fix -Wmissing-variable-declarations warning for ia32_xyz_class
Date: Thu, 31 Aug 2023 14:11:32 -0700	[thread overview]
Message-ID: <202308311409.F4EC8BC674@keescook> (raw)
In-Reply-To: <20230829-missingvardecl-audit-v1-1-34efeb7f3539@google.com>

On Tue, Aug 29, 2023 at 10:33:16PM +0000, Justin Stitt wrote:
> When building x86 defconfig with Clang-18 I get the following warnings:
> | arch/x86/ia32/audit.c:6:10: warning: no previous extern declaration for non-static variable 'ia32_dir_class' [-Wmissing-variable-declarations]
> |     6 | unsigned ia32_dir_class[] = {
> | arch/x86/ia32/audit.c:11:10: warning: no previous extern declaration for non-static variable 'ia32_chattr_class' [-Wmissing-variable-declarations]
> |    11 | unsigned ia32_chattr_class[] = {
> | arch/x86/ia32/audit.c:16:10: warning: no previous extern declaration for non-static variable 'ia32_write_class' [-Wmissing-variable-declarations]
> |    16 | unsigned ia32_write_class[] = {
> | arch/x86/ia32/audit.c:21:10: warning: no previous extern declaration for non-static variable 'ia32_read_class' [-Wmissing-variable-declarations]
> |    21 | unsigned ia32_read_class[] = {
> | arch/x86/ia32/audit.c:26:10: warning: no previous extern declaration for non-static variable 'ia32_signal_class' [-Wmissing-variable-declarations]
> |    26 | unsigned ia32_signal_class[] = {
> 
> These warnings occur due to their respective extern declarations being
> scoped inside of audit_classes_init as well as only being enabled with
> `CONFIG_IA32_EMULATION=y`:
> | static int __init audit_classes_init(void)
> | {
> | #ifdef CONFIG_IA32_EMULATION
> | 	extern __u32 ia32_dir_class[];
> | 	extern __u32 ia32_write_class[];
> | 	extern __u32 ia32_read_class[];
> | 	extern __u32 ia32_chattr_class[];
> | 	audit_register_class(AUDIT_CLASS_WRITE_32, ia32_write_class);
> | 	audit_register_class(AUDIT_CLASS_READ_32, ia32_read_class);
> | 	audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ia32_dir_class);
> | 	audit_register_class(AUDIT_CLASS_CHATTR_32, ia32_chattr_class);
> | #endif
> | 	audit_register_class(AUDIT_CLASS_WRITE, write_class);
> | 	audit_register_class(AUDIT_CLASS_READ, read_class);
> | 	audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
> | 	audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
> | 	return 0;
> | }
> 
> Lift the extern declarations to their own header and resolve scoping
> issues (and thus fix the warnings).
> 
> Moreover, change __u32 to unsigned so that we match the definitions:
> | unsigned ia32_dir_class[] = {
> | #include <asm-generic/audit_dir_write.h>
> | ~0U
> | };
> |
> | unsigned ia32_chattr_class[] = {
> | #include <asm-generic/audit_change_attr.h>
> | ~0U
> | };
> | ...

I would expect checkpatch to warn about bare "unsigned", which is frown
on these days. :) I think __u32 should be fine here...? (Why is it __u32
instead of u32, btw?)

But otherwise, yes, looks good.

-Kees

-- 
Kees Cook

  parent reply	other threads:[~2023-08-31 21:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29 22:33 [PATCH] x86/audit: fix -Wmissing-variable-declarations warning for ia32_xyz_class Justin Stitt
2023-08-30  8:20 ` [tip: x86/urgent] x86/audit: Fix " tip-bot2 for Justin Stitt
2023-08-31 21:11 ` Kees Cook [this message]
2023-08-31 23:18   ` [PATCH] x86/audit: fix " Justin Stitt

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=202308311409.F4EC8BC674@keescook \
    --to=keescook@chromium.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=justinstitt@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mingo@redhat.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=tglx@linutronix.de \
    --cc=trix@redhat.com \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.