Commit eb90a16e authored by Trond Myklebust's avatar Trond Myklebust

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: a0584ee9 ("SUNRPC: Use struct xdr_stream when decoding...")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 27adc785
...@@ -2454,7 +2454,7 @@ static noinline int ...@@ -2454,7 +2454,7 @@ static noinline int
rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr) rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
{ {
struct rpc_clnt *clnt = task->tk_client; struct rpc_clnt *clnt = task->tk_client;
int error = -EACCES; int error;
__be32 *p; __be32 *p;
/* RFC-1014 says that the representation of XDR data must be a /* 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) ...@@ -2463,7 +2463,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
* undefined results * undefined results
*/ */
if (task->tk_rqstp->rq_rcv_buf.len & 3) if (task->tk_rqstp->rq_rcv_buf.len & 3)
goto out_badlen; goto out_unparsable;
p = xdr_inline_decode(xdr, 3 * sizeof(*p)); p = xdr_inline_decode(xdr, 3 * sizeof(*p));
if (!p) if (!p)
...@@ -2498,9 +2498,10 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr) ...@@ -2498,9 +2498,10 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
goto out_err; goto out_err;
case rpc_garbage_args: case rpc_garbage_args:
trace_rpc__garbage_args(task); trace_rpc__garbage_args(task);
error = -EIO;
break; break;
default: default:
trace_rpc__unparsable(task); goto out_unparsable;
} }
out_garbage: out_garbage:
...@@ -2514,11 +2515,6 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr) ...@@ -2514,11 +2515,6 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
rpc_exit(task, error); rpc_exit(task, error);
return error; return error;
out_badlen:
trace_rpc__unparsable(task);
error = -EIO;
goto out_err;
out_unparsable: out_unparsable:
trace_rpc__unparsable(task); trace_rpc__unparsable(task);
error = -EIO; error = -EIO;
...@@ -2529,6 +2525,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr) ...@@ -2529,6 +2525,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
goto out_garbage; goto out_garbage;
out_msg_denied: out_msg_denied:
error = -EACCES;
p = xdr_inline_decode(xdr, sizeof(*p)); p = xdr_inline_decode(xdr, sizeof(*p));
if (!p) if (!p)
goto out_unparsable; goto out_unparsable;
...@@ -2540,9 +2537,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr) ...@@ -2540,9 +2537,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
error = -EPROTONOSUPPORT; error = -EPROTONOSUPPORT;
goto out_err; goto out_err;
default: default:
trace_rpc__unparsable(task); goto out_unparsable;
error = -EIO;
goto out_err;
} }
p = xdr_inline_decode(xdr, sizeof(*p)); p = xdr_inline_decode(xdr, sizeof(*p));
...@@ -2577,8 +2572,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr) ...@@ -2577,8 +2572,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
task->tk_xprt->servername); task->tk_xprt->servername);
break; break;
default: default:
trace_rpc__unparsable(task); goto out_unparsable;
error = -EIO;
} }
goto out_err; goto out_err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment