aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/connector/connector.c5
-rw-r--r--drivers/net/wan/lmc/lmc_main.c2
-rw-r--r--fs/compat_ioctl.c2
-rw-r--r--include/linux/Kbuild1
-rw-r--r--include/linux/string.h12
-rw-r--r--kernel/sys_ni.c4
-rw-r--r--net/core/dev.c112
-rw-r--r--net/core/net_namespace.c2
-rw-r--r--net/core/skbuff.c16
-rw-r--r--net/ipv4/esp4.c12
-rw-r--r--net/ipv4/ipvs/ip_vs_lblcr.c76
-rw-r--r--net/ipv4/tcp_ipv4.c2
-rw-r--r--net/ipv6/addrconf.c4
-rw-r--r--net/ipv6/esp6.c13
-rw-r--r--net/ipv6/tcp_ipv6.c2
-rw-r--r--net/key/af_key.c4
-rw-r--r--net/rxrpc/rxkad.c9
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c6
18 files changed, 111 insertions, 173 deletions
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 0e328d387af4..6883fcb79ad3 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -218,7 +218,7 @@ static void cn_rx_skb(struct sk_buff *__skb)
218 skb->len < nlh->nlmsg_len || 218 skb->len < nlh->nlmsg_len ||
219 nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) { 219 nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) {
220 kfree_skb(skb); 220 kfree_skb(skb);
221 goto out; 221 return;
222 } 222 }
223 223
224 len = NLMSG_ALIGN(nlh->nlmsg_len); 224 len = NLMSG_ALIGN(nlh->nlmsg_len);
@@ -229,9 +229,6 @@ static void cn_rx_skb(struct sk_buff *__skb)
229 if (err < 0) 229 if (err < 0)
230 kfree_skb(skb); 230 kfree_skb(skb);
231 } 231 }
232
233out:
234 kfree_skb(__skb);
235} 232}
236 233
237/* 234/*
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 64eb57893602..37c52e131750 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -234,7 +234,7 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/
234 sc->lmc_xinfo.Magic1 = 0xDEADBEEF; 234 sc->lmc_xinfo.Magic1 = 0xDEADBEEF;
235 235
236 if (copy_to_user(ifr->ifr_data, &sc->lmc_xinfo, 236 if (copy_to_user(ifr->ifr_data, &sc->lmc_xinfo,
237 sizeof(struct lmc_xinfo))) { 237 sizeof(struct lmc_xinfo)))
238 ret = -EFAULT; 238 ret = -EFAULT;
239 else 239 else
240 ret = 0; 240 ret = 0;
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index a4284ccac1f9..bd26e4cbb994 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -322,7 +322,7 @@ static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
322 int err; 322 int err;
323 323
324 uifr = compat_alloc_user_space(sizeof(struct ifreq)); 324 uifr = compat_alloc_user_space(sizeof(struct ifreq));
325 if (copy_in_user(uifr, compat_ptr(arg), sizeof(struct ifreq32))); 325 if (copy_in_user(uifr, compat_ptr(arg), sizeof(struct ifreq32)))
326 return -EFAULT; 326 return -EFAULT;
327 327
328 err = sys_ioctl(fd, SIOCGIFNAME, (unsigned long)uifr); 328 err = sys_ioctl(fd, SIOCGIFNAME, (unsigned long)uifr);
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index bd33c22315c1..37bfa19d8064 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -326,6 +326,7 @@ unifdef-y += sonypi.h
326unifdef-y += soundcard.h 326unifdef-y += soundcard.h
327unifdef-y += stat.h 327unifdef-y += stat.h
328unifdef-y += stddef.h 328unifdef-y += stddef.h
329unifdef-y += string.h
329unifdef-y += synclink.h 330unifdef-y += synclink.h
330unifdef-y += sysctl.h 331unifdef-y += sysctl.h
331unifdef-y += tcp.h 332unifdef-y += tcp.h
diff --git a/include/linux/string.h b/include/linux/string.h
index 836062b7582a..c5d3fcad7b57 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -3,16 +3,14 @@
3 3
4/* We don't want strings.h stuff being user by user stuff by accident */ 4/* We don't want strings.h stuff being user by user stuff by accident */
5 5
6#ifdef __KERNEL__ 6#ifndef __KERNEL__
7#include <string.h>
8#else
7 9
8#include <linux/compiler.h> /* for inline */ 10#include <linux/compiler.h> /* for inline */
9#include <linux/types.h> /* for size_t */ 11#include <linux/types.h> /* for size_t */
10#include <linux/stddef.h> /* for NULL */ 12#include <linux/stddef.h> /* for NULL */
11 13
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16extern char *strndup_user(const char __user *, long); 14extern char *strndup_user(const char __user *, long);
17 15
18/* 16/*
@@ -111,9 +109,5 @@ extern void *kmemdup(const void *src, size_t len, gfp_t gfp);
111extern char **argv_split(gfp_t gfp, const char *str, int *argcp); 109extern char **argv_split(gfp_t gfp, const char *str, int *argcp);
112extern void argv_free(char **argv); 110extern void argv_free(char **argv);
113 111
114#ifdef __cplusplus
115}
116#endif
117
118#endif 112#endif
119#endif /* _LINUX_STRING_H_ */ 113#endif /* _LINUX_STRING_H_ */
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 52c7a151e298..56cb009a4b35 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -40,10 +40,14 @@ cond_syscall(sys_recvfrom);
40cond_syscall(sys_recv); 40cond_syscall(sys_recv);
41cond_syscall(sys_socket); 41cond_syscall(sys_socket);
42cond_syscall(sys_setsockopt); 42cond_syscall(sys_setsockopt);
43cond_syscall(compat_sys_setsockopt);
43cond_syscall(sys_getsockopt); 44cond_syscall(sys_getsockopt);
45cond_syscall(compat_sys_getsockopt);
44cond_syscall(sys_shutdown); 46cond_syscall(sys_shutdown);
45cond_syscall(sys_sendmsg); 47cond_syscall(sys_sendmsg);
48cond_syscall(compat_sys_sendmsg);
46cond_syscall(sys_recvmsg); 49cond_syscall(sys_recvmsg);
50cond_syscall(compat_sys_recvmsg);
47cond_syscall(sys_socketcall); 51cond_syscall(sys_socketcall);
48cond_syscall(sys_futex); 52cond_syscall(sys_futex);
49cond_syscall(compat_sys_futex); 53cond_syscall(compat_sys_futex);
diff --git a/net/core/dev.c b/net/core/dev.c
index 02e7d8377c4a..91ece48e127e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3496,6 +3496,60 @@ static void net_set_todo(struct net_device *dev)
3496 spin_unlock(&net_todo_list_lock); 3496 spin_unlock(&net_todo_list_lock);
3497} 3497}
3498 3498
3499static void rollback_registered(struct net_device *dev)
3500{
3501 BUG_ON(dev_boot_phase);
3502 ASSERT_RTNL();
3503
3504 /* Some devices call without registering for initialization unwind. */
3505 if (dev->reg_state == NETREG_UNINITIALIZED) {
3506 printk(KERN_DEBUG "unregister_netdevice: device %s/%p never "
3507 "was registered\n", dev->name, dev);
3508
3509 WARN_ON(1);
3510 return;
3511 }
3512
3513 BUG_ON(dev->reg_state != NETREG_REGISTERED);
3514
3515 /* If device is running, close it first. */
3516 dev_close(dev);
3517
3518 /* And unlink it from device chain. */
3519 unlist_netdevice(dev);
3520
3521 dev->reg_state = NETREG_UNREGISTERING;
3522
3523 synchronize_net();
3524
3525 /* Shutdown queueing discipline. */
3526 dev_shutdown(dev);
3527
3528
3529 /* Notify protocols, that we are about to destroy
3530 this device. They should clean all the things.
3531 */
3532 call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
3533
3534 /*
3535 * Flush the unicast and multicast chains
3536 */
3537 dev_addr_discard(dev);
3538
3539 if (dev->uninit)
3540 dev->uninit(dev);
3541
3542 /* Notifier chain MUST detach us from master device. */
3543 BUG_TRAP(!dev->master);
3544
3545 /* Remove entries from kobject tree */
3546 netdev_unregister_kobject(dev);
3547
3548 synchronize_net();
3549
3550 dev_put(dev);
3551}
3552
3499/** 3553/**
3500 * register_netdevice - register a network device 3554 * register_netdevice - register a network device
3501 * @dev: device to register 3555 * @dev: device to register
@@ -3633,8 +3687,10 @@ int register_netdevice(struct net_device *dev)
3633 /* Notify protocols, that a new device appeared. */ 3687 /* Notify protocols, that a new device appeared. */
3634 ret = call_netdevice_notifiers(NETDEV_REGISTER, dev); 3688 ret = call_netdevice_notifiers(NETDEV_REGISTER, dev);
3635 ret = notifier_to_errno(ret); 3689 ret = notifier_to_errno(ret);
3636 if (ret) 3690 if (ret) {
3637 unregister_netdevice(dev); 3691 rollback_registered(dev);
3692 dev->reg_state = NETREG_UNREGISTERED;
3693 }
3638 3694
3639out: 3695out:
3640 return ret; 3696 return ret;
@@ -3911,59 +3967,9 @@ void synchronize_net(void)
3911 3967
3912void unregister_netdevice(struct net_device *dev) 3968void unregister_netdevice(struct net_device *dev)
3913{ 3969{
3914 BUG_ON(dev_boot_phase); 3970 rollback_registered(dev);
3915 ASSERT_RTNL();
3916
3917 /* Some devices call without registering for initialization unwind. */
3918 if (dev->reg_state == NETREG_UNINITIALIZED) {
3919 printk(KERN_DEBUG "unregister_netdevice: device %s/%p never "
3920 "was registered\n", dev->name, dev);
3921
3922 WARN_ON(1);
3923 return;
3924 }
3925
3926 BUG_ON(dev->reg_state != NETREG_REGISTERED);
3927
3928 /* If device is running, close it first. */
3929 dev_close(dev);
3930
3931 /* And unlink it from device chain. */
3932 unlist_netdevice(dev);
3933
3934 dev->reg_state = NETREG_UNREGISTERING;
3935
3936 synchronize_net();
3937
3938 /* Shutdown queueing discipline. */
3939 dev_shutdown(dev);
3940
3941
3942 /* Notify protocols, that we are about to destroy
3943 this device. They should clean all the things.
3944 */
3945 call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
3946
3947 /*
3948 * Flush the unicast and multicast chains
3949 */
3950 dev_addr_discard(dev);
3951
3952 if (dev->uninit)
3953 dev->uninit(dev);
3954
3955 /* Notifier chain MUST detach us from master device. */
3956 BUG_TRAP(!dev->master);
3957
3958 /* Remove entries from kobject tree */
3959 netdev_unregister_kobject(dev);
3960
3961 /* Finish processing unregister after unlock */ 3971 /* Finish processing unregister after unlock */
3962 net_set_todo(dev); 3972 net_set_todo(dev);
3963
3964 synchronize_net();
3965
3966 dev_put(dev);
3967} 3973}
3968 3974
3969/** 3975/**
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 6f71db8c4428..662e6ea1cecf 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -112,6 +112,8 @@ out_undo:
112 if (ops->exit) 112 if (ops->exit)
113 ops->exit(net); 113 ops->exit(net);
114 } 114 }
115
116 rcu_barrier();
115 goto out; 117 goto out;
116} 118}
117 119
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 573e17240197..64b50ff7a413 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2028,8 +2028,8 @@ void __init skb_init(void)
2028 * Fill the specified scatter-gather list with mappings/pointers into a 2028 * Fill the specified scatter-gather list with mappings/pointers into a
2029 * region of the buffer space attached to a socket buffer. 2029 * region of the buffer space attached to a socket buffer.
2030 */ 2030 */
2031int 2031static int
2032skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len) 2032__skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2033{ 2033{
2034 int start = skb_headlen(skb); 2034 int start = skb_headlen(skb);
2035 int i, copy = start - offset; 2035 int i, copy = start - offset;
@@ -2078,7 +2078,8 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2078 if ((copy = end - offset) > 0) { 2078 if ((copy = end - offset) > 0) {
2079 if (copy > len) 2079 if (copy > len)
2080 copy = len; 2080 copy = len;
2081 elt += skb_to_sgvec(list, sg+elt, offset - start, copy); 2081 elt += __skb_to_sgvec(list, sg+elt, offset - start,
2082 copy);
2082 if ((len -= copy) == 0) 2083 if ((len -= copy) == 0)
2083 return elt; 2084 return elt;
2084 offset += copy; 2085 offset += copy;
@@ -2090,6 +2091,15 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2090 return elt; 2091 return elt;
2091} 2092}
2092 2093
2094int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2095{
2096 int nsg = __skb_to_sgvec(skb, sg, offset, len);
2097
2098 __sg_mark_end(&sg[nsg - 1]);
2099
2100 return nsg;
2101}
2102
2093/** 2103/**
2094 * skb_cow_data - Check that a socket buffer's data buffers are writable 2104 * skb_cow_data - Check that a socket buffer's data buffers are writable
2095 * @skb: The socket buffer to check. 2105 * @skb: The socket buffer to check.
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index cad4278025ad..c31bccb9b526 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -111,9 +111,10 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
111 goto unlock; 111 goto unlock;
112 } 112 }
113 sg_init_table(sg, nfrags); 113 sg_init_table(sg, nfrags);
114 sg_mark_end(sg, skb_to_sgvec(skb, sg, esph->enc_data + 114 skb_to_sgvec(skb, sg,
115 esp->conf.ivlen - 115 esph->enc_data +
116 skb->data, clen)); 116 esp->conf.ivlen -
117 skb->data, clen);
117 err = crypto_blkcipher_encrypt(&desc, sg, sg, clen); 118 err = crypto_blkcipher_encrypt(&desc, sg, sg, clen);
118 if (unlikely(sg != &esp->sgbuf[0])) 119 if (unlikely(sg != &esp->sgbuf[0]))
119 kfree(sg); 120 kfree(sg);
@@ -205,8 +206,9 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
205 goto out; 206 goto out;
206 } 207 }
207 sg_init_table(sg, nfrags); 208 sg_init_table(sg, nfrags);
208 sg_mark_end(sg, skb_to_sgvec(skb, sg, sizeof(*esph) + esp->conf.ivlen, 209 skb_to_sgvec(skb, sg,
209 elen)); 210 sizeof(*esph) + esp->conf.ivlen,
211 elen);
210 err = crypto_blkcipher_decrypt(&desc, sg, sg, elen); 212 err = crypto_blkcipher_decrypt(&desc, sg, sg, elen);
211 if (unlikely(sg != &esp->sgbuf[0])) 213 if (unlikely(sg != &esp->sgbuf[0]))
212 kfree(sg); 214 kfree(sg);
diff --git a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c
index 6a1fec416eaf..427b593c1069 100644
--- a/net/ipv4/ipvs/ip_vs_lblcr.c
+++ b/net/ipv4/ipvs/ip_vs_lblcr.c
@@ -48,8 +48,6 @@
48/* for sysctl */ 48/* for sysctl */
49#include <linux/fs.h> 49#include <linux/fs.h>
50#include <linux/sysctl.h> 50#include <linux/sysctl.h>
51/* for proc_net_create/proc_net_remove */
52#include <linux/proc_fs.h>
53#include <net/net_namespace.h> 51#include <net/net_namespace.h>
54 52
55#include <net/ip_vs.h> 53#include <net/ip_vs.h>
@@ -547,71 +545,6 @@ static void ip_vs_lblcr_check_expire(unsigned long data)
547 mod_timer(&tbl->periodic_timer, jiffies+CHECK_EXPIRE_INTERVAL); 545 mod_timer(&tbl->periodic_timer, jiffies+CHECK_EXPIRE_INTERVAL);
548} 546}
549 547
550
551#ifdef CONFIG_IP_VS_LBLCR_DEBUG
552static struct ip_vs_lblcr_table *lblcr_table_list;
553
554/*
555 * /proc/net/ip_vs_lblcr to display the mappings of
556 * destination IP address <==> its serverSet
557 */
558static int
559ip_vs_lblcr_getinfo(char *buffer, char **start, off_t offset, int length)
560{
561 off_t pos=0, begin;
562 int len=0, size;
563 struct ip_vs_lblcr_table *tbl;
564 unsigned long now = jiffies;
565 int i;
566 struct ip_vs_lblcr_entry *en;
567
568 tbl = lblcr_table_list;
569
570 size = sprintf(buffer, "LastTime Dest IP address Server set\n");
571 pos += size;
572 len += size;
573
574 for (i=0; i<IP_VS_LBLCR_TAB_SIZE; i++) {
575 read_lock_bh(&tbl->lock);
576 list_for_each_entry(en, &tbl->bucket[i], list) {
577 char tbuf[16];
578 struct ip_vs_dest_list *d;
579
580 sprintf(tbuf, "%u.%u.%u.%u", NIPQUAD(en->addr));
581 size = sprintf(buffer+len, "%8lu %-16s ",
582 now-en->lastuse, tbuf);
583
584 read_lock(&en->set.lock);
585 for (d=en->set.list; d!=NULL; d=d->next) {
586 size += sprintf(buffer+len+size,
587 "%u.%u.%u.%u ",
588 NIPQUAD(d->dest->addr));
589 }
590 read_unlock(&en->set.lock);
591 size += sprintf(buffer+len+size, "\n");
592 len += size;
593 pos += size;
594 if (pos <= offset)
595 len=0;
596 if (pos >= offset+length) {
597 read_unlock_bh(&tbl->lock);
598 goto done;
599 }
600 }
601 read_unlock_bh(&tbl->lock);
602 }
603
604 done:
605 begin = len - (pos - offset);
606 *start = buffer + begin;
607 len -= begin;
608 if(len>length)
609 len = length;
610 return len;
611}
612#endif
613
614
615static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc) 548static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc)
616{ 549{
617 int i; 550 int i;
@@ -650,9 +583,6 @@ static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc)
650 tbl->periodic_timer.expires = jiffies+CHECK_EXPIRE_INTERVAL; 583 tbl->periodic_timer.expires = jiffies+CHECK_EXPIRE_INTERVAL;
651 add_timer(&tbl->periodic_timer); 584 add_timer(&tbl->periodic_timer);
652 585
653#ifdef CONFIG_IP_VS_LBLCR_DEBUG
654 lblcr_table_list = tbl;
655#endif
656 return 0; 586 return 0;
657} 587}
658 588
@@ -843,18 +773,12 @@ static int __init ip_vs_lblcr_init(void)
843{ 773{
844 INIT_LIST_HEAD(&ip_vs_lblcr_scheduler.n_list); 774 INIT_LIST_HEAD(&ip_vs_lblcr_scheduler.n_list);
845 sysctl_header = register_sysctl_table(lblcr_root_table); 775 sysctl_header = register_sysctl_table(lblcr_root_table);
846#ifdef CONFIG_IP_VS_LBLCR_DEBUG
847 proc_net_create(&init_net, "ip_vs_lblcr", 0, ip_vs_lblcr_getinfo);
848#endif
849 return register_ip_vs_scheduler(&ip_vs_lblcr_scheduler); 776 return register_ip_vs_scheduler(&ip_vs_lblcr_scheduler);
850} 777}
851 778
852 779
853static void __exit ip_vs_lblcr_cleanup(void) 780static void __exit ip_vs_lblcr_cleanup(void)
854{ 781{
855#ifdef CONFIG_IP_VS_LBLCR_DEBUG
856 proc_net_remove(&init_net, "ip_vs_lblcr");
857#endif
858 unregister_sysctl_table(sysctl_header); 782 unregister_sysctl_table(sysctl_header);
859 unregister_ip_vs_scheduler(&ip_vs_lblcr_scheduler); 783 unregister_ip_vs_scheduler(&ip_vs_lblcr_scheduler);
860} 784}
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index d3d8d5dfcee3..eec02b29ffcf 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1083,7 +1083,7 @@ static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key,
1083 sg_set_buf(&sg[block++], key->key, key->keylen); 1083 sg_set_buf(&sg[block++], key->key, key->keylen);
1084 nbytes += key->keylen; 1084 nbytes += key->keylen;
1085 1085
1086 sg_mark_end(sg, block); 1086 __sg_mark_end(&sg[block - 1]);
1087 1087
1088 /* Now store the Hash into the packet */ 1088 /* Now store the Hash into the packet */
1089 err = crypto_hash_init(desc); 1089 err = crypto_hash_init(desc);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 348bd8d06112..1bd8d818f8e9 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4288,8 +4288,4 @@ void __exit addrconf_cleanup(void)
4288 del_timer(&addr_chk_timer); 4288 del_timer(&addr_chk_timer);
4289 4289
4290 rtnl_unlock(); 4290 rtnl_unlock();
4291
4292#ifdef CONFIG_PROC_FS
4293 proc_net_remove(&init_net, "if_inet6");
4294#endif
4295} 4291}
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index ab17b5e62355..7db66f10e00d 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -110,9 +110,10 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
110 goto unlock; 110 goto unlock;
111 } 111 }
112 sg_init_table(sg, nfrags); 112 sg_init_table(sg, nfrags);
113 sg_mark_end(sg, skb_to_sgvec(skb, sg, esph->enc_data + 113 skb_to_sgvec(skb, sg,
114 esp->conf.ivlen - 114 esph->enc_data +
115 skb->data, clen)); 115 esp->conf.ivlen -
116 skb->data, clen);
116 err = crypto_blkcipher_encrypt(&desc, sg, sg, clen); 117 err = crypto_blkcipher_encrypt(&desc, sg, sg, clen);
117 if (unlikely(sg != &esp->sgbuf[0])) 118 if (unlikely(sg != &esp->sgbuf[0]))
118 kfree(sg); 119 kfree(sg);
@@ -209,9 +210,9 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
209 } 210 }
210 } 211 }
211 sg_init_table(sg, nfrags); 212 sg_init_table(sg, nfrags);
212 sg_mark_end(sg, skb_to_sgvec(skb, sg, 213 skb_to_sgvec(skb, sg,
213 sizeof(*esph) + esp->conf.ivlen, 214 sizeof(*esph) + esp->conf.ivlen,
214 elen)); 215 elen);
215 ret = crypto_blkcipher_decrypt(&desc, sg, sg, elen); 216 ret = crypto_blkcipher_decrypt(&desc, sg, sg, elen);
216 if (unlikely(sg != &esp->sgbuf[0])) 217 if (unlikely(sg != &esp->sgbuf[0]))
217 kfree(sg); 218 kfree(sg);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index f1523b82cac1..4b9032880959 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -781,7 +781,7 @@ static int tcp_v6_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key,
781 sg_set_buf(&sg[block++], key->key, key->keylen); 781 sg_set_buf(&sg[block++], key->key, key->keylen);
782 nbytes += key->keylen; 782 nbytes += key->keylen;
783 783
784 sg_mark_end(sg, block); 784 __sg_mark_end(&sg[block - 1]);
785 785
786 /* Now store the hash into the packet */ 786 /* Now store the hash into the packet */
787 err = crypto_hash_init(desc); 787 err = crypto_hash_init(desc);
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 7969f8a716df..266f112c38c2 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -395,9 +395,9 @@ static inline int pfkey_sec_ctx_len(struct sadb_x_sec_ctx *sec_ctx)
395static inline int verify_sec_ctx_len(void *p) 395static inline int verify_sec_ctx_len(void *p)
396{ 396{
397 struct sadb_x_sec_ctx *sec_ctx = (struct sadb_x_sec_ctx *)p; 397 struct sadb_x_sec_ctx *sec_ctx = (struct sadb_x_sec_ctx *)p;
398 int len; 398 int len = sec_ctx->sadb_x_ctx_len;
399 399
400 if (sec_ctx->sadb_x_ctx_len > PAGE_SIZE) 400 if (len > PAGE_SIZE)
401 return -EINVAL; 401 return -EINVAL;
402 402
403 len = pfkey_sec_ctx_len(sec_ctx); 403 len = pfkey_sec_ctx_len(sec_ctx);
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index eebefb6ef139..c387cf68a08c 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -237,7 +237,8 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call,
237 len = data_size + call->conn->size_align - 1; 237 len = data_size + call->conn->size_align - 1;
238 len &= ~(call->conn->size_align - 1); 238 len &= ~(call->conn->size_align - 1);
239 239
240 sg_init_table(sg, skb_to_sgvec(skb, sg, 0, len)); 240 sg_init_table(sg, nsg);
241 skb_to_sgvec(skb, sg, 0, len);
241 crypto_blkcipher_encrypt_iv(&desc, sg, sg, len); 242 crypto_blkcipher_encrypt_iv(&desc, sg, sg, len);
242 243
243 _leave(" = 0"); 244 _leave(" = 0");
@@ -344,7 +345,7 @@ static int rxkad_verify_packet_auth(const struct rxrpc_call *call,
344 goto nomem; 345 goto nomem;
345 346
346 sg_init_table(sg, nsg); 347 sg_init_table(sg, nsg);
347 sg_mark_end(sg, skb_to_sgvec(skb, sg, 0, 8)); 348 skb_to_sgvec(skb, sg, 0, 8);
348 349
349 /* start the decryption afresh */ 350 /* start the decryption afresh */
350 memset(&iv, 0, sizeof(iv)); 351 memset(&iv, 0, sizeof(iv));
@@ -426,7 +427,7 @@ static int rxkad_verify_packet_encrypt(const struct rxrpc_call *call,
426 } 427 }
427 428
428 sg_init_table(sg, nsg); 429 sg_init_table(sg, nsg);
429 sg_mark_end(sg, skb_to_sgvec(skb, sg, 0, skb->len)); 430 skb_to_sgvec(skb, sg, 0, skb->len);
430 431
431 /* decrypt from the session key */ 432 /* decrypt from the session key */
432 payload = call->conn->key->payload.data; 433 payload = call->conn->key->payload.data;
@@ -701,7 +702,7 @@ static void rxkad_sg_set_buf2(struct scatterlist sg[2],
701 nsg++; 702 nsg++;
702 } 703 }
703 704
704 sg_mark_end(sg, nsg); 705 __sg_mark_end(&sg[nsg - 1]);
705 706
706 ASSERTCMP(sg[0].length + sg[1].length, ==, buflen); 707 ASSERTCMP(sg[0].length + sg[1].length, ==, buflen);
707} 708}
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index 91cd8f0d1e10..ab7cbd6575c4 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -211,8 +211,8 @@ encryptor(struct scatterlist *sg, void *data)
211 if (thislen == 0) 211 if (thislen == 0)
212 return 0; 212 return 0;
213 213
214 sg_mark_end(desc->infrags, desc->fragno); 214 __sg_mark_end(&desc->infrags[desc->fragno - 1]);
215 sg_mark_end(desc->outfrags, desc->fragno); 215 __sg_mark_end(&desc->outfrags[desc->fragno - 1]);
216 216
217 ret = crypto_blkcipher_encrypt_iv(&desc->desc, desc->outfrags, 217 ret = crypto_blkcipher_encrypt_iv(&desc->desc, desc->outfrags,
218 desc->infrags, thislen); 218 desc->infrags, thislen);
@@ -293,7 +293,7 @@ decryptor(struct scatterlist *sg, void *data)
293 if (thislen == 0) 293 if (thislen == 0)
294 return 0; 294 return 0;
295 295
296 sg_mark_end(desc->frags, desc->fragno); 296 __sg_mark_end(&desc->frags[desc->fragno - 1]);
297 297
298 ret = crypto_blkcipher_decrypt_iv(&desc->desc, desc->frags, 298 ret = crypto_blkcipher_decrypt_iv(&desc->desc, desc->frags,
299 desc->frags, thislen); 299 desc->frags, thislen);