Skip to contentSkip to conversation

nfsd: fix oops on mixed NFSv4/NFSv3 client access

PATCH In review J. Bruce Fields 2 participants 3 messages Aug 5, 2020

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

PATCH 1/1 nfsd: fix oops on mixed NFSv4/NFSv3 client access

From: "J. Bruce Fields" <[email protected]>

If an NFSv2/v3 client breaks an NFSv4 client's delegation, it will hit a NULL dereference in nfsd_breaker_owns_lease().

Easily reproduceable with for example

mount -overs=4.2 server:/export /mnt/
sleep 1h </mnt/file &
mount -overs=3 server:/export /mnt2/
touch /mnt2/file

Fixes 28df3d1539de50 ("nfsd: clients don't need to break their own delegations")
---
 fs/nfsd/nfs4state.c | 2 ++
 1 file changed, 2 insertions(+)
fs/nfsd/nfs4state.c +2 -0
index 9fc0a1b9e4dd..45f3832d70d4 100644
@@ -4597,6 +4597,8 @@ static bool nfsd_breaker_owns_lease(struct file_lock *fl)
 	if (!i_am_nfsd())
 		return NULL;
 	rqst = kthread_data(current);
+	if (!rqst->rq_lease_breaker)
+		return NULL;
 	clp = *(rqst->rq_lease_breaker);
 	return dl->dl_stid.sc_client == clp;
 }
Signature · 1 line
2.26.2
#1 lore raw

Hi Bruce-

Quoted 9 lines · On Aug 5, 2020, at 3:10 PM, [email protected] wrote:

From: "J. Bruce Fields" <[email protected]>

If an NFSv2/v3 client breaks an NFSv4 client's delegation, it will hit a NULL dereference in nfsd_breaker_owns_lease().

Easily reproduceable with for example

Quoted 7 lines

mount -overs=4.2 server:/export /mnt/
sleep 1h </mnt/file &
mount -overs=3 server:/export /mnt2/
touch /mnt2/file

Fixes 28df3d1539de50 ("nfsd: clients don't need to break their own delegations")

May I add

And send this in the first NFSD v5.9 -rc pull request?

Quoted 21 lines

---
fs/nfsd/nfs4state.c | 2 ++

1 file changed, 2 insertions(+)
fs/nfsd/nfs4state.c +2 -0
index 9fc0a1b9e4dd..45f3832d70d4 100644
@@ -4597,6 +4597,8 @@ static bool nfsd_breaker_owns_lease(struct file_lock *fl)
 	if (!i_am_nfsd())
 		return NULL;
 	rqst = kthread_data(current);
+	if (!rqst->rq_lease_breaker)
+		return NULL;
 	clp = *(rqst->rq_lease_breaker);
 	return dl->dl_stid.sc_client == clp;
 }
Signature · 1 line
2.26.2

--
Chuck Lever

#2 lore raw
Quoted 16 lines · Chuck Lever

Hi Bruce-

Quoted 14 lines · On Aug 5, 2020, at 3:10 PM, [email protected] wrote:

From: "J. Bruce Fields" <[email protected]>

If an NFSv2/v3 client breaks an NFSv4 client's delegation, it will hit a NULL dereference in nfsd_breaker_owns_lease().

Easily reproduceable with for example

mount -overs=4.2 server:/export /mnt/
sleep 1h </mnt/file &
mount -overs=3 server:/export /mnt2/
touch /mnt2/file

Quoted 8 lines
Quoted 2 lines
Fixes 28df3d1539de50 ("nfsd: clients don't need to break their own delegations")

May I add

And send this in the first NFSD v5.9 -rc pull request?

Sounds good, thanks!

--b.

Quoted 28 lines
Quoted 23 lines

---
fs/nfsd/nfs4state.c | 2 ++

1 file changed, 2 insertions(+)
fs/nfsd/nfs4state.c +2 -0
index 9fc0a1b9e4dd..45f3832d70d4 100644
@@ -4597,6 +4597,8 @@ static bool nfsd_breaker_owns_lease(struct file_lock *fl)
 	if (!i_am_nfsd())
 		return NULL;
 	rqst = kthread_data(current);
+	if (!rqst->rq_lease_breaker)
+		return NULL;
 	clp = *(rqst->rq_lease_breaker);
 	return dl->dl_stid.sc_client == clp;
 }
Signature · 1 line
2.26.2

--
Chuck Lever