Skip to contentSkip to conversation

drivers/char: remove /dev/kmem for good

PATCH In review David Hildenbrand 6 participants 10 messages Mar 24, 2021 – Mar 31, 2021

Subsystems (23)
lore
Share & tools
lore
#0 lore raw

cover drivers/char: remove /dev/kmem for good

Let's remove /dev/kmem, which is unused and obsolete. Description from patch #1:

"
Exploring /dev/kmem and /dev/mem in the context of memory hot(un)plug and memory ballooning, I started questioning the existance of /dev/kmem.

Comparing it with the /proc/kcore implementation, it does not seem to be able to deal with things like
a) Pages unmapped from the direct mapping (e.g., to be used by secretmem) -> kern_addr_valid(). virt_addr_valid() is not sufficient.
b) Special cases like gart aperture memory that is not to be touched -> mem_pfn_is_ram()
Unless I am missing something, it's at least broken in some cases and might fault/crash the machine.

Looks like its existance has been questioned before in 2005 and 2010 [1], after ~11 additional years, it might make sense to revive the discussion.

CONFIG_DEVKMEM is only enabled in a single defconfig (on purpose or by mistake?). All distributions disable it: in Ubuntu it has been disabled for more than 10 years, in Debian since 2.6.31, in Fedora at least starting with FC3, in RHEL starting with RHEL4, in SUSE starting from 15sp2, and OpenSUSE has it disabled as well.

1) /dev/kmem was popular for rootkits [2] before it got disabled basically everywhere. Ubuntu documents [3] "There is no modern user of /dev/kmem any more beyond attackers using it to load kernel rootkits.". RHEL documents in a BZ [5] "it served no practical purpose other than to serve as a potential security problem or to enable binary module drivers to access structures/functions they shouldn't be touching"

2) /proc/kcore is a decent interface to have a controlled way to read kernel memory for debugging puposes. (will need some extensions to deal with memory offlining/unplug, memory ballooning, and poisoned pages, though)

3) It might be useful for corner case debugging [1]. KDB/KGDB might be a better fit, especially, to write random memory; harder to shoot yourself into the foot.

4) "Kernel Memory Editor" [4] hasn't seen any updates since 2000 and seems to be incompatible with 64bit [1]. For educational purposes, /proc/kcore might be used to monitor value updates -- or older kernels can be used.

5) It's broken on arm64, and therefore, completely disabled there.

Looks like it's essentially unused and has been replaced by better suited interfaces for individual tasks (/proc/kcore, KDB/KGDB). Let's just remove it.

[1] https://lwn.net/Articles/147901/
[2] https://www.linuxjournal.com/article/10505
[3] https://wiki.ubuntu.com/Security/Features#A.2Fdev.2Fkmem_disabled
[4] https://sourceforge.net/projects/kme/
[5] https://bugzilla.redhat.com/show_bug.cgi?id=154796
"

RFC -> v1:
- "drivers/char: remove /dev/kmem for good"
-- Add more details to patch description regarding distributions
- "mm/vmalloc: remove vwrite()"
-- Also remove the nommu variant
- Compile-tested on more archs/configs

David Hildenbrand (3):
drivers/char: remove /dev/kmem for good
mm: remove xlate_dev_kmem_ptr()
mm/vmalloc: remove vwrite()

 Documentation/admin-guide/devices.txt     |   2 +-
 arch/alpha/include/asm/io.h               |   5 -
 arch/arm/configs/dove_defconfig           |   1 -
 arch/arm/configs/magician_defconfig       |   1 -
 arch/arm/configs/moxart_defconfig         |   1 -
 arch/arm/configs/mps2_defconfig           |   1 -
 arch/arm/configs/mvebu_v5_defconfig       |   1 -
 arch/arm/configs/xcep_defconfig           |   1 -
 arch/arm/include/asm/io.h                 |   5 -
 arch/h8300/configs/edosk2674_defconfig    |   1 -
 arch/h8300/configs/h8300h-sim_defconfig   |   1 -
 arch/h8300/configs/h8s-sim_defconfig      |   1 -
 arch/hexagon/configs/comet_defconfig      |   1 -
 arch/hexagon/include/asm/io.h             |   1 -
 arch/ia64/include/asm/io.h                |   1 -
 arch/ia64/include/asm/uaccess.h           |  18 --
 arch/m68k/configs/amcore_defconfig        |   1 -
 arch/m68k/include/asm/io_mm.h             |   5 -
 arch/mips/include/asm/io.h                |   5 -
 arch/openrisc/configs/or1ksim_defconfig   |   1 -
 arch/parisc/include/asm/io.h              |   5 -
 arch/powerpc/include/asm/io.h             |   5 -
 arch/s390/include/asm/io.h                |   5 -
 arch/sh/configs/edosk7705_defconfig       |   1 -
 arch/sh/configs/se7206_defconfig          |   1 -
 arch/sh/configs/sh2007_defconfig          |   1 -
 arch/sh/configs/sh7724_generic_defconfig  |   1 -
 arch/sh/configs/sh7770_generic_defconfig  |   1 -
 arch/sh/configs/sh7785lcr_32bit_defconfig |   1 -
 arch/sh/include/asm/io.h                  |   5 -
 arch/sparc/configs/sparc64_defconfig      |   1 -
 arch/sparc/include/asm/io_64.h            |   5 -
 arch/xtensa/configs/xip_kc705_defconfig   |   1 -
 drivers/char/Kconfig                      |  10 -
 drivers/char/mem.c                        | 231 ----------------------
 include/asm-generic/io.h                  |  11 --
 include/linux/fs.h                        |   2 +-
 include/linux/vmalloc.h                   |   3 +-
 kernel/configs/android-base.config        |   1 -
 mm/ksm.c                                  |   2 +-
 mm/nommu.c                                |  10 -
 mm/vmalloc.c                              | 118 +----------
 42 files changed, 6 insertions(+), 469 deletions(-)

base-commit: 0d02ec6b3136c73c09e7859f0d0e4e2c4c07b49b

Signature · 1 line
2.29.2
#1 lore raw

PATCH 1/3 drivers/char: remove /dev/kmem for good

Exploring /dev/kmem and /dev/mem in the context of memory hot(un)plug and memory ballooning, I started questioning the existance of /dev/kmem.

Comparing it with the /proc/kcore implementation, it does not seem to be able to deal with things like
a) Pages unmapped from the direct mapping (e.g., to be used by secretmem) -> kern_addr_valid(). virt_addr_valid() is not sufficient.
b) Special cases like gart aperture memory that is not to be touched -> mem_pfn_is_ram()
Unless I am missing something, it's at least broken in some cases and might fault/crash the machine.

Looks like its existance has been questioned before in 2005 and 2010 [1], after ~11 additional years, it might make sense to revive the discussion.

CONFIG_DEVKMEM is only enabled in a single defconfig (on purpose or by mistake?). All distributions disable it: in Ubuntu it has been disabled for more than 10 years, in Debian since 2.6.31, in Fedora at least starting with FC3, in RHEL starting with RHEL4, in SUSE starting from 15sp2, and OpenSUSE has it disabled as well.

1) /dev/kmem was popular for rootkits [2] before it got disabled basically everywhere. Ubuntu documents [3] "There is no modern user of /dev/kmem any more beyond attackers using it to load kernel rootkits.". RHEL documents in a BZ [5] "it served no practical purpose other than to serve as a potential security problem or to enable binary module drivers to access structures/functions they shouldn't be touching"

2) /proc/kcore is a decent interface to have a controlled way to read kernel memory for debugging puposes. (will need some extensions to deal with memory offlining/unplug, memory ballooning, and poisoned pages, though)

3) It might be useful for corner case debugging [1]. KDB/KGDB might be a better fit, especially, to write random memory; harder to shoot yourself into the foot.

4) "Kernel Memory Editor" [4] hasn't seen any updates since 2000 and seems to be incompatible with 64bit [1]. For educational purposes, /proc/kcore might be used to monitor value updates -- or older kernels can be used.

5) It's broken on arm64, and therefore, completely disabled there.

Looks like it's essentially unused and has been replaced by better suited interfaces for individual tasks (/proc/kcore, KDB/KGDB). Let's just remove it.

[1] https://lwn.net/Articles/147901/
[2] https://www.linuxjournal.com/article/10505
[3] https://wiki.ubuntu.com/Security/Features#A.2Fdev.2Fkmem_disabled
[4] https://sourceforge.net/projects/kme/
[5] https://bugzilla.redhat.com/show_bug.cgi?id=154796

