Skip to content

Commit 35e77d2

Browse files
chuckleveramschuma-ntap
authored andcommitted
SUNRPC: Add rpc_auth::au_ralign field
Currently rpc_inline_rcv_pages() uses au_rslack to estimate the size of the upper layer reply header. This is fine for auth flavors where au_verfsize == au_rslack. However, some auth flavors have more going on. krb5i for example has two more words after the verifier, and another blob following the RPC message. The calculation involving au_rslack pushes the upper layer reply header too far into the rcv_buf. au_rslack is still valuable: it's the amount of buffer space needed for the reply, and is used when allocating the reply buffer. We'll keep that. But, add a new field that can be used to properly estimate the location of the upper layer header in each RPC reply, based on the auth flavor in use. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent a00275b commit 35e77d2

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

include/linux/sunrpc/auth.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,12 @@ struct rpc_cred_cache;
7474
struct rpc_authops;
7575
struct rpc_auth {
7676
unsigned int au_cslack; /* call cred size estimate */
77-
/* guess at number of u32's auth adds before
78-
* reply data; normally the verifier size: */
79-
unsigned int au_rslack;
77+
unsigned int au_rslack; /* reply cred size estimate */
8078
unsigned int au_verfsize; /* size of reply verifier */
79+
unsigned int au_ralign; /* words before UL header */
8180

82-
unsigned int au_flags; /* various flags */
83-
const struct rpc_authops *au_ops; /* operations */
81+
unsigned int au_flags;
82+
const struct rpc_authops *au_ops;
8483
rpc_authflavor_t au_flavor; /* pseudoflavor (note may
8584
* differ from the flavor in
8685
* au_ops->au_flavor in gss

net/sunrpc/auth_gss/auth_gss.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt)
10171017
auth->au_cslack = GSS_CRED_SLACK >> 2;
10181018
auth->au_rslack = GSS_VERF_SLACK >> 2;
10191019
auth->au_verfsize = GSS_VERF_SLACK >> 2;
1020+
auth->au_ralign = GSS_VERF_SLACK >> 2;
10201021
auth->au_flags = 0;
10211022
auth->au_ops = &authgss_ops;
10221023
auth->au_flavor = flavor;
@@ -1891,7 +1892,10 @@ static int gss_wrap_req(struct rpc_task *task, struct xdr_stream *xdr)
18911892
static int
18921893
gss_unwrap_resp_auth(struct rpc_cred *cred)
18931894
{
1894-
cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize;
1895+
struct rpc_auth *auth = cred->cr_auth;
1896+
1897+
auth->au_rslack = auth->au_verfsize;
1898+
auth->au_ralign = auth->au_verfsize;
18951899
return 0;
18961900
}
18971901

@@ -1902,6 +1906,7 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred,
19021906
{
19031907
struct xdr_buf integ_buf, *rcv_buf = &rqstp->rq_rcv_buf;
19041908
u32 data_offset, mic_offset, integ_len, maj_stat;
1909+
struct rpc_auth *auth = cred->cr_auth;
19051910
struct xdr_netobj mic;
19061911
__be32 *p;
19071912

@@ -1928,8 +1933,8 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred,
19281933
if (maj_stat != GSS_S_COMPLETE)
19291934
goto bad_mic;
19301935

1931-
cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + 2 +
1932-
1 + XDR_QUADLEN(mic.len);
1936+
auth->au_rslack = auth->au_verfsize + 2 + 1 + XDR_QUADLEN(mic.len);
1937+
auth->au_ralign = auth->au_verfsize + 2;
19331938
return 0;
19341939
unwrap_failed:
19351940
trace_rpcgss_unwrap_failed(task);
@@ -1949,6 +1954,7 @@ gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred,
19491954
{
19501955
struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf;
19511956
struct kvec *head = rqstp->rq_rcv_buf.head;
1957+
struct rpc_auth *auth = cred->cr_auth;
19521958
unsigned int savedlen = rcv_buf->len;
19531959
u32 offset, opaque_len, maj_stat;
19541960
__be32 *p;
@@ -1976,8 +1982,10 @@ gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred,
19761982
*/
19771983
xdr_init_decode(xdr, rcv_buf, p, rqstp);
19781984

1979-
cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + 2 +
1980-
XDR_QUADLEN(savedlen - rcv_buf->len);
1985+
auth->au_rslack = auth->au_verfsize + 2 +
1986+
XDR_QUADLEN(savedlen - rcv_buf->len);
1987+
auth->au_ralign = auth->au_verfsize + 2 +
1988+
XDR_QUADLEN(savedlen - rcv_buf->len);
19811989
return 0;
19821990
unwrap_failed:
19831991
trace_rpcgss_unwrap_failed(task);

net/sunrpc/auth_null.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ struct rpc_auth null_auth = {
115115
.au_cslack = NUL_CALLSLACK,
116116
.au_rslack = NUL_REPLYSLACK,
117117
.au_verfsize = NUL_REPLYSLACK,
118+
.au_ralign = NUL_REPLYSLACK,
118119
.au_ops = &authnull_ops,
119120
.au_flavor = RPC_AUTH_NULL,
120121
.au_count = REFCOUNT_INIT(1),

net/sunrpc/auth_unix.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ unx_validate(struct rpc_task *task, struct xdr_stream *xdr)
187187

188188
auth->au_verfsize = XDR_QUADLEN(size) + 2;
189189
auth->au_rslack = XDR_QUADLEN(size) + 2;
190+
auth->au_ralign = XDR_QUADLEN(size) + 2;
190191
return 0;
191192
}
192193

net/sunrpc/clnt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ void rpc_prepare_reply_pages(struct rpc_rqst *req, struct page **pages,
11801180
/* Subtract one to force an extra word of buffer space for the
11811181
* payload's XDR pad to fall into the rcv_buf's tail iovec.
11821182
*/
1183-
hdrsize += RPC_REPHDRSIZE + req->rq_cred->cr_auth->au_rslack - 1;
1183+
hdrsize += RPC_REPHDRSIZE + req->rq_cred->cr_auth->au_ralign - 1;
11841184

11851185
xdr_inline_pages(&req->rq_rcv_buf, hdrsize << 2, pages, base, len);
11861186
trace_rpc_reply_pages(req);

0 commit comments

Comments
 (0)