Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pvcalls-front: Avoid get_free_pages(GFP_KERNEL) under spinlock
[ Upstream commit 9f51c05 ] The problem is that we call this with a spin lock held. The call tree is: pvcalls_front_accept() holds bedata->socket_lock. -> create_active() -> __get_free_pages() uses GFP_KERNEL The create_active() function is only called from pvcalls_front_accept() with a spin_lock held, The allocation is not allowed to sleep and GFP_KERNEL is not sufficient. This issue was detected by using the Coccinelle software. v2: Add a function doing the allocations which is called outside the lock and passing the allocated data to create_active(). v3: Use the matching deallocators i.e., free_page() and free_pages(), respectively. v4: It would be better to pre-populate map (struct sock_mapping), rather than introducing one more new struct. v5: Since allocating the data outside of this call it should also be freed outside, when create_active() fails. Move kzalloc(sizeof(*map2), GFP_ATOMIC) outside spinlock and use GFP_KERNEL instead. v6: Drop the superfluous calls. Suggested-by: Juergen Gross <[email protected]> Suggested-by: Boris Ostrovsky <[email protected]> Suggested-by: Stefano Stabellini <[email protected]> Signed-off-by: Wen Yang <[email protected]> Acked-by: Stefano Stabellini <[email protected]> CC: Julia Lawall <[email protected]> CC: Boris Ostrovsky <[email protected]> CC: Juergen Gross <[email protected]> CC: Stefano Stabellini <[email protected]> CC: [email protected] CC: [email protected] Signed-off-by: Boris Ostrovsky <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
- Loading branch information