Cc Linus Torvalds <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andrew Morton <[email protected]>
Cc "Alexander A. Klimov" <[email protected]>
Cc Alexander Viro <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Andrey Zhizhikin <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Brian Cain <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Chris Zankel <[email protected]>
Cc Corentin Labbe <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc "Eric W. Biederman" <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Gerald Schaefer <[email protected]>
Cc Greentime Hu <[email protected]>
Cc Gregory Clement <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Helge Deller <[email protected]>
Cc Hillf Danton <[email protected]>
Cc huang ying <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Ivan Kokshaysky <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc James Troup <[email protected]>
Cc Jiaxun Yang <[email protected]>
Cc Jonas Bonn <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Kairui Song <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Kuninori Morimoto <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
Cc Luc Van Oostenryck <[email protected]>
Cc Luis Chamberlain <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Matt Turner <[email protected]>
Cc Max Filippov <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Mikulas Patocka <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Niklas Schnelle <[email protected]>
Cc Oleksiy Avramchenko <[email protected]>
Cc Palmer Dabbelt <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc "Pavel Machek (CIP)" <[email protected]>
Cc Pavel Machek <[email protected]>
Cc "Peter Zijlstra (Intel)" <[email protected]>
Cc Pierre Morel <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Rich Felker <[email protected]>
Cc Robert Richter <[email protected]>
Cc Rob Herring <[email protected]>
Cc Russell King <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Sebastian Andrzej Siewior <[email protected]>
Cc Sebastian Hesselbarth <[email protected]>
Cc Stafford Horne <[email protected]>
Cc Stefan Kristiansson <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Sudeep Holla <[email protected]>
Cc Theodore Dubois <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Viresh Kumar <[email protected]>
Cc William Cohen <[email protected]>
Cc Xiaoming Ni <[email protected]>
Cc Yoshinori Sato <[email protected]>
Cc Linux API <[email protected]>
---
 Documentation/admin-guide/devices.txt     |   2 +-
 arch/arm/configs/dove_defconfig           |   1 -
 arch/arm/configs/magician_defconfig       |   1 -
 arch/arm/configs/moxart_defconfig         |   1 -
 arch/arm/configs/mps2_defconfig           |   1 -
 arch/arm/configs/mvebu_v5_defconfig       |   1 -
 arch/arm/configs/xcep_defconfig           |   1 -
 arch/h8300/configs/edosk2674_defconfig    |   1 -
 arch/h8300/configs/h8300h-sim_defconfig   |   1 -
 arch/h8300/configs/h8s-sim_defconfig      |   1 -
 arch/hexagon/configs/comet_defconfig      |   1 -
 arch/m68k/configs/amcore_defconfig        |   1 -
 arch/openrisc/configs/or1ksim_defconfig   |   1 -
 arch/sh/configs/edosk7705_defconfig       |   1 -
 arch/sh/configs/se7206_defconfig          |   1 -
 arch/sh/configs/sh2007_defconfig          |   1 -
 arch/sh/configs/sh7724_generic_defconfig  |   1 -
 arch/sh/configs/sh7770_generic_defconfig  |   1 -
 arch/sh/configs/sh7785lcr_32bit_defconfig |   1 -
 arch/sparc/configs/sparc64_defconfig      |   1 -
 arch/xtensa/configs/xip_kc705_defconfig   |   1 -
 drivers/char/Kconfig                      |  10 -
 drivers/char/mem.c                        | 231 ----------------------
 include/linux/fs.h                        |   2 +-
 include/linux/vmalloc.h                   |   2 +-
 kernel/configs/android-base.config        |   1 -
 mm/ksm.c                                  |   2 +-
 mm/vmalloc.c                              |   2 +-
 28 files changed, 5 insertions(+), 267 deletions(-)
Documentation/admin-guide/devices.txt +1 -1
index 63fd4e6a014b..beffd5e9130a 100644
@@ -4,7 +4,7 @@
 
    1 char	Memory devices
 		  1 = /dev/mem		Physical memory access
-		  2 = /dev/kmem		Kernel virtual memory access
+		  2 = /dev/kmem		OBSOLETE - replaced by /proc/kcore
 		  3 = /dev/null		Null device
 		  4 = /dev/port		I/O port access
 		  5 = /dev/zero		Null byte source
arch/arm/configs/dove_defconfig +0 -1
index e70c997d5f4c..b935162a8bba 100644
@@ -63,7 +63,6 @@ CONFIG_INPUT_EVDEV=y
 # CONFIG_MOUSE_PS2 is not set
 # CONFIG_SERIO is not set
 CONFIG_LEGACY_PTY_COUNT=16
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_RUNTIME_UARTS=2
arch/arm/configs/magician_defconfig +0 -1
index b4670d42f378..abde1fb23b20 100644
@@ -72,7 +72,6 @@ CONFIG_INPUT_TOUCHSCREEN=y
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_UINPUT=m
 # CONFIG_SERIO is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_PXA=y
 # CONFIG_LEGACY_PTYS is not set
 # CONFIG_HW_RANDOM is not set
arch/arm/configs/moxart_defconfig +0 -1
index 6834e97af348..eacc089d86c5 100644
@@ -79,7 +79,6 @@ CONFIG_INPUT_EVBUG=y
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
 # CONFIG_LEGACY_PTYS is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_NR_UARTS=1
