All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: kernel test robot <lkp@intel.com>
Cc: oe-kbuild-all@lists.linux.dev
Subject: Re: [kees:dev/v7.0-rc2/obt 6/6] drivers/misc/lkdtm/bugs.c:835:17: sparse: sparse: cast truncates bits from constant value (7fffffff becomes ff)
Date: Tue, 31 Mar 2026 12:48:00 -0700	[thread overview]
Message-ID: <202603311247.F1B3A67@keescook> (raw)
In-Reply-To: <202604010149.X24fVPZ0-lkp@intel.com>

On Wed, Apr 01, 2026 at 02:06:25AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git dev/v7.0-rc2/obt
> head:   e5a10c0ef1457ad3c713a1bbe087da2b407d4722
> commit: e5a10c0ef1457ad3c713a1bbe087da2b407d4722 [6/6] lkdtm/bugs: Add basic Overflow Behavior Types test
> config: arc-randconfig-r121-20260331 (https://download.01.org/0day-ci/archive/20260401/202604010149.X24fVPZ0-lkp@intel.com/config)
> compiler: arc-linux-gcc (GCC) 8.5.0
> sparse: v0.6.5-rc1
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260401/202604010149.X24fVPZ0-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@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202604010149.X24fVPZ0-lkp@intel.com/
> 
> sparse warnings: (new ones prefixed by >>)
> >> drivers/misc/lkdtm/bugs.c:835:17: sparse: sparse: cast truncates bits from constant value (7fffffff becomes ff)

This is by design. What's the right way to make sparse ignore a value
like this? (It appears to be seeing through the "volatile" qualifier.)

-Kees

> 
> vim +835 drivers/misc/lkdtm/bugs.c
> 
>    819	
>    820	static void lkdtm_OBT_TRUNC_TRAP(void)
>    821	{
>    822		volatile int big = INT_MAX;
>    823		volatile int wide_low_value = 5;
>    824		u8t narrow_low_value = 0;
>    825		s32t same = 0;
>    826		u8t small = 0;
>    827	
>    828		pr_info("Performing same-width assignment\n");
>    829		same = big;
>    830	
>    831		pr_info("Performing small-value assignment\n");
>    832		narrow_low_value = wide_low_value;
>    833	
>    834		pr_info("Performing truncated assignment\n");
>  > 835		small = big;
>    836	
>    837		pr_info("FAIL: survived overflowing truncated assignment: %d -> %u (ok: %d -> %u)\n",
>    838			same, small, wide_low_value, narrow_low_value);
>    839		pr_expected_config(OVERFLOW_BEHAVIOR_TYPES_TRAP);
>    840	}
>    841	
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki

-- 
Kees Cook

      reply	other threads:[~2026-03-31 19:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 18:06 [kees:dev/v7.0-rc2/obt 6/6] drivers/misc/lkdtm/bugs.c:835:17: sparse: sparse: cast truncates bits from constant value (7fffffff becomes ff) kernel test robot
2026-03-31 19:48 ` Kees Cook [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=202603311247.F1B3A67@keescook \
    --to=kees@kernel.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.