Date: | 2010-09-08 02:31:19 (13 years 6 months ago) |
---|---|
Author: | Maarten ter Huurne |
Commit: | b056cd7dd0bc423826ef51be48fe010efbc6e9cc |
Message: | /dev/mem: Add kernel config option to omit this device. Omitting this device prevents software from accessing the hardware directly, which can cause trouble if the kernel accesses the same hardware. It also saves some space on embedded systems. |
Files: |
arch/x86/Kconfig.debug (1 diff) drivers/char/Kconfig (1 diff) drivers/char/mem.c (8 diffs) |
Change Details
arch/x86/Kconfig.debug | ||
---|---|---|
7 | 7 | |
8 | 8 | config STRICT_DEVMEM |
9 | 9 | bool "Filter access to /dev/mem" |
10 | depends on DEVMEM | |
10 | 11 | ---help--- |
11 | 12 | If this option is disabled, you allow userspace (root) access to all |
12 | 13 | of memory, including kernel and userspace memory. Accidental |
drivers/char/Kconfig | ||
---|---|---|
88 | 88 | information. For framebuffer console users, please refer to |
89 | 89 | <file:Documentation/fb/fbcon.txt>. |
90 | 90 | |
91 | config DEVMEM | |
92 | bool "/dev/mem virtual device support" | |
93 | default y | |
94 | help | |
95 | Say Y here if you want to support the /dev/mem device. | |
96 | Some X server drivers access the video hardware using this device. | |
97 | Accessing hardware directly from user space can be useful in some | |
98 | cases, but it is not without risks. | |
99 | When in doubt, say "N". | |
100 | ||
91 | 101 | config DEVKMEM |
92 | 102 | bool "/dev/kmem virtual device support" |
93 | 103 | default y |
drivers/char/mem.c | ||
---|---|---|
89 | 89 | { |
90 | 90 | } |
91 | 91 | |
92 | #ifdef CONFIG_DEVMEM | |
93 | ||
92 | 94 | /* |
93 | 95 | * This funcion reads the *physical* memory. The f_pos points directly to the |
94 | 96 | * memory location. |
... | ... | |
212 | 214 | return written; |
213 | 215 | } |
214 | 216 | |
217 | #endif | |
218 | ||
219 | #if defined(CONFIG_DEVMEM) || defined(CONFIG_DEVKMEM) | |
220 | ||
215 | 221 | int __weak phys_mem_access_prot_allowed(struct file *file, |
216 | 222 | unsigned long pfn, unsigned long size, pgprot_t *vma_prot) |
217 | 223 | { |
... | ... | |
333 | 339 | return 0; |
334 | 340 | } |
335 | 341 | |
342 | #endif | |
343 | ||
336 | 344 | #ifdef CONFIG_DEVKMEM |
337 | 345 | static int mmap_kmem(struct file *file, struct vm_area_struct *vma) |
338 | 346 | { |
... | ... | |
696 | 704 | return file->f_pos = 0; |
697 | 705 | } |
698 | 706 | |
707 | #if defined(CONFIG_DEVMEM) || defined(CONFIG_DEVKMEM) || defined(CONFIG_DEVPORT) | |
699 | 708 | /* |
700 | 709 | * The memory devices use the full 32/64 bits of the offset, and so we cannot |
701 | 710 | * check against negative addresses: they are ok. The return value is weird, |
... | ... | |
728 | 737 | mutex_unlock(&file->f_path.dentry->d_inode->i_mutex); |
729 | 738 | return ret; |
730 | 739 | } |
740 | #endif | |
731 | 741 | |
742 | #if defined(CONFIG_DEVMEM) || defined(CONFIG_DEVKMEM) || \ | |
743 | defined(CONFIG_DEVPORT) || defined(CONFIG_CRASH_DUMP) | |
732 | 744 | static int open_port(struct inode * inode, struct file * filp) |
733 | 745 | { |
734 | 746 | return capable(CAP_SYS_RAWIO) ? 0 : -EPERM; |
735 | 747 | } |
748 | #endif | |
736 | 749 | |
737 | 750 | #define zero_lseek null_lseek |
738 | 751 | #define full_lseek null_lseek |
... | ... | |
742 | 755 | #define open_kmem open_mem |
743 | 756 | #define open_oldmem open_mem |
744 | 757 | |
758 | #ifdef CONFIG_DEVMEM | |
745 | 759 | static const struct file_operations mem_fops = { |
746 | 760 | .llseek = memory_lseek, |
747 | 761 | .read = read_mem, |
... | ... | |
750 | 764 | .open = open_mem, |
751 | 765 | .get_unmapped_area = get_unmapped_area_mem, |
752 | 766 | }; |
767 | #endif | |
753 | 768 | |
754 | 769 | #ifdef CONFIG_DEVKMEM |
755 | 770 | static const struct file_operations kmem_fops = { |
... | ... | |
841 | 856 | const struct file_operations *fops; |
842 | 857 | struct backing_dev_info *dev_info; |
843 | 858 | } devlist[] = { |
859 | #ifdef CONFIG_DEVMEM | |
844 | 860 | [1] = { "mem", 0, &mem_fops, &directly_mappable_cdev_bdi }, |
861 | #endif | |
845 | 862 | #ifdef CONFIG_DEVKMEM |
846 | 863 | [2] = { "kmem", 0, &kmem_fops, &directly_mappable_cdev_bdi }, |
847 | 864 | #endif |
Branches:
ben-wpan
ben-wpan-stefan
5396a9238205f20f811ea57898980d3ca82df0b6
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9