Skip to content

Commit 99d074d

Browse files
committed
SUNRPC: Check rq_auth_stat when preparing to wrap a response
Commit 5b304bc ("[PATCH] knfsd: svcrpc: gss: fix failure on SVC_DENIED in integrity case") added a check to prevent wrapping an RPC response if reply_stat == MSG_DENIED, assuming that the only way to get to svcauth_gss_release() with that reply_stat value was if the reject_stat was AUTH_ERROR (reject_stat == MISMATCH is handled earlier in svc_process_common()). The code there is somewhat confusing. For one thing, rpc_success is an accept_stat value, not a reply_stat value. The correct reply_stat value to look for is RPC_MSG_DENIED. It happens to be the same value as rpc_success, so it all works out, but it's not terribly readable. Since commit 438623a ("SUNRPC: Add svc_rqst::rq_auth_stat"), the actual auth_stat value is stored in the svc_rqst, so that value is now available to svcauth_gss_prepare_to_wrap() to make its decision to wrap, based on direct information about the authentication status of the RPC caller. No behavior change is intended, this simply replaces some old code with something that should be more self-documenting. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent eb1b780 commit 99d074d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

net/sunrpc/auth_gss/svcauth_gss.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,17 +1732,19 @@ svcauth_gss_accept(struct svc_rqst *rqstp)
17321732
}
17331733

17341734
static __be32 *
1735-
svcauth_gss_prepare_to_wrap(struct xdr_buf *resbuf, struct gss_svc_data *gsd)
1735+
svcauth_gss_prepare_to_wrap(struct svc_rqst *rqstp, struct gss_svc_data *gsd)
17361736
{
1737+
struct xdr_buf *resbuf = &rqstp->rq_res;
17371738
__be32 *p;
17381739
u32 verf_len;
17391740

17401741
p = gsd->verf_start;
17411742
gsd->verf_start = NULL;
17421743

1743-
/* If the reply stat is nonzero, don't wrap: */
1744-
if (*(p-1) != rpc_success)
1744+
/* AUTH_ERROR replies are not wrapped. */
1745+
if (rqstp->rq_auth_stat != rpc_auth_ok)
17451746
return NULL;
1747+
17461748
/* Skip the verifier: */
17471749
p += 1;
17481750
verf_len = ntohl(*p++);
@@ -1786,7 +1788,7 @@ static int svcauth_gss_wrap_integ(struct svc_rqst *rqstp)
17861788
u32 offset, len, maj_stat;
17871789
__be32 *p;
17881790

1789-
p = svcauth_gss_prepare_to_wrap(buf, gsd);
1791+
p = svcauth_gss_prepare_to_wrap(rqstp, gsd);
17901792
if (p == NULL)
17911793
goto out;
17921794

@@ -1846,7 +1848,7 @@ static int svcauth_gss_wrap_priv(struct svc_rqst *rqstp)
18461848
u32 offset, pad, maj_stat;
18471849
__be32 *p, *lenp;
18481850

1849-
p = svcauth_gss_prepare_to_wrap(buf, gsd);
1851+
p = svcauth_gss_prepare_to_wrap(rqstp, gsd);
18501852
if (p == NULL)
18511853
return 0;
18521854

0 commit comments

Comments
 (0)