Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

David Hildenbrand and committed by
Linus Torvalds
bbcd53c9 cb152a1a

+5 -264
+1 -1
Documentation/admin-guide/devices.txt
··· 4 4 5 5 1 char Memory devices 6 6 1 = /dev/mem Physical memory access 7 - 2 = /dev/kmem Kernel virtual memory access 7 + 2 = /dev/kmem OBSOLETE - replaced by /proc/kcore 8 8 3 = /dev/null Null device 9 9 4 = /dev/port I/O port access 10 10 5 = /dev/zero Null byte source
-1
arch/arm/configs/dove_defconfig
··· 63 63 # CONFIG_MOUSE_PS2 is not set 64 64 # CONFIG_SERIO is not set 65 65 CONFIG_LEGACY_PTY_COUNT=16 66 - # CONFIG_DEVKMEM is not set 67 66 CONFIG_SERIAL_8250=y 68 67 CONFIG_SERIAL_8250_CONSOLE=y 69 68 CONFIG_SERIAL_8250_RUNTIME_UARTS=2
-1
arch/arm/configs/magician_defconfig
··· 72 72 CONFIG_INPUT_MISC=y 73 73 CONFIG_INPUT_UINPUT=m 74 74 # CONFIG_SERIO is not set 75 - # CONFIG_DEVKMEM is not set 76 75 CONFIG_SERIAL_PXA=y 77 76 # CONFIG_LEGACY_PTYS is not set 78 77 # CONFIG_HW_RANDOM is not set
-1
arch/arm/configs/moxart_defconfig
··· 79 79 # CONFIG_SERIO is not set 80 80 # CONFIG_VT is not set 81 81 # CONFIG_LEGACY_PTYS is not set 82 - # CONFIG_DEVKMEM is not set 83 82 CONFIG_SERIAL_8250=y 84 83 CONFIG_SERIAL_8250_CONSOLE=y 85 84 CONFIG_SERIAL_8250_NR_UARTS=1
-1
arch/arm/configs/mps2_defconfig
··· 69 69 # CONFIG_VT is not set 70 70 # CONFIG_LEGACY_PTYS is not set 71 71 CONFIG_SERIAL_NONSTANDARD=y 72 - # CONFIG_DEVKMEM is not set 73 72 CONFIG_SERIAL_MPS2_UART_CONSOLE=y 74 73 CONFIG_SERIAL_MPS2_UART=y 75 74 # CONFIG_HW_RANDOM is not set
-1
arch/arm/configs/mvebu_v5_defconfig
··· 100 100 CONFIG_KEYBOARD_GPIO=y 101 101 # CONFIG_INPUT_MOUSE is not set 102 102 CONFIG_LEGACY_PTY_COUNT=16 103 - # CONFIG_DEVKMEM is not set 104 103 CONFIG_SERIAL_8250=y 105 104 CONFIG_SERIAL_8250_CONSOLE=y 106 105 CONFIG_SERIAL_8250_RUNTIME_UARTS=2
-1
arch/arm/configs/xcep_defconfig
··· 53 53 # CONFIG_INPUT_KEYBOARD is not set 54 54 # CONFIG_INPUT_MOUSE is not set 55 55 # CONFIG_SERIO is not set 56 - # CONFIG_DEVKMEM is not set 57 56 CONFIG_SERIAL_PXA=y 58 57 CONFIG_SERIAL_PXA_CONSOLE=y 59 58 # CONFIG_LEGACY_PTYS is not set
-1
arch/hexagon/configs/comet_defconfig
··· 34 34 # CONFIG_SERIO is not set 35 35 # CONFIG_CONSOLE_TRANSLATIONS is not set 36 36 CONFIG_LEGACY_PTY_COUNT=64 37 - # CONFIG_DEVKMEM is not set 38 37 # CONFIG_HW_RANDOM is not set 39 38 CONFIG_SPI=y 40 39 CONFIG_SPI_DEBUG=y
-1
arch/m68k/configs/amcore_defconfig
··· 60 60 # CONFIG_VT is not set 61 61 # CONFIG_UNIX98_PTYS is not set 62 62 # CONFIG_DEVMEM is not set 63 - # CONFIG_DEVKMEM is not set 64 63 CONFIG_SERIAL_MCF=y 65 64 CONFIG_SERIAL_MCF_BAUDRATE=115200 66 65 CONFIG_SERIAL_MCF_CONSOLE=y
-1
arch/openrisc/configs/or1ksim_defconfig
··· 43 43 # CONFIG_SERIO is not set 44 44 # CONFIG_VT is not set 45 45 # CONFIG_LEGACY_PTYS is not set 46 - # CONFIG_DEVKMEM is not set 47 46 CONFIG_SERIAL_8250=y 48 47 CONFIG_SERIAL_8250_CONSOLE=y 49 48 CONFIG_SERIAL_OF_PLATFORM=y
-1
arch/sh/configs/edosk7705_defconfig
··· 23 23 # CONFIG_INPUT is not set 24 24 # CONFIG_SERIO is not set 25 25 # CONFIG_VT is not set 26 - # CONFIG_DEVKMEM is not set 27 26 # CONFIG_UNIX98_PTYS is not set 28 27 # CONFIG_LEGACY_PTYS is not set 29 28 # CONFIG_HW_RANDOM is not set
-1
arch/sh/configs/se7206_defconfig
··· 71 71 # CONFIG_INPUT is not set 72 72 # CONFIG_SERIO is not set 73 73 # CONFIG_VT is not set 74 - # CONFIG_DEVKMEM is not set 75 74 CONFIG_SERIAL_SH_SCI=y 76 75 CONFIG_SERIAL_SH_SCI_NR_UARTS=4 77 76 CONFIG_SERIAL_SH_SCI_CONSOLE=y
-1
arch/sh/configs/sh2007_defconfig
··· 75 75 # CONFIG_INPUT_MOUSE is not set 76 76 # CONFIG_SERIO is not set 77 77 CONFIG_VT_HW_CONSOLE_BINDING=y 78 - # CONFIG_DEVKMEM is not set 79 78 CONFIG_SERIAL_SH_SCI=y 80 79 CONFIG_SERIAL_SH_SCI_CONSOLE=y 81 80 # CONFIG_LEGACY_PTYS is not set
-1
arch/sh/configs/sh7724_generic_defconfig
··· 18 18 # CONFIG_INPUT is not set 19 19 # CONFIG_SERIO is not set 20 20 # CONFIG_VT is not set 21 - # CONFIG_DEVKMEM is not set 22 21 CONFIG_SERIAL_SH_SCI=y 23 22 CONFIG_SERIAL_SH_SCI_NR_UARTS=6 24 23 CONFIG_SERIAL_SH_SCI_CONSOLE=y
-1
arch/sh/configs/sh7770_generic_defconfig
··· 20 20 # CONFIG_INPUT is not set 21 21 # CONFIG_SERIO is not set 22 22 # CONFIG_VT is not set 23 - # CONFIG_DEVKMEM is not set 24 23 CONFIG_SERIAL_SH_SCI=y 25 24 CONFIG_SERIAL_SH_SCI_NR_UARTS=6 26 25 CONFIG_SERIAL_SH_SCI_CONSOLE=y
-1
arch/sh/configs/sh7785lcr_32bit_defconfig
··· 66 66 CONFIG_INPUT_EVDEV=y 67 67 CONFIG_INPUT_EVBUG=m 68 68 CONFIG_VT_HW_CONSOLE_BINDING=y 69 - # CONFIG_DEVKMEM is not set 70 69 CONFIG_SERIAL_SH_SCI=y 71 70 CONFIG_SERIAL_SH_SCI_NR_UARTS=6 72 71 CONFIG_SERIAL_SH_SCI_CONSOLE=y
-1
arch/sparc/configs/sparc64_defconfig
··· 122 122 # CONFIG_SERIO_SERPORT is not set 123 123 CONFIG_SERIO_PCIPS2=m 124 124 CONFIG_SERIO_RAW=m 125 - # CONFIG_DEVKMEM is not set 126 125 CONFIG_SERIAL_SUNSU=y 127 126 CONFIG_SERIAL_SUNSU_CONSOLE=y 128 127 CONFIG_SERIAL_SUNSAB=y
-1
arch/xtensa/configs/xip_kc705_defconfig
··· 72 72 # CONFIG_INPUT_KEYBOARD is not set 73 73 # CONFIG_INPUT_MOUSE is not set 74 74 # CONFIG_SERIO is not set 75 - CONFIG_DEVKMEM=y 76 75 CONFIG_SERIAL_8250=y 77 76 # CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set 78 77 CONFIG_SERIAL_8250_CONSOLE=y
-10
drivers/char/Kconfig
··· 334 334 memory. 335 335 When in doubt, say "Y". 336 336 337 - config DEVKMEM 338 - bool "/dev/kmem virtual device support" 339 - # On arm64, VMALLOC_START < PAGE_OFFSET, which confuses kmem read/write 340 - depends on !ARM64 341 - help 342 - Say Y here if you want to support the /dev/kmem device. The 343 - /dev/kmem device is rarely used, but can be used for certain 344 - kind of kernel debugging operations. 345 - When in doubt, say "N". 346 - 347 337 config NVRAM 348 338 tristate "/dev/nvram support" 349 339 depends on X86 || HAVE_ARCH_NVRAM_OPS
-231
drivers/char/mem.c
··· 403 403 return 0; 404 404 } 405 405 406 - static int mmap_kmem(struct file *file, struct vm_area_struct *vma) 407 - { 408 - unsigned long pfn; 409 - 410 - /* Turn a kernel-virtual address into a physical page frame */ 411 - pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT; 412 - 413 - /* 414 - * RED-PEN: on some architectures there is more mapped memory than 415 - * available in mem_map which pfn_valid checks for. Perhaps should add a 416 - * new macro here. 417 - * 418 - * RED-PEN: vmalloc is not supported right now. 419 - */ 420 - if (!pfn_valid(pfn)) 421 - return -EIO; 422 - 423 - vma->vm_pgoff = pfn; 424 - return mmap_mem(file, vma); 425 - } 426 - 427 - /* 428 - * This function reads the *virtual* memory as seen by the kernel. 429 - */ 430 - static ssize_t read_kmem(struct file *file, char __user *buf, 431 - size_t count, loff_t *ppos) 432 - { 433 - unsigned long p = *ppos; 434 - ssize_t low_count, read, sz; 435 - char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */ 436 - int err = 0; 437 - 438 - read = 0; 439 - if (p < (unsigned long) high_memory) { 440 - low_count = count; 441 - if (count > (unsigned long)high_memory - p) 442 - low_count = (unsigned long)high_memory - p; 443 - 444 - #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED 445 - /* we don't have page 0 mapped on sparc and m68k.. */ 446 - if (p < PAGE_SIZE && low_count > 0) { 447 - sz = size_inside_page(p, low_count); 448 - if (clear_user(buf, sz)) 449 - return -EFAULT; 450 - buf += sz; 451 - p += sz; 452 - read += sz; 453 - low_count -= sz; 454 - count -= sz; 455 - } 456 - #endif 457 - while (low_count > 0) { 458 - sz = size_inside_page(p, low_count); 459 - 460 - /* 461 - * On ia64 if a page has been mapped somewhere as 462 - * uncached, then it must also be accessed uncached 463 - * by the kernel or data corruption may occur 464 - */ 465 - kbuf = xlate_dev_kmem_ptr((void *)p); 466 - if (!virt_addr_valid(kbuf)) 467 - return -ENXIO; 468 - 469 - if (copy_to_user(buf, kbuf, sz)) 470 - return -EFAULT; 471 - buf += sz; 472 - p += sz; 473 - read += sz; 474 - low_count -= sz; 475 - count -= sz; 476 - if (should_stop_iteration()) { 477 - count = 0; 478 - break; 479 - } 480 - } 481 - } 482 - 483 - if (count > 0) { 484 - kbuf = (char *)__get_free_page(GFP_KERNEL); 485 - if (!kbuf) 486 - return -ENOMEM; 487 - while (count > 0) { 488 - sz = size_inside_page(p, count); 489 - if (!is_vmalloc_or_module_addr((void *)p)) { 490 - err = -ENXIO; 491 - break; 492 - } 493 - sz = vread(kbuf, (char *)p, sz); 494 - if (!sz) 495 - break; 496 - if (copy_to_user(buf, kbuf, sz)) { 497 - err = -EFAULT; 498 - break; 499 - } 500 - count -= sz; 501 - buf += sz; 502 - read += sz; 503 - p += sz; 504 - if (should_stop_iteration()) 505 - break; 506 - } 507 - free_page((unsigned long)kbuf); 508 - } 509 - *ppos = p; 510 - return read ? read : err; 511 - } 512 - 513 - 514 - static ssize_t do_write_kmem(unsigned long p, const char __user *buf, 515 - size_t count, loff_t *ppos) 516 - { 517 - ssize_t written, sz; 518 - unsigned long copied; 519 - 520 - written = 0; 521 - #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED 522 - /* we don't have page 0 mapped on sparc and m68k.. */ 523 - if (p < PAGE_SIZE) { 524 - sz = size_inside_page(p, count); 525 - /* Hmm. Do something? */ 526 - buf += sz; 527 - p += sz; 528 - count -= sz; 529 - written += sz; 530 - } 531 - #endif 532 - 533 - while (count > 0) { 534 - void *ptr; 535 - 536 - sz = size_inside_page(p, count); 537 - 538 - /* 539 - * On ia64 if a page has been mapped somewhere as uncached, then 540 - * it must also be accessed uncached by the kernel or data 541 - * corruption may occur. 542 - */ 543 - ptr = xlate_dev_kmem_ptr((void *)p); 544 - if (!virt_addr_valid(ptr)) 545 - return -ENXIO; 546 - 547 - copied = copy_from_user(ptr, buf, sz); 548 - if (copied) { 549 - written += sz - copied; 550 - if (written) 551 - break; 552 - return -EFAULT; 553 - } 554 - buf += sz; 555 - p += sz; 556 - count -= sz; 557 - written += sz; 558 - if (should_stop_iteration()) 559 - break; 560 - } 561 - 562 - *ppos += written; 563 - return written; 564 - } 565 - 566 - /* 567 - * This function writes to the *virtual* memory as seen by the kernel. 568 - */ 569 - static ssize_t write_kmem(struct file *file, const char __user *buf, 570 - size_t count, loff_t *ppos) 571 - { 572 - unsigned long p = *ppos; 573 - ssize_t wrote = 0; 574 - ssize_t virtr = 0; 575 - char *kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */ 576 - int err = 0; 577 - 578 - if (p < (unsigned long) high_memory) { 579 - unsigned long to_write = min_t(unsigned long, count, 580 - (unsigned long)high_memory - p); 581 - wrote = do_write_kmem(p, buf, to_write, ppos); 582 - if (wrote != to_write) 583 - return wrote; 584 - p += wrote; 585 - buf += wrote; 586 - count -= wrote; 587 - } 588 - 589 - if (count > 0) { 590 - kbuf = (char *)__get_free_page(GFP_KERNEL); 591 - if (!kbuf) 592 - return wrote ? wrote : -ENOMEM; 593 - while (count > 0) { 594 - unsigned long sz = size_inside_page(p, count); 595 - unsigned long n; 596 - 597 - if (!is_vmalloc_or_module_addr((void *)p)) { 598 - err = -ENXIO; 599 - break; 600 - } 601 - n = copy_from_user(kbuf, buf, sz); 602 - if (n) { 603 - err = -EFAULT; 604 - break; 605 - } 606 - vwrite(kbuf, (char *)p, sz); 607 - count -= sz; 608 - buf += sz; 609 - virtr += sz; 610 - p += sz; 611 - if (should_stop_iteration()) 612 - break; 613 - } 614 - free_page((unsigned long)kbuf); 615 - } 616 - 617 - *ppos = p; 618 - return virtr + wrote ? : err; 619 - } 620 - 621 406 static ssize_t read_port(struct file *file, char __user *buf, 622 407 size_t count, loff_t *ppos) 623 408 { ··· 640 855 #define write_zero write_null 641 856 #define write_iter_zero write_iter_null 642 857 #define open_mem open_port 643 - #define open_kmem open_mem 644 858 645 859 static const struct file_operations __maybe_unused mem_fops = { 646 860 .llseek = memory_lseek, ··· 647 863 .write = write_mem, 648 864 .mmap = mmap_mem, 649 865 .open = open_mem, 650 - #ifndef CONFIG_MMU 651 - .get_unmapped_area = get_unmapped_area_mem, 652 - .mmap_capabilities = memory_mmap_capabilities, 653 - #endif 654 - }; 655 - 656 - static const struct file_operations __maybe_unused kmem_fops = { 657 - .llseek = memory_lseek, 658 - .read = read_kmem, 659 - .write = write_kmem, 660 - .mmap = mmap_kmem, 661 - .open = open_kmem, 662 866 #ifndef CONFIG_MMU 663 867 .get_unmapped_area = get_unmapped_area_mem, 664 868 .mmap_capabilities = memory_mmap_capabilities, ··· 696 924 } devlist[] = { 697 925 #ifdef CONFIG_DEVMEM 698 926 [DEVMEM_MINOR] = { "mem", 0, &mem_fops, FMODE_UNSIGNED_OFFSET }, 699 - #endif 700 - #ifdef CONFIG_DEVKMEM 701 - [2] = { "kmem", 0, &kmem_fops, FMODE_UNSIGNED_OFFSET }, 702 927 #endif 703 928 [3] = { "null", 0666, &null_fops, 0 }, 704 929 #ifdef CONFIG_DEVPORT
+1 -1
include/linux/fs.h
··· 145 145 /* Expect random access pattern */ 146 146 #define FMODE_RANDOM ((__force fmode_t)0x1000) 147 147 148 - /* File is huge (eg. /dev/kmem): treat loff_t as unsigned */ 148 + /* File is huge (eg. /dev/mem): treat loff_t as unsigned */ 149 149 #define FMODE_UNSIGNED_OFFSET ((__force fmode_t)0x2000) 150 150 151 151 /* File is opened with O_PATH; almost nothing can be done with it */
+1 -1
include/linux/vmalloc.h
··· 227 227 } 228 228 #endif 229 229 230 - /* for /dev/kmem */ 230 + /* for /proc/kcore */ 231 231 extern long vread(char *buf, char *addr, unsigned long count); 232 232 extern long vwrite(char *buf, char *addr, unsigned long count); 233 233
-1
kernel/configs/android-base.config
··· 1 1 # KEEP ALPHABETICALLY SORTED 2 - # CONFIG_DEVKMEM is not set 3 2 # CONFIG_DEVMEM is not set 4 3 # CONFIG_FHANDLE is not set 5 4 # CONFIG_INET_LRO is not set
+1 -1
mm/ksm.c
··· 459 459 * but taking great care only to touch a ksm page, in a VM_MERGEABLE vma, 460 460 * in case the application has unmapped and remapped mm,addr meanwhile. 461 461 * Could a ksm page appear anywhere else? Actually yes, in a VM_PFNMAP 462 - * mmap of /dev/mem or /dev/kmem, where we would not want to touch it. 462 + * mmap of /dev/mem, where we would not want to touch it. 463 463 * 464 464 * FAULT_FLAG/FOLL_REMOTE are because we do this outside the context 465 465 * of the process that owns 'vma'. We also do not want to enforce
+1 -1
mm/vmalloc.c
··· 3219 3219 * Note: In usual ops, vread() is never necessary because the caller 3220 3220 * should know vmalloc() area is valid and can use memcpy(). 3221 3221 * This is for routines which have to access vmalloc area without 3222 - * any information, as /dev/kmem. 3222 + * any information, as /proc/kcore. 3223 3223 * 3224 3224 * Return: number of bytes for which addr and buf should be increased 3225 3225 * (same number as @count) or %0 if [addr...addr+count) doesn't