Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1617146 > unrolled thread

[PATCH 05/24] Restrict /dev/mem and /dev/kmem when the kernel is locked down

Started byDavid Howells <dhowells@redhat.com>
First post2017-04-05 19:10 +0200
Last post2017-04-05 19:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 05/24] Restrict /dev/mem and /dev/kmem when the kernel is  locked down David Howells <dhowells@redhat.com> - 2017-04-05 19:10 +0200

#1617146 — [PATCH 05/24] Restrict /dev/mem and /dev/kmem when the kernel is locked down

FromDavid Howells <dhowells@redhat.com>
Date2017-04-05 19:10 +0200
Subject[PATCH 05/24] Restrict /dev/mem and /dev/kmem when the kernel is locked down
Message-ID<tsWBr-5sA-13@gated-at.bofh.it>
From: Matthew Garrett <matthew.garrett@nebula.com>

Allowing users to write to address space makes it possible for the kernel to
be subverted, avoiding module loading restrictions.  Prevent this when the
kernel has been locked down.

Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Signed-off-by: David Howells <dhowells@redhat.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..f8144049bda3 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 (kernel_is_locked_down())
+		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 (kernel_is_locked_down())
+		return -EPERM;
+
 	if (p < (unsigned long) high_memory) {
 		unsigned long to_write = min_t(unsigned long, count,
 					       (unsigned long)high_memory - p);

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web