2002-08-26 20:11:51

by Jeff Dike

[permalink] [raw]
Subject: copy_to_user to a kmapped address

Is this (in file_read_actor) bogus or am I missing something?

1621 kaddr = kmap(page);
1622 left = __copy_to_user(desc->buf, kaddr + offset, size);
1623 kunmap(page);

It seems to me that copy_to_user should be able to assume that the destination
address is a user address.

This is biting me because I'm moving the UML kernel into a separate address
space, so there's no way, in general, to tell the difference between a kernel
address and a userspace address.

Jeff


2002-08-26 20:28:51

by Russell King

[permalink] [raw]
Subject: Re: copy_to_user to a kmapped address

On Mon, Aug 26, 2002 at 04:19:37PM -0500, Jeff Dike wrote:
> Is this (in file_read_actor) bogus or am I missing something?
>
> 1621 kaddr = kmap(page);
> 1622 left = __copy_to_user(desc->buf, kaddr + offset, size);
> 1623 kunmap(page);
>
> It seems to me that copy_to_user should be able to assume that the destination
> address is a user address.
>
> This is biting me because I'm moving the UML kernel into a separate address
> space, so there's no way, in general, to tell the difference between a kernel
> address and a userspace address.

Umm, that's copying from kaddr + offset _to_ desc->buf. desc->buf
should be the user space address, and kaddr + offset a kernel address:

unsigned long __copy_to_user(void *to, const void *from, unsigned long n)

--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html

2002-08-26 21:23:57

by Jeff Dike

[permalink] [raw]
Subject: Re: copy_to_user to a kmapped address

[email protected] said:
> Umm, that's copying from kaddr + offset _to_ desc->buf. desc->buf
> should be the user space address, and kaddr + offset a kernel address:

Duh, nevermind...

Jeff