arch/arm/configs/mps2_defconfig +0 -1
index 1d923dbb9928..89f4a6ff30bd 100644
@@ -69,7 +69,6 @@ CONFIG_SMSC911X=y
 # CONFIG_VT is not set
 # CONFIG_LEGACY_PTYS is not set
 CONFIG_SERIAL_NONSTANDARD=y
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_MPS2_UART_CONSOLE=y
 CONFIG_SERIAL_MPS2_UART=y
 # CONFIG_HW_RANDOM is not set
arch/arm/configs/mvebu_v5_defconfig +0 -1
index 4f16716bfc32..d57ff30dabff 100644
@@ -100,7 +100,6 @@ CONFIG_INPUT_EVDEV=y
 CONFIG_KEYBOARD_GPIO=y
 # CONFIG_INPUT_MOUSE is not set
 CONFIG_LEGACY_PTY_COUNT=16
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_RUNTIME_UARTS=2
arch/arm/configs/xcep_defconfig +0 -1
index f1fbdfc5c8c6..4d8e7f2eaef7 100644
@@ -53,7 +53,6 @@ CONFIG_NET_ETHERNET=y
 # CONFIG_INPUT_KEYBOARD is not set
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_SERIO is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_PXA=y
 CONFIG_SERIAL_PXA_CONSOLE=y
 # CONFIG_LEGACY_PTYS is not set
arch/h8300/configs/edosk2674_defconfig +0 -1
index 23791dcf6c25..7137883ff4c7 100644
@@ -32,7 +32,6 @@ CONFIG_BINFMT_FLAT=y
 # CONFIG_VT is not set
 # CONFIG_UNIX98_PTYS is not set
 # CONFIG_LEGACY_PTYS is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
 # CONFIG_HW_RANDOM is not set
arch/h8300/configs/h8300h-sim_defconfig +0 -1
index 7fc9c2f0acc0..d4e066a1529a 100644
@@ -32,7 +32,6 @@ CONFIG_BINFMT_FLAT=y
 # CONFIG_VT is not set
 # CONFIG_UNIX98_PTYS is not set
 # CONFIG_LEGACY_PTYS is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_EARLYCON=y
 # CONFIG_HW_RANDOM is not set
arch/h8300/configs/h8s-sim_defconfig +0 -1
index 23791dcf6c25..7137883ff4c7 100644
@@ -32,7 +32,6 @@ CONFIG_BINFMT_FLAT=y
 # CONFIG_VT is not set
 # CONFIG_UNIX98_PTYS is not set
 # CONFIG_LEGACY_PTYS is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
 # CONFIG_HW_RANDOM is not set
arch/hexagon/configs/comet_defconfig +0 -1
index f19ae2ab0aaa..c5a214716a38 100644
@@ -34,7 +34,6 @@ CONFIG_NET_ETHERNET=y
 # CONFIG_SERIO is not set
 # CONFIG_CONSOLE_TRANSLATIONS is not set
 CONFIG_LEGACY_PTY_COUNT=64
-# CONFIG_DEVKMEM is not set
 # CONFIG_HW_RANDOM is not set
 CONFIG_SPI=y
 CONFIG_SPI_DEBUG=y
arch/m68k/configs/amcore_defconfig +0 -1
index 3a84f24d41c8..6d9ed2198170 100644
@@ -60,7 +60,6 @@ CONFIG_DM9000=y
 # CONFIG_VT is not set
 # CONFIG_UNIX98_PTYS is not set
 # CONFIG_DEVMEM is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_MCF=y
 CONFIG_SERIAL_MCF_BAUDRATE=115200
 CONFIG_SERIAL_MCF_CONSOLE=y
arch/openrisc/configs/or1ksim_defconfig +0 -1
index 75f2da324d0e..6e1e004047c7 100644
@@ -43,7 +43,6 @@ CONFIG_MICREL_PHY=y
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
 # CONFIG_LEGACY_PTYS is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_OF_PLATFORM=y
arch/sh/configs/edosk7705_defconfig +0 -1
index ef7cc31997b1..9ee35269bee2 100644
@@ -23,7 +23,6 @@ CONFIG_SH_PCLK_FREQ=31250000
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
-# CONFIG_DEVKMEM is not set
 # CONFIG_UNIX98_PTYS is not set
 # CONFIG_LEGACY_PTYS is not set
 # CONFIG_HW_RANDOM is not set
