Skip to contentSkip to conversation

drm/amdgpu: Adjust debugfs register access permissions

PATCH In review Alex Deucher 3 participants 8 messages Oct 23, 2024 – Oct 31, 2024

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/3 drm/amdgpu: Adjust debugfs register access permissions

Regular users shouldn't have read access.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
index 6e6092916d4e..e44a44405266 100644
@@ -1654,7 +1654,7 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
 
 	for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
 		ent = debugfs_create_file(debugfs_regs_names[i],
-					  S_IFREG | 0444, root,
+					  S_IFREG | 0400, root,
 					  adev, debugfs_regs[i]);
 		if (!i && !IS_ERR_OR_NULL(ent))
 			i_size_write(ent->d_inode, adev->rmmio_size);
Signature · 1 line
2.46.2
author maintainer
#1 lore raw

PATCH 2/3 drm/amdgpu: Adjust debugfs eviction and IB access permissions

Users should not be able to run these.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3 -3
index e44a44405266..2ef7bcfdb2e2 100644
@@ -2108,11 +2108,11 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
 	amdgpu_securedisplay_debugfs_init(adev);
 	amdgpu_fw_attestation_debugfs_init(adev);
 
-	debugfs_create_file("amdgpu_evict_vram", 0444, root, adev,
+	debugfs_create_file("amdgpu_evict_vram", 0400, root, adev,
 			    &amdgpu_evict_vram_fops);
-	debugfs_create_file("amdgpu_evict_gtt", 0444, root, adev,
+	debugfs_create_file("amdgpu_evict_gtt", 0400, root, adev,
 			    &amdgpu_evict_gtt_fops);
-	debugfs_create_file("amdgpu_test_ib", 0444, root, adev,
+	debugfs_create_file("amdgpu_test_ib", 0400, root, adev,
 			    &amdgpu_debugfs_test_ib_fops);
 	debugfs_create_file("amdgpu_vm_info", 0444, root, adev,
 			    &amdgpu_debugfs_vm_info_fops);
Signature · 1 line
2.46.2
author maintainer
#2 lore raw

PATCH 3/3 drm/amdgpu: add missing size check in amdgpu_debugfs_gprwave_read()

In reply to Alex Deucher

Avoid a possible buffer overflow if size is larger than 4K.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
index 2ef7bcfdb2e2..3a118645b4bb 100644
@@ -402,7 +402,7 @@ static ssize_t amdgpu_debugfs_gprwave_read(struct file *f, char __user *buf, siz
 	int r;
 	uint32_t *data, x;
 
-	if (size & 0x3 || *pos & 0x3)
+	if (size > 4096 || size & 0x3 || *pos & 0x3)
 		return -EINVAL;
 
 	r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
Signature · 1 line
2.46.2
#3 lore raw
In reply to Alex Deucher

Ping on this series?

Alex

Quoted 24 lines · Alex Deucher

Regular users shouldn't have read access.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -2
index 6e6092916d4e..e44a44405266 100644
@@ -1654,7 +1654,7 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
 
        for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
                ent = debugfs_create_file(debugfs_regs_names[i],
-                                         S_IFREG | 0444, root,
+                                         S_IFREG | 0400, root,
                                          adev, debugfs_regs[i]);
                if (!i && !IS_ERR_OR_NULL(ent))
                        i_size_write(ent->d_inode, adev->rmmio_size);
--

2.46.2

#4 lore raw

Ping on this series?

Alex

Quoted 30 lines · Alex Deucher

Ping on this series?

Alex

Quoted 24 lines · Alex Deucher

Regular users shouldn't have read access.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -2
index 6e6092916d4e..e44a44405266 100644
@@ -1654,7 +1654,7 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
 
        for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
                ent = debugfs_create_file(debugfs_regs_names[i],
-                                         S_IFREG | 0444, root,
+                                         S_IFREG | 0400, root,
                                          adev, debugfs_regs[i]);
                if (!i && !IS_ERR_OR_NULL(ent))
                        i_size_write(ent->d_inode, adev->rmmio_size);
--

2.46.2

Reviewed-by
#5 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Best Regards,
Kevin

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 31, 2024 12:03 AM
To: Deucher, Alexander <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/3] drm/amdgpu: Adjust debugfs register access permissions

Ping on this series?

Alex

Quoted 30 lines · Alex Deucher

Ping on this series?

Alex

Quoted 24 lines · Alex Deucher

Regular users shouldn't have read access.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -2
index 6e6092916d4e..e44a44405266 100644
@@ -1654,7 +1654,7 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
 
        for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
                ent = debugfs_create_file(debugfs_regs_names[i],
-                                         S_IFREG | 0444, root,
+                                         S_IFREG | 0400, root,
                                          adev, debugfs_regs[i]);
                if (!i && !IS_ERR_OR_NULL(ent))
                        i_size_write(ent->d_inode, adev->rmmio_size);
--

2.46.2

#6 lore raw
Quoted 4 lines · Yang(Kevin)

[AMD Official Use Only - AMD Internal Distribution Only]

Is this for the whole series or just the first patch?

Thanks,

Alex

Quoted 46 lines

Best Regards,
Kevin

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 31, 2024 12:03 AM
To: Deucher, Alexander <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/3] drm/amdgpu: Adjust debugfs register access permissions

Ping on this series?

Alex

Quoted 30 lines · Alex Deucher

Ping on this series?

Alex

Quoted 24 lines · Alex Deucher

Regular users shouldn't have read access.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -2
index 6e6092916d4e..e44a44405266 100644
@@ -1654,7 +1654,7 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
 
        for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
                ent = debugfs_create_file(debugfs_regs_names[i],
-                                         S_IFREG | 0444, root,
+                                         S_IFREG | 0400, root,
                                          adev, debugfs_regs[i]);
                if (!i && !IS_ERR_OR_NULL(ent))
                        i_size_write(ent->d_inode, adev->rmmio_size);
--

2.46.2

Reviewed-by
#7 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, October 31, 2024 10:59 AM
To: Wang, Yang(Kevin) <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]
Subject: Re: [PATCH 1/3] drm/amdgpu: Adjust debugfs register access permissions

Quoted 4 lines · Yang(Kevin)

[AMD Official Use Only - AMD Internal Distribution Only]

Is this for the whole series or just the first patch?

Thanks,

Alex

[Kevin]:

the whole patch set is looks good to me.

Series is

Best Regards,
Kevin

Quoted 51 lines

Best Regards,
Kevin

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 31, 2024 12:03 AM
To: Deucher, Alexander <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/3] drm/amdgpu: Adjust debugfs register access permissions

Ping on this series?

Alex

Quoted 33 lines · Alex Deucher

Ping on this series?

Alex

Quoted 27 lines · Alex Deucher

Regular users shouldn't have read access.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
index 6e6092916d4e..e44a44405266 100644
@@ -1654,7 +1654,7 @@ int amdgpu_debugfs_regs_init(struct
 amdgpu_device *adev)
 
        for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
                ent = debugfs_create_file(debugfs_regs_names[i],
-                                         S_IFREG | 0444, root,
+                                         S_IFREG | 0400, root,
                                          adev, debugfs_regs[i]);
                if (!i && !IS_ERR_OR_NULL(ent))
                        i_size_write(ent->d_inode,

adev->rmmio_size);
--
2.46.2