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

2005-04-16 Thread David Wagner
Hacksaw wrote: >What I would expect the kernel to do is this: > >system_call_data_prep (userdata, size){ [...] > for each page from userdata to userdata+size > { > if the page is swapped out, swap it in > if the page is not owned by the user process, return

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

2005-04-16 Thread Vadim Lobanov
On Sat, 16 Apr 2005, Hacksaw wrote: > >if you want actual concrete examples, let me know. > I'd love a few, but maybe privately? > > > I can certainly see where always copying is simpler; I certainly consider this > to be an optimization, which must be looked at carefully, lest you end up with >

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

2005-04-16 Thread Hacksaw
>if you want actual concrete examples, let me know. I'd love a few, but maybe privately? I can certainly see where always copying is simpler; I certainly consider this to be an optimization, which must be looked at carefully, lest you end up with that which speed things up a little, but adds a

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

2005-04-16 Thread Hacksaw
if you want actual concrete examples, let me know. I'd love a few, but maybe privately? I can certainly see where always copying is simpler; I certainly consider this to be an optimization, which must be looked at carefully, lest you end up with that which speed things up a little, but adds a

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

2005-04-16 Thread Vadim Lobanov
On Sat, 16 Apr 2005, Hacksaw wrote: if you want actual concrete examples, let me know. I'd love a few, but maybe privately? I can certainly see where always copying is simpler; I certainly consider this to be an optimization, which must be looked at carefully, lest you end up with that

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

2005-04-16 Thread David Wagner
Hacksaw wrote: What I would expect the kernel to do is this: system_call_data_prep (userdata, size){ [...] for each page from userdata to userdata+size { if the page is swapped out, swap it in if the page is not owned by the user process, return -ENOWAYMAN

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

2005-04-15 Thread Vadim Lobanov
On Sat, 16 Apr 2005, Hacksaw wrote: > Sorry if this bugs anyone, but I'm learning things here. > > What I would expect the kernel to do is this: > > system_call_data_prep (userdata, size){ > >if !4G/4G { > for each page from userdata to userdata+size > { > if the page is

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

2005-04-15 Thread Hacksaw
Sorry if this bugs anyone, but I'm learning things here. What I would expect the kernel to do is this: system_call_data_prep (userdata, size){ if !4G/4G { for each page from userdata to userdata+size { if the page is swapped out, swap it in if the page is not

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

2005-04-15 Thread Hacksaw
Sorry if this bugs anyone, but I'm learning things here. What I would expect the kernel to do is this: system_call_data_prep (userdata, size){ if !4G/4G { for each page from userdata to userdata+size { if the page is swapped out, swap it in if the page is not

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

2005-04-15 Thread Vadim Lobanov
On Sat, 16 Apr 2005, Hacksaw wrote: Sorry if this bugs anyone, but I'm learning things here. What I would expect the kernel to do is this: system_call_data_prep (userdata, size){ if !4G/4G { for each page from userdata to userdata+size { if the page is swapped out,

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

2005-04-14 Thread Helge Hafting
Tomko wrote: Catalin Marinas wrote: No, it is because this function checks whether the access to the user space address is OK. There are situations when it can also sleep (page not present). what u means "OK"? kernel space should have right to access any memory address , can u expained in

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

2005-04-14 Thread Helge Hafting
Tomko wrote: Catalin Marinas wrote: No, it is because this function checks whether the access to the user space address is OK. There are situations when it can also sleep (page not present). what u means OK? kernel space should have right to access any memory address , can u expained in

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

2005-04-13 Thread David Schwartz
> Catalin Marinas wrote: > >Tomko <[EMAIL PROTECTED]> wrote: > >>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? > >No, it is because this

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

2005-04-13 Thread Tomko
Catalin Marinas wrote: Tomko <[EMAIL PROTECTED]> wrote: 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? No, it is because this function checks

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

2005-04-13 Thread Richard B. Johnson
On Wed, 13 Apr 2005, Theodore Ts'o wrote: On Wed, Apr 13, 2005 at 08:40:05AM -0400, Richard B. Johnson wrote: The kernel does NOT have to copy data from user-space before using it. Incorrect. It must, or the kernel code in question is by definition buggy. What? Explain why a memory-mapped buffer

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

2005-04-13 Thread Theodore Ts'o
On Wed, Apr 13, 2005 at 08:40:05AM -0400, Richard B. Johnson wrote: > The kernel does NOT have to copy data from user-space before > using it. Incorrect. It must, or the kernel code in question is by definition buggy. > In fact, user-mode pointers are valid in kernel-space > when the kernel is

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

2005-04-13 Thread Richard B. Johnson
On Wed, 13 Apr 2005, Hacksaw wrote: Why not use it directly Some of these reasons are: It seems like you gave reason why userland pointers shouldn't be trusted, not why userland data should be copied into kernel land. All the problems you mentioned would have to be solved by the kernel regardless

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

2005-04-13 Thread Hacksaw
>>Why not use it directly >Some of these reasons are: It seems like you gave reason why userland pointers shouldn't be trusted, not why userland data should be copied into kernel land. All the problems you mentioned would have to be solved by the kernel regardless of copying the data around.

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

2005-04-13 Thread Benjamin Herrenschmidt
On Wed, 2005-04-13 at 12:21 +0800, Tomko wrote: > Hi all, > > I am new to linux , hope someone can help me. > 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

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

2005-04-13 Thread Catalin Marinas
Tomko <[EMAIL PROTECTED]> wrote: > 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? No, it is because this function checks whether the access to

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

2005-04-13 Thread Tomko
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

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

2005-04-13 Thread Jan-Benedict Glaw
On Wed, 2005-04-13 12:21:41 +0800, Tomko <[EMAIL PROTECTED]> wrote in message <[EMAIL PROTECTED]>: > 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

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

2005-04-13 Thread Vadim Lobanov
On Wed, 13 Apr 2005, Eshwar wrote: > > >The quick and simple answer to this question is: data integrity. > > >The main thing to understand is that, from the perspective of the > >kernel, any user input provided in the form of system calls must have > >immutable data. Only if the data is immutable

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

2005-04-13 Thread Vadim Lobanov
On Wed, 13 Apr 2005, Eshwar wrote: The quick and simple answer to this question is: data integrity. The main thing to understand is that, from the perspective of the kernel, any user input provided in the form of system calls must have immutable data. Only if the data is immutable can the

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

2005-04-13 Thread Jan-Benedict Glaw
On Wed, 2005-04-13 12:21:41 +0800, Tomko [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]: 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

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

2005-04-13 Thread Tomko
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

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

2005-04-13 Thread Catalin Marinas
Tomko [EMAIL PROTECTED] wrote: 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? No, it is because this function checks whether the access to the

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

2005-04-13 Thread Benjamin Herrenschmidt
On Wed, 2005-04-13 at 12:21 +0800, Tomko wrote: Hi all, I am new to linux , hope someone can help me. 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 .

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

2005-04-13 Thread Hacksaw
Why not use it directly Some of these reasons are: It seems like you gave reason why userland pointers shouldn't be trusted, not why userland data should be copied into kernel land. All the problems you mentioned would have to be solved by the kernel regardless of copying the data around.

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

2005-04-13 Thread Richard B. Johnson
On Wed, 13 Apr 2005, Hacksaw wrote: Why not use it directly Some of these reasons are: It seems like you gave reason why userland pointers shouldn't be trusted, not why userland data should be copied into kernel land. All the problems you mentioned would have to be solved by the kernel regardless

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

2005-04-13 Thread Theodore Ts'o
On Wed, Apr 13, 2005 at 08:40:05AM -0400, Richard B. Johnson wrote: The kernel does NOT have to copy data from user-space before using it. Incorrect. It must, or the kernel code in question is by definition buggy. In fact, user-mode pointers are valid in kernel-space when the kernel is

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

2005-04-13 Thread Richard B. Johnson
On Wed, 13 Apr 2005, Theodore Ts'o wrote: On Wed, Apr 13, 2005 at 08:40:05AM -0400, Richard B. Johnson wrote: The kernel does NOT have to copy data from user-space before using it. Incorrect. It must, or the kernel code in question is by definition buggy. What? Explain why a memory-mapped buffer

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

2005-04-13 Thread Tomko
Catalin Marinas wrote: Tomko [EMAIL PROTECTED] wrote: 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? No, it is because this function checks

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

2005-04-13 Thread David Schwartz
Catalin Marinas wrote: Tomko [EMAIL PROTECTED] wrote: 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? No, it is because this function checks

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

2005-04-12 Thread Vadim Lobanov
On Wed, 13 Apr 2005, Tomko wrote: > Hi all, > > I am new to linux , hope someone can help me. > 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

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

2005-04-12 Thread Vadim Lobanov
On Wed, 13 Apr 2005, Tomko wrote: Hi all, I am new to linux , hope someone can help me. 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