2018-11-02 19:11:30

by Mark Salyzyn

[permalink] [raw]
Subject: /proc/iomem: only expose physical resource addresses to privileged users

From: Linus Torvalds <[email protected]>

commit 51d7b120418e99d6b3bf8df9eb3cc31e8171dee4 upstream ported to
3.18.y

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 <[email protected]>
Signed-off-by: Mark Salyzyn <[email protected]>
Cc: [email protected]
Cc: [email protected] # 3.18
---
kernel/resource.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/kernel/resource.c b/kernel/resource.c
index d9c7d5d77c8a..83658ca0e69c 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -104,16 +104,25 @@ static int r_show(struct seq_file *m, void *v)
{
struct resource *root = m->private;
struct resource *r = v, *p;
+ unsigned long long start, end;
int width = root->end < 0x10000 ? 4 : 8;
int depth;

for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent)
if (p->parent == root)
break;
+
+ if (file_ns_capable(m->file, &init_user_ns, CAP_SYS_ADMIN)) {
+ start = r->start;
+ end = r->end;
+ } else {
+ start = end = 0;
+ }
+
seq_printf(m, "%*s%0*llx-%0*llx : %s\n",
depth * 2, "",
- width, (unsigned long long) r->start,
- width, (unsigned long long) r->end,
+ width, start,
+ width, end,
r->name ? r->name : "<BAD>");
return 0;
}
--
2.19.1.930.g4563a0d9d0-goog



2018-11-03 06:43:26

by Greg KH

[permalink] [raw]
Subject: Re: /proc/iomem: only expose physical resource addresses to privileged users

On Fri, Nov 02, 2018 at 12:08:59PM -0700, Mark Salyzyn wrote:
> From: Linus Torvalds <[email protected]>
>
> commit 51d7b120418e99d6b3bf8df9eb3cc31e8171dee4 upstream ported to
> 3.18.y

Now queued up, thanks.

greg k-h