Re: atomic copy_from_user?

From: Linus Torvalds (torvalds_at_osdl.org)
Date: 12/22/03

  • Next message: Ross Dickson: "Updated Lockup Patches, 2.4.22 - 23 Nforce2, apic timer ack delay, ioapic edge for NMI debug"
    Date:	Sun, 21 Dec 2003 20:31:41 -0800 (PST)
    To: Albert Cahalan <albert@users.sourceforge.net>
    
    

    On Sun, 21 Dec 2003, Albert Cahalan wrote:
    >
    > Surely I'm not the only one wanting such a beast...?

    I sure as hell hope you are.

    > From some naughty place in the code where might_sleep
    > would trigger, I'd like to read from user memory.
    > I'll pretty much assume that mlockall() has been
    > called. Suppose that "current" is correct as well.
    > I'd just use a pointer directly, except that:
    >
    > a. it isn't OK for the 4g/4g feature, s390, or sparc64
    > b. it causes the "sparse" type checker to complain
    > c. it will oops or worse if the user screwed up
    >
    > If the page is swapped out, I want a failed copy.

    the sequence

            local_bh_disable();
            err = get_user(n, ptr);
            local_bh_enable();
            if (!err)
                    .. 'n' .. was the value

    will do this in 2.6.x, except it will complain loudly about the unatomic
    access. Other than that, it will do what you ask for.

    However, I'd still suggest not doing this. It's just broken. I don't see
    any real reason to do this except as a "test if the page is paged out"
    kind of thing..

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


  • Next message: Ross Dickson: "Updated Lockup Patches, 2.4.22 - 23 Nforce2, apic timer ack delay, ioapic edge for NMI debug"