RE: copy_to/from_use query?

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

 




-----Original Message-----
From: Aboo Valappil [mailto:aboo@xxxxxxxxxxxxxxx]
Sent: Tuesday, October 12, 2004 12:44 PM
To: jonathan@xxxxxxxxxxxxxx; Om
Cc: Linux Newbies
Subject: RE: copy_to/from_use query?


>Point number 2 here ( check page is available ) ... What if page is not
>available and there is no page table/page directory set up for this ?
>Does it cause a page fault ? or it make sure that there is no page fault
>by doing all the page table manipulation and getting the page frame for
>the request  ( pretty much does all the jobs by a page fault handler ) ?

	It do cause a PF, but in the PF handler code, before certifying it
as a kernel bug, there is a check made to see if the PF is due to reasons
like copy_from/to user etc. If it is so then the PF handler returns without
calling Oops!! 

Correct me if i am wrong !


-----Original Message-----
From: kernelnewbies-bounce@xxxxxxxxxxxx
[mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Jon Masters
Sent: Tuesday, October 12, 2004 7:39 AM
To: Om
Cc: Linux Newbies
Subject: Re: copy_to/from_use query?

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/


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

--
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