[bug report] drm/amdgpu: add amdgpu_ras.c to support ras (v2)
Zhou1, Tao
Tao.Zhou1 at amd.com
Wed May 6 07:26:16 UTC 2020
[AMD Public Use]
Hi Dan:
Please check the following piece of code in amdgpu_ras_debugfs_ctrl_parse_data:
if (op != -1) {
if (amdgpu_ras_find_block_id_by_name(block_name, &block_id))
return -EINVAL;
data->head.block = block_id;
amdgpu_ras_find_block_id_by_name will return error directly if someone try to provide an invalid block_name intentionally via debugfs.
Regards,
Tao
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Dan
> Carpenter
> Sent: 2020年5月5日 17:13
> To: Pan, Xinhui <Xinhui.Pan at amd.com>
> Cc: amd-gfx at lists.freedesktop.org
> Subject: [bug report] drm/amdgpu: add amdgpu_ras.c to support ras (v2)
>
> Hello xinhui pan,
>
> The patch c030f2e4166c: "drm/amdgpu: add amdgpu_ras.c to support ras
> (v2)" from Oct 31, 2018, leads to the following static checker
> warning:
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:620
> amdgpu_ras_feature_enable()
> warn: uncapped user index 'ras_block_string[head->block]'
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> 587 int amdgpu_ras_feature_enable(struct amdgpu_device *adev,
> 588 struct ras_common_if *head, bool enable)
> 589 {
> 590 struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
> 591 union ta_ras_cmd_input info;
> 592 int ret;
> 593
> 594 if (!con)
> 595 return -EINVAL;
> 596
> 597 if (!enable) {
> 598 info.disable_features = (struct ta_ras_disable_features_input)
> {
> 599 .block_id = amdgpu_ras_block_to_ta(head->block),
> 600 .error_type = amdgpu_ras_error_to_ta(head->type),
> 601 };
> 602 } else {
> 603 info.enable_features = (struct ta_ras_enable_features_input)
> {
> 604 .block_id = amdgpu_ras_block_to_ta(head->block),
> 605 .error_type = amdgpu_ras_error_to_ta(head->type),
> 606 };
> 607 }
> 608
> 609 /* Do not enable if it is not allowed. */
> 610 WARN_ON(enable && !amdgpu_ras_is_feature_allowed(adev,
> head));
> 611 /* Are we alerady in that state we are going to set? */
> 612 if (!(!!enable ^ !!amdgpu_ras_is_feature_enabled(adev, head)))
> 613 return 0;
> 614
> 615 if (!amdgpu_ras_intr_triggered()) {
> 616 ret = psp_ras_enable_features(&adev->psp, &info, enable);
> 617 if (ret) {
> 618 amdgpu_ras_parse_status_code(adev,
> 619 enable ? "enable":"disable",
> 620 ras_block_str(head->block),
> ^^^^^^^^^^^ The head->block
> value can be set to anything using debugfs. That's a problem because it
> could easily lead to a kernel panic (which is
> annoying) and also because these days we try to restrict what root can do.
>
> 621 (enum ta_ras_status)ret);
> 622 if (ret == TA_RAS_STATUS__RESET_NEEDED)
> 623 return -EAGAIN;
> 624 return -EINVAL;
> 625 }
> 626 }
> 627
> 628 /* setup the obj */
> 629 __amdgpu_ras_feature_enable(adev, head, enable);
> 630
> 631 return 0;
> 632 }
>
> regards,
> dan carpenter
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.f
> reedesktop.org%2Fmailman%2Flistinfo%2Famd-
> gfx&data=02%7C01%7Ctao.zhou1%40amd.com%7Cd9925eca763149180
> ea508d7f0d47cfe%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C6
> 37242667754892396&sdata=k%2FMTgz9D1jIJGRFBu2Yuu6wuHP%2BPbR
> vEcNJp87slIJE%3D&reserved=0
More information about the amd-gfx
mailing list