Re: Why system call need to copy the date from the userspace before using it

Tomko
2005-04-13T10:44:20Z

hi ,
Thank you for your reply, can i ask some more question?

Inside the system call , the kernel often copy the data by calling
copy_from_user() rather than just using strcpy(), is it because the
memory mapping in kenel space is different from user space? for example
, now user program want to pass a pointer *a to kernel space , is it
true that *a seems means address 0xb000 to user space but actually it is
at 0xc000 at kernel space?

Thx a lot,
TOM

Jan-Benedict Glaw wrote:

>On Wed, 2005-04-13 12:21:41 +0800, Tomko <tomko@haha.com>
>wrote in message <425C9E55.6010607@haha.com>:
>
>
>>While i am reading the source code of the linux system call , i find
>>that the system call need to call copy_from_user() to copy the data from
>>user space to kernel space before using it . Why not use it directly as
>>the system call has got the address ? Furthermore , how to distinguish
>>between user space and kernel space ?
>>
>>
>
>Think about the memory access. The page that contains the data could be
>swapped out, so the kernel isn't allowed to just access it, because it's
>not there.
>
>MfG, JBG
>
>
>