diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2023-01-08 19:29:07 +0300 |
---|---|---|
committer | Chuck Lever <chuck.lever@oracle.com> | 2023-02-20 17:20:25 +0300 |
commit | ba8b13e5f4303979440bc5c2a45b3d720b9c0b42 (patch) | |
tree | 73d5e6678e0b296e152c793d35cefdc9d23a0e79 /net/sunrpc/auth_gss/svcauth_gss.c | |
parent | 7b135c65bb4544a5a1f72573b11adbcfc8aade9b (diff) | |
download | linux-ba8b13e5f4303979440bc5c2a45b3d720b9c0b42.tar.xz |
SUNRPC: Record gss_wrap() errors in svcauth_gss_wrap_priv()
Match the error reporting in the other unwrap and wrap functions.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'net/sunrpc/auth_gss/svcauth_gss.c')
-rw-r--r-- | net/sunrpc/auth_gss/svcauth_gss.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 78b4eeba5ddc..273dc86ee629 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c @@ -1813,7 +1813,9 @@ out: bad_mic: trace_rpcgss_svc_get_mic(rqstp, maj_stat); + return -EINVAL; wrap_failed: + trace_rpcgss_svc_wrap_failed(rqstp); return -EINVAL; } @@ -1834,18 +1836,16 @@ static int svcauth_gss_wrap_priv(struct svc_rqst *rqstp) struct gss_svc_data *gsd = rqstp->rq_auth_data; struct rpc_gss_wire_cred *gc = &gsd->clcred; struct xdr_buf *buf = &rqstp->rq_res; - struct page **inpages = NULL; + u32 offset, pad, maj_stat; __be32 *p, *lenp; - int offset; - int pad; p = svcauth_gss_prepare_to_wrap(buf, gsd); if (p == NULL) return 0; + lenp = p++; offset = (u8 *)p - (u8 *)buf->head[0].iov_base; *p++ = htonl(gc->gc_seq); - inpages = buf->pages; /* XXX: Would be better to write some xdr helper functions for * nfs{2,3,4}xdr.c that place the data right, instead of copying: */ @@ -1859,12 +1859,12 @@ static int svcauth_gss_wrap_priv(struct svc_rqst *rqstp) if (buf->tail[0].iov_base) { if (buf->tail[0].iov_base >= buf->head[0].iov_base + PAGE_SIZE) - return -EINVAL; + goto wrap_failed; if (buf->tail[0].iov_base < buf->head[0].iov_base) - return -EINVAL; + goto wrap_failed; if (buf->tail[0].iov_len + buf->head[0].iov_len + 2 * RPC_MAX_AUTH_SIZE > PAGE_SIZE) - return -ENOMEM; + goto wrap_failed; memmove(buf->tail[0].iov_base + RPC_MAX_AUTH_SIZE, buf->tail[0].iov_base, buf->tail[0].iov_len); @@ -1879,13 +1879,16 @@ static int svcauth_gss_wrap_priv(struct svc_rqst *rqstp) */ if (!buf->tail[0].iov_base) { if (buf->head[0].iov_len + 2 * RPC_MAX_AUTH_SIZE > PAGE_SIZE) - return -ENOMEM; + goto wrap_failed; buf->tail[0].iov_base = buf->head[0].iov_base + buf->head[0].iov_len + RPC_MAX_AUTH_SIZE; buf->tail[0].iov_len = 0; } - if (gss_wrap(gsd->rsci->mechctx, offset, buf, inpages)) - return -ENOMEM; + + maj_stat = gss_wrap(gsd->rsci->mechctx, offset, buf, buf->pages); + if (maj_stat != GSS_S_COMPLETE) + goto bad_wrap; + *lenp = htonl(buf->len - offset); pad = 3 - ((buf->len - offset - 1) & 3); p = (__be32 *)(buf->tail[0].iov_base + buf->tail[0].iov_len); @@ -1894,6 +1897,12 @@ static int svcauth_gss_wrap_priv(struct svc_rqst *rqstp) buf->len += pad; return 0; +wrap_failed: + trace_rpcgss_svc_wrap_failed(rqstp); + return -EINVAL; +bad_wrap: + trace_rpcgss_svc_wrap(rqstp, maj_stat); + return -ENOMEM; } /** |