diff options
| author | Chuck Lever <chuck.lever@oracle.com> | 2019-02-11 11:25:36 -0500 |
|---|---|---|
| committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2019-02-14 11:48:36 -0500 |
| commit | 35e77d21baa04b554bf3dc9a08dfa7e569286e51 (patch) | |
| tree | d6e48672b6fbd6ce82ba47438295b18b53b2c4b0 | |
| parent | a00275baa68e1ee226cc659f54dc3a571f3ad600 (diff) | |
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>
| -rw-r--r-- | include/linux/sunrpc/auth.h | 9 | ||||
| -rw-r--r-- | net/sunrpc/auth_gss/auth_gss.c | 18 | ||||
| -rw-r--r-- | net/sunrpc/auth_null.c | 1 | ||||
| -rw-r--r-- | net/sunrpc/auth_unix.c | 1 | ||||
| -rw-r--r-- | net/sunrpc/clnt.c | 2 |
5 files changed, 20 insertions, 11 deletions
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h index 359dfdd04e77..5f9076fdb090 100644 --- a/include/linux/sunrpc/auth.h +++ b/include/linux/sunrpc/auth.h | |||
| @@ -74,13 +74,12 @@ struct rpc_cred_cache; | |||
| 74 | struct rpc_authops; | 74 | struct rpc_authops; |
| 75 | struct rpc_auth { | 75 | struct rpc_auth { |
| 76 | unsigned int au_cslack; /* call cred size estimate */ | 76 | unsigned int au_cslack; /* call cred size estimate */ |
| 77 | /* guess at number of u32's auth adds before | 77 | unsigned int au_rslack; /* reply cred size estimate */ |
| 78 | * reply data; normally the verifier size: */ | ||
| 79 | unsigned int au_rslack; | ||
| 80 | unsigned int au_verfsize; /* size of reply verifier */ | 78 | unsigned int au_verfsize; /* size of reply verifier */ |
| 79 | unsigned int au_ralign; /* words before UL header */ | ||
| 81 | 80 | ||
| 82 | unsigned int au_flags; /* various flags */ | 81 | unsigned int au_flags; |
| 83 | const struct rpc_authops *au_ops; /* operations */ | 82 | const struct rpc_authops *au_ops; |
| 84 | rpc_authflavor_t au_flavor; /* pseudoflavor (note may | 83 | rpc_authflavor_t au_flavor; /* pseudoflavor (note may |
| 85 | * differ from the flavor in | 84 | * differ from the flavor in |
| 86 | * au_ops->au_flavor in gss | 85 | * au_ops->au_flavor in gss |
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 731e7a482e18..c67e2ad151ae 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
| @@ -1017,6 +1017,7 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) | |||
| 1017 | auth->au_cslack = GSS_CRED_SLACK >> 2; | 1017 | auth->au_cslack = GSS_CRED_SLACK >> 2; |
| 1018 | auth->au_rslack = GSS_VERF_SLACK >> 2; | 1018 | auth->au_rslack = GSS_VERF_SLACK >> 2; |
| 1019 | auth->au_verfsize = GSS_VERF_SLACK >> 2; | 1019 | auth->au_verfsize = GSS_VERF_SLACK >> 2; |
| 1020 | auth->au_ralign = GSS_VERF_SLACK >> 2; | ||
| 1020 | auth->au_flags = 0; | 1021 | auth->au_flags = 0; |
| 1021 | auth->au_ops = &authgss_ops; | 1022 | auth->au_ops = &authgss_ops; |
| 1022 | auth->au_flavor = flavor; | 1023 | auth->au_flavor = flavor; |
| @@ -1891,7 +1892,10 @@ out: | |||
| 1891 | static int | 1892 | static int |
| 1892 | gss_unwrap_resp_auth(struct rpc_cred *cred) | 1893 | gss_unwrap_resp_auth(struct rpc_cred *cred) |
| 1893 | { | 1894 | { |
| 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; | ||
| 1895 | return 0; | 1899 | return 0; |
| 1896 | } | 1900 | } |
| 1897 | 1901 | ||
| @@ -1902,6 +1906,7 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred, | |||
| 1902 | { | 1906 | { |
| 1903 | struct xdr_buf integ_buf, *rcv_buf = &rqstp->rq_rcv_buf; | 1907 | struct xdr_buf integ_buf, *rcv_buf = &rqstp->rq_rcv_buf; |
| 1904 | u32 data_offset, mic_offset, integ_len, maj_stat; | 1908 | u32 data_offset, mic_offset, integ_len, maj_stat; |
| 1909 | struct rpc_auth *auth = cred->cr_auth; | ||
| 1905 | struct xdr_netobj mic; | 1910 | struct xdr_netobj mic; |
| 1906 | __be32 *p; | 1911 | __be32 *p; |
| 1907 | 1912 | ||
| @@ -1928,8 +1933,8 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred, | |||
| 1928 | if (maj_stat != GSS_S_COMPLETE) | 1933 | if (maj_stat != GSS_S_COMPLETE) |
| 1929 | goto bad_mic; | 1934 | goto bad_mic; |
| 1930 | 1935 | ||
| 1931 | cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + 2 + | 1936 | auth->au_rslack = auth->au_verfsize + 2 + 1 + XDR_QUADLEN(mic.len); |
| 1932 | 1 + XDR_QUADLEN(mic.len); | 1937 | auth->au_ralign = auth->au_verfsize + 2; |
| 1933 | return 0; | 1938 | return 0; |
| 1934 | unwrap_failed: | 1939 | unwrap_failed: |
| 1935 | trace_rpcgss_unwrap_failed(task); | 1940 | trace_rpcgss_unwrap_failed(task); |
| @@ -1949,6 +1954,7 @@ gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred, | |||
| 1949 | { | 1954 | { |
| 1950 | struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf; | 1955 | struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf; |
| 1951 | struct kvec *head = rqstp->rq_rcv_buf.head; | 1956 | struct kvec *head = rqstp->rq_rcv_buf.head; |
| 1957 | struct rpc_auth *auth = cred->cr_auth; | ||
| 1952 | unsigned int savedlen = rcv_buf->len; | 1958 | unsigned int savedlen = rcv_buf->len; |
| 1953 | u32 offset, opaque_len, maj_stat; | 1959 | u32 offset, opaque_len, maj_stat; |
| 1954 | __be32 *p; | 1960 | __be32 *p; |
| @@ -1976,8 +1982,10 @@ gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred, | |||
| 1976 | */ | 1982 | */ |
| 1977 | xdr_init_decode(xdr, rcv_buf, p, rqstp); | 1983 | xdr_init_decode(xdr, rcv_buf, p, rqstp); |
| 1978 | 1984 | ||
| 1979 | cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + 2 + | 1985 | auth->au_rslack = auth->au_verfsize + 2 + |
| 1980 | XDR_QUADLEN(savedlen - rcv_buf->len); | 1986 | XDR_QUADLEN(savedlen - rcv_buf->len); |
| 1987 | auth->au_ralign = auth->au_verfsize + 2 + | ||
| 1988 | XDR_QUADLEN(savedlen - rcv_buf->len); | ||
| 1981 | return 0; | 1989 | return 0; |
| 1982 | unwrap_failed: | 1990 | unwrap_failed: |
| 1983 | trace_rpcgss_unwrap_failed(task); | 1991 | trace_rpcgss_unwrap_failed(task); |
diff --git a/net/sunrpc/auth_null.c b/net/sunrpc/auth_null.c index 9ae08248a9e1..41a633a4049e 100644 --- a/net/sunrpc/auth_null.c +++ b/net/sunrpc/auth_null.c | |||
| @@ -115,6 +115,7 @@ struct rpc_auth null_auth = { | |||
| 115 | .au_cslack = NUL_CALLSLACK, | 115 | .au_cslack = NUL_CALLSLACK, |
| 116 | .au_rslack = NUL_REPLYSLACK, | 116 | .au_rslack = NUL_REPLYSLACK, |
| 117 | .au_verfsize = NUL_REPLYSLACK, | 117 | .au_verfsize = NUL_REPLYSLACK, |
| 118 | .au_ralign = NUL_REPLYSLACK, | ||
| 118 | .au_ops = &authnull_ops, | 119 | .au_ops = &authnull_ops, |
| 119 | .au_flavor = RPC_AUTH_NULL, | 120 | .au_flavor = RPC_AUTH_NULL, |
| 120 | .au_count = REFCOUNT_INIT(1), | 121 | .au_count = REFCOUNT_INIT(1), |
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index a93c56442487..c048eb6deaaf 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c | |||
| @@ -187,6 +187,7 @@ unx_validate(struct rpc_task *task, struct xdr_stream *xdr) | |||
| 187 | 187 | ||
| 188 | auth->au_verfsize = XDR_QUADLEN(size) + 2; | 188 | auth->au_verfsize = XDR_QUADLEN(size) + 2; |
| 189 | auth->au_rslack = XDR_QUADLEN(size) + 2; | 189 | auth->au_rslack = XDR_QUADLEN(size) + 2; |
| 190 | auth->au_ralign = XDR_QUADLEN(size) + 2; | ||
| 190 | return 0; | 191 | return 0; |
| 191 | } | 192 | } |
| 192 | 193 | ||
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 4ea38b029e2f..99bfeb17367c 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
| @@ -1180,7 +1180,7 @@ void rpc_prepare_reply_pages(struct rpc_rqst *req, struct page **pages, | |||
| 1180 | /* Subtract one to force an extra word of buffer space for the | 1180 | /* Subtract one to force an extra word of buffer space for the |
| 1181 | * payload's XDR pad to fall into the rcv_buf's tail iovec. | 1181 | * payload's XDR pad to fall into the rcv_buf's tail iovec. |
| 1182 | */ | 1182 | */ |
| 1183 | hdrsize += RPC_REPHDRSIZE + req->rq_cred->cr_auth->au_rslack - 1; | 1183 | hdrsize += RPC_REPHDRSIZE + req->rq_cred->cr_auth->au_ralign - 1; |
| 1184 | 1184 | ||
| 1185 | xdr_inline_pages(&req->rq_rcv_buf, hdrsize << 2, pages, base, len); | 1185 | xdr_inline_pages(&req->rq_rcv_buf, hdrsize << 2, pages, base, len); |
| 1186 | trace_rpc_reply_pages(req); | 1186 | trace_rpc_reply_pages(req); |
