Skip to content

Commit 51d7b12

Browse files
committed
/proc/iomem: only expose physical resource addresses to privileged users
In commit c4004b0 ("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>
1 parent ab0fa82 commit 51d7b12

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

kernel/resource.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,25 @@ static int r_show(struct seq_file *m, void *v)
105105
{
106106
struct resource *root = m->private;
107107
struct resource *r = v, *p;
108+
unsigned long long start, end;
108109
int width = root->end < 0x10000 ? 4 : 8;
109110
int depth;
110111

111112
for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent)
112113
if (p->parent == root)
113114
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+
114123
seq_printf(m, "%*s%0*llx-%0*llx : %s\n",
115124
depth * 2, "",
116-
width, (unsigned long long) r->start,
117-
width, (unsigned long long) r->end,
125+
width, start,
126+
width, end,
118127
r->name ? r->name : "<BAD>");
119128
return 0;
120129
}

0 commit comments

Comments
 (0)