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>] [day] [month] [year] [list]
Message-ID: <202212061543.dGjpdNj4-lkp@intel.com>
Date:   Tue, 6 Dec 2022 15:10:40 +0800
From:   kernel test robot <lkp@...el.com>
To:     Gao Xiang <hsiangkao@...ux.alibaba.com>
Cc:     oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
        Yue Hu <huyue2@...lpad.com>, Chao Yu <yuchao0@...wei.com>,
        Chao Yu <chao@...nel.org>
Subject: include/asm-generic/cmpxchg-local.h:30:42: sparse: sparse: cast
 truncates bits from constant value (e0f510cc becomes cc)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   bce9332220bd677d83b19d21502776ad555a0e73
commit: 2f44013e39984c127c6efedf70e6b5f4e9dcf315 erofs: fix pcluster use-after-free on UP platforms
date:   3 months ago
config: nios2-randconfig-s053-20221205
compiler: nios2-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2f44013e39984c127c6efedf70e6b5f4e9dcf315
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 2f44013e39984c127c6efedf70e6b5f4e9dcf315
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2 SHELL=/bin/bash fs/erofs/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>

sparse warnings: (new ones prefixed by >>)
   fs/erofs/utils.c: note: in included file (through include/asm-generic/cmpxchg.h, arch/nios2/include/generated/asm/cmpxchg.h, include/asm-generic/atomic.h, ...):
>> include/asm-generic/cmpxchg-local.h:30:42: sparse: sparse: cast truncates bits from constant value (e0f510cc becomes cc)
>> include/asm-generic/cmpxchg-local.h:34:44: sparse: sparse: cast truncates bits from constant value (e0f510cc becomes 10cc)
--
   fs/erofs/zdata.c: note: in included file (through include/asm-generic/cmpxchg.h, arch/nios2/include/generated/asm/cmpxchg.h, include/asm-generic/atomic.h, ...):
>> include/asm-generic/cmpxchg-local.h:30:42: sparse: sparse: cast truncates bits from constant value (e0f510cc becomes cc)
>> include/asm-generic/cmpxchg-local.h:34:44: sparse: sparse: cast truncates bits from constant value (e0f510cc becomes 10cc)
   include/asm-generic/cmpxchg-local.h:30:42: sparse: sparse: cast truncates bits from constant value (5f0edead becomes ad)
   include/asm-generic/cmpxchg-local.h:34:44: sparse: sparse: cast truncates bits from constant value (5f0edead becomes dead)

vim +30 include/asm-generic/cmpxchg-local.h

068fbad288a2c1 Mathieu Desnoyers 2008-02-07   7  
aa93685afbefa0 Behan Webster     2012-11-20   8  extern unsigned long wrong_size_cmpxchg(volatile void *ptr)
aa93685afbefa0 Behan Webster     2012-11-20   9  	__noreturn;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  10  
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  11  /*
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  12   * Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  13   * long parameter, supporting various types of architectures.
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  14   */
6988631bdfddce Mark Rutland      2021-05-25  15  static inline unsigned long __generic_cmpxchg_local(volatile void *ptr,
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  16  		unsigned long old, unsigned long new, int size)
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  17  {
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  18  	unsigned long flags, prev;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  19  
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  20  	/*
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  21  	 * Sanity checking, compile-time.
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  22  	 */
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  23  	if (size == 8 && sizeof(unsigned long) != 8)
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  24  		wrong_size_cmpxchg(ptr);
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  25  
5042afe7fe3239 Ingo Molnar       2009-07-03  26  	raw_local_irq_save(flags);
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  27  	switch (size) {
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  28  	case 1: prev = *(u8 *)ptr;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  29  		if (prev == old)
068fbad288a2c1 Mathieu Desnoyers 2008-02-07 @30  			*(u8 *)ptr = (u8)new;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  31  		break;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  32  	case 2: prev = *(u16 *)ptr;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  33  		if (prev == old)
068fbad288a2c1 Mathieu Desnoyers 2008-02-07 @34  			*(u16 *)ptr = (u16)new;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  35  		break;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  36  	case 4: prev = *(u32 *)ptr;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  37  		if (prev == old)
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  38  			*(u32 *)ptr = (u32)new;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  39  		break;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  40  	case 8: prev = *(u64 *)ptr;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  41  		if (prev == old)
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  42  			*(u64 *)ptr = (u64)new;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  43  		break;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  44  	default:
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  45  		wrong_size_cmpxchg(ptr);
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  46  	}
5042afe7fe3239 Ingo Molnar       2009-07-03  47  	raw_local_irq_restore(flags);
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  48  	return prev;
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  49  }
068fbad288a2c1 Mathieu Desnoyers 2008-02-07  50  

:::::: The code at line 30 was first introduced by commit
:::::: 068fbad288a2c18b75b0425fb56d241f018a1cb5 Add cmpxchg_local to asm-generic for per cpu atomic operations

:::::: TO: Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
:::::: CC: Linus Torvalds <torvalds@...dy.linux-foundation.org>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

View attachment "config" of type "text/plain" (149482 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