From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: linux-ia64@vger.kernel.org
Subject: [PATCH] enable to read region 5 from /dev/kmem
Date: Fri, 01 Jul 2005 08:41:49 +0000 [thread overview]
Message-ID: <42C501CD.4010907@jp.fujitsu.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 120 bytes --]
This patch allows users to read region 5 from /dev/kmem and enhances range check of it.
Regards,
-- Kamezawa Hiroyuki.
[-- Attachment #2: ia64_region5_kmem.patch --]
[-- Type: text/plain, Size: 1831 bytes --]
enables reading region 5 from /dev/kmem
This patch enables to read region 5 from /dev/kmem.
And 'cat /dev/kmem' never cause panic.
"Don't do that" is good advise :).
Signed-Off-By: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
linux-2.6.13-rc1-kamezawa/drivers/char/mem.c | 3 +-
linux-2.6.13-rc1-kamezawa/include/asm-ia64/uaccess.h | 22 +++++++++++++++++--
2 files changed, 22 insertions(+), 3 deletions(-)
diff -puN include/asm-ia64/uaccess.h~ia64_region5_kmem include/asm-ia64/uaccess.h
--- linux-2.6.13-rc1/include/asm-ia64/uaccess.h~ia64_region5_kmem 2005-07-01 17:10:05.000000000 +0900
+++ linux-2.6.13-rc1-kamezawa/include/asm-ia64/uaccess.h 2005-07-01 17:12:51.000000000 +0900
@@ -395,8 +395,26 @@ xlate_dev_kmem_ptr (char * p)
{
struct page *page;
char * ptr;
-
- page = virt_to_page((unsigned long)p >> PAGE_SHIFT);
+ unsigned long pfn;
+ int region;
+ region = REGION_NUMBER(p);
+ switch(region) {
+ case 5:
+ return p;
+ case 6:
+ pfn = ((unsigned long)p - __IA64_UNCACHED_OFFSET) >> PAGE_SHIFT;
+ break;
+ case 7:
+ pfn = __pa(p) >> PAGE_SHIFT;
+ break;
+ default:
+ return NULL;
+ }
+ if (!pfn_valid(pfn))
+ return NULL;
+ if (region == 6)
+ return p;
+ page = pfn_to_page(pfn);
if (PageUncached(page))
ptr = (char *)__pa(p) + __IA64_UNCACHED_OFFSET;
else
diff -puN drivers/char/mem.c~ia64_region5_kmem drivers/char/mem.c
--- linux-2.6.13-rc1/drivers/char/mem.c~ia64_region5_kmem 2005-07-01 17:13:06.000000000 +0900
+++ linux-2.6.13-rc1-kamezawa/drivers/char/mem.c 2005-07-01 17:13:15.000000000 +0900
@@ -155,7 +155,8 @@ static ssize_t read_mem(struct file * fi
* by the kernel or data corruption may occur
*/
ptr = xlate_dev_mem_ptr(p);
-
+ if (!ptr)
+ return -EFAULT;
if (copy_to_user(buf, ptr, sz))
return -EFAULT;
buf += sz;
_
next reply other threads:[~2005-07-01 8:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-01 8:41 KAMEZAWA Hiroyuki [this message]
2005-07-11 23:02 ` [PATCH] enable to read region 5 from /dev/kmem Luck, Tony
2005-07-12 0:14 ` KAMEZAWA Hiroyuki
2005-07-12 0:22 ` Chen, Kenneth W
2005-07-12 1:16 ` KAMEZAWA Hiroyuki
2005-07-12 7:18 ` KAMEZAWA Hiroyuki
2005-07-12 17:14 ` Luck, Tony
2005-07-12 18:23 ` david mosberger
2005-07-12 19:05 ` Luck, Tony
2005-07-12 21:39 ` david mosberger
2005-07-12 22:08 ` Luck, Tony
2005-07-13 0:33 ` KAMEZAWA Hiroyuki
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=42C501CD.4010907@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-ia64@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