Skip to contentSkip to conversation

high_memory address in /proc/dri/*/vma

DISCUSSION Ben Hutchings 3 participants 8 messages Dec 20, 2011

lore
Share & tools
lore
#0 lore raw

[Re-sent to the right address, I hope.]

Kees, in commit 01e2f533a234dc62d16c0d3d4fb9d71cf1ce50c3 ("drm: do not leak kernel addresses via /proc/dri/*/vma") you changed the logging of high_memory:

- seq_printf(m, "vma use count: %d, high_memory = %p, 0x%08llx\n",
+ seq_printf(m, "vma use count: %d, high_memory = %pK, 0x%pK\n",

                   atomic_read(&dev->vma_count),

- high_memory, (u64)virt_to_phys(high_memory));
+ high_memory, (void *)virt_to_phys(high_memory));

This doesn't make sense because the physical address may be truncated (in theory at least).

I think it would make more sense to make this entire file readable by root only, but I don't know whether anything depends on being able to read it. Its existence is conditional on DRM_DEBUG_CODE != 0 but that is always true at the moment.

Ben.

Signature · 2 lines
Ben Hutchings
Humans are not rational beings; they are rationalising beings.
#1 lore raw
Quoted 4 lines · Ben Hutchings

Kees, in commit 01e2f533a234dc62d16c0d3d4fb9d71cf1ce50c3 ("drm: do not leak kernel addresses via /proc/dri/*/vma") you changed the logging of high_memory:

Quoted 8 lines

-       seq_printf(m, "vma use count: %d, high_memory = %p, 0x%08llx\n",
+       seq_printf(m, "vma use count: %d, high_memory = %pK, 0x%pK\n", atomic_read(&dev->vma_count),
-                  high_memory, (u64)virt_to_phys(high_memory));
+                  high_memory, (void *)virt_to_phys(high_memory));

This doesn't make sense because the physical address may be truncated (in theory at least).

Leaking even a truncated address is still a problem, IMO. Or do you mean there is some side-effect causing a problem?

Quoted 4 lines

I think it would make more sense to make this entire file readable by root only, but I don't know whether anything depends on being able to read it.  Its existence is conditional on DRM_DEBUG_CODE != 0 but that is always true at the moment.

The kptr_restrict syscall (that controls %pK behavior) has 3 modes, including one that hides these values even from the root user, so I would prefer this stays as-is.

Sorry I'm being dense, but what problem is %pK causing here? I'd be happy to help get it fixed.

-Kees

Signature · 2 lines
Kees Cook
ChromeOS Security
#2 lore raw
Quoted 11 lines · Kees Cook
Quoted 10 lines · Ben Hutchings

Kees, in commit 01e2f533a234dc62d16c0d3d4fb9d71cf1ce50c3 ("drm: do not leak kernel addresses via /proc/dri/*/vma") you changed the logging of high_memory:

(quoted diff) +2 -2
-       seq_printf(m, "vma use count: %d, high_memory = %p, 0x%08llx\n",
+       seq_printf(m, "vma use count: %d, high_memory = %pK, 0x%pK\n",
                  atomic_read(&dev->vma_count),
-                  high_memory, (u64)virt_to_phys(high_memory));
+                  high_memory, (void *)virt_to_phys(high_memory));
Quoted 5 lines
Quoted 2 lines

This doesn't make sense because the physical address may be truncated (in theory at least).

Leaking even a truncated address is still a problem, IMO. Or do you mean there is some side-effect causing a problem?

I mean that this the conversion to void * can be a narrowing conversion, so when printing of kernel pointers is enabled the full physical address may not be displayed.

Quoted 11 lines
Quoted 4 lines

I think it would make more sense to make this entire file readable by root only, but I don't know whether anything depends on being able to read it. Its existence is conditional on DRM_DEBUG_CODE != 0 but that is always true at the moment.

The kptr_restrict syscall (that controls %pK behavior) has 3 modes, including one that hides these values even from the root user, so I would prefer this stays as-is.

Sorry I'm being dense, but what problem is %pK causing here? I'd be happy to help get it fixed.

The problem is that it is not suitable for printing physical addresses, because they are not pointers.

Ben.

Signature · 2 lines
Ben Hutchings
Humans are not rational beings; they are rationalising beings.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 15 lines · Ben Hutchings
Quoted 14 lines · Kees Cook
Quoted 12 lines · Ben Hutchings

Kees, in commit 01e2f533a234dc62d16c0d3d4fb9d71cf1ce50c3 ("drm: do not leak kernel addresses via /proc/dri/*/vma") you changed the logging of high_memory:

-       seq_printf(m, "vma use count: %d, high_memory = %p, 0x%08llx\n",
+       seq_printf(m, "vma use count: %d, high_memory = %pK, 0x%pK\n", atomic_read(&dev->vma_count),
-                  high_memory, (u64)virt_to_phys(high_memory));
+                  high_memory, (void *)virt_to_phys(high_memory));

This doesn't make sense because the physical address may be truncated (in theory at least).

Quoted 6 lines
Quoted 2 lines

Leaking even a truncated address is still a problem, IMO. Or do you mean there is some side-effect causing a problem?

I mean that this the conversion to void * can be a narrowing conversion, so when printing of kernel pointers is enabled the full physical address may not be displayed.

Ah-ha, okay, I see what you mean now. This is, as you say, only a problem "in theory". Is it worth fixing currently? If so, we probably need to add the "K" option to %x in some fashion.

-Kees

