]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
SUNRPC: avoid race between mod_timer() and del_timer_sync()
authorNeilBrown <neilb@suse.de>
Tue, 8 Mar 2022 02:42:17 +0000 (13:42 +1100)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 12:37:27 +0000 (14:37 +0200)
commit0092dceb89b8bcad7e8fab10059c51e62d8c0655
tree6c8bc8d4f498300756afd8a8828fb2455138a097
parent17000ec7466bb6e244886cd8ac59532407644436
SUNRPC: avoid race between mod_timer() and del_timer_sync()

BugLink: https://bugs.launchpad.net/bugs/1969110
commit 3848e96edf4788f772d83990022fa7023a233d83 upstream.

xprt_destory() claims XPRT_LOCKED and then calls del_timer_sync().
Both xprt_unlock_connect() and xprt_release() call
 ->release_xprt()
which drops XPRT_LOCKED and *then* xprt_schedule_autodisconnect()
which calls mod_timer().

This may result in mod_timer() being called *after* del_timer_sync().
When this happens, the timer may fire long after the xprt has been freed,
and run_timer_softirq() will probably crash.

The pairing of ->release_xprt() and xprt_schedule_autodisconnect() is
always called under ->transport_lock.  So if we take ->transport_lock to
call del_timer_sync(), we can be sure that mod_timer() will run first
(if it runs at all).

Cc: stable@vger.kernel.org
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 518a7d6be1ed5ce056544fd03d8487fcf704768b)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
net/sunrpc/xprt.c