diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-14 15:05:37 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-14 15:56:09 -0400 |
commit | 51d7b120418e99d6b3bf8df9eb3cc31e8171dee4 (patch) | |
tree | d8fb1817068df408e6a009df9050159aebdd95c4 /kernel/resource.c | |
parent | ab0fa82b2df96ddadb327ac39f26b5d80cb3d104 (diff) |
/proc/iomem: only expose physical resource addresses to privileged users
In commit c4004b02f8e5b ("x86: remove the kernel code/data/bss resources
from /proc/iomem") I was hoping to remove the phyiscal kernel address
data from /proc/iomem entirely, but that had to be reverted because some
system programs actually use it.
This limits all the detailed resource information to properly
credentialed users instead.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/resource.c')
-rw-r--r-- | kernel/resource.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/kernel/resource.c b/kernel/resource.c index 2e78ead30934..9b5f04404152 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
@@ -105,16 +105,25 @@ static int r_show(struct seq_file *m, void *v) | |||
105 | { | 105 | { |
106 | struct resource *root = m->private; | 106 | struct resource *root = m->private; |
107 | struct resource *r = v, *p; | 107 | struct resource *r = v, *p; |
108 | unsigned long long start, end; | ||
108 | int width = root->end < 0x10000 ? 4 : 8; | 109 | int width = root->end < 0x10000 ? 4 : 8; |
109 | int depth; | 110 | int depth; |
110 | 111 | ||
111 | for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent) | 112 | for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent) |
112 | if (p->parent == root) | 113 | if (p->parent == root) |
113 | break; | 114 | break; |
115 | |||
116 | if (file_ns_capable(m->file, &init_user_ns, CAP_SYS_ADMIN)) { | ||
117 | start = r->start; | ||
118 | end = r->end; | ||
119 | } else { | ||
120 | start = end = 0; | ||
121 | } | ||
122 | |||
114 | seq_printf(m, "%*s%0*llx-%0*llx : %s\n", | 123 | seq_printf(m, "%*s%0*llx-%0*llx : %s\n", |
115 | depth * 2, "", | 124 | depth * 2, "", |
116 | width, (unsigned long long) r->start, | 125 | width, start, |
117 | width, (unsigned long long) r->end, | 126 | width, end, |
118 | r->name ? r->name : "<BAD>"); | 127 | r->name ? r->name : "<BAD>"); |
119 | return 0; | 128 | return 0; |
120 | } | 129 | } |