Commit 15d8f808 authored by Chuck Lever's avatar Chuck Lever

SUNRPC: Record gss_get_mic() errors in svcauth_gss_wrap_integ()

An error computing the checksum here is an exceptional event.
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 0adaddd3
...@@ -208,6 +208,7 @@ DECLARE_EVENT_CLASS(rpcgss_svc_gssapi_class, ...@@ -208,6 +208,7 @@ DECLARE_EVENT_CLASS(rpcgss_svc_gssapi_class,
DEFINE_SVC_GSSAPI_EVENT(unwrap); DEFINE_SVC_GSSAPI_EVENT(unwrap);
DEFINE_SVC_GSSAPI_EVENT(mic); DEFINE_SVC_GSSAPI_EVENT(mic);
DEFINE_SVC_GSSAPI_EVENT(get_mic);
TRACE_EVENT(rpcgss_svc_unwrap_failed, TRACE_EVENT(rpcgss_svc_unwrap_failed,
TP_PROTO( TP_PROTO(
......
...@@ -1782,10 +1782,9 @@ static int svcauth_gss_wrap_integ(struct svc_rqst *rqstp) ...@@ -1782,10 +1782,9 @@ static int svcauth_gss_wrap_integ(struct svc_rqst *rqstp)
struct xdr_buf *buf = &rqstp->rq_res; struct xdr_buf *buf = &rqstp->rq_res;
struct xdr_buf databody_integ; struct xdr_buf databody_integ;
struct xdr_netobj checksum; struct xdr_netobj checksum;
u32 offset, len, maj_stat;
struct kvec *resv; struct kvec *resv;
u32 offset, len;
__be32 *p; __be32 *p;
int stat = -EINVAL;
p = svcauth_gss_prepare_to_wrap(buf, gsd); p = svcauth_gss_prepare_to_wrap(buf, gsd);
if (p == NULL) if (p == NULL)
...@@ -1796,21 +1795,20 @@ static int svcauth_gss_wrap_integ(struct svc_rqst *rqstp) ...@@ -1796,21 +1795,20 @@ static int svcauth_gss_wrap_integ(struct svc_rqst *rqstp)
goto out; goto out;
*p++ = htonl(len); *p++ = htonl(len);
*p++ = htonl(gc->gc_seq); *p++ = htonl(gc->gc_seq);
if (xdr_buf_subsegment(buf, &databody_integ, offset, len)) { if (xdr_buf_subsegment(buf, &databody_integ, offset, len))
WARN_ON_ONCE(1); goto wrap_failed;
goto out_err;
}
if (!buf->tail[0].iov_base) { if (!buf->tail[0].iov_base) {
if (buf->head[0].iov_len + RPC_MAX_AUTH_SIZE > PAGE_SIZE) if (buf->head[0].iov_len + RPC_MAX_AUTH_SIZE > PAGE_SIZE)
goto out_err; goto wrap_failed;
buf->tail[0].iov_base = buf->head[0].iov_base buf->tail[0].iov_base = buf->head[0].iov_base
+ buf->head[0].iov_len; + buf->head[0].iov_len;
buf->tail[0].iov_len = 0; buf->tail[0].iov_len = 0;
} }
resv = &buf->tail[0]; resv = &buf->tail[0];
checksum.data = (u8 *)resv->iov_base + resv->iov_len + 4; checksum.data = (u8 *)resv->iov_base + resv->iov_len + 4;
if (gss_get_mic(gsd->rsci->mechctx, &databody_integ, &checksum)) maj_stat = gss_get_mic(gsd->rsci->mechctx, &databody_integ, &checksum);
goto out_err; if (maj_stat != GSS_S_COMPLETE)
goto bad_mic;
svc_putnl(resv, checksum.len); svc_putnl(resv, checksum.len);
memset(checksum.data + checksum.len, 0, memset(checksum.data + checksum.len, 0,
round_up_to_quad(checksum.len) - checksum.len); round_up_to_quad(checksum.len) - checksum.len);
...@@ -1818,11 +1816,13 @@ static int svcauth_gss_wrap_integ(struct svc_rqst *rqstp) ...@@ -1818,11 +1816,13 @@ static int svcauth_gss_wrap_integ(struct svc_rqst *rqstp)
/* not strictly required: */ /* not strictly required: */
buf->len += XDR_QUADLEN(checksum.len) << 2; buf->len += XDR_QUADLEN(checksum.len) << 2;
if (resv->iov_len > PAGE_SIZE) if (resv->iov_len > PAGE_SIZE)
goto out_err; goto wrap_failed;
out: out:
stat = 0; return 0;
out_err: bad_mic:
return stat; trace_rpcgss_svc_get_mic(rqstp, maj_stat);
wrap_failed:
return -EINVAL;
} }
static inline int static inline int
......
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