All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Krafft <krafft@de.ibm.com>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] sensors-detect: Skip "random" I/O port
Date: Fri, 22 Feb 2008 10:18:48 +0000	[thread overview]
Message-ID: <20080222111848.4d898999@de.ibm.com> (raw)
In-Reply-To: <20080218223317.2142dc16@hyperion.delvare>


[-- Attachment #1.1: Type: text/plain, Size: 2048 bytes --]

Hi Ben,

regarding your problem with poking into PCI ranges:
As arnd mentioned, we could check, wether there is a mapping for that address
and if so, allow the access. That could be done in check_legacy_ioport,
although the name looks a bit misleading.
What do you think ?

On Fri, 22 Feb 2008 18:21:23 +1100
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:

> 
> Christian, can you re-send me that patch ?
> 
> Ben.

Sure, patch was as trivial as this:


sensors_detect crashes kernel on PowerPC, as it pokes directly to memory.
This patch adds a check_legacy_ioports to read_port and write_port.
It will now return ENXIO, instead of oopsing.

Signed-off-by: Christian Krafft <krafft@de.ibm.com>

Index: linux.git/drivers/char/mem.c
===================================================================
--- linux.git.orig/drivers/char/mem.c
+++ linux.git/drivers/char/mem.c
@@ -566,8 +566,13 @@ static ssize_t read_port(struct file * f
 	char __user *tmp = buf;
 
 	if (!access_ok(VERIFY_WRITE, buf, count))
-		return -EFAULT; 
+		return -EFAULT;
+
 	while (count-- > 0 && i < 65536) {
+#ifdef CONFIG_PPC_MERGE
+		if (check_legacy_ioport(i))
+			return -ENXIO;
+#endif
 		if (__put_user(inb(i),tmp) < 0) 
 			return -EFAULT;  
 		i++;
@@ -585,6 +590,7 @@ static ssize_t write_port(struct file * 
 
 	if (!access_ok(VERIFY_READ,buf,count))
 		return -EFAULT;
+
 	while (count-- > 0 && i < 65536) {
 		char c;
 		if (__get_user(c, tmp)) {
@@ -592,6 +598,10 @@ static ssize_t write_port(struct file * 
 				break;
 			return -EFAULT; 
 		}
+#ifdef CONFIG_PPC_MERGE
+		if (check_legacy_ioport(i))
+			return -ENXIO;
+#endif
 		outb(c,i);
 		i++;
 		tmp++;


-- 
Mit freundlichen Gruessen,
kind regards,

Christian Krafft
IBM Systems & Technology Group,
Linux Kernel Development
IT Specialist


Vorsitzender des Aufsichtsrats:	Martin Jetter
Geschaeftsfuehrung:		Herbert Kircher
Sitz der Gesellschaft:		Boeblingen
Registriergericht:		Amtsgericht Stuttgart, HRB 243294

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2008-02-22 10:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-18 21:33 [lm-sensors] [PATCH] sensors-detect: Skip "random" I/O port probing Jean Delvare
2008-02-18 22:46 ` [lm-sensors] [PATCH] sensors-detect: Skip "random" I/O port Benjamin Herrenschmidt
2008-02-20 19:07 ` Jean Delvare
2008-02-21 10:02 ` Christian Krafft
2008-02-21 10:09 ` Jean Delvare
2008-02-21 22:49 ` Benjamin Herrenschmidt
2008-02-22  7:19 ` Jean Delvare
2008-02-22  7:21 ` Benjamin Herrenschmidt
2008-02-22  7:44 ` Jean Delvare
2008-02-22 10:18 ` Christian Krafft [this message]
2008-02-22 21:26 ` Benjamin Herrenschmidt
2008-02-22 22:22 ` [lm-sensors] [PATCH] sensors-detect: Skip "random" I/O Benjamin Herrenschmidt

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=20080222111848.4d898999@de.ibm.com \
    --to=krafft@de.ibm.com \
    --cc=lm-sensors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.