mm/kfence/core.c:329:34: sparse: sparse: cast to restricted __le64

From: kernel test robot
Date: Thu Nov 02 2023 - 09:58:09 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 21e80f3841c01aeaf32d7aee7bbc87b3db1aa0c6
commit: 7581495ac82d6cb073609284c7f7186a48021d1e mm: kfence: fix false positives on big endian
date: 6 months ago
config: s390-randconfig-r113-20231102 (https://download.01.org/0day-ci/archive/20231102/202311022155.9hNK2VJO-lkp@xxxxxxxxx/config)
compiler: s390-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231102/202311022155.9hNK2VJO-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311022155.9hNK2VJO-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> mm/kfence/core.c:329:34: sparse: sparse: cast to restricted __le64
mm/kfence/core.c:333:34: sparse: sparse: cast to restricted __le64
mm/kfence/core.c:352:21: sparse: sparse: cast to restricted __le64
mm/kfence/core.c:372:21: sparse: sparse: cast to restricted __le64
mm/kfence/core.c:1181:9: sparse: sparse: context imbalance in 'kfence_handle_page_fault' - different lock contexts for basic block

vim +329 mm/kfence/core.c

0ce20dd840897b Alexander Potapenko 2021-02-25 318
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 319 static inline void set_canary(const struct kfence_metadata *meta)
0ce20dd840897b Alexander Potapenko 2021-02-25 320 {
0ce20dd840897b Alexander Potapenko 2021-02-25 321 const unsigned long pageaddr = ALIGN_DOWN(meta->addr, PAGE_SIZE);
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 322 unsigned long addr = pageaddr;
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 323
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 324 /*
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 325 * The canary may be written to part of the object memory, but it does
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 326 * not affect it. The user should initialize the object before using it.
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 327 */
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 328 for (; addr < meta->addr; addr += sizeof(u64))
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 @329 *((u64 *)addr) = KFENCE_CANARY_PATTERN_U64;
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 330
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 331 addr = ALIGN_DOWN(meta->addr + meta->size, sizeof(u64));
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 332 for (; addr - pageaddr < PAGE_SIZE; addr += sizeof(u64))
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 333 *((u64 *)addr) = KFENCE_CANARY_PATTERN_U64;
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 334 }
1ba3cbf3ec3b21 Peng Zhang 2023-04-03 335

:::::: The code at line 329 was first introduced by commit
:::::: 1ba3cbf3ec3b21d866436fb46b4bb7bdc38608f9 mm: kfence: improve the performance of __kfence_alloc() and __kfence_free()

:::::: TO: Peng Zhang <zhangpeng.00@xxxxxxxxxxxxx>
:::::: CC: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki