lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9rsTirs9lLfEPD9@lx-t490>
Date: Wed, 19 Mar 2025 17:09:50 +0100
From: "Ahmed S. Darwish" <darwi@...utronix.de>
To: kernel test robot <lkp@...el.com>
Cc: Ingo Molnar <mingo@...hat.com>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	Borislav Petkov <bp@...en8.de>, oe-kbuild-all@...ts.linux.dev,
	Thomas Gleixner <tglx@...utronix.de>,
	Andrew Cooper <andrew.cooper3@...rix.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	John Ogness <john.ogness@...utronix.de>, x86@...nel.org,
	x86-cpuid@...ts.linux.dev, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 18/29] x86/cacheinfo: Use enums for cache descriptor
 types

Hi,

On Wed, 19 Mar 2025, kernel test robot wrote:
>
> arch/x86/include/asm/cpuid/types.h:56:1: sparse: sparse:
>   static assertion failed: "sizeof(enum _cache_table_type) == 1"
>

I've checked the error report and reproduced it on my machine:

    https://download.01.org/0day-ci/archive/20250319/202503192150.Vhannmnp-lkp@intel.com/reproduce

After cloning sparse git repo and playing around with its validation test
suite, I've realized that it does not understand __attribiute__((packed))
on enums.

Namely, applying below diff on top of sparse's git repo:

    |  diff --git a/validation/enum-min-size.c b/validation/enum-min-size.c
    |  index e8bd9fb1..e691b332 100644
    |  --- a/validation/enum-min-size.c
    |  +++ b/validation/enum-min-size.c
    |  @@ -1,5 +1,9 @@
    |   enum i { I = 1 };
    |   _Static_assert(sizeof(enum i) == sizeof(int), "int");
    |  +
    |  +enum k { X = 0} __attribute__((packed));
    |  +_Static_assert(sizeof(enum k) == sizeof(char), "char");
    |  +
    |   enum u { U = 1U };
    |   _Static_assert(sizeof(enum u) == sizeof(int), "uint");

Then running the modified test:

    sparse/$ cd validation
    sparse/validation$ ./test-suite enum-min-size.c

leads to the same error:

    TEST    enum-min-size (enum-min-size.c)
    +enum-min-size.c:5:31: error: static assertion failed: "char"
    error: FAIL: test 'enum-min-size.c' failed

After checking other kernel code which have __packed on enums, I found
this at <linux/rw_hint.h>, which is included by core SCSI code:

    /* Sparse ignores __packed annotations on enums, hence the #ifndef below. */
    #ifndef __CHECKER__
    static_assert(sizeof(enum rw_hint) == 1);
    #endif

So I'll add a similar CPP guard (in v4, since I've already posted v3.)

Thanks!

--
Ahmed S. Darwish
Linutronix GmbH

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