public inbox for [email protected]
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <[email protected]>
To: kernel test robot <[email protected]>
Cc: [email protected],
	GNU/Weeb Mailing List <[email protected]>,
	[email protected]
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
Date: Mon, 7 Feb 2022 16:28:06 -0800	[thread overview]
Message-ID: <20220208002806.GJ4285@paulmck-ThinkPad-P17-Gen-1> (raw)
In-Reply-To: <[email protected]>

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/[email protected]/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 <[email protected]>
> 
> 
> 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/[email protected]

      reply	other threads:[~2022-02-08  0:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07  1:23 [ammarfaizi2-block:paulmck/linux-rcu/dev 18/18] mm/slab_common.c:336:23: sparse: sparse: restricted slab_flags_t degrades to integer kernel test robot
2022-02-08  0:28 ` Paul E. McKenney [this message]

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=20220208002806.GJ4285@paulmck-ThinkPad-P17-Gen-1 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox