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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2e548eae-f851-44ce-b0e5-963bc5f47e35@yandex.ru>
Date:   Wed, 15 Nov 2023 14:16:43 +0300
From:   Dmitry Antipov <dmantipov@...dex.ru>
To:     oe-kbuild-all@...ts.linux.dev
Cc:     linux-kernel@...r.kernel.org, Kalle Valo <quic_kvalo@...cinc.com>
Subject: GCC/ARM experts wanted [Was: Re:
 include/linux/compiler_types.h:397:45: error: call to
 '__compiletime_assert_460' declared with attribute error: BUILD_BUG_ON
 failed: sizeof(vring->va[0]) != 32]

On 11/15/23 03:49, kernel test robot wrote:

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   9bacdd8996c77c42ca004440be610692275ff9d0
> commit: 1ad8237e971630c66a1a6194491e0837b64d00e0 wifi: wil6210: fix fortify warnings
> date:   4 months ago
> config: arm-buildonly-randconfig-r003-20220914 (https://download.01.org/0day-ci/archive/20231115/202311150821.cI4yciFE-lkp@intel.com/config)
> compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231115/202311150821.cI4yciFE-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@...el.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202311150821.cI4yciFE-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
>     In file included from <command-line>:
>     drivers/net/wireless/ath/wil6210/txrx.c: In function 'wil_vring_alloc':
>>> include/linux/compiler_types.h:397:45: error: call to '__compiletime_assert_460' declared with attribute error: BUILD_BUG_ON failed: sizeof(vring->va[0]) != 32
>       397 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>           |                                             ^
>     include/linux/compiler_types.h:378:25: note: in definition of macro '__compiletime_assert'
>       378 |                         prefix ## suffix();                             \
>           |                         ^~~~~~
>     include/linux/compiler_types.h:397:9: note: in expansion of macro '_compiletime_assert'
>       397 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>           |         ^~~~~~~~~~~~~~~~~~~
>     include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
>        39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>           |                                     ^~~~~~~~~~~~~~~~~~
>     include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
>        50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
>           |         ^~~~~~~~~~~~~~~~
>     drivers/net/wireless/ath/wil6210/txrx.c:118:9: note: in expansion of macro 'BUILD_BUG_ON'
>       118 |         BUILD_BUG_ON(sizeof(vring->va[0]) != 32);
>           |         ^~~~~~~~~~~~
> --
>     In file included from <command-line>:
>     drivers/net/wireless/ath/wil6210/txrx_edma.c: In function 'wil_ring_alloc_desc_ring':
>>> include/linux/compiler_types.h:397:45: error: call to '__compiletime_assert_452' declared with attribute error: BUILD_BUG_ON failed: sizeof(ring->va[0]) != 32
>       397 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>           |                                             ^
>     include/linux/compiler_types.h:378:25: note: in definition of macro '__compiletime_assert'
>       378 |                         prefix ## suffix();                             \
>           |                         ^~~~~~
>     include/linux/compiler_types.h:397:9: note: in expansion of macro '_compiletime_assert'
>       397 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>           |         ^~~~~~~~~~~~~~~~~~~
>     include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
>        39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>           |                                     ^~~~~~~~~~~~~~~~~~
>     include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
>        50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
>           |         ^~~~~~~~~~~~~~~~
>     drivers/net/wireless/ath/wil6210/txrx_edma.c:381:9: note: in expansion of macro 'BUILD_BUG_ON'
>       381 |         BUILD_BUG_ON(sizeof(ring->va[0]) != 32);
>           |         ^~~~~~~~~~~~
> 
> 
> vim +/__compiletime_assert_460 +397 include/linux/compiler_types.h
> 
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  383
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  384  #define _compiletime_assert(condition, msg, prefix, suffix) \
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  385  	__compiletime_assert(condition, msg, prefix, suffix)
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  386
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  387  /**
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  388   * compiletime_assert - break build and emit msg if condition is false
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  389   * @condition: a compile-time constant condition to check
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  390   * @msg:       a message to emit if condition is false
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  391   *
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  392   * In tradition of POSIX assert, this macro will break the build if the
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  393   * supplied condition is *false*, emitting the supplied error message if the
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  394   * compiler has support to do so.
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  395   */
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  396  #define compiletime_assert(condition, msg) \
> eb5c2d4b45e3d2 Will Deacon 2020-07-21 @397  	_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
> eb5c2d4b45e3d2 Will Deacon 2020-07-21  398
> 
> :::::: The code at line 397 was first introduced by commit
> :::::: eb5c2d4b45e3d2d5d052ea6b8f1463976b1020d5 compiler.h: Move compiletime_assert() macros into compiler_types.h
> 
> :::::: TO: Will Deacon <will@...nel.org>
> :::::: CC: Will Deacon <will@...nel.org>

I've tracked this down to the following sample:

struct vring_tx_mac {
	unsigned int d[3];
	unsigned int ucode_cmd;
} __attribute__((packed));

struct vring_rx_mac {
	unsigned int d0;
	unsigned int d1;
	unsigned short w4;
	union { struct { unsigned short pn_15_0; unsigned int pn_47_16; } __attribute__((__packed__));
		struct { unsigned short pn_15_0; unsigned int pn_47_16; } __attribute__((__packed__)) pn;
	};
} __attribute__((packed));

struct wil_ring_dma_addr {
	unsigned int addr_low;
	unsigned short addr_high;
} __attribute__((packed));

struct vring_tx_dma {
	unsigned int d0;
	struct wil_ring_dma_addr addr;
	unsigned char  ip_length;
	unsigned char  b11;       /* 0..6: mac_length; 7:ip_version */
	unsigned char  error;     /* 0..2: err; 3..7: reserved; */
	unsigned char  status;    /* 0: used; 1..7; reserved */
	unsigned short length;
} __packed;

struct vring_tx_desc {
	struct vring_tx_mac mac;
	struct vring_tx_dma dma;
} __attribute__((packed));

struct wil_ring_tx_enhanced_mac {
	unsigned int d[3];
	unsigned short tso_mss;
	unsigned short scratchpad;
} __attribute__((packed));

struct wil_ring_tx_enhanced_dma {
	unsigned char l4_hdr_len;
	unsigned char cmd;
	unsigned short w1;
	struct wil_ring_dma_addr addr;
	unsigned char  ip_length;
	unsigned char  b11;       /* 0..6: mac_length; 7:ip_version */
	unsigned short addr_high_high;
	unsigned short length;
} __attribute__((packed));

struct wil_tx_enhanced_desc {
	struct wil_ring_tx_enhanced_mac mac;
	struct wil_ring_tx_enhanced_dma dma;
} __attribute__((packed));

union wil_tx_desc {
	struct vring_tx_desc legacy;
	struct wil_tx_enhanced_desc enhanced;
} __attribute__((packed));

struct vring_rx_dma {
	unsigned int d0;
	struct wil_ring_dma_addr addr;
	unsigned char  ip_length;
	unsigned char  b11;
	unsigned char  error;
	unsigned char  status;
	unsigned short length;
} __attribute__((packed));

struct vring_rx_desc {
	struct vring_rx_mac mac;
	struct vring_rx_dma dma;
} __attribute__((packed));

struct wil_ring_rx_enhanced_mac {
	unsigned int d[3];
	unsigned short buff_id;
	unsigned short reserved;
} __attribute((packed));

struct wil_ring_rx_enhanced_dma {
	unsigned int d0;
	struct wil_ring_dma_addr addr;
	unsigned short w5;
	unsigned short addr_high_high;
	unsigned short length;
} __attribute((packed));

struct wil_rx_enhanced_desc {
	struct wil_ring_rx_enhanced_mac mac;
	struct wil_ring_rx_enhanced_dma dma;
} __attribute((packed));

union wil_rx_desc {
	struct vring_rx_desc legacy;
	struct wil_rx_enhanced_desc enhanced;
} __attribute__((packed));

union wil_ring_desc {
	union wil_tx_desc tx;
	union wil_rx_desc rx;
} __attribute__((packed));

int f (void) {
	return sizeof(union wil_ring_desc);
}

$ arm-linux-gnu-gcc -Os -c t-build-bug.c
$ arm-linux-gnu-objdump  -j .text -D t-build-bug.o

t-build-bug.o:     file format elf32-littlearm

Disassembly of section .text:

00000000 <f>:
    0:	e3a00020 	mov	r0, #32                         ;; OK
    4:	e12fff1e 	bx	lr

$ arm-linux-gnu-gcc -mlittle-endian -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -fno-dwarf2-cfi-asm -mno-fdpic -fno-omit-frame-pointer -mapcs -mno-sched-prolog 
-fno-ipa-sra -mabi=apcs-gnu -mno-thumb-interwork -marm -Wa,-mno-warn-deprecated -march=armv4 -mtune=xscale -msoft-float -Uarm -fno-delete-null-pointer-checks -Os -fno-allow-store-data-races 
-fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining -fno-stack-protector -fno-omit-frame-pointer -fno-optimize-sibling-calls -ftrivial-auto-var-init=zero -fno-stack-clash-protection -pg 
-fno-inline-functions-called-once -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fsanitize=kernel-address -fasan-shadow-offset=0x1f000000 --param asan-globals=1 --param 
asan-instrumentation-with-call-threshold=10000 --param asan-instrument-allocas=1 --param asan-stack=1 --param asan-kernel-mem-intrinsic-prefix=1 -c t-build-bug.c
$ arm-linux-gnu-objdump  -j .text -D t-build-bug.o

t-build-bug.o:     file format elf32-littlearm

Disassembly of section .text:

00000000 <f>:
    0:	e1a0c00d 	mov	ip, sp
    4:	e92dd800 	push	{fp, ip, lr, pc}
    8:	e24cb004 	sub	fp, ip, #4
    c:	e52de004 	push	{lr}		@ (str lr, [sp, #-4]!)
   10:	ebfffffe 	bl	0 <__gnu_mcount_nc>
   14:	e3a00022 	mov	r0, #34	@ 0x22                  ;; OOPS
   18:	e89da800 	ldm	sp, {fp, sp, pc}

Now it's time for advice from GCC/ARM experts.

Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