Skip to contentSkip to conversation

Patch "NFSv4.1: Fix a race where CB_NOTIFY_LOCK fails to wake a waiter" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Aug 1, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

NFSv4.1: Fix a race where CB_NOTIFY_LOCK fails to wake a waiter

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
nfsv4.1-fix-a-race-where-cb_notify_lock-fails-to-wake-a-waiter.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From b7dbcc0e433f0f61acb89ed9861ec996be4f2b38 Mon Sep 17 00:00:00 2001

From: Benjamin Coddington <[email protected]>
Date: Fri, 28 Jul 2017 12:33:54 -0400
Subject: NFSv4.1: Fix a race where CB_NOTIFY_LOCK fails to wake a waiter

From: Benjamin Coddington <[email protected]>

commit b7dbcc0e433f0f61acb89ed9861ec996be4f2b38 upstream.

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 a1d617d8f134 ("nfs: allow blocking locks to be awoken by lock callbacks")
---
 fs/nfs/nfs4proc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4proc.c +1 -1
@@ -6419,7 +6419,7 @@ nfs4_retry_setlk(struct nfs4_state *stat
 		set_current_state(TASK_INTERRUPTIBLE);
 		spin_unlock_irqrestore(&q->lock, flags);
 
-		freezable_schedule_timeout_interruptible(NFS4_LOCK_MAXTIMEOUT);
+		freezable_schedule_timeout(NFS4_LOCK_MAXTIMEOUT);
 	}
 
 	finish_wait(q, &wait);

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/nfsv4.1-fix-a-race-where-cb_notify_lock-fails-to-wake-a-waiter.patch