On Tue, Mar 8, 2022 at 9:40 AM Linus Torvalds wrote: > > Hmm. The futex code actually uses "fixup_user_fault()" for this case. > Maybe fault_in_safe_writeable() should do that? .. paging all the bits back in, I'm reminded that one of the worries was "what about large areas". But I really think that the solution should be that we limit the size of fault_in_safe_writeable() to just a couple of pages. Even if you were to fault in gigabytes, page-out can undo it anyway, so there is no semantic reason why that function should ever do more than a few pages to make sure. There's already even a comment about how there's no guarantee that the pages will stay. Side note: the current GUP-based fault_in_safe_writeable() is buggy in another way anyway: it doesn't work right for stack extending accesses. So I think the fix for this all might be something like the attached (TOTALLY UNTESTED)! Comments? Andreas, mind (carefully - maybe it is totally broken and does unspeakable acts to your pets) testing this? Linus