diff mbox series

[for-4.4,2/3] /proc/iomem: only expose physical resource addresses to privileged users

Message ID 1501523611-18222-3-git-send-email-sumit.semwal@linaro.org
State New
Headers show
Series Stable candidates from Ubuntu Xenial 4.4-lts | expand

Commit Message

Sumit Semwal July 31, 2017, 5:53 p.m. UTC
From: Linus Torvalds <torvalds@linux-foundation.org>


Commit 34dbbcdbf63360661ff7bda6c5f52f99ac515f92 upstream.

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.

[sumits: this is used in Ubuntu as a fix for CVE-2015-8944]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>

---
 kernel/resource.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

-- 
2.7.4

Comments

Greg KH Aug. 4, 2017, 7:41 p.m. UTC | #1
On Mon, Jul 31, 2017 at 11:23:30PM +0530, Sumit Semwal wrote:
> From: Linus Torvalds <torvalds@linux-foundation.org>

> 

> Commit 34dbbcdbf63360661ff7bda6c5f52f99ac515f92 upstream.


Wrong git commit id :(
diff mbox series

Patch

diff --git a/kernel/resource.c b/kernel/resource.c
index 249b1eb1e6e1..a4a94e700fb9 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -105,16 +105,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;
 }