From: Jeff Dike <jdike@addtoit.com>
To: BlaisorBlade <blaisorblade_spam@yahoo.it>
Cc: user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] [PATCH] fix writing into /dev/kmem
Date: Mon, 01 Mar 2004 20:31:10 -0500 [thread overview]
Message-ID: <200403020131.i221VAM9025692@ccure.user-mode-linux.org> (raw)
In-Reply-To: Your message of "Sun, 29 Feb 2004 13:25:40 +0100." <200402291325.40644.blaisorblade_spam@yahoo.it>
blaisorblade_spam@yahoo.it said:
> This patch is like the one for the read from /dev/kmem (i.e. the one
> fixing the panic when one does "cat /dev/kmem": you can reproduce
> this panic on Uml2.6): it makes it behave like /dev/mem (man 4 mem is
> indeed helpful!). So it is basically not *the right way*.
Well, if you look at read_kmem, the thing that it reads is physical memory
plus kernel virtual memory. I.e. /dev/kmem is /dev/mem + the kernel virtual
memory areas.
Addmittedly, I don't see how x86 gets away with dereferencing address 0, but
I don't see what's wrong with my fixes. The file offsets being passed in
are effectively physical addresses, which need to be converted into virtual
addresses before being dereferenced, with is what __va() does, and __pa()
undoes.
Also, read_mem does the _va() correctly:
if (copy_to_user(buf, __va(p), count))
return -EFAULT;
while read_kmem does not:
if (copy_to_user(buf, (char *)p, read))
return -EFAULT;
The only out that I can see is that readers of kmem are supposed to pass in
kernel virtual addresses, 0xc0000000 and up. But, if so, those guys
fundamentally aren't going to work on UML because those addresses will be
wrong.
It would be nice to see exactly what klogd is doing.
> To read the physical address 0x1with /dev/kmem, you are supposed to
> read 0xc0000001; so with that patch any proper user of /dev/kmem will
> overflow p.
0xa0000001, actually, which is what __va does.
Jeff
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next prev parent reply other threads:[~2004-03-02 1:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-29 2:36 [uml-devel] [PATCH] fix writing into /dev/kmem Jeff Dike
2004-02-29 12:25 ` BlaisorBlade
2004-03-02 1:31 ` Jeff Dike [this message]
2004-03-02 18:41 ` BlaisorBlade
2004-03-04 2:02 ` Jeff Dike
2004-03-08 11:50 ` BlaisorBlade
2004-02-29 16:20 ` BlaisorBlade
2004-03-02 1:11 ` Jeff Dike
2004-03-02 1:31 ` Jeff Dike
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=200403020131.i221VAM9025692@ccure.user-mode-linux.org \
--to=jdike@addtoit.com \
--cc=blaisorblade_spam@yahoo.it \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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