mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bert hubert <ahu@ds9a.nl>
To: linux-kernel@vger.kernel.org, akpm@osdl.org
Cc: devik@cdi.cz
Subject: [PATCH] Allow /dev/{,k}mem to be disabled to prevent kernel from being modified easily
Date: Sun, 3 Aug 2003 20:09:50 +0200	[thread overview]
Message-ID: <20030803180950.GA11575@outpost.ds9a.nl> (raw)

Greetings,

After being gloriously rootkitted with a program coded by HTB author Martin
Devera (lots of thanks, devik, your work is appreciated, I suggest you read
up about Oppenheimer when disclaiming that you are 'just a coder'. The item
to google on is: "ethics sweetness hydrogen bomb Oppenheimer"), I wrote
a patch to disable /dev/kmem and /dev/mem, which is harmless on servers
without X.

It blocks attempts by rootkits, such as devik's SucKIT, to hide themselves.

It is not a final solution but it raises the bar a lot. Please apply.

By default, nothing is changed, but I'd turn this feature on on servers
without X. Patch:

--- linux-2.6.0-test1/drivers/char/Kconfig.orig	Mon Jul 14 05:29:27 2003
+++ linux-2.6.0-test1/drivers/char/Kconfig	Sun Aug  3 19:55:37 2003
@@ -1003,5 +1003,20 @@
 	  out to lunch past a certain margin.  It can reboot the system
 	  or merely print a warning.
 
+config MEMORY_ACCESS
+	bool "Allow userspace access to memory" 
+	default y
+	help
+          Security paranoid operators may want to disable userspace
+          from accessing raw memory or kernel memory via /dev/mem and
+          /dev/kmem. Some malware hides itself from sight by manipulating
+          the kernel directly via raw memory, disabling this feature
+          gives some protection against rootkits.
+
+	  Answering 'N' generally breaks the X Window System.
+
+          Answer 'Y' unless you are paranoid about security or don't
+	  care about X.
+
 endmenu
 
--- linux-2.6.0-test1/drivers/char/mem.c.orig	Sun Aug  3 19:22:29 2003
+++ linux-2.6.0-test1/drivers/char/mem.c	Sun Aug  3 19:34:04 2003
@@ -608,12 +608,14 @@
 static int memory_open(struct inode * inode, struct file * filp)
 {
 	switch (minor(inode->i_rdev)) {
+#if defined(CONFIG_MEMORY_ACCESS)
 		case 1:
 			filp->f_op = &mem_fops;
 			break;
 		case 2:
 			filp->f_op = &kmem_fops;
 			break;
+#endif
 		case 3:
 			filp->f_op = &null_fops;
 			break;
@@ -655,8 +657,10 @@
 	umode_t			mode;
 	struct file_operations	*fops;
 } devlist[] = { /* list of minor devices */
+#if defined(CONFIG_MEMORY_ACCESS)
 	{1, "mem",     S_IRUSR | S_IWUSR | S_IRGRP, &mem_fops},
 	{2, "kmem",    S_IRUSR | S_IWUSR | S_IRGRP, &kmem_fops},
+#endif	
 	{3, "null",    S_IRUGO | S_IWUGO,           &null_fops},
 #if defined(CONFIG_ISA) || !defined(__mc68000__)
 	{4, "port",    S_IRUSR | S_IWUSR | S_IRGRP, &port_fops},




-- 
http://www.PowerDNS.com      Open source, database driven DNS Software 
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO

             reply	other threads:[~2003-08-03 18:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-03 18:09 bert hubert [this message]
2003-08-03 19:11 ` Willy Tarreau
2003-08-03 19:18   ` bert hubert
2003-08-03 20:26     ` Willy Tarreau
2003-08-03 21:37       ` Andries Brouwer
2003-08-03 19:32 ` Andrew Morton
2003-08-03 20:45   ` bert hubert
2003-08-03 20:52     ` Wichert Akkerman
2003-08-03 21:00     ` Andrew Morton
2003-08-03 21:33       ` David Lang
2003-08-03 21:47         ` bert hubert
2003-08-04 13:10           ` Alan Cox
2003-08-03 20:14 ` Matan Ziv-Av
2003-08-03 21:02 ` Alan Cox
2003-08-03 21:08 ` Erik Andersen
2003-08-04 12:30   ` eliezer
2003-08-04  9:37 ` devik
2003-08-04 13:46   ` bert hubert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030803180950.GA11575@outpost.ds9a.nl \
    --to=ahu@ds9a.nl \
    --cc=akpm@osdl.org \
    --cc=devik@cdi.cz \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®