Re: [PATCH] proc: pagemap: Hold mmap_sem during page walk
From: KOSAKI Motohiro
Date: Thu Apr 01 2010 - 01:55:01 EST
> > So Matt, please actually address the _bug_ I pointed out rather than talk
> > about other things. And yes, getting rid of the vma accesses sounds like
> > it would fix it best. If that means that it doesn't work for hugepages, so
> > be it.
> That'd actually take us back to where it was when it hit mainline, which
> would make a lot of people unhappy. I wouldn't be one of them as there
> thankfully aren't any huge pages in my world. But I'm convinced
> put_user() must go. In which case, get_user_pages() stays, and I've got
> to switch things to direct physical page access into that array.
no. direct physical page access for /proc is completely wrong idea, i think.
please imazine the caller process is multi threaded and it use fork case,
1. the parent process has thread-A and thread-B.
2. thread-A call read_pagemap
3. read_pagemap grab the page-C
3. at the same time, thread-B call fork(), now page-C pointed from two process.
4. thread-B touch page-C, cow occur, then the parent process has cowed page (page-C')
and the child process has original page-C.
5. thread-A write page-C by physical page access, then the child page is
modified, instead parent one.
I just recommend simply do double buffering.
> Even if I fix that, I believe San's original bug can still be triggered
> though, as all the new callers to find_vma are run outside of the
> target's mm_sem. Fixing that should be reasonably straight-forward.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/