From: Kirill A. Shutemov Date: Mon, 9 Mar 2015 21:11:12 +0000 (+0200) Subject: ANDROID: pagemap: do not leak physical addresses to non-privileged userspace X-Git-Tag: firefly_0821_release~696 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f662f0e62417d66d9ae4ca40abf9f0309d266746;p=firefly-linux-kernel-4.4.55.git ANDROID: pagemap: do not leak physical addresses to non-privileged userspace 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 ] We add this patch again for pass CTS FileSystemPermissionTest: Assert /proc/self/pagemap not readable Change-Id: Id4bf9ea27af000734356b921cd723868802b4335 Signed-off-by: Kirill A. Shutemov Acked-by: Konstantin Khlebnikov Acked-by: Andy Lutomirski Cc: Pavel Emelyanov Cc: Andrew Morton Cc: Mark Seaborn Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds Signed-off-by: Huang, Tao --- diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 200e3b29aa22..25d70a001c51 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1396,6 +1396,16 @@ static int pagemap_open(struct inode *inode, struct file *file) { struct mm_struct *mm; +#if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_ANDROID) + /* + * For pass CTS + * FileSystemPermissionTest: Assert /proc/self/pagemap not readable + */ + /* do not disclose physical addresses: attack vector */ + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; +#endif + mm = proc_mem_open(inode, PTRACE_MODE_READ); if (IS_ERR(mm)) return PTR_ERR(mm);