Skip to content

sunrpc: Set sk_allocation to GFP_NOFS to avoid using current->task_frag.

Guillaume Nault requested to merge gnault/centos-stream-9:bz2143920 into main

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2143920 Upstream Status: RHEL only

sk_allocation is used by sk_page_frag() to figure out if it can return current->task_frag or if it should resort to the socket specific page_frag (sk->sk_frag). Some subsystems, like NFS, can't use current->task_frag, because they can be called during memory reclaim, while current->task_frag is already in use. That leads to corruption of the page_frag structure.

By reverting sk_allocation to its default value (GFP_KERNEL), upstream commit a1231fda ("SUNRPC: Set memalloc_nofs_save() on all
rpciod/xprtiod jobs") made sk_page_frag() unable to realise that NFS sockets can be used during memory reclaim and thus cannot use current->task_frag.

Fix this by setting sk->sk_allocation to GFP_NOFS, to explicitely tell sk_page_frag() to use the private sk->sk_frag instead.

All attempts to fix this bug upstream have failed:

Fixes: a1231fda ("SUNRPC: Set memalloc_nofs_save() on all rpciod/xprtiod jobs") Signed-off-by: Guillaume Nault gnault@redhat.com

Merge request reports