Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933625AbbDIJKm (ORCPT ); Thu, 9 Apr 2015 05:10:42 -0400 Received: from mail.kernel.org ([198.145.29.136]:43753 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932744AbbDII6F (ORCPT ); Thu, 9 Apr 2015 04:58:05 -0400 From: lizf@kernel.org To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , Pavel Emelyanov , Andrew Morton , Mark Seaborn , Linus Torvalds , Zefan Li , mancha security Subject: [PATCH 3.4 161/176] pagemap: do not leak physical addresses to non-privileged userspace Date: Thu, 9 Apr 2015 16:46:49 +0800 Message-Id: <1428569224-23820-161-git-send-email-lizf@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428569028-23762-1-git-send-email-lizf@kernel.org> References: <1428569028-23762-1-git-send-email-lizf@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2081 Lines: 66 From: "Kirill A. Shutemov" 3.4.107-rc1 review patch. If anyone has any objections, please let me know. ------------------ commit ab676b7d6fbf4b294bf198fb27ade5b0e865c7ce upstream. 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 Acked-by: Konstantin Khlebnikov Acked-by: Andy Lutomirski Cc: Pavel Emelyanov Cc: Andrew Morton Cc: Mark Seaborn Signed-off-by: Linus Torvalds Signed-off-by: Zefan Li [mancha: Backported to 3.10] Signed-off-by: mancha security --- 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 8df7fd2..bc17933 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -985,9 +985,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.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/