linux-sg2042/drivers
David Hildenbrand bbcd53c960 drivers/char: remove /dev/kmem for good
Patch series "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 existence 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 existence 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

Link: https://lkml.kernel.org/r/20210324102351.6932-1-david@redhat.com
Link: https://lkml.kernel.org/r/20210324102351.6932-2-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Alexander A. Klimov" <grandmaster@al2klimov.de>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Brian Cain <bcain@codeaurora.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Chris Zankel <chris@zankel.net>
Cc: Corentin Labbe <clabbe@baylibre.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Greentime Hu <green.hu@gmail.com>
Cc: Gregory Clement <gregory.clement@bootlin.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Hillf Danton <hdanton@sina.com>
Cc: huang ying <huang.ying.caritas@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: James Troup <james.troup@canonical.com>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kairui Song <kasong@redhat.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Niklas Schnelle <schnelle@linux.ibm.com>
Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
Cc: openrisc@lists.librecores.org
Cc: Palmer Dabbelt <palmerdabbelt@google.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: "Pavel Machek (CIP)" <pavel@denx.de>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Pierre Morel <pmorel@linux.ibm.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Rich Felker <dalias@libc.org>
Cc: Robert Richter <rric@kernel.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: sparclinux@vger.kernel.org
Cc: Stafford Horne <shorne@gmail.com>
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Theodore Dubois <tblodt@icloud.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: William Cohen <wcohen@redhat.com>
Cc: Xiaoming Ni <nixiaoming@huawei.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-05-07 00:26:34 -07:00
..
accessibility TTY/Serial driver updates for 5.13-rc1 2021-04-26 11:20:10 -07:00
acpi acpi,memhotplug: enable MHP_MEMMAP_ON_MEMORY when supported 2021-05-05 11:27:27 -07:00
amba
android selinux/stable-5.13 PR 20210426 2021-04-27 13:42:11 -07:00
ata SCSI misc on 20210428 2021-04-28 17:22:10 -07:00
atm Networking changes for 5.13. 2021-04-29 11:57:23 -07:00
auxdisplay
base init/initramfs.c: do unpacking asynchronously 2021-05-07 00:26:33 -07:00
bcma bcma: remove unused function 2021-04-18 09:36:56 +03:00
block include: remove pagemap.h from blkdev.h 2021-05-06 19:24:11 -07:00
bluetooth Networking changes for 5.13. 2021-04-29 11:57:23 -07:00
bus ARM: SoC drivers for v5.13 2021-04-26 12:11:52 -07:00
cdrom gdrom: fix compilation error 2021-04-11 19:32:06 -06:00
char drivers/char: remove /dev/kmem for good 2021-05-07 00:26:34 -07:00
clk Here's a collection of largely clk driver updates for the merge window. The 2021-04-28 17:13:56 -07:00
clocksource ARM: platform support for Apple M1 2021-04-26 12:30:36 -07:00
comedi staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
connector
counter
cpufreq Power management updates for 5.13-rc1 2021-04-26 15:10:25 -07:00
cpuidle Merge back earlier cpuidle updates for v5.13. 2021-04-08 20:05:49 +02:00
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2021-04-26 08:51:23 -07:00
cxl cxl/mem: Fix memory device capacity probing 2021-04-16 18:21:56 -07:00
dax
dca
devfreq PM / devfreq: imx8m-ddrc: Remove unneeded of_match_ptr() 2021-04-08 13:14:51 +09:00
dio
dma ARM: SoC drivers for v5.13 2021-04-26 12:11:52 -07:00
dma-buf drm/syncobj: use newly allocated stub fences 2021-04-08 12:21:13 +02:00
edac
eisa
extcon - Core Frameworks 2021-04-28 15:59:13 -07:00
firewire The usual updates from the irq departement: 2021-04-26 09:43:16 -07:00
firmware - removed get_fs/set_fs 2021-04-29 11:28:08 -07:00
fpga ARM: SoC drivers for v5.13 2021-04-26 12:11:52 -07:00
fsi
gnss
gpio - Core Frameworks 2021-04-28 15:59:13 -07:00
gpu i915: fix remap_io_sg to verify the pgprot 2021-04-30 11:20:39 -07:00
greybus greybus: es2: fix kernel-doc warnings 2021-04-16 07:26:50 +02:00
hid
hsi HSI: core: fix resource leaks in hsi_add_client_from_dt() 2021-04-16 00:14:49 +02:00
hv printk changes for 5.13 2021-04-27 18:09:44 -07:00
hwmon ACPI updates for 5.13-rc1 2021-04-26 15:03:23 -07:00
hwspinlock
hwtracing coresight: etm-perf: Fix define build issue when built as module 2021-04-16 09:34:57 +02:00
i2c - Core Frameworks 2021-04-28 15:59:13 -07:00
i3c
ide
idle intel_idle: add Iclelake-D support 2021-04-08 19:18:07 +02:00
iio spi: Updates for v5.13 2021-04-26 16:32:11 -07:00
infiniband RDMA/umem: batch page unpin in __ib_umem_release() 2021-04-30 11:20:37 -07:00
input - Core Frameworks 2021-04-28 15:59:13 -07:00
interconnect CFI on arm64 series for v5.13-rc1 2021-04-27 10:16:46 -07:00
iommu
ipack
irqchip - removed get_fs/set_fs 2021-04-29 11:28:08 -07:00
isdn proc: mandate ->proc_lseek in "struct proc_ops" 2021-05-06 19:24:11 -07:00
leds treewide: change my e-mail address, fix my name 2021-04-09 14:54:23 -07:00
lightnvm lightnvm: deprecated OCSSD support and schedule it for removal in Linux 5.15 2021-04-13 09:16:12 -06:00
macintosh
mailbox - qcom: enable support for SM8350 and SC7280 2021-04-28 16:10:33 -07:00
mcb
md include: remove pagemap.h from blkdev.h 2021-05-06 19:24:11 -07:00
media drm for 5.13-rc1 2021-04-28 10:01:40 -07:00
memory Power management updates for 5.13-rc1 2021-04-26 15:10:25 -07:00
memstick memstick: r592: ignore kfifo_out() return code again 2021-04-26 11:08:23 +02:00
message scsi: message: fusion: Remove unused local variable 'vtarget' 2021-04-13 01:39:12 -04:00
mfd - Core Frameworks 2021-04-28 15:59:13 -07:00
misc CFI on arm64 series for v5.13-rc1 2021-04-27 10:16:46 -07:00
mmc MMC core: 2021-04-28 15:56:51 -07:00
most Staging/IIO driver updates for 5.13-rc1 2021-04-26 11:14:21 -07:00
mtd printk changes for 5.13 2021-04-27 18:09:44 -07:00
mux
net proc: mandate ->proc_lseek in "struct proc_ops" 2021-05-06 19:24:11 -07:00
nfc nfc: st-nci: remove unnecessary label 2021-04-13 14:50:57 -07:00
ntb
nubus
nvdimm include: remove pagemap.h from blkdev.h 2021-05-06 19:24:11 -07:00
nvme for-5.13/drivers-2021-04-27 2021-04-28 14:39:37 -07:00
nvmem
of Networking changes for 5.13. 2021-04-29 11:57:23 -07:00
opp
parisc
parport
pci mm/vmalloc: remove unmap_kernel_range 2021-04-30 11:20:40 -07:00
pcmcia
perf
phy Networking changes for 5.13. 2021-04-29 11:57:23 -07:00
pinctrl ARM: SoC drivers for v5.13 2021-04-26 12:11:52 -07:00
platform USB/Thunderbolt patches for 5.13-rc1 2021-04-26 11:32:23 -07:00
pnp
power power supply and reset changes for the v5.13 series 2021-04-28 15:43:58 -07:00
powercap
pps TTY/Serial driver updates for 5.13-rc1 2021-04-26 11:20:10 -07:00
ps3
ptp
pwm - Core Frameworks 2021-04-28 15:59:13 -07:00
rapidio
ras RAS/CEC: Correct ce_add_elem()'s returned values 2021-04-07 11:52:26 +02:00
regulator - Core Frameworks 2021-04-28 15:59:13 -07:00
remoteproc
reset ARM SCMI updates for v5.13 2021-04-08 17:38:20 +02:00
rpmsg
rtc - Core Frameworks 2021-04-28 15:59:13 -07:00
s390 Networking changes for 5.13. 2021-04-29 11:57:23 -07:00
sbus
scsi include: remove pagemap.h from blkdev.h 2021-05-06 19:24:11 -07:00
sh The usual updates from the irq departement: 2021-04-26 09:43:16 -07:00
siox
slimbus
soc ARM: SoC drivers for v5.13 2021-04-26 12:11:52 -07:00
soundwire
spi CFI on arm64 series for v5.13-rc1 2021-04-27 10:16:46 -07:00
spmi
ssb
staging Networking changes for 5.13. 2021-04-29 11:57:23 -07:00
target SCSI misc on 20210428 2021-04-28 17:22:10 -07:00
tc
tee ARM: SoC drivers for v5.13 2021-04-26 12:11:52 -07:00
thermal
thunderbolt thunderbolt: Changes for v5.13 merge window 2021-04-13 12:17:14 +02:00
tty Power management updates for 5.13-rc1 2021-04-26 15:10:25 -07:00
uio
usb SCSI misc on 20210428 2021-04-28 17:22:10 -07:00
vdpa vdpa/mlx5: Set err = -ENOMEM in case dma_map_sg_attrs fails 2021-04-22 18:15:31 -04:00
vfio VFIO updates for v5.13-rc1 2021-04-28 17:19:47 -07:00
vhost SCSI misc on 20210428 2021-04-28 17:22:10 -07:00
video - New Device Support 2021-04-28 16:02:58 -07:00
virt
virtio
visorbus
vlynq
vme
w1 w1: ds28e17: Use module_w1_family to simplify the code 2021-04-10 10:58:21 +02:00
watchdog - Core Frameworks 2021-04-28 15:59:13 -07:00
xen SCSI misc on 20210428 2021-04-28 17:22:10 -07:00
zorro
Kconfig staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
Makefile staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00