diff options
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/auth_gss/gss_krb5_crypto.c | 34 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/gss_spkm3_seal.c | 2 | ||||
-rw-r--r-- | net/sunrpc/xdr.c | 2 |
3 files changed, 30 insertions, 8 deletions
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c index 24711be4b2dc..91cd8f0d1e10 100644 --- a/net/sunrpc/auth_gss/gss_krb5_crypto.c +++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c | |||
@@ -75,7 +75,7 @@ krb5_encrypt( | |||
75 | memcpy(local_iv, iv, crypto_blkcipher_ivsize(tfm)); | 75 | memcpy(local_iv, iv, crypto_blkcipher_ivsize(tfm)); |
76 | 76 | ||
77 | memcpy(out, in, length); | 77 | memcpy(out, in, length); |
78 | sg_set_buf(sg, out, length); | 78 | sg_init_one(sg, out, length); |
79 | 79 | ||
80 | ret = crypto_blkcipher_encrypt_iv(&desc, sg, sg, length); | 80 | ret = crypto_blkcipher_encrypt_iv(&desc, sg, sg, length); |
81 | out: | 81 | out: |
@@ -110,7 +110,7 @@ krb5_decrypt( | |||
110 | memcpy(local_iv,iv, crypto_blkcipher_ivsize(tfm)); | 110 | memcpy(local_iv,iv, crypto_blkcipher_ivsize(tfm)); |
111 | 111 | ||
112 | memcpy(out, in, length); | 112 | memcpy(out, in, length); |
113 | sg_set_buf(sg, out, length); | 113 | sg_init_one(sg, out, length); |
114 | 114 | ||
115 | ret = crypto_blkcipher_decrypt_iv(&desc, sg, sg, length); | 115 | ret = crypto_blkcipher_decrypt_iv(&desc, sg, sg, length); |
116 | out: | 116 | out: |
@@ -146,7 +146,7 @@ make_checksum(char *cksumname, char *header, int hdrlen, struct xdr_buf *body, | |||
146 | err = crypto_hash_init(&desc); | 146 | err = crypto_hash_init(&desc); |
147 | if (err) | 147 | if (err) |
148 | goto out; | 148 | goto out; |
149 | sg_set_buf(sg, header, hdrlen); | 149 | sg_init_one(sg, header, hdrlen); |
150 | err = crypto_hash_update(&desc, sg, hdrlen); | 150 | err = crypto_hash_update(&desc, sg, hdrlen); |
151 | if (err) | 151 | if (err) |
152 | goto out; | 152 | goto out; |
@@ -188,8 +188,6 @@ encryptor(struct scatterlist *sg, void *data) | |||
188 | /* Worst case is 4 fragments: head, end of page 1, start | 188 | /* Worst case is 4 fragments: head, end of page 1, start |
189 | * of page 2, tail. Anything more is a bug. */ | 189 | * of page 2, tail. Anything more is a bug. */ |
190 | BUG_ON(desc->fragno > 3); | 190 | BUG_ON(desc->fragno > 3); |
191 | desc->infrags[desc->fragno] = *sg; | ||
192 | desc->outfrags[desc->fragno] = *sg; | ||
193 | 191 | ||
194 | page_pos = desc->pos - outbuf->head[0].iov_len; | 192 | page_pos = desc->pos - outbuf->head[0].iov_len; |
195 | if (page_pos >= 0 && page_pos < outbuf->page_len) { | 193 | if (page_pos >= 0 && page_pos < outbuf->page_len) { |
@@ -199,7 +197,10 @@ encryptor(struct scatterlist *sg, void *data) | |||
199 | } else { | 197 | } else { |
200 | in_page = sg_page(sg); | 198 | in_page = sg_page(sg); |
201 | } | 199 | } |
202 | sg_assign_page(&desc->infrags[desc->fragno], in_page); | 200 | sg_set_page(&desc->infrags[desc->fragno], in_page, sg->length, |
201 | sg->offset); | ||
202 | sg_set_page(&desc->outfrags[desc->fragno], sg_page(sg), sg->length, | ||
203 | sg->offset); | ||
203 | desc->fragno++; | 204 | desc->fragno++; |
204 | desc->fraglen += sg->length; | 205 | desc->fraglen += sg->length; |
205 | desc->pos += sg->length; | 206 | desc->pos += sg->length; |
@@ -210,10 +211,17 @@ encryptor(struct scatterlist *sg, void *data) | |||
210 | if (thislen == 0) | 211 | if (thislen == 0) |
211 | return 0; | 212 | return 0; |
212 | 213 | ||
214 | sg_mark_end(desc->infrags, desc->fragno); | ||
215 | sg_mark_end(desc->outfrags, desc->fragno); | ||
216 | |||
213 | ret = crypto_blkcipher_encrypt_iv(&desc->desc, desc->outfrags, | 217 | ret = crypto_blkcipher_encrypt_iv(&desc->desc, desc->outfrags, |
214 | desc->infrags, thislen); | 218 | desc->infrags, thislen); |
215 | if (ret) | 219 | if (ret) |
216 | return ret; | 220 | return ret; |
221 | |||
222 | sg_init_table(desc->infrags, 4); | ||
223 | sg_init_table(desc->outfrags, 4); | ||
224 | |||
217 | if (fraglen) { | 225 | if (fraglen) { |
218 | sg_set_page(&desc->outfrags[0], sg_page(sg), fraglen, | 226 | sg_set_page(&desc->outfrags[0], sg_page(sg), fraglen, |
219 | sg->offset + sg->length - fraglen); | 227 | sg->offset + sg->length - fraglen); |
@@ -247,6 +255,9 @@ gss_encrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *buf, | |||
247 | desc.fragno = 0; | 255 | desc.fragno = 0; |
248 | desc.fraglen = 0; | 256 | desc.fraglen = 0; |
249 | 257 | ||
258 | sg_init_table(desc.infrags, 4); | ||
259 | sg_init_table(desc.outfrags, 4); | ||
260 | |||
250 | ret = xdr_process_buf(buf, offset, buf->len - offset, encryptor, &desc); | 261 | ret = xdr_process_buf(buf, offset, buf->len - offset, encryptor, &desc); |
251 | return ret; | 262 | return ret; |
252 | } | 263 | } |
@@ -271,7 +282,8 @@ decryptor(struct scatterlist *sg, void *data) | |||
271 | /* Worst case is 4 fragments: head, end of page 1, start | 282 | /* Worst case is 4 fragments: head, end of page 1, start |
272 | * of page 2, tail. Anything more is a bug. */ | 283 | * of page 2, tail. Anything more is a bug. */ |
273 | BUG_ON(desc->fragno > 3); | 284 | BUG_ON(desc->fragno > 3); |
274 | desc->frags[desc->fragno] = *sg; | 285 | sg_set_page(&desc->frags[desc->fragno], sg_page(sg), sg->length, |
286 | sg->offset); | ||
275 | desc->fragno++; | 287 | desc->fragno++; |
276 | desc->fraglen += sg->length; | 288 | desc->fraglen += sg->length; |
277 | 289 | ||
@@ -281,10 +293,15 @@ decryptor(struct scatterlist *sg, void *data) | |||
281 | if (thislen == 0) | 293 | if (thislen == 0) |
282 | return 0; | 294 | return 0; |
283 | 295 | ||
296 | sg_mark_end(desc->frags, desc->fragno); | ||
297 | |||
284 | ret = crypto_blkcipher_decrypt_iv(&desc->desc, desc->frags, | 298 | ret = crypto_blkcipher_decrypt_iv(&desc->desc, desc->frags, |
285 | desc->frags, thislen); | 299 | desc->frags, thislen); |
286 | if (ret) | 300 | if (ret) |
287 | return ret; | 301 | return ret; |
302 | |||
303 | sg_init_table(desc->frags, 4); | ||
304 | |||
288 | if (fraglen) { | 305 | if (fraglen) { |
289 | sg_set_page(&desc->frags[0], sg_page(sg), fraglen, | 306 | sg_set_page(&desc->frags[0], sg_page(sg), fraglen, |
290 | sg->offset + sg->length - fraglen); | 307 | sg->offset + sg->length - fraglen); |
@@ -312,6 +329,9 @@ gss_decrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *buf, | |||
312 | desc.desc.flags = 0; | 329 | desc.desc.flags = 0; |
313 | desc.fragno = 0; | 330 | desc.fragno = 0; |
314 | desc.fraglen = 0; | 331 | desc.fraglen = 0; |
332 | |||
333 | sg_init_table(desc.frags, 4); | ||
334 | |||
315 | return xdr_process_buf(buf, offset, buf->len - offset, decryptor, &desc); | 335 | return xdr_process_buf(buf, offset, buf->len - offset, decryptor, &desc); |
316 | } | 336 | } |
317 | 337 | ||
diff --git a/net/sunrpc/auth_gss/gss_spkm3_seal.c b/net/sunrpc/auth_gss/gss_spkm3_seal.c index d158635de6c0..abf17ce2e3b1 100644 --- a/net/sunrpc/auth_gss/gss_spkm3_seal.c +++ b/net/sunrpc/auth_gss/gss_spkm3_seal.c | |||
@@ -173,7 +173,7 @@ make_spkm3_checksum(s32 cksumtype, struct xdr_netobj *key, char *header, | |||
173 | if (err) | 173 | if (err) |
174 | goto out; | 174 | goto out; |
175 | 175 | ||
176 | sg_set_buf(sg, header, hdrlen); | 176 | sg_init_one(sg, header, hdrlen); |
177 | crypto_hash_update(&desc, sg, sg->length); | 177 | crypto_hash_update(&desc, sg, sg->length); |
178 | 178 | ||
179 | xdr_process_buf(body, body_offset, body->len - body_offset, | 179 | xdr_process_buf(body, body_offset, body->len - body_offset, |
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index f38dac30481b..fdc5e6d7562b 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c | |||
@@ -1030,6 +1030,8 @@ xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, | |||
1030 | unsigned page_len, thislen, page_offset; | 1030 | unsigned page_len, thislen, page_offset; |
1031 | struct scatterlist sg[1]; | 1031 | struct scatterlist sg[1]; |
1032 | 1032 | ||
1033 | sg_init_table(sg, 1); | ||
1034 | |||
1033 | if (offset >= buf->head[0].iov_len) { | 1035 | if (offset >= buf->head[0].iov_len) { |
1034 | offset -= buf->head[0].iov_len; | 1036 | offset -= buf->head[0].iov_len; |
1035 | } else { | 1037 | } else { |