diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2019-02-11 11:24:58 -0500 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2019-02-14 09:11:18 -0500 |
commit | a0584ee9aed805446b044ce855e67264f0dc619e (patch) | |
tree | f32c32e668db5a918b86f6562c639f71f353b6cf /net/sunrpc/auth.c | |
parent | 7f5667a5f8c4ff85b14ccce9d41f9244bd30ab68 (diff) |
SUNRPC: Use struct xdr_stream when decoding RPC Reply header
Modernize and harden the code path that parses an RPC Reply
message.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'net/sunrpc/auth.c')
-rw-r--r-- | net/sunrpc/auth.c | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index add2135d9b01..e7861026b9e5 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/sunrpc/gss_api.h> | 17 | #include <linux/sunrpc/gss_api.h> |
18 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
19 | 19 | ||
20 | #include <trace/events/sunrpc.h> | ||
21 | |||
20 | #define RPC_CREDCACHE_DEFAULT_HASHBITS (4) | 22 | #define RPC_CREDCACHE_DEFAULT_HASHBITS (4) |
21 | struct rpc_cred_cache { | 23 | struct rpc_cred_cache { |
22 | struct hlist_head *hashtable; | 24 | struct hlist_head *hashtable; |
@@ -773,14 +775,6 @@ int rpcauth_marshcred(struct rpc_task *task, struct xdr_stream *xdr) | |||
773 | return ops->crmarshal(task, xdr); | 775 | return ops->crmarshal(task, xdr); |
774 | } | 776 | } |
775 | 777 | ||
776 | __be32 * | ||
777 | rpcauth_checkverf(struct rpc_task *task, __be32 *p) | ||
778 | { | ||
779 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; | ||
780 | |||
781 | return cred->cr_ops->crvalidate(task, p); | ||
782 | } | ||
783 | |||
784 | /** | 778 | /** |
785 | * rpcauth_wrap_req_encode - XDR encode the RPC procedure | 779 | * rpcauth_wrap_req_encode - XDR encode the RPC procedure |
786 | * @task: controlling RPC task | 780 | * @task: controlling RPC task |
@@ -814,27 +808,52 @@ int rpcauth_wrap_req(struct rpc_task *task, struct xdr_stream *xdr) | |||
814 | return ops->crwrap_req(task, xdr); | 808 | return ops->crwrap_req(task, xdr); |
815 | } | 809 | } |
816 | 810 | ||
817 | static int | 811 | /** |
818 | rpcauth_unwrap_req_decode(kxdrdproc_t decode, struct rpc_rqst *rqstp, | 812 | * rpcauth_checkverf - Validate verifier in RPC Reply header |
819 | __be32 *data, void *obj) | 813 | * @task: controlling RPC task |
814 | * @xdr: xdr_stream containing RPC Reply header | ||
815 | * | ||
816 | * On success, @xdr is updated to point past the verifier and | ||
817 | * zero is returned. Otherwise, @xdr is in an undefined state | ||
818 | * and a negative errno is returned. | ||
819 | */ | ||
820 | int | ||
821 | rpcauth_checkverf(struct rpc_task *task, struct xdr_stream *xdr) | ||
820 | { | 822 | { |
821 | struct xdr_stream xdr; | 823 | const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops; |
822 | 824 | ||
823 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, data, rqstp); | 825 | return ops->crvalidate(task, xdr); |
824 | return decode(rqstp, &xdr, obj); | ||
825 | } | 826 | } |
826 | 827 | ||
828 | /** | ||
829 | * rpcauth_unwrap_resp_decode - Invoke XDR decode function | ||
830 | * @task: controlling RPC task | ||
831 | * @xdr: stream where the Reply message resides | ||
832 | * | ||
833 | * Returns zero on success; otherwise a negative errno is returned. | ||
834 | */ | ||
827 | int | 835 | int |
828 | rpcauth_unwrap_resp(struct rpc_task *task, kxdrdproc_t decode, void *rqstp, | 836 | rpcauth_unwrap_resp_decode(struct rpc_task *task, struct xdr_stream *xdr) |
829 | __be32 *data, void *obj) | ||
830 | { | 837 | { |
831 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; | 838 | kxdrdproc_t decode = task->tk_msg.rpc_proc->p_decode; |
839 | |||
840 | return decode(task->tk_rqstp, xdr, task->tk_msg.rpc_resp); | ||
841 | } | ||
842 | EXPORT_SYMBOL_GPL(rpcauth_unwrap_resp_decode); | ||
843 | |||
844 | /** | ||
845 | * rpcauth_unwrap_resp - Invoke unwrap and decode function for the cred | ||
846 | * @task: controlling RPC task | ||
847 | * @xdr: stream where the Reply message resides | ||
848 | * | ||
849 | * Returns zero on success; otherwise a negative errno is returned. | ||
850 | */ | ||
851 | int | ||
852 | rpcauth_unwrap_resp(struct rpc_task *task, struct xdr_stream *xdr) | ||
853 | { | ||
854 | const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops; | ||
832 | 855 | ||
833 | if (cred->cr_ops->crunwrap_resp) | 856 | return ops->crunwrap_resp(task, xdr); |
834 | return cred->cr_ops->crunwrap_resp(task, decode, rqstp, | ||
835 | data, obj); | ||
836 | /* By default, we decode the arguments normally. */ | ||
837 | return rpcauth_unwrap_req_decode(decode, rqstp, data, obj); | ||
838 | } | 857 | } |
839 | 858 | ||
840 | bool | 859 | bool |