Re: [patch 2.6.13-rc4] fix get_user_pages bug

Linus Torvalds
2005-08-01T20:18:59Z

On Mon, 1 Aug 2005, Andrew Morton wrote:
>
> That was introduced 19 months ago by the s390 guys (see patch below).

This really is a very broken patch, btw.

> + if (write && !pte_write(pte))
> + goto out;
> + if (write && !pte_dirty(pte)) {
> + struct page *page = pte_page(pte);
> + if (!PageDirty(page))
> + set_page_dirty(page);
> + }
> + pfn = pte_pfn(pte);
> + if (pfn_valid(pfn)) {
> + struct page *page = pfn_to_page(pfn);
> +
> + mark_page_accessed(page);
> + return page;

Note how it doesn't do any "pfn_valid()" stuff for the dirty bit setting,
so it will set random bits in memory if the pte points to some IO page.

Maybe that doesn't happen on s390, but..

Anyway, if the s390 people just have a sw-writable bit in their page table
layout, I bet they can fix their problem by just having a "sw dirty"
bit, and then make "pte_mkdirty()" set that bit. Nobody else will care,
but ptrace will then just work correctly for them too.

Linus