* drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1433 amdgpu_discovery_get_vcn_info() error: buffer overflow 'adev->vcn.vcn_codec_disable_mask' 2 <= 3
@ 2022-06-16 23:49 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-06-16 23:49 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 4318 bytes --]
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Alex Deucher <alexander.deucher@amd.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 48a23ec6ff2b2a5effe8d3ae5f17fc6b7f35df65
commit: 622469c87fc3e6c90a980be3e2287d82bd55c977 drm/amdgpu/discovery: add a function to parse the vcn info table
date: 7 weeks ago
:::::: branch date: 5 hours ago
:::::: commit date: 7 weeks ago
config: ia64-randconfig-m031-20220616 (https://download.01.org/0day-ci/archive/20220617/202206170749.3DE0MiWb-lkp(a)intel.com/config)
compiler: ia64-linux-gcc (GCC) 11.3.0
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1433 amdgpu_discovery_get_vcn_info() error: buffer overflow 'adev->vcn.vcn_codec_disable_mask' 2 <= 3
vim +1433 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
622469c87fc3e6 Alex Deucher 2022-03-30 1402
622469c87fc3e6 Alex Deucher 2022-03-30 1403 int amdgpu_discovery_get_vcn_info(struct amdgpu_device *adev)
622469c87fc3e6 Alex Deucher 2022-03-30 1404 {
622469c87fc3e6 Alex Deucher 2022-03-30 1405 struct binary_header *bhdr;
622469c87fc3e6 Alex Deucher 2022-03-30 1406 union vcn_info *vcn_info;
622469c87fc3e6 Alex Deucher 2022-03-30 1407 u16 offset;
622469c87fc3e6 Alex Deucher 2022-03-30 1408 int v;
622469c87fc3e6 Alex Deucher 2022-03-30 1409
622469c87fc3e6 Alex Deucher 2022-03-30 1410 if (!adev->mman.discovery_bin) {
622469c87fc3e6 Alex Deucher 2022-03-30 1411 DRM_ERROR("ip discovery uninitialized\n");
622469c87fc3e6 Alex Deucher 2022-03-30 1412 return -EINVAL;
622469c87fc3e6 Alex Deucher 2022-03-30 1413 }
622469c87fc3e6 Alex Deucher 2022-03-30 1414
622469c87fc3e6 Alex Deucher 2022-03-30 1415 if (adev->vcn.num_vcn_inst > VCN_INFO_TABLE_MAX_NUM_INSTANCES) {
622469c87fc3e6 Alex Deucher 2022-03-30 1416 dev_err(adev->dev, "invalid vcn instances\n");
622469c87fc3e6 Alex Deucher 2022-03-30 1417 return -EINVAL;
622469c87fc3e6 Alex Deucher 2022-03-30 1418 }
622469c87fc3e6 Alex Deucher 2022-03-30 1419
622469c87fc3e6 Alex Deucher 2022-03-30 1420 bhdr = (struct binary_header *)adev->mman.discovery_bin;
622469c87fc3e6 Alex Deucher 2022-03-30 1421 offset = le16_to_cpu(bhdr->table_list[VCN_INFO].offset);
622469c87fc3e6 Alex Deucher 2022-03-30 1422
622469c87fc3e6 Alex Deucher 2022-03-30 1423 if (!offset) {
622469c87fc3e6 Alex Deucher 2022-03-30 1424 dev_err(adev->dev, "invalid vcn table offset\n");
622469c87fc3e6 Alex Deucher 2022-03-30 1425 return -EINVAL;
622469c87fc3e6 Alex Deucher 2022-03-30 1426 }
622469c87fc3e6 Alex Deucher 2022-03-30 1427
622469c87fc3e6 Alex Deucher 2022-03-30 1428 vcn_info = (union vcn_info *)(adev->mman.discovery_bin + offset);
622469c87fc3e6 Alex Deucher 2022-03-30 1429
622469c87fc3e6 Alex Deucher 2022-03-30 1430 switch (le16_to_cpu(vcn_info->v1.header.version_major)) {
622469c87fc3e6 Alex Deucher 2022-03-30 1431 case 1:
622469c87fc3e6 Alex Deucher 2022-03-30 1432 for (v = 0; v < adev->vcn.num_vcn_inst; v++) {
622469c87fc3e6 Alex Deucher 2022-03-30 @1433 adev->vcn.vcn_codec_disable_mask[v] =
622469c87fc3e6 Alex Deucher 2022-03-30 1434 le32_to_cpu(vcn_info->v1.instance_info[v].fuse_data.all_bits);
622469c87fc3e6 Alex Deucher 2022-03-30 1435 }
622469c87fc3e6 Alex Deucher 2022-03-30 1436 break;
622469c87fc3e6 Alex Deucher 2022-03-30 1437 default:
622469c87fc3e6 Alex Deucher 2022-03-30 1438 dev_err(adev->dev,
622469c87fc3e6 Alex Deucher 2022-03-30 1439 "Unhandled VCN info table %d.%d\n",
622469c87fc3e6 Alex Deucher 2022-03-30 1440 le16_to_cpu(vcn_info->v1.header.version_major),
622469c87fc3e6 Alex Deucher 2022-03-30 1441 le16_to_cpu(vcn_info->v1.header.version_minor));
622469c87fc3e6 Alex Deucher 2022-03-30 1442 return -EINVAL;
622469c87fc3e6 Alex Deucher 2022-03-30 1443 }
622469c87fc3e6 Alex Deucher 2022-03-30 1444 return 0;
f39f5bb1c9d68d Xiaojie Yuan 2019-06-20 1445 }
795d08391b8627 Alex Deucher 2021-07-20 1446
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 6+ messages in thread
* drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1433 amdgpu_discovery_get_vcn_info() error: buffer overflow 'adev->vcn.vcn_codec_disable_mask' 2 <= 3
@ 2022-06-18 0:57 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-06-18 0:57 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 4318 bytes --]
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Alex Deucher <alexander.deucher@amd.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4b35035bcf80ddb47c0112c4fbd84a63a2836a18
commit: 622469c87fc3e6c90a980be3e2287d82bd55c977 drm/amdgpu/discovery: add a function to parse the vcn info table
date: 7 weeks ago
:::::: branch date: 5 hours ago
:::::: commit date: 7 weeks ago
config: ia64-randconfig-m031-20220616 (https://download.01.org/0day-ci/archive/20220618/202206180825.YkvqBbZg-lkp(a)intel.com/config)
compiler: ia64-linux-gcc (GCC) 11.3.0
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1433 amdgpu_discovery_get_vcn_info() error: buffer overflow 'adev->vcn.vcn_codec_disable_mask' 2 <= 3
vim +1433 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
622469c87fc3e6 Alex Deucher 2022-03-30 1402
622469c87fc3e6 Alex Deucher 2022-03-30 1403 int amdgpu_discovery_get_vcn_info(struct amdgpu_device *adev)
622469c87fc3e6 Alex Deucher 2022-03-30 1404 {
622469c87fc3e6 Alex Deucher 2022-03-30 1405 struct binary_header *bhdr;
622469c87fc3e6 Alex Deucher 2022-03-30 1406 union vcn_info *vcn_info;
622469c87fc3e6 Alex Deucher 2022-03-30 1407 u16 offset;
622469c87fc3e6 Alex Deucher 2022-03-30 1408 int v;
622469c87fc3e6 Alex Deucher 2022-03-30 1409
622469c87fc3e6 Alex Deucher 2022-03-30 1410 if (!adev->mman.discovery_bin) {
622469c87fc3e6 Alex Deucher 2022-03-30 1411 DRM_ERROR("ip discovery uninitialized\n");
622469c87fc3e6 Alex Deucher 2022-03-30 1412 return -EINVAL;
622469c87fc3e6 Alex Deucher 2022-03-30 1413 }
622469c87fc3e6 Alex Deucher 2022-03-30 1414
622469c87fc3e6 Alex Deucher 2022-03-30 1415 if (adev->vcn.num_vcn_inst > VCN_INFO_TABLE_MAX_NUM_INSTANCES) {
622469c87fc3e6 Alex Deucher 2022-03-30 1416 dev_err(adev->dev, "invalid vcn instances\n");
622469c87fc3e6 Alex Deucher 2022-03-30 1417 return -EINVAL;
622469c87fc3e6 Alex Deucher 2022-03-30 1418 }
622469c87fc3e6 Alex Deucher 2022-03-30 1419
622469c87fc3e6 Alex Deucher 2022-03-30 1420 bhdr = (struct binary_header *)adev->mman.discovery_bin;
622469c87fc3e6 Alex Deucher 2022-03-30 1421 offset = le16_to_cpu(bhdr->table_list[VCN_INFO].offset);
622469c87fc3e6 Alex Deucher 2022-03-30 1422
622469c87fc3e6 Alex Deucher 2022-03-30 1423 if (!offset) {
622469c87fc3e6 Alex Deucher 2022-03-30 1424 dev_err(adev->dev, "invalid vcn table offset\n");
622469c87fc3e6 Alex Deucher 2022-03-30 1425 return -EINVAL;
622469c87fc3e6 Alex Deucher 2022-03-30 1426 }
622469c87fc3e6 Alex Deucher 2022-03-30 1427
622469c87fc3e6 Alex Deucher 2022-03-30 1428 vcn_info = (union vcn_info *)(adev->mman.discovery_bin + offset);
622469c87fc3e6 Alex Deucher 2022-03-30 1429
622469c87fc3e6 Alex Deucher 2022-03-30 1430 switch (le16_to_cpu(vcn_info->v1.header.version_major)) {
622469c87fc3e6 Alex Deucher 2022-03-30 1431 case 1:
622469c87fc3e6 Alex Deucher 2022-03-30 1432 for (v = 0; v < adev->vcn.num_vcn_inst; v++) {
622469c87fc3e6 Alex Deucher 2022-03-30 @1433 adev->vcn.vcn_codec_disable_mask[v] =
622469c87fc3e6 Alex Deucher 2022-03-30 1434 le32_to_cpu(vcn_info->v1.instance_info[v].fuse_data.all_bits);
622469c87fc3e6 Alex Deucher 2022-03-30 1435 }
622469c87fc3e6 Alex Deucher 2022-03-30 1436 break;
622469c87fc3e6 Alex Deucher 2022-03-30 1437 default:
622469c87fc3e6 Alex Deucher 2022-03-30 1438 dev_err(adev->dev,
622469c87fc3e6 Alex Deucher 2022-03-30 1439 "Unhandled VCN info table %d.%d\n",
622469c87fc3e6 Alex Deucher 2022-03-30 1440 le16_to_cpu(vcn_info->v1.header.version_major),
622469c87fc3e6 Alex Deucher 2022-03-30 1441 le16_to_cpu(vcn_info->v1.header.version_minor));
622469c87fc3e6 Alex Deucher 2022-03-30 1442 return -EINVAL;
622469c87fc3e6 Alex Deucher 2022-03-30 1443 }
622469c87fc3e6 Alex Deucher 2022-03-30 1444 return 0;
f39f5bb1c9d68d Xiaojie Yuan 2019-06-20 1445 }
795d08391b8627 Alex Deucher 2021-07-20 1446
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1433 amdgpu_discovery_get_vcn_info() error: buffer overflow 'adev->vcn.vcn_codec_disable_mask' 2 <= 3
2022-06-02 14:24 [kbuild] " Alex Deucher
@ 2022-06-02 15:33 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-06-02 15:33 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 742 bytes --]
On Thu, Jun 02, 2022 at 10:24:58AM -0400, Alex Deucher wrote:
> On Thu, Jun 2, 2022 at 7:51 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > On Thu, Jun 02, 2022 at 08:26:03AM +0200, Ernst Sjöstrand wrote:
> > > Dan: I also ran Smatch which resulted in the following discussion:
> > >
> > > https://lists.freedesktop.org/archives/amd-gfx/2022-May/079228.html
> >
> > Since the bounds check is dead code which does not make sense and is not
> > required, another idea would be to just delete it.
>
> It wouldn't be dead code if AMDGPU_MAX_VCN_INSTANCES ever increased.
Or we could add a comment to the code I suppose.
/* Impossible in 2022 but this check might sense in the future */
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1433 amdgpu_discovery_get_vcn_info() error: buffer overflow 'adev->vcn.vcn_codec_disable_mask' 2 <= 3
2022-06-02 6:26 [kbuild] " Ernst Sjöstrand
@ 2022-06-02 11:50 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-06-02 11:50 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 368 bytes --]
On Thu, Jun 02, 2022 at 08:26:03AM +0200, Ernst Sjöstrand wrote:
> Dan: I also ran Smatch which resulted in the following discussion:
>
> https://lists.freedesktop.org/archives/amd-gfx/2022-May/079228.html
Since the bounds check is dead code which does not make sense and is not
required, another idea would be to just delete it.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1433 amdgpu_discovery_get_vcn_info() error: buffer overflow 'adev->vcn.vcn_codec_disable_mask' 2 <= 3
2022-05-27 7:56 [kbuild] " Chen, Guchun
@ 2022-05-27 8:12 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-05-27 8:12 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 399 bytes --]
On Fri, May 27, 2022 at 07:56:48AM +0000, Chen, Guchun wrote:
> A patch was available already to protect against such scenario.
>
> https://patchwork.freedesktop.org/patch/486289/ , "drm/amdgpu/discovery: validate VCN and SDMA instances"
>
What? That's an unrelated patch and it has already been applied so I
took it into consideration when doing my analysis.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1433 amdgpu_discovery_get_vcn_info() error: buffer overflow 'adev->vcn.vcn_codec_disable_mask' 2 <= 3
@ 2022-05-27 7:14 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-05-27 7:14 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 4316 bytes --]
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Alex Deucher <alexander.deucher@amd.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 7e284070abe53d448517b80493863595af4ab5f0
commit: 622469c87fc3e6c90a980be3e2287d82bd55c977 drm/amdgpu/discovery: add a function to parse the vcn info table
date: 4 weeks ago
:::::: branch date: 3 hours ago
:::::: commit date: 4 weeks ago
config: arc-randconfig-m031-20220524 (https://download.01.org/0day-ci/archive/20220527/202205271546.oV14N2r8-lkp(a)intel.com/config)
compiler: arceb-elf-gcc (GCC) 11.3.0
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1433 amdgpu_discovery_get_vcn_info() error: buffer overflow 'adev->vcn.vcn_codec_disable_mask' 2 <= 3
vim +1433 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
622469c87fc3e6 Alex Deucher 2022-03-30 1402
622469c87fc3e6 Alex Deucher 2022-03-30 1403 int amdgpu_discovery_get_vcn_info(struct amdgpu_device *adev)
622469c87fc3e6 Alex Deucher 2022-03-30 1404 {
622469c87fc3e6 Alex Deucher 2022-03-30 1405 struct binary_header *bhdr;
622469c87fc3e6 Alex Deucher 2022-03-30 1406 union vcn_info *vcn_info;
622469c87fc3e6 Alex Deucher 2022-03-30 1407 u16 offset;
622469c87fc3e6 Alex Deucher 2022-03-30 1408 int v;
622469c87fc3e6 Alex Deucher 2022-03-30 1409
622469c87fc3e6 Alex Deucher 2022-03-30 1410 if (!adev->mman.discovery_bin) {
622469c87fc3e6 Alex Deucher 2022-03-30 1411 DRM_ERROR("ip discovery uninitialized\n");
622469c87fc3e6 Alex Deucher 2022-03-30 1412 return -EINVAL;
622469c87fc3e6 Alex Deucher 2022-03-30 1413 }
622469c87fc3e6 Alex Deucher 2022-03-30 1414
622469c87fc3e6 Alex Deucher 2022-03-30 1415 if (adev->vcn.num_vcn_inst > VCN_INFO_TABLE_MAX_NUM_INSTANCES) {
622469c87fc3e6 Alex Deucher 2022-03-30 1416 dev_err(adev->dev, "invalid vcn instances\n");
622469c87fc3e6 Alex Deucher 2022-03-30 1417 return -EINVAL;
622469c87fc3e6 Alex Deucher 2022-03-30 1418 }
622469c87fc3e6 Alex Deucher 2022-03-30 1419
622469c87fc3e6 Alex Deucher 2022-03-30 1420 bhdr = (struct binary_header *)adev->mman.discovery_bin;
622469c87fc3e6 Alex Deucher 2022-03-30 1421 offset = le16_to_cpu(bhdr->table_list[VCN_INFO].offset);
622469c87fc3e6 Alex Deucher 2022-03-30 1422
622469c87fc3e6 Alex Deucher 2022-03-30 1423 if (!offset) {
622469c87fc3e6 Alex Deucher 2022-03-30 1424 dev_err(adev->dev, "invalid vcn table offset\n");
622469c87fc3e6 Alex Deucher 2022-03-30 1425 return -EINVAL;
622469c87fc3e6 Alex Deucher 2022-03-30 1426 }
622469c87fc3e6 Alex Deucher 2022-03-30 1427
622469c87fc3e6 Alex Deucher 2022-03-30 1428 vcn_info = (union vcn_info *)(adev->mman.discovery_bin + offset);
622469c87fc3e6 Alex Deucher 2022-03-30 1429
622469c87fc3e6 Alex Deucher 2022-03-30 1430 switch (le16_to_cpu(vcn_info->v1.header.version_major)) {
622469c87fc3e6 Alex Deucher 2022-03-30 1431 case 1:
622469c87fc3e6 Alex Deucher 2022-03-30 1432 for (v = 0; v < adev->vcn.num_vcn_inst; v++) {
622469c87fc3e6 Alex Deucher 2022-03-30 @1433 adev->vcn.vcn_codec_disable_mask[v] =
622469c87fc3e6 Alex Deucher 2022-03-30 1434 le32_to_cpu(vcn_info->v1.instance_info[v].fuse_data.all_bits);
622469c87fc3e6 Alex Deucher 2022-03-30 1435 }
622469c87fc3e6 Alex Deucher 2022-03-30 1436 break;
622469c87fc3e6 Alex Deucher 2022-03-30 1437 default:
622469c87fc3e6 Alex Deucher 2022-03-30 1438 dev_err(adev->dev,
622469c87fc3e6 Alex Deucher 2022-03-30 1439 "Unhandled VCN info table %d.%d\n",
622469c87fc3e6 Alex Deucher 2022-03-30 1440 le16_to_cpu(vcn_info->v1.header.version_major),
622469c87fc3e6 Alex Deucher 2022-03-30 1441 le16_to_cpu(vcn_info->v1.header.version_minor));
622469c87fc3e6 Alex Deucher 2022-03-30 1442 return -EINVAL;
622469c87fc3e6 Alex Deucher 2022-03-30 1443 }
622469c87fc3e6 Alex Deucher 2022-03-30 1444 return 0;
f39f5bb1c9d68d Xiaojie Yuan 2019-06-20 1445 }
795d08391b8627 Alex Deucher 2021-07-20 1446
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-06-18 0:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-16 23:49 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1433 amdgpu_discovery_get_vcn_info() error: buffer overflow 'adev->vcn.vcn_codec_disable_mask' 2 <= 3 kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2022-06-18 0:57 kernel test robot
2022-06-02 14:24 [kbuild] " Alex Deucher
2022-06-02 15:33 ` Dan Carpenter
2022-06-02 6:26 [kbuild] " Ernst Sjöstrand
2022-06-02 11:50 ` Dan Carpenter
2022-05-27 7:56 [kbuild] " Chen, Guchun
2022-05-27 8:12 ` Dan Carpenter
2022-05-27 7:14 kernel test robot
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.