From patchwork Tue Nov 4 17:23:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 40162 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 46E9721894 for ; Tue, 4 Nov 2014 17:24:11 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id c41sf4392657eek.4 for ; Tue, 04 Nov 2014 09:24:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=t52wd/cIWFeJVbWp8Ew2vTgUMfiSatEtg8dz/vpdweg=; b=DbrLWYjgUSiJ3MdKJy3r3hZxv2A9F88XMYJrBGJb8uRV5ehcOD/xWF8d5LZ1+Uf+E8 5AMgssv25X3J3gYtT+d8pPc8ZHPB1gily/YJrLkG9kGD5MkX8z4oZO7pGu8ATplhQVFJ JMp1OKic209iux8tIB2NySCZ9xF8UpOH4vjHiLVBfRl9ZMNA3qixNqoTa1EwAJRLpY+m Fnry/Sy7Y22uAOqi7en0Ibzd27+9vcdSoFFsfAOOZcefoJL/wRGqdyrcxOTIqHLbnmqI EwdM8EEYlI8V/3lR8krR2Cu9OtcK7cHz1SUILZTOKJ7ojxAxonxqnoy6gqZvrtTB2g44 z9Lg== X-Gm-Message-State: ALoCoQnandLsn2MjbPt8QhK8tCIZcLcPRS64DzSBAFfmUfPZRrBnno6h+EtBdkVTK8GtV6je4jQ5 X-Received: by 10.112.166.102 with SMTP id zf6mr848630lbb.12.1415121849489; Tue, 04 Nov 2014 09:24:09 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.133 with SMTP id m5ls887942laf.102.gmail; Tue, 04 Nov 2014 09:24:09 -0800 (PST) X-Received: by 10.152.1.130 with SMTP id 2mr60996865lam.89.1415121849316; Tue, 04 Nov 2014 09:24:09 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id qf5si1666665lbb.105.2014.11.04.09.24.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Nov 2014 09:24:09 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id pv20so1259699lab.39 for ; Tue, 04 Nov 2014 09:24:09 -0800 (PST) X-Received: by 10.152.87.98 with SMTP id w2mr60147677laz.27.1415121849166; Tue, 04 Nov 2014 09:24:09 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp157656lbc; Tue, 4 Nov 2014 09:24:07 -0800 (PST) X-Received: by 10.66.138.16 with SMTP id qm16mr51432662pab.35.1415121846505; Tue, 04 Nov 2014 09:24:06 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si695178pdh.202.2014.11.04.09.24.05 for ; Tue, 04 Nov 2014 09:24:06 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753412AbaKDRXr (ORCPT + 25 others); Tue, 4 Nov 2014 12:23:47 -0500 Received: from mail-wi0-f182.google.com ([209.85.212.182]:59272 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752568AbaKDRXl (ORCPT ); Tue, 4 Nov 2014 12:23:41 -0500 Received: by mail-wi0-f182.google.com with SMTP id d1so9959613wiv.3 for ; Tue, 04 Nov 2014 09:23:40 -0800 (PST) X-Received: by 10.194.59.17 with SMTP id v17mr4866690wjq.130.1415121819552; Tue, 04 Nov 2014 09:23:39 -0800 (PST) Received: from mohikan.mushroom.smurfnet.nu (cpc4-cmbg17-2-0-cust71.5-4.cable.virginm.net. [86.14.224.72]) by mx.google.com with ESMTPSA id f7sm1725265wiz.13.2014.11.04.09.23.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Nov 2014 09:23:38 -0800 (PST) From: Leif Lindholm To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org Cc: linux@arm.linux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, schwidefsky@de.ibm.com, eiko.carstens@de.ibm.com, linux390@de.ibm.com, metcalf@tilera.com, gxt@mprc.pku.edu.cn, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org, keescook@chromium.org, luto@amacapital.net, oleg@redhat.com, akpm@linux-foundation.org, dave.long@linaro.org, hch@infradead.org, arjan@linux.intel.com Subject: [RFC PATCH] make CONFIG_STRICT_DEVMEM a core non-debug feature Date: Tue, 4 Nov 2014 17:23:56 +0000 Message-Id: <1415121836-16241-1-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 1.7.10.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: leif.lindholm@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Most, but not all, architectures supporting CONFIG_STRICT_DEVMEM treat it as a debug feature - although its function is pretty much the opposite of debug. This patch deletes all architecture-specific config options and moves the option to core code, as a non-debug option. Signed-off-by: Leif Lindholm --- Apologies for wide distribution, but this is a bit invasive, if trivial. arch/Kconfig | 3 +++ arch/arm/Kconfig | 1 + arch/arm/Kconfig.debug | 14 -------------- arch/arm64/Kconfig | 1 + arch/arm64/Kconfig.debug | 14 -------------- arch/powerpc/Kconfig | 1 + arch/powerpc/Kconfig.debug | 12 ------------ arch/s390/Kconfig | 1 + arch/s390/Kconfig.debug | 12 ------------ arch/tile/Kconfig | 4 +--- arch/unicore32/Kconfig | 1 + arch/unicore32/Kconfig.debug | 14 -------------- arch/x86/Kconfig | 1 + arch/x86/Kconfig.debug | 17 ----------------- drivers/char/Kconfig | 16 ++++++++++++++++ 15 files changed, 26 insertions(+), 86 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 05d7a8a..e5f4f03 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -484,6 +484,9 @@ config HAVE_IRQ_EXIT_ON_IRQ_STACK This spares a stack switch and improves cache usage on softirq processing. +config HAVE_ARCH_RESTRICTED_DEVMEM + bool + # # ABI hall of shame # diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 89c4b5c..e04910f 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -30,6 +30,7 @@ config ARM select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT) select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL select HAVE_ARCH_KGDB + select HAVE_ARCH_RESTRICTED_DEVMEM if MMU select HAVE_ARCH_SECCOMP_FILTER if (AEABI && !OABI_COMPAT) select HAVE_ARCH_TRACEHOOK select HAVE_BPF_JIT diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug index d8f6a2e..2a02a7d 100644 --- a/arch/arm/Kconfig.debug +++ b/arch/arm/Kconfig.debug @@ -14,20 +14,6 @@ config ARM_PTDUMP kernel. If in doubt, say "N" -config STRICT_DEVMEM - bool "Filter access to /dev/mem" - depends on MMU - ---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. - - If this option is switched on, the /dev/mem file only allows - userspace access to memory mapped peripherals. - - If in doubt, say Y. - # RMK wants arm kernels compiled with frame pointers or stack unwinding. # If you know what you are doing and are willing to live without stack # traces, you can get a slightly smaller kernel by setting this option to diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 9532f8d..90abbb2 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -37,6 +37,7 @@ config ARM64 select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_KGDB + select HAVE_ARCH_RESTRICTED_DEVMEM if MMU select HAVE_ARCH_TRACEHOOK select HAVE_BPF_JIT select HAVE_C_RECORDMCOUNT diff --git a/arch/arm64/Kconfig.debug b/arch/arm64/Kconfig.debug index 0a12933..d0036dd 100644 --- a/arch/arm64/Kconfig.debug +++ b/arch/arm64/Kconfig.debug @@ -6,20 +6,6 @@ config FRAME_POINTER bool default y -config STRICT_DEVMEM - bool "Filter access to /dev/mem" - depends on MMU - 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. - - If this option is switched on, the /dev/mem file only allows - userspace access to memory mapped peripherals. - - If in doubt, say Y. - config PID_IN_CONTEXTIDR bool "Write the current PID to the CONTEXTIDR register" help diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 88eace4..cd35068 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -148,6 +148,7 @@ config PPC select HAVE_ARCH_AUDITSYSCALL select ARCH_SUPPORTS_ATOMIC_RMW select DCACHE_WORD_ACCESS if PPC64 && CPU_LITTLE_ENDIAN + select HAVE_ARCH_RESTRICTED_DEVMEM config GENERIC_CSUM def_bool CPU_LITTLE_ENDIAN diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug index ec2e40f..6f11382 100644 --- a/arch/powerpc/Kconfig.debug +++ b/arch/powerpc/Kconfig.debug @@ -334,18 +334,6 @@ config PPC_EARLY_DEBUG_CPM_ADDR platform probing is done, all platforms selected must share the same address. -config STRICT_DEVMEM - def_bool y - prompt "Filter access to /dev/mem" - help - This option restricts access to /dev/mem. If this option is - disabled, you allow userspace access to all memory, including - kernel and userspace memory. Accidental memory access is likely - to be disastrous. - Memory access is required for experts who want to debug the kernel. - - If you are unsure, say Y. - config FAIL_IOMMU bool "Fault-injection capability for IOMMU" depends on FAULT_INJECTION diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index f2cf1f9..fe92272 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -109,6 +109,7 @@ config S390 select HAVE_ALIGNED_STRUCT_PAGE if SLUB select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL if !MARCH_G5 + select HAVE_ARCH_RESTRICTED_DEVMEM select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE if 64BIT diff --git a/arch/s390/Kconfig.debug b/arch/s390/Kconfig.debug index c56878e..26c5d5be 100644 --- a/arch/s390/Kconfig.debug +++ b/arch/s390/Kconfig.debug @@ -5,18 +5,6 @@ config TRACE_IRQFLAGS_SUPPORT source "lib/Kconfig.debug" -config STRICT_DEVMEM - def_bool y - prompt "Filter access to /dev/mem" - ---help--- - This option restricts access to /dev/mem. If this option is - disabled, you allow userspace access to all memory, including - kernel and userspace memory. Accidental memory access is likely - to be disastrous. - Memory access is required for experts who want to debug the kernel. - - If you are unsure, say Y. - config S390_PTDUMP bool "Export kernel pagetable layout to userspace via debugfs" depends on DEBUG_KERNEL diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index 7cca418..f881168 100644 --- a/arch/tile/Kconfig +++ b/arch/tile/Kconfig @@ -27,6 +27,7 @@ config TILE select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select HAVE_DEBUG_STACKOVERFLOW select ARCH_WANT_FRAME_POINTERS + select HAVE_ARCH_RESTRICTED_DEVMEM # FIXME: investigate whether we need/want these options. # select HAVE_IOREMAP_PROT @@ -110,9 +111,6 @@ config ARCH_DISCONTIGMEM_DEFAULT config TRACE_IRQFLAGS_SUPPORT def_bool y -config STRICT_DEVMEM - def_bool y - # SMP is required for Tilera Linux. config SMP def_bool y diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig index 928237a..574b07f 100644 --- a/arch/unicore32/Kconfig +++ b/arch/unicore32/Kconfig @@ -18,6 +18,7 @@ config UNICORE32 select ARCH_WANT_FRAME_POINTERS select GENERIC_IOMAP select MODULES_USE_ELF_REL + select HAVE_ARCH_RESTRICTED_DEVMEM if MMU help UniCore-32 is 32-bit Instruction Set Architecture, including a series of low-power-consumption RISC chip diff --git a/arch/unicore32/Kconfig.debug b/arch/unicore32/Kconfig.debug index 1a36262..f075bbe 100644 --- a/arch/unicore32/Kconfig.debug +++ b/arch/unicore32/Kconfig.debug @@ -2,20 +2,6 @@ menu "Kernel hacking" source "lib/Kconfig.debug" -config STRICT_DEVMEM - bool "Filter access to /dev/mem" - depends on MMU - ---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. - - If this option is switched on, the /dev/mem file only allows - userspace access to memory mapped peripherals. - - If in doubt, say Y. - config EARLY_PRINTK def_bool DEBUG_OCD help diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ded8a67..91392bf 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -137,6 +137,7 @@ config X86 select HAVE_ACPI_APEI_NMI if ACPI select ACPI_LEGACY_TABLES_LOOKUP if ACPI select X86_FEATURE_NAMES if PROC_FS + select HAVE_ARCH_RESTRICTED_DEVMEM config INSTRUCTION_DECODER def_bool y diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug index 61bd2ad..e35d4a1 100644 --- a/arch/x86/Kconfig.debug +++ b/arch/x86/Kconfig.debug @@ -5,23 +5,6 @@ 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. Note that with PAT support - enabled, even in this case there are restrictions on /dev/mem - use due to the cache aliasing requirements. - - If this option is switched on, the /dev/mem file only allows - userspace access to PCI space and the BIOS code and data regions. - This is sufficient for dosemu and X and all common users of - /dev/mem. - - If in doubt, say Y. - config X86_VERBOSE_BOOTUP bool "Enable verbose x86 bootup info messages" default y diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index efefd12..39f7817 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -6,6 +6,22 @@ menu "Character devices" source "drivers/tty/Kconfig" +config STRICT_DEVMEM + bool "Reduced access to /dev/mem" + depends on HAVE_ARCH_RESTRICTED_DEVMEM + default y + 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. + + If this option is switched on, the /dev/mem file restricts userspace + access to an architecture-specific subset of the physical address + space. + + If in doubt, say Y. + config DEVKMEM bool "/dev/kmem virtual device support" default y