SUNRPC GSS overhaul
Subsystems (4)
cover SUNRPC GSS overhaul
Hi-
Request For Comments on this series, which converts the rpc_auth paths (including GSS) to use xdr_stream. It applies on top of the series I sent last Friday.
I'd eventually like to see this work in v5.1.
---
Chuck Lever (10):
SUNRPC: Remove some dprintk() call sites from auth functions
SUNRPC: Remove rpc_xprt::tsh_size
SUNRPC: Add build option to disable support for insecure enctypes
SUNRPC: Add common byte-swapped RPC header constants
SUNRPC: Use struct xdr_stream when constructing RPC Call header
SUNRPC: Clean up rpc_verify_header()
SUNRPC: Use struct xdr_stream when decoding RPC Reply header
SUNRPC: Introduce trace points in rpc_auth_gss.ko
SUNRPC: Remove xdr_buf_trim()
SUNRPC: Add SPDX IDs to some net/sunrpc/auth_gss/ files
include/linux/sunrpc/auth.h | 30 +- include/linux/sunrpc/auth_gss.h | 5 include/linux/sunrpc/gss_krb5_enctypes.h | 42 ++ include/linux/sunrpc/xdr.h | 67 ++- include/linux/sunrpc/xprt.h | 7 include/trace/events/rpcgss.h | 361 +++++++++++++++++++ include/trace/events/rpcrdma.h | 12 + include/trace/events/sunrpc.h | 142 +++++++ net/sunrpc/Kconfig | 16 + net/sunrpc/auth.c | 136 ++++--- net/sunrpc/auth_gss/Makefile | 2 net/sunrpc/auth_gss/auth_gss.c | 542 ++++++++++++++-------------- net/sunrpc/auth_gss/gss_krb5_mech.c | 29 - net/sunrpc/auth_gss/gss_krb5_wrap.c | 8 net/sunrpc/auth_gss/gss_mech_switch.c | 27 - net/sunrpc/auth_gss/gss_rpc_upcall.c | 15 - net/sunrpc/auth_gss/gss_rpc_upcall.h | 16 - net/sunrpc/auth_gss/gss_rpc_xdr.c | 15 - net/sunrpc/auth_gss/gss_rpc_xdr.h | 17 - net/sunrpc/auth_gss/svcauth_gss.c | 3 net/sunrpc/auth_gss/trace.c | 11 + net/sunrpc/auth_null.c | 54 +-- net/sunrpc/auth_unix.c | 112 +++--- net/sunrpc/clnt.c | 360 +++++++++---------- net/sunrpc/svc.c | 19 - net/sunrpc/xdr.c | 41 -- net/sunrpc/xprt.c | 10 - net/sunrpc/xprtrdma/svc_rdma_backchannel.c | 1 net/sunrpc/xprtrdma/transport.c | 1 net/sunrpc/xprtsock.c | 91 +++-- 30 files changed, 1326 insertions(+), 866 deletions(-) create mode 100644 include/trace/events/rpcgss.h create mode 100644 net/sunrpc/auth_gss/trace.c
--
Chuck Lever
RFC PATCH 1/10 SUNRPC: Remove some dprintk() call sites from auth functions
Clean up: Reduce dprintk noise by removing dprintk() call sites from hot path that do not report exceptions. These are usually replaceable with function graph tracing.
--- net/sunrpc/auth.c | 29 ----------------------------- net/sunrpc/auth_unix.c | 9 +-------- 2 files changed, 1 insertion(+), 37 deletions(-)
net/sunrpc/auth.c +0 -29
@@ -17,10 +17,6 @@#include <linux/sunrpc/gss_api.h> #include <linux/spinlock.h> -#if IS_ENABLED (CONFIG_SUNRPC_DEBUG ) -# define RPCDBG_FACILITY RPCDBG_AUTH -#endif -#define RPC_CREDCACHE_DEFAULT_HASHBITS (4)struct rpc_cred_cache {struct hlist_head *hashtable;
@@ -267,8 +263,6 @@ static int param_get_hashtbl_sz(char *buffer, const struct kernel_param *kp) } }rcu_read_unlock (); - -dprintk ("RPC: %s returns %d\n" , __func__, result);return result; }EXPORT_SYMBOL_GPL (rpcauth_list_flavors);
@@ -636,9 +630,6 @@ struct rpc_cred *struct rpc_cred *ret;const struct cred *cred =current_cred (); -dprintk ("RPC: looking up %s cred\n" , - auth->au_ops->au_name); -memset (&acred,0 ,sizeof (acred)); acred.cred = cred; ret = auth->au_ops->lookup_cred (auth, &acred, flags);
@@ -670,8 +661,6 @@ struct rpc_cred * };struct rpc_cred *ret; -dprintk ("RPC: %5u looking up %s cred\n" , - task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); ret = auth->au_ops->lookup_cred (auth, &acred, lookupflags);put_cred (acred.cred);return ret;
@@ -688,8 +677,6 @@ struct rpc_cred *if (!acred.principal)return NULL ; -dprintk ("RPC: %5u looking up %s machine cred\n" , - task->tk_pid, task->tk_client->cl_auth->au_ops->au_name);return auth->au_ops->lookup_cred (auth, &acred, lookupflags); }
@@ -698,8 +685,6 @@ struct rpc_cred * {struct rpc_auth *auth = task->tk_client->cl_auth; -dprintk ("RPC: %5u looking up %s cred\n" , - task->tk_pid, auth->au_ops->au_name);return rpcauth_lookupcred (auth, lookupflags); }
@@ -776,9 +761,6 @@ struct rpc_cred * {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u marshaling %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); -return cred->cr_ops->crmarshal (task, p); }
@@ -787,9 +769,6 @@ struct rpc_cred * {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u validating %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); -return cred->cr_ops->crvalidate (task, p); }
@@ -808,8 +787,6 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u using %s cred %p to wrap rpc data\n" , - task->tk_pid, cred->cr_ops->cr_name, cred);if (cred->cr_ops->crwrap_req)return cred->cr_ops->crwrap_req (task, encode, rqstp, data, obj);/* By default, we encode the arguments normally. */
@@ -833,8 +810,6 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u using %s cred %p to unwrap rpc data\n" , - task->tk_pid, cred->cr_ops->cr_name, cred);if (cred->cr_ops->crunwrap_resp)return cred->cr_ops->crunwrap_resp (task, decode, rqstp, data, obj);
@@ -865,8 +840,6 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, goto out; cred = task->tk_rqstp->rq_cred; } -dprintk ("RPC: %5u refreshing %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); err = cred->cr_ops->crrefresh (task); out:
@@ -880,8 +853,6 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u invalidating %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred);if (cred)clear_bit (RPCAUTH_CRED_UPTODATE , &cred->cr_flags); }
net/sunrpc/auth_unix.c +1 -8
@@ -28,8 +28,6 @@static struct rpc_auth *unx_create (const struct rpc_auth_create_args *args,struct rpc_clnt *clnt) { -dprintk ("RPC: creating UNIX authenticator for client %p\n" , - clnt);refcount_inc (&unix_auth.au_count);return &unix_auth; }
@@ -37,7 +35,6 @@static void unx_destroy (struct rpc_auth *auth) { -dprintk ("RPC: destroying UNIX authenticator %p\n" , auth); }/*
@@ -48,10 +45,6 @@ {struct rpc_cred *ret =mempool_alloc (unix_pool,GFP_NOFS ); -dprintk ("RPC: allocating UNIX cred for uid %d gid %d\n" , -from_kuid (&init_user_ns, acred->cred->fsuid), -from_kgid (&init_user_ns, acred->cred->fsgid)); -rpcauth_init_cred (ret, acred, auth, &unix_credops); ret->cr_flags =1UL <<RPCAUTH_CRED_UPTODATE ;return ret;
@@ -61,7 +54,7 @@ unx_free_cred_callback(struct rcu_head *head) { struct rpc_cred *rpc_cred = container_of(head, struct rpc_cred, cr_rcu); -dprintk ("RPC: unx_free_cred %p\n" , rpc_cred); +put_cred (rpc_cred->cr_cred);mempool_free (rpc_cred, unix_pool); }
Re: [PATCH RFC 01/10] SUNRPC: Remove some dprintk() call sites from auth functions
Quoted 3 lines · Chuck Lever
Clean up: Reduce dprintk noise by removing
dprintk()call sites from hot path that do not report exceptions. These are usually replaceable with function graph tracing.
Yeah, dprintk's sometimes much to verbose to be useful, thanks for looking at this. How are you deciding what the hot paths are?
--b.
Quoted 165 lines
Signed-off-by Chuck Lever <[email protected]>--- net/sunrpc/auth.c | 29 ----------------------------- net/sunrpc/auth_unix.c | 9 +-------- 2 files changed, 1 insertion(+), 37 deletions(-)net/sunrpc/auth.c +0
-29@@ -17,10 +17,6 @@#include <linux/sunrpc/gss_api.h> #include <linux/spinlock.h> -#if IS_ENABLED (CONFIG_SUNRPC_DEBUG ) -# define RPCDBG_FACILITY RPCDBG_AUTH -#endif -#define RPC_CREDCACHE_DEFAULT_HASHBITS (4)struct rpc_cred_cache {struct hlist_head *hashtable;@@ -267,8 +263,6 @@ static int param_get_hashtbl_sz(char *buffer, const struct kernel_param *kp) } }rcu_read_unlock (); - -dprintk ("RPC: %s returns %d\n" , __func__, result);return result; }EXPORT_SYMBOL_GPL (rpcauth_list_flavors);@@ -636,9 +630,6 @@ struct rpc_cred *struct rpc_cred *ret;const struct cred *cred =current_cred (); -dprintk ("RPC: looking up %s cred\n" , - auth->au_ops->au_name); -memset (&acred,0 ,sizeof (acred)); acred.cred = cred; ret = auth->au_ops->lookup_cred (auth, &acred, flags);@@ -670,8 +661,6 @@ struct rpc_cred * };struct rpc_cred *ret; -dprintk ("RPC: %5u looking up %s cred\n" , - task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); ret = auth->au_ops->lookup_cred (auth, &acred, lookupflags);put_cred (acred.cred);return ret;@@ -688,8 +677,6 @@ struct rpc_cred *if (!acred.principal)return NULL ; -dprintk ("RPC: %5u looking up %s machine cred\n" , - task->tk_pid, task->tk_client->cl_auth->au_ops->au_name);return auth->au_ops->lookup_cred (auth, &acred, lookupflags); }@@ -698,8 +685,6 @@ struct rpc_cred * {struct rpc_auth *auth = task->tk_client->cl_auth; -dprintk ("RPC: %5u looking up %s cred\n" , - task->tk_pid, auth->au_ops->au_name);return rpcauth_lookupcred (auth, lookupflags); }@@ -776,9 +761,6 @@ struct rpc_cred * {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u marshaling %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); -return cred->cr_ops->crmarshal (task, p); }@@ -787,9 +769,6 @@ struct rpc_cred * {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u validating %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); -return cred->cr_ops->crvalidate (task, p); }@@ -808,8 +787,6 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u using %s cred %p to wrap rpc data\n" , - task->tk_pid, cred->cr_ops->cr_name, cred);if (cred->cr_ops->crwrap_req)return cred->cr_ops->crwrap_req (task, encode, rqstp, data, obj);/* By default, we encode the arguments normally. */ @@ -833,8 +810,6 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u using %s cred %p to unwrap rpc data\n" , - task->tk_pid, cred->cr_ops->cr_name, cred);if (cred->cr_ops->crunwrap_resp)return cred->cr_ops->crunwrap_resp (task, decode, rqstp, data, obj);@@ -865,8 +840,6 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, goto out; cred = task->tk_rqstp->rq_cred; } -dprintk ("RPC: %5u refreshing %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); err = cred->cr_ops->crrefresh (task); out:@@ -880,8 +853,6 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u invalidating %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred);if (cred)clear_bit (RPCAUTH_CRED_UPTODATE , &cred->cr_flags); }net/sunrpc/auth_unix.c +1
-8@@ -28,8 +28,6 @@static struct rpc_auth *unx_create (const struct rpc_auth_create_args *args,struct rpc_clnt *clnt) { -dprintk ("RPC: creating UNIX authenticator for client %p\n" , - clnt);refcount_inc (&unix_auth.au_count);return &unix_auth; }@@ -37,7 +35,6 @@static void unx_destroy (struct rpc_auth *auth) { -dprintk ("RPC: destroying UNIX authenticator %p\n" , auth); }/* @@ -48,10 +45,6 @@ {struct rpc_cred *ret =mempool_alloc (unix_pool,GFP_NOFS ); -dprintk ("RPC: allocating UNIX cred for uid %d gid %d\n" , -from_kuid (&init_user_ns, acred->cred->fsuid), -from_kgid (&init_user_ns, acred->cred->fsgid)); -rpcauth_init_cred (ret, acred, auth, &unix_credops); ret->cr_flags =1UL <<RPCAUTH_CRED_UPTODATE ;return ret;@@ -61,7 +54,7 @@ unx_free_cred_callback(struct rcu_head *head) { struct rpc_cred *rpc_cred = container_of(head, struct rpc_cred, cr_rcu); -dprintk ("RPC: unx_free_cred %p\n" , rpc_cred); +put_cred (rpc_cred->cr_cred);mempool_free (rpc_cred, unix_pool); }
Re: [PATCH RFC 01/10] SUNRPC: Remove some dprintk() call sites from auth functions
Quoted 11 lines · On Feb 4, 2019, at 2:04 PM, [email protected] wrote:
Quoted 3 lines · Chuck Lever
Clean up: Reduce dprintk noise by removing
dprintk()call sites from hot path that do not report exceptions. These are usually replaceable with function graph tracing.Yeah, dprintk's sometimes much to verbose to be useful, thanks for looking at this. How are you deciding what the hot paths are?
Anything that is called one or more times per RPC.
There are some places where low value dprintks are removed just because. By and large these can often be replaced by using the ftrace function plug-in.
Quoted 151 lines
--b.
Quoted 149 lines
Signed-off-by Chuck Lever <[email protected]>---
net/sunrpc/auth.c| 29 -----------------------------net/sunrpc/auth_unix.c| 9 +--------2 files changed, 1 insertion(+), 37 deletions(-)net/sunrpc/auth.c +0
-27@@ -17,10 +17,6 @@#include <linux/sunrpc/gss_api.h> #include <linux/spinlock.h> -#if IS_ENABLED (CONFIG_SUNRPC_DEBUG ) -# define RPCDBG_FACILITY RPCDBG_AUTH -#endif -#define RPC_CREDCACHE_DEFAULT_HASHBITS (4)struct rpc_cred_cache {struct hlist_head *hashtable;@@ -267,8 +263,6 @@ static int param_get_hashtbl_sz(char *buffer, const struct kernel_param *kp) } }rcu_read_unlock (); - -dprintk ("RPC: %s returns %d\n" , __func__, result);return result; }EXPORT_SYMBOL_GPL (rpcauth_list_flavors);@@ -636,9 +630,6 @@ struct rpc_cred *struct rpc_cred *ret;const struct cred *cred =current_cred (); -dprintk ("RPC: looking up %s cred\n" , - auth->au_ops->au_name); -memset (&acred,0 ,sizeof (acred)); acred.cred = cred; ret = auth->au_ops->lookup_cred (auth, &acred, flags);@@ -670,8 +661,6 @@ struct rpc_cred * };struct rpc_cred *ret; -dprintk ("RPC: %5u looking up %s cred\n" , - task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); ret = auth->au_ops->lookup_cred (auth, &acred, lookupflags);put_cred (acred.cred);return ret;@@ -688,8 +677,6 @@ struct rpc_cred *if (!acred.principal)return NULL ; -dprintk ("RPC: %5u looking up %s machine cred\n" , - task->tk_pid, task->tk_client->cl_auth->au_ops->au_name);return auth->au_ops->lookup_cred (auth, &acred, lookupflags); }@@ -698,8 +685,6 @@ struct rpc_cred * {struct rpc_auth *auth = task->tk_client->cl_auth; -dprintk ("RPC: %5u looking up %s cred\n" , - task->tk_pid, auth->au_ops->au_name);return rpcauth_lookupcred (auth, lookupflags); }@@ -776,9 +761,6 @@ struct rpc_cred * {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u marshaling %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); -return cred->cr_ops->crmarshal (task, p); }@@ -787,9 +769,6 @@ struct rpc_cred * {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u validating %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); -return cred->cr_ops->crvalidate (task, p); }@@ -808,8 +787,6 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u using %s cred %p to wrap rpc data\n" , - task->tk_pid, cred->cr_ops->cr_name, cred);if (cred->cr_ops->crwrap_req)return cred->cr_ops->crwrap_req (task, encode, rqstp, data, obj);/* By default, we encode the arguments normally. */ @@ -833,8 +810,6 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u using %s cred %p to unwrap rpc data\n" , - task->tk_pid, cred->cr_ops->cr_name, cred);if (cred->cr_ops->crunwrap_resp)return cred->cr_ops->crunwrap_resp (task, decode, rqstp, data, obj);@@ -865,8 +840,6 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, goto out; cred = task->tk_rqstp->rq_cred; } -dprintk ("RPC: %5u refreshing %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); err = cred->cr_ops->crrefresh (task);out:
net/sunrpc/auth.c +0
-2@@ -880,8 +853,6 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, {struct rpc_cred *cred = task->tk_rqstp->rq_cred; -dprintk ("RPC: %5u invalidating %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred);if (cred)clear_bit (RPCAUTH_CRED_UPTODATE , &cred->cr_flags); }net/sunrpc/auth_unix.c +0
-0@@ -28,8 +28,6 @@static struct
rpc_auth*unx_create(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt){net/sunrpc/auth_unix.c +0
-2-dprintk ("RPC: creating UNIX authenticator for client %p\n" , - clnt);refcount_inc(&unix_auth.au_count); return &unix_auth; }net/sunrpc/auth_unix.c +0
-0@@ -37,7 +35,6 @@static void
unx_destroy(struct rpc_auth *auth)
{net/sunrpc/auth_unix.c +0
-1-dprintk ("RPC: destroying UNIX authenticator %p\n" , auth);}
/*
net/sunrpc/auth_unix.c +0
-0@@ -48,10 +45,6 @@ {struct rpc_cred *ret =mempool_alloc (unix_pool,GFP_NOFS );
Quoted 16 lines
Quoted 8 lines
net/sunrpc/auth_unix.c +0
-4-dprintk ("RPC: allocating UNIX cred for uid %d gid %d\n" , -from_kuid (&init_user_ns, acred->cred->fsuid), -from_kgid (&init_user_ns, acred->cred->fsgid)); -rpcauth_init_cred (ret, acred, auth, &unix_credops); ret->cr_flags =1UL <<RPCAUTH_CRED_UPTODATE ;return ret;net/sunrpc/auth_unix.c line 60
Quoted 8 lines
net/sunrpc/auth_unix.c +1
-1@@ -61,7 +54,7 @@ unx_free_cred_callback(struct rcu_head *head) { struct rpc_cred *rpc_cred = container_of(head, struct rpc_cred, cr_rcu); -dprintk ("RPC: unx_free_cred %p\n" , rpc_cred); +put_cred (rpc_cred->cr_cred);mempool_free (rpc_cred, unix_pool); }
--
Chuck Lever
RFC PATCH 2/10 SUNRPC: Remove rpc_xprt::tsh_size
In reply to Chuck Levertsh_size was added to accommodate transports that send a pre-amble before each RPC message. However, this assumes the pre-amble is fixed in size, which isn't true for some transports. That makes tsh_size not very generic.
Also I'd like to make the estimation of RPC send and receive buffer sizes more precise. tsh_size doesn't currently appear to be accounted for at all by call_allocate.
Therefore let's just remove the tsh_size concept, and make the only transports that have a non-zero tsh_size employ a direct approach.
--- include/linux/sunrpc/xprt.h | 7 -- net/sunrpc/auth_gss/auth_gss.c | 3 - net/sunrpc/clnt.c | 1 net/sunrpc/svc.c | 19 +----- net/sunrpc/xprtrdma/svc_rdma_backchannel.c | 1 net/sunrpc/xprtrdma/transport.c | 1 net/sunrpc/xprtsock.c | 91 ++++++++++++++++++---------- 7 files changed, 65 insertions(+), 58 deletions(-)
include/linux/sunrpc/xprt.h +0 -7
@@ -196,8 +196,6 @@ struct rpc_xprt {size_t max_payload;/* largest RPC payload size, in bytes */ -unsigned int tsh_size;/* size of transport specific -header */ struct rpc_wait_queue binding;/* requests waiting on rpcbind */ struct rpc_wait_queue sending;/* requests waiting to send */
@@ -362,11 +360,6 @@ struct rpc_xprt * xprt_alloc(struct net *net, size_t size, unsigned int max_req);void xprt_free (struct rpc_xprt *); -static inline __be32 *xprt_skip_transport_header (struct rpc_xprt *xprt,__be32 *p) -{ -return p + xprt->tsh_size; -} -static inline int xprt_enable_swap (struct rpc_xprt *xprt) {
net/sunrpc/auth_gss/auth_gss.c +1 -2
@@ -1563,8 +1563,7 @@ static void gss_pipe_free(struct gss_pipe *p)/* We compute the checksum for the verifier over the xdr-encoded bytes * starting with the xid and ending at the end of the credential: */ - iov.iov_base =xprt_skip_transport_header (req->rq_xprt, - req->rq_snd_buf.head[0 ].iov_base); + iov.iov_base = req->rq_snd_buf.head[0 ].iov_base; iov.iov_len = (u8 *)p - (u8 *)iov.iov_base;xdr_buf_from_iov (&iov, &verf_buf);
net/sunrpc/clnt.c +0 -1
@@ -2331,7 +2331,6 @@ void rpc_force_rebind(struct rpc_clnt *clnt)/* FIXME: check buffer size? */ - p =xprt_skip_transport_header (req->rq_xprt, p); *p++ = req->rq_xid;/* XID */ *p++ =htonl (RPC_CALL );/* CALL */ *p++ =htonl (RPC_VERSION );/* RPC version */
net/sunrpc/svc.c +4 -15
@@ -1145,17 +1145,6 @@ static __printf(2,3) void svc_printk(struct svc_rqst *rqstp, const char *fmt, ..#endif /* -* Setup response header for TCP, it has a 4B record length field. -*/ -static void svc_tcp_prep_reply_hdr (struct svc_rqst *rqstp) -{ -struct kvec *resv = &rqstp->rq_res.head[0 ]; - -/* tcp needs a space for the record length... */ -svc_putnl (resv,0 ); -} - -/* * Common routine for processing the RPC request. */ static int
@@ -1182,10 +1171,6 @@ static void svc_tcp_prep_reply_hdr(struct svc_rqst *rqstp)set_bit (RQ_USEDEFERRAL , &rqstp->rq_flags);clear_bit (RQ_DROPME , &rqstp->rq_flags); -/* Setup reply header */ -if (rqstp->rq_prot ==IPPROTO_TCP ) -svc_tcp_prep_reply_hdr (rqstp); -svc_putu32 (resv, rqstp->rq_xid); vers =svc_getnl (argv);
@@ -1443,6 +1428,10 @@ static void svc_tcp_prep_reply_hdr(struct svc_rqst *rqstp) goto out_drop; } +/* Reserve space for the record marker */ +if (rqstp->rq_prot ==IPPROTO_TCP ) +svc_putnl (resv,0 ); +/* Returns 1 for send, 0 for drop */ if (likely (svc_process_common (rqstp, argv, resv)))return svc_send (rqstp);
net/sunrpc/xprtrdma/svc_rdma_backchannel.c +0 -1
@@ -304,7 +304,6 @@ static int svc_rdma_bc_sendto(struct svcxprt_rdma *rdma, xprt->idle_timeout =RPCRDMA_IDLE_DISC_TO ; xprt->prot =XPRT_TRANSPORT_BC_RDMA ; - xprt->tsh_size =0 ; xprt->ops = &xprt_rdma_bc_procs;memcpy (&xprt->addr, args->dstaddr, args->addrlen);
net/sunrpc/xprtrdma/transport.c +0 -1
@@ -332,7 +332,6 @@ xprt->idle_timeout =RPCRDMA_IDLE_DISC_TO ; xprt->resvport =0 ;/* privileged port not needed */ - xprt->tsh_size =0 ;/* RPC-RDMA handles framing */ xprt->ops = &xprt_rdma_procs;/*
net/sunrpc/xprtsock.c +60 -31
159 lines not on this page · raw message
RFC PATCH 3/10 SUNRPC: Add build option to disable support for insecure enctypes
In reply to Chuck LeverEnable distributions to enforce the rejection of ancient and insecure Kerberos enctypes in the kernel's RPCSEC_GSS implementation. These are the single-DES encryption types that were deprecated in 2012 by RFC 6649.
Enctypes that were deprecated more recently (by RFC 8429) remain fully supported for now because they are still likely to be widely used.
--- include/linux/sunrpc/gss_krb5_enctypes.h | 42 +++++++++++++++++++++++++++++- net/sunrpc/Kconfig | 16 +++++++++++ net/sunrpc/auth_gss/gss_krb5_mech.c | 2 + 3 files changed, 59 insertions(+), 1 deletion(-)
include/linux/sunrpc/gss_krb5_enctypes.h +41 -1
@@ -1,4 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* -* Dumb way to share this static piece of information with nfsd +* Define the string that exports the set of kernel-supported +* Kerberos enctypes. This list is sent via upcall to gssd, and +* is also exposed via the nfsd /proc API. The consumers generally +* treat this as an ordered list, where the first item in the list +* is the most preferred. +*/ + +#ifndef _LINUX_SUNRPC_GSS_KRB5_ENCTYPES_H +#define _LINUX_SUNRPC_GSS_KRB5_ENCTYPES_H + +#ifdef CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES + +/* +* NB: This list includes encryption types that were deprecated +* by RFC 8429 (DES3_CBC_SHA1 and ARCFOUR_HMAC). +* +* ENCTYPE_AES256_CTS_HMAC_SHA1_96 +* ENCTYPE_AES128_CTS_HMAC_SHA1_96 +* ENCTYPE_DES3_CBC_SHA1 +* ENCTYPE_ARCFOUR_HMAC +*/ +#define KRB5_SUPPORTED_ENCTYPES "18,17,16,23" + +#else /* CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES */ + +/* +* NB: This list includes encryption types that were deprecated +* by RFC 8429 and RFC 6649. +* +* ENCTYPE_AES256_CTS_HMAC_SHA1_96 +* ENCTYPE_AES128_CTS_HMAC_SHA1_96 +* ENCTYPE_DES3_CBC_SHA1 +* ENCTYPE_ARCFOUR_HMAC +* ENCTYPE_DES_CBC_MD5 +* ENCTYPE_DES_CBC_CRC +* ENCTYPE_DES_CBC_MD4 */ #define KRB5_SUPPORTED_ENCTYPES "18,17,16,23,3,1,2" + +#endif /* CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES */ + +#endif /* _LINUX_SUNRPC_GSS_KRB5_ENCTYPES_H */
net/sunrpc/Kconfig +16 -0
@@ -34,6 +34,22 @@ config RPCSEC_GSS_KRB5 If unsure, say Y. +config CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES + bool "Secure RPC: Disable insecure Kerberos encryption types" + depends on RPCSEC_GSS_KRB5 + default n + help + Choose Y here to disable the use of deprecated encryption types + with the Kerberos version 5 GSS-API mechanism (RFC 1964). The + deprecated encryption types include DES-CBC-MD5, DES-CBC-CRC, + and DES-CBC-MD4. These types were deprecated by RFC 6649 because + they were found to be insecure. + + N is the default because many sites have deployed KDCs and + keytabs that contain only these deprecated encryption types. + Choosing Y prevents the use of known-insecure encryption types + but might result in compatibility problems. + config SUNRPC_DEBUG bool "RPC: Enable dprintk debugging" depends on SUNRPC && SYSCTL
net/sunrpc/auth_gss/gss_krb5_mech.c +2 -0
@@ -53,6 +53,7 @@static struct gss_api_mech gss_kerberos_mech;/* forward declaration */ static const struct gss_krb5_enctype supported_gss_krb5_enctypes[] = { +#ifndef CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES/* * DES (All DES enctypes are mapped to the same gss functionality) */
@@ -74,6 +75,7 @@ .cksumlength = 8, .keyed_cksum = 0, }, +#endif /* CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES */ /* * RC4-HMAC */
RFC PATCH 4/10 SUNRPC: Add common byte-swapped RPC header constants
In reply to Chuck LeverByte-swapping causes a CPU pipeline bubble on some processors. When a decoder is comparing an on-the-wire value for equality, byte- swapping can be avoided by comparing it directly to a pre-byte- swapped constant value.
The current set of pre-xdr'd constants is missing some common values used in the RPC header. Fill those out.
--- include/linux/sunrpc/auth_gss.h | 5 ++- include/linux/sunrpc/xdr.h | 66 ++++++++++++++++++++++++--------------- 2 files changed, 45 insertions(+), 26 deletions(-)
include/linux/sunrpc/auth_gss.h +4 -1
@@ -19,7 +19,10 @@#include <linux/sunrpc/svc.h> #include <linux/sunrpc/gss_api.h> -#define RPC_GSS_VERSION 1 +enum { +RPC_GSS_VERSION =1 , + rpc_gss_version =cpu_to_be32 (RPC_GSS_VERSION ) +};#define MAXSEQ 0x80000000/* maximum legal sequence number, from rfc 2203 */
include/linux/sunrpc/xdr.h +41 -25
78 lines not on this page · raw message
Tom Talpey
reviewerRe: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Quoted 65 lines · Chuck Lever
Byte-swapping causes a CPU pipeline bubble on some processors. When a decoder is comparing an on-the-wire value for equality, byte- swapping can be avoided by comparing it directly to a pre-byte- swapped constant value.
The current set of pre-xdr'd constants is missing some common values used in the RPC header. Fill those out.
Signed-off-by Chuck Lever <[email protected]>--- include/linux/sunrpc/auth_gss.h | 5 ++- include/linux/sunrpc/xdr.h | 66 ++++++++++++++++++++++++--------------- 2 files changed, 45 insertions(+), 26 deletions(-)include/linux/sunrpc/auth_gss.h +4
-1@@ -19,7 +19,10 @@#include <linux/sunrpc/svc.h> #include <linux/sunrpc/gss_api.h> -#define RPC_GSS_VERSION 1 +enum { +RPC_GSS_VERSION =1 , + rpc_gss_version =cpu_to_be32 (RPC_GSS_VERSION ) +};#define MAXSEQ 0x80000000/* maximum legal sequence number, from rfc 2203 */ include/linux/sunrpc/xdr.h +1
-19@@ -17,6 +17,7 @@#include <asm/byteorder.h> #include <asm/unaligned.h> #include <linux/scatterlist.h> +#include <linux/sunrpc/msg_prot.h> struct bio_vec ;struct rpc_rqst ;@@ -79,31 +80,46 @@ struct xdr_buf { buf->buflen = len; } -/* -* pre-xdr'ed macros. -*/ - -#define xdr_zero cpu_to_be32(0) -#define xdr_one cpu_to_be32(1) -#define xdr_two cpu_to_be32(2) - -#define rpc_success cpu_to_be32(RPC_SUCCESS) -#define rpc_prog_unavail cpu_to_be32(RPC_PROG_UNAVAIL) -#define rpc_prog_mismatch cpu_to_be32(RPC_PROG_MISMATCH) -#define rpc_proc_unavail cpu_to_be32(RPC_PROC_UNAVAIL) -#define rpc_garbage_args cpu_to_be32(RPC_GARBAGE_ARGS) -#define rpc_system_err cpu_to_be32(RPC_SYSTEM_ERR) -#define rpc_drop_reply cpu_to_be32(RPC_DROP_REPLY) - -#define rpc_auth_ok cpu_to_be32(RPC_AUTH_OK) -#define rpc_autherr_badcred cpu_to_be32(RPC_AUTH_BADCRED) -#define rpc_autherr_rejectedcred cpu_to_be32(RPC_AUTH_REJECTEDCRED)
include/linux/sunrpc/xdr.h struct xdr_buf { · line 86
Quoted 10 lines
include/linux/sunrpc/xdr.h +4
-6-#define rpc_autherr_badverf cpu_to_be32(RPC_AUTH_BADVERF) -#define rpc_autherr_rejectedverf cpu_to_be32(RPC_AUTH_REJECTEDVERF) -#define rpc_autherr_tooweak cpu_to_be32(RPC_AUTH_TOOWEAK) -#define rpcsec_gsserr_credproblem cpu_to_be32(RPCSEC_GSS_CREDPROBLEM) -#define rpcsec_gsserr_ctxproblem cpu_to_be32(RPCSEC_GSS_CTXPROBLEM) -#define rpc_autherr_oldseqnum cpu_to_be32(101) +enum xdr_be32_equivalents { + xdr_zero =cpu_to_be32 (0 ), + xdr_one =cpu_to_be32 (1 ), + xdr_two =cpu_to_be32 (2 ),
It is clever to use an enum to pre-compute these values, but it becomes a concern that the type (and size) of an enum may not be the same as values they may be compared to.
Commonly, code may compare them to int32, uint32, etc. What guarantees are there that such comparisons will yield the appropriate result, especially if a < or > test is performed?
Tom.
Quoted 42 lines
include/linux/sunrpc/xdr.h +36
-0+ + rpc_version =cpu_to_be32 (RPC_VERSION ), + + rpc_auth_null =cpu_to_be32 (RPC_AUTH_NULL ), + rpc_auth_unix =cpu_to_be32 (RPC_AUTH_UNIX ), + rpc_auth_short =cpu_to_be32 (RPC_AUTH_SHORT ), + rpc_auth_des =cpu_to_be32 (RPC_AUTH_DES ), + rpc_auth_krb =cpu_to_be32 (RPC_AUTH_KRB ), + rpc_auth_gss =cpu_to_be32 (RPC_AUTH_GSS ), + + rpc_call =cpu_to_be32 (RPC_CALL ), + rpc_reply =cpu_to_be32 (RPC_REPLY ), + + rpc_msg_accepted =cpu_to_be32 (RPC_MSG_ACCEPTED ), + rpc_msg_denied =cpu_to_be32 (RPC_MSG_DENIED ), + + rpc_success =cpu_to_be32 (RPC_SUCCESS ), + rpc_prog_unavail =cpu_to_be32 (RPC_PROG_UNAVAIL ), + rpc_prog_mismatch =cpu_to_be32 (RPC_PROG_MISMATCH ), + rpc_proc_unavail =cpu_to_be32 (RPC_PROC_UNAVAIL ), + rpc_garbage_args =cpu_to_be32 (RPC_GARBAGE_ARGS ), + rpc_system_err =cpu_to_be32 (RPC_SYSTEM_ERR ), + rpc_drop_reply =cpu_to_be32 (RPC_DROP_REPLY ), + + rpc_mismatch =cpu_to_be32 (RPC_MISMATCH ), + rpc_auth_error =cpu_to_be32 (RPC_AUTH_ERROR ), + + rpc_auth_ok =cpu_to_be32 (RPC_AUTH_OK ), + rpc_autherr_badcred =cpu_to_be32 (RPC_AUTH_BADCRED ), + rpc_autherr_rejectedcred =cpu_to_be32 (RPC_AUTH_REJECTEDCRED ), + rpc_autherr_badverf =cpu_to_be32 (RPC_AUTH_BADVERF ), + rpc_autherr_rejectedverf =cpu_to_be32 (RPC_AUTH_REJECTEDVERF ), + rpc_autherr_tooweak =cpu_to_be32 (RPC_AUTH_TOOWEAK ), + rpcsec_gsserr_credproblem =cpu_to_be32 (RPCSEC_GSS_CREDPROBLEM ), + rpcsec_gsserr_ctxproblem = cpu_to_be32(RPCSEC_GSS_CTXPROBLEM), +};/* * Miscellaneous XDR helper functions
Re: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Quoted 66 lines · Tom Talpey
Quoted 61 lines · Chuck Lever
Byte-swapping causes a CPU pipeline bubble on some processors. When a decoder is comparing an on-the-wire value for equality, byte- swapping can be avoided by comparing it directly to a pre-byte- swapped constant value.
The current set of pre-xdr'd constants is missing some common values used in the RPC header. Fill those out.Signed-off-by Chuck Lever <[email protected]>--- include/linux/sunrpc/auth_gss.h | 5 ++- include/linux/sunrpc/xdr.h | 66 ++++++++++++++++++++++++--------------- 2 files changed, 45 insertions(+), 26 deletions(-)include/linux/sunrpc/auth_gss.h +4
-0@@ -19,7 +19,10 @@#include <linux/sunrpc/svc.h> #include <linux/sunrpc/gss_api.h> -#define RPC_GSS_VERSION 1 +enum { +RPC_GSS_VERSION =1 , + rpc_gss_version =cpu_to_be32 (RPC_GSS_VERSION ) +};#define MAXSEQ 0x80000000/* maximum legal sequence number, from rfc 2203 */ diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.hindex 787939d..69161cb 100644
include/linux/sunrpc/xdr.h +1
-22@@ -17,6 +17,7 @@#include <asm/byteorder.h> #include <asm/unaligned.h> #include <linux/scatterlist.h> +#include <linux/sunrpc/msg_prot.h> struct bio_vec ;struct rpc_rqst ;@@ -79,31 +80,46 @@ struct xdr_buf { buf->buflen = len; } -/* -* pre-xdr'ed macros. -*/ - -#define xdr_zero cpu_to_be32(0) -#define xdr_one cpu_to_be32(1) -#define xdr_two cpu_to_be32(2) - -#define rpc_success cpu_to_be32(RPC_SUCCESS) -#define rpc_prog_unavail cpu_to_be32(RPC_PROG_UNAVAIL) -#define rpc_prog_mismatch cpu_to_be32(RPC_PROG_MISMATCH) -#define rpc_proc_unavail cpu_to_be32(RPC_PROC_UNAVAIL) -#define rpc_garbage_args cpu_to_be32(RPC_GARBAGE_ARGS) -#define rpc_system_err cpu_to_be32(RPC_SYSTEM_ERR) -#define rpc_drop_reply cpu_to_be32(RPC_DROP_REPLY) - -#define rpc_auth_ok cpu_to_be32(RPC_AUTH_OK) -#define rpc_autherr_badcred cpu_to_be32(RPC_AUTH_BADCRED) -#define rpc_autherr_rejectedcred cpu_to_be32(RPC_AUTH_REJECTEDCRED) -#define rpc_autherr_badverf cpu_to_be32(RPC_AUTH_BADVERF) -#define rpc_autherr_rejectedverf cpu_to_be32(RPC_AUTH_REJECTEDVERF) -#define rpc_autherr_tooweak cpu_to_be32(RPC_AUTH_TOOWEAK) -#define rpcsec_gsserr_credproblem cpu_to_be32(RPCSEC_GSS_CREDPROBLEM)
Quoted 8 lines
include/linux/sunrpc/xdr.h struct xdr_buf { · line 86
Quoted 6 lines
include/linux/sunrpc/xdr.h +4
-2-#define rpcsec_gsserr_ctxproblem cpu_to_be32(RPCSEC_GSS_CTXPROBLEM) -#define rpc_autherr_oldseqnum cpu_to_be32(101) +enum xdr_be32_equivalents { + xdr_zero =cpu_to_be32 (0 ), + xdr_one =cpu_to_be32 (1 ), + xdr_two =cpu_to_be32 (2 ),It is clever to use an enum to pre-compute these values, but
Perhaps not clever; it is a current Linux kernel coding practice to use an enum in favor of a C macro for constants.
Quoted 2 lines
it becomes a concern that the type (and size) of an enum may not be the same as values they may be compared to.
Indeed, an enum is a variably-sized signed integer, IIUC.
Quoted 3 lines
Commonly, code may compare them to int32, uint32, etc. What guarantees are there that such comparisons will yield the appropriate result, especially if a < or > test is performed?
I believe for the purposes of assignment and equality comparison the compiler will promote these to the size and sign of the variable. We would never perform a greater or less than test with these values, obviously.
However, they probably should have an obvious and well-defined type, and I should leave the already-defined macros as they are.
Quoted 32 lines
Tom.
Quoted 30 lines
include/linux/sunrpc/xdr.h +30
-0+ + rpc_version =cpu_to_be32 (RPC_VERSION ), + + rpc_auth_null =cpu_to_be32 (RPC_AUTH_NULL ), + rpc_auth_unix =cpu_to_be32 (RPC_AUTH_UNIX ), + rpc_auth_short =cpu_to_be32 (RPC_AUTH_SHORT ), + rpc_auth_des =cpu_to_be32 (RPC_AUTH_DES ), + rpc_auth_krb =cpu_to_be32 (RPC_AUTH_KRB ), + rpc_auth_gss =cpu_to_be32 (RPC_AUTH_GSS ), + + rpc_call =cpu_to_be32 (RPC_CALL ), + rpc_reply =cpu_to_be32 (RPC_REPLY ), + + rpc_msg_accepted =cpu_to_be32 (RPC_MSG_ACCEPTED ), + rpc_msg_denied =cpu_to_be32 (RPC_MSG_DENIED ), + + rpc_success =cpu_to_be32 (RPC_SUCCESS ), + rpc_prog_unavail =cpu_to_be32 (RPC_PROG_UNAVAIL ), + rpc_prog_mismatch =cpu_to_be32 (RPC_PROG_MISMATCH ), + rpc_proc_unavail =cpu_to_be32 (RPC_PROC_UNAVAIL ), + rpc_garbage_args =cpu_to_be32 (RPC_GARBAGE_ARGS ), + rpc_system_err =cpu_to_be32 (RPC_SYSTEM_ERR ), + rpc_drop_reply =cpu_to_be32 (RPC_DROP_REPLY ), + + rpc_mismatch =cpu_to_be32 (RPC_MISMATCH ), + rpc_auth_error =cpu_to_be32 (RPC_AUTH_ERROR ), + + rpc_auth_ok =cpu_to_be32 (RPC_AUTH_OK ), + rpc_autherr_badcred =cpu_to_be32 (RPC_AUTH_BADCRED ), + rpc_autherr_rejectedcred = cpu_to_be32(RPC_AUTH_REJECTEDCRED),
Quoted 8 lines
include/linux/sunrpc/xdr.h struct xdr_buf { · line 125
Quoted 8 lines
include/linux/sunrpc/xdr.h +6
-0+ rpc_autherr_badverf =cpu_to_be32 (RPC_AUTH_BADVERF ), + rpc_autherr_rejectedverf =cpu_to_be32 (RPC_AUTH_REJECTEDVERF ), + rpc_autherr_tooweak =cpu_to_be32 (RPC_AUTH_TOOWEAK ), + rpcsec_gsserr_credproblem =cpu_to_be32 (RPCSEC_GSS_CREDPROBLEM ), + rpcsec_gsserr_ctxproblem = cpu_to_be32(RPCSEC_GSS_CTXPROBLEM), +};/* * Miscellaneous XDR helper functions
--
Chuck Lever
Re: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Quoted 85 lines · Chuck Lever
Quoted 76 lines · Tom Talpey
Quoted 73 lines · Chuck Lever
Byte-swapping causes a CPU pipeline bubble on some processors. When
a decoder is comparing an on-the-wire value for equality, byte- swapping can be avoided by comparing it directly to a pre-byte- swapped constant value.
The current set of pre-xdr'd constants is missing some common values
used in the RPC header. Fill those out.Signed-off-by Chuck Lever <[email protected]>--- include/linux/sunrpc/auth_gss.h | 5 ++- include/linux/sunrpc/xdr.h | 66 ++++++++++++++++++++++++- -------------- 2 files changed, 45 insertions(+), 26 deletions(-)include/linux/sunrpc/auth_gss.h +4
-0@@ -19,7 +19,10 @@#include <linux/sunrpc/svc.h> #include <linux/sunrpc/gss_api.h> -#define RPC_GSS_VERSION 1 +enum { +RPC_GSS_VERSION =1 , + rpc_gss_version =cpu_to_be32 (RPC_GSS_VERSION ) +};#define MAXSEQ 0x80000000/* maximum legal sequence number, from rfc 2203 */
diff --gita/include/linux/sunrpc/xdr.hb/include/linux/sunrpc/xdr.h
index 787939d..69161cb 100644include/linux/sunrpc/xdr.h +1
-23@@ -17,6 +17,7 @@#include <asm/byteorder.h> #include <asm/unaligned.h> #include <linux/scatterlist.h> +#include <linux/sunrpc/msg_prot.h> struct bio_vec ;struct rpc_rqst ;@@ -79,31 +80,46 @@ struct xdr_buf { buf->buflen = len; } -/* -* pre-xdr'ed macros. -*/ - -#define xdr_zero cpu_to_be32(0) -#define xdr_one cpu_to_be32(1) -#define xdr_two cpu_to_be32(2) - -#define rpc_success cpu_to_be32(RPC_SUCCESS) -#define rpc_prog_unavail cpu_to_be32(RPC_PROG_UNAVAIL) -#define rpc_prog_mismatch cpu_to_be32(RPC_PROG_MISMATCH) -#define rpc_proc_unavail cpu_to_be32(RPC_PROC_UNAVAIL) -#define rpc_garbage_args cpu_to_be32(RPC_GARBAGE_ARGS) -#define rpc_system_err cpu_to_be32(RPC_SYSTEM_ERR) -#define rpc_drop_reply cpu_to_be32(RPC_DROP_REPLY) - -#define rpc_auth_ok cpu_to_be32(RPC_AUTH_OK) -#define rpc_autherr_badcred cpu_to_be32(RPC_AUTH_BADCRED) -#define rpc_autherr_rejectedcredcpu_to_be32(RPC_AUTH_REJECTEDCRED) -#define rpc_autherr_badverf cpu_to_be32(RPC_AUTH_BADVERF) -#define rpc_autherr_rejectedverfcpu_to_be32(RPC_AUTH_REJECTEDVERF) -#define rpc_autherr_tooweak cpu_to_be32(RPC_AUTH_TOOWEAK) -#define rpcsec_gsserr_credproblem cpu_to_be32(RPCSEC_GSS_CREDPROBLEM) -#define rpcsec_gsserr_ctxproblem cpu_to_be32(RPCSEC_GSS_CTQuoted 8 lines
include/linux/sunrpc/xdr.h struct xdr_buf { · line 86
Quoted 6 lines
XPROBLEM)
include/linux/sunrpc/xdr.h +4
-1-#define rpc_autherr_oldseqnum cpu_to_be32(101) +enum xdr_be32_equivalents { + xdr_zero =cpu_to_be32 (0 ), + xdr_one =cpu_to_be32 (1 ), + xdr_two =cpu_to_be32 (2 ),It is clever to use an enum to pre-compute these values, but
Quoted 2 lines
Perhaps not clever; it is a current Linux kernel coding practice to use an enum in favor of a C macro for constants.
Sure, but won't that confuse 'sparse' static checking? These constants will no longer appear as being big endian.
Doesn't gcc's __builtin_bswap32() already compute the result at compile time when you feed it a constant value? AFAICS it is supposed to, which is why we use it directly in include/uapi/linux/swab.h instead of using a special cased __builtin_constant_p().
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Re: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Quoted 90 lines · Trond Myklebust
Quoted 85 lines · Chuck Lever
Quoted 84 lines · Tom Talpey
Quoted 74 lines · Chuck Lever
Byte-swapping causes a CPU pipeline bubble on some processors. When
a decoder is comparing an on-the-wire value for equality, byte- swapping can be avoided by comparing it directly to a pre-byte- swapped constant value.
The current set of pre-xdr'd constants is missing some common values
used in the RPC header. Fill those out.Signed-off-by Chuck Lever <[email protected]>---
include/linux/sunrpc/auth_gss.h| 5 ++-include/linux/sunrpc/xdr.h| 66 ++++++++++++++++++++++++-
--------------2 files changed, 45 insertions(+), 26 deletions(-)include/linux/sunrpc/auth_gss.h +4
-1@@ -19,7 +19,10 @@#include <linux/sunrpc/svc.h> #include <linux/sunrpc/gss_api.h> -#define RPC_GSS_VERSION 1 +enum { +RPC_GSS_VERSION =1 , + rpc_gss_version =cpu_to_be32 (RPC_GSS_VERSION ) +};#define MAXSEQ 0x80000000/* maximum legal sequence number, from rfc 2203 */
include/linux/sunrpc/xdr.h +1
-24@@ -17,6 +17,7 @@#include <asm/byteorder.h> #include <asm/unaligned.h> #include <linux/scatterlist.h> +#include <linux/sunrpc/msg_prot.h> struct bio_vec ;struct rpc_rqst ;@@ -79,31 +80,46 @@ struct xdr_buf { buf->buflen = len; } -/* -* pre-xdr'ed macros. -*/ - -#define xdr_zero cpu_to_be32(0) -#define xdr_one cpu_to_be32(1) -#define xdr_two cpu_to_be32(2) - -#define rpc_success cpu_to_be32(RPC_SUCCESS) -#define rpc_prog_unavail cpu_to_be32(RPC_PROG_UNAVAIL) -#define rpc_prog_mismatch cpu_to_be32(RPC_PROG_MISMATCH) -#define rpc_proc_unavail cpu_to_be32(RPC_PROC_UNAVAIL) -#define rpc_garbage_args cpu_to_be32(RPC_GARBAGE_ARGS) -#define rpc_system_err cpu_to_be32(RPC_SYSTEM_ER R) -#define rpc_drop_reply cpu_to_be32(RPC_DROP_REPL Y) - -#define rpc_auth_ok cpu_to_be32(RPC_AUTH_OK) -#define rpc_autherr_badcred cpu_to_be32(RPC_AUTH_BADCRED) -#define rpc_autherr_rejectedcred cpu_to_be32(RPC_AUTH_REJECTEDCRED) -#define rpc_autherr_badverf cpu_to_be32(RPC_AUTH_BADVERF) -#define rpc_autherr_rejectedverf cpu_to_be32(RPC_AUTH_REJECTEDVERF) -#define rpc_autherr_tooweak cpu_to_be32(RPC_AUTH_TOOWEAK) -#define rpcsec_gsserr_credproblem cpu_to_be32(RPCSEC_GSS_CR EDPROBLEM) -#define rpcsec_gsserr_ctxproblem cpu_to_be32(RPCSEC_GSS_CTXPROBLEM)
include/linux/sunrpc/xdr.h struct xdr_buf { · line 86
Quoted 5 lines
include/linux/sunrpc/xdr.h +4
-1-#define rpc_autherr_oldseqnum cpu_to_be32(101) +enum xdr_be32_equivalents { + xdr_zero =cpu_to_be32 (0 ), + xdr_one =cpu_to_be32 (1 ), + xdr_two =cpu_to_be32 (2 ),It is clever to use an enum to pre-compute these values, but
Quoted 5 lines
Quoted 2 lines
Perhaps not clever; it is a current Linux kernel coding practice to use an enum in favor of a C macro for constants.
Sure, but won't that confuse 'sparse' static checking? These constants will no longer appear as being big endian.
Agreed, that is not a desirable situation for these symbolic constants.
Quoted 4 lines
Doesn't gcc's
__builtin_bswap32()already compute the result at compile time when you feed it a constant value? AFAICS it is supposed to, which is why we use it directly ininclude/uapi/linux/swab.hinstead of using a special cased__builtin_constant_p().
The return type of __builtin_bswap32 is uint32_t, not __be32.
I will stick with cpu_to_be32(), and simply add the missing constants.
--
Chuck Lever
Re: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Quoted 11 lines · Chuck Lever
Quoted 10 lines
On Feb 3, 2019, at 10:00 AM, Trond Myklebust <
[email protected]> wrote:Doesn't gcc's
__builtin_bswap32()already compute the result at compile
time when you feed it a constant value? AFAICS it is supposed to, which
is why we use it directly ininclude/uapi/linux/swab.hinstead of using
a special cased__builtin_constant_p().
Quoted 5 lines
The return type of
__builtin_bswap32isuint32_t, not__be32.I will stick with
cpu_to_be32(), and simply add the missing constants.
cpu_to_be32() is a macro that expands to __builtin_bswap32() plus a cast for most architectures on gcc.
What I'm saying is that as far as I know, the existing #defines should compile into be32 constants by default, as should any call of the form cpu_to_b32(<const expression>) and htonl(<const expression>).
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Re: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
In reply to Chuck LeverQuoted 4 lines · Chuck Lever
Byte-swapping causes a CPU pipeline bubble on some processors. When a decoder is comparing an on-the-wire value for equality, byte- swapping can be avoided by comparing it directly to a pre-byte- swapped constant value.
Which ones?
Re: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Quoted 11 lines · Christoph Hellwig
Quoted 4 lines · Chuck Lever
Byte-swapping causes a CPU pipeline bubble on some processors. When a decoder is comparing an on-the-wire value for equality, byte- swapping can be avoided by comparing it directly to a pre-byte- swapped constant value.
Which ones?
I assume you mean on which processors have I observed CPU cycle spikes around bswap instructions. I've seen this behavior only on Intel processors of various families.
Would you prefer a different justification for this clean-up?
--
Chuck Lever
Re: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Quoted 9 lines · Chuck Lever
Quoted 6 lines
Quoted 4 lines
Byte-swapping causes a CPU pipeline bubble on some processors. When a decoder is comparing an on-the-wire value for equality, byte- swapping can be avoided by comparing it directly to a pre-byte- swapped constant value.
Which ones?
I assume you mean on which processors have I observed CPU cycle spikes around bswap instructions.
Yes.
Quoted 2 lines
I've seen this behavior only
on Intel processors of various families.
Interesting. In general we should not do separate byte swap instructions on x86, as MOVBE can be used to do a load or store with an included byteswap, and I thought the whole point for that was that they could be handled in the same cycle.
In fact https://www.agner.org/optimize/instruction_tables.pdf
says that movbe is generally a single cycle instruction.
Quoted 1 line
Would you prefer a different justification for this clean-up?
I don't really care about the cleanup, it is just that the explanation goes against conventional wisdom, which is why I was a little surpised.
And that is not just the cycles, but also as Trond pointed out that the Linux byte swapping macro on constants should usually be optimized away at compile time anyway.
Re: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Quoted 28 lines · Christoph Hellwig
Quoted 9 lines · Chuck Lever
Quoted 6 lines
Quoted 4 lines
Byte-swapping causes a CPU pipeline bubble on some processors. When a decoder is comparing an on-the-wire value for equality, byte- swapping can be avoided by comparing it directly to a pre-byte- swapped constant value.
Which ones?
I assume you mean on which processors have I observed CPU cycle spikes around bswap instructions.
Yes.
Quoted 2 lines
I've seen this behavior only
on Intel processors of various families.Interesting. In general we should not do separate byte swap instructions on x86, as MOVBE can be used to do a load or store with an included byteswap, and I thought the whole point for that was that they could be handled in the same cycle.
In fact https://www.agner.org/optimize/instruction_tables.pdf
says that movbe is generally a single cycle instruction.
Quoted 8 lines
Quoted 1 line
Would you prefer a different justification for this clean-up?
I don't really care about the cleanup, it is just that the explanation goes against conventional wisdom, which is why I was a little surpised.
And that is not just the cycles, but also as Trond pointed out that the Linux byte swapping macro on constants should usually be optimized away at compile time anyway.
They are. The problem is that we are byte-swapping the incoming wire data and then comparing to CPU-endian constants in some hot paths. It's better to leave the incoming data alone and compare to a pre- byte-swapped constant. This patch adds some of these constants that were missing, in preparation for fixing the hot paths.
That is apparently not clear from the patch description, so I will endeavor to improve it.
--
Chuck Lever
Re: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Quoted 8 lines · Chuck Lever
They are. The problem is that we are byte-swapping the incoming wire data and then comparing to CPU-endian constants in some hot paths. It's better to leave the incoming data alone and compare to a pre- byte-swapped constant. This patch adds some of these constants that were missing, in preparation for fixing the hot paths.
That is apparently not clear from the patch description, so I will endeavor to improve it.
Why do we need new enums / #defines for that?
Just replace:
if (beXX_to_cpu(pkt->field) == SOME_CONSTANT)
with
if (pkt->field == cpu_to_be32(SOME_CONSTANT))
and we are done. The latter is a pretty common pattern through the kernel.
Re: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Quoted 18 lines · Christoph Hellwig
Quoted 8 lines · Chuck Lever
They are. The problem is that we are byte-swapping the incoming wire data and then comparing to CPU-endian constants in some hot paths. It's better to leave the incoming data alone and compare to a pre- byte-swapped constant. This patch adds some of these constants that were missing, in preparation for fixing the hot paths.
That is apparently not clear from the patch description, so I will endeavor to improve it.
Why do we need new enums / #defines for that?
Just replace:
Quoted 7 lines
if (beXX_to_cpu(pkt->field) == SOME_CONSTANT)with
if (pkt->field == cpu_to_be32(SOME_CONSTANT))and we are done.
True.
Quoted 1 line
The latter is a pretty common pattern through the kernel.
However the pattern in the NFS server and lockd is to define a lower-case version of the same macro that is pre-byte-swapped. I'm attempting to follow existing precedent in this area.
We already have, for example, in various sunrpc headers:
enum rpc_accept_stat {
RPC_SUCCESS = 0,
RPC_PROG_UNAVAIL = 1,
RPC_PROG_MISMATCH = 2,
...
};
#define rpc_success cpu_to_be32(RPC_SUCCESS) #define rpc_prog_unavail cpu_to_be32(RPC_PROG_UNAVAIL) #define rpc_prog_mismatch cpu_to_be32(RPC_PROG_MISMATCH)
Or, for NFS:
enum nfs_stat {
...
NFSERR_SHARE_DENIED = 10015,
...
};
#define nfserr_share_denied cpu_to_be32(NFSERR_SHARE_DENIED)
There are some missing lower-case macros, which I am trying to add to our existing collection before I rewrite the RPC header encoding and decoding functions. So I'm adding:
+ rpc_gss_version = cpu_to_be32(RPC_GSS_VERSION),
+ rpc_call = cpu_to_be32(RPC_CALL), + rpc_reply = cpu_to_be32(RPC_REPLY), + + rpc_msg_accepted = cpu_to_be32(RPC_MSG_ACCEPTED), + rpc_msg_denied = cpu_to_be32(RPC_MSG_DENIED),
Actually since we have decided not to use enum for these, this smaller addition can simply be squashed into the later patches, and I can drop this patch, which was intended as a clean-up but now appears to be unnecessary.
--
Chuck Lever
Re: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Quoted 20 lines · Chuck Lever
Quoted 20 lines · Christoph Hellwig
Quoted 8 lines · Chuck Lever
They are. The problem is that we are byte-swapping the incoming wire data and then comparing to CPU-endian constants in some hot paths. It's better to leave the incoming data alone and compare to a pre- byte-swapped constant. This patch adds some of these constants that were missing, in preparation for fixing the hot paths.
That is apparently not clear from the patch description, so I will endeavor to improve it.
Why do we need new enums / #defines for that?
Just replace:
if (beXX_to_cpu(pkt->field) == SOME_CONSTANT)
Quoted 7 lines
Quoted 5 lines
with
if (pkt->field == cpu_to_be32(SOME_CONSTANT))and we are done.
True.
I'm a little surprised the compiler couldn't do that automatically. (Disclaimer: I know nothing about compilers.)
Quoted 5 lines
Quoted 1 line
The latter is a pretty common pattern through the kernel.
However the pattern in the NFS server and lockd is to define a lower-case version of the same macro that is pre-byte-swapped. I'm attempting to follow existing precedent in this area.
I've never really understood why that was done. (Not saying it was wrong, just that I don't understand it.) As long as you're reading the value, how could byte-swapping it actually add a significant expense?
The one thing I do like is that I can look at e.g.:
int nfsd4_get_nfs4_acl ... __be32 nfsd4_set_nfs4_acl ...
and tell that the former returns a linux errno, the latter an NFS error.
--b.
Quoted 45 lines
We already have, for example, in various sunrpc headers:
enum
rpc_accept_stat{
RPC_SUCCESS= 0,
RPC_PROG_UNAVAIL= 1,
RPC_PROG_MISMATCH= 2,
...
};#define rpc_success cpu_to_be32(RPC_SUCCESS) #define rpc_prog_unavail cpu_to_be32(RPC_PROG_UNAVAIL) #define rpc_prog_mismatch cpu_to_be32(RPC_PROG_MISMATCH)Or, for NFS:
enum nfs_stat { ... NFSERR_SHARE_DENIED = 10015, ... };#define
nfserr_share_deniedcpu_to_be32(NFSERR_SHARE_DENIED)There are some missing lower-case macros, which I am trying to add to our existing collection before I rewrite the RPC header encoding and decoding functions. So I'm adding:
(quoted diff) +6
-0+ rpc_gss_version = cpu_to_be32(RPC_GSS_VERSION), + rpc_call = cpu_to_be32(RPC_CALL), + rpc_reply = cpu_to_be32(RPC_REPLY), + + rpc_msg_accepted = cpu_to_be32(RPC_MSG_ACCEPTED), + rpc_msg_denied = cpu_to_be32(RPC_MSG_DENIED),Actually since we have decided not to use enum for these, this smaller addition can simply be squashed into the later patches, and I can drop this patch, which was intended as a clean-up but now appears to be unnecessary.
--
Chuck Lever
Tom Talpey
reviewerRe: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Quoted 34 lines · J. Bruce Fields
Quoted 20 lines · Chuck Lever
Quoted 20 lines · Christoph Hellwig
Quoted 8 lines · Chuck Lever
They are. The problem is that we are byte-swapping the incoming wire data and then comparing to CPU-endian constants in some hot paths. It's better to leave the incoming data alone and compare to a pre- byte-swapped constant. This patch adds some of these constants that were missing, in preparation for fixing the hot paths.
That is apparently not clear from the patch description, so I will endeavor to improve it.
Why do we need new enums / #defines for that?
Just replace:
if (beXX_to_cpu(pkt->field) == SOME_CONSTANT)Quoted 7 lines
Quoted 5 lines
with
if (pkt->field == cpu_to_be32(SOME_CONSTANT))and we are done.
True.
I'm a little surprised the compiler couldn't do that automatically. (Disclaimer: I know nothing about compilers.)
Quoted 2 lines
Quoted 1 line
The latter is a pretty common pattern through the kernel.
Quoted 7 lines
Quoted 3 lines
However the pattern in the NFS server and lockd is to define a lower-case version of the same macro that is pre-byte-swapped. I'm attempting to follow existing precedent in this area.
I've never really understood why that was done. (Not saying it was wrong, just that I don't understand it.) As long as you're reading the value, how could byte-swapping it actually add a significant expense?
Shifts and Rotates are expensive on many processors, and hard to pipeline for byteawap because each step needs to wait for the result of the previous.
Maybe this is less of an issue with modern processors, but I'd certainly not be surprised that embedded processors "did it the hard way".
Tom.
Quoted 57 lines
The one thing I do like is that I can look at e.g.:
int nfsd4_get_nfs4_acl ... __be32 nfsd4_set_nfs4_acl ...and tell that the former returns a linux errno, the latter an NFS error.
--b.
Quoted 45 lines
We already have, for example, in various sunrpc headers:
enum
rpc_accept_stat{
RPC_SUCCESS= 0,
RPC_PROG_UNAVAIL= 1,
RPC_PROG_MISMATCH= 2,
...
};#define rpc_success cpu_to_be32(RPC_SUCCESS) #define rpc_prog_unavail cpu_to_be32(RPC_PROG_UNAVAIL) #define rpc_prog_mismatch cpu_to_be32(RPC_PROG_MISMATCH)Or, for NFS:
enum nfs_stat { ... NFSERR_SHARE_DENIED = 10015, ... };#define
nfserr_share_deniedcpu_to_be32(NFSERR_SHARE_DENIED)There are some missing lower-case macros, which I am trying to add to our existing collection before I rewrite the RPC header encoding and decoding functions. So I'm adding:
(quoted diff) +6
-0+ rpc_gss_version = cpu_to_be32(RPC_GSS_VERSION), + rpc_call = cpu_to_be32(RPC_CALL), + rpc_reply = cpu_to_be32(RPC_REPLY), + + rpc_msg_accepted = cpu_to_be32(RPC_MSG_ACCEPTED), + rpc_msg_denied = cpu_to_be32(RPC_MSG_DENIED),Actually since we have decided not to use enum for these, this smaller addition can simply be squashed into the later patches, and I can drop this patch, which was intended as a clean-up but now appears to be unnecessary.
--
Chuck Lever
RFC PATCH 5/10 SUNRPC: Use struct xdr_stream when constructing RPC Call header
In reply to Chuck LeverModernize and harden the code path that constructs each RPC Call message.
--- include/linux/sunrpc/auth.h | 15 ++- include/trace/events/sunrpc.h | 29 ++++++ net/sunrpc/auth.c | 56 ++++++++---- net/sunrpc/auth_gss/auth_gss.c | 191 +++++++++++++++++++--------------------- net/sunrpc/auth_null.c | 23 +++-- net/sunrpc/auth_unix.c | 61 ++++++++----- net/sunrpc/clnt.c | 66 +++++++------- 7 files changed, 260 insertions(+), 181 deletions(-)
include/linux/sunrpc/auth.h +10 -5
@@ -131,11 +131,12 @@ struct rpc_credops {void (*crdestroy)(struct rpc_cred *);int (*crmatch)(struct auth_cred *,struct rpc_cred *,int ); -__be32 * (*crmarshal)(struct rpc_task *,__be32 *); +int (*crmarshal)(struct rpc_task *task, +struct xdr_stream *xdr);int (*crrefresh)(struct rpc_task *);__be32 * (*crvalidate)(struct rpc_task *,__be32 *); -int (*crwrap_req)(struct rpc_task *,kxdreproc_t , -void *,__be32 *,void *); +int (*crwrap_req)(struct rpc_task *task, +struct xdr_stream *xdr);int (*crunwrap_resp)(struct rpc_task *,kxdrdproc_t ,void *,__be32 *,void *);int (*crkey_timeout)(struct rpc_cred *);
@@ -165,9 +166,13 @@ int rpcauth_get_gssinfo(rpc_authflavor_t,void rpcauth_init_cred (struct rpc_cred *,const struct auth_cred *,struct rpc_auth *,const struct rpc_credops *);struct rpc_cred *rpcauth_lookupcred (struct rpc_auth *,int );void put_rpccred (struct rpc_cred *); -__be32 *rpcauth_marshcred (struct rpc_task *,__be32 *); +int rpcauth_marshcred (struct rpc_task *task, +struct xdr_stream *xdr);__be32 *rpcauth_checkverf (struct rpc_task *,__be32 *); -int rpcauth_wrap_req (struct rpc_task *task,kxdreproc_t encode,void *rqstp,__be32 *data,void *obj); +int rpcauth_wrap_req_encode (struct rpc_task *task, +struct xdr_stream *xdr); +int rpcauth_wrap_req (struct rpc_task *task, +struct xdr_stream *xdr);int rpcauth_unwrap_resp (struct rpc_task *task,kxdrdproc_t decode,void *rqstp,__be32 *data,void *obj);bool rpcauth_xmit_need_reencode (struct rpc_task *task);int rpcauth_refreshcred (struct rpc_task *);
include/trace/events/sunrpc.h +29 -0
@@ -213,6 +213,35 @@DEFINE_RPC_QUEUED_EVENT (sleep);DEFINE_RPC_QUEUED_EVENT (wakeup); +DECLARE_EVENT_CLASS (rpc_failure, + + TP_PROTO(const struct rpc_task *task), + +TP_ARGS (task), + +TP_STRUCT__entry ( + __field(unsigned int, task_id) + __field(unsigned int, client_id) + ), + +TP_fast_assign ( + __entry->task_id = task->tk_pid; + __entry->client_id = task->tk_client->cl_clid; + ), + +TP_printk ("task:%u@%u" , + __entry->task_id, __entry->client_id) +); + +#define DEFINE_RPC_FAILURE (name) \ + DEFINE_EVENT(rpc_failure, rpc_bad_##name, \ + TP_PROTO( \ + const struct rpc_task *task \ + ), \ + TP_ARGS(task)) + +DEFINE_RPC_FAILURE (callhdr); + TRACE_EVENT(rpc_stats_latency, TP_PROTO(
net/sunrpc/auth.c +38 -18
76 lines not on this page · raw message
net/sunrpc/auth_gss/auth_gss.c +93 -98
316 lines not on this page · raw message
net/sunrpc/auth_null.c +15 -8
@@ -59,15 +59,21 @@/* * Marshal credential. */ -static __be32 * -nul_marshal (struct rpc_task *task,__be32 *p) +static int +nul_marshal (struct rpc_task *task,struct xdr_stream *xdr) { - *p++ =htonl (RPC_AUTH_NULL ); - *p++ =0 ; - *p++ =htonl (RPC_AUTH_NULL ); - *p++ =0 ; - -return p; +__be32 *p; + + p =xdr_reserve_space (xdr,4 *sizeof (*p)); +if (!p) +return -EMSGSIZE ; +/* Credential */ + *p++ = rpc_auth_null; + *p++ = xdr_zero; +/* Verifier */ + *p++ = rpc_auth_null; + *p = xdr_zero; +return 0 ; }/*
@@ -125,6 +131,7 @@ struct rpc_auth null_auth = { .crdestroy = nul_destroy_cred, .crmatch = nul_match, .crmarshal = nul_marshal, + .crwrap_req = rpcauth_wrap_req_encode, .crrefresh = nul_refresh, .crvalidate = nul_validate, };
net/sunrpc/auth_unix.c +40 -21
83 lines not on this page · raw message
net/sunrpc/clnt.c +35 -31
107 lines not on this page · raw message
RFC PATCH 6/10 SUNRPC: Clean up rpc_verify_header()
In reply to Chuck Lever- Recover some instruction count because I'm about to introduce a few xdr_inline_decode call sites
- Replace dprintk() call sites with trace points
- Reduce the hot path so it fits in fewer cachelines
I've also renamed it rpc_decode_header() to match everything else in the RPC client.
--- include/trace/events/sunrpc.h | 52 ++++++++++ net/sunrpc/clnt.c | 223 ++++++++++++++++++----------------------- 2 files changed, 148 insertions(+), 127 deletions(-)
include/trace/events/sunrpc.h +52 -0
@@ -241,6 +241,58 @@ TP_ARGS(task))DEFINE_RPC_FAILURE (callhdr); +DEFINE_RPC_FAILURE (verifier); + +DECLARE_EVENT_CLASS (rpc_reply_event, + +TP_PROTO ( + const struct rpc_task *task + ), + +TP_ARGS (task), + +TP_STRUCT__entry ( + __field(unsigned int, task_id) + __field(unsigned int, client_id) + __field(u32, xid) + __string(progname, task->tk_client->cl_program->name) + __field(u32, version) + __string(procname, rpc_proc_name(task)) +__string (servername, task->tk_xprt->servername) + ), + +TP_fast_assign ( + __entry->task_id = task->tk_pid; + __entry->client_id = task->tk_client->cl_clid; + __entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid); + __assign_str(progname, task->tk_client->cl_program->name) + __entry->version = task->tk_client->cl_vers; + __assign_str(procname, rpc_proc_name(task)) +__assign_str (servername, task->tk_xprt->servername) + ), + +TP_printk ("task:%u@%d server=%s xid=0x%08x %sv%d %s" , + __entry->task_id, __entry->client_id,__get_str (servername), + __entry->xid,__get_str (progname), __entry->version, +__get_str (procname)) +) + +#define DEFINE_RPC_REPLY_EVENT (name) \ + DEFINE_EVENT(rpc_reply_event, rpc_##name, \ + TP_PROTO( \ + const struct rpc_task *task \ + ), \ + TP_ARGS(task)) + +DEFINE_RPC_REPLY_EVENT (prog_unavail); +DEFINE_RPC_REPLY_EVENT (prog_mismatch); +DEFINE_RPC_REPLY_EVENT (proc_unavail); +DEFINE_RPC_REPLY_EVENT (garbage_args); +DEFINE_RPC_REPLY_EVENT (unparsable); +DEFINE_RPC_REPLY_EVENT (mismatch); +DEFINE_RPC_REPLY_EVENT (stale_creds); +DEFINE_RPC_REPLY_EVENT (bad_creds); +DEFINE_RPC_REPLY_EVENT (auth_tooweak); TRACE_EVENT(rpc_stats_latency,
net/sunrpc/clnt.c +96 -127
281 lines not on this page · raw message
RFC PATCH 7/10 SUNRPC: Use struct xdr_stream when decoding RPC Reply header
In reply to Chuck LeverModernize and harden the code path that parses an RPC Reply message.
--- include/linux/sunrpc/auth.h | 15 ++- net/sunrpc/auth.c | 63 ++++++++---- net/sunrpc/auth_gss/auth_gss.c | 204 ++++++++++++++++++++++------------------ net/sunrpc/auth_null.c | 31 +++--- net/sunrpc/auth_unix.c | 42 +++++--- net/sunrpc/clnt.c | 88 +++++++++-------- 6 files changed, 242 insertions(+), 201 deletions(-)
include/linux/sunrpc/auth.h +10 -5
@@ -134,11 +134,12 @@ struct rpc_credops {int (*crmarshal)(struct rpc_task *task,struct xdr_stream *xdr);int (*crrefresh)(struct rpc_task *); -__be32 * (*crvalidate)(struct rpc_task *,__be32 *); +int (*crvalidate)(struct rpc_task *task, +struct xdr_stream *xdr);int (*crwrap_req)(struct rpc_task *task,struct xdr_stream *xdr); -int (*crunwrap_resp)(struct rpc_task *,kxdrdproc_t , -void *,__be32 *,void *); +int (*crunwrap_resp)(struct rpc_task *task, +struct xdr_stream *xdr);int (*crkey_timeout)(struct rpc_cred *);char * (*crstringify_acceptor)(struct rpc_cred *);bool (*crneed_reencode)(struct rpc_task *);
@@ -168,12 +169,16 @@ int rpcauth_get_gssinfo(rpc_authflavor_t,void put_rpccred (struct rpc_cred *);int rpcauth_marshcred (struct rpc_task *task,struct xdr_stream *xdr); -__be32 *rpcauth_checkverf (struct rpc_task *,__be32 *); +int rpcauth_checkverf (struct rpc_task *task, +struct xdr_stream *xdr);int rpcauth_wrap_req_encode (struct rpc_task *task,struct xdr_stream *xdr);int rpcauth_wrap_req (struct rpc_task *task,struct xdr_stream *xdr); -int rpcauth_unwrap_resp (struct rpc_task *task,kxdrdproc_t decode,void *rqstp,__be32 *data,void *obj); +int rpcauth_unwrap_resp_decode (struct rpc_task *task, +struct xdr_stream *xdr); +int rpcauth_unwrap_resp (struct rpc_task *task, +struct xdr_stream *xdr);bool rpcauth_xmit_need_reencode (struct rpc_task *task);int rpcauth_refreshcred (struct rpc_task *);void rpcauth_invalcred (struct rpc_task *);
net/sunrpc/auth.c +41 -22
88 lines not on this page · raw message
net/sunrpc/auth_gss/auth_gss.c +110 -94
287 lines not on this page · raw message
net/sunrpc/auth_null.c +13 -18
@@ -86,25 +86,19 @@return 0 ; } -static __be32 * -nul_validate (struct rpc_task *task,__be32 *p) +static int +nul_validate (struct rpc_task *task,struct xdr_stream *xdr) { -rpc_authflavor_t flavor; -u32 size; - - flavor =ntohl (*p++); -if (flavor !=RPC_AUTH_NULL ) { -printk ("RPC: bad verf flavor: %u\n" , flavor); -return ERR_PTR (-EIO ); - } - - size =ntohl (*p++); -if (size !=0 ) { -printk ("RPC: bad verf size: %u\n" , size); -return ERR_PTR (-EIO ); - } - -return p; +__be32 *p; + + p =xdr_inline_decode (xdr,2 *sizeof (*p)); +if (!p) +return -EIO ; +if (*p++ != rpc_auth_null) +return -EIO ; +if (*p != xdr_zero) +return -EIO ; +return 0 ; }const struct rpc_authops authnull_ops = {
@@ -134,6 +128,7 @@ struct rpc_auth null_auth = { .crwrap_req = rpcauth_wrap_req_encode, .crrefresh = nul_refresh, .crvalidate = nul_validate, + .crunwrap_resp = rpcauth_unwrap_resp_decode, }; static
net/sunrpc/auth_unix.c +23 -19
56 lines not on this page · raw message
net/sunrpc/clnt.c +45 -43
173 lines not on this page · raw message
RFC PATCH 8/10 SUNRPC: Introduce trace points in rpc_auth_gss.ko
In reply to Chuck LeverAdd infrastructure for trace points in the RPC_AUTH_GSS kernel module, and add a few sample trace points. These report exceptional or unexpected events, and observe the assignment of GSS sequence numbers.
--- include/trace/events/rpcgss.h | 361 ++++++++++++++++++++++++++++++++++++++++ include/trace/events/rpcrdma.h | 12 + include/trace/events/sunrpc.h | 61 +++++++ net/sunrpc/auth_gss/Makefile | 2 net/sunrpc/auth_gss/auth_gss.c | 165 +++++++++--------- net/sunrpc/auth_gss/trace.c | 11 + net/sunrpc/xprt.c | 10 + 7 files changed, 530 insertions(+), 92 deletions(-) create mode 100644 include/trace/events/rpcgss.h create mode 100644 net/sunrpc/auth_gss/trace.c
include/trace/events/rpcgss.h new file +361 -0
@@ -0,0 +1,361 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2018 Oracle. All rights reserved. +* +* Trace point definitions for the "rpcgss" subsystem. +*/ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM rpcgss + +#if !defined(_TRACE_RPCRDMA_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _TRACE_RPCGSS_H + +#include <linux/tracepoint.h> + +/** +** GSS-API related trace events +**/ + +TRACE_DEFINE_ENUM (GSS_S_BAD_MECH ); +TRACE_DEFINE_ENUM (GSS_S_BAD_NAME ); +TRACE_DEFINE_ENUM (GSS_S_BAD_NAMETYPE ); +TRACE_DEFINE_ENUM (GSS_S_BAD_BINDINGS ); +TRACE_DEFINE_ENUM (GSS_S_BAD_STATUS ); +TRACE_DEFINE_ENUM (GSS_S_BAD_SIG ); +TRACE_DEFINE_ENUM (GSS_S_NO_CRED ); +TRACE_DEFINE_ENUM (GSS_S_NO_CONTEXT ); +TRACE_DEFINE_ENUM (GSS_S_DEFECTIVE_TOKEN ); +TRACE_DEFINE_ENUM (GSS_S_DEFECTIVE_CREDENTIAL ); +TRACE_DEFINE_ENUM (GSS_S_CREDENTIALS_EXPIRED ); +TRACE_DEFINE_ENUM (GSS_S_CONTEXT_EXPIRED ); +TRACE_DEFINE_ENUM (GSS_S_FAILURE ); +TRACE_DEFINE_ENUM (GSS_S_BAD_QOP ); +TRACE_DEFINE_ENUM (GSS_S_UNAUTHORIZED ); +TRACE_DEFINE_ENUM (GSS_S_UNAVAILABLE ); +TRACE_DEFINE_ENUM (GSS_S_DUPLICATE_ELEMENT ); +TRACE_DEFINE_ENUM (GSS_S_NAME_NOT_MN ); +TRACE_DEFINE_ENUM (GSS_S_CONTINUE_NEEDED ); +TRACE_DEFINE_ENUM (GSS_S_DUPLICATE_TOKEN ); +TRACE_DEFINE_ENUM (GSS_S_OLD_TOKEN ); +TRACE_DEFINE_ENUM (GSS_S_UNSEQ_TOKEN ); +TRACE_DEFINE_ENUM (GSS_S_GAP_TOKEN ); + +#define show_gss_status (x) \ + __print_flags(x, "|", \ + { GSS_S_BAD_MECH, "GSS_S_BAD_MECH" }, \ + { GSS_S_BAD_NAME, "GSS_S_BAD_NAME" }, \ + { GSS_S_BAD_NAMETYPE, "GSS_S_BAD_NAMETYPE" }, \ + { GSS_S_BAD_BINDINGS, "GSS_S_BAD_BINDINGS" }, \ + { GSS_S_BAD_STATUS, "GSS_S_BAD_STATUS" }, \ + { GSS_S_BAD_SIG, "GSS_S_BAD_SIG" }, \ + { GSS_S_NO_CRED, "GSS_S_NO_CRED" }, \ + { GSS_S_NO_CONTEXT, "GSS_S_NO_CONTEXT" }, \ + { GSS_S_DEFECTIVE_TOKEN, "GSS_S_DEFECTIVE_TOKEN" }, \ + { GSS_S_DEFECTIVE_CREDENTIAL, "GSS_S_DEFECTIVE_CREDENTIAL" }, \ + { GSS_S_CREDENTIALS_EXPIRED, "GSS_S_CREDENTIALS_EXPIRED" }, \ + { GSS_S_CONTEXT_EXPIRED, "GSS_S_CONTEXT_EXPIRED" }, \ + { GSS_S_FAILURE, "GSS_S_FAILURE" }, \ + { GSS_S_BAD_QOP, "GSS_S_BAD_QOP" }, \ + { GSS_S_UNAUTHORIZED, "GSS_S_UNAUTHORIZED" }, \ + { GSS_S_UNAVAILABLE, "GSS_S_UNAVAILABLE" }, \ + { GSS_S_DUPLICATE_ELEMENT, "GSS_S_DUPLICATE_ELEMENT" }, \ + { GSS_S_NAME_NOT_MN, "GSS_S_NAME_NOT_MN" }, \ + { GSS_S_CONTINUE_NEEDED, "GSS_S_CONTINUE_NEEDED" }, \ + { GSS_S_DUPLICATE_TOKEN, "GSS_S_DUPLICATE_TOKEN" }, \ + { GSS_S_OLD_TOKEN, "GSS_S_OLD_TOKEN" }, \ + { GSS_S_UNSEQ_TOKEN, "GSS_S_UNSEQ_TOKEN" }, \ + { GSS_S_GAP_TOKEN, "GSS_S_GAP_TOKEN" }) + + +DECLARE_EVENT_CLASS (rpcgss_gssapi_event, +TP_PROTO ( + const struct rpc_task *task, + u32 maj_stat + ), + +TP_ARGS (task, maj_stat), + +TP_STRUCT__entry ( + __field(unsigned int, task_id) + __field(unsigned int, client_id) +__field (u32, maj_stat) + + ), + +TP_fast_assign ( + __entry->task_id = task->tk_pid; + __entry->client_id = task->tk_client->cl_clid; + __entry->maj_stat = maj_stat; + ), + +TP_printk ("task:%u@%u maj_stat=%s" , + __entry->task_id, __entry->client_id, + __entry->maj_stat ==0 ? +"GSS_S_COMPLETE" :show_gss_status (__entry->maj_stat)) +); + +#define DEFINE_GSSAPI_EVENT (name) \ + DEFINE_EVENT(rpcgss_gssapi_event, rpcgss_##name, \ + TP_PROTO( \ + const struct rpc_task *task, \ + u32 maj_stat \ + ), \ + TP_ARGS(task, maj_stat)) + +TRACE_EVENT (rpcgss_import_ctx, +TP_PROTO ( + int status + ), + +TP_ARGS (status), + +TP_STRUCT__entry ( +__field (int, status) + ), + +TP_fast_assign ( + __entry->status = status; + ), + +TP_printk ("status=%d" , __entry->status) +); + +DEFINE_GSSAPI_EVENT (get_mic); +DEFINE_GSSAPI_EVENT (verify_mic); +DEFINE_GSSAPI_EVENT (wrap); +DEFINE_GSSAPI_EVENT (unwrap); + + +/** +** GSS auth unwrap failures +**/ + +TRACE_EVENT (rpcgss_unwrap_failed, +TP_PROTO ( + const struct rpc_task *task + ), + +TP_ARGS (task), + +TP_STRUCT__entry ( + __field(unsigned int, task_id) + __field(unsigned int, client_id) + ), + +TP_fast_assign ( + __entry->task_id = task->tk_pid; + __entry->client_id = task->tk_client->cl_clid; + ), + +TP_printk ("task:%u@%u" , __entry->task_id, __entry->client_id) +); + +TRACE_EVENT (rpcgss_bad_seqno, +TP_PROTO ( + const struct rpc_task *task, + u32 expected, + u32 received + ), + +TP_ARGS (task, expected, received), + +TP_STRUCT__entry ( + __field(unsigned int, task_id) + __field(unsigned int, client_id) + __field(u32, expected) +__field (u32, received) + ), + +TP_fast_assign ( + __entry->task_id = task->tk_pid; + __entry->client_id = task->tk_client->cl_clid; + __entry->expected = expected; + __entry->received = received; + ), + +TP_printk ("task:%u@%u expected seqno %u, received seqno %u" , + __entry->task_id, __entry->client_id, + __entry->expected, __entry->received) +); + +TRACE_EVENT (rpcgss_seqno, +TP_PROTO ( + const struct rpc_task *task + ), + +TP_ARGS (task), + +TP_STRUCT__entry ( + __field(unsigned int, task_id) + __field(unsigned int, client_id) + __field(u32, xid) +__field (u32, seqno) + ), + +TP_fast_assign ( + const struct rpc_rqst *rqst = task->tk_rqstp; + + __entry->task_id = task->tk_pid; + __entry->client_id = task->tk_client->cl_clid; + __entry->xid = be32_to_cpu(rqst->rq_xid); + __entry->seqno = rqst->rq_seqno; + ), + +TP_printk ("task:%u@%u xid=0x%08x seqno=%u" , + __entry->task_id, __entry->client_id, + __entry->xid, __entry->seqno) +); + +TRACE_EVENT (rpcgss_need_reencode, +TP_PROTO ( + const struct rpc_task *task, + u32 seq_xmit, + bool ret + ), + +TP_ARGS (task, seq_xmit, ret), + +TP_STRUCT__entry ( + __field(unsigned int, task_id) + __field(unsigned int, client_id) + __field(u32, xid) + __field(u32, seq_xmit) + __field(u32, seqno) +__field (bool, ret) + ), + +TP_fast_assign ( + __entry->task_id = task->tk_pid; + __entry->client_id = task->tk_client->cl_clid; + __entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid); + __entry->seq_xmit = seq_xmit; + __entry->seqno = task->tk_rqstp->rq_seqno; + __entry->ret = ret; + ), + +TP_printk ("task:%u@%u xid=0x%08x rq_seqno=%u seq_xmit=%u reencode %sneeded" , + __entry->task_id, __entry->client_id, + __entry->xid, __entry->seqno, __entry->seq_xmit, + __entry->ret ?"" :"un" ) +); + +/** +** gssd upcall related trace events +**/ + +TRACE_EVENT (rpcgss_upcall_msg, +TP_PROTO ( + const char *buf + ), + +TP_ARGS (buf), + +TP_STRUCT__entry ( +__string (msg, buf) + ), + +TP_fast_assign ( +__assign_str (msg, buf) + ), + +TP_printk ("msg='%s'" ,__get_str (msg)) +); + +TRACE_EVENT (rpcgss_upcall_result, +TP_PROTO ( + u32 uid, + int result + ), + +TP_ARGS (uid, result), + +TP_STRUCT__entry ( + __field(u32, uid) +__field (int, result) + + ), + +TP_fast_assign ( + __entry->uid = uid; + __entry->result = result; + ), + +TP_printk ("for uid %u, result=%d" , __entry->uid, __entry->result) +); + +TRACE_EVENT (rpcgss_context, +TP_PROTO ( + unsigned long expiry, + unsigned long now, + unsigned int timeout, + unsigned int len, + const u8 *data + ), + +TP_ARGS (expiry, now, timeout, len, data), + +TP_STRUCT__entry ( + __field(unsigned long, expiry) + __field(unsigned long, now) + __field(unsigned int, timeout) + __field(int, len) +__string (acceptor, data) + ), + +TP_fast_assign ( + __entry->expiry = expiry; + __entry->now = now; + __entry->timeout = timeout; + __entry->len = len; + strncpy(__get_str(acceptor), data, len); + ), + +TP_printk ("gc_expiry=%lu now=%lu timeout=%u acceptor=%.*s" , + __entry->expiry, __entry->now, __entry->timeout, + __entry->len,__get_str (acceptor)) +); + + +/** +** Miscellaneous events +*/ + +TRACE_DEFINE_ENUM (RPC_AUTH_GSS_KRB5 ); +TRACE_DEFINE_ENUM (RPC_AUTH_GSS_KRB5I ); +TRACE_DEFINE_ENUM (RPC_AUTH_GSS_KRB5P ); + +#define show_pseudoflavor (x) \ + __print_symbolic(x, \ + { RPC_AUTH_GSS_KRB5, "RPC_AUTH_GSS_KRB5" }, \ + { RPC_AUTH_GSS_KRB5I, "RPC_AUTH_GSS_KRB5I" }, \ + { RPC_AUTH_GSS_KRB5P, "RPC_AUTH_GSS_KRB5P" }) + + +TRACE_EVENT (rpcgss_createauth, +TP_PROTO ( + unsigned int flavor, + int error + ), + +TP_ARGS (flavor, error), + +TP_STRUCT__entry ( + __field(unsigned int, flavor) +__field (int, error) + + ), + +TP_fast_assign ( + __entry->flavor = flavor; + __entry->error = error; + ), + +TP_printk ("flavor=%s error=%d" , +show_pseudoflavor (__entry->flavor), __entry->error) +); + + +#endif /* _TRACE_RPCGSS_H */ + +#include <trace/define_trace.h>
include/trace/events/rpcrdma.h +10 -2
@@ -521,12 +521,18 @@TP_STRUCT__entry (__field (const void *,req ) + __field(unsigned int, task_id) + __field(unsigned int, client_id)__field (int, num_sge)__field (int, signaled)__field (int, status) ),TP_fast_assign ( + const struct rpc_rqst *rqst = &req->rl_slot; + + __entry->task_id = rqst->rq_task->tk_pid; + __entry->client_id = rqst->rq_task->tk_client->cl_clid; __entry->req = req; __entry->num_sge = req->rl_sendctx->sc_wr.num_sge; __entry->signaled = req->rl_sendctx->sc_wr.send_flags &
@@ -534,9 +540,11 @@ __entry->status = status; ), -TP_printk ("req=%p, %d SGEs%s, status=%d" , +TP_printk ("task:%u@%u req=%p (%d SGE%s) %sstatus=%d" , + __entry->task_id, __entry->client_id, __entry->req, __entry->num_sge, - (__entry->signaled ?", signaled" :"" ), + (__entry->num_sge ==1 ?"" :"s" ), + (__entry->signaled ?"signaled " :"" ), __entry->status ) );
include/trace/events/sunrpc.h +60 -1
69 lines not on this page · raw message
net/sunrpc/auth_gss/Makefile +1 -1
@@ -7,7 +7,7 @@ obj-$(CONFIG_SUNRPC_GSS) += auth_rpcgss.o auth_rpcgss-y := auth_gss.o gss_generic_token.o \ gss_mech_switch.o svcauth_gss.o \ - gss_rpc_upcall.o gss_rpc_xdr.o + gss_rpc_upcall.o gss_rpc_xdr.o trace.o obj-$(CONFIG_RPCSEC_GSS_KRB5) += rpcsec_gss_krb5.o
net/sunrpc/auth_gss/auth_gss.c +81 -84
483 lines not on this page · raw message
net/sunrpc/auth_gss/trace.c new file +11 -0
@@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018, 2019 Oracle. All rights reserved. +*/ + +#include <linux/sunrpc/clnt.h> +#include <linux/sunrpc/sched.h> +#include <linux/sunrpc/gss_err.h> + +#define CREATE_TRACE_POINTS +#include <trace/events/rpcgss.h>
net/sunrpc/xprt.c +6 -4
@@ -1165,6 +1165,7 @@ void xprt_request_wait_receive(struct rpc_task *task)/* Note: req is added _before_ pos */ list_add_tail (&req->rq_xmit, &pos->rq_xmit);INIT_LIST_HEAD (&req->rq_xmit2); +trace_xprt_enq_xmit (task,1 ); goto out; } }else if (RPC_IS_SWAPPER (task)) {
@@ -1176,6 +1177,7 @@ void xprt_request_wait_receive(struct rpc_task *task)/* Note: req is added _before_ pos */ list_add_tail (&req->rq_xmit, &pos->rq_xmit);INIT_LIST_HEAD (&req->rq_xmit2); +trace_xprt_enq_xmit (task,2 ); goto out; } }else if (!req->rq_seqno) {
@@ -1184,11 +1186,13 @@ void xprt_request_wait_receive(struct rpc_task *task)continue ;list_add_tail (&req->rq_xmit2, &pos->rq_xmit2);INIT_LIST_HEAD (&req->rq_xmit); +trace_xprt_enq_xmit (task,3 ); goto out; } }list_add_tail (&req->rq_xmit, &xprt->xmit_queue);INIT_LIST_HEAD (&req->rq_xmit2); +trace_xprt_enq_xmit (task,4 ); out:set_bit (RPC_TASK_NEED_XMIT , &task->tk_runstate);spin_unlock (&xprt->queue_lock);
@@ -1313,8 +1317,6 @@ void xprt_end_transmit(struct rpc_task *task)int is_retrans =RPC_WAS_SENT (task);int status; -dprintk ("RPC: %5u xprt_transmit(%u)\n" , task->tk_pid, req->rq_slen); -if (!req->rq_bytes_sent) {if (xprt_request_data_received (task)) { status =0 ;
@@ -1336,9 +1338,9 @@ void xprt_end_transmit(struct rpc_task *task) connect_cookie = xprt->connect_cookie; status = xprt->ops->send_request (req); -trace_xprt_transmit (xprt, req->rq_xid, status);if (status !=0 ) { req->rq_ntrans--; +trace_xprt_transmit (req, status);return status; }
@@ -1347,7 +1349,6 @@ void xprt_end_transmit(struct rpc_task *task)xprt_inject_disconnect (xprt); -dprintk ("RPC: %5u xmit complete\n" , task->tk_pid); task->tk_flags |=RPC_TASK_SENT ;spin_lock_bh (&xprt->transport_lock);
@@ -1360,6 +1361,7 @@ void xprt_end_transmit(struct rpc_task *task) req->rq_connect_cookie = connect_cookie; out_dequeue: +trace_xprt_transmit (req, status);xprt_request_dequeue_transmit (task);rpc_wake_up_queued_task_set_status (&xprt->sending, task, status);return status;
RFC PATCH 9/10 SUNRPC: Remove xdr_buf_trim()
In reply to Chuck LeverThe key action of xdr_buf_trim() is that it shortens buf->len, the length of the xdr_buf' content. The other actions -- shortening the head, pages, and tail components -- are actually not necessary. In some cases, changing the size of those components corrupts the RPC message contained in the buffer.
--- include/linux/sunrpc/xdr.h | 1 - net/sunrpc/auth_gss/gss_krb5_wrap.c | 8 ++++--- net/sunrpc/auth_gss/svcauth_gss.c | 2 +- net/sunrpc/xdr.c | 41 ----------------------------------- 4 files changed, 6 insertions(+), 46 deletions(-)
include/linux/sunrpc/xdr.h +0 -1
@@ -183,7 +183,6 @@ static inline __be32 *xdr_encode_array(__be32 *p, const void *s, unsigned int leextern void xdr_shift_buf (struct xdr_buf *,size_t );extern void xdr_buf_from_iov (struct kvec *,struct xdr_buf *);extern int xdr_buf_subsegment (struct xdr_buf *,struct xdr_buf *,unsigned int ,unsigned int ); -extern void xdr_buf_trim (struct xdr_buf *,unsigned int );extern int xdr_buf_read_netobj (struct xdr_buf *,struct xdr_netobj *,unsigned int );extern int read_bytes_from_xdr_buf (struct xdr_buf *,unsigned int ,void *,unsigned int );extern int write_bytes_to_xdr_buf (struct xdr_buf *,unsigned int ,void *,unsigned int );
net/sunrpc/auth_gss/gss_krb5_wrap.c +5 -3
@@ -570,14 +570,16 @@ static void rotate_left(u32 base, struct xdr_buf *buf, unsigned int shift)*/ movelen = min_t(unsigned int, buf->head[0].iov_len, buf->len); movelen -= offset +GSS_KRB5_TOK_HDR_LEN + headskip; -BUG_ON (offset +GSS_KRB5_TOK_HDR_LEN + headskip + movelen > - buf->head[0 ].iov_len); +if (offset +GSS_KRB5_TOK_HDR_LEN + headskip + movelen > + buf->head[0 ].iov_len) +return GSS_S_FAILURE ;memmove (ptr, ptr +GSS_KRB5_TOK_HDR_LEN + headskip, movelen); buf->head[0 ].iov_len -=GSS_KRB5_TOK_HDR_LEN + headskip; buf->len -=GSS_KRB5_TOK_HDR_LEN + headskip;/* Trim off the trailing "extra count" and checksum blob */ -xdr_buf_trim (buf, ec +GSS_KRB5_TOK_HDR_LEN + tailskip); + buf->len -= ec +GSS_KRB5_TOK_HDR_LEN + tailskip; +return GSS_S_COMPLETE ; }
net/sunrpc/auth_gss/svcauth_gss.c +1 -1
@@ -896,7 +896,7 @@ u32 svcauth_gss_flavor(struct auth_domain *dom)if (svc_getnl (&buf->head[0 ]) != seq) goto out;/* trim off the mic and padding at the end before returning */ -xdr_buf_trim (buf,round_up_to_quad (mic.len) +4 ); + buf->len -=4 +round_up_to_quad (mic.len); stat =0 ; out:kfree (mic.data);
net/sunrpc/xdr.c +0 -41
47 lines not on this page · raw message
Re: [PATCH RFC 09/10] SUNRPC: Remove xdr_buf_trim()
Quoted 5 lines · Chuck Lever
The key action of
xdr_buf_trim()is that it shortensbuf->len, the length of thexdr_buf' content. The other actions -- shortening the head, pages, and tail components -- are actually not necessary. In some cases, changing the size of those components corrupts the RPC message contained in the buffer.
That's really burying the lede.... Is there an actual user-visible bug here?
--b.
Quoted 110 lines
Signed-off-by Chuck Lever <[email protected]>--- include/linux/sunrpc/xdr.h | 1 - net/sunrpc/auth_gss/gss_krb5_wrap.c | 8 ++++--- net/sunrpc/auth_gss/svcauth_gss.c | 2 +- net/sunrpc/xdr.c | 41 ----------------------------------- 4 files changed, 6 insertions(+), 46 deletions(-)include/linux/sunrpc/xdr.h +0
-1@@ -183,7 +183,6 @@ static inline __be32 *xdr_encode_array(__be32 *p, const void *s, unsigned int leextern void xdr_shift_buf (struct xdr_buf *,size_t );extern void xdr_buf_from_iov (struct kvec *,struct xdr_buf *);extern int xdr_buf_subsegment (struct xdr_buf *,struct xdr_buf *,unsigned int ,unsigned int ); -extern void xdr_buf_trim (struct xdr_buf *,unsigned int );extern int xdr_buf_read_netobj (struct xdr_buf *,struct xdr_netobj *,unsigned int );extern int read_bytes_from_xdr_buf (struct xdr_buf *,unsigned int ,void *,unsigned int );extern int write_bytes_to_xdr_buf (struct xdr_buf *,unsigned int ,void *,unsigned int );net/sunrpc/auth_gss/gss_krb5_wrap.c +5
-3@@ -570,14 +570,16 @@ static void rotate_left(u32 base, struct xdr_buf *buf, unsigned int shift)*/ movelen = min_t(unsigned int, buf->head[0].iov_len, buf->len); movelen -= offset +GSS_KRB5_TOK_HDR_LEN + headskip; -BUG_ON (offset +GSS_KRB5_TOK_HDR_LEN + headskip + movelen > - buf->head[0 ].iov_len); +if (offset +GSS_KRB5_TOK_HDR_LEN + headskip + movelen > + buf->head[0 ].iov_len) +return GSS_S_FAILURE ;memmove (ptr, ptr +GSS_KRB5_TOK_HDR_LEN + headskip, movelen); buf->head[0 ].iov_len -=GSS_KRB5_TOK_HDR_LEN + headskip; buf->len -=GSS_KRB5_TOK_HDR_LEN + headskip;/* Trim off the trailing "extra count" and checksum blob */ -xdr_buf_trim (buf, ec +GSS_KRB5_TOK_HDR_LEN + tailskip); + buf->len -= ec +GSS_KRB5_TOK_HDR_LEN + tailskip; +return GSS_S_COMPLETE ; }net/sunrpc/auth_gss/svcauth_gss.c +1
-1@@ -896,7 +896,7 @@ u32 svcauth_gss_flavor(struct auth_domain *dom)if (svc_getnl (&buf->head[0 ]) != seq) goto out;/* trim off the mic and padding at the end before returning */ -xdr_buf_trim (buf,round_up_to_quad (mic.len) +4 ); + buf->len -=4 +round_up_to_quad (mic.len); stat =0 ; out:kfree (mic.data);net/sunrpc/xdr.c +0
-41@@ -1139,47 +1139,6 @@ void xdr_enter_page(struct xdr_stream *xdr, unsigned int len) }EXPORT_SYMBOL_GPL (xdr_buf_subsegment); -/** -* xdr_buf_trim - lop at most "len" bytes off the end of "buf" -* @buf: buf to be trimmed -* @len: number of bytes to reduce "buf" by -* -* Trim an xdr_buf by the given number of bytes by fixing up the lengths. Note -* that it's possible that we'll trim less than that amount if the xdr_buf is -* too small, or if (for instance) it's all in the head and the parser has -* already read too far into it. -*/ -void xdr_buf_trim (struct xdr_buf *buf,unsigned int len) -{ -size_t cur; -unsigned int trim = len; - -if (buf->tail[0 ].iov_len) { - cur =min_t (size_t, buf->tail[0 ].iov_len, trim); - buf->tail[0 ].iov_len -= cur; - trim -= cur; -if (!trim) - goto fix_len; - } - -if (buf->page_len) { - cur = min_t(unsigned int, buf->page_len, trim); - buf->page_len -= cur; - trim -= cur; -if (!trim) - goto fix_len; - } - -if (buf->head[0 ].iov_len) { - cur =min_t (size_t, buf->head[0 ].iov_len, trim); - buf->head[0 ].iov_len -= cur; - trim -= cur; - } -fix_len: - buf->len -= (len - trim); -} -EXPORT_SYMBOL_GPL (xdr_buf_trim); -static void __read_bytes_from_xdr_buf (struct xdr_buf *subbuf,void *obj,unsigned int len) {unsigned int this_len;
Re: [PATCH RFC 09/10] SUNRPC: Remove xdr_buf_trim()
Quoted 13 lines · On Feb 4, 2019, at 2:46 PM, [email protected] wrote:
Quoted 5 lines · Chuck Lever
The key action of
xdr_buf_trim()is that it shortensbuf->len, the length of thexdr_buf' content. The other actions -- shortening the head, pages, and tail components -- are actually not necessary. In some cases, changing the size of those components corrupts the RPC message contained in the buffer.That's really burying the lede.... Is there an actual user-visible bug here?
I don't think so. This is more of the form:
a) the function does fundamentally the wrong thing, so
b) certain changes to this code path result is unexpected and incorrect behavior
Thus typically only developers hacking on this code run into a problem.
Quoted 104 lines
--b.
Quoted 102 lines
Signed-off-by Chuck Lever <[email protected]>---
include/linux/sunrpc/xdr.h | 1 - net/sunrpc/auth_gss/gss_krb5_wrap.c | 8 ++++--- net/sunrpc/auth_gss/svcauth_gss.c | 2 +- net/sunrpc/xdr.c | 41 ----------------------------------- 4 files changed, 6 insertions(+), 46 deletions(-)include/linux/sunrpc/xdr.h +0
-1@@ -183,7 +183,6 @@ static inline __be32 *xdr_encode_array(__be32 *p, const void *s, unsigned int leextern void xdr_shift_buf (struct xdr_buf *,size_t );extern void xdr_buf_from_iov (struct kvec *,struct xdr_buf *);extern int xdr_buf_subsegment (struct xdr_buf *,struct xdr_buf *,unsigned int ,unsigned int ); -extern void xdr_buf_trim (struct xdr_buf *,unsigned int );extern int xdr_buf_read_netobj (struct xdr_buf *,struct xdr_netobj *,unsigned int );extern int read_bytes_from_xdr_buf (struct xdr_buf *,unsigned int ,void *,unsigned int );extern int write_bytes_to_xdr_buf (struct xdr_buf *,unsigned int ,void *,unsigned int );net/sunrpc/auth_gss/gss_krb5_wrap.c +5
-3@@ -570,14 +570,16 @@ static void rotate_left(u32 base, struct xdr_buf *buf, unsigned int shift)*/ movelen = min_t(unsigned int, buf->head[0].iov_len, buf->len); movelen -= offset +GSS_KRB5_TOK_HDR_LEN + headskip; -BUG_ON (offset +GSS_KRB5_TOK_HDR_LEN + headskip + movelen > - buf->head[0 ].iov_len); +if (offset +GSS_KRB5_TOK_HDR_LEN + headskip + movelen > + buf->head[0 ].iov_len) +return GSS_S_FAILURE ;memmove (ptr, ptr +GSS_KRB5_TOK_HDR_LEN + headskip, movelen); buf->head[0 ].iov_len -=GSS_KRB5_TOK_HDR_LEN + headskip; buf->len -=GSS_KRB5_TOK_HDR_LEN + headskip;/* Trim off the trailing "extra count" and checksum blob */ -xdr_buf_trim (buf, ec +GSS_KRB5_TOK_HDR_LEN + tailskip); + buf->len -= ec +GSS_KRB5_TOK_HDR_LEN + tailskip; +return GSS_S_COMPLETE ; }net/sunrpc/auth_gss/svcauth_gss.c +1
-1@@ -896,7 +896,7 @@ u32 svcauth_gss_flavor(struct auth_domain *dom)if (svc_getnl (&buf->head[0 ]) != seq) goto out;/* trim off the mic and padding at the end before returning */ -xdr_buf_trim (buf,round_up_to_quad (mic.len) +4 ); + buf->len -=4 +round_up_to_quad (mic.len); stat =0 ;out:
kfree(mic.data);net/sunrpc/xdr.c +0
-36@@ -1139,47 +1139,6 @@ void xdr_enter_page(struct xdr_stream *xdr, unsigned int len) }EXPORT_SYMBOL_GPL (xdr_buf_subsegment); -/** -* xdr_buf_trim - lop at most "len" bytes off the end of "buf" -* @buf: buf to be trimmed -* @len: number of bytes to reduce "buf" by -* -* Trim an xdr_buf by the given number of bytes by fixing up the lengths. Note -* that it's possible that we'll trim less than that amount if the xdr_buf is -* too small, or if (for instance) it's all in the head and the parser has -* already read too far into it. -*/ -void xdr_buf_trim (struct xdr_buf *buf,unsigned int len) -{ -size_t cur; -unsigned int trim = len; - -if (buf->tail[0 ].iov_len) { - cur =min_t (size_t, buf->tail[0 ].iov_len, trim); - buf->tail[0 ].iov_len -= cur; - trim -= cur; -if (!trim) - goto fix_len; - } - -if (buf->page_len) { - cur = min_t(unsigned int, buf->page_len, trim); - buf->page_len -= cur; - trim -= cur; -if (!trim) - goto fix_len; - } - -if (buf->head[0 ].iov_len) { - cur =min_t (size_t, buf->head[0 ].iov_len, trim); - buf->head[0 ].iov_len -= cur; - trim -= cur; - }
Quoted 8 lines
net/sunrpc/xdr.c void xdr_enter_page(struct xdr_stream *xdr, unsigned int len) · line 1144
Quoted 8 lines
net/sunrpc/xdr.c +0
-5-fix_len: - buf->len -= (len - trim); -} -EXPORT_SYMBOL_GPL (xdr_buf_trim); -static void __read_bytes_from_xdr_buf (struct xdr_buf *subbuf,void *obj,unsigned int len) {unsigned int this_len;
--
Chuck Lever
Re: [PATCH RFC 09/10] SUNRPC: Remove xdr_buf_trim()
Quoted 14 lines · Chuck Lever
Quoted 13 lines · On Feb 4, 2019, at 2:46 PM, [email protected] wrote:
Quoted 5 lines · Chuck Lever
The key action of
xdr_buf_trim()is that it shortensbuf->len, the length of thexdr_buf' content. The other actions -- shortening the head, pages, and tail components -- are actually not necessary. In some cases, changing the size of those components corrupts the RPC message contained in the buffer.That's really burying the lede.... Is there an actual user-visible bug here?
Quoted 8 lines
I don't think so. This is more of the form:
a) the function does fundamentally the wrong thing, so
b) certain changes to this code path result is unexpected and incorrect behavior
Thus typically only developers hacking on this code run into a problem.
OK, got it. It'd help just to make it clear in the changelog that that this is an accident waiting to happen rather than a current bug (as far as we know).
--b.
Quoted 119 lines
Quoted 106 lines
--b.
Quoted 102 lines
Signed-off-by Chuck Lever <[email protected]>---
include/linux/sunrpc/xdr.h | 1 - net/sunrpc/auth_gss/gss_krb5_wrap.c | 8 ++++--- net/sunrpc/auth_gss/svcauth_gss.c | 2 +- net/sunrpc/xdr.c | 41 ----------------------------------- 4 files changed, 6 insertions(+), 46 deletions(-)include/linux/sunrpc/xdr.h +0
-1@@ -183,7 +183,6 @@ static inline __be32 *xdr_encode_array(__be32 *p, const void *s, unsigned int leextern void xdr_shift_buf (struct xdr_buf *,size_t );extern void xdr_buf_from_iov (struct kvec *,struct xdr_buf *);extern int xdr_buf_subsegment (struct xdr_buf *,struct xdr_buf *,unsigned int ,unsigned int ); -extern void xdr_buf_trim (struct xdr_buf *,unsigned int );extern int xdr_buf_read_netobj (struct xdr_buf *,struct xdr_netobj *,unsigned int );extern int read_bytes_from_xdr_buf (struct xdr_buf *,unsigned int ,void *,unsigned int );extern int write_bytes_to_xdr_buf (struct xdr_buf *,unsigned int ,void *,unsigned int );net/sunrpc/auth_gss/gss_krb5_wrap.c +5
-3@@ -570,14 +570,16 @@ static void rotate_left(u32 base, struct xdr_buf *buf, unsigned int shift)*/ movelen = min_t(unsigned int, buf->head[0].iov_len, buf->len); movelen -= offset +GSS_KRB5_TOK_HDR_LEN + headskip; -BUG_ON (offset +GSS_KRB5_TOK_HDR_LEN + headskip + movelen > - buf->head[0 ].iov_len); +if (offset +GSS_KRB5_TOK_HDR_LEN + headskip + movelen > + buf->head[0 ].iov_len) +return GSS_S_FAILURE ;memmove (ptr, ptr +GSS_KRB5_TOK_HDR_LEN + headskip, movelen); buf->head[0 ].iov_len -=GSS_KRB5_TOK_HDR_LEN + headskip; buf->len -=GSS_KRB5_TOK_HDR_LEN + headskip;/* Trim off the trailing "extra count" and checksum blob */ -xdr_buf_trim (buf, ec +GSS_KRB5_TOK_HDR_LEN + tailskip); + buf->len -= ec +GSS_KRB5_TOK_HDR_LEN + tailskip; +return GSS_S_COMPLETE ; }net/sunrpc/auth_gss/svcauth_gss.c +1
-1@@ -896,7 +896,7 @@ u32 svcauth_gss_flavor(struct auth_domain *dom)if (svc_getnl (&buf->head[0 ]) != seq) goto out;/* trim off the mic and padding at the end before returning */ -xdr_buf_trim (buf,round_up_to_quad (mic.len) +4 ); + buf->len -=4 +round_up_to_quad (mic.len); stat =0 ;out:
kfree(mic.data);net/sunrpc/xdr.c +0
-36@@ -1139,47 +1139,6 @@ void xdr_enter_page(struct xdr_stream *xdr, unsigned int len) }EXPORT_SYMBOL_GPL (xdr_buf_subsegment); -/** -* xdr_buf_trim - lop at most "len" bytes off the end of "buf" -* @buf: buf to be trimmed -* @len: number of bytes to reduce "buf" by -* -* Trim an xdr_buf by the given number of bytes by fixing up the lengths. Note -* that it's possible that we'll trim less than that amount if the xdr_buf is -* too small, or if (for instance) it's all in the head and the parser has -* already read too far into it. -*/ -void xdr_buf_trim (struct xdr_buf *buf,unsigned int len) -{ -size_t cur; -unsigned int trim = len; - -if (buf->tail[0 ].iov_len) { - cur =min_t (size_t, buf->tail[0 ].iov_len, trim); - buf->tail[0 ].iov_len -= cur; - trim -= cur; -if (!trim) - goto fix_len; - } - -if (buf->page_len) { - cur = min_t(unsigned int, buf->page_len, trim); - buf->page_len -= cur; - trim -= cur; -if (!trim) - goto fix_len; - } - -if (buf->head[0 ].iov_len) { - cur =min_t (size_t, buf->head[0 ].iov_len, trim); - buf->head[0 ].iov_len -= cur; - trim -= cur; - }Quoted 8 lines
net/sunrpc/xdr.c void xdr_enter_page(struct xdr_stream *xdr, unsigned int len) · line 1144
Quoted 8 lines
net/sunrpc/xdr.c +0
-5-fix_len: - buf->len -= (len - trim); -} -EXPORT_SYMBOL_GPL (xdr_buf_trim); -static void __read_bytes_from_xdr_buf (struct xdr_buf *subbuf,void *obj,unsigned int len) {unsigned int this_len;--
Chuck Lever
Re: [PATCH RFC 09/10] SUNRPC: Remove xdr_buf_trim()
Quoted 23 lines · Bruce Fields
Quoted 18 lines · Chuck Lever
Quoted 13 lines · On Feb 4, 2019, at 2:46 PM, [email protected] wrote:
Quoted 5 lines · Chuck Lever
The key action of
xdr_buf_trim()is that it shortensbuf->len, the length of thexdr_buf' content. The other actions -- shortening the head, pages, and tail components -- are actually not necessary. In some cases, changing the size of those components corrupts the RPC message contained in the buffer.That's really burying the lede.... Is there an actual user-visible bug here?
I don't think so. This is more of the form:
a) the function does fundamentally the wrong thing, so
Quoted 8 lines
Quoted 4 lines
b) certain changes to this code path result is unexpected and incorrect behavior
Thus typically only developers hacking on this code run into a problem.
OK, got it. It'd help just to make it clear in the changelog that that this is an accident waiting to happen rather than a current bug (as far as we know).
With said improvement to the changelog, can I add your Acked-by when I submit this through Anna's tree?
Quoted 119 lines
--b.
Quoted 117 lines
Quoted 106 lines
--b.
Quoted 102 lines
Signed-off-by Chuck Lever <[email protected]>---
include/linux/sunrpc/xdr.h | 1 - net/sunrpc/auth_gss/gss_krb5_wrap.c | 8 ++++--- net/sunrpc/auth_gss/svcauth_gss.c | 2 +- net/sunrpc/xdr.c | 41 ----------------------------------- 4 files changed, 6 insertions(+), 46 deletions(-)include/linux/sunrpc/xdr.h +0
-1@@ -183,7 +183,6 @@ static inline __be32 *xdr_encode_array(__be32 *p, const void *s, unsigned int leextern void xdr_shift_buf (struct xdr_buf *,size_t );extern void xdr_buf_from_iov (struct kvec *,struct xdr_buf *);extern int xdr_buf_subsegment (struct xdr_buf *,struct xdr_buf *,unsigned int ,unsigned int ); -extern void xdr_buf_trim (struct xdr_buf *,unsigned int );extern int xdr_buf_read_netobj (struct xdr_buf *,struct xdr_netobj *,unsigned int );extern int read_bytes_from_xdr_buf (struct xdr_buf *,unsigned int ,void *,unsigned int );extern int write_bytes_to_xdr_buf (struct xdr_buf *,unsigned int ,void *,unsigned int );net/sunrpc/auth_gss/gss_krb5_wrap.c +5
-3@@ -570,14 +570,16 @@ static void rotate_left(u32 base, struct xdr_buf *buf, unsigned int shift)*/ movelen = min_t(unsigned int, buf->head[0].iov_len, buf->len); movelen -= offset +GSS_KRB5_TOK_HDR_LEN + headskip; -BUG_ON (offset +GSS_KRB5_TOK_HDR_LEN + headskip + movelen > - buf->head[0 ].iov_len); +if (offset +GSS_KRB5_TOK_HDR_LEN + headskip + movelen > + buf->head[0 ].iov_len) +return GSS_S_FAILURE ;memmove (ptr, ptr +GSS_KRB5_TOK_HDR_LEN + headskip, movelen); buf->head[0 ].iov_len -=GSS_KRB5_TOK_HDR_LEN + headskip; buf->len -=GSS_KRB5_TOK_HDR_LEN + headskip;/* Trim off the trailing "extra count" and checksum blob */ -xdr_buf_trim (buf, ec +GSS_KRB5_TOK_HDR_LEN + tailskip); + buf->len -= ec +GSS_KRB5_TOK_HDR_LEN + tailskip; +return GSS_S_COMPLETE ; }net/sunrpc/auth_gss/svcauth_gss.c +1
-1@@ -896,7 +896,7 @@ u32 svcauth_gss_flavor(struct auth_domain *dom)if (svc_getnl (&buf->head[0 ]) != seq) goto out;/* trim off the mic and padding at the end before returning */ -xdr_buf_trim (buf,round_up_to_quad (mic.len) +4 ); + buf->len -=4 +round_up_to_quad (mic.len); stat =0 ;out:
kfree(mic.data);net/sunrpc/xdr.c +0
-36@@ -1139,47 +1139,6 @@ void xdr_enter_page(struct xdr_stream *xdr, unsigned int len) }EXPORT_SYMBOL_GPL (xdr_buf_subsegment); -/** -* xdr_buf_trim - lop at most "len" bytes off the end of "buf" -* @buf: buf to be trimmed -* @len: number of bytes to reduce "buf" by -* -* Trim an xdr_buf by the given number of bytes by fixing up the lengths. Note -* that it's possible that we'll trim less than that amount if the xdr_buf is -* too small, or if (for instance) it's all in the head and the parser has -* already read too far into it. -*/ -void xdr_buf_trim (struct xdr_buf *buf,unsigned int len) -{ -size_t cur; -unsigned int trim = len; - -if (buf->tail[0 ].iov_len) { - cur =min_t (size_t, buf->tail[0 ].iov_len, trim); - buf->tail[0 ].iov_len -= cur; - trim -= cur; -if (!trim) - goto fix_len; - } - -if (buf->page_len) { - cur = min_t(unsigned int, buf->page_len, trim); - buf->page_len -= cur; - trim -= cur; -if (!trim) - goto fix_len; - } - -if (buf->head[0 ].iov_len) { - cur =min_t (size_t, buf->head[0 ].iov_len, trim); - buf->head[0 ].iov_len -= cur; - trim -= cur; - }Quoted 8 lines
net/sunrpc/xdr.c void xdr_enter_page(struct xdr_stream *xdr, unsigned int len) · line 1144
Quoted 8 lines
net/sunrpc/xdr.c +0
-5-fix_len: - buf->len -= (len - trim); -} -EXPORT_SYMBOL_GPL (xdr_buf_trim); -static void __read_bytes_from_xdr_buf (struct xdr_buf *subbuf,void *obj,unsigned int len) {unsigned int this_len;--
Chuck Lever
--
Chuck Lever
Re: [PATCH RFC 09/10] SUNRPC: Remove xdr_buf_trim()
Quoted 26 lines · Chuck Lever
Quoted 26 lines · Bruce Fields
Quoted 21 lines · Chuck Lever
Quoted 13 lines · On Feb 4, 2019, at 2:46 PM, [email protected] wrote:
Quoted 5 lines · Chuck Lever
The key action of
xdr_buf_trim()is that it shortensbuf->len, the length of thexdr_buf' content. The other actions -- shortening the head, pages, and tail components -- are actually not necessary. In some cases, changing the size of those components corrupts the RPC message contained in the buffer.That's really burying the lede.... Is there an actual user-visible bug here?
I don't think so. This is more of the form:
a) the function does fundamentally the wrong thing, so
b) certain changes to this code path result is unexpected and incorrect behavior
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Thus typically only developers hacking on this code run into a problem.
OK, got it. It'd help just to make it clear in the changelog that that this is an accident waiting to happen rather than a current bug (as far as we know).
With said improvement to the changelog, can I add your Acked-by when I submit this through Anna's tree?
Sure, thanks.
--b.
RFC PATCH 10/10 SUNRPC: Add SPDX IDs to some net/sunrpc/auth_gss/ files
In reply to Chuck LeverFiles under net/sunrpc/auth_gss/ do not yet have SPDX ID tags. This directory is somewhat complicated because most of these files have license boilerplate that is not strictly GPL 2.0.
In this patch I add ID tags where there is an obvious match. The less recognizable licenses are still under research.
For reference, SPDX IDs added in this patch correspond to the following license text:
GPL-2.0 https://spdx.org/licenses/GPL-2.0.html GPL-2.0+ https://spdx.org/licenses/GPL-2.0+.html BSD-3-Clause https://spdx.org/licenses/BSD-3-Clause.html
--- net/sunrpc/auth_gss/auth_gss.c | 27 +-------------------------- net/sunrpc/auth_gss/gss_krb5_mech.c | 27 +-------------------------- net/sunrpc/auth_gss/gss_mech_switch.c | 27 +-------------------------- net/sunrpc/auth_gss/gss_rpc_upcall.c | 15 +-------------- net/sunrpc/auth_gss/gss_rpc_upcall.h | 16 ++-------------- net/sunrpc/auth_gss/gss_rpc_xdr.c | 15 +-------------- net/sunrpc/auth_gss/gss_rpc_xdr.h | 17 +---------------- net/sunrpc/auth_gss/svcauth_gss.c | 1 + 8 files changed, 9 insertions(+), 136 deletions(-)
net/sunrpc/auth_gss/auth_gss.c +1 -26
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: BSD-3-Clause /* * linux/net/sunrpc/auth_gss/auth_gss.c *
@@ -8,34 +9,8 @@* * Dug Song <[email protected]> * Andy Adamson <[email protected]> -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the University nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <linux/module.h> #include <linux/init.h> #include <linux/types.h>
net/sunrpc/auth_gss/gss_krb5_mech.c +1 -26
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: BSD-3-Clause /* * linux/net/sunrpc/gss_krb5_mech.c *
@@ -6,32 +7,6 @@* * Andy Adamson <[email protected]> * J. Bruce Fields <[email protected]> -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the University nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* */ #include <crypto/hash.h>
net/sunrpc/auth_gss/gss_mech_switch.c +1 -26
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: BSD-3-Clause /* * linux/net/sunrpc/gss_mech_switch.c *
@@ -5,32 +6,6 @@* All rights reserved. * * J. Bruce Fields <[email protected]> -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. Neither the name of the University nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* */ #include <linux/types.h>
net/sunrpc/auth_gss/gss_rpc_upcall.c +1 -14
@@ -1,21 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * linux/net/sunrpc/gss_rpc_upcall.c * * Copyright (C) 2012 Simo Sorce <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <linux/types.h>
net/sunrpc/auth_gss/gss_rpc_upcall.h +2 -14
@@ -1,21 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * linux/net/sunrpc/gss_rpc_upcall.h * * Copyright (C) 2012 Simo Sorce <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _GSS_RPC_UPCALL_H
@@ -45,4 +32,5 @@ int gssp_accept_sec_context_upcall(struct net *net,void init_gssp_clnt (struct sunrpc_net *);int set_gssp_clnt (struct net *);void clear_gssp_clnt (struct sunrpc_net *); +#endif /* _GSS_RPC_UPCALL_H */
net/sunrpc/auth_gss/gss_rpc_xdr.c +1 -14
@@ -1,21 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * GSS Proxy upcall module * * Copyright (C) 2012 Simo Sorce <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <linux/sunrpc/svcauth.h>
net/sunrpc/auth_gss/gss_rpc_xdr.h +1 -16
@@ -1,21 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * GSS Proxy upcall module * * Copyright (C) 2012 Simo Sorce <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _LINUX_GSS_RPC_XDR_H
@@ -262,6 +249,4 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp,#define GSSX_ARG_wrap_size_limit_sz 0#define GSSX_RES_wrap_size_limit_sz 0 - -#endif /* _LINUX_GSS_RPC_XDR_H */
net/sunrpc/auth_gss/svcauth_gss.c +1 -0
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Neil Brown <[email protected]> * J. Bruce Fields <[email protected]>