Skip to contentSkip to conversation

mountd: Fix potential data corrupter

PATCH In review Steve Dickson 1 participant 2 messages Feb 24, 2022 – Feb 28, 2022

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

PATCH 1/1 mountd: Fix potential data corrupter

Commit 9c99b463 typecast an uint into a int to fix a Coverity warning. Potentially this could cause a very large rogue value to be negative allow the rouge value to index into a table causing corruption.

A check has been added to detect this type of situation.

---
 support/nfs/rpcdispatch.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
support/nfs/rpcdispatch.c +3 -2
index f7c27c98..7329f419 100644
@@ -26,12 +26,13 @@ rpc_dispatch(struct svc_req *rqstp, SVCXPRT *transp,
 			void *argp, void *resp)
 {
 	struct rpc_dentry	*dent;
+	int rq_vers = (int)rqstp->rq_vers;
 
-	if (((int)rqstp->rq_vers) > nvers) {
+	if (rq_vers < 1 || rq_vers > nvers) {
 		svcerr_progvers(transp, 1, nvers);
 		return;
 	}
-	dtable += (rqstp->rq_vers - 1);
+	dtable += (rq_vers - 1);
 	if (rqstp->rq_proc > dtable->nproc) {
 		svcerr_noproc(transp);
 		return;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 10 lines · Steve Dickson

Commit 9c99b463 typecast an uint into a int to fix a Coverity warning. Potentially this could cause a very large rogue value to be negative allow the rouge value to index into a table causing corruption.

A check has been added to detect this type of situation.

Committed... (tag: nfs-utils-2-6-2-rc3)
With the addition of

steved.

Quoted 24 lines
---
  support/nfs/rpcdispatch.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
support/nfs/rpcdispatch.c +3 -2
index f7c27c98..7329f419 100644
@@ -26,12 +26,13 @@ rpc_dispatch(struct svc_req *rqstp, SVCXPRT *transp,
  			void *argp, void *resp)
  {
  	struct rpc_dentry	*dent;
+	int rq_vers = (int)rqstp->rq_vers;
 
-	if (((int)rqstp->rq_vers) > nvers) {
+	if (rq_vers < 1 || rq_vers > nvers) {
  		svcerr_progvers(transp, 1, nvers);
  		return;
  	}
-	dtable += (rqstp->rq_vers - 1);
+	dtable += (rq_vers - 1);
  	if (rqstp->rq_proc > dtable->nproc) {
  		svcerr_noproc(transp);
  		return;