Re: copy_to/from_use query?

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

 



On Mon, 11 Oct 2004 10:08:16 -0700, Om <omanakuttan@xxxxxxx> wrote:
> > > > >
> > > > > No, you can't. The user-space memory is not directly addressable from
> > > > > kernel.

What Jan Hudec means (please include quotes indicating who said what)
is that the kernel code cannot necessary directly dereference a
pointer in to userspace, even though it may form part of the
conceptual virtual memory map as seen by the kernel. The reasons for
this include the following items of note:

    *). Userspace memory is pageable (the kernel is not yet so) so it
may not be mapped and in kernel code has to take that in to
consideration.

    *). Userspace memory is governed by page tables which may not
contain an entry for other reasons or a processor TLB might need to be
loaded as part of a page fault like exception when memory is accessed
on embedded CPUs (the kernel also supports pinning on some CPUs where
large fixed mappings cover the kernel so it doesn't get this problem).

    *). Userspace memory might be in high memory so even just manually
walking the process descriptor and pulling out addresses won't cut the
mustard here (that's an English phrase nobody ever uses any more, but
I felt like it).

    *). Randomly following a pointer in to userspace or implementing
checks yourself is to say that you can do a better job than tested
kernel access code that does sanity and security checks for you.

> then how does copy_from_user and copy_to_user work? (I don't know enough
> assembly to understand the code in uaccess.h)

Roughly this goes on:

    *). Check validity of vma and process memory mapping.
    *). Check page is available.
    *). Copy the data accross.

Jon.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[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