Commit 28155524 authored by Chuck Lever's avatar Chuck Lever

SUNRPC: Clean up: Replace dprintk and BUG_ON call sites in svcauth_gss.c

Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 96f194b7
...@@ -126,7 +126,7 @@ DEFINE_GSSAPI_EVENT(verify_mic); ...@@ -126,7 +126,7 @@ DEFINE_GSSAPI_EVENT(verify_mic);
DEFINE_GSSAPI_EVENT(wrap); DEFINE_GSSAPI_EVENT(wrap);
DEFINE_GSSAPI_EVENT(unwrap); DEFINE_GSSAPI_EVENT(unwrap);
TRACE_EVENT(rpcgss_accept_upcall, TRACE_EVENT(rpcgss_svc_accept_upcall,
TP_PROTO( TP_PROTO(
__be32 xid, __be32 xid,
u32 major_status, u32 major_status,
...@@ -154,6 +154,29 @@ TRACE_EVENT(rpcgss_accept_upcall, ...@@ -154,6 +154,29 @@ TRACE_EVENT(rpcgss_accept_upcall,
) )
); );
TRACE_EVENT(rpcgss_svc_accept,
TP_PROTO(
__be32 xid,
size_t len
),
TP_ARGS(xid, len),
TP_STRUCT__entry(
__field(u32, xid)
__field(size_t, len)
),
TP_fast_assign(
__entry->xid = be32_to_cpu(xid);
__entry->len = len;
),
TP_printk("xid=0x%08x len=%zu",
__entry->xid, __entry->len
)
);
/** /**
** GSS auth unwrap failures ** GSS auth unwrap failures
...@@ -268,6 +291,40 @@ TRACE_EVENT(rpcgss_need_reencode, ...@@ -268,6 +291,40 @@ TRACE_EVENT(rpcgss_need_reencode,
__entry->ret ? "" : "un") __entry->ret ? "" : "un")
); );
DECLARE_EVENT_CLASS(rpcgss_svc_seqno_class,
TP_PROTO(
__be32 xid,
u32 seqno
),
TP_ARGS(xid, seqno),
TP_STRUCT__entry(
__field(u32, xid)
__field(u32, seqno)
),
TP_fast_assign(
__entry->xid = be32_to_cpu(xid);
__entry->seqno = seqno;
),
TP_printk("xid=0x%08x seqno=%u, request discarded",
__entry->xid, __entry->seqno)
);
#define DEFINE_SVC_SEQNO_EVENT(name) \
DEFINE_EVENT(rpcgss_svc_seqno_class, rpcgss_svc_##name, \
TP_PROTO( \
__be32 xid, \
u32 seqno \
), \
TP_ARGS(xid, seqno))
DEFINE_SVC_SEQNO_EVENT(large_seqno);
DEFINE_SVC_SEQNO_EVENT(old_seqno);
/** /**
** gssd upcall related trace events ** gssd upcall related trace events
**/ **/
......
...@@ -55,10 +55,6 @@ ...@@ -55,10 +55,6 @@
#include "gss_rpc_upcall.h" #include "gss_rpc_upcall.h"
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
# define RPCDBG_FACILITY RPCDBG_AUTH
#endif
/* The rpcsec_init cache is used for mapping RPCSEC_GSS_{,CONT_}INIT requests /* The rpcsec_init cache is used for mapping RPCSEC_GSS_{,CONT_}INIT requests
* into replies. * into replies.
* *
...@@ -713,14 +709,12 @@ gss_verify_header(struct svc_rqst *rqstp, struct rsc *rsci, ...@@ -713,14 +709,12 @@ gss_verify_header(struct svc_rqst *rqstp, struct rsc *rsci,
} }
if (gc->gc_seq > MAXSEQ) { if (gc->gc_seq > MAXSEQ) {
dprintk("RPC: svcauth_gss: discarding request with " trace_rpcgss_svc_large_seqno(rqstp->rq_xid, gc->gc_seq);
"large sequence number %d\n", gc->gc_seq);
*authp = rpcsec_gsserr_ctxproblem; *authp = rpcsec_gsserr_ctxproblem;
return SVC_DENIED; return SVC_DENIED;
} }
if (!gss_check_seq_num(rsci, gc->gc_seq)) { if (!gss_check_seq_num(rsci, gc->gc_seq)) {
dprintk("RPC: svcauth_gss: discarding request with " trace_rpcgss_svc_old_seqno(rqstp->rq_xid, gc->gc_seq);
"old sequence number %d\n", gc->gc_seq);
return SVC_DROP; return SVC_DROP;
} }
return SVC_OK; return SVC_OK;
...@@ -1245,7 +1239,6 @@ static int gss_proxy_save_rsc(struct cache_detail *cd, ...@@ -1245,7 +1239,6 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
if (!ud->found_creds) { if (!ud->found_creds) {
/* userspace seem buggy, we should always get at least a /* userspace seem buggy, we should always get at least a
* mapping to nobody */ * mapping to nobody */
dprintk("RPC: No creds found!\n");
goto out; goto out;
} else { } else {
struct timespec64 boot; struct timespec64 boot;
...@@ -1311,8 +1304,8 @@ static int svcauth_gss_proxy_init(struct svc_rqst *rqstp, ...@@ -1311,8 +1304,8 @@ static int svcauth_gss_proxy_init(struct svc_rqst *rqstp,
if (status) if (status)
goto out; goto out;
trace_rpcgss_accept_upcall(rqstp->rq_xid, ud.major_status, trace_rpcgss_svc_accept_upcall(rqstp->rq_xid, ud.major_status,
ud.minor_status); ud.minor_status);
switch (ud.major_status) { switch (ud.major_status) {
case GSS_S_CONTINUE_NEEDED: case GSS_S_CONTINUE_NEEDED:
...@@ -1320,31 +1313,23 @@ static int svcauth_gss_proxy_init(struct svc_rqst *rqstp, ...@@ -1320,31 +1313,23 @@ static int svcauth_gss_proxy_init(struct svc_rqst *rqstp,
break; break;
case GSS_S_COMPLETE: case GSS_S_COMPLETE:
status = gss_proxy_save_rsc(sn->rsc_cache, &ud, &handle); status = gss_proxy_save_rsc(sn->rsc_cache, &ud, &handle);
if (status) { if (status)
pr_info("%s: gss_proxy_save_rsc failed (%d)\n",
__func__, status);
goto out; goto out;
}
cli_handle.data = (u8 *)&handle; cli_handle.data = (u8 *)&handle;
cli_handle.len = sizeof(handle); cli_handle.len = sizeof(handle);
break; break;
default: default:
ret = SVC_CLOSE;
goto out; goto out;
} }
/* Got an answer to the upcall; use it: */ /* Got an answer to the upcall; use it: */
if (gss_write_init_verf(sn->rsc_cache, rqstp, if (gss_write_init_verf(sn->rsc_cache, rqstp,
&cli_handle, &ud.major_status)) { &cli_handle, &ud.major_status))
pr_info("%s: gss_write_init_verf failed\n", __func__);
goto out; goto out;
}
if (gss_write_resv(resv, PAGE_SIZE, if (gss_write_resv(resv, PAGE_SIZE,
&cli_handle, &ud.out_token, &cli_handle, &ud.out_token,
ud.major_status, ud.minor_status)) { ud.major_status, ud.minor_status))
pr_info("%s: gss_write_resv failed\n", __func__);
goto out; goto out;
}
ret = SVC_COMPLETE; ret = SVC_COMPLETE;
out: out:
...@@ -1495,8 +1480,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp) ...@@ -1495,8 +1480,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
int ret; int ret;
struct sunrpc_net *sn = net_generic(SVC_NET(rqstp), sunrpc_net_id); struct sunrpc_net *sn = net_generic(SVC_NET(rqstp), sunrpc_net_id);
dprintk("RPC: svcauth_gss: argv->iov_len = %zd\n", trace_rpcgss_svc_accept(rqstp->rq_xid, argv->iov_len);
argv->iov_len);
*authp = rpc_autherr_badcred; *authp = rpc_autherr_badcred;
if (!svcdata) if (!svcdata)
...@@ -1705,7 +1689,8 @@ svcauth_gss_wrap_resp_integ(struct svc_rqst *rqstp) ...@@ -1705,7 +1689,8 @@ svcauth_gss_wrap_resp_integ(struct svc_rqst *rqstp)
resv->iov_len += XDR_QUADLEN(mic.len) << 2; resv->iov_len += XDR_QUADLEN(mic.len) << 2;
/* not strictly required: */ /* not strictly required: */
resbuf->len += XDR_QUADLEN(mic.len) << 2; resbuf->len += XDR_QUADLEN(mic.len) << 2;
BUG_ON(resv->iov_len > PAGE_SIZE); if (resv->iov_len > PAGE_SIZE)
goto out_err;
out: out:
stat = 0; stat = 0;
out_err: out_err:
...@@ -1741,9 +1726,11 @@ svcauth_gss_wrap_resp_priv(struct svc_rqst *rqstp) ...@@ -1741,9 +1726,11 @@ svcauth_gss_wrap_resp_priv(struct svc_rqst *rqstp)
* both the head and tail. * both the head and tail.
*/ */
if (resbuf->tail[0].iov_base) { if (resbuf->tail[0].iov_base) {
BUG_ON(resbuf->tail[0].iov_base >= resbuf->head[0].iov_base if (resbuf->tail[0].iov_base >=
+ PAGE_SIZE); resbuf->head[0].iov_base + PAGE_SIZE)
BUG_ON(resbuf->tail[0].iov_base < resbuf->head[0].iov_base); return -EINVAL;
if (resbuf->tail[0].iov_base < resbuf->head[0].iov_base)
return -EINVAL;
if (resbuf->tail[0].iov_len + resbuf->head[0].iov_len if (resbuf->tail[0].iov_len + resbuf->head[0].iov_len
+ 2 * RPC_MAX_AUTH_SIZE > PAGE_SIZE) + 2 * RPC_MAX_AUTH_SIZE > PAGE_SIZE)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment