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>] [day] [month] [year] [list]
Message-ID: <202205082233.0Gm8B7A4-lkp@intel.com>
Date:   Mon, 9 May 2022 14:16:48 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org, Hawking Zhang <Hawking.Zhang@....com>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org,
        Alex Deucher <alexander.deucher@....com>,
        Wenhui Sheng <Wenhui.Sheng@....com>
Subject: [agd5f:drm-next 429/599] drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:1278
 gfx_v11_0_rlc_backdoor_autoload_copy_ucode() warn: should '1 << id' be a 64
 bit type?

tree:   https://gitlab.freedesktop.org/agd5f/linux.git drm-next
head:   3170f5f234272247989fafee4cba4cbbc822631c
commit: 3d879e81f0f9ed5d33b5eda0fe5226c884bb8073 [429/599] drm/amdgpu: add init support for GFX11 (v2)
config: csky-randconfig-m031-20220508 (https://download.01.org/0day-ci/archive/20220508/202205082233.0Gm8B7A4-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 11.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>

smatch warnings:
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:1278 gfx_v11_0_rlc_backdoor_autoload_copy_ucode() warn: should '1 << id' be a 64 bit type?

vim +1278 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c

3d879e81f0f9ed Hawking Zhang 2022-04-13  1250  static void gfx_v11_0_rlc_backdoor_autoload_copy_ucode(struct amdgpu_device *adev,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1251  					      SOC21_FIRMWARE_ID id,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1252  			    		      const void *fw_data,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1253  					      uint32_t fw_size,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1254  					      uint32_t *fw_autoload_mask)

It would be cleaner to just declare fw_autoload_mask as a u64.  I
reviewed the code to see why it's a u32 and could not see a reason.

3d879e81f0f9ed Hawking Zhang 2022-04-13  1255  {
3d879e81f0f9ed Hawking Zhang 2022-04-13  1256  	uint32_t toc_offset;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1257  	uint32_t toc_fw_size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1258  	char *ptr = adev->gfx.rlc.rlc_autoload_ptr;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1259  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1260  	if (id <= SOC21_FIRMWARE_ID_INVALID || id >= SOC21_FIRMWARE_ID_MAX)

SOC21_FIRMWARE_ID_MAX is 37 which is more than 31 so this but is real.

3d879e81f0f9ed Hawking Zhang 2022-04-13  1261  		return;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1262  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1263  	toc_offset = rlc_autoload_info[id].offset;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1264  	toc_fw_size = rlc_autoload_info[id].size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1265  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1266  	if (fw_size == 0)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1267  		fw_size = toc_fw_size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1268  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1269  	if (fw_size > toc_fw_size)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1270  		fw_size = toc_fw_size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1271  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1272  	memcpy(ptr + toc_offset, fw_data, fw_size);
3d879e81f0f9ed Hawking Zhang 2022-04-13  1273  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1274  	if (fw_size < toc_fw_size)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1275  		memset(ptr + toc_offset + fw_size, 0, toc_fw_size - fw_size);
3d879e81f0f9ed Hawking Zhang 2022-04-13  1276  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1277  	if ((id != SOC21_FIRMWARE_ID_RS64_PFP) && (id != SOC21_FIRMWARE_ID_RS64_ME))
3d879e81f0f9ed Hawking Zhang 2022-04-13 @1278  		*(uint64_t *)fw_autoload_mask |= 1 << id;
                                                                                         ^^^^^^^^

This needs to be 1ULL < id.  Otherwise if id is >= 32 the shift will
wrap.

3d879e81f0f9ed Hawking Zhang 2022-04-13  1279  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