Skip to content

Commit eb90a16

Browse files
author
Trond Myklebust
committed
SUNRPC: rpc_decode_header() must always return a non-zero value on error
Ensure that when the "garbage args" case falls through, we do set an error of EIO. Fixes: a0584ee ("SUNRPC: Use struct xdr_stream when decoding...") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 27adc78 commit eb90a16

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

net/sunrpc/clnt.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,7 +2454,7 @@ static noinline int
24542454
rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
24552455
{
24562456
struct rpc_clnt *clnt = task->tk_client;
2457-
int error = -EACCES;
2457+
int error;
24582458
__be32 *p;
24592459

24602460
/* RFC-1014 says that the representation of XDR data must be a
@@ -2463,7 +2463,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
24632463
* undefined results
24642464
*/
24652465
if (task->tk_rqstp->rq_rcv_buf.len & 3)
2466-
goto out_badlen;
2466+
goto out_unparsable;
24672467

24682468
p = xdr_inline_decode(xdr, 3 * sizeof(*p));
24692469
if (!p)
@@ -2498,9 +2498,10 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
24982498
goto out_err;
24992499
case rpc_garbage_args:
25002500
trace_rpc__garbage_args(task);
2501+
error = -EIO;
25012502
break;
25022503
default:
2503-
trace_rpc__unparsable(task);
2504+
goto out_unparsable;
25042505
}
25052506

25062507
out_garbage:
@@ -2514,11 +2515,6 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
25142515
rpc_exit(task, error);
25152516
return error;
25162517

2517-
out_badlen:
2518-
trace_rpc__unparsable(task);
2519-
error = -EIO;
2520-
goto out_err;
2521-
25222518
out_unparsable:
25232519
trace_rpc__unparsable(task);
25242520
error = -EIO;
@@ -2529,6 +2525,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
25292525
goto out_garbage;
25302526

25312527
out_msg_denied:
2528+
error = -EACCES;
25322529
p = xdr_inline_decode(xdr, sizeof(*p));
25332530
if (!p)
25342531
goto out_unparsable;
@@ -2540,9 +2537,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
25402537
error = -EPROTONOSUPPORT;
25412538
goto out_err;
25422539
default:
2543-
trace_rpc__unparsable(task);
2544-
error = -EIO;
2545-
goto out_err;
2540+
goto out_unparsable;
25462541
}
25472542

25482543
p = xdr_inline_decode(xdr, sizeof(*p));
@@ -2577,8 +2572,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
25772572
task->tk_xprt->servername);
25782573
break;
25792574
default:
2580-
trace_rpc__unparsable(task);
2581-
error = -EIO;
2575+
goto out_unparsable;
25822576
}
25832577
goto out_err;
25842578
}

0 commit comments

Comments
 (0)