Re: Use of copy_to_user() and copy_from_user() functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 12, 2013 at 9:24 AM, Chetan Nanda <chetannanda@xxxxxxxxx> wrote:
>
>
>
> On Mon, Feb 11, 2013 at 5:25 PM, anish singh <anish198519851985@xxxxxxxxx> wrote:
>>
>>
>>
>> On Mon, Feb 11, 2013 at 4:51 PM, पारस <beparas@xxxxxxxxx> wrote:
>> > Hi All,
>> >
>> > To read/write data to user-space from kernel-space we use copy_from_user()
>> > and copy_to_user() functions.
>> >
>> > What is the use of these function?
>> > Why kernel can't directly access user address and read/write on to it?
>> what will happen if the user space process gets scheduled out while
>> you were using it?
>>
> copy_to/from_user should always be called from process context. So even if a process is scheduled out there is >not impact, as when process schedule back in copying will resume to/from correct page.
because page fault will be triggered and the user space will be swapped in.
 That answers the original question.
>>
>> > Can any one explain why kernel can't directly access the user-space address.
>> >
>> > Thanks
>> >
>> >
>> > _______________________________________________
>> > Kernelnewbies mailing list
>> > Kernelnewbies@xxxxxxxxxxxxxxxxx
>> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>> >
>>
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies@xxxxxxxxxxxxxxxxx
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux