]> git.baikalelectronics.ru Git - kernel.git/commit
NFSv4.1: Fix a race where CB_NOTIFY_LOCK fails to wake a waiter
authorBenjamin Coddington <bcodding@redhat.com>
Fri, 28 Jul 2017 16:33:54 +0000 (12:33 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Fri, 28 Jul 2017 19:35:30 +0000 (15:35 -0400)
commit7e07edc4d85e800e6d2eae923166dc5aa38b2017
treecedc255e9890c2060393b1f28cf8db5d57e51151
parent2dc3ee2b5b9a069a10650ef33d8bb6e5c95a4b30
NFSv4.1: Fix a race where CB_NOTIFY_LOCK fails to wake a waiter

nfs4_retry_setlk() sets the task's state to TASK_INTERRUPTIBLE within the
same region protected by the wait_queue's lock after checking for a
notification from CB_NOTIFY_LOCK callback.  However, after releasing that
lock, a wakeup for that task may race in before the call to
freezable_schedule_timeout_interruptible() and set TASK_WAKING, then
freezable_schedule_timeout_interruptible() will set the state back to
TASK_INTERRUPTIBLE before the task will sleep.  The result is that the task
will sleep for the entire duration of the timeout.

Since we've already set TASK_INTERRUPTIBLE in the locked section, just use
freezable_schedule_timout() instead.

Fixes: 404e1bcabd56 ("nfs: allow blocking locks to be awoken by lock callbacks")
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Cc: stable@vger.kernel.org # v4.9+
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/nfs4proc.c