mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-09 02:51:11 +01:00
mm/mempolicy: Allow lookup_node() to handle fatal signal
lookup_node() uses gup to pin the page and get node information. It
checks against ret>=0 assuming the page will be filled in. However it's
also possible that gup will return zero, for example, when the thread is
quickly killed with a fatal signal. Teach lookup_node() to gracefully
return an error -EFAULT if it happens.
Meanwhile, initialize "page" to NULL to avoid potential risk of
exploiting the pointer.
Fixes: 4426e945df ("mm/gup: allow VM_FAULT_RETRY for multiple times")
Reported-by: [email protected]
Signed-off-by: Peter Xu <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
1 parent
63bef48fd6
commit
ba841078cd
1 file changed
+5
-2
+5
-2
@@ -896,12 +896,15 @@ static void get_policy_nodemask(struct mempolicy *p, nodemask_t *nodes)
|
||||
|
||||
static int lookup_node(struct mm_struct *mm, unsigned long addr)
|
||||
{
|
||||
struct page *p;
|
||||
struct page *p = NULL;
|
||||
int err;
|
||||
|
||||
int locked = 1;
|
||||
err = get_user_pages_locked(addr & PAGE_MASK, 1, 0, &p, &locked);
|
||||
if (err >= 0) {
|
||||
if (err == 0) {
|
||||
/* E.g. GUP interrupted by fatal signal */
|
||||
err = -EFAULT;
|
||||
} else if (err > 0) {
|
||||
err = page_to_nid(p);
|
||||
put_page(p);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user