Re: [PATCH] hold cow while breaking

Linus Torvalds (torvalds@transmeta.com)
Sun, 29 Jul 2001 08:30:19 -0700 (PDT)


On Sun, 29 Jul 2001, Hugh Dickins wrote:
>
> do_wp_page() COW breaking is now very slightly unsafe. Please don't
> ask me to provide a test case! but the pte_same() check after regetting
> page_table_lock is not quite enough to guarantee that the old_page was
> not reaped, reused for something else, copy_cow_paged while containing
> that other data, freed and then reused for precisely its original pte.

Oh, but it is.

We do hold the MM semaphore over the whole sequence, so there's no way the
page table entry can be replaced by anything else than a non-present one
(ie vmscan can swap it out, but nothing can swap it in because of the
lock).

So yes, we may copy data that is "garbage", but re-testing the page table
will make sure that if it was garbage we will never use it.

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/