Skip to content

Commit 29cd292

Browse files
committed
SUNRPC: Fix encoding of accepted but unsuccessful RPC replies
Jiri Slaby says: > I bisected to this ... as it breaks nfs3-only servers in 6.3. > I.e. /etc/nfs.conf containing: > [nfsd] > vers4=no > > The client sees: > mount("10.0.2.15:/tmp", "/mnt", "nfs", 0, "vers=4.2,addr=10.0.2.15,clientad"...) = -1 EIO (Input/output error) > write(2, "mount.nfs: mount system call fai"..., 45 > mount.nfs: mount system call failed for /mnt > > And the kernel says: > nfs4_discover_server_trunking unhandled error -5. Exiting with error EIO Reported-by: Jiri Slaby <[email protected]> Link: https://bugzilla.suse.com/show_bug.cgi?id=1210995 Fixes: 4bcf034 ("SUNRPC: Set rq_accept_statp inside ->accept methods") Tested-by: Jiri Slaby <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent fc412a6 commit 29cd292

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

net/sunrpc/svc.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ svc_process_common(struct svc_rqst *rqstp)
14161416
/* Only RPCv2 supported */
14171417
xdr_stream_encode_u32(xdr, RPC_VERSION);
14181418
xdr_stream_encode_u32(xdr, RPC_VERSION);
1419-
goto sendit;
1419+
return 1; /* don't wrap */
14201420

14211421
err_bad_auth:
14221422
dprintk("svc: authentication failed (%d)\n",
@@ -1432,15 +1432,20 @@ svc_process_common(struct svc_rqst *rqstp)
14321432
err_bad_prog:
14331433
dprintk("svc: unknown program %d\n", rqstp->rq_prog);
14341434
serv->sv_stats->rpcbadfmt++;
1435-
xdr_stream_encode_u32(xdr, RPC_PROG_UNAVAIL);
1435+
*rqstp->rq_accept_statp = rpc_prog_unavail;
14361436
goto sendit;
14371437

14381438
err_bad_vers:
14391439
svc_printk(rqstp, "unknown version (%d for prog %d, %s)\n",
14401440
rqstp->rq_vers, rqstp->rq_prog, progp->pg_name);
14411441

14421442
serv->sv_stats->rpcbadfmt++;
1443-
xdr_stream_encode_u32(xdr, RPC_PROG_MISMATCH);
1443+
*rqstp->rq_accept_statp = rpc_prog_mismatch;
1444+
1445+
/*
1446+
* svc_authenticate() has already added the verifier and
1447+
* advanced the stream just past rq_accept_statp.
1448+
*/
14441449
xdr_stream_encode_u32(xdr, process.mismatch.lovers);
14451450
xdr_stream_encode_u32(xdr, process.mismatch.hivers);
14461451
goto sendit;
@@ -1449,19 +1454,19 @@ svc_process_common(struct svc_rqst *rqstp)
14491454
svc_printk(rqstp, "unknown procedure (%d)\n", rqstp->rq_proc);
14501455

14511456
serv->sv_stats->rpcbadfmt++;
1452-
xdr_stream_encode_u32(xdr, RPC_PROC_UNAVAIL);
1457+
*rqstp->rq_accept_statp = rpc_proc_unavail;
14531458
goto sendit;
14541459

14551460
err_garbage_args:
14561461
svc_printk(rqstp, "failed to decode RPC header\n");
14571462

14581463
serv->sv_stats->rpcbadfmt++;
1459-
xdr_stream_encode_u32(xdr, RPC_GARBAGE_ARGS);
1464+
*rqstp->rq_accept_statp = rpc_garbage_args;
14601465
goto sendit;
14611466

14621467
err_system_err:
14631468
serv->sv_stats->rpcbadfmt++;
1464-
xdr_stream_encode_u32(xdr, RPC_SYSTEM_ERR);
1469+
*rqstp->rq_accept_statp = rpc_system_err;
14651470
goto sendit;
14661471
}
14671472

0 commit comments

Comments
 (0)