aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/sungem_phy.c11
-rw-r--r--include/linux/skbuff.h7
-rw-r--r--include/net/sock.h1
-rw-r--r--net/bridge/netfilter/ebtables.c20
-rw-r--r--net/core/skbuff.c8
-rw-r--r--net/core/stream.c1
-rw-r--r--net/ipv4/tcp_output.c10
-rw-r--r--net/llc/llc_input.c3
-rw-r--r--net/socket.c1
9 files changed, 40 insertions, 22 deletions
diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c
index cb0aba95d4e3..046371ee5bbe 100644
--- a/drivers/net/sungem_phy.c
+++ b/drivers/net/sungem_phy.c
@@ -275,7 +275,7 @@ static int bcm5411_init(struct mii_phy* phy)
275 return 0; 275 return 0;
276} 276}
277 277
278static int bcm5411_suspend(struct mii_phy* phy) 278static int generic_suspend(struct mii_phy* phy)
279{ 279{
280 phy_write(phy, MII_BMCR, BMCR_PDOWN); 280 phy_write(phy, MII_BMCR, BMCR_PDOWN);
281 281
@@ -738,7 +738,7 @@ static struct mii_phy_def bcm5401_phy_def = {
738/* Broadcom BCM 5411 */ 738/* Broadcom BCM 5411 */
739static struct mii_phy_ops bcm5411_phy_ops = { 739static struct mii_phy_ops bcm5411_phy_ops = {
740 .init = bcm5411_init, 740 .init = bcm5411_init,
741 .suspend = bcm5411_suspend, 741 .suspend = generic_suspend,
742 .setup_aneg = bcm54xx_setup_aneg, 742 .setup_aneg = bcm54xx_setup_aneg,
743 .setup_forced = bcm54xx_setup_forced, 743 .setup_forced = bcm54xx_setup_forced,
744 .poll_link = genmii_poll_link, 744 .poll_link = genmii_poll_link,
@@ -757,7 +757,7 @@ static struct mii_phy_def bcm5411_phy_def = {
757/* Broadcom BCM 5421 */ 757/* Broadcom BCM 5421 */
758static struct mii_phy_ops bcm5421_phy_ops = { 758static struct mii_phy_ops bcm5421_phy_ops = {
759 .init = bcm5421_init, 759 .init = bcm5421_init,
760 .suspend = bcm5411_suspend, 760 .suspend = generic_suspend,
761 .setup_aneg = bcm54xx_setup_aneg, 761 .setup_aneg = bcm54xx_setup_aneg,
762 .setup_forced = bcm54xx_setup_forced, 762 .setup_forced = bcm54xx_setup_forced,
763 .poll_link = genmii_poll_link, 763 .poll_link = genmii_poll_link,
@@ -776,7 +776,7 @@ static struct mii_phy_def bcm5421_phy_def = {
776/* Broadcom BCM 5421 built-in K2 */ 776/* Broadcom BCM 5421 built-in K2 */
777static struct mii_phy_ops bcm5421k2_phy_ops = { 777static struct mii_phy_ops bcm5421k2_phy_ops = {
778 .init = bcm5421_init, 778 .init = bcm5421_init,
779 .suspend = bcm5411_suspend, 779 .suspend = generic_suspend,
780 .setup_aneg = bcm54xx_setup_aneg, 780 .setup_aneg = bcm54xx_setup_aneg,
781 .setup_forced = bcm54xx_setup_forced, 781 .setup_forced = bcm54xx_setup_forced,
782 .poll_link = genmii_poll_link, 782 .poll_link = genmii_poll_link,
@@ -795,7 +795,7 @@ static struct mii_phy_def bcm5421k2_phy_def = {
795/* Broadcom BCM 5462 built-in Vesta */ 795/* Broadcom BCM 5462 built-in Vesta */
796static struct mii_phy_ops bcm5462V_phy_ops = { 796static struct mii_phy_ops bcm5462V_phy_ops = {
797 .init = bcm5421_init, 797 .init = bcm5421_init,
798 .suspend = bcm5411_suspend, 798 .suspend = generic_suspend,
799 .setup_aneg = bcm54xx_setup_aneg, 799 .setup_aneg = bcm54xx_setup_aneg,
800 .setup_forced = bcm54xx_setup_forced, 800 .setup_forced = bcm54xx_setup_forced,
801 .poll_link = genmii_poll_link, 801 .poll_link = genmii_poll_link,
@@ -816,6 +816,7 @@ static struct mii_phy_def bcm5462V_phy_def = {
816 * would be useful here) --BenH. 816 * would be useful here) --BenH.
817 */ 817 */
818static struct mii_phy_ops marvell_phy_ops = { 818static struct mii_phy_ops marvell_phy_ops = {
819 .suspend = generic_suspend,
819 .setup_aneg = marvell_setup_aneg, 820 .setup_aneg = marvell_setup_aneg,
820 .setup_forced = marvell_setup_forced, 821 .setup_forced = marvell_setup_forced,
821 .poll_link = genmii_poll_link, 822 .poll_link = genmii_poll_link,
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c4619a428d9b..f8f234708b98 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -344,6 +344,13 @@ extern void skb_over_panic(struct sk_buff *skb, int len,
344 void *here); 344 void *here);
345extern void skb_under_panic(struct sk_buff *skb, int len, 345extern void skb_under_panic(struct sk_buff *skb, int len,
346 void *here); 346 void *here);
347extern void skb_truesize_bug(struct sk_buff *skb);
348
349static inline void skb_truesize_check(struct sk_buff *skb)
350{
351 if (unlikely((int)skb->truesize < sizeof(struct sk_buff) + skb->len))
352 skb_truesize_bug(skb);
353}
347 354
348extern int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb, 355extern int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
349 int getfrag(void *from, char *to, int offset, 356 int getfrag(void *from, char *to, int offset,
diff --git a/include/net/sock.h b/include/net/sock.h
index af2b0544586e..ff8b0dad7b0f 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -454,6 +454,7 @@ static inline void sk_stream_set_owner_r(struct sk_buff *skb, struct sock *sk)
454 454
455static inline void sk_stream_free_skb(struct sock *sk, struct sk_buff *skb) 455static inline void sk_stream_free_skb(struct sock *sk, struct sk_buff *skb)
456{ 456{
457 skb_truesize_check(skb);
457 sock_set_flag(sk, SOCK_QUEUE_SHRUNK); 458 sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
458 sk->sk_wmem_queued -= skb->truesize; 459 sk->sk_wmem_queued -= skb->truesize;
459 sk->sk_forward_alloc += skb->truesize; 460 sk->sk_forward_alloc += skb->truesize;
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 84b9af76f0a2..3a13ed643459 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -831,7 +831,7 @@ static int translate_table(struct ebt_replace *repl,
831 return -ENOMEM; 831 return -ENOMEM;
832 for_each_possible_cpu(i) { 832 for_each_possible_cpu(i) {
833 newinfo->chainstack[i] = 833 newinfo->chainstack[i] =
834 vmalloc(udc_cnt * sizeof(struct ebt_chainstack)); 834 vmalloc(udc_cnt * sizeof(*(newinfo->chainstack[0])));
835 if (!newinfo->chainstack[i]) { 835 if (!newinfo->chainstack[i]) {
836 while (i) 836 while (i)
837 vfree(newinfo->chainstack[--i]); 837 vfree(newinfo->chainstack[--i]);
@@ -841,8 +841,7 @@ static int translate_table(struct ebt_replace *repl,
841 } 841 }
842 } 842 }
843 843
844 cl_s = (struct ebt_cl_stack *) 844 cl_s = vmalloc(udc_cnt * sizeof(*cl_s));
845 vmalloc(udc_cnt * sizeof(struct ebt_cl_stack));
846 if (!cl_s) 845 if (!cl_s)
847 return -ENOMEM; 846 return -ENOMEM;
848 i = 0; /* the i'th udc */ 847 i = 0; /* the i'th udc */
@@ -944,8 +943,7 @@ static int do_replace(void __user *user, unsigned int len)
944 943
945 countersize = COUNTER_OFFSET(tmp.nentries) * 944 countersize = COUNTER_OFFSET(tmp.nentries) *
946 (highest_possible_processor_id()+1); 945 (highest_possible_processor_id()+1);
947 newinfo = (struct ebt_table_info *) 946 newinfo = vmalloc(sizeof(*newinfo) + countersize);
948 vmalloc(sizeof(struct ebt_table_info) + countersize);
949 if (!newinfo) 947 if (!newinfo)
950 return -ENOMEM; 948 return -ENOMEM;
951 949
@@ -967,8 +965,7 @@ static int do_replace(void __user *user, unsigned int len)
967 /* the user wants counters back 965 /* the user wants counters back
968 the check on the size is done later, when we have the lock */ 966 the check on the size is done later, when we have the lock */
969 if (tmp.num_counters) { 967 if (tmp.num_counters) {
970 counterstmp = (struct ebt_counter *) 968 counterstmp = vmalloc(tmp.num_counters * sizeof(*counterstmp));
971 vmalloc(tmp.num_counters * sizeof(struct ebt_counter));
972 if (!counterstmp) { 969 if (!counterstmp) {
973 ret = -ENOMEM; 970 ret = -ENOMEM;
974 goto free_entries; 971 goto free_entries;
@@ -1148,8 +1145,7 @@ int ebt_register_table(struct ebt_table *table)
1148 1145
1149 countersize = COUNTER_OFFSET(table->table->nentries) * 1146 countersize = COUNTER_OFFSET(table->table->nentries) *
1150 (highest_possible_processor_id()+1); 1147 (highest_possible_processor_id()+1);
1151 newinfo = (struct ebt_table_info *) 1148 newinfo = vmalloc(sizeof(*newinfo) + countersize);
1152 vmalloc(sizeof(struct ebt_table_info) + countersize);
1153 ret = -ENOMEM; 1149 ret = -ENOMEM;
1154 if (!newinfo) 1150 if (!newinfo)
1155 return -ENOMEM; 1151 return -ENOMEM;
@@ -1247,8 +1243,7 @@ static int update_counters(void __user *user, unsigned int len)
1247 if (hlp.num_counters == 0) 1243 if (hlp.num_counters == 0)
1248 return -EINVAL; 1244 return -EINVAL;
1249 1245
1250 if ( !(tmp = (struct ebt_counter *) 1246 if (!(tmp = vmalloc(hlp.num_counters * sizeof(*tmp)))) {
1251 vmalloc(hlp.num_counters * sizeof(struct ebt_counter))) ){
1252 MEMPRINT("Update_counters && nomemory\n"); 1247 MEMPRINT("Update_counters && nomemory\n");
1253 return -ENOMEM; 1248 return -ENOMEM;
1254 } 1249 }
@@ -1377,8 +1372,7 @@ static int copy_everything_to_user(struct ebt_table *t, void __user *user,
1377 BUGPRINT("Num_counters wrong\n"); 1372 BUGPRINT("Num_counters wrong\n");
1378 return -EINVAL; 1373 return -EINVAL;
1379 } 1374 }
1380 counterstmp = (struct ebt_counter *) 1375 counterstmp = vmalloc(nentries * sizeof(*counterstmp));
1381 vmalloc(nentries * sizeof(struct ebt_counter));
1382 if (!counterstmp) { 1376 if (!counterstmp) {
1383 MEMPRINT("Couldn't copy counters, out of memory\n"); 1377 MEMPRINT("Couldn't copy counters, out of memory\n");
1384 return -ENOMEM; 1378 return -ENOMEM;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 09464fa8d72f..fb3770f9c094 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -112,6 +112,14 @@ void skb_under_panic(struct sk_buff *skb, int sz, void *here)
112 BUG(); 112 BUG();
113} 113}
114 114
115void skb_truesize_bug(struct sk_buff *skb)
116{
117 printk(KERN_ERR "SKB BUG: Invalid truesize (%u) "
118 "len=%u, sizeof(sk_buff)=%Zd\n",
119 skb->truesize, skb->len, sizeof(struct sk_buff));
120}
121EXPORT_SYMBOL(skb_truesize_bug);
122
115/* Allocate a new skbuff. We do this ourselves so we can fill in a few 123/* Allocate a new skbuff. We do this ourselves so we can fill in a few
116 * 'private' fields and also do memory statistics to find all the 124 * 'private' fields and also do memory statistics to find all the
117 * [BEEP] leaks. 125 * [BEEP] leaks.
diff --git a/net/core/stream.c b/net/core/stream.c
index 35e25259fd95..e9489696f694 100644
--- a/net/core/stream.c
+++ b/net/core/stream.c
@@ -176,6 +176,7 @@ void sk_stream_rfree(struct sk_buff *skb)
176{ 176{
177 struct sock *sk = skb->sk; 177 struct sock *sk = skb->sk;
178 178
179 skb_truesize_check(skb);
179 atomic_sub(skb->truesize, &sk->sk_rmem_alloc); 180 atomic_sub(skb->truesize, &sk->sk_rmem_alloc);
180 sk->sk_forward_alloc += skb->truesize; 181 sk->sk_forward_alloc += skb->truesize;
181} 182}
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 44df1db726a3..a28ae593b976 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -533,6 +533,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
533 struct tcp_sock *tp = tcp_sk(sk); 533 struct tcp_sock *tp = tcp_sk(sk);
534 struct sk_buff *buff; 534 struct sk_buff *buff;
535 int nsize, old_factor; 535 int nsize, old_factor;
536 int nlen;
536 u16 flags; 537 u16 flags;
537 538
538 BUG_ON(len > skb->len); 539 BUG_ON(len > skb->len);
@@ -552,8 +553,10 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
552 if (buff == NULL) 553 if (buff == NULL)
553 return -ENOMEM; /* We'll just try again later. */ 554 return -ENOMEM; /* We'll just try again later. */
554 555
555 buff->truesize = skb->len - len; 556 sk_charge_skb(sk, buff);
556 skb->truesize -= buff->truesize; 557 nlen = skb->len - len - nsize;
558 buff->truesize += nlen;
559 skb->truesize -= nlen;
557 560
558 /* Correct the sequence numbers. */ 561 /* Correct the sequence numbers. */
559 TCP_SKB_CB(buff)->seq = TCP_SKB_CB(skb)->seq + len; 562 TCP_SKB_CB(buff)->seq = TCP_SKB_CB(skb)->seq + len;
@@ -1039,7 +1042,8 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len,
1039 if (unlikely(buff == NULL)) 1042 if (unlikely(buff == NULL))
1040 return -ENOMEM; 1043 return -ENOMEM;
1041 1044
1042 buff->truesize = nlen; 1045 sk_charge_skb(sk, buff);
1046 buff->truesize += nlen;
1043 skb->truesize -= nlen; 1047 skb->truesize -= nlen;
1044 1048
1045 /* Correct the sequence numbers. */ 1049 /* Correct the sequence numbers. */
diff --git a/net/llc/llc_input.c b/net/llc/llc_input.c
index 8f3addf0724c..d62e0f9b9da3 100644
--- a/net/llc/llc_input.c
+++ b/net/llc/llc_input.c
@@ -118,7 +118,8 @@ static inline int llc_fixup_skb(struct sk_buff *skb)
118 u16 pdulen = eth_hdr(skb)->h_proto, 118 u16 pdulen = eth_hdr(skb)->h_proto,
119 data_size = ntohs(pdulen) - llc_len; 119 data_size = ntohs(pdulen) - llc_len;
120 120
121 skb_trim(skb, data_size); 121 if (unlikely(pskb_trim_rcsum(skb, data_size)))
122 return 0;
122 } 123 }
123 return 1; 124 return 1;
124} 125}
diff --git a/net/socket.c b/net/socket.c
index 23898f45f713..0ce12dfc7a71 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -490,6 +490,7 @@ static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed)
490 struct file *file; 490 struct file *file;
491 struct socket *sock; 491 struct socket *sock;
492 492
493 *err = -EBADF;
493 file = fget_light(fd, fput_needed); 494 file = fget_light(fd, fput_needed);
494 if (file) { 495 if (file) {
495 sock = sock_from_file(file, err); 496 sock = sock_from_file(file, err);