Skip to content

Commit 5b304bc

Browse files
bfieldsLinus Torvalds
authored andcommitted
[PATCH] knfsd: svcrpc: gss: fix failure on SVC_DENIED in integrity case
If the request is denied after gss_accept was called, we shouldn't try to wrap the reply. We were checking the accept_stat but not the reply_stat. To check the reply_stat in _release, we need a pointer to before (rather than after) the verifier, so modify body_start appropriately. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 3c15a48 commit 5b304bc

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

net/sunrpc/auth_gss/svcauth_gss.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -903,9 +903,9 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
903903
struct gss_svc_data {
904904
/* decoded gss client cred: */
905905
struct rpc_gss_wire_cred clcred;
906-
/* pointer to the beginning of the procedure-specific results,
907-
* which may be encrypted/checksummed in svcauth_gss_release: */
908-
__be32 *body_start;
906+
/* save a pointer to the beginning of the encoded verifier,
907+
* for use in encryption/checksumming in svcauth_gss_release: */
908+
__be32 *verf_start;
909909
struct rsc *rsci;
910910
};
911911

@@ -968,7 +968,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
968968
if (!svcdata)
969969
goto auth_err;
970970
rqstp->rq_auth_data = svcdata;
971-
svcdata->body_start = NULL;
971+
svcdata->verf_start = NULL;
972972
svcdata->rsci = NULL;
973973
gc = &svcdata->clcred;
974974

@@ -1097,6 +1097,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
10971097
goto complete;
10981098
case RPC_GSS_PROC_DATA:
10991099
*authp = rpcsec_gsserr_ctxproblem;
1100+
svcdata->verf_start = resv->iov_base + resv->iov_len;
11001101
if (gss_write_verf(rqstp, rsci->mechctx, gc->gc_seq))
11011102
goto auth_err;
11021103
rqstp->rq_cred = rsci->cred;
@@ -1110,7 +1111,6 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
11101111
gc->gc_seq, rsci->mechctx))
11111112
goto auth_err;
11121113
/* placeholders for length and seq. number: */
1113-
svcdata->body_start = resv->iov_base + resv->iov_len;
11141114
svc_putnl(resv, 0);
11151115
svc_putnl(resv, 0);
11161116
break;
@@ -1119,7 +1119,6 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
11191119
gc->gc_seq, rsci->mechctx))
11201120
goto auth_err;
11211121
/* placeholders for length and seq. number: */
1122-
svcdata->body_start = resv->iov_base + resv->iov_len;
11231122
svc_putnl(resv, 0);
11241123
svc_putnl(resv, 0);
11251124
break;
@@ -1150,14 +1149,21 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
11501149
u32 *
11511150
svcauth_gss_prepare_to_wrap(struct xdr_buf *resbuf, struct gss_svc_data *gsd)
11521151
{
1153-
u32 *p;
1152+
u32 *p, verf_len;
11541153

1155-
p = gsd->body_start;
1156-
gsd->body_start = NULL;
1154+
p = gsd->verf_start;
1155+
gsd->verf_start = NULL;
1156+
1157+
/* If the reply stat is nonzero, don't wrap: */
1158+
if (*(p-1) != rpc_success)
1159+
return NULL;
1160+
/* Skip the verifier: */
1161+
p += 1;
1162+
verf_len = ntohl(*p++);
1163+
p += XDR_QUADLEN(verf_len);
11571164
/* move accept_stat to right place: */
11581165
memcpy(p, p + 2, 4);
1159-
/* Don't wrap in failure case: */
1160-
/* Counting on not getting here if call was not even accepted! */
1166+
/* Also don't wrap if the accept stat is nonzero: */
11611167
if (*p != rpc_success) {
11621168
resbuf->head[0].iov_len -= 2 * 4;
11631169
return NULL;
@@ -1283,7 +1289,7 @@ svcauth_gss_release(struct svc_rqst *rqstp)
12831289
if (gc->gc_proc != RPC_GSS_PROC_DATA)
12841290
goto out;
12851291
/* Release can be called twice, but we only wrap once. */
1286-
if (gsd->body_start == NULL)
1292+
if (gsd->verf_start == NULL)
12871293
goto out;
12881294
/* normally not set till svc_send, but we need it here: */
12891295
/* XXX: what for? Do we mess it up the moment we call svc_putu32

0 commit comments

Comments
 (0)