summaryrefslogtreecommitdiffstats
path: root/Restrict-dev-mem-and-dev-kmem-when-module-loading-is.patch
diff options
context:
space:
mode:
authorLaura Abbott <labbott@fedoraproject.org>2015-09-01 15:03:08 -0700
committerLaura Abbott <labbott@fedoraproject.org>2015-09-01 15:59:56 -0700
commitd07b889185195409a6090ed3e12fff475b4258f4 (patch)
treec2b98784a9c45c2ba5420c4a256c03d1c1c2e125 /Restrict-dev-mem-and-dev-kmem-when-module-loading-is.patch
parent07775e21b6d0c7b9c2251deb8cb5ef3052a38c6e (diff)
downloadkernel-d07b889185195409a6090ed3e12fff475b4258f4.tar.gz
kernel-d07b889185195409a6090ed3e12fff475b4258f4.tar.xz
kernel-d07b889185195409a6090ed3e12fff475b4258f4.zip
Linux v4.2
This is a squashed patch of the history from F22 + the 4.2 rebase
Diffstat (limited to 'Restrict-dev-mem-and-dev-kmem-when-module-loading-is.patch')
-rw-r--r--Restrict-dev-mem-and-dev-kmem-when-module-loading-is.patch38
1 files changed, 38 insertions, 0 deletions
diff --git a/Restrict-dev-mem-and-dev-kmem-when-module-loading-is.patch b/Restrict-dev-mem-and-dev-kmem-when-module-loading-is.patch
new file mode 100644
index 000000000..99cae0a0a
--- /dev/null
+++ b/Restrict-dev-mem-and-dev-kmem-when-module-loading-is.patch
@@ -0,0 +1,38 @@
+From: Matthew Garrett <matthew.garrett@nebula.com>
+Date: Fri, 9 Mar 2012 09:28:15 -0500
+Subject: [PATCH] Restrict /dev/mem and /dev/kmem when module loading is
+ restricted
+
+Allowing users to write to address space makes it possible for the kernel
+to be subverted, avoiding module loading restrictions. Prevent this when
+any restrictions have been imposed on loading modules.
+
+Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
+---
+ drivers/char/mem.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/drivers/char/mem.c b/drivers/char/mem.c
+index efe38c1bc234..16b8af1188e1 100644
+--- a/drivers/char/mem.c
++++ b/drivers/char/mem.c
+@@ -167,6 +167,9 @@ static ssize_t write_mem(struct file *file, const char __user *buf,
+ if (p != *ppos)
+ return -EFBIG;
+
++ if (secure_modules())
++ return -EPERM;
++
+ if (!valid_phys_addr_range(p, count))
+ return -EFAULT;
+
+@@ -513,6 +516,9 @@ static ssize_t write_kmem(struct file *file, const char __user *buf,
+ char *kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */
+ int err = 0;
+
++ if (secure_modules())
++ return -EPERM;
++
+ if (p < (unsigned long) high_memory) {
+ unsigned long to_write = min_t(unsigned long, count,
+ (unsigned long)high_memory - p);