lkml.org 
[lkml]   [2011]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    Subjectcopy_*_user
    From
    I am investigating copy_from_user  and copy_to_user in linux under
    i386. These two function both take a pointer with virtual address and
    a pointer with physical address.

    copy_from_user calls __copy_from_user_ll and copy_to_user calls
    __copy_to_user_ll. It make sense to me that __copy_to_user_ll converts
    the virtual address to physical address using the current process's
    page table.


    unsigned long __copy_to_user_ll(void __user *to, const void *from,
    unsigned long n)
    {
    ...
    retval = get_user_pages(current, current->mm,
    (unsigned long)to, 1, 1, 0, &pg, NULL);

    if (retval == -ENOMEM && is_global_init(current)) {
    up_read(&current->mm->mmap_sem);
    congestion_wait(BLK_RW_ASYNC, HZ/50);
    goto survive;
    }

    if (retval != 1) {
    up_read(&current->mm->mmap_sem);
    break;
    }

    maddr = kmap_atomic(pg, KM_USER0);
    memcpy(maddr + offset, from, len);
    ...
    }

    But it seems to be that __copy_from_user_ll is not converted the
    address at all before attempting to copy. Can someone help explain to
    me why ?


    Thanks


    \
     
     \ /
      Last update: 2011-10-22 19:09    [W:0.020 / U:182.788 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site