Signature · 2 lines
Kees Cook
ChromeOS Security
#4 lore raw
Quoted 19 lines · Kees Cook
Quoted 18 lines · Ben Hutchings
Quoted 16 lines · Kees Cook
Quoted 10 lines · Ben Hutchings

Kees, in commit 01e2f533a234dc62d16c0d3d4fb9d71cf1ce50c3 ("drm: do not leak kernel addresses via /proc/dri/*/vma") you changed the logging of high_memory:

(quoted diff) +2 -2
-       seq_printf(m, "vma use count: %d, high_memory = %p, 0x%08llx\n",
+       seq_printf(m, "vma use count: %d, high_memory = %pK, 0x%pK\n",
                  atomic_read(&dev->vma_count),
-                  high_memory, (u64)virt_to_phys(high_memory));
+                  high_memory, (void *)virt_to_phys(high_memory));
Quoted 2 lines

This doesn't make sense because the physical address may be truncated (in theory at least).

Leaking even a truncated address is still a problem, IMO. Or do you mean there is some side-effect causing a problem?

Quoted 6 lines
Quoted 3 lines

I mean that this the conversion to void * can be a narrowing conversion, so when printing of kernel pointers is enabled the full physical address may not be displayed.

Ah-ha, okay, I see what you mean now. This is, as you say, only a problem "in theory". Is it worth fixing currently?

I don't know.

Quoted 1 line

If so, we probably need to add the "K" option to %x in some fashion.

Something like that, yes.

Ben.

Signature · 2 lines
Ben Hutchings
Humans are not rational beings; they are rationalising beings.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw
In reply to Ben Hutchings
Quoted 12 lines · Ben Hutchings

[Re-sent to the right address, I hope.]

Kees, in commit 01e2f533a234dc62d16c0d3d4fb9d71cf1ce50c3 ("drm: do not leak kernel addresses via /proc/dri/*/vma") you changed the logging of high_memory:

(quoted diff) +2 -2
-       seq_printf(m, "vma use count: %d, high_memory = %p, 0x%08llx\n",
+       seq_printf(m, "vma use count: %d, high_memory = %pK, 0x%pK\n",
                   atomic_read(&dev->vma_count),
-                  high_memory, (u64)virt_to_phys(high_memory));
+                  high_memory, (void *)virt_to_phys(high_memory));
Quoted 7 lines

This doesn't make sense because the physical address may be truncated (in theory at least).

I think it would make more sense to make this entire file readable by root only, but I don't know whether anything depends on being able to read it. Its existence is conditional on DRM_DEBUG_CODE != 0 but that is always true at the moment.

Afaik (and I've done quite some code history checking) the proc files are not relied upon by userspace (up to about 10 years back). Patch to kill them all is pending and should hit either 3.3 or 3.4.
-Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#6 lore raw
Quoted 16 lines · Daniel Vetter
Quoted 15 lines · Ben Hutchings

[Re-sent to the right address, I hope.]

Kees, in commit 01e2f533a234dc62d16c0d3d4fb9d71cf1ce50c3 ("drm: do not leak kernel addresses via /proc/dri/*/vma") you changed the logging of high_memory:

-       seq_printf(m, "vma use count: %d, high_memory = %p, 0x%08llx\n",
+       seq_printf(m, "vma use count: %d, high_memory = %pK, 0x%pK\n", atomic_read(&dev->vma_count),
-                  high_memory, (u64)virt_to_phys(high_memory));
+                  high_memory, (void *)virt_to_phys(high_memory));

This doesn't make sense because the physical address may be truncated (in theory at least).

Quoted 8 lines
Quoted 4 lines

I think it would make more sense to make this entire file readable by root only, but I don't know whether anything depends on being able to read it.  Its existence is conditional on DRM_DEBUG_CODE != 0 but that is always true at the moment.

Afaik (and I've done quite some code history checking) the proc files are not relied upon by userspace (up to about 10 years back). Patch to kill them all is pending and should hit either 3.3 or 3.4.

That works too. :)

Signature · 2 lines
Kees Cook
ChromeOS Security
#7 lore raw
In reply to Daniel Vetter
Quoted 16 lines · Daniel Vetter
Quoted 15 lines · Ben Hutchings

[Re-sent to the right address, I hope.]

Kees, in commit 01e2f533a234dc62d16c0d3d4fb9d71cf1ce50c3 ("drm: do not leak kernel addresses via /proc/dri/*/vma") you changed the logging of high_memory:

(quoted diff) +2 -2
-       seq_printf(m, "vma use count: %d, high_memory = %p, 0x%08llx\n",
+       seq_printf(m, "vma use count: %d, high_memory = %pK, 0x%pK\n",
                   atomic_read(&dev->vma_count),
-                  high_memory, (u64)virt_to_phys(high_memory));
+                  high_memory, (void *)virt_to_phys(high_memory));

This doesn't make sense because the physical address may be truncated (in theory at least).

Quoted 8 lines
Quoted 4 lines

I think it would make more sense to make this entire file readable by root only, but I don't know whether anything depends on being able to read it. Its existence is conditional on DRM_DEBUG_CODE != 0 but that is always true at the moment.

Afaik (and I've done quite some code history checking) the proc files are not relied upon by userspace (up to about 10 years back). Patch to kill them all is pending and should hit either 3.3 or 3.4.

Great, that'll be one more warning gone. :-)

Ben.

Signature · 3 lines
Ben Hutchings
We get into the habit of living before acquiring the habit of thinking.
                                                              - Albert Camus