Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277081
b: refs/heads/master
c: e6780f7
h: refs/heads/master
i:
  277079: 2ac15b9
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Dec 31, 2011
1 parent c23ee08 commit 3164fc2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 06867fbb8abc936192195e5dcc4b63e12cc78f72
refs/heads/master: e6780f7243eddb133cc20ec37fa69317c218b709
28 changes: 20 additions & 8 deletions trunk/kernel/futex.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,29 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
#endif

lock_page(page_head);

/*
* If page_head->mapping is NULL, then it cannot be a PageAnon
* page; but it might be the ZERO_PAGE or in the gate area or
* in a special mapping (all cases which we are happy to fail);
* or it may have been a good file page when get_user_pages_fast
* found it, but truncated or holepunched or subjected to
* invalidate_complete_page2 before we got the page lock (also
* cases which we are happy to fail). And we hold a reference,
* so refcount care in invalidate_complete_page's remove_mapping
* prevents drop_caches from setting mapping to NULL beneath us.
*
* The case we do have to guard against is when memory pressure made
* shmem_writepage move it from filecache to swapcache beneath us:
* an unlikely race, but we do need to retry for page_head->mapping.
*/
if (!page_head->mapping) {
int shmem_swizzled = PageSwapCache(page_head);
unlock_page(page_head);
put_page(page_head);
/*
* ZERO_PAGE pages don't have a mapping. Avoid a busy loop
* trying to find one. RW mapping would have COW'd (and thus
* have a mapping) so this page is RO and won't ever change.
*/
if ((page_head == ZERO_PAGE(address)))
return -EFAULT;
goto again;
if (shmem_swizzled)
goto again;
return -EFAULT;
}

/*
Expand Down

0 comments on commit 3164fc2

Please sign in to comment.