Commit 517d6c3a authored by Matthew Garrett's avatar Matthew Garrett Committed by Tim Gardner

Restrict /dev/mem and /dev/kmem when module loading is restricted

BugLink: http://bugs.launchpad.net/bugs/1566221

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: default avatarMatthew Garrett <matthew.garrett@nebula.com>
Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
parent 716e7611
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment