SUNRPC: return proper error from gss_wrap_req_priv
Subsystems (3)
PATCH 1/1 SUNRPC: return proper error from gss_wrap_req_priv
don't return 0 if snd_buf->len really greater than snd_buf->buflen
--- net/sunrpc/auth_gss/auth_gss.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/sunrpc/auth_gss/auth_gss.c +3 -1
@@ -1875,8 +1875,10 @@ gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, offset = (u8 *)p - (u8 *)snd_buf->head[0 ].iov_base; maj_stat =gss_wrap (ctx->gc_gss_ctx, offset, snd_buf, inpages);/* slack space should prevent this ever happening: */ -if (unlikely (snd_buf->len > snd_buf->buflen)) +if (unlikely (snd_buf->len > snd_buf->buflen)) { + status = -EIO ; goto wrap_failed; + }/* We're assuming that when GSS_S_CONTEXT_EXPIRED, the encryption was * done anyway, so it's safe to put the request on the wire: */ if (maj_stat ==GSS_S_CONTEXT_EXPIRED )
Signature · 1 line
2.39.1
Quoted 3 lines · Chen Hanxiao
don't return 0 if
snd_buf->lenreally greater thansnd_buf->buflenSigned-off-by Chen Hanxiao <[email protected]>
more below ..
Quoted 9 lines
--- net/sunrpc/auth_gss/auth_gss.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)net/sunrpc/auth_gss/auth_gss.c +0
-0
net/sunrpc/auth_gss/auth_gss.c gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, · line 1880
Quoted 7 lines
net/sunrpc/auth_gss/auth_gss.c +2
-1@@ -1875,8 +1875,10 @@ gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, offset = (u8 *)p - (u8 *)snd_buf->head[0 ].iov_base; maj_stat =gss_wrap (ctx->gc_gss_ctx, offset, snd_buf, inpages);/* slack space should prevent this ever happening: */ -if (unlikely (snd_buf->len > snd_buf->buflen)) +if (unlikely (snd_buf->len > snd_buf->buflen)) { + status = -EIO ; goto wrap_failed;
Maybe Chuck intended to jump to bad_wrap in 0c77668ddb4e? Interesting that you found this considering "slack space should prevent this ever happening".
Ben
Chuck Lever
Reviewed-byQuoted 16 lines · Benjamin Coddington
Quoted 3 lines · Chen Hanxiao
don't return 0 if
snd_buf->lenreally greater thansnd_buf->buflenSigned-off-by Chen Hanxiao <[email protected]>Fixes 0c77668ddb4e ("SUNRPC: Introduce trace points in rpc_auth_gss.ko")Reviewed-by Benjamin Coddington <[email protected]>more below ..
Quoted 4 lines
--- net/sunrpc/auth_gss/auth_gss.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 14 lines
net/sunrpc/auth_gss/auth_gss.c gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, · line 1880
Quoted 12 lines
net/sunrpc/auth_gss/auth_gss.c +2
-1@@ -1875,8 +1875,10 @@ gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, offset = (u8 *)p - (u8 *)snd_buf->head[0 ].iov_base; maj_stat =gss_wrap (ctx->gc_gss_ctx, offset, snd_buf, inpages);/* slack space should prevent this ever happening: */ -if (unlikely (snd_buf->len > snd_buf->buflen)) +if (unlikely (snd_buf->len > snd_buf->buflen)) { + status = -EIO ; goto wrap_failed;Maybe Chuck intended to jump to
bad_wrapin0c77668ddb4e?
bad_wrap is specifically for reporting a GSS failure, so "goto wrap_failed;" is correct.
The bug here is that the earlier alloc_enc_pages() call clobbers the default value of @status.
Quoted 2 lines
Interesting that
you found this considering "slack space should prevent this ever happening".
That suggests that the slack space computation is somehow wrong, which might be possible for one of the new enctypes..? Further investigation is warranted.
Signature · 1 line
Chuck Lever