[linux-next:master 2432/2827] fs/ntfs3/fslog.c:520:27: sparse: sparse: restricted __le32 degrades to integer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   41d66f96d0f15a0a2ad6fa2208f6bac1a66cbd52
commit: 1b7dd28e14c4728ae1a815605ca33ffb4ce1b309 [2432/2827] fs/ntfs3: Correct function is_rst_area_valid
config: x86_64-randconfig-121-20240130 (https://download.01.org/0day-ci/archive/20240130/202401302158.oKXhk0gV-lkp@xxxxxxxxx/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240130/202401302158.oKXhk0gV-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/202401302158.oKXhk0gV-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> fs/ntfs3/fslog.c:520:27: sparse: sparse: restricted __le32 degrades to integer

vim +520 fs/ntfs3/fslog.c

   463	
   464	static inline bool is_rst_area_valid(const struct RESTART_HDR *rhdr)
   465	{
   466		const struct RESTART_AREA *ra;
   467		u16 cl, fl, ul;
   468		u32 off, l_size, seq_bits;
   469		u16 ro = le16_to_cpu(rhdr->ra_off);
   470		u32 sys_page = le32_to_cpu(rhdr->sys_page_size);
   471	
   472		if (ro + offsetof(struct RESTART_AREA, l_size) >
   473		    SECTOR_SIZE - sizeof(short))
   474			return false;
   475	
   476		ra = Add2Ptr(rhdr, ro);
   477		cl = le16_to_cpu(ra->log_clients);
   478	
   479		if (cl > 1)
   480			return false;
   481	
   482		off = le16_to_cpu(ra->client_off);
   483	
   484		if (!IS_ALIGNED(off, 8) || ro + off > SECTOR_SIZE - sizeof(short))
   485			return false;
   486	
   487		off += cl * sizeof(struct CLIENT_REC);
   488	
   489		if (off > sys_page)
   490			return false;
   491	
   492		/*
   493		 * Check the restart length field and whether the entire
   494		 * restart area is contained that length.
   495		 */
   496		if (le16_to_cpu(rhdr->ra_off) + le16_to_cpu(ra->ra_len) > sys_page ||
   497		    off > le16_to_cpu(ra->ra_len)) {
   498			return false;
   499		}
   500	
   501		/*
   502		 * As a final check make sure that the use list and the free list
   503		 * are either empty or point to a valid client.
   504		 */
   505		fl = le16_to_cpu(ra->client_idx[0]);
   506		ul = le16_to_cpu(ra->client_idx[1]);
   507		if ((fl != LFS_NO_CLIENT && fl >= cl) ||
   508		    (ul != LFS_NO_CLIENT && ul >= cl))
   509			return false;
   510	
   511		/* Make sure the sequence number bits match the log file size. */
   512		l_size = le64_to_cpu(ra->l_size);
   513	
   514		seq_bits = sizeof(u64) * 8 + 3;
   515		while (l_size) {
   516			l_size >>= 1;
   517			seq_bits -= 1;
   518		}
   519	
 > 520		if (seq_bits != ra->seq_num_bits)
   521			return false;
   522	
   523		/* The log page data offset and record header length must be quad-aligned. */
   524		if (!IS_ALIGNED(le16_to_cpu(ra->data_off), 8) ||
   525		    !IS_ALIGNED(le16_to_cpu(ra->rec_hdr_len), 8))
   526			return false;
   527	
   528		return true;
   529	}
   530	

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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux