[lkml]   [2009]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH 2/2] Perform check in iov_iter_fault_in_readable() by check_readable_bytes()
    Andi Kleen wrote:
    > > ptr = mmap(0, page_size, ....);
    > > ...
    > > write(fd, ptr + page_size - 256, 512);
    > >
    > > Write() will fail here, but it can write first 256 bytes. Previously,
    > > all 512 bytes were proceeded, but last 256 bytes were zeroed, and
    > > sys_write() returned 256. Not very nice too.
    > Is that really something that users rely on? It looks like a seriously
    > broken user program. Which one is that? (just that I can avoid it :)

    A few programs set pages read-only, and rely on SIGSEGVs to trigger
    mprotect() in the signal handler and thus track dirty pages.

    I think the Boehm garbage collector has this option, as do some LISP

    System calls don't trigger SIGSEGVs so they can't rely on that when
    calling read(). I'm not sure how they handle that.

    It would be quite nice if it were safe to call read(), get EFAULT
    immediately, or a truncated read() then the next read() gets EFAULT
    because it starts at a missing page boundary, and then that's a hint
    for the program to consult it's data structures and do it's mprotect()

    Hopefully no programs assume they can do that already, but it would be
    nice if they could begin to assume it, instead of checking their data
    structure in advance of every read() call.

    I don't know of any program which would need the same thing with
    write(), but obviously good for symmetry.

    -- Jamie

     \ /
      Last update: 2009-05-15 15:45    [W:0.019 / U:9.804 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site