arch/sh/configs/se7206_defconfig +0 -1
index 315b04a8dd2f..601d062250d1 100644
@@ -71,7 +71,6 @@ CONFIG_SMC91X=y
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_NR_UARTS=4
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
arch/sh/configs/sh2007_defconfig +0 -1
index 99975db461d8..79f02f1c0dc8 100644
@@ -75,7 +75,6 @@ CONFIG_INPUT_FF_MEMLESS=y
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_SERIO is not set
 CONFIG_VT_HW_CONSOLE_BINDING=y
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
 # CONFIG_LEGACY_PTYS is not set
arch/sh/configs/sh7724_generic_defconfig +0 -1
index 2c46c0004780..cbc9389a89a8 100644
@@ -18,7 +18,6 @@ CONFIG_CPU_IDLE=y
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_NR_UARTS=6
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
arch/sh/configs/sh7770_generic_defconfig +0 -1
index 88193153e51b..ee2357deba0f 100644
@@ -20,7 +20,6 @@ CONFIG_CPU_IDLE=y
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_NR_UARTS=6
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
arch/sh/configs/sh7785lcr_32bit_defconfig +0 -1
index 9b885c14c400..5c725c75fcef 100644
@@ -66,7 +66,6 @@ CONFIG_INPUT_FF_MEMLESS=m
 CONFIG_INPUT_EVDEV=y
 CONFIG_INPUT_EVBUG=m
 CONFIG_VT_HW_CONSOLE_BINDING=y
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_NR_UARTS=6
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
arch/sparc/configs/sparc64_defconfig +0 -1
index 12a4fb0bd52a..18099099583e 100644
@@ -122,7 +122,6 @@ CONFIG_INPUT_SPARCSPKR=y
 # CONFIG_SERIO_SERPORT is not set
 CONFIG_SERIO_PCIPS2=m
 CONFIG_SERIO_RAW=m
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SUNSU=y
 CONFIG_SERIAL_SUNSU_CONSOLE=y
 CONFIG_SERIAL_SUNSAB=y
arch/xtensa/configs/xip_kc705_defconfig +0 -1
index 4f1ff9531f6a..062148e17135 100644
@@ -72,7 +72,6 @@ CONFIG_MARVELL_PHY=y
 # CONFIG_INPUT_KEYBOARD is not set
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_SERIO is not set
-CONFIG_DEVKMEM=y
 CONFIG_SERIAL_8250=y
 # CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
 CONFIG_SERIAL_8250_CONSOLE=y
drivers/char/Kconfig +0 -10
index d229a2d0c017..b151e0fcdeb5 100644
@@ -334,16 +334,6 @@ config DEVMEM
 	  memory.
 	  When in doubt, say "Y".
 
-config DEVKMEM
-	bool "/dev/kmem virtual device support"
-	# On arm64, VMALLOC_START < PAGE_OFFSET, which confuses kmem read/write
-	depends on !ARM64
-	help
-	  Say Y here if you want to support the /dev/kmem device. The
-	  /dev/kmem device is rarely used, but can be used for certain
-	  kind of kernel debugging operations.
-	  When in doubt, say "N".
-
 config NVRAM
 	tristate "/dev/nvram support"
 	depends on X86 || HAVE_ARCH_NVRAM_OPS
drivers/char/mem.c +0 -231

255 lines not on this page · raw message

include/linux/fs.h +1 -1
index ec8f3ddf4a6a..a727186ef4cd 100644
@@ -144,7 +144,7 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
 /* Expect random access pattern */
 #define FMODE_RANDOM		((__force fmode_t)0x1000)
 
-/* File is huge (eg. /dev/kmem): treat loff_t as unsigned */
+/* File is huge (eg. /dev/mem): treat loff_t as unsigned */
 #define FMODE_UNSIGNED_OFFSET	((__force fmode_t)0x2000)
 
 /* File is opened with O_PATH; almost nothing can be done with it */
include/linux/vmalloc.h +1 -1
index df92211cf771..390af680e916 100644
@@ -198,7 +198,7 @@ static inline void set_vm_flush_reset_perms(void *addr)
 }
 #endif
 
-/* for /dev/kmem */
+/* for /proc/kcore */
 extern long vread(char *buf, char *addr, unsigned long count);
 extern long vwrite(char *buf, char *addr, unsigned long count);
 
kernel/configs/android-base.config +0 -1
index d3fd428f4b92..eb701b2ac72f 100644
@@ -1,5 +1,4 @@
 #  KEEP ALPHABETICALLY SORTED
-# CONFIG_DEVKMEM is not set
 # CONFIG_DEVMEM is not set
 # CONFIG_FHANDLE is not set
 # CONFIG_INET_LRO is not set
