[PATCH] pagemap: roothammer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Greg et al.

Many DRAM modules are susceptible to disturbance errors as outlined by
Kim et al. in June of last year [1]. More recently, a methodology to
exploit these memory cell interactions to escalate privileges on Linux
was made public by Google's Project Zero [2].

One attack vector detailed in their methodology uses information gleaned
from virtual page - frame maps. As a hardening/mitigation response,
ab676b7d6fbf [3] restricts access to /proc/*/pagemap to privileged
userspace.

I noticed 3.14.37 was the only LT kernel to receive a backport of this
mitigation.  Attached please find a backport for use on 3.10.y
(candidate for inclusion in 3.10.74).

3.12.y and 3.18.y can probably use [3] pretty much directly while 3.2.y
and 3.4.y can likely use my patch with a little offset TLC.

--mancha

[1] http://users.ece.cmu.edu/~yoonguk/papers/kim-isca14.pdf
[2] http://googleprojectzero.blogspot.com/2015/03/exploiting-dram-rowhammer-bug-to-gain.html
[3] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=ab676b7d6fbf

From e650025c3a4e86ef8accdb679ca3adbd4fdbf4fb Mon Sep 17 00:00:00 2001
From: mancha security <mancha1@xxxxxxxx>
Date: Sat, 28 Mar 2015 19:11:29 +0000
Subject: [PATCH] pagemap: do not leak physical addresses to non-privileged
 userspace

Backport of:

  commit ab676b7d6fbf4b294bf198fb27ade5b0e865c7ce
  Author: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
  Date:   Mon Mar 9 23:11:12 2015 +0200

  As pointed by recent post[1] on exploiting DRAM physical imperfection,
  /proc/PID/pagemap exposes sensitive information which can be used to do
  attacks.

  This disallows anybody without CAP_SYS_ADMIN to read the pagemap.

  [1] http://googleprojectzero.blogspot.com/2015/03/exploiting-dram-rowhammer-bug-to-gain.html

  [ Eventually we might want to do anything more finegrained, but for now
    this is the simple model.   - Linus ]

  Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
  Acked-by: Konstantin Khlebnikov <khlebnikov@xxxxxxxxxx>
  Acked-by: Andy Lutomirski <luto@xxxxxxxxxxxxxx>
  Cc: Pavel Emelyanov <xemul@xxxxxxxxxxxxx>
  Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
  Cc: Mark Seaborn <mseaborn@xxxxxxxxxxxx>
  Cc: stable@xxxxxxxxxxxxxxx
  Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

Signed-off-by: mancha security <mancha1@xxxxxxxx>
---
 fs/proc/task_mmu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 65fc60a..be9c7bb 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1110,9 +1110,19 @@ out:
 	return ret;
 }
 
+static int pagemap_open(struct inode *inode, struct file *file)
+{
+	/* do not disclose physical addresses to unprivileged
+	   userspace (closes a rowhammer attack vector) */
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	return 0;
+}
+
 const struct file_operations proc_pagemap_operations = {
 	.llseek		= mem_lseek, /* borrow this */
 	.read		= pagemap_read,
+	.open		= pagemap_open,
 };
 #endif /* CONFIG_PROC_PAGE_MONITOR */
 
-- 
1.8.3.1

Attachment: pgpcHvRHR6pRv.pgp
Description: PGP signature


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]