From patchwork Tue Feb 18 19:11:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Picco X-Patchwork-Id: 321624 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2A48E2C00D5 for ; Wed, 19 Feb 2014 06:11:43 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751816AbaBRTLm (ORCPT ); Tue, 18 Feb 2014 14:11:42 -0500 Received: from hapkido.dreamhost.com ([66.33.216.122]:36263 "EHLO hapkido.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751242AbaBRTLl (ORCPT ); Tue, 18 Feb 2014 14:11:41 -0500 Received: from homiemail-a64.g.dreamhost.com (mailbigip.dreamhost.com [208.97.132.5]) by hapkido.dreamhost.com (Postfix) with ESMTP id 30E7E11C2 for ; Tue, 18 Feb 2014 11:06:44 -0800 (PST) Received: from homiemail-a64.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a64.g.dreamhost.com (Postfix) with ESMTP id 75F4943807C; Tue, 18 Feb 2014 11:11:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=meloft.net; h=from:to:cc :subject:date:message-id; s=meloft.net; bh=ImU+KD7G74sxAeORMd7Qi p1Sa8k=; b=AoG08GhLFzrGf/ppVvm2aE+Q/ux9vhGYbBhOVH0MAASFD19v/Zye+ jW9EoJcOpYz8TS9vKkovRk72TF/N+ORZ7RsS8nRfLLm8x2fRkll9mT/VQUD8eXIo SrpFzfuMt1ZOwnlaoHVfWj8VysJ0GmdXExJOtT8USj6+96ktpUg6O4= Received: from meloft.net (c-50-136-7-79.hsd1.nh.comcast.net [50.136.7.79]) (Authenticated sender: bpicco@meloft.net) by homiemail-a64.g.dreamhost.com (Postfix) with ESMTPA id 976F0438095; Tue, 18 Feb 2014 11:11:02 -0800 (PST) From: Bob Picco To: davem@davemloft.net Cc: sparclinux@vger.kernel.org, bob picco , Bob Picco Subject: [PATCH 1/2] sparc64 - strict devmem Date: Tue, 18 Feb 2014 14:11:18 -0500 Message-Id: <1392750679-6966-1-git-send-email-bpicco@meloft.net> X-Mailer: git-send-email 1.8.1.2 Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org From: bob picco This is just the first part of restricting /dev/mem access on sparc. This patch does nothing to change the current behaviour. The patch is in preparation for a subsequent patch. Signed-off-by: Bob Picco --- arch/sparc/Kconfig.debug | 8 ++++++++ arch/sparc/include/asm/page_64.h | 1 + arch/sparc/mm/init_64.c | 11 +++++++++++ 3 files changed, 20 insertions(+), 0 deletions(-) diff --git a/arch/sparc/Kconfig.debug b/arch/sparc/Kconfig.debug index 6db35fb..92f2388 100644 --- a/arch/sparc/Kconfig.debug +++ b/arch/sparc/Kconfig.debug @@ -6,6 +6,14 @@ config TRACE_IRQFLAGS_SUPPORT source "lib/Kconfig.debug" +config STRICT_DEVMEM + bool "Filter access to /dev/mem" + ---help--- + If this option is disabled, you allow userspace (root) access to all + of memory, including kernel and userspace memory. Accidental + access to this is obviously disastrous, but specific access can + be used by people debugging the kernel. + config DEBUG_DCFLUSH bool "D-cache flush debugging" depends on SPARC64 && DEBUG_KERNEL diff --git a/arch/sparc/include/asm/page_64.h b/arch/sparc/include/asm/page_64.h index aac53fc..e54ee50 100644 --- a/arch/sparc/include/asm/page_64.h +++ b/arch/sparc/include/asm/page_64.h @@ -36,6 +36,7 @@ extern void hugetlb_setup(struct pt_regs *regs); #define WANT_PAGE_VIRTUAL +extern int devmem_is_allowed(unsigned long pagenr); extern void _clear_page(void *page); #define clear_page(X) _clear_page((void *)(X)) struct page; diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index eafbc65..9c4a820 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -2694,3 +2694,14 @@ void hugetlb_setup(struct pt_regs *regs) } } #endif + +#ifdef CONFIG_STRICT_DEVMEM +/* devmem_is_allowed for sparc. + */ +int devmem_is_allowed(unsigned long pagenr) +{ + int rc = page_is_ram(pagenr); + + return rc; +} +#endif