mm/ksm.c +1 -1
index 9694ee2c71de..901cab89299d 100644
@@ -461,7 +461,7 @@ static inline bool ksm_test_exit(struct mm_struct *mm)
  * but taking great care only to touch a ksm page, in a VM_MERGEABLE vma,
  * in case the application has unmapped and remapped mm,addr meanwhile.
  * Could a ksm page appear anywhere else?  Actually yes, in a VM_PFNMAP
- * mmap of /dev/mem or /dev/kmem, where we would not want to touch it.
+ * mmap of /dev/mem, where we would not want to touch it.
  *
  * FAULT_FLAG/FOLL_REMOTE are because we do this outside the context
  * of the process that owns 'vma'.  We also do not want to enforce
mm/vmalloc.c +1 -1
index 4f5f8c907897..ccb405b82581 100644
@@ -2875,7 +2875,7 @@ static int aligned_vwrite(char *buf, char *addr, unsigned long count)
  * Note: In usual ops, vread() is never necessary because the caller
  * should know vmalloc() area is valid and can use memcpy().
  * This is for routines which have to access vmalloc area without
- * any information, as /dev/kmem.
+ * any information, as /proc/kcore.
  *
  * Return: number of bytes for which addr and buf should be increased
  * (same number as @count) or %0 if [addr...addr+count) doesn't
Signature · 1 line
2.29.2
#2 lore raw

PATCH 2/3 mm: remove xlate_dev_kmem_ptr()

In reply to David Hildenbrand

Since /dev/kmem has been removed, let's remove the xlate_dev_kmem_ptr() leftovers.

Cc Linus Torvalds <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Ivan Kokshaysky <[email protected]>
Cc Matt Turner <[email protected]>
Cc Russell King <[email protected]>
Cc Brian Cain <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Yoshinori Sato <[email protected]>
Cc Rich Felker <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Mikulas Patocka <[email protected]>
Cc Luc Van Oostenryck <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Palmer Dabbelt <[email protected]>
Cc Luis Chamberlain <[email protected]>
Cc Greentime Hu <[email protected]>
Cc Sebastian Andrzej Siewior <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Jiaxun Yang <[email protected]>
Cc "Peter Zijlstra (Intel)" <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Gerald Schaefer <[email protected]>
Cc Niklas Schnelle <[email protected]>
Cc Pierre Morel <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Kuninori Morimoto <[email protected]>
---
 arch/alpha/include/asm/io.h     |  5 -----
 arch/arm/include/asm/io.h       |  5 -----
 arch/hexagon/include/asm/io.h   |  1 -
 arch/ia64/include/asm/io.h      |  1 -
 arch/ia64/include/asm/uaccess.h | 18 ------------------
 arch/m68k/include/asm/io_mm.h   |  5 -----
 arch/mips/include/asm/io.h      |  5 -----
 arch/parisc/include/asm/io.h    |  5 -----
 arch/powerpc/include/asm/io.h   |  5 -----
 arch/s390/include/asm/io.h      |  5 -----
 arch/sh/include/asm/io.h        |  5 -----
 arch/sparc/include/asm/io_64.h  |  5 -----
 include/asm-generic/io.h        | 11 -----------
 13 files changed, 76 deletions(-)
arch/alpha/include/asm/io.h +0 -5
index 1f6a909d1fa5..0fab5ac90775 100644
@@ -602,11 +602,6 @@ extern void outsl (unsigned long port, const void *src, unsigned long count);
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 #endif /* __KERNEL__ */
 
 #endif /* __ALPHA_IO_H */
arch/arm/include/asm/io.h +0 -5
index fc748122f1e0..f74944c6fe8d 100644
@@ -430,11 +430,6 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 #include <asm-generic/io.h>
 
 #ifdef CONFIG_MMU
arch/hexagon/include/asm/io.h +0 -1
index bda2a9c2df78..c33241425a5c 100644
@@ -64,7 +64,6 @@ static inline void *phys_to_virt(unsigned long address)
  * convert a physical pointer to a virtual kernel pointer for
  * /dev/mem access.
  */
