lkml.org 
[lkml]   [2001]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: null pointer questions
    Brian Gerst wrote:
    >
    > Ken Ashcraft wrote:
    > >
    > > > > 2. What happens if I pass a null pointer as the destination parameter
    > > > > to copy_from_user? Does copy_from_user handle it safely or will the
    > > > > kernel seg fault?
    > > >
    > > > The kernel won't crash, but it might fail (depending on whether 0 is a
    > > > valid user space address or not).
    > >
    > > Why does it matter if 0 is a valid user space or not? If I make the call
    > >
    > > copy_from_user(0, user_ptr, 4);
    > >
    > > the null pointer is the kernel address, not the user address. Can you
    > > clarify please?
    >
    > copy_from_user uses the string move instruction on the x86, so the
    > exception code would assume the source faulted not the dest. It would
    > return -EFAULT instead of causing an oops.

    Err, would return non-zero instead of -EFAULT.

    --

    Brian Gerst
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:12    [W:0.028 / U:0.020 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site