Skip to contentSkip to conversation

NFSD: fix use-after-free in nfsd4_ssc_setup_dul()

PATCH In review Xingyuan Mo 3 participants 3 messages Jan 11, 2023 – Jan 12, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFSD: fix use-after-free in nfsd4_ssc_setup_dul()

If signal_pending() returns true, schedule_timeout() will not be executed, causing the waiting task to remain in the wait queue.
Fixed by adding a call to finish_wait(), which ensures that the waiting task will always be removed from the wait queue.

---
 fs/nfsd/nfs4proc.c | 1 +
 1 file changed, 1 insertion(+)
fs/nfsd/nfs4proc.c +1 -0
index bd880d55f565..3fa819e29b3f 100644
@@ -1318,6 +1318,7 @@ static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *nn, char *ipaddr,
 			/* allow 20secs for mount/unmount for now - revisit */
 			if (signal_pending(current) ||
 					(schedule_timeout(20*HZ) == 0)) {
+				finish_wait(&nn->nfsd_ssc_waitq, &wait);
 				kfree(work);
 				return nfserr_eagain;
 			}
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Xingyuan Mo

If signal_pending() returns true, schedule_timeout() will not be executed, causing the waiting task to remain in the wait queue.
Fixed by adding a call to finish_wait(), which ensures that the waiting task will always be removed from the wait queue.

---
 fs/nfsd/nfs4proc.c | 1 +
 1 file changed, 1 insertion(+)
fs/nfsd/nfs4proc.c +0 -0
index bd880d55f565..3fa819e29b3f 100644

fs/nfsd/nfs4proc.c static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *nn, char *ipaddr, · line 1324

Quoted 7 lines
fs/nfsd/nfs4proc.c +1 -0
@@ -1318,6 +1318,7 @@ static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *nn, char *ipaddr,
 			/* allow 20secs for mount/unmount for now - revisit */
 			if (signal_pending(current) ||
 					(schedule_timeout(20*HZ) == 0)) {
+				finish_wait(&nn->nfsd_ssc_waitq, &wait);
 				kfree(work);
 				return nfserr_eagain;
 			}

Nice catch.

#2 lore raw
In reply to Xingyuan Mo
Quoted 11 lines · Xingyuan Mo

If signal_pending() returns true, schedule_timeout() will not be executed, causing the waiting task to remain in the wait queue.
Fixed by adding a call to finish_wait(), which ensures that the waiting task will always be removed from the wait queue.

Hello, applied to nfsd's for-rc, thanks! I expect to send a PR for to Linus in a few days.

Quoted 19 lines

---
fs/nfsd/nfs4proc.c | 1 +

1 file changed, 1 insertion(+)
fs/nfsd/nfs4proc.c +1 -0
index bd880d55f565..3fa819e29b3f 100644
@@ -1318,6 +1318,7 @@ static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *nn, char *ipaddr,
 			/* allow 20secs for mount/unmount for now - revisit */
 			if (signal_pending(current) ||
 					(schedule_timeout(20*HZ) == 0)) {
+				finish_wait(&nn->nfsd_ssc_waitq, &wait);
 				kfree(work);
 				return nfserr_eagain;
 			}
Signature · 1 line
2.34.1

--
Chuck Lever