]> xenbits.xensource.com Git - people/julieng/linux-arm.git/commitdiff
Restrict /dev/mem and /dev/kmem when module loading is restricted
authorMatthew Garrett <matthew.garrett@nebula.com>
Fri, 9 Mar 2012 14:28:15 +0000 (09:28 -0500)
committerJulien Grall <julien.grall@citrix.com>
Fri, 18 Sep 2015 15:29:28 +0000 (16:29 +0100)
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

index 53fe675f9bd764c12d0235a745ebed07f638db9c..b52c8886053228ed0c9e9ad48062ee15ddf9ee5c 100644 (file)
@@ -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);