Prevent NULL pointer deref in grab_swap_token
PATCH 1/1 Prevent NULL pointer deref in grab_swap_token
grab_swap_token() assumes that the current process has an mm struct, which is not true for kernel threads invoking get_user_pages(). Since this should be extremely rare, just return from grab_swap_token() without doing anything.
mm/thrash.c +3 -0
@@ -54,6 +54,9 @@struct mm_struct *mm;int reason; +if (current->mm ==NULL ) +return ; +/* We have the token. Let others know we still need it. */ if (has_swap_token (current->mm)) { current->mm->recent_pagein =1 ;
Quoted 6 lines · Dean Roe
grab_swap_token()assumes that the current process has an mm struct, which is not true for kernel threads invokingget_user_pages(). Since this should be extremely rare, just return fromgrab_swap_token()without doing anything.
Fair enough.
Which kernel threads are running get_user_pages()?
Quoted 4 lines · Dean Roe
grab_swap_token()assumes that the current process has an mm struct, which is not true for kernel threads invokingget_user_pages(). Since this should be extremely rare, just return fromgrab_swap_token()without doing anything.
There's a few things that will break if a kernel thread calls get_user_pages, so we should rather fix those.
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Dean Roe
grab_swap_token()assumes that the current process has an mm struct, which is not true for kernel threads invokingget_user_pages(). Since this should be extremely rare, just return fromgrab_swap_token()without doing anything.There's a few things that will break if a kernel thread calls
get_user_pages, so we should rather fix those.
What things will break? Anything which dinks with current->mm in or under get_user_pages() is probably already broken.
Quoted 2 lines · Dean Roe
grab_swap_token()assumes that the current process has an mm struct, which is not true for kernel threads invokingget_user_pages().
well WHICH user ? ;)