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] [day] [month] [year] [list]
Date:   Mon, 7 Feb 2022 16:28:06 -0800
From:   "Paul E. McKenney" <paulmck@...nel.org>
To:     kernel test robot <lkp@...el.com>
Cc:     kbuild-all@...ts.01.org,
        GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [ammarfaizi2-block:paulmck/linux-rcu/dev 18/18]
 mm/slab_common.c:336:23: sparse: sparse: restricted slab_flags_t degrades to
 integer

On Mon, Feb 07, 2022 at 09:23:47AM +0800, kernel test robot wrote:
> tree:   https://github.com/ammarfaizi2/linux-block paulmck/linux-rcu/dev
> head:   e6e0d15aa1c5117dda15eb266e8b862627af7608
> commit: e6e0d15aa1c5117dda15eb266e8b862627af7608 [18/18] mm: Check for SLAB_TYPESAFE_BY_RCU and __GFP_ZERO slab creation
> config: m68k-randconfig-s032-20220206 (https://download.01.org/0day-ci/archive/20220207/202202070951.I9Vhb0aQ-lkp@intel.com/config)
> compiler: m68k-linux-gcc (GCC) 11.2.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-dirty
>         # https://github.com/ammarfaizi2/linux-block/commit/e6e0d15aa1c5117dda15eb266e8b862627af7608
>         git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
>         git fetch --no-tags ammarfaizi2-block paulmck/linux-rcu/dev
>         git checkout e6e0d15aa1c5117dda15eb266e8b862627af7608
>         # save the config file to linux build tree
>         mkdir build_dir
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=m68k SHELL=/bin/bash
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@...el.com>
> 
> 
> sparse warnings: (new ones prefixed by >>)
> >> mm/slab_common.c:336:23: sparse: sparse: restricted slab_flags_t degrades to integer
> >> mm/slab_common.c:336:46: sparse: sparse: restricted gfp_t degrades to integer

Good catch!  I really did get the various flags confused.  :-/

Will fix with attribution.

							Thanx, Paul

>    mm/slab_common.c:336:14: sparse: sparse: restricted slab_flags_t degrades to integer
>    mm/slab_common.c:336:63: sparse: sparse: restricted slab_flags_t degrades to integer
>    mm/slab_common.c:336:86: sparse: sparse: restricted gfp_t degrades to integer
> 
> vim +336 mm/slab_common.c
> 
>    321	
>    322		mutex_lock(&slab_mutex);
>    323	
>    324		err = kmem_cache_sanity_check(name, size);
>    325		if (err) {
>    326			goto out_unlock;
>    327		}
>    328	
>    329		/* Refuse requests with allocator specific flags */
>    330		if (flags & ~SLAB_FLAGS_PERMITTED) {
>    331			err = -EINVAL;
>    332			goto out_unlock;
>    333		}
>    334	
>    335		/* References to typesafe memory survives free/alloc. */
>  > 336		if ((flags & (SLAB_TYPESAFE_BY_RCU | __GFP_ZERO)) == (SLAB_TYPESAFE_BY_RCU | __GFP_ZERO)) {
>    337			err = -EINVAL;
>    338			goto out_unlock;
>    339		}
>    340	
>    341		/*
>    342		 * Some allocators will constraint the set of valid flags to a subset
>    343		 * of all flags. We expect them to define CACHE_CREATE_MASK in this
>    344		 * case, and we'll just provide them with a sanitized version of the
>    345		 * passed flags.
>    346		 */
>    347		flags &= CACHE_CREATE_MASK;
>    348	
>    349		/* Fail closed on bad usersize of useroffset values. */
>    350		if (WARN_ON(!usersize && useroffset) ||
>    351		    WARN_ON(size < usersize || size - usersize < useroffset))
>    352			usersize = useroffset = 0;
>    353	
>    354		if (!usersize)
>    355			s = __kmem_cache_alias(name, size, align, flags, ctor);
>    356		if (s)
>    357			goto out_unlock;
>    358	
>    359		cache_name = kstrdup_const(name, GFP_KERNEL);
>    360		if (!cache_name) {
>    361			err = -ENOMEM;
>    362			goto out_unlock;
>    363		}
>    364	
>    365		s = create_cache(cache_name, size,
>    366				 calculate_alignment(flags, align, size),
>    367				 flags, useroffset, usersize, ctor, NULL);
>    368		if (IS_ERR(s)) {
>    369			err = PTR_ERR(s);
>    370			kfree_const(cache_name);
>    371		}
>    372	
>    373	out_unlock:
>    374		mutex_unlock(&slab_mutex);
>    375	
>    376		if (err) {
>    377			if (flags & SLAB_PANIC)
>    378				panic("%s: Failed to create slab '%s'. Error %d\n",
>    379					__func__, name, err);
>    380			else {
>    381				pr_warn("%s(%s) failed with error %d\n",
>    382					__func__, name, err);
>    383				dump_stack();
>    384			}
>    385			return NULL;
>    386		}
>    387		return s;
>    388	}
>    389	EXPORT_SYMBOL(kmem_cache_create_usercopy);
>    390	
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