You've already forked fedora-kernel-pf
mirror of
https://github.com/encounter/fedora-kernel-pf.git
synced 2026-03-30 11:10:06 -07:00
44 lines
1.3 KiB
Diff
44 lines
1.3 KiB
Diff
From 12e2c6926a6b03e070fc58271cf41a482de06467 Mon Sep 17 00:00:00 2001
|
|
From: Matthew Garrett <matthew.garrett@nebula.com>
|
|
Date: Fri, 9 Mar 2012 09:28:15 -0500
|
|
Subject: [PATCH 06/20] 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.
|
|
|
|
[labbott: Rebased again]
|
|
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 6d9cc2d39d22..bda271d022a0 100644
|
|
--- a/drivers/char/mem.c
|
|
+++ b/drivers/char/mem.c
|
|
@@ -163,6 +163,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);
|
|
--
|
|
2.11.0
|
|
|