aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 00:48:06 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 00:48:06 -0400
commit9f75e1eff3edb2bb07349b94c28f4f2a6c66ca43 (patch)
tree27a73405d3652dc6771fab28721b70e6d44ff47a
parentb1459461f1e0abd5c28317d6bff6f2ca612a719d (diff)
parent1b40efd772f4419fbc1a8940506424246985c333 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/herbert/crypto-2.6
-rw-r--r--crypto/api.c5
-rw-r--r--crypto/hmac.c19
-rw-r--r--crypto/tcrypt.c56
-rw-r--r--drivers/md/dm-crypt.c12
-rw-r--r--drivers/net/wireless/airo.c7
-rw-r--r--drivers/scsi/arm/scsi.h6
-rw-r--r--drivers/scsi/libata-core.c10
-rw-r--r--drivers/scsi/sg.c5
-rw-r--r--drivers/usb/misc/usbtest.c7
-rw-r--r--include/linux/scatterlist.h17
-rw-r--r--net/ipv6/addrconf.c10
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c23
12 files changed, 64 insertions, 113 deletions
diff --git a/crypto/api.c b/crypto/api.c
index 959c4e5f264f..40ae42e9b6a6 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -215,7 +215,10 @@ int crypto_register_alg(struct crypto_alg *alg)
215 if (alg->cra_alignmask & (alg->cra_alignmask + 1)) 215 if (alg->cra_alignmask & (alg->cra_alignmask + 1))
216 return -EINVAL; 216 return -EINVAL;
217 217
218 if (alg->cra_alignmask > PAGE_SIZE) 218 if (alg->cra_alignmask & alg->cra_blocksize)
219 return -EINVAL;
220
221 if (alg->cra_blocksize > PAGE_SIZE)
219 return -EINVAL; 222 return -EINVAL;
220 223
221 down_write(&crypto_alg_sem); 224 down_write(&crypto_alg_sem);
diff --git a/crypto/hmac.c b/crypto/hmac.c
index da0456b37109..46120dee5ada 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -18,18 +18,15 @@
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/highmem.h> 19#include <linux/highmem.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <asm/scatterlist.h> 21#include <linux/scatterlist.h>
22#include "internal.h" 22#include "internal.h"
23 23
24static void hash_key(struct crypto_tfm *tfm, u8 *key, unsigned int keylen) 24static void hash_key(struct crypto_tfm *tfm, u8 *key, unsigned int keylen)
25{ 25{
26 struct scatterlist tmp; 26 struct scatterlist tmp;
27 27
28 tmp.page = virt_to_page(key); 28 sg_set_buf(&tmp, key, keylen);
29 tmp.offset = offset_in_page(key);
30 tmp.length = keylen;
31 crypto_digest_digest(tfm, &tmp, 1, key); 29 crypto_digest_digest(tfm, &tmp, 1, key);
32
33} 30}
34 31
35int crypto_alloc_hmac_block(struct crypto_tfm *tfm) 32int crypto_alloc_hmac_block(struct crypto_tfm *tfm)
@@ -69,9 +66,7 @@ void crypto_hmac_init(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen)
69 for (i = 0; i < crypto_tfm_alg_blocksize(tfm); i++) 66 for (i = 0; i < crypto_tfm_alg_blocksize(tfm); i++)
70 ipad[i] ^= 0x36; 67 ipad[i] ^= 0x36;
71 68
72 tmp.page = virt_to_page(ipad); 69 sg_set_buf(&tmp, ipad, crypto_tfm_alg_blocksize(tfm));
73 tmp.offset = offset_in_page(ipad);
74 tmp.length = crypto_tfm_alg_blocksize(tfm);
75 70
76 crypto_digest_init(tfm); 71 crypto_digest_init(tfm);
77 crypto_digest_update(tfm, &tmp, 1); 72 crypto_digest_update(tfm, &tmp, 1);
@@ -103,16 +98,12 @@ void crypto_hmac_final(struct crypto_tfm *tfm, u8 *key,
103 for (i = 0; i < crypto_tfm_alg_blocksize(tfm); i++) 98 for (i = 0; i < crypto_tfm_alg_blocksize(tfm); i++)
104 opad[i] ^= 0x5c; 99 opad[i] ^= 0x5c;
105 100
106 tmp.page = virt_to_page(opad); 101 sg_set_buf(&tmp, opad, crypto_tfm_alg_blocksize(tfm));
107 tmp.offset = offset_in_page(opad);
108 tmp.length = crypto_tfm_alg_blocksize(tfm);
109 102
110 crypto_digest_init(tfm); 103 crypto_digest_init(tfm);
111 crypto_digest_update(tfm, &tmp, 1); 104 crypto_digest_update(tfm, &tmp, 1);
112 105
113 tmp.page = virt_to_page(out); 106 sg_set_buf(&tmp, out, crypto_tfm_alg_digestsize(tfm));
114 tmp.offset = offset_in_page(out);
115 tmp.length = crypto_tfm_alg_digestsize(tfm);
116 107
117 crypto_digest_update(tfm, &tmp, 1); 108 crypto_digest_update(tfm, &tmp, 1);
118 crypto_digest_final(tfm, out); 109 crypto_digest_final(tfm, out);
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 68639419c5bd..53f4ee804bdb 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -21,7 +21,7 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <asm/scatterlist.h> 24#include <linux/scatterlist.h>
25#include <linux/string.h> 25#include <linux/string.h>
26#include <linux/crypto.h> 26#include <linux/crypto.h>
27#include <linux/highmem.h> 27#include <linux/highmem.h>
@@ -86,7 +86,6 @@ static void hexdump(unsigned char *buf, unsigned int len)
86static void test_hash(char *algo, struct hash_testvec *template, 86static void test_hash(char *algo, struct hash_testvec *template,
87 unsigned int tcount) 87 unsigned int tcount)
88{ 88{
89 char *p;
90 unsigned int i, j, k, temp; 89 unsigned int i, j, k, temp;
91 struct scatterlist sg[8]; 90 struct scatterlist sg[8];
92 char result[64]; 91 char result[64];
@@ -116,10 +115,7 @@ static void test_hash(char *algo, struct hash_testvec *template,
116 printk("test %u:\n", i + 1); 115 printk("test %u:\n", i + 1);
117 memset(result, 0, 64); 116 memset(result, 0, 64);
118 117
119 p = hash_tv[i].plaintext; 118 sg_set_buf(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize);
120 sg[0].page = virt_to_page(p);
121 sg[0].offset = offset_in_page(p);
122 sg[0].length = hash_tv[i].psize;
123 119
124 crypto_digest_init(tfm); 120 crypto_digest_init(tfm);
125 if (tfm->crt_u.digest.dit_setkey) { 121 if (tfm->crt_u.digest.dit_setkey) {
@@ -154,10 +150,8 @@ static void test_hash(char *algo, struct hash_testvec *template,
154 hash_tv[i].plaintext + temp, 150 hash_tv[i].plaintext + temp,
155 hash_tv[i].tap[k]); 151 hash_tv[i].tap[k]);
156 temp += hash_tv[i].tap[k]; 152 temp += hash_tv[i].tap[k];
157 p = &xbuf[IDX[k]]; 153 sg_set_buf(&sg[k], &xbuf[IDX[k]],
158 sg[k].page = virt_to_page(p); 154 hash_tv[i].tap[k]);
159 sg[k].offset = offset_in_page(p);
160 sg[k].length = hash_tv[i].tap[k];
161 } 155 }
162 156
163 crypto_digest_digest(tfm, sg, hash_tv[i].np, result); 157 crypto_digest_digest(tfm, sg, hash_tv[i].np, result);
@@ -179,7 +173,6 @@ static void test_hash(char *algo, struct hash_testvec *template,
179static void test_hmac(char *algo, struct hmac_testvec *template, 173static void test_hmac(char *algo, struct hmac_testvec *template,
180 unsigned int tcount) 174 unsigned int tcount)
181{ 175{
182 char *p;
183 unsigned int i, j, k, temp; 176 unsigned int i, j, k, temp;
184 struct scatterlist sg[8]; 177 struct scatterlist sg[8];
185 char result[64]; 178 char result[64];
@@ -210,11 +203,8 @@ static void test_hmac(char *algo, struct hmac_testvec *template,
210 printk("test %u:\n", i + 1); 203 printk("test %u:\n", i + 1);
211 memset(result, 0, sizeof (result)); 204 memset(result, 0, sizeof (result));
212 205
213 p = hmac_tv[i].plaintext;
214 klen = hmac_tv[i].ksize; 206 klen = hmac_tv[i].ksize;
215 sg[0].page = virt_to_page(p); 207 sg_set_buf(&sg[0], hmac_tv[i].plaintext, hmac_tv[i].psize);
216 sg[0].offset = offset_in_page(p);
217 sg[0].length = hmac_tv[i].psize;
218 208
219 crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, 1, result); 209 crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, 1, result);
220 210
@@ -243,10 +233,8 @@ static void test_hmac(char *algo, struct hmac_testvec *template,
243 hmac_tv[i].plaintext + temp, 233 hmac_tv[i].plaintext + temp,
244 hmac_tv[i].tap[k]); 234 hmac_tv[i].tap[k]);
245 temp += hmac_tv[i].tap[k]; 235 temp += hmac_tv[i].tap[k];
246 p = &xbuf[IDX[k]]; 236 sg_set_buf(&sg[k], &xbuf[IDX[k]],
247 sg[k].page = virt_to_page(p); 237 hmac_tv[i].tap[k]);
248 sg[k].offset = offset_in_page(p);
249 sg[k].length = hmac_tv[i].tap[k];
250 } 238 }
251 239
252 crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, 240 crypto_hmac(tfm, hmac_tv[i].key, &klen, sg,
@@ -270,7 +258,7 @@ static void test_cipher(char *algo, int mode, int enc,
270{ 258{
271 unsigned int ret, i, j, k, temp; 259 unsigned int ret, i, j, k, temp;
272 unsigned int tsize; 260 unsigned int tsize;
273 char *p, *q; 261 char *q;
274 struct crypto_tfm *tfm; 262 struct crypto_tfm *tfm;
275 char *key; 263 char *key;
276 struct cipher_testvec *cipher_tv; 264 struct cipher_testvec *cipher_tv;
@@ -330,10 +318,8 @@ static void test_cipher(char *algo, int mode, int enc,
330 goto out; 318 goto out;
331 } 319 }
332 320
333 p = cipher_tv[i].input; 321 sg_set_buf(&sg[0], cipher_tv[i].input,
334 sg[0].page = virt_to_page(p); 322 cipher_tv[i].ilen);
335 sg[0].offset = offset_in_page(p);
336 sg[0].length = cipher_tv[i].ilen;
337 323
338 if (!mode) { 324 if (!mode) {
339 crypto_cipher_set_iv(tfm, cipher_tv[i].iv, 325 crypto_cipher_set_iv(tfm, cipher_tv[i].iv,
@@ -389,10 +375,8 @@ static void test_cipher(char *algo, int mode, int enc,
389 cipher_tv[i].input + temp, 375 cipher_tv[i].input + temp,
390 cipher_tv[i].tap[k]); 376 cipher_tv[i].tap[k]);
391 temp += cipher_tv[i].tap[k]; 377 temp += cipher_tv[i].tap[k];
392 p = &xbuf[IDX[k]]; 378 sg_set_buf(&sg[k], &xbuf[IDX[k]],
393 sg[k].page = virt_to_page(p); 379 cipher_tv[i].tap[k]);
394 sg[k].offset = offset_in_page(p);
395 sg[k].length = cipher_tv[i].tap[k];
396 } 380 }
397 381
398 if (!mode) { 382 if (!mode) {
@@ -431,14 +415,12 @@ out:
431static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p, 415static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p,
432 int blen, int sec) 416 int blen, int sec)
433{ 417{
434 struct scatterlist sg[8]; 418 struct scatterlist sg[1];
435 unsigned long start, end; 419 unsigned long start, end;
436 int bcount; 420 int bcount;
437 int ret; 421 int ret;
438 422
439 sg[0].page = virt_to_page(p); 423 sg_set_buf(sg, p, blen);
440 sg[0].offset = offset_in_page(p);
441 sg[0].length = blen;
442 424
443 for (start = jiffies, end = start + sec * HZ, bcount = 0; 425 for (start = jiffies, end = start + sec * HZ, bcount = 0;
444 time_before(jiffies, end); bcount++) { 426 time_before(jiffies, end); bcount++) {
@@ -459,14 +441,12 @@ static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p,
459static int test_cipher_cycles(struct crypto_tfm *tfm, int enc, char *p, 441static int test_cipher_cycles(struct crypto_tfm *tfm, int enc, char *p,
460 int blen) 442 int blen)
461{ 443{
462 struct scatterlist sg[8]; 444 struct scatterlist sg[1];
463 unsigned long cycles = 0; 445 unsigned long cycles = 0;
464 int ret = 0; 446 int ret = 0;
465 int i; 447 int i;
466 448
467 sg[0].page = virt_to_page(p); 449 sg_set_buf(sg, p, blen);
468 sg[0].offset = offset_in_page(p);
469 sg[0].length = blen;
470 450
471 local_bh_disable(); 451 local_bh_disable();
472 local_irq_disable(); 452 local_irq_disable();
@@ -709,9 +689,7 @@ static void test_crc32c(void)
709 for (i = 0; i < NUMVEC; i++) { 689 for (i = 0; i < NUMVEC; i++) {
710 for (j = 0; j < VECSIZE; j++) 690 for (j = 0; j < VECSIZE; j++)
711 test_vec[i][j] = ++b; 691 test_vec[i][j] = ++b;
712 sg[i].page = virt_to_page(test_vec[i]); 692 sg_set_buf(&sg[i], test_vec[i], VECSIZE);
713 sg[i].offset = offset_in_page(test_vec[i]);
714 sg[i].length = VECSIZE;
715 } 693 }
716 694
717 seed = SEEDTESTVAL; 695 seed = SEEDTESTVAL;
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 28c1a628621f..cf6631056683 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -15,7 +15,7 @@
15#include <linux/crypto.h> 15#include <linux/crypto.h>
16#include <linux/workqueue.h> 16#include <linux/workqueue.h>
17#include <asm/atomic.h> 17#include <asm/atomic.h>
18#include <asm/scatterlist.h> 18#include <linux/scatterlist.h>
19#include <asm/page.h> 19#include <asm/page.h>
20 20
21#include "dm.h" 21#include "dm.h"
@@ -164,9 +164,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
164 return -ENOMEM; 164 return -ENOMEM;
165 } 165 }
166 166
167 sg.page = virt_to_page(cc->key); 167 sg_set_buf(&sg, cc->key, cc->key_size);
168 sg.offset = offset_in_page(cc->key);
169 sg.length = cc->key_size;
170 crypto_digest_digest(hash_tfm, &sg, 1, salt); 168 crypto_digest_digest(hash_tfm, &sg, 1, salt);
171 crypto_free_tfm(hash_tfm); 169 crypto_free_tfm(hash_tfm);
172 170
@@ -207,14 +205,12 @@ static void crypt_iv_essiv_dtr(struct crypt_config *cc)
207 205
208static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector) 206static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
209{ 207{
210 struct scatterlist sg = { NULL, }; 208 struct scatterlist sg;
211 209
212 memset(iv, 0, cc->iv_size); 210 memset(iv, 0, cc->iv_size);
213 *(u64 *)iv = cpu_to_le64(sector); 211 *(u64 *)iv = cpu_to_le64(sector);
214 212
215 sg.page = virt_to_page(iv); 213 sg_set_buf(&sg, iv, cc->iv_size);
216 sg.offset = offset_in_page(iv);
217 sg.length = cc->iv_size;
218 crypto_cipher_encrypt((struct crypto_tfm *)cc->iv_gen_private, 214 crypto_cipher_encrypt((struct crypto_tfm *)cc->iv_gen_private,
219 &sg, &sg, cc->iv_size); 215 &sg, &sg, cc->iv_size);
220 216
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 4c11699bad91..750c0167539c 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -35,6 +35,7 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/in.h> 36#include <linux/in.h>
37#include <linux/bitops.h> 37#include <linux/bitops.h>
38#include <linux/scatterlist.h>
38#include <asm/io.h> 39#include <asm/io.h>
39#include <asm/system.h> 40#include <asm/system.h>
40 41
@@ -1590,11 +1591,9 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct
1590 aes_counter[12] = (u8)(counter >> 24); 1591 aes_counter[12] = (u8)(counter >> 24);
1591 counter++; 1592 counter++;
1592 memcpy (plain, aes_counter, 16); 1593 memcpy (plain, aes_counter, 16);
1593 sg[0].page = virt_to_page(plain); 1594 sg_set_buf(sg, plain, 16);
1594 sg[0].offset = ((long) plain & ~PAGE_MASK);
1595 sg[0].length = 16;
1596 crypto_cipher_encrypt(tfm, sg, sg, 16); 1595 crypto_cipher_encrypt(tfm, sg, sg, 16);
1597 cipher = kmap(sg[0].page) + sg[0].offset; 1596 cipher = kmap(sg->page) + sg->offset;
1598 for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) { 1597 for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) {
1599 context->coeff[i++] = ntohl(*(u32 *)&cipher[j]); 1598 context->coeff[i++] = ntohl(*(u32 *)&cipher[j]);
1600 j += 4; 1599 j += 4;
diff --git a/drivers/scsi/arm/scsi.h b/drivers/scsi/arm/scsi.h
index 48e1c4d9738b..19937640e2e7 100644
--- a/drivers/scsi/arm/scsi.h
+++ b/drivers/scsi/arm/scsi.h
@@ -10,6 +10,8 @@
10 * Commonly used scsi driver functions. 10 * Commonly used scsi driver functions.
11 */ 11 */
12 12
13#include <linux/scatterlist.h>
14
13#define BELT_AND_BRACES 15#define BELT_AND_BRACES
14 16
15/* 17/*
@@ -22,9 +24,7 @@ static inline int copy_SCp_to_sg(struct scatterlist *sg, Scsi_Pointer *SCp, int
22 24
23 BUG_ON(bufs + 1 > max); 25 BUG_ON(bufs + 1 > max);
24 26
25 sg->page = virt_to_page(SCp->ptr); 27 sg_set_buf(sg, SCp->ptr, SCp->this_residual);
26 sg->offset = offset_in_page(SCp->ptr);
27 sg->length = SCp->this_residual;
28 28
29 if (bufs) 29 if (bufs)
30 memcpy(sg + 1, SCp->buffer + 1, 30 memcpy(sg + 1, SCp->buffer + 1,
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index b1b1c6f01419..5ca97605ff35 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -49,6 +49,7 @@
49#include <linux/suspend.h> 49#include <linux/suspend.h>
50#include <linux/workqueue.h> 50#include <linux/workqueue.h>
51#include <linux/jiffies.h> 51#include <linux/jiffies.h>
52#include <linux/scatterlist.h>
52#include <scsi/scsi.h> 53#include <scsi/scsi.h>
53#include "scsi.h" 54#include "scsi.h"
54#include "scsi_priv.h" 55#include "scsi_priv.h"
@@ -2576,19 +2577,12 @@ void ata_qc_prep(struct ata_queued_cmd *qc)
2576 2577
2577void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) 2578void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
2578{ 2579{
2579 struct scatterlist *sg;
2580
2581 qc->flags |= ATA_QCFLAG_SINGLE; 2580 qc->flags |= ATA_QCFLAG_SINGLE;
2582 2581
2583 memset(&qc->sgent, 0, sizeof(qc->sgent));
2584 qc->sg = &qc->sgent; 2582 qc->sg = &qc->sgent;
2585 qc->n_elem = 1; 2583 qc->n_elem = 1;
2586 qc->buf_virt = buf; 2584 qc->buf_virt = buf;
2587 2585 sg_init_one(qc->sg, buf, buflen);
2588 sg = qc->sg;
2589 sg->page = virt_to_page(buf);
2590 sg->offset = (unsigned long) buf & ~PAGE_MASK;
2591 sg->length = buflen;
2592} 2586}
2593 2587
2594/** 2588/**
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 2d30b46806bf..d86d5c26061d 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -49,6 +49,7 @@ static int sg_version_num = 30533; /* 2 digits for each component */
49#include <linux/seq_file.h> 49#include <linux/seq_file.h>
50#include <linux/blkdev.h> 50#include <linux/blkdev.h>
51#include <linux/delay.h> 51#include <linux/delay.h>
52#include <linux/scatterlist.h>
52 53
53#include "scsi.h" 54#include "scsi.h"
54#include <scsi/scsi_dbg.h> 55#include <scsi/scsi_dbg.h>
@@ -1996,9 +1997,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
1996 if (!p) 1997 if (!p)
1997 break; 1998 break;
1998 } 1999 }
1999 sclp->page = virt_to_page(p); 2000 sg_set_buf(sclp, p, ret_sz);
2000 sclp->offset = offset_in_page(p);
2001 sclp->length = ret_sz;
2002 2001
2003 SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n", 2002 SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n",
2004 k, sg_scatg2virt(sclp), ret_sz)); 2003 k, sg_scatg2virt(sclp), ret_sz));
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 90a96257d6ce..2997f558159b 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -9,7 +9,7 @@
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/moduleparam.h> 11#include <linux/moduleparam.h>
12#include <asm/scatterlist.h> 12#include <linux/scatterlist.h>
13 13
14#include <linux/usb.h> 14#include <linux/usb.h>
15 15
@@ -381,7 +381,6 @@ alloc_sglist (int nents, int max, int vary)
381 sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL); 381 sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL);
382 if (!sg) 382 if (!sg)
383 return NULL; 383 return NULL;
384 memset (sg, 0, nents * sizeof *sg);
385 384
386 for (i = 0; i < nents; i++) { 385 for (i = 0; i < nents; i++) {
387 char *buf; 386 char *buf;
@@ -394,9 +393,7 @@ alloc_sglist (int nents, int max, int vary)
394 memset (buf, 0, size); 393 memset (buf, 0, size);
395 394
396 /* kmalloc pages are always physically contiguous! */ 395 /* kmalloc pages are always physically contiguous! */
397 sg [i].page = virt_to_page (buf); 396 sg_init_one(&sg[i], buf, size);
398 sg [i].offset = offset_in_page (buf);
399 sg [i].length = size;
400 397
401 if (vary) { 398 if (vary) {
402 size += vary; 399 size += vary;
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 7f717e95ae37..66ff545552f7 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -1,14 +1,23 @@
1#ifndef _LINUX_SCATTERLIST_H 1#ifndef _LINUX_SCATTERLIST_H
2#define _LINUX_SCATTERLIST_H 2#define _LINUX_SCATTERLIST_H
3 3
4static inline void sg_init_one(struct scatterlist *sg, 4#include <asm/scatterlist.h>
5 u8 *buf, unsigned int buflen) 5#include <linux/mm.h>
6{ 6#include <linux/string.h>
7 memset(sg, 0, sizeof(*sg));
8 7
8static inline void sg_set_buf(struct scatterlist *sg, void *buf,
9 unsigned int buflen)
10{
9 sg->page = virt_to_page(buf); 11 sg->page = virt_to_page(buf);
10 sg->offset = offset_in_page(buf); 12 sg->offset = offset_in_page(buf);
11 sg->length = buflen; 13 sg->length = buflen;
12} 14}
13 15
16static inline void sg_init_one(struct scatterlist *sg, void *buf,
17 unsigned int buflen)
18{
19 memset(sg, 0, sizeof(*sg));
20 sg_set_buf(sg, buf, buflen);
21}
22
14#endif /* _LINUX_SCATTERLIST_H */ 23#endif /* _LINUX_SCATTERLIST_H */
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index a970b4727ce8..41edc14851e8 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -75,7 +75,7 @@
75#ifdef CONFIG_IPV6_PRIVACY 75#ifdef CONFIG_IPV6_PRIVACY
76#include <linux/random.h> 76#include <linux/random.h>
77#include <linux/crypto.h> 77#include <linux/crypto.h>
78#include <asm/scatterlist.h> 78#include <linux/scatterlist.h>
79#endif 79#endif
80 80
81#include <asm/uaccess.h> 81#include <asm/uaccess.h>
@@ -1217,12 +1217,8 @@ static int __ipv6_regen_rndid(struct inet6_dev *idev)
1217 struct net_device *dev; 1217 struct net_device *dev;
1218 struct scatterlist sg[2]; 1218 struct scatterlist sg[2];
1219 1219
1220 sg[0].page = virt_to_page(idev->entropy); 1220 sg_set_buf(&sg[0], idev->entropy, 8);
1221 sg[0].offset = offset_in_page(idev->entropy); 1221 sg_set_buf(&sg[1], idev->work_eui64, 8);
1222 sg[0].length = 8;
1223 sg[1].page = virt_to_page(idev->work_eui64);
1224 sg[1].offset = offset_in_page(idev->work_eui64);
1225 sg[1].length = 8;
1226 1222
1227 dev = idev->dev; 1223 dev = idev->dev;
1228 1224
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index 3f3d5437f02d..97c981fa6b8e 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -37,7 +37,7 @@
37#include <linux/types.h> 37#include <linux/types.h>
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <asm/scatterlist.h> 40#include <linux/scatterlist.h>
41#include <linux/crypto.h> 41#include <linux/crypto.h>
42#include <linux/highmem.h> 42#include <linux/highmem.h>
43#include <linux/pagemap.h> 43#include <linux/pagemap.h>
@@ -75,9 +75,7 @@ krb5_encrypt(
75 memcpy(local_iv, iv, crypto_tfm_alg_ivsize(tfm)); 75 memcpy(local_iv, iv, crypto_tfm_alg_ivsize(tfm));
76 76
77 memcpy(out, in, length); 77 memcpy(out, in, length);
78 sg[0].page = virt_to_page(out); 78 sg_set_buf(sg, out, length);
79 sg[0].offset = offset_in_page(out);
80 sg[0].length = length;
81 79
82 ret = crypto_cipher_encrypt_iv(tfm, sg, sg, length, local_iv); 80 ret = crypto_cipher_encrypt_iv(tfm, sg, sg, length, local_iv);
83 81
@@ -117,9 +115,7 @@ krb5_decrypt(
117 memcpy(local_iv,iv, crypto_tfm_alg_ivsize(tfm)); 115 memcpy(local_iv,iv, crypto_tfm_alg_ivsize(tfm));
118 116
119 memcpy(out, in, length); 117 memcpy(out, in, length);
120 sg[0].page = virt_to_page(out); 118 sg_set_buf(sg, out, length);
121 sg[0].offset = offset_in_page(out);
122 sg[0].length = length;
123 119
124 ret = crypto_cipher_decrypt_iv(tfm, sg, sg, length, local_iv); 120 ret = crypto_cipher_decrypt_iv(tfm, sg, sg, length, local_iv);
125 121
@@ -132,13 +128,6 @@ out:
132 128
133EXPORT_SYMBOL(krb5_decrypt); 129EXPORT_SYMBOL(krb5_decrypt);
134 130
135static void
136buf_to_sg(struct scatterlist *sg, char *ptr, int len) {
137 sg->page = virt_to_page(ptr);
138 sg->offset = offset_in_page(ptr);
139 sg->length = len;
140}
141
142static int 131static int
143process_xdr_buf(struct xdr_buf *buf, int offset, int len, 132process_xdr_buf(struct xdr_buf *buf, int offset, int len,
144 int (*actor)(struct scatterlist *, void *), void *data) 133 int (*actor)(struct scatterlist *, void *), void *data)
@@ -152,7 +141,7 @@ process_xdr_buf(struct xdr_buf *buf, int offset, int len,
152 thislen = buf->head[0].iov_len - offset; 141 thislen = buf->head[0].iov_len - offset;
153 if (thislen > len) 142 if (thislen > len)
154 thislen = len; 143 thislen = len;
155 buf_to_sg(sg, buf->head[0].iov_base + offset, thislen); 144 sg_set_buf(sg, buf->head[0].iov_base + offset, thislen);
156 ret = actor(sg, data); 145 ret = actor(sg, data);
157 if (ret) 146 if (ret)
158 goto out; 147 goto out;
@@ -195,7 +184,7 @@ process_xdr_buf(struct xdr_buf *buf, int offset, int len,
195 thislen = buf->tail[0].iov_len - offset; 184 thislen = buf->tail[0].iov_len - offset;
196 if (thislen > len) 185 if (thislen > len)
197 thislen = len; 186 thislen = len;
198 buf_to_sg(sg, buf->tail[0].iov_base + offset, thislen); 187 sg_set_buf(sg, buf->tail[0].iov_base + offset, thislen);
199 ret = actor(sg, data); 188 ret = actor(sg, data);
200 len -= thislen; 189 len -= thislen;
201 } 190 }
@@ -241,7 +230,7 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
241 goto out; 230 goto out;
242 231
243 crypto_digest_init(tfm); 232 crypto_digest_init(tfm);
244 buf_to_sg(sg, header, hdrlen); 233 sg_set_buf(sg, header, hdrlen);
245 crypto_digest_update(tfm, sg, 1); 234 crypto_digest_update(tfm, sg, 1);
246 process_xdr_buf(body, body_offset, body->len - body_offset, 235 process_xdr_buf(body, body_offset, body->len - body_offset,
247 checksummer, tfm); 236 checksummer, tfm);