-#define xlate_dev_kmem_ptr(p)    __va(p)
 #define xlate_dev_mem_ptr(p)    __va(p)
 
 /*
arch/ia64/include/asm/io.h +0 -1
index 3d666a11a2de..6d93b923b379 100644
@@ -277,7 +277,6 @@ extern void memset_io(volatile void __iomem *s, int c, long n);
 #define memcpy_fromio memcpy_fromio
 #define memcpy_toio memcpy_toio
 #define memset_io memset_io
-#define xlate_dev_kmem_ptr xlate_dev_kmem_ptr
 #define xlate_dev_mem_ptr xlate_dev_mem_ptr
 #include <asm-generic/io.h>
 #undef PCI_IOBASE
arch/ia64/include/asm/uaccess.h +0 -18
index 179243c3dfc7..e19d2dcc0ced 100644
@@ -272,22 +272,4 @@ xlate_dev_mem_ptr(phys_addr_t p)
 	return ptr;
 }
 
-/*
- * Convert a virtual cached kernel memory pointer to an uncached pointer
- */
-static __inline__ void *
-xlate_dev_kmem_ptr(void *p)
-{
-	struct page *page;
-	void *ptr;
-
-	page = virt_to_page((unsigned long)p);
-	if (PageUncached(page))
-		ptr = (void *)__pa(p) + __IA64_UNCACHED_OFFSET;
-	else
-		ptr = p;
-
-	return ptr;
-}
-
 #endif /* _ASM_IA64_UACCESS_H */
arch/m68k/include/asm/io_mm.h +0 -5
index 819f611dccf2..d41fa488453b 100644
@@ -397,11 +397,6 @@ static inline void isa_delay(void)
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 #define readb_relaxed(addr)	readb(addr)
 #define readw_relaxed(addr)	readw(addr)
 #define readl_relaxed(addr)	readl(addr)
arch/mips/include/asm/io.h +0 -5
index 78537aa23500..e6373e7ac892 100644
@@ -552,11 +552,6 @@ extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 void __ioread64_copy(void *to, const void __iomem *from, size_t count);
 
 #endif /* _ASM_IO_H */
arch/parisc/include/asm/io.h +0 -5
index 8a11b8cf4719..0b5259102319 100644
@@ -316,11 +316,6 @@ extern void iowrite64be(u64 val, void __iomem *addr);
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 extern int devmem_is_allowed(unsigned long pfn);
 
 #endif
arch/powerpc/include/asm/io.h +0 -5
index 273edd208ec5..f130783c8301 100644
@@ -662,11 +662,6 @@ static inline void name at					\
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 /*
  * We don't do relaxed operations yet, at least not with this semantic
  */
arch/s390/include/asm/io.h +0 -5
index 28664ee0abc1..e3882b012bfa 100644
@@ -20,11 +20,6 @@ void *xlate_dev_mem_ptr(phys_addr_t phys);
 #define unxlate_dev_mem_ptr unxlate_dev_mem_ptr
 void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 #define IO_SPACE_LIMIT 0
 
 void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot);
arch/sh/include/asm/io.h +0 -5
index 6d5c6463bc07..cf9a3ec32406 100644
@@ -283,11 +283,6 @@ static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 #define ARCH_HAS_VALID_PHYS_ADDR_RANGE
 int valid_phys_addr_range(phys_addr_t addr, size_t size);
 int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
arch/sparc/include/asm/io_64.h +0 -5
index 9bb27e5c22f1..ff6fe387d78c 100644
@@ -450,11 +450,6 @@ void sbus_set_sbus64(struct device *, int);
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 #endif
 
 #endif /* !(__SPARC64_IO_H) */
include/asm-generic/io.h +0 -11
index c6af40ce03be..33d4746b086f 100644
@@ -1045,17 +1045,6 @@ static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
 #endif
 #endif /* CONFIG_GENERIC_IOMAP */
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#ifndef xlate_dev_kmem_ptr
-#define xlate_dev_kmem_ptr xlate_dev_kmem_ptr
-static inline void *xlate_dev_kmem_ptr(void *addr)
-{
-	return addr;
-}
-#endif
-
 #ifndef xlate_dev_mem_ptr
 #define xlate_dev_mem_ptr xlate_dev_mem_ptr
 static inline void *xlate_dev_mem_ptr(phys_addr_t addr)
Signature · 1 line
2.29.2
#3 lore raw

PATCH 3/3 mm/vmalloc: remove vwrite()

In reply to David Hildenbrand

The last user (/dev/kmem) is gone. Let's drop it.

Cc Linus Torvalds <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Hillf Danton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Oleksiy Avramchenko <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Minchan Kim <[email protected]>
Cc huang ying <[email protected]>
---
 include/linux/vmalloc.h |   1 -
 mm/nommu.c              |  10 ----
 mm/vmalloc.c            | 116 +---------------------------------------
 3 files changed, 1 insertion(+), 126 deletions(-)
include/linux/vmalloc.h +0 -1
index 390af680e916..9c1b17c7dd95 100644
@@ -200,7 +200,6 @@ static inline void set_vm_flush_reset_perms(void *addr)
 
 /* for /proc/kcore */
 extern long vread(char *buf, char *addr, unsigned long count);
-extern long vwrite(char *buf, char *addr, unsigned long count);
 
 /*
  *	Internals.  Dont't use..
mm/nommu.c +0 -10
index 5c9ab799c0e6..85a3a68dffb6 100644
@@ -210,16 +210,6 @@ long vread(char *buf, char *addr, unsigned long count)
 	return count;
 }
 
-long vwrite(char *buf, char *addr, unsigned long count)
-{
-	/* Don't allow overflow */
-	if ((unsigned long) addr + count < count)
-		count = -(unsigned long) addr;
-
-	memcpy(addr, buf, count);
-	return count;
-}
-
 /*
  *	vmalloc  -  allocate virtually contiguous memory
  *
mm/vmalloc.c +1 -115

134 lines not on this page · raw message

Signature · 1 line
2.29.2
maintainer
#4 lore raw
In reply to David Hildenbrand
Quoted 2 lines

Let's remove /dev/kmem, which is unused and obsolete.

I grabbed these. Silently - the cc list is amazing ;)

I was wondering if it would be better to permanently disable /dev/kmem in Kconfig along with a comment "if you really want this thing then email peeps@places with a very good reason why". Let that ride for a year or three then blam.

But this is so much more attractive, and it certainly sounds like it's worth any damage it might cause.

We do tend to think about distros. I bet there are a number of weird embedded type systems using /dev/kmem - it's amazing what sorts of hacks those people will put up with the get something out the door. But those systems tend to carry a lot of specialized changes anyway, so they can just add "revert David's patch" to their pile.

#5 lore raw
Quoted 10 lines · Andrew Morton
Quoted 2 lines

Let's remove /dev/kmem, which is unused and obsolete.

I grabbed these. Silently - the cc list is amazing ;)

I was wondering if it would be better to permanently disable /dev/kmem in Kconfig along with a comment "if you really want this thing then email peeps@places with a very good reason why". Let that ride for a year or three then blam.

Quoted 9 lines

But this is so much more attractive, and it certainly sounds like it's worth any damage it might cause.

We do tend to think about distros. I bet there are a number of weird embedded type systems using /dev/kmem - it's amazing what sorts of hacks those people will put up with the get something out the door. But those systems tend to carry a lot of specialized changes anyway, so they can just add "revert David's patch" to their pile.

I wonder if we should have the opposite of driver/staging and call it outgoing, with a big thank you to the users and developers and also to indicate this feature will be removed in the next (few) merge(s) cycles. I guess not all code can be accumulated under a single hierarchy. May not be worth the effort, just thinking out loud.

Balbir Singh

#6 lore raw
Quoted 22 lines · Balbir Singh
Quoted 10 lines · Andrew Morton
Quoted 2 lines

Let's remove /dev/kmem, which is unused and obsolete.

I grabbed these. Silently - the cc list is amazing ;)

I was wondering if it would be better to permanently disable /dev/kmem in Kconfig along with a comment "if you really want this thing then email peeps@places with a very good reason why". Let that ride for a year or three then blam.

Quoted 9 lines

But this is so much more attractive, and it certainly sounds like it's worth any damage it might cause.

We do tend to think about distros. I bet there are a number of weird embedded type systems using /dev/kmem - it's amazing what sorts of hacks those people will put up with the get something out the door. But those systems tend to carry a lot of specialized changes anyway, so they can just add "revert David's patch" to their pile.

Quoted 5 lines

I wonder if we should have the opposite of driver/staging and call it outgoing, with a big thank you to the users and developers and also to indicate this feature will be removed in the next (few) merge(s) cycles. I guess not all code can be accumulated under a single hierarchy. May not be worth the effort, just thinking out loud.

That is exactly what drivers/staging/ is being used for, for stuff on the way out of the kernel. wimax just left the kernel that way a week or so ago, we've been doing this for many years now, the fact that no one has noticed is good as that means that no one has needed the code removed that way :)

thanks,

greg k-h

#8 lore raw
In reply to Andrew Morton
Quoted 3 lines · Andrew Morton

We do tend to think about distros. I bet there are a number of weird embedded type systems using /dev/kmem - it's amazing what sorts of hacks those people will put up with the get something out the door.

There certainly are (seen lots of such crap), another good reason for kicking it out asap.

Quoted 2 lines

But those systems tend to carry a lot of specialized changes anyway, so they can just add "revert David's patch" to their pile.

Often those kind of people aren't capable of that. If anyone finds such systems, report them to cert, bsi, fd, ...

--mtx

Signature · 8 lines
---
Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
GPG/PGP-Schlüssel zu.
---
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
[email protected] -- +49-151-27565287