diff options
Diffstat (limited to 'net')
88 files changed, 677 insertions, 395 deletions
diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c index 799c631f0fed..f7fa67c78766 100644 --- a/net/atm/atm_sysfs.c +++ b/net/atm/atm_sysfs.c | |||
| @@ -143,12 +143,13 @@ static struct class atm_class = { | |||
| 143 | .dev_uevent = atm_uevent, | 143 | .dev_uevent = atm_uevent, |
| 144 | }; | 144 | }; |
| 145 | 145 | ||
| 146 | int atm_register_sysfs(struct atm_dev *adev) | 146 | int atm_register_sysfs(struct atm_dev *adev, struct device *parent) |
| 147 | { | 147 | { |
| 148 | struct device *cdev = &adev->class_dev; | 148 | struct device *cdev = &adev->class_dev; |
| 149 | int i, j, err; | 149 | int i, j, err; |
| 150 | 150 | ||
| 151 | cdev->class = &atm_class; | 151 | cdev->class = &atm_class; |
| 152 | cdev->parent = parent; | ||
| 152 | dev_set_drvdata(cdev, adev); | 153 | dev_set_drvdata(cdev, adev); |
| 153 | 154 | ||
| 154 | dev_set_name(cdev, "%s%d", adev->type, adev->number); | 155 | dev_set_name(cdev, "%s%d", adev->type, adev->number); |
diff --git a/net/atm/resources.c b/net/atm/resources.c index d29e58261511..23f45ce6f351 100644 --- a/net/atm/resources.c +++ b/net/atm/resources.c | |||
| @@ -74,8 +74,9 @@ struct atm_dev *atm_dev_lookup(int number) | |||
| 74 | } | 74 | } |
| 75 | EXPORT_SYMBOL(atm_dev_lookup); | 75 | EXPORT_SYMBOL(atm_dev_lookup); |
| 76 | 76 | ||
| 77 | struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, | 77 | struct atm_dev *atm_dev_register(const char *type, struct device *parent, |
| 78 | int number, unsigned long *flags) | 78 | const struct atmdev_ops *ops, int number, |
| 79 | unsigned long *flags) | ||
| 79 | { | 80 | { |
| 80 | struct atm_dev *dev, *inuse; | 81 | struct atm_dev *dev, *inuse; |
| 81 | 82 | ||
| @@ -115,7 +116,7 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, | |||
| 115 | goto out_fail; | 116 | goto out_fail; |
| 116 | } | 117 | } |
| 117 | 118 | ||
| 118 | if (atm_register_sysfs(dev) < 0) { | 119 | if (atm_register_sysfs(dev, parent) < 0) { |
| 119 | pr_err("atm_register_sysfs failed for dev %s\n", type); | 120 | pr_err("atm_register_sysfs failed for dev %s\n", type); |
| 120 | atm_proc_dev_deregister(dev); | 121 | atm_proc_dev_deregister(dev); |
| 121 | goto out_fail; | 122 | goto out_fail; |
diff --git a/net/atm/resources.h b/net/atm/resources.h index 126fb1840dfb..521431e30507 100644 --- a/net/atm/resources.h +++ b/net/atm/resources.h | |||
| @@ -42,6 +42,6 @@ static inline void atm_proc_dev_deregister(struct atm_dev *dev) | |||
| 42 | 42 | ||
| 43 | #endif /* CONFIG_PROC_FS */ | 43 | #endif /* CONFIG_PROC_FS */ |
| 44 | 44 | ||
| 45 | int atm_register_sysfs(struct atm_dev *adev); | 45 | int atm_register_sysfs(struct atm_dev *adev, struct device *parent); |
| 46 | void atm_unregister_sysfs(struct atm_dev *adev); | 46 | void atm_unregister_sysfs(struct atm_dev *adev); |
| 47 | #endif | 47 | #endif |
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 26eaebf4aaa9..bb86d2932394 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
| @@ -1392,6 +1392,7 @@ static int ax25_getname(struct socket *sock, struct sockaddr *uaddr, | |||
| 1392 | ax25_cb *ax25; | 1392 | ax25_cb *ax25; |
| 1393 | int err = 0; | 1393 | int err = 0; |
| 1394 | 1394 | ||
| 1395 | memset(fsa, 0, sizeof(fsa)); | ||
| 1395 | lock_sock(sk); | 1396 | lock_sock(sk); |
| 1396 | ax25 = ax25_sk(sk); | 1397 | ax25 = ax25_sk(sk); |
| 1397 | 1398 | ||
| @@ -1403,7 +1404,6 @@ static int ax25_getname(struct socket *sock, struct sockaddr *uaddr, | |||
| 1403 | 1404 | ||
| 1404 | fsa->fsa_ax25.sax25_family = AF_AX25; | 1405 | fsa->fsa_ax25.sax25_family = AF_AX25; |
| 1405 | fsa->fsa_ax25.sax25_call = ax25->dest_addr; | 1406 | fsa->fsa_ax25.sax25_call = ax25->dest_addr; |
| 1406 | fsa->fsa_ax25.sax25_ndigis = 0; | ||
| 1407 | 1407 | ||
| 1408 | if (ax25->digipeat != NULL) { | 1408 | if (ax25->digipeat != NULL) { |
| 1409 | ndigi = ax25->digipeat->ndigi; | 1409 | ndigi = ax25->digipeat->ndigi; |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index bfef5bae0b3a..84093b0000b9 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
| @@ -1175,6 +1175,12 @@ static inline void hci_remote_features_evt(struct hci_dev *hdev, struct sk_buff | |||
| 1175 | hci_send_cmd(hdev, | 1175 | hci_send_cmd(hdev, |
| 1176 | HCI_OP_READ_REMOTE_EXT_FEATURES, | 1176 | HCI_OP_READ_REMOTE_EXT_FEATURES, |
| 1177 | sizeof(cp), &cp); | 1177 | sizeof(cp), &cp); |
| 1178 | } else if (!ev->status && conn->out && | ||
| 1179 | conn->sec_level == BT_SECURITY_HIGH) { | ||
| 1180 | struct hci_cp_auth_requested cp; | ||
| 1181 | cp.handle = ev->handle; | ||
| 1182 | hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, | ||
| 1183 | sizeof(cp), &cp); | ||
| 1178 | } else { | 1184 | } else { |
| 1179 | conn->state = BT_CONNECTED; | 1185 | conn->state = BT_CONNECTED; |
| 1180 | hci_proto_connect_cfm(conn, ev->status); | 1186 | hci_proto_connect_cfm(conn, ev->status); |
diff --git a/net/bluetooth/hidp/Kconfig b/net/bluetooth/hidp/Kconfig index 98fdfa1fbddd..86a91543172a 100644 --- a/net/bluetooth/hidp/Kconfig +++ b/net/bluetooth/hidp/Kconfig | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | config BT_HIDP | 1 | config BT_HIDP |
| 2 | tristate "HIDP protocol support" | 2 | tristate "HIDP protocol support" |
| 3 | depends on BT && BT_L2CAP && INPUT | 3 | depends on BT && BT_L2CAP && INPUT && HID_SUPPORT |
| 4 | select HID | 4 | select HID |
| 5 | help | 5 | help |
| 6 | HIDP (Human Interface Device Protocol) is a transport layer | 6 | HIDP (Human Interface Device Protocol) is a transport layer |
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index daa7a988d9a6..cd8f6ea03841 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
| @@ -2421,11 +2421,11 @@ static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned | |||
| 2421 | break; | 2421 | break; |
| 2422 | 2422 | ||
| 2423 | case 2: | 2423 | case 2: |
| 2424 | *val = __le16_to_cpu(*((__le16 *) opt->val)); | 2424 | *val = get_unaligned_le16(opt->val); |
| 2425 | break; | 2425 | break; |
| 2426 | 2426 | ||
| 2427 | case 4: | 2427 | case 4: |
| 2428 | *val = __le32_to_cpu(*((__le32 *) opt->val)); | 2428 | *val = get_unaligned_le32(opt->val); |
| 2429 | break; | 2429 | break; |
| 2430 | 2430 | ||
| 2431 | default: | 2431 | default: |
| @@ -2452,11 +2452,11 @@ static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val) | |||
| 2452 | break; | 2452 | break; |
| 2453 | 2453 | ||
| 2454 | case 2: | 2454 | case 2: |
| 2455 | *((__le16 *) opt->val) = cpu_to_le16(val); | 2455 | put_unaligned_le16(val, opt->val); |
| 2456 | break; | 2456 | break; |
| 2457 | 2457 | ||
| 2458 | case 4: | 2458 | case 4: |
| 2459 | *((__le32 *) opt->val) = cpu_to_le32(val); | 2459 | put_unaligned_le32(val, opt->val); |
| 2460 | break; | 2460 | break; |
| 2461 | 2461 | ||
| 2462 | default: | 2462 | default: |
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 39a5d87e33b4..432a9a633e8d 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
| @@ -79,7 +79,10 @@ static void rfcomm_make_uih(struct sk_buff *skb, u8 addr); | |||
| 79 | 79 | ||
| 80 | static void rfcomm_process_connect(struct rfcomm_session *s); | 80 | static void rfcomm_process_connect(struct rfcomm_session *s); |
| 81 | 81 | ||
| 82 | static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, bdaddr_t *dst, int *err); | 82 | static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, |
| 83 | bdaddr_t *dst, | ||
| 84 | u8 sec_level, | ||
| 85 | int *err); | ||
| 83 | static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst); | 86 | static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst); |
| 84 | static void rfcomm_session_del(struct rfcomm_session *s); | 87 | static void rfcomm_session_del(struct rfcomm_session *s); |
| 85 | 88 | ||
| @@ -308,6 +311,7 @@ static void rfcomm_dlc_clear_state(struct rfcomm_dlc *d) | |||
| 308 | d->state = BT_OPEN; | 311 | d->state = BT_OPEN; |
| 309 | d->flags = 0; | 312 | d->flags = 0; |
| 310 | d->mscex = 0; | 313 | d->mscex = 0; |
| 314 | d->sec_level = BT_SECURITY_LOW; | ||
| 311 | d->mtu = RFCOMM_DEFAULT_MTU; | 315 | d->mtu = RFCOMM_DEFAULT_MTU; |
| 312 | d->v24_sig = RFCOMM_V24_RTC | RFCOMM_V24_RTR | RFCOMM_V24_DV; | 316 | d->v24_sig = RFCOMM_V24_RTC | RFCOMM_V24_RTR | RFCOMM_V24_DV; |
| 313 | 317 | ||
| @@ -401,7 +405,7 @@ static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, | |||
| 401 | 405 | ||
| 402 | s = rfcomm_session_get(src, dst); | 406 | s = rfcomm_session_get(src, dst); |
| 403 | if (!s) { | 407 | if (!s) { |
| 404 | s = rfcomm_session_create(src, dst, &err); | 408 | s = rfcomm_session_create(src, dst, d->sec_level, &err); |
| 405 | if (!s) | 409 | if (!s) |
| 406 | return err; | 410 | return err; |
| 407 | } | 411 | } |
| @@ -679,7 +683,10 @@ static void rfcomm_session_close(struct rfcomm_session *s, int err) | |||
| 679 | rfcomm_session_put(s); | 683 | rfcomm_session_put(s); |
| 680 | } | 684 | } |
| 681 | 685 | ||
| 682 | static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, bdaddr_t *dst, int *err) | 686 | static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, |
| 687 | bdaddr_t *dst, | ||
| 688 | u8 sec_level, | ||
| 689 | int *err) | ||
| 683 | { | 690 | { |
| 684 | struct rfcomm_session *s = NULL; | 691 | struct rfcomm_session *s = NULL; |
| 685 | struct sockaddr_l2 addr; | 692 | struct sockaddr_l2 addr; |
| @@ -704,6 +711,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, bdaddr_t *dst | |||
| 704 | sk = sock->sk; | 711 | sk = sock->sk; |
| 705 | lock_sock(sk); | 712 | lock_sock(sk); |
| 706 | l2cap_pi(sk)->imtu = l2cap_mtu; | 713 | l2cap_pi(sk)->imtu = l2cap_mtu; |
| 714 | l2cap_pi(sk)->sec_level = sec_level; | ||
| 707 | if (l2cap_ertm) | 715 | if (l2cap_ertm) |
| 708 | l2cap_pi(sk)->mode = L2CAP_MODE_ERTM; | 716 | l2cap_pi(sk)->mode = L2CAP_MODE_ERTM; |
| 709 | release_sock(sk); | 717 | release_sock(sk); |
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index d0927d1fdada..66b9e5c0523a 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
| @@ -882,7 +882,7 @@ static int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 type) | |||
| 882 | int lm = 0; | 882 | int lm = 0; |
| 883 | 883 | ||
| 884 | if (type != SCO_LINK && type != ESCO_LINK) | 884 | if (type != SCO_LINK && type != ESCO_LINK) |
| 885 | return 0; | 885 | return -EINVAL; |
| 886 | 886 | ||
| 887 | BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr)); | 887 | BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr)); |
| 888 | 888 | ||
| @@ -908,7 +908,7 @@ static int sco_connect_cfm(struct hci_conn *hcon, __u8 status) | |||
| 908 | BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status); | 908 | BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status); |
| 909 | 909 | ||
| 910 | if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK) | 910 | if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK) |
| 911 | return 0; | 911 | return -EINVAL; |
| 912 | 912 | ||
| 913 | if (!status) { | 913 | if (!status) { |
| 914 | struct sco_conn *conn; | 914 | struct sco_conn *conn; |
| @@ -927,7 +927,7 @@ static int sco_disconn_cfm(struct hci_conn *hcon, __u8 reason) | |||
| 927 | BT_DBG("hcon %p reason %d", hcon, reason); | 927 | BT_DBG("hcon %p reason %d", hcon, reason); |
| 928 | 928 | ||
| 929 | if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK) | 929 | if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK) |
| 930 | return 0; | 930 | return -EINVAL; |
| 931 | 931 | ||
| 932 | sco_conn_del(hcon, bt_err(reason)); | 932 | sco_conn_del(hcon, bt_err(reason)); |
| 933 | 933 | ||
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index eb5b256ffc88..543b3262d002 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c | |||
| @@ -437,7 +437,7 @@ static struct sk_buff *br_ip6_multicast_alloc_query(struct net_bridge *br, | |||
| 437 | ip6h = ipv6_hdr(skb); | 437 | ip6h = ipv6_hdr(skb); |
| 438 | 438 | ||
| 439 | *(__force __be32 *)ip6h = htonl(0x60000000); | 439 | *(__force __be32 *)ip6h = htonl(0x60000000); |
| 440 | ip6h->payload_len = 8 + sizeof(*mldq); | 440 | ip6h->payload_len = htons(8 + sizeof(*mldq)); |
| 441 | ip6h->nexthdr = IPPROTO_HOPOPTS; | 441 | ip6h->nexthdr = IPPROTO_HOPOPTS; |
| 442 | ip6h->hop_limit = 1; | 442 | ip6h->hop_limit = 1; |
| 443 | ipv6_addr_set(&ip6h->saddr, 0, 0, 0, 0); | 443 | ipv6_addr_set(&ip6h->saddr, 0, 0, 0, 0); |
| @@ -1430,7 +1430,7 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br, | |||
| 1430 | struct net_bridge_port *port, | 1430 | struct net_bridge_port *port, |
| 1431 | struct sk_buff *skb) | 1431 | struct sk_buff *skb) |
| 1432 | { | 1432 | { |
| 1433 | struct sk_buff *skb2 = skb; | 1433 | struct sk_buff *skb2; |
| 1434 | struct ipv6hdr *ip6h; | 1434 | struct ipv6hdr *ip6h; |
| 1435 | struct icmp6hdr *icmp6h; | 1435 | struct icmp6hdr *icmp6h; |
| 1436 | u8 nexthdr; | 1436 | u8 nexthdr; |
| @@ -1469,15 +1469,15 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br, | |||
| 1469 | if (!skb2) | 1469 | if (!skb2) |
| 1470 | return -ENOMEM; | 1470 | return -ENOMEM; |
| 1471 | 1471 | ||
| 1472 | err = -EINVAL; | ||
| 1473 | if (!pskb_may_pull(skb2, offset + sizeof(struct icmp6hdr))) | ||
| 1474 | goto out; | ||
| 1475 | |||
| 1472 | len -= offset - skb_network_offset(skb2); | 1476 | len -= offset - skb_network_offset(skb2); |
| 1473 | 1477 | ||
| 1474 | __skb_pull(skb2, offset); | 1478 | __skb_pull(skb2, offset); |
| 1475 | skb_reset_transport_header(skb2); | 1479 | skb_reset_transport_header(skb2); |
| 1476 | 1480 | ||
| 1477 | err = -EINVAL; | ||
| 1478 | if (!pskb_may_pull(skb2, sizeof(*icmp6h))) | ||
| 1479 | goto out; | ||
| 1480 | |||
| 1481 | icmp6h = icmp6_hdr(skb2); | 1481 | icmp6h = icmp6_hdr(skb2); |
| 1482 | 1482 | ||
| 1483 | switch (icmp6h->icmp6_type) { | 1483 | switch (icmp6h->icmp6_type) { |
| @@ -1516,7 +1516,12 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br, | |||
| 1516 | switch (icmp6h->icmp6_type) { | 1516 | switch (icmp6h->icmp6_type) { |
| 1517 | case ICMPV6_MGM_REPORT: | 1517 | case ICMPV6_MGM_REPORT: |
| 1518 | { | 1518 | { |
| 1519 | struct mld_msg *mld = (struct mld_msg *)icmp6h; | 1519 | struct mld_msg *mld; |
| 1520 | if (!pskb_may_pull(skb2, sizeof(*mld))) { | ||
| 1521 | err = -EINVAL; | ||
| 1522 | goto out; | ||
| 1523 | } | ||
| 1524 | mld = (struct mld_msg *)skb_transport_header(skb2); | ||
| 1520 | BR_INPUT_SKB_CB(skb2)->mrouters_only = 1; | 1525 | BR_INPUT_SKB_CB(skb2)->mrouters_only = 1; |
| 1521 | err = br_ip6_multicast_add_group(br, port, &mld->mld_mca); | 1526 | err = br_ip6_multicast_add_group(br, port, &mld->mld_mca); |
| 1522 | break; | 1527 | break; |
| @@ -1529,15 +1534,18 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br, | |||
| 1529 | break; | 1534 | break; |
| 1530 | case ICMPV6_MGM_REDUCTION: | 1535 | case ICMPV6_MGM_REDUCTION: |
| 1531 | { | 1536 | { |
| 1532 | struct mld_msg *mld = (struct mld_msg *)icmp6h; | 1537 | struct mld_msg *mld; |
| 1538 | if (!pskb_may_pull(skb2, sizeof(*mld))) { | ||
| 1539 | err = -EINVAL; | ||
| 1540 | goto out; | ||
| 1541 | } | ||
| 1542 | mld = (struct mld_msg *)skb_transport_header(skb2); | ||
| 1533 | br_ip6_multicast_leave_group(br, port, &mld->mld_mca); | 1543 | br_ip6_multicast_leave_group(br, port, &mld->mld_mca); |
| 1534 | } | 1544 | } |
| 1535 | } | 1545 | } |
| 1536 | 1546 | ||
| 1537 | out: | 1547 | out: |
| 1538 | __skb_push(skb2, offset); | 1548 | kfree_skb(skb2); |
| 1539 | if (skb2 != skb) | ||
| 1540 | kfree_skb(skb2); | ||
| 1541 | return err; | 1549 | return err; |
| 1542 | } | 1550 | } |
| 1543 | #endif | 1551 | #endif |
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c index 35cf27087b56..e3d7aefa9181 100644 --- a/net/bridge/br_stp_bpdu.c +++ b/net/bridge/br_stp_bpdu.c | |||
| @@ -50,6 +50,8 @@ static void br_send_bpdu(struct net_bridge_port *p, | |||
| 50 | 50 | ||
| 51 | llc_mac_hdr_init(skb, p->dev->dev_addr, p->br->group_addr); | 51 | llc_mac_hdr_init(skb, p->dev->dev_addr, p->br->group_addr); |
| 52 | 52 | ||
| 53 | skb_reset_mac_header(skb); | ||
| 54 | |||
| 53 | NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, | 55 | NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, |
| 54 | dev_queue_xmit); | 56 | dev_queue_xmit); |
| 55 | } | 57 | } |
diff --git a/net/can/bcm.c b/net/can/bcm.c index 08ffe9e4be20..9d5e8accfab1 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c | |||
| @@ -125,7 +125,7 @@ struct bcm_sock { | |||
| 125 | struct list_head tx_ops; | 125 | struct list_head tx_ops; |
| 126 | unsigned long dropped_usr_msgs; | 126 | unsigned long dropped_usr_msgs; |
| 127 | struct proc_dir_entry *bcm_proc_read; | 127 | struct proc_dir_entry *bcm_proc_read; |
| 128 | char procname [9]; /* pointer printed in ASCII with \0 */ | 128 | char procname [32]; /* inode number in decimal with \0 */ |
| 129 | }; | 129 | }; |
| 130 | 130 | ||
| 131 | static inline struct bcm_sock *bcm_sk(const struct sock *sk) | 131 | static inline struct bcm_sock *bcm_sk(const struct sock *sk) |
| @@ -1521,7 +1521,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len, | |||
| 1521 | 1521 | ||
| 1522 | if (proc_dir) { | 1522 | if (proc_dir) { |
| 1523 | /* unique socket address as filename */ | 1523 | /* unique socket address as filename */ |
| 1524 | sprintf(bo->procname, "%p", sock); | 1524 | sprintf(bo->procname, "%lu", sock_i_ino(sk)); |
| 1525 | bo->bcm_proc_read = proc_create_data(bo->procname, 0644, | 1525 | bo->bcm_proc_read = proc_create_data(bo->procname, 0644, |
| 1526 | proc_dir, | 1526 | proc_dir, |
| 1527 | &bcm_proc_fops, sk); | 1527 | &bcm_proc_fops, sk); |
diff --git a/net/ceph/Makefile b/net/ceph/Makefile index aab1cabb8035..5f19415ec9c0 100644 --- a/net/ceph/Makefile +++ b/net/ceph/Makefile | |||
| @@ -1,9 +1,6 @@ | |||
| 1 | # | 1 | # |
| 2 | # Makefile for CEPH filesystem. | 2 | # Makefile for CEPH filesystem. |
| 3 | # | 3 | # |
| 4 | |||
| 5 | ifneq ($(KERNELRELEASE),) | ||
| 6 | |||
| 7 | obj-$(CONFIG_CEPH_LIB) += libceph.o | 4 | obj-$(CONFIG_CEPH_LIB) += libceph.o |
| 8 | 5 | ||
| 9 | libceph-objs := ceph_common.o messenger.o msgpool.o buffer.o pagelist.o \ | 6 | libceph-objs := ceph_common.o messenger.o msgpool.o buffer.o pagelist.o \ |
| @@ -16,22 +13,3 @@ libceph-objs := ceph_common.o messenger.o msgpool.o buffer.o pagelist.o \ | |||
| 16 | ceph_fs.o ceph_strings.o ceph_hash.o \ | 13 | ceph_fs.o ceph_strings.o ceph_hash.o \ |
| 17 | pagevec.o | 14 | pagevec.o |
| 18 | 15 | ||
| 19 | else | ||
| 20 | #Otherwise we were called directly from the command | ||
| 21 | # line; invoke the kernel build system. | ||
| 22 | |||
| 23 | KERNELDIR ?= /lib/modules/$(shell uname -r)/build | ||
| 24 | PWD := $(shell pwd) | ||
| 25 | |||
| 26 | default: all | ||
| 27 | |||
| 28 | all: | ||
| 29 | $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_CEPH_LIB=m modules | ||
| 30 | |||
| 31 | modules_install: | ||
| 32 | $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_CEPH_LIB=m modules_install | ||
| 33 | |||
| 34 | clean: | ||
| 35 | $(MAKE) -C $(KERNELDIR) M=$(PWD) clean | ||
| 36 | |||
| 37 | endif | ||
diff --git a/net/ceph/buffer.c b/net/ceph/buffer.c index 53d8abfa25d5..bf3e6a13c215 100644 --- a/net/ceph/buffer.c +++ b/net/ceph/buffer.c | |||
| @@ -19,7 +19,7 @@ struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp) | |||
| 19 | if (b->vec.iov_base) { | 19 | if (b->vec.iov_base) { |
| 20 | b->is_vmalloc = false; | 20 | b->is_vmalloc = false; |
| 21 | } else { | 21 | } else { |
| 22 | b->vec.iov_base = __vmalloc(len, gfp, PAGE_KERNEL); | 22 | b->vec.iov_base = __vmalloc(len, gfp | __GFP_HIGHMEM, PAGE_KERNEL); |
| 23 | if (!b->vec.iov_base) { | 23 | if (!b->vec.iov_base) { |
| 24 | kfree(b); | 24 | kfree(b); |
| 25 | return NULL; | 25 | return NULL; |
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 0e8157ee5d43..b6ff4a1519ab 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
| @@ -97,11 +97,9 @@ struct workqueue_struct *ceph_msgr_wq; | |||
| 97 | int ceph_msgr_init(void) | 97 | int ceph_msgr_init(void) |
| 98 | { | 98 | { |
| 99 | ceph_msgr_wq = create_workqueue("ceph-msgr"); | 99 | ceph_msgr_wq = create_workqueue("ceph-msgr"); |
| 100 | if (IS_ERR(ceph_msgr_wq)) { | 100 | if (!ceph_msgr_wq) { |
| 101 | int ret = PTR_ERR(ceph_msgr_wq); | 101 | pr_err("msgr_init failed to create workqueue\n"); |
| 102 | pr_err("msgr_init failed to create workqueue: %d\n", ret); | 102 | return -ENOMEM; |
| 103 | ceph_msgr_wq = NULL; | ||
| 104 | return ret; | ||
| 105 | } | 103 | } |
| 106 | return 0; | 104 | return 0; |
| 107 | } | 105 | } |
| @@ -540,8 +538,7 @@ static void prepare_write_message(struct ceph_connection *con) | |||
| 540 | /* initialize page iterator */ | 538 | /* initialize page iterator */ |
| 541 | con->out_msg_pos.page = 0; | 539 | con->out_msg_pos.page = 0; |
| 542 | if (m->pages) | 540 | if (m->pages) |
| 543 | con->out_msg_pos.page_pos = | 541 | con->out_msg_pos.page_pos = m->page_alignment; |
| 544 | le16_to_cpu(m->hdr.data_off) & ~PAGE_MASK; | ||
| 545 | else | 542 | else |
| 546 | con->out_msg_pos.page_pos = 0; | 543 | con->out_msg_pos.page_pos = 0; |
| 547 | con->out_msg_pos.data_pos = 0; | 544 | con->out_msg_pos.data_pos = 0; |
| @@ -1491,7 +1488,7 @@ static int read_partial_message(struct ceph_connection *con) | |||
| 1491 | struct ceph_msg *m = con->in_msg; | 1488 | struct ceph_msg *m = con->in_msg; |
| 1492 | int ret; | 1489 | int ret; |
| 1493 | int to, left; | 1490 | int to, left; |
| 1494 | unsigned front_len, middle_len, data_len, data_off; | 1491 | unsigned front_len, middle_len, data_len; |
| 1495 | int datacrc = con->msgr->nocrc; | 1492 | int datacrc = con->msgr->nocrc; |
| 1496 | int skip; | 1493 | int skip; |
| 1497 | u64 seq; | 1494 | u64 seq; |
| @@ -1527,19 +1524,17 @@ static int read_partial_message(struct ceph_connection *con) | |||
| 1527 | data_len = le32_to_cpu(con->in_hdr.data_len); | 1524 | data_len = le32_to_cpu(con->in_hdr.data_len); |
| 1528 | if (data_len > CEPH_MSG_MAX_DATA_LEN) | 1525 | if (data_len > CEPH_MSG_MAX_DATA_LEN) |
| 1529 | return -EIO; | 1526 | return -EIO; |
| 1530 | data_off = le16_to_cpu(con->in_hdr.data_off); | ||
| 1531 | 1527 | ||
| 1532 | /* verify seq# */ | 1528 | /* verify seq# */ |
| 1533 | seq = le64_to_cpu(con->in_hdr.seq); | 1529 | seq = le64_to_cpu(con->in_hdr.seq); |
| 1534 | if ((s64)seq - (s64)con->in_seq < 1) { | 1530 | if ((s64)seq - (s64)con->in_seq < 1) { |
| 1535 | pr_info("skipping %s%lld %s seq %lld, expected %lld\n", | 1531 | pr_info("skipping %s%lld %s seq %lld expected %lld\n", |
| 1536 | ENTITY_NAME(con->peer_name), | 1532 | ENTITY_NAME(con->peer_name), |
| 1537 | ceph_pr_addr(&con->peer_addr.in_addr), | 1533 | ceph_pr_addr(&con->peer_addr.in_addr), |
| 1538 | seq, con->in_seq + 1); | 1534 | seq, con->in_seq + 1); |
| 1539 | con->in_base_pos = -front_len - middle_len - data_len - | 1535 | con->in_base_pos = -front_len - middle_len - data_len - |
| 1540 | sizeof(m->footer); | 1536 | sizeof(m->footer); |
| 1541 | con->in_tag = CEPH_MSGR_TAG_READY; | 1537 | con->in_tag = CEPH_MSGR_TAG_READY; |
| 1542 | con->in_seq++; | ||
| 1543 | return 0; | 1538 | return 0; |
| 1544 | } else if ((s64)seq - (s64)con->in_seq > 1) { | 1539 | } else if ((s64)seq - (s64)con->in_seq > 1) { |
| 1545 | pr_err("read_partial_message bad seq %lld expected %lld\n", | 1540 | pr_err("read_partial_message bad seq %lld expected %lld\n", |
| @@ -1576,7 +1571,7 @@ static int read_partial_message(struct ceph_connection *con) | |||
| 1576 | 1571 | ||
| 1577 | con->in_msg_pos.page = 0; | 1572 | con->in_msg_pos.page = 0; |
| 1578 | if (m->pages) | 1573 | if (m->pages) |
| 1579 | con->in_msg_pos.page_pos = data_off & ~PAGE_MASK; | 1574 | con->in_msg_pos.page_pos = m->page_alignment; |
| 1580 | else | 1575 | else |
| 1581 | con->in_msg_pos.page_pos = 0; | 1576 | con->in_msg_pos.page_pos = 0; |
| 1582 | con->in_msg_pos.data_pos = 0; | 1577 | con->in_msg_pos.data_pos = 0; |
| @@ -2301,6 +2296,7 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags) | |||
| 2301 | 2296 | ||
| 2302 | /* data */ | 2297 | /* data */ |
| 2303 | m->nr_pages = 0; | 2298 | m->nr_pages = 0; |
| 2299 | m->page_alignment = 0; | ||
| 2304 | m->pages = NULL; | 2300 | m->pages = NULL; |
| 2305 | m->pagelist = NULL; | 2301 | m->pagelist = NULL; |
| 2306 | m->bio = NULL; | 2302 | m->bio = NULL; |
| @@ -2370,6 +2366,7 @@ static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con, | |||
| 2370 | type, front_len); | 2366 | type, front_len); |
| 2371 | return NULL; | 2367 | return NULL; |
| 2372 | } | 2368 | } |
| 2369 | msg->page_alignment = le16_to_cpu(hdr->data_off); | ||
| 2373 | } | 2370 | } |
| 2374 | memcpy(&msg->hdr, &con->in_hdr, sizeof(con->in_hdr)); | 2371 | memcpy(&msg->hdr, &con->in_hdr, sizeof(con->in_hdr)); |
| 2375 | 2372 | ||
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 79391994b3ed..3e20a122ffa2 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
| @@ -71,6 +71,7 @@ void ceph_calc_raw_layout(struct ceph_osd_client *osdc, | |||
| 71 | op->extent.length = objlen; | 71 | op->extent.length = objlen; |
| 72 | } | 72 | } |
| 73 | req->r_num_pages = calc_pages_for(off, *plen); | 73 | req->r_num_pages = calc_pages_for(off, *plen); |
| 74 | req->r_page_alignment = off & ~PAGE_MASK; | ||
| 74 | if (op->op == CEPH_OSD_OP_WRITE) | 75 | if (op->op == CEPH_OSD_OP_WRITE) |
| 75 | op->payload_len = *plen; | 76 | op->payload_len = *plen; |
| 76 | 77 | ||
| @@ -390,6 +391,8 @@ void ceph_osdc_build_request(struct ceph_osd_request *req, | |||
| 390 | req->r_request->hdr.data_len = cpu_to_le32(data_len); | 391 | req->r_request->hdr.data_len = cpu_to_le32(data_len); |
| 391 | } | 392 | } |
| 392 | 393 | ||
| 394 | req->r_request->page_alignment = req->r_page_alignment; | ||
| 395 | |||
| 393 | BUG_ON(p > msg->front.iov_base + msg->front.iov_len); | 396 | BUG_ON(p > msg->front.iov_base + msg->front.iov_len); |
| 394 | msg_size = p - msg->front.iov_base; | 397 | msg_size = p - msg->front.iov_base; |
| 395 | msg->front.iov_len = msg_size; | 398 | msg->front.iov_len = msg_size; |
| @@ -419,7 +422,8 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
| 419 | u32 truncate_seq, | 422 | u32 truncate_seq, |
| 420 | u64 truncate_size, | 423 | u64 truncate_size, |
| 421 | struct timespec *mtime, | 424 | struct timespec *mtime, |
| 422 | bool use_mempool, int num_reply) | 425 | bool use_mempool, int num_reply, |
| 426 | int page_align) | ||
| 423 | { | 427 | { |
| 424 | struct ceph_osd_req_op ops[3]; | 428 | struct ceph_osd_req_op ops[3]; |
| 425 | struct ceph_osd_request *req; | 429 | struct ceph_osd_request *req; |
| @@ -447,6 +451,10 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
| 447 | calc_layout(osdc, vino, layout, off, plen, req, ops); | 451 | calc_layout(osdc, vino, layout, off, plen, req, ops); |
| 448 | req->r_file_layout = *layout; /* keep a copy */ | 452 | req->r_file_layout = *layout; /* keep a copy */ |
| 449 | 453 | ||
| 454 | /* in case it differs from natural alignment that calc_layout | ||
| 455 | filled in for us */ | ||
| 456 | req->r_page_alignment = page_align; | ||
| 457 | |||
| 450 | ceph_osdc_build_request(req, off, plen, ops, | 458 | ceph_osdc_build_request(req, off, plen, ops, |
| 451 | snapc, | 459 | snapc, |
| 452 | mtime, | 460 | mtime, |
| @@ -1489,7 +1497,7 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc, | |||
| 1489 | struct ceph_vino vino, struct ceph_file_layout *layout, | 1497 | struct ceph_vino vino, struct ceph_file_layout *layout, |
| 1490 | u64 off, u64 *plen, | 1498 | u64 off, u64 *plen, |
| 1491 | u32 truncate_seq, u64 truncate_size, | 1499 | u32 truncate_seq, u64 truncate_size, |
| 1492 | struct page **pages, int num_pages) | 1500 | struct page **pages, int num_pages, int page_align) |
| 1493 | { | 1501 | { |
| 1494 | struct ceph_osd_request *req; | 1502 | struct ceph_osd_request *req; |
| 1495 | int rc = 0; | 1503 | int rc = 0; |
| @@ -1499,15 +1507,15 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc, | |||
| 1499 | req = ceph_osdc_new_request(osdc, layout, vino, off, plen, | 1507 | req = ceph_osdc_new_request(osdc, layout, vino, off, plen, |
| 1500 | CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, | 1508 | CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, |
| 1501 | NULL, 0, truncate_seq, truncate_size, NULL, | 1509 | NULL, 0, truncate_seq, truncate_size, NULL, |
| 1502 | false, 1); | 1510 | false, 1, page_align); |
| 1503 | if (!req) | 1511 | if (!req) |
| 1504 | return -ENOMEM; | 1512 | return -ENOMEM; |
| 1505 | 1513 | ||
| 1506 | /* it may be a short read due to an object boundary */ | 1514 | /* it may be a short read due to an object boundary */ |
| 1507 | req->r_pages = pages; | 1515 | req->r_pages = pages; |
| 1508 | 1516 | ||
| 1509 | dout("readpages final extent is %llu~%llu (%d pages)\n", | 1517 | dout("readpages final extent is %llu~%llu (%d pages align %d)\n", |
| 1510 | off, *plen, req->r_num_pages); | 1518 | off, *plen, req->r_num_pages, page_align); |
| 1511 | 1519 | ||
| 1512 | rc = ceph_osdc_start_request(osdc, req, false); | 1520 | rc = ceph_osdc_start_request(osdc, req, false); |
| 1513 | if (!rc) | 1521 | if (!rc) |
| @@ -1533,6 +1541,7 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino, | |||
| 1533 | { | 1541 | { |
| 1534 | struct ceph_osd_request *req; | 1542 | struct ceph_osd_request *req; |
| 1535 | int rc = 0; | 1543 | int rc = 0; |
| 1544 | int page_align = off & ~PAGE_MASK; | ||
| 1536 | 1545 | ||
| 1537 | BUG_ON(vino.snap != CEPH_NOSNAP); | 1546 | BUG_ON(vino.snap != CEPH_NOSNAP); |
| 1538 | req = ceph_osdc_new_request(osdc, layout, vino, off, &len, | 1547 | req = ceph_osdc_new_request(osdc, layout, vino, off, &len, |
| @@ -1541,7 +1550,7 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino, | |||
| 1541 | CEPH_OSD_FLAG_WRITE, | 1550 | CEPH_OSD_FLAG_WRITE, |
| 1542 | snapc, do_sync, | 1551 | snapc, do_sync, |
| 1543 | truncate_seq, truncate_size, mtime, | 1552 | truncate_seq, truncate_size, mtime, |
| 1544 | nofail, 1); | 1553 | nofail, 1, page_align); |
| 1545 | if (!req) | 1554 | if (!req) |
| 1546 | return -ENOMEM; | 1555 | return -ENOMEM; |
| 1547 | 1556 | ||
| @@ -1638,8 +1647,7 @@ static struct ceph_msg *get_reply(struct ceph_connection *con, | |||
| 1638 | m = ceph_msg_get(req->r_reply); | 1647 | m = ceph_msg_get(req->r_reply); |
| 1639 | 1648 | ||
| 1640 | if (data_len > 0) { | 1649 | if (data_len > 0) { |
| 1641 | unsigned data_off = le16_to_cpu(hdr->data_off); | 1650 | int want = calc_pages_for(req->r_page_alignment, data_len); |
| 1642 | int want = calc_pages_for(data_off & ~PAGE_MASK, data_len); | ||
| 1643 | 1651 | ||
| 1644 | if (unlikely(req->r_num_pages < want)) { | 1652 | if (unlikely(req->r_num_pages < want)) { |
| 1645 | pr_warning("tid %lld reply %d > expected %d pages\n", | 1653 | pr_warning("tid %lld reply %d > expected %d pages\n", |
| @@ -1651,6 +1659,7 @@ static struct ceph_msg *get_reply(struct ceph_connection *con, | |||
| 1651 | } | 1659 | } |
| 1652 | m->pages = req->r_pages; | 1660 | m->pages = req->r_pages; |
| 1653 | m->nr_pages = req->r_num_pages; | 1661 | m->nr_pages = req->r_num_pages; |
| 1662 | m->page_alignment = req->r_page_alignment; | ||
| 1654 | #ifdef CONFIG_BLOCK | 1663 | #ifdef CONFIG_BLOCK |
| 1655 | m->bio = req->r_bio; | 1664 | m->bio = req->r_bio; |
| 1656 | #endif | 1665 | #endif |
diff --git a/net/ceph/pagevec.c b/net/ceph/pagevec.c index 54caf0687155..1a040e64c69f 100644 --- a/net/ceph/pagevec.c +++ b/net/ceph/pagevec.c | |||
| @@ -13,8 +13,7 @@ | |||
| 13 | * build a vector of user pages | 13 | * build a vector of user pages |
| 14 | */ | 14 | */ |
| 15 | struct page **ceph_get_direct_page_vector(const char __user *data, | 15 | struct page **ceph_get_direct_page_vector(const char __user *data, |
| 16 | int num_pages, | 16 | int num_pages, bool write_page) |
| 17 | loff_t off, size_t len) | ||
| 18 | { | 17 | { |
| 19 | struct page **pages; | 18 | struct page **pages; |
| 20 | int rc; | 19 | int rc; |
| @@ -25,24 +24,27 @@ struct page **ceph_get_direct_page_vector(const char __user *data, | |||
| 25 | 24 | ||
| 26 | down_read(¤t->mm->mmap_sem); | 25 | down_read(¤t->mm->mmap_sem); |
| 27 | rc = get_user_pages(current, current->mm, (unsigned long)data, | 26 | rc = get_user_pages(current, current->mm, (unsigned long)data, |
| 28 | num_pages, 0, 0, pages, NULL); | 27 | num_pages, write_page, 0, pages, NULL); |
| 29 | up_read(¤t->mm->mmap_sem); | 28 | up_read(¤t->mm->mmap_sem); |
| 30 | if (rc < 0) | 29 | if (rc < num_pages) |
| 31 | goto fail; | 30 | goto fail; |
| 32 | return pages; | 31 | return pages; |
| 33 | 32 | ||
| 34 | fail: | 33 | fail: |
| 35 | kfree(pages); | 34 | ceph_put_page_vector(pages, rc > 0 ? rc : 0, false); |
| 36 | return ERR_PTR(rc); | 35 | return ERR_PTR(rc); |
| 37 | } | 36 | } |
| 38 | EXPORT_SYMBOL(ceph_get_direct_page_vector); | 37 | EXPORT_SYMBOL(ceph_get_direct_page_vector); |
| 39 | 38 | ||
| 40 | void ceph_put_page_vector(struct page **pages, int num_pages) | 39 | void ceph_put_page_vector(struct page **pages, int num_pages, bool dirty) |
| 41 | { | 40 | { |
| 42 | int i; | 41 | int i; |
| 43 | 42 | ||
| 44 | for (i = 0; i < num_pages; i++) | 43 | for (i = 0; i < num_pages; i++) { |
| 44 | if (dirty) | ||
| 45 | set_page_dirty_lock(pages[i]); | ||
| 45 | put_page(pages[i]); | 46 | put_page(pages[i]); |
| 47 | } | ||
| 46 | kfree(pages); | 48 | kfree(pages); |
| 47 | } | 49 | } |
| 48 | EXPORT_SYMBOL(ceph_put_page_vector); | 50 | EXPORT_SYMBOL(ceph_put_page_vector); |
diff --git a/net/core/dst.c b/net/core/dst.c index 8abe628b79f1..b99c7c7ffce2 100644 --- a/net/core/dst.c +++ b/net/core/dst.c | |||
| @@ -370,6 +370,7 @@ static int dst_dev_event(struct notifier_block *this, unsigned long event, | |||
| 370 | 370 | ||
| 371 | static struct notifier_block dst_dev_notifier = { | 371 | static struct notifier_block dst_dev_notifier = { |
| 372 | .notifier_call = dst_dev_event, | 372 | .notifier_call = dst_dev_event, |
| 373 | .priority = -10, /* must be called after other network notifiers */ | ||
| 373 | }; | 374 | }; |
| 374 | 375 | ||
| 375 | void __init dst_init(void) | 376 | void __init dst_init(void) |
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c index 82a4369ae150..a20e5d3bbfa0 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c | |||
| @@ -181,8 +181,7 @@ static int fib_rule_match(struct fib_rule *rule, struct fib_rules_ops *ops, | |||
| 181 | { | 181 | { |
| 182 | int ret = 0; | 182 | int ret = 0; |
| 183 | 183 | ||
| 184 | if (rule->iifindex && (rule->iifindex != fl->iif) && | 184 | if (rule->iifindex && (rule->iifindex != fl->iif)) |
| 185 | !(fl->flags & FLOWI_FLAG_MATCH_ANY_IIF)) | ||
| 186 | goto out; | 185 | goto out; |
| 187 | 186 | ||
| 188 | if (rule->oifindex && (rule->oifindex != fl->oif)) | 187 | if (rule->oifindex && (rule->oifindex != fl->oif)) |
diff --git a/net/core/filter.c b/net/core/filter.c index 7beaec36b541..ae21a0d3c4a2 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
| @@ -112,39 +112,41 @@ EXPORT_SYMBOL(sk_filter); | |||
| 112 | */ | 112 | */ |
| 113 | unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen) | 113 | unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen) |
| 114 | { | 114 | { |
| 115 | struct sock_filter *fentry; /* We walk down these */ | ||
| 116 | void *ptr; | 115 | void *ptr; |
| 117 | u32 A = 0; /* Accumulator */ | 116 | u32 A = 0; /* Accumulator */ |
| 118 | u32 X = 0; /* Index Register */ | 117 | u32 X = 0; /* Index Register */ |
| 119 | u32 mem[BPF_MEMWORDS]; /* Scratch Memory Store */ | 118 | u32 mem[BPF_MEMWORDS]; /* Scratch Memory Store */ |
| 119 | unsigned long memvalid = 0; | ||
| 120 | u32 tmp; | 120 | u32 tmp; |
| 121 | int k; | 121 | int k; |
| 122 | int pc; | 122 | int pc; |
| 123 | 123 | ||
| 124 | BUILD_BUG_ON(BPF_MEMWORDS > BITS_PER_LONG); | ||
| 124 | /* | 125 | /* |
| 125 | * Process array of filter instructions. | 126 | * Process array of filter instructions. |
| 126 | */ | 127 | */ |
| 127 | for (pc = 0; pc < flen; pc++) { | 128 | for (pc = 0; pc < flen; pc++) { |
| 128 | fentry = &filter[pc]; | 129 | const struct sock_filter *fentry = &filter[pc]; |
| 130 | u32 f_k = fentry->k; | ||
| 129 | 131 | ||
| 130 | switch (fentry->code) { | 132 | switch (fentry->code) { |
| 131 | case BPF_S_ALU_ADD_X: | 133 | case BPF_S_ALU_ADD_X: |
| 132 | A += X; | 134 | A += X; |
| 133 | continue; | 135 | continue; |
| 134 | case BPF_S_ALU_ADD_K: | 136 | case BPF_S_ALU_ADD_K: |
| 135 | A += fentry->k; | 137 | A += f_k; |
| 136 | continue; | 138 | continue; |
| 137 | case BPF_S_ALU_SUB_X: | 139 | case BPF_S_ALU_SUB_X: |
| 138 | A -= X; | 140 | A -= X; |
| 139 | continue; | 141 | continue; |
| 140 | case BPF_S_ALU_SUB_K: | 142 | case BPF_S_ALU_SUB_K: |
| 141 | A -= fentry->k; | 143 | A -= f_k; |
| 142 | continue; | 144 | continue; |
| 143 | case BPF_S_ALU_MUL_X: | 145 | case BPF_S_ALU_MUL_X: |
| 144 | A *= X; | 146 | A *= X; |
| 145 | continue; | 147 | continue; |
| 146 | case BPF_S_ALU_MUL_K: | 148 | case BPF_S_ALU_MUL_K: |
| 147 | A *= fentry->k; | 149 | A *= f_k; |
| 148 | continue; | 150 | continue; |
| 149 | case BPF_S_ALU_DIV_X: | 151 | case BPF_S_ALU_DIV_X: |
| 150 | if (X == 0) | 152 | if (X == 0) |
| @@ -152,49 +154,49 @@ unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int | |||
| 152 | A /= X; | 154 | A /= X; |
| 153 | continue; | 155 | continue; |
| 154 | case BPF_S_ALU_DIV_K: | 156 | case BPF_S_ALU_DIV_K: |
| 155 | A /= fentry->k; | 157 | A /= f_k; |
| 156 | continue; | 158 | continue; |
| 157 | case BPF_S_ALU_AND_X: | 159 | case BPF_S_ALU_AND_X: |
| 158 | A &= X; | 160 | A &= X; |
| 159 | continue; | 161 | continue; |
| 160 | case BPF_S_ALU_AND_K: | 162 | case BPF_S_ALU_AND_K: |
| 161 | A &= fentry->k; | 163 | A &= f_k; |
| 162 | continue; | 164 | continue; |
| 163 | case BPF_S_ALU_OR_X: | 165 | case BPF_S_ALU_OR_X: |
| 164 | A |= X; | 166 | A |= X; |
| 165 | continue; | 167 | continue; |
| 166 | case BPF_S_ALU_OR_K: | 168 | case BPF_S_ALU_OR_K: |
| 167 | A |= fentry->k; | 169 | A |= f_k; |
| 168 | continue; | 170 | continue; |
| 169 | case BPF_S_ALU_LSH_X: | 171 | case BPF_S_ALU_LSH_X: |
| 170 | A <<= X; | 172 | A <<= X; |
| 171 | continue; | 173 | continue; |
| 172 | case BPF_S_ALU_LSH_K: | 174 | case BPF_S_ALU_LSH_K: |
| 173 | A <<= fentry->k; | 175 | A <<= f_k; |
| 174 | continue; | 176 | continue; |
| 175 | case BPF_S_ALU_RSH_X: | 177 | case BPF_S_ALU_RSH_X: |
| 176 | A >>= X; | 178 | A >>= X; |
| 177 | continue; | 179 | continue; |
| 178 | case BPF_S_ALU_RSH_K: | 180 | case BPF_S_ALU_RSH_K: |
| 179 | A >>= fentry->k; | 181 | A >>= f_k; |
| 180 | continue; | 182 | continue; |
| 181 | case BPF_S_ALU_NEG: | 183 | case BPF_S_ALU_NEG: |
| 182 | A = -A; | 184 | A = -A; |
| 183 | continue; | 185 | continue; |
| 184 | case BPF_S_JMP_JA: | 186 | case BPF_S_JMP_JA: |
| 185 | pc += fentry->k; | 187 | pc += f_k; |
| 186 | continue; | 188 | continue; |
| 187 | case BPF_S_JMP_JGT_K: | 189 | case BPF_S_JMP_JGT_K: |
| 188 | pc += (A > fentry->k) ? fentry->jt : fentry->jf; | 190 | pc += (A > f_k) ? fentry->jt : fentry->jf; |
| 189 | continue; | 191 | continue; |
| 190 | case BPF_S_JMP_JGE_K: | 192 | case BPF_S_JMP_JGE_K: |
| 191 | pc += (A >= fentry->k) ? fentry->jt : fentry->jf; | 193 | pc += (A >= f_k) ? fentry->jt : fentry->jf; |
| 192 | continue; | 194 | continue; |
| 193 | case BPF_S_JMP_JEQ_K: | 195 | case BPF_S_JMP_JEQ_K: |
| 194 | pc += (A == fentry->k) ? fentry->jt : fentry->jf; | 196 | pc += (A == f_k) ? fentry->jt : fentry->jf; |
| 195 | continue; | 197 | continue; |
| 196 | case BPF_S_JMP_JSET_K: | 198 | case BPF_S_JMP_JSET_K: |
| 197 | pc += (A & fentry->k) ? fentry->jt : fentry->jf; | 199 | pc += (A & f_k) ? fentry->jt : fentry->jf; |
| 198 | continue; | 200 | continue; |
| 199 | case BPF_S_JMP_JGT_X: | 201 | case BPF_S_JMP_JGT_X: |
| 200 | pc += (A > X) ? fentry->jt : fentry->jf; | 202 | pc += (A > X) ? fentry->jt : fentry->jf; |
| @@ -209,7 +211,7 @@ unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int | |||
| 209 | pc += (A & X) ? fentry->jt : fentry->jf; | 211 | pc += (A & X) ? fentry->jt : fentry->jf; |
| 210 | continue; | 212 | continue; |
| 211 | case BPF_S_LD_W_ABS: | 213 | case BPF_S_LD_W_ABS: |
| 212 | k = fentry->k; | 214 | k = f_k; |
| 213 | load_w: | 215 | load_w: |
| 214 | ptr = load_pointer(skb, k, 4, &tmp); | 216 | ptr = load_pointer(skb, k, 4, &tmp); |
| 215 | if (ptr != NULL) { | 217 | if (ptr != NULL) { |
| @@ -218,7 +220,7 @@ load_w: | |||
| 218 | } | 220 | } |
| 219 | break; | 221 | break; |
| 220 | case BPF_S_LD_H_ABS: | 222 | case BPF_S_LD_H_ABS: |
| 221 | k = fentry->k; | 223 | k = f_k; |
| 222 | load_h: | 224 | load_h: |
| 223 | ptr = load_pointer(skb, k, 2, &tmp); | 225 | ptr = load_pointer(skb, k, 2, &tmp); |
| 224 | if (ptr != NULL) { | 226 | if (ptr != NULL) { |
| @@ -227,7 +229,7 @@ load_h: | |||
| 227 | } | 229 | } |
| 228 | break; | 230 | break; |
| 229 | case BPF_S_LD_B_ABS: | 231 | case BPF_S_LD_B_ABS: |
| 230 | k = fentry->k; | 232 | k = f_k; |
| 231 | load_b: | 233 | load_b: |
| 232 | ptr = load_pointer(skb, k, 1, &tmp); | 234 | ptr = load_pointer(skb, k, 1, &tmp); |
| 233 | if (ptr != NULL) { | 235 | if (ptr != NULL) { |
| @@ -242,32 +244,34 @@ load_b: | |||
| 242 | X = skb->len; | 244 | X = skb->len; |
| 243 | continue; | 245 | continue; |
| 244 | case BPF_S_LD_W_IND: | 246 | case BPF_S_LD_W_IND: |
| 245 | k = X + fentry->k; | 247 | k = X + f_k; |
| 246 | goto load_w; | 248 | goto load_w; |
| 247 | case BPF_S_LD_H_IND: | 249 | case BPF_S_LD_H_IND: |
| 248 | k = X + fentry->k; | 250 | k = X + f_k; |
| 249 | goto load_h; | 251 | goto load_h; |
| 250 | case BPF_S_LD_B_IND: | 252 | case BPF_S_LD_B_IND: |
| 251 | k = X + fentry->k; | 253 | k = X + f_k; |
| 252 | goto load_b; | 254 | goto load_b; |
| 253 | case BPF_S_LDX_B_MSH: | 255 | case BPF_S_LDX_B_MSH: |
| 254 | ptr = load_pointer(skb, fentry->k, 1, &tmp); | 256 | ptr = load_pointer(skb, f_k, 1, &tmp); |
| 255 | if (ptr != NULL) { | 257 | if (ptr != NULL) { |
| 256 | X = (*(u8 *)ptr & 0xf) << 2; | 258 | X = (*(u8 *)ptr & 0xf) << 2; |
| 257 | continue; | 259 | continue; |
| 258 | } | 260 | } |
| 259 | return 0; | 261 | return 0; |
| 260 | case BPF_S_LD_IMM: | 262 | case BPF_S_LD_IMM: |
| 261 | A = fentry->k; | 263 | A = f_k; |
| 262 | continue; | 264 | continue; |
| 263 | case BPF_S_LDX_IMM: | 265 | case BPF_S_LDX_IMM: |
| 264 | X = fentry->k; | 266 | X = f_k; |
| 265 | continue; | 267 | continue; |
| 266 | case BPF_S_LD_MEM: | 268 | case BPF_S_LD_MEM: |
| 267 | A = mem[fentry->k]; | 269 | A = (memvalid & (1UL << f_k)) ? |
| 270 | mem[f_k] : 0; | ||
| 268 | continue; | 271 | continue; |
| 269 | case BPF_S_LDX_MEM: | 272 | case BPF_S_LDX_MEM: |
| 270 | X = mem[fentry->k]; | 273 | X = (memvalid & (1UL << f_k)) ? |
| 274 | mem[f_k] : 0; | ||
| 271 | continue; | 275 | continue; |
| 272 | case BPF_S_MISC_TAX: | 276 | case BPF_S_MISC_TAX: |
| 273 | X = A; | 277 | X = A; |
| @@ -276,14 +280,16 @@ load_b: | |||
| 276 | A = X; | 280 | A = X; |
| 277 | continue; | 281 | continue; |
| 278 | case BPF_S_RET_K: | 282 | case BPF_S_RET_K: |
| 279 | return fentry->k; | 283 | return f_k; |
| 280 | case BPF_S_RET_A: | 284 | case BPF_S_RET_A: |
| 281 | return A; | 285 | return A; |
| 282 | case BPF_S_ST: | 286 | case BPF_S_ST: |
| 283 | mem[fentry->k] = A; | 287 | memvalid |= 1UL << f_k; |
| 288 | mem[f_k] = A; | ||
| 284 | continue; | 289 | continue; |
| 285 | case BPF_S_STX: | 290 | case BPF_S_STX: |
| 286 | mem[fentry->k] = X; | 291 | memvalid |= 1UL << f_k; |
| 292 | mem[f_k] = X; | ||
| 287 | continue; | 293 | continue; |
| 288 | default: | 294 | default: |
| 289 | WARN_ON(1); | 295 | WARN_ON(1); |
| @@ -583,23 +589,16 @@ int sk_chk_filter(struct sock_filter *filter, int flen) | |||
| 583 | EXPORT_SYMBOL(sk_chk_filter); | 589 | EXPORT_SYMBOL(sk_chk_filter); |
| 584 | 590 | ||
| 585 | /** | 591 | /** |
| 586 | * sk_filter_rcu_release: Release a socket filter by rcu_head | 592 | * sk_filter_release_rcu - Release a socket filter by rcu_head |
| 587 | * @rcu: rcu_head that contains the sk_filter to free | 593 | * @rcu: rcu_head that contains the sk_filter to free |
| 588 | */ | 594 | */ |
| 589 | static void sk_filter_rcu_release(struct rcu_head *rcu) | 595 | void sk_filter_release_rcu(struct rcu_head *rcu) |
| 590 | { | 596 | { |
| 591 | struct sk_filter *fp = container_of(rcu, struct sk_filter, rcu); | 597 | struct sk_filter *fp = container_of(rcu, struct sk_filter, rcu); |
| 592 | 598 | ||
| 593 | sk_filter_release(fp); | 599 | kfree(fp); |
| 594 | } | ||
| 595 | |||
| 596 | static void sk_filter_delayed_uncharge(struct sock *sk, struct sk_filter *fp) | ||
| 597 | { | ||
| 598 | unsigned int size = sk_filter_len(fp); | ||
| 599 | |||
| 600 | atomic_sub(size, &sk->sk_omem_alloc); | ||
| 601 | call_rcu_bh(&fp->rcu, sk_filter_rcu_release); | ||
| 602 | } | 600 | } |
| 601 | EXPORT_SYMBOL(sk_filter_release_rcu); | ||
| 603 | 602 | ||
| 604 | /** | 603 | /** |
| 605 | * sk_attach_filter - attach a socket filter | 604 | * sk_attach_filter - attach a socket filter |
| @@ -643,7 +642,7 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk) | |||
| 643 | rcu_assign_pointer(sk->sk_filter, fp); | 642 | rcu_assign_pointer(sk->sk_filter, fp); |
| 644 | 643 | ||
| 645 | if (old_fp) | 644 | if (old_fp) |
| 646 | sk_filter_delayed_uncharge(sk, old_fp); | 645 | sk_filter_uncharge(sk, old_fp); |
| 647 | return 0; | 646 | return 0; |
| 648 | } | 647 | } |
| 649 | EXPORT_SYMBOL_GPL(sk_attach_filter); | 648 | EXPORT_SYMBOL_GPL(sk_attach_filter); |
| @@ -657,7 +656,7 @@ int sk_detach_filter(struct sock *sk) | |||
| 657 | sock_owned_by_user(sk)); | 656 | sock_owned_by_user(sk)); |
| 658 | if (filter) { | 657 | if (filter) { |
| 659 | rcu_assign_pointer(sk->sk_filter, NULL); | 658 | rcu_assign_pointer(sk->sk_filter, NULL); |
| 660 | sk_filter_delayed_uncharge(sk, filter); | 659 | sk_filter_uncharge(sk, filter); |
| 661 | ret = 0; | 660 | ret = 0; |
| 662 | } | 661 | } |
| 663 | return ret; | 662 | return ret; |
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index a5ff5a89f376..7f902cad10f8 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
| @@ -712,15 +712,21 @@ static void rx_queue_release(struct kobject *kobj) | |||
| 712 | 712 | ||
| 713 | 713 | ||
| 714 | map = rcu_dereference_raw(queue->rps_map); | 714 | map = rcu_dereference_raw(queue->rps_map); |
| 715 | if (map) | 715 | if (map) { |
| 716 | RCU_INIT_POINTER(queue->rps_map, NULL); | ||
| 716 | call_rcu(&map->rcu, rps_map_release); | 717 | call_rcu(&map->rcu, rps_map_release); |
| 718 | } | ||
| 717 | 719 | ||
| 718 | flow_table = rcu_dereference_raw(queue->rps_flow_table); | 720 | flow_table = rcu_dereference_raw(queue->rps_flow_table); |
| 719 | if (flow_table) | 721 | if (flow_table) { |
| 722 | RCU_INIT_POINTER(queue->rps_flow_table, NULL); | ||
| 720 | call_rcu(&flow_table->rcu, rps_dev_flow_table_release); | 723 | call_rcu(&flow_table->rcu, rps_dev_flow_table_release); |
| 724 | } | ||
| 721 | 725 | ||
| 722 | if (atomic_dec_and_test(&first->count)) | 726 | if (atomic_dec_and_test(&first->count)) |
| 723 | kfree(first); | 727 | kfree(first); |
| 728 | else | ||
| 729 | memset(kobj, 0, sizeof(*kobj)); | ||
| 724 | } | 730 | } |
| 725 | 731 | ||
| 726 | static struct kobj_type rx_queue_ktype = { | 732 | static struct kobj_type rx_queue_ktype = { |
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index fbce4b05a53e..33bc3823ac6f 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
| @@ -887,7 +887,7 @@ static ssize_t pktgen_if_write(struct file *file, | |||
| 887 | i += len; | 887 | i += len; |
| 888 | 888 | ||
| 889 | if (debug) { | 889 | if (debug) { |
| 890 | size_t copy = min(count, 1023); | 890 | size_t copy = min_t(size_t, count, 1023); |
| 891 | char tb[copy + 1]; | 891 | char tb[copy + 1]; |
| 892 | if (copy_from_user(tb, user_buffer, copy)) | 892 | if (copy_from_user(tb, user_buffer, copy)) |
| 893 | return -EFAULT; | 893 | return -EFAULT; |
| @@ -2612,8 +2612,8 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, | |||
| 2612 | /* Update any of the values, used when we're incrementing various | 2612 | /* Update any of the values, used when we're incrementing various |
| 2613 | * fields. | 2613 | * fields. |
| 2614 | */ | 2614 | */ |
| 2615 | queue_map = pkt_dev->cur_queue_map; | ||
| 2616 | mod_cur_headers(pkt_dev); | 2615 | mod_cur_headers(pkt_dev); |
| 2616 | queue_map = pkt_dev->cur_queue_map; | ||
| 2617 | 2617 | ||
| 2618 | datalen = (odev->hard_header_len + 16) & ~0xf; | 2618 | datalen = (odev->hard_header_len + 16) & ~0xf; |
| 2619 | 2619 | ||
| @@ -2976,8 +2976,8 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, | |||
| 2976 | /* Update any of the values, used when we're incrementing various | 2976 | /* Update any of the values, used when we're incrementing various |
| 2977 | * fields. | 2977 | * fields. |
| 2978 | */ | 2978 | */ |
| 2979 | queue_map = pkt_dev->cur_queue_map; | ||
| 2980 | mod_cur_headers(pkt_dev); | 2979 | mod_cur_headers(pkt_dev); |
| 2980 | queue_map = pkt_dev->cur_queue_map; | ||
| 2981 | 2981 | ||
| 2982 | skb = __netdev_alloc_skb(odev, | 2982 | skb = __netdev_alloc_skb(odev, |
| 2983 | pkt_dev->cur_pkt_size + 64 | 2983 | pkt_dev->cur_pkt_size + 64 |
diff --git a/net/core/request_sock.c b/net/core/request_sock.c index 7552495aff7a..fceeb37d7161 100644 --- a/net/core/request_sock.c +++ b/net/core/request_sock.c | |||
| @@ -45,9 +45,7 @@ int reqsk_queue_alloc(struct request_sock_queue *queue, | |||
| 45 | nr_table_entries = roundup_pow_of_two(nr_table_entries + 1); | 45 | nr_table_entries = roundup_pow_of_two(nr_table_entries + 1); |
| 46 | lopt_size += nr_table_entries * sizeof(struct request_sock *); | 46 | lopt_size += nr_table_entries * sizeof(struct request_sock *); |
| 47 | if (lopt_size > PAGE_SIZE) | 47 | if (lopt_size > PAGE_SIZE) |
| 48 | lopt = __vmalloc(lopt_size, | 48 | lopt = vzalloc(lopt_size); |
| 49 | GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, | ||
| 50 | PAGE_KERNEL); | ||
| 51 | else | 49 | else |
| 52 | lopt = kzalloc(lopt_size, GFP_KERNEL); | 50 | lopt = kzalloc(lopt_size, GFP_KERNEL); |
| 53 | if (lopt == NULL) | 51 | if (lopt == NULL) |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 8121268ddbdd..841c287ef40a 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
| @@ -347,16 +347,17 @@ static size_t rtnl_link_get_size(const struct net_device *dev) | |||
| 347 | if (!ops) | 347 | if (!ops) |
| 348 | return 0; | 348 | return 0; |
| 349 | 349 | ||
| 350 | size = nlmsg_total_size(sizeof(struct nlattr)) + /* IFLA_LINKINFO */ | 350 | size = nla_total_size(sizeof(struct nlattr)) + /* IFLA_LINKINFO */ |
| 351 | nlmsg_total_size(strlen(ops->kind) + 1); /* IFLA_INFO_KIND */ | 351 | nla_total_size(strlen(ops->kind) + 1); /* IFLA_INFO_KIND */ |
| 352 | 352 | ||
| 353 | if (ops->get_size) | 353 | if (ops->get_size) |
| 354 | /* IFLA_INFO_DATA + nested data */ | 354 | /* IFLA_INFO_DATA + nested data */ |
| 355 | size += nlmsg_total_size(sizeof(struct nlattr)) + | 355 | size += nla_total_size(sizeof(struct nlattr)) + |
| 356 | ops->get_size(dev); | 356 | ops->get_size(dev); |
| 357 | 357 | ||
| 358 | if (ops->get_xstats_size) | 358 | if (ops->get_xstats_size) |
| 359 | size += ops->get_xstats_size(dev); /* IFLA_INFO_XSTATS */ | 359 | /* IFLA_INFO_XSTATS */ |
| 360 | size += nla_total_size(ops->get_xstats_size(dev)); | ||
| 360 | 361 | ||
| 361 | return size; | 362 | return size; |
| 362 | } | 363 | } |
diff --git a/net/core/sock.c b/net/core/sock.c index 3eed5424e659..e5af8d5d5b50 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
| @@ -1009,6 +1009,36 @@ static void sock_copy(struct sock *nsk, const struct sock *osk) | |||
| 1009 | #endif | 1009 | #endif |
| 1010 | } | 1010 | } |
| 1011 | 1011 | ||
| 1012 | /* | ||
| 1013 | * caches using SLAB_DESTROY_BY_RCU should let .next pointer from nulls nodes | ||
| 1014 | * un-modified. Special care is taken when initializing object to zero. | ||
| 1015 | */ | ||
| 1016 | static inline void sk_prot_clear_nulls(struct sock *sk, int size) | ||
| 1017 | { | ||
| 1018 | if (offsetof(struct sock, sk_node.next) != 0) | ||
| 1019 | memset(sk, 0, offsetof(struct sock, sk_node.next)); | ||
| 1020 | memset(&sk->sk_node.pprev, 0, | ||
| 1021 | size - offsetof(struct sock, sk_node.pprev)); | ||
| 1022 | } | ||
| 1023 | |||
| 1024 | void sk_prot_clear_portaddr_nulls(struct sock *sk, int size) | ||
| 1025 | { | ||
| 1026 | unsigned long nulls1, nulls2; | ||
| 1027 | |||
| 1028 | nulls1 = offsetof(struct sock, __sk_common.skc_node.next); | ||
| 1029 | nulls2 = offsetof(struct sock, __sk_common.skc_portaddr_node.next); | ||
| 1030 | if (nulls1 > nulls2) | ||
| 1031 | swap(nulls1, nulls2); | ||
| 1032 | |||
| 1033 | if (nulls1 != 0) | ||
| 1034 | memset((char *)sk, 0, nulls1); | ||
| 1035 | memset((char *)sk + nulls1 + sizeof(void *), 0, | ||
| 1036 | nulls2 - nulls1 - sizeof(void *)); | ||
| 1037 | memset((char *)sk + nulls2 + sizeof(void *), 0, | ||
| 1038 | size - nulls2 - sizeof(void *)); | ||
| 1039 | } | ||
| 1040 | EXPORT_SYMBOL(sk_prot_clear_portaddr_nulls); | ||
| 1041 | |||
| 1012 | static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority, | 1042 | static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority, |
| 1013 | int family) | 1043 | int family) |
| 1014 | { | 1044 | { |
| @@ -1021,19 +1051,12 @@ static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority, | |||
| 1021 | if (!sk) | 1051 | if (!sk) |
| 1022 | return sk; | 1052 | return sk; |
| 1023 | if (priority & __GFP_ZERO) { | 1053 | if (priority & __GFP_ZERO) { |
| 1024 | /* | 1054 | if (prot->clear_sk) |
| 1025 | * caches using SLAB_DESTROY_BY_RCU should let | 1055 | prot->clear_sk(sk, prot->obj_size); |
| 1026 | * sk_node.next un-modified. Special care is taken | 1056 | else |
| 1027 | * when initializing object to zero. | 1057 | sk_prot_clear_nulls(sk, prot->obj_size); |
| 1028 | */ | ||
| 1029 | if (offsetof(struct sock, sk_node.next) != 0) | ||
| 1030 | memset(sk, 0, offsetof(struct sock, sk_node.next)); | ||
| 1031 | memset(&sk->sk_node.pprev, 0, | ||
| 1032 | prot->obj_size - offsetof(struct sock, | ||
| 1033 | sk_node.pprev)); | ||
| 1034 | } | 1058 | } |
| 1035 | } | 1059 | } else |
| 1036 | else | ||
| 1037 | sk = kmalloc(prot->obj_size, priority); | 1060 | sk = kmalloc(prot->obj_size, priority); |
| 1038 | 1061 | ||
| 1039 | if (sk != NULL) { | 1062 | if (sk != NULL) { |
| @@ -1653,10 +1676,10 @@ int __sk_mem_schedule(struct sock *sk, int size, int kind) | |||
| 1653 | { | 1676 | { |
| 1654 | struct proto *prot = sk->sk_prot; | 1677 | struct proto *prot = sk->sk_prot; |
| 1655 | int amt = sk_mem_pages(size); | 1678 | int amt = sk_mem_pages(size); |
| 1656 | int allocated; | 1679 | long allocated; |
| 1657 | 1680 | ||
| 1658 | sk->sk_forward_alloc += amt * SK_MEM_QUANTUM; | 1681 | sk->sk_forward_alloc += amt * SK_MEM_QUANTUM; |
| 1659 | allocated = atomic_add_return(amt, prot->memory_allocated); | 1682 | allocated = atomic_long_add_return(amt, prot->memory_allocated); |
| 1660 | 1683 | ||
| 1661 | /* Under limit. */ | 1684 | /* Under limit. */ |
| 1662 | if (allocated <= prot->sysctl_mem[0]) { | 1685 | if (allocated <= prot->sysctl_mem[0]) { |
| @@ -1714,7 +1737,7 @@ suppress_allocation: | |||
| 1714 | 1737 | ||
| 1715 | /* Alas. Undo changes. */ | 1738 | /* Alas. Undo changes. */ |
| 1716 | sk->sk_forward_alloc -= amt * SK_MEM_QUANTUM; | 1739 | sk->sk_forward_alloc -= amt * SK_MEM_QUANTUM; |
| 1717 | atomic_sub(amt, prot->memory_allocated); | 1740 | atomic_long_sub(amt, prot->memory_allocated); |
| 1718 | return 0; | 1741 | return 0; |
| 1719 | } | 1742 | } |
| 1720 | EXPORT_SYMBOL(__sk_mem_schedule); | 1743 | EXPORT_SYMBOL(__sk_mem_schedule); |
| @@ -1727,12 +1750,12 @@ void __sk_mem_reclaim(struct sock *sk) | |||
| 1727 | { | 1750 | { |
| 1728 | struct proto *prot = sk->sk_prot; | 1751 | struct proto *prot = sk->sk_prot; |
| 1729 | 1752 | ||
| 1730 | atomic_sub(sk->sk_forward_alloc >> SK_MEM_QUANTUM_SHIFT, | 1753 | atomic_long_sub(sk->sk_forward_alloc >> SK_MEM_QUANTUM_SHIFT, |
| 1731 | prot->memory_allocated); | 1754 | prot->memory_allocated); |
| 1732 | sk->sk_forward_alloc &= SK_MEM_QUANTUM - 1; | 1755 | sk->sk_forward_alloc &= SK_MEM_QUANTUM - 1; |
| 1733 | 1756 | ||
| 1734 | if (prot->memory_pressure && *prot->memory_pressure && | 1757 | if (prot->memory_pressure && *prot->memory_pressure && |
| 1735 | (atomic_read(prot->memory_allocated) < prot->sysctl_mem[0])) | 1758 | (atomic_long_read(prot->memory_allocated) < prot->sysctl_mem[0])) |
| 1736 | *prot->memory_pressure = 0; | 1759 | *prot->memory_pressure = 0; |
| 1737 | } | 1760 | } |
| 1738 | EXPORT_SYMBOL(__sk_mem_reclaim); | 1761 | EXPORT_SYMBOL(__sk_mem_reclaim); |
| @@ -2452,12 +2475,12 @@ static char proto_method_implemented(const void *method) | |||
| 2452 | 2475 | ||
| 2453 | static void proto_seq_printf(struct seq_file *seq, struct proto *proto) | 2476 | static void proto_seq_printf(struct seq_file *seq, struct proto *proto) |
| 2454 | { | 2477 | { |
| 2455 | seq_printf(seq, "%-9s %4u %6d %6d %-3s %6u %-3s %-10s " | 2478 | seq_printf(seq, "%-9s %4u %6d %6ld %-3s %6u %-3s %-10s " |
| 2456 | "%2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c\n", | 2479 | "%2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c\n", |
| 2457 | proto->name, | 2480 | proto->name, |
| 2458 | proto->obj_size, | 2481 | proto->obj_size, |
| 2459 | sock_prot_inuse_get(seq_file_net(seq), proto), | 2482 | sock_prot_inuse_get(seq_file_net(seq), proto), |
| 2460 | proto->memory_allocated != NULL ? atomic_read(proto->memory_allocated) : -1, | 2483 | proto->memory_allocated != NULL ? atomic_long_read(proto->memory_allocated) : -1L, |
| 2461 | proto->memory_pressure != NULL ? *proto->memory_pressure ? "yes" : "no" : "NI", | 2484 | proto->memory_pressure != NULL ? *proto->memory_pressure ? "yes" : "no" : "NI", |
| 2462 | proto->max_header, | 2485 | proto->max_header, |
| 2463 | proto->slab == NULL ? "no" : "yes", | 2486 | proto->slab == NULL ? "no" : "yes", |
diff --git a/net/core/timestamping.c b/net/core/timestamping.c index 0ae6c22da85b..c19bb4ee405e 100644 --- a/net/core/timestamping.c +++ b/net/core/timestamping.c | |||
| @@ -96,11 +96,13 @@ bool skb_defer_rx_timestamp(struct sk_buff *skb) | |||
| 96 | struct phy_device *phydev; | 96 | struct phy_device *phydev; |
| 97 | unsigned int type; | 97 | unsigned int type; |
| 98 | 98 | ||
| 99 | skb_push(skb, ETH_HLEN); | 99 | if (skb_headroom(skb) < ETH_HLEN) |
| 100 | return false; | ||
| 101 | __skb_push(skb, ETH_HLEN); | ||
| 100 | 102 | ||
| 101 | type = classify(skb); | 103 | type = classify(skb); |
| 102 | 104 | ||
| 103 | skb_pull(skb, ETH_HLEN); | 105 | __skb_pull(skb, ETH_HLEN); |
| 104 | 106 | ||
| 105 | switch (type) { | 107 | switch (type) { |
| 106 | case PTP_CLASS_V1_IPV4: | 108 | case PTP_CLASS_V1_IPV4: |
diff --git a/net/dccp/input.c b/net/dccp/input.c index 265985370fa1..e424a09e83f6 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c | |||
| @@ -239,7 +239,8 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb) | |||
| 239 | dccp_update_gsr(sk, seqno); | 239 | dccp_update_gsr(sk, seqno); |
| 240 | 240 | ||
| 241 | if (dh->dccph_type != DCCP_PKT_SYNC && | 241 | if (dh->dccph_type != DCCP_PKT_SYNC && |
| 242 | (ackno != DCCP_PKT_WITHOUT_ACK_SEQ)) | 242 | ackno != DCCP_PKT_WITHOUT_ACK_SEQ && |
| 243 | after48(ackno, dp->dccps_gar)) | ||
| 243 | dp->dccps_gar = ackno; | 244 | dp->dccps_gar = ackno; |
| 244 | } else { | 245 | } else { |
| 245 | unsigned long now = jiffies; | 246 | unsigned long now = jiffies; |
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index d6b93d19790f..6f97268ed85f 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c | |||
| @@ -155,7 +155,7 @@ static const struct proto_ops dn_proto_ops; | |||
| 155 | static DEFINE_RWLOCK(dn_hash_lock); | 155 | static DEFINE_RWLOCK(dn_hash_lock); |
| 156 | static struct hlist_head dn_sk_hash[DN_SK_HASH_SIZE]; | 156 | static struct hlist_head dn_sk_hash[DN_SK_HASH_SIZE]; |
| 157 | static struct hlist_head dn_wild_sk; | 157 | static struct hlist_head dn_wild_sk; |
| 158 | static atomic_t decnet_memory_allocated; | 158 | static atomic_long_t decnet_memory_allocated; |
| 159 | 159 | ||
| 160 | static int __dn_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen, int flags); | 160 | static int __dn_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen, int flags); |
| 161 | static int __dn_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen, int flags); | 161 | static int __dn_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen, int flags); |
| @@ -1556,6 +1556,8 @@ static int __dn_getsockopt(struct socket *sock, int level,int optname, char __us | |||
| 1556 | if (r_len > sizeof(struct linkinfo_dn)) | 1556 | if (r_len > sizeof(struct linkinfo_dn)) |
| 1557 | r_len = sizeof(struct linkinfo_dn); | 1557 | r_len = sizeof(struct linkinfo_dn); |
| 1558 | 1558 | ||
| 1559 | memset(&link, 0, sizeof(link)); | ||
| 1560 | |||
| 1559 | switch(sock->state) { | 1561 | switch(sock->state) { |
| 1560 | case SS_CONNECTING: | 1562 | case SS_CONNECTING: |
| 1561 | link.idn_linkstate = LL_CONNECTING; | 1563 | link.idn_linkstate = LL_CONNECTING; |
diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c index be3eb8e23288..28f8b5e5f73b 100644 --- a/net/decnet/sysctl_net_decnet.c +++ b/net/decnet/sysctl_net_decnet.c | |||
| @@ -38,7 +38,7 @@ int decnet_log_martians = 1; | |||
| 38 | int decnet_no_fc_max_cwnd = NSP_MIN_WINDOW; | 38 | int decnet_no_fc_max_cwnd = NSP_MIN_WINDOW; |
| 39 | 39 | ||
| 40 | /* Reasonable defaults, I hope, based on tcp's defaults */ | 40 | /* Reasonable defaults, I hope, based on tcp's defaults */ |
| 41 | int sysctl_decnet_mem[3] = { 768 << 3, 1024 << 3, 1536 << 3 }; | 41 | long sysctl_decnet_mem[3] = { 768 << 3, 1024 << 3, 1536 << 3 }; |
| 42 | int sysctl_decnet_wmem[3] = { 4 * 1024, 16 * 1024, 128 * 1024 }; | 42 | int sysctl_decnet_wmem[3] = { 4 * 1024, 16 * 1024, 128 * 1024 }; |
| 43 | int sysctl_decnet_rmem[3] = { 4 * 1024, 87380, 87380 * 2 }; | 43 | int sysctl_decnet_rmem[3] = { 4 * 1024, 87380, 87380 * 2 }; |
| 44 | 44 | ||
| @@ -324,7 +324,7 @@ static ctl_table dn_table[] = { | |||
| 324 | .data = &sysctl_decnet_mem, | 324 | .data = &sysctl_decnet_mem, |
| 325 | .maxlen = sizeof(sysctl_decnet_mem), | 325 | .maxlen = sizeof(sysctl_decnet_mem), |
| 326 | .mode = 0644, | 326 | .mode = 0644, |
| 327 | .proc_handler = proc_dointvec, | 327 | .proc_handler = proc_doulongvec_minmax |
| 328 | }, | 328 | }, |
| 329 | { | 329 | { |
| 330 | .procname = "decnet_rmem", | 330 | .procname = "decnet_rmem", |
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index f8c1ae4b41f0..15dcc1a586b4 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #include <linux/skbuff.h> | 31 | #include <linux/skbuff.h> |
| 32 | #include <linux/udp.h> | 32 | #include <linux/udp.h> |
| 33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
| 34 | #include <linux/vmalloc.h> | ||
| 34 | #include <net/sock.h> | 35 | #include <net/sock.h> |
| 35 | #include <net/inet_common.h> | 36 | #include <net/inet_common.h> |
| 36 | #include <linux/stat.h> | 37 | #include <linux/stat.h> |
| @@ -276,12 +277,12 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 276 | #endif | 277 | #endif |
| 277 | #ifdef CONFIG_ECONET_AUNUDP | 278 | #ifdef CONFIG_ECONET_AUNUDP |
| 278 | struct msghdr udpmsg; | 279 | struct msghdr udpmsg; |
| 279 | struct iovec iov[msg->msg_iovlen+1]; | 280 | struct iovec iov[2]; |
| 280 | struct aunhdr ah; | 281 | struct aunhdr ah; |
| 281 | struct sockaddr_in udpdest; | 282 | struct sockaddr_in udpdest; |
| 282 | __kernel_size_t size; | 283 | __kernel_size_t size; |
| 283 | int i; | ||
| 284 | mm_segment_t oldfs; | 284 | mm_segment_t oldfs; |
| 285 | char *userbuf; | ||
| 285 | #endif | 286 | #endif |
| 286 | 287 | ||
| 287 | /* | 288 | /* |
| @@ -297,23 +298,14 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 297 | 298 | ||
| 298 | mutex_lock(&econet_mutex); | 299 | mutex_lock(&econet_mutex); |
| 299 | 300 | ||
| 300 | if (saddr == NULL) { | 301 | if (saddr == NULL || msg->msg_namelen < sizeof(struct sockaddr_ec)) { |
| 301 | struct econet_sock *eo = ec_sk(sk); | 302 | mutex_unlock(&econet_mutex); |
| 302 | 303 | return -EINVAL; | |
| 303 | addr.station = eo->station; | 304 | } |
| 304 | addr.net = eo->net; | 305 | addr.station = saddr->addr.station; |
| 305 | port = eo->port; | 306 | addr.net = saddr->addr.net; |
| 306 | cb = eo->cb; | 307 | port = saddr->port; |
| 307 | } else { | 308 | cb = saddr->cb; |
| 308 | if (msg->msg_namelen < sizeof(struct sockaddr_ec)) { | ||
| 309 | mutex_unlock(&econet_mutex); | ||
| 310 | return -EINVAL; | ||
| 311 | } | ||
| 312 | addr.station = saddr->addr.station; | ||
| 313 | addr.net = saddr->addr.net; | ||
| 314 | port = saddr->port; | ||
| 315 | cb = saddr->cb; | ||
| 316 | } | ||
| 317 | 309 | ||
| 318 | /* Look for a device with the right network number. */ | 310 | /* Look for a device with the right network number. */ |
| 319 | dev = net2dev_map[addr.net]; | 311 | dev = net2dev_map[addr.net]; |
| @@ -328,17 +320,17 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 328 | } | 320 | } |
| 329 | } | 321 | } |
| 330 | 322 | ||
| 331 | if (len + 15 > dev->mtu) { | ||
| 332 | mutex_unlock(&econet_mutex); | ||
| 333 | return -EMSGSIZE; | ||
| 334 | } | ||
| 335 | |||
| 336 | if (dev->type == ARPHRD_ECONET) { | 323 | if (dev->type == ARPHRD_ECONET) { |
| 337 | /* Real hardware Econet. We're not worthy etc. */ | 324 | /* Real hardware Econet. We're not worthy etc. */ |
| 338 | #ifdef CONFIG_ECONET_NATIVE | 325 | #ifdef CONFIG_ECONET_NATIVE |
| 339 | unsigned short proto = 0; | 326 | unsigned short proto = 0; |
| 340 | int res; | 327 | int res; |
| 341 | 328 | ||
| 329 | if (len + 15 > dev->mtu) { | ||
| 330 | mutex_unlock(&econet_mutex); | ||
| 331 | return -EMSGSIZE; | ||
| 332 | } | ||
| 333 | |||
| 342 | dev_hold(dev); | 334 | dev_hold(dev); |
| 343 | 335 | ||
| 344 | skb = sock_alloc_send_skb(sk, len+LL_ALLOCATED_SPACE(dev), | 336 | skb = sock_alloc_send_skb(sk, len+LL_ALLOCATED_SPACE(dev), |
| @@ -351,7 +343,6 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 351 | 343 | ||
| 352 | eb = (struct ec_cb *)&skb->cb; | 344 | eb = (struct ec_cb *)&skb->cb; |
| 353 | 345 | ||
| 354 | /* BUG: saddr may be NULL */ | ||
| 355 | eb->cookie = saddr->cookie; | 346 | eb->cookie = saddr->cookie; |
| 356 | eb->sec = *saddr; | 347 | eb->sec = *saddr; |
| 357 | eb->sent = ec_tx_done; | 348 | eb->sent = ec_tx_done; |
| @@ -415,6 +406,11 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 415 | return -ENETDOWN; /* No socket - can't send */ | 406 | return -ENETDOWN; /* No socket - can't send */ |
| 416 | } | 407 | } |
| 417 | 408 | ||
| 409 | if (len > 32768) { | ||
| 410 | err = -E2BIG; | ||
| 411 | goto error; | ||
| 412 | } | ||
| 413 | |||
| 418 | /* Make up a UDP datagram and hand it off to some higher intellect. */ | 414 | /* Make up a UDP datagram and hand it off to some higher intellect. */ |
| 419 | 415 | ||
| 420 | memset(&udpdest, 0, sizeof(udpdest)); | 416 | memset(&udpdest, 0, sizeof(udpdest)); |
| @@ -446,36 +442,26 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 446 | 442 | ||
| 447 | /* tack our header on the front of the iovec */ | 443 | /* tack our header on the front of the iovec */ |
| 448 | size = sizeof(struct aunhdr); | 444 | size = sizeof(struct aunhdr); |
| 449 | /* | ||
| 450 | * XXX: that is b0rken. We can't mix userland and kernel pointers | ||
| 451 | * in iovec, since on a lot of platforms copy_from_user() will | ||
| 452 | * *not* work with the kernel and userland ones at the same time, | ||
| 453 | * regardless of what we do with set_fs(). And we are talking about | ||
| 454 | * econet-over-ethernet here, so "it's only ARM anyway" doesn't | ||
| 455 | * apply. Any suggestions on fixing that code? -- AV | ||
| 456 | */ | ||
| 457 | iov[0].iov_base = (void *)&ah; | 445 | iov[0].iov_base = (void *)&ah; |
| 458 | iov[0].iov_len = size; | 446 | iov[0].iov_len = size; |
| 459 | for (i = 0; i < msg->msg_iovlen; i++) { | 447 | |
| 460 | void __user *base = msg->msg_iov[i].iov_base; | 448 | userbuf = vmalloc(len); |
| 461 | size_t iov_len = msg->msg_iov[i].iov_len; | 449 | if (userbuf == NULL) { |
| 462 | /* Check it now since we switch to KERNEL_DS later. */ | 450 | err = -ENOMEM; |
| 463 | if (!access_ok(VERIFY_READ, base, iov_len)) { | 451 | goto error; |
| 464 | mutex_unlock(&econet_mutex); | ||
| 465 | return -EFAULT; | ||
| 466 | } | ||
| 467 | iov[i+1].iov_base = base; | ||
| 468 | iov[i+1].iov_len = iov_len; | ||
| 469 | size += iov_len; | ||
| 470 | } | 452 | } |
| 471 | 453 | ||
| 454 | iov[1].iov_base = userbuf; | ||
| 455 | iov[1].iov_len = len; | ||
| 456 | err = memcpy_fromiovec(userbuf, msg->msg_iov, len); | ||
| 457 | if (err) | ||
| 458 | goto error_free_buf; | ||
| 459 | |||
| 472 | /* Get a skbuff (no data, just holds our cb information) */ | 460 | /* Get a skbuff (no data, just holds our cb information) */ |
| 473 | if ((skb = sock_alloc_send_skb(sk, 0, | 461 | if ((skb = sock_alloc_send_skb(sk, 0, |
| 474 | msg->msg_flags & MSG_DONTWAIT, | 462 | msg->msg_flags & MSG_DONTWAIT, |
| 475 | &err)) == NULL) { | 463 | &err)) == NULL) |
| 476 | mutex_unlock(&econet_mutex); | 464 | goto error_free_buf; |
| 477 | return err; | ||
| 478 | } | ||
| 479 | 465 | ||
| 480 | eb = (struct ec_cb *)&skb->cb; | 466 | eb = (struct ec_cb *)&skb->cb; |
| 481 | 467 | ||
| @@ -491,7 +477,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 491 | udpmsg.msg_name = (void *)&udpdest; | 477 | udpmsg.msg_name = (void *)&udpdest; |
| 492 | udpmsg.msg_namelen = sizeof(udpdest); | 478 | udpmsg.msg_namelen = sizeof(udpdest); |
| 493 | udpmsg.msg_iov = &iov[0]; | 479 | udpmsg.msg_iov = &iov[0]; |
| 494 | udpmsg.msg_iovlen = msg->msg_iovlen + 1; | 480 | udpmsg.msg_iovlen = 2; |
| 495 | udpmsg.msg_control = NULL; | 481 | udpmsg.msg_control = NULL; |
| 496 | udpmsg.msg_controllen = 0; | 482 | udpmsg.msg_controllen = 0; |
| 497 | udpmsg.msg_flags=0; | 483 | udpmsg.msg_flags=0; |
| @@ -499,9 +485,13 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 499 | oldfs = get_fs(); set_fs(KERNEL_DS); /* More privs :-) */ | 485 | oldfs = get_fs(); set_fs(KERNEL_DS); /* More privs :-) */ |
| 500 | err = sock_sendmsg(udpsock, &udpmsg, size); | 486 | err = sock_sendmsg(udpsock, &udpmsg, size); |
| 501 | set_fs(oldfs); | 487 | set_fs(oldfs); |
| 488 | |||
| 489 | error_free_buf: | ||
| 490 | vfree(userbuf); | ||
| 502 | #else | 491 | #else |
| 503 | err = -EPROTOTYPE; | 492 | err = -EPROTOTYPE; |
| 504 | #endif | 493 | #endif |
| 494 | error: | ||
| 505 | mutex_unlock(&econet_mutex); | 495 | mutex_unlock(&econet_mutex); |
| 506 | 496 | ||
| 507 | return err; | 497 | return err; |
| @@ -671,6 +661,11 @@ static int ec_dev_ioctl(struct socket *sock, unsigned int cmd, void __user *arg) | |||
| 671 | err = 0; | 661 | err = 0; |
| 672 | switch (cmd) { | 662 | switch (cmd) { |
| 673 | case SIOCSIFADDR: | 663 | case SIOCSIFADDR: |
| 664 | if (!capable(CAP_NET_ADMIN)) { | ||
| 665 | err = -EPERM; | ||
| 666 | break; | ||
| 667 | } | ||
| 668 | |||
| 674 | edev = dev->ec_ptr; | 669 | edev = dev->ec_ptr; |
| 675 | if (edev == NULL) { | 670 | if (edev == NULL) { |
| 676 | /* Magic up a new one. */ | 671 | /* Magic up a new one. */ |
| @@ -856,9 +851,13 @@ static void aun_incoming(struct sk_buff *skb, struct aunhdr *ah, size_t len) | |||
| 856 | { | 851 | { |
| 857 | struct iphdr *ip = ip_hdr(skb); | 852 | struct iphdr *ip = ip_hdr(skb); |
| 858 | unsigned char stn = ntohl(ip->saddr) & 0xff; | 853 | unsigned char stn = ntohl(ip->saddr) & 0xff; |
| 854 | struct dst_entry *dst = skb_dst(skb); | ||
| 855 | struct ec_device *edev = NULL; | ||
| 859 | struct sock *sk = NULL; | 856 | struct sock *sk = NULL; |
| 860 | struct sk_buff *newskb; | 857 | struct sk_buff *newskb; |
| 861 | struct ec_device *edev = skb->dev->ec_ptr; | 858 | |
| 859 | if (dst) | ||
| 860 | edev = dst->dev->ec_ptr; | ||
| 862 | 861 | ||
| 863 | if (! edev) | 862 | if (! edev) |
| 864 | goto bad; | 863 | goto bad; |
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index eb6f69a8f27a..c19c1f739fba 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
| @@ -163,13 +163,19 @@ struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref) | |||
| 163 | .daddr = addr | 163 | .daddr = addr |
| 164 | } | 164 | } |
| 165 | }, | 165 | }, |
| 166 | .flags = FLOWI_FLAG_MATCH_ANY_IIF | ||
| 167 | }; | 166 | }; |
| 168 | struct fib_result res = { 0 }; | 167 | struct fib_result res = { 0 }; |
| 169 | struct net_device *dev = NULL; | 168 | struct net_device *dev = NULL; |
| 169 | struct fib_table *local_table; | ||
| 170 | |||
| 171 | #ifdef CONFIG_IP_MULTIPLE_TABLES | ||
| 172 | res.r = NULL; | ||
| 173 | #endif | ||
| 170 | 174 | ||
| 171 | rcu_read_lock(); | 175 | rcu_read_lock(); |
| 172 | if (fib_lookup(net, &fl, &res)) { | 176 | local_table = fib_get_table(net, RT_TABLE_LOCAL); |
| 177 | if (!local_table || | ||
| 178 | fib_table_lookup(local_table, &fl, &res, FIB_LOOKUP_NOREF)) { | ||
| 173 | rcu_read_unlock(); | 179 | rcu_read_unlock(); |
| 174 | return NULL; | 180 | return NULL; |
| 175 | } | 181 | } |
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 200eb538fbb3..0f280348e0fd 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
| @@ -365,7 +365,7 @@ static struct tnode *tnode_alloc(size_t size) | |||
| 365 | if (size <= PAGE_SIZE) | 365 | if (size <= PAGE_SIZE) |
| 366 | return kzalloc(size, GFP_KERNEL); | 366 | return kzalloc(size, GFP_KERNEL); |
| 367 | else | 367 | else |
| 368 | return __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL); | 368 | return vzalloc(size); |
| 369 | } | 369 | } |
| 370 | 370 | ||
| 371 | static void __tnode_vfree(struct work_struct *arg) | 371 | static void __tnode_vfree(struct work_struct *arg) |
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 96bc7f9475a3..e5d1a44bcbdf 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
| @@ -569,6 +569,9 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
| 569 | /* No need to clone since we're just using its address. */ | 569 | /* No need to clone since we're just using its address. */ |
| 570 | rt2 = rt; | 570 | rt2 = rt; |
| 571 | 571 | ||
| 572 | if (!fl.nl_u.ip4_u.saddr) | ||
| 573 | fl.nl_u.ip4_u.saddr = rt->rt_src; | ||
| 574 | |||
| 572 | err = xfrm_lookup(net, (struct dst_entry **)&rt, &fl, NULL, 0); | 575 | err = xfrm_lookup(net, (struct dst_entry **)&rt, &fl, NULL, 0); |
| 573 | switch (err) { | 576 | switch (err) { |
| 574 | case 0: | 577 | case 0: |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index c8877c6c7216..3c53c2d89e3b 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
| @@ -2306,10 +2306,8 @@ void ip_mc_drop_socket(struct sock *sk) | |||
| 2306 | 2306 | ||
| 2307 | in_dev = inetdev_by_index(net, iml->multi.imr_ifindex); | 2307 | in_dev = inetdev_by_index(net, iml->multi.imr_ifindex); |
| 2308 | (void) ip_mc_leave_src(sk, iml, in_dev); | 2308 | (void) ip_mc_leave_src(sk, iml, in_dev); |
| 2309 | if (in_dev != NULL) { | 2309 | if (in_dev != NULL) |
| 2310 | ip_mc_dec_group(in_dev, iml->multi.imr_multiaddr.s_addr); | 2310 | ip_mc_dec_group(in_dev, iml->multi.imr_multiaddr.s_addr); |
| 2311 | in_dev_put(in_dev); | ||
| 2312 | } | ||
| 2313 | /* decrease mem now to avoid the memleak warning */ | 2311 | /* decrease mem now to avoid the memleak warning */ |
| 2314 | atomic_sub(sizeof(*iml), &sk->sk_omem_alloc); | 2312 | atomic_sub(sizeof(*iml), &sk->sk_omem_alloc); |
| 2315 | call_rcu(&iml->rcu, ip_mc_socklist_reclaim); | 2313 | call_rcu(&iml->rcu, ip_mc_socklist_reclaim); |
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 1b344f30b463..3c0369a3a663 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c | |||
| @@ -133,8 +133,7 @@ int __inet_inherit_port(struct sock *sk, struct sock *child) | |||
| 133 | } | 133 | } |
| 134 | } | 134 | } |
| 135 | } | 135 | } |
| 136 | sk_add_bind_node(child, &tb->owners); | 136 | inet_bind_hash(child, tb, port); |
| 137 | inet_csk(child)->icsk_bind_hash = tb; | ||
| 138 | spin_unlock(&head->lock); | 137 | spin_unlock(&head->lock); |
| 139 | 138 | ||
| 140 | return 0; | 139 | return 0; |
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 4ae1f203f7cb..b14ec7d03b6e 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
| @@ -59,13 +59,13 @@ static int sockstat_seq_show(struct seq_file *seq, void *v) | |||
| 59 | local_bh_enable(); | 59 | local_bh_enable(); |
| 60 | 60 | ||
| 61 | socket_seq_show(seq); | 61 | socket_seq_show(seq); |
| 62 | seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %d\n", | 62 | seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %ld\n", |
| 63 | sock_prot_inuse_get(net, &tcp_prot), orphans, | 63 | sock_prot_inuse_get(net, &tcp_prot), orphans, |
| 64 | tcp_death_row.tw_count, sockets, | 64 | tcp_death_row.tw_count, sockets, |
| 65 | atomic_read(&tcp_memory_allocated)); | 65 | atomic_long_read(&tcp_memory_allocated)); |
| 66 | seq_printf(seq, "UDP: inuse %d mem %d\n", | 66 | seq_printf(seq, "UDP: inuse %d mem %ld\n", |
| 67 | sock_prot_inuse_get(net, &udp_prot), | 67 | sock_prot_inuse_get(net, &udp_prot), |
| 68 | atomic_read(&udp_memory_allocated)); | 68 | atomic_long_read(&udp_memory_allocated)); |
| 69 | seq_printf(seq, "UDPLITE: inuse %d\n", | 69 | seq_printf(seq, "UDPLITE: inuse %d\n", |
| 70 | sock_prot_inuse_get(net, &udplite_prot)); | 70 | sock_prot_inuse_get(net, &udplite_prot)); |
| 71 | seq_printf(seq, "RAW: inuse %d\n", | 71 | seq_printf(seq, "RAW: inuse %d\n", |
| @@ -253,6 +253,7 @@ static const struct snmp_mib snmp4_net_list[] = { | |||
| 253 | SNMP_MIB_ITEM("TCPMinTTLDrop", LINUX_MIB_TCPMINTTLDROP), | 253 | SNMP_MIB_ITEM("TCPMinTTLDrop", LINUX_MIB_TCPMINTTLDROP), |
| 254 | SNMP_MIB_ITEM("TCPDeferAcceptDrop", LINUX_MIB_TCPDEFERACCEPTDROP), | 254 | SNMP_MIB_ITEM("TCPDeferAcceptDrop", LINUX_MIB_TCPDEFERACCEPTDROP), |
| 255 | SNMP_MIB_ITEM("IPReversePathFilter", LINUX_MIB_IPRPFILTER), | 255 | SNMP_MIB_ITEM("IPReversePathFilter", LINUX_MIB_IPRPFILTER), |
| 256 | SNMP_MIB_ITEM("TCPTimeWaitOverflow", LINUX_MIB_TCPTIMEWAITOVERFLOW), | ||
| 256 | SNMP_MIB_SENTINEL | 257 | SNMP_MIB_SENTINEL |
| 257 | }; | 258 | }; |
| 258 | 259 | ||
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 987bf9adb318..93bfd95584f4 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
| @@ -2585,9 +2585,10 @@ static int ip_route_output_slow(struct net *net, struct rtable **rp, | |||
| 2585 | goto out; | 2585 | goto out; |
| 2586 | 2586 | ||
| 2587 | /* RACE: Check return value of inet_select_addr instead. */ | 2587 | /* RACE: Check return value of inet_select_addr instead. */ |
| 2588 | if (rcu_dereference(dev_out->ip_ptr) == NULL) | 2588 | if (!(dev_out->flags & IFF_UP) || !__in_dev_get_rcu(dev_out)) { |
| 2589 | goto out; /* Wrong error code */ | 2589 | err = -ENETUNREACH; |
| 2590 | 2590 | goto out; | |
| 2591 | } | ||
| 2591 | if (ipv4_is_local_multicast(oldflp->fl4_dst) || | 2592 | if (ipv4_is_local_multicast(oldflp->fl4_dst) || |
| 2592 | ipv4_is_lbcast(oldflp->fl4_dst)) { | 2593 | ipv4_is_lbcast(oldflp->fl4_dst)) { |
| 2593 | if (!fl.fl4_src) | 2594 | if (!fl.fl4_src) |
| @@ -2648,8 +2649,12 @@ static int ip_route_output_slow(struct net *net, struct rtable **rp, | |||
| 2648 | } | 2649 | } |
| 2649 | 2650 | ||
| 2650 | if (res.type == RTN_LOCAL) { | 2651 | if (res.type == RTN_LOCAL) { |
| 2651 | if (!fl.fl4_src) | 2652 | if (!fl.fl4_src) { |
| 2652 | fl.fl4_src = fl.fl4_dst; | 2653 | if (res.fi->fib_prefsrc) |
| 2654 | fl.fl4_src = res.fi->fib_prefsrc; | ||
| 2655 | else | ||
| 2656 | fl.fl4_src = fl.fl4_dst; | ||
| 2657 | } | ||
| 2653 | dev_out = net->loopback_dev; | 2658 | dev_out = net->loopback_dev; |
| 2654 | fl.oif = dev_out->ifindex; | 2659 | fl.oif = dev_out->ifindex; |
| 2655 | res.fi = NULL; | 2660 | res.fi = NULL; |
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index d96c1da4b17c..1b4ec21497a4 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c | |||
| @@ -26,6 +26,8 @@ static int zero; | |||
| 26 | static int tcp_retr1_max = 255; | 26 | static int tcp_retr1_max = 255; |
| 27 | static int ip_local_port_range_min[] = { 1, 1 }; | 27 | static int ip_local_port_range_min[] = { 1, 1 }; |
| 28 | static int ip_local_port_range_max[] = { 65535, 65535 }; | 28 | static int ip_local_port_range_max[] = { 65535, 65535 }; |
| 29 | static int tcp_adv_win_scale_min = -31; | ||
| 30 | static int tcp_adv_win_scale_max = 31; | ||
| 29 | 31 | ||
| 30 | /* Update system visible IP port range */ | 32 | /* Update system visible IP port range */ |
| 31 | static void set_local_port_range(int range[2]) | 33 | static void set_local_port_range(int range[2]) |
| @@ -398,7 +400,7 @@ static struct ctl_table ipv4_table[] = { | |||
| 398 | .data = &sysctl_tcp_mem, | 400 | .data = &sysctl_tcp_mem, |
| 399 | .maxlen = sizeof(sysctl_tcp_mem), | 401 | .maxlen = sizeof(sysctl_tcp_mem), |
| 400 | .mode = 0644, | 402 | .mode = 0644, |
| 401 | .proc_handler = proc_dointvec | 403 | .proc_handler = proc_doulongvec_minmax |
| 402 | }, | 404 | }, |
| 403 | { | 405 | { |
| 404 | .procname = "tcp_wmem", | 406 | .procname = "tcp_wmem", |
| @@ -426,7 +428,9 @@ static struct ctl_table ipv4_table[] = { | |||
| 426 | .data = &sysctl_tcp_adv_win_scale, | 428 | .data = &sysctl_tcp_adv_win_scale, |
| 427 | .maxlen = sizeof(int), | 429 | .maxlen = sizeof(int), |
| 428 | .mode = 0644, | 430 | .mode = 0644, |
| 429 | .proc_handler = proc_dointvec | 431 | .proc_handler = proc_dointvec_minmax, |
| 432 | .extra1 = &tcp_adv_win_scale_min, | ||
| 433 | .extra2 = &tcp_adv_win_scale_max, | ||
| 430 | }, | 434 | }, |
| 431 | { | 435 | { |
| 432 | .procname = "tcp_tw_reuse", | 436 | .procname = "tcp_tw_reuse", |
| @@ -602,8 +606,7 @@ static struct ctl_table ipv4_table[] = { | |||
| 602 | .data = &sysctl_udp_mem, | 606 | .data = &sysctl_udp_mem, |
| 603 | .maxlen = sizeof(sysctl_udp_mem), | 607 | .maxlen = sizeof(sysctl_udp_mem), |
| 604 | .mode = 0644, | 608 | .mode = 0644, |
| 605 | .proc_handler = proc_dointvec_minmax, | 609 | .proc_handler = proc_doulongvec_minmax, |
| 606 | .extra1 = &zero | ||
| 607 | }, | 610 | }, |
| 608 | { | 611 | { |
| 609 | .procname = "udp_rmem_min", | 612 | .procname = "udp_rmem_min", |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 1664a0590bb8..f15c36a706ec 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
| @@ -282,7 +282,7 @@ int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT; | |||
| 282 | struct percpu_counter tcp_orphan_count; | 282 | struct percpu_counter tcp_orphan_count; |
| 283 | EXPORT_SYMBOL_GPL(tcp_orphan_count); | 283 | EXPORT_SYMBOL_GPL(tcp_orphan_count); |
| 284 | 284 | ||
| 285 | int sysctl_tcp_mem[3] __read_mostly; | 285 | long sysctl_tcp_mem[3] __read_mostly; |
| 286 | int sysctl_tcp_wmem[3] __read_mostly; | 286 | int sysctl_tcp_wmem[3] __read_mostly; |
| 287 | int sysctl_tcp_rmem[3] __read_mostly; | 287 | int sysctl_tcp_rmem[3] __read_mostly; |
| 288 | 288 | ||
| @@ -290,7 +290,7 @@ EXPORT_SYMBOL(sysctl_tcp_mem); | |||
| 290 | EXPORT_SYMBOL(sysctl_tcp_rmem); | 290 | EXPORT_SYMBOL(sysctl_tcp_rmem); |
| 291 | EXPORT_SYMBOL(sysctl_tcp_wmem); | 291 | EXPORT_SYMBOL(sysctl_tcp_wmem); |
| 292 | 292 | ||
| 293 | atomic_t tcp_memory_allocated; /* Current allocated memory. */ | 293 | atomic_long_t tcp_memory_allocated; /* Current allocated memory. */ |
| 294 | EXPORT_SYMBOL(tcp_memory_allocated); | 294 | EXPORT_SYMBOL(tcp_memory_allocated); |
| 295 | 295 | ||
| 296 | /* | 296 | /* |
| @@ -2246,7 +2246,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, | |||
| 2246 | /* Values greater than interface MTU won't take effect. However | 2246 | /* Values greater than interface MTU won't take effect. However |
| 2247 | * at the point when this call is done we typically don't yet | 2247 | * at the point when this call is done we typically don't yet |
| 2248 | * know which interface is going to be used */ | 2248 | * know which interface is going to be used */ |
| 2249 | if (val < 8 || val > MAX_TCP_WINDOW) { | 2249 | if (val < TCP_MIN_MSS || val > MAX_TCP_WINDOW) { |
| 2250 | err = -EINVAL; | 2250 | err = -EINVAL; |
| 2251 | break; | 2251 | break; |
| 2252 | } | 2252 | } |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 3357f69e353d..6d8ab1c4efc3 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
| @@ -259,8 +259,11 @@ static void tcp_fixup_sndbuf(struct sock *sk) | |||
| 259 | int sndmem = tcp_sk(sk)->rx_opt.mss_clamp + MAX_TCP_HEADER + 16 + | 259 | int sndmem = tcp_sk(sk)->rx_opt.mss_clamp + MAX_TCP_HEADER + 16 + |
| 260 | sizeof(struct sk_buff); | 260 | sizeof(struct sk_buff); |
| 261 | 261 | ||
| 262 | if (sk->sk_sndbuf < 3 * sndmem) | 262 | if (sk->sk_sndbuf < 3 * sndmem) { |
| 263 | sk->sk_sndbuf = min(3 * sndmem, sysctl_tcp_wmem[2]); | 263 | sk->sk_sndbuf = 3 * sndmem; |
| 264 | if (sk->sk_sndbuf > sysctl_tcp_wmem[2]) | ||
| 265 | sk->sk_sndbuf = sysctl_tcp_wmem[2]; | ||
| 266 | } | ||
| 264 | } | 267 | } |
| 265 | 268 | ||
| 266 | /* 2. Tuning advertised window (window_clamp, rcv_ssthresh) | 269 | /* 2. Tuning advertised window (window_clamp, rcv_ssthresh) |
| @@ -396,7 +399,7 @@ static void tcp_clamp_window(struct sock *sk) | |||
| 396 | if (sk->sk_rcvbuf < sysctl_tcp_rmem[2] && | 399 | if (sk->sk_rcvbuf < sysctl_tcp_rmem[2] && |
| 397 | !(sk->sk_userlocks & SOCK_RCVBUF_LOCK) && | 400 | !(sk->sk_userlocks & SOCK_RCVBUF_LOCK) && |
| 398 | !tcp_memory_pressure && | 401 | !tcp_memory_pressure && |
| 399 | atomic_read(&tcp_memory_allocated) < sysctl_tcp_mem[0]) { | 402 | atomic_long_read(&tcp_memory_allocated) < sysctl_tcp_mem[0]) { |
| 400 | sk->sk_rcvbuf = min(atomic_read(&sk->sk_rmem_alloc), | 403 | sk->sk_rcvbuf = min(atomic_read(&sk->sk_rmem_alloc), |
| 401 | sysctl_tcp_rmem[2]); | 404 | sysctl_tcp_rmem[2]); |
| 402 | } | 405 | } |
| @@ -4861,7 +4864,7 @@ static int tcp_should_expand_sndbuf(struct sock *sk) | |||
| 4861 | return 0; | 4864 | return 0; |
| 4862 | 4865 | ||
| 4863 | /* If we are under soft global TCP memory pressure, do not expand. */ | 4866 | /* If we are under soft global TCP memory pressure, do not expand. */ |
| 4864 | if (atomic_read(&tcp_memory_allocated) >= sysctl_tcp_mem[0]) | 4867 | if (atomic_long_read(&tcp_memory_allocated) >= sysctl_tcp_mem[0]) |
| 4865 | return 0; | 4868 | return 0; |
| 4866 | 4869 | ||
| 4867 | /* If we filled the congestion window, do not expand. */ | 4870 | /* If we filled the congestion window, do not expand. */ |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 8f8527d41682..d978bb2f748b 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
| @@ -415,6 +415,9 @@ void tcp_v4_err(struct sk_buff *icmp_skb, u32 info) | |||
| 415 | !icsk->icsk_backoff) | 415 | !icsk->icsk_backoff) |
| 416 | break; | 416 | break; |
| 417 | 417 | ||
| 418 | if (sock_owned_by_user(sk)) | ||
| 419 | break; | ||
| 420 | |||
| 418 | icsk->icsk_backoff--; | 421 | icsk->icsk_backoff--; |
| 419 | inet_csk(sk)->icsk_rto = __tcp_set_rto(tp) << | 422 | inet_csk(sk)->icsk_rto = __tcp_set_rto(tp) << |
| 420 | icsk->icsk_backoff; | 423 | icsk->icsk_backoff; |
| @@ -429,11 +432,6 @@ void tcp_v4_err(struct sk_buff *icmp_skb, u32 info) | |||
| 429 | if (remaining) { | 432 | if (remaining) { |
| 430 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, | 433 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, |
| 431 | remaining, TCP_RTO_MAX); | 434 | remaining, TCP_RTO_MAX); |
| 432 | } else if (sock_owned_by_user(sk)) { | ||
| 433 | /* RTO revert clocked out retransmission, | ||
| 434 | * but socket is locked. Will defer. */ | ||
| 435 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, | ||
| 436 | HZ/20, TCP_RTO_MAX); | ||
| 437 | } else { | 435 | } else { |
| 438 | /* RTO revert clocked out retransmission. | 436 | /* RTO revert clocked out retransmission. |
| 439 | * Will retransmit now */ | 437 | * Will retransmit now */ |
| @@ -2032,7 +2030,7 @@ static void *listening_get_next(struct seq_file *seq, void *cur) | |||
| 2032 | get_req: | 2030 | get_req: |
| 2033 | req = icsk->icsk_accept_queue.listen_opt->syn_table[st->sbucket]; | 2031 | req = icsk->icsk_accept_queue.listen_opt->syn_table[st->sbucket]; |
| 2034 | } | 2032 | } |
| 2035 | sk = sk_next(st->syn_wait_sk); | 2033 | sk = sk_nulls_next(st->syn_wait_sk); |
| 2036 | st->state = TCP_SEQ_STATE_LISTENING; | 2034 | st->state = TCP_SEQ_STATE_LISTENING; |
| 2037 | read_unlock_bh(&icsk->icsk_accept_queue.syn_wait_lock); | 2035 | read_unlock_bh(&icsk->icsk_accept_queue.syn_wait_lock); |
| 2038 | } else { | 2036 | } else { |
| @@ -2041,11 +2039,13 @@ get_req: | |||
| 2041 | if (reqsk_queue_len(&icsk->icsk_accept_queue)) | 2039 | if (reqsk_queue_len(&icsk->icsk_accept_queue)) |
| 2042 | goto start_req; | 2040 | goto start_req; |
| 2043 | read_unlock_bh(&icsk->icsk_accept_queue.syn_wait_lock); | 2041 | read_unlock_bh(&icsk->icsk_accept_queue.syn_wait_lock); |
| 2044 | sk = sk_next(sk); | 2042 | sk = sk_nulls_next(sk); |
| 2045 | } | 2043 | } |
| 2046 | get_sk: | 2044 | get_sk: |
| 2047 | sk_nulls_for_each_from(sk, node) { | 2045 | sk_nulls_for_each_from(sk, node) { |
| 2048 | if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) { | 2046 | if (!net_eq(sock_net(sk), net)) |
| 2047 | continue; | ||
| 2048 | if (sk->sk_family == st->family) { | ||
| 2049 | cur = sk; | 2049 | cur = sk; |
| 2050 | goto out; | 2050 | goto out; |
| 2051 | } | 2051 | } |
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 43cf901d7659..a66735f75963 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
| @@ -347,7 +347,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo) | |||
| 347 | * socket up. We've got bigger problems than | 347 | * socket up. We've got bigger problems than |
| 348 | * non-graceful socket closings. | 348 | * non-graceful socket closings. |
| 349 | */ | 349 | */ |
| 350 | LIMIT_NETDEBUG(KERN_INFO "TCP: time wait bucket table overflow\n"); | 350 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPTIMEWAITOVERFLOW); |
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | tcp_update_metrics(sk); | 353 | tcp_update_metrics(sk); |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 05b1ecf36763..61c2463e2753 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
| @@ -231,11 +231,10 @@ void tcp_select_initial_window(int __space, __u32 mss, | |||
| 231 | /* when initializing use the value from init_rcv_wnd | 231 | /* when initializing use the value from init_rcv_wnd |
| 232 | * rather than the default from above | 232 | * rather than the default from above |
| 233 | */ | 233 | */ |
| 234 | if (init_rcv_wnd && | 234 | if (init_rcv_wnd) |
| 235 | (*rcv_wnd > init_rcv_wnd * mss)) | 235 | *rcv_wnd = min(*rcv_wnd, init_rcv_wnd * mss); |
| 236 | *rcv_wnd = init_rcv_wnd * mss; | 236 | else |
| 237 | else if (*rcv_wnd > init_cwnd * mss) | 237 | *rcv_wnd = min(*rcv_wnd, init_cwnd * mss); |
| 238 | *rcv_wnd = init_cwnd * mss; | ||
| 239 | } | 238 | } |
| 240 | 239 | ||
| 241 | /* Set the clamp no higher than max representable value */ | 240 | /* Set the clamp no higher than max representable value */ |
| @@ -386,27 +385,30 @@ struct tcp_out_options { | |||
| 386 | */ | 385 | */ |
| 387 | static u8 tcp_cookie_size_check(u8 desired) | 386 | static u8 tcp_cookie_size_check(u8 desired) |
| 388 | { | 387 | { |
| 389 | if (desired > 0) { | 388 | int cookie_size; |
| 389 | |||
| 390 | if (desired > 0) | ||
| 390 | /* previously specified */ | 391 | /* previously specified */ |
| 391 | return desired; | 392 | return desired; |
| 392 | } | 393 | |
| 393 | if (sysctl_tcp_cookie_size <= 0) { | 394 | cookie_size = ACCESS_ONCE(sysctl_tcp_cookie_size); |
| 395 | if (cookie_size <= 0) | ||
| 394 | /* no default specified */ | 396 | /* no default specified */ |
| 395 | return 0; | 397 | return 0; |
| 396 | } | 398 | |
| 397 | if (sysctl_tcp_cookie_size <= TCP_COOKIE_MIN) { | 399 | if (cookie_size <= TCP_COOKIE_MIN) |
| 398 | /* value too small, specify minimum */ | 400 | /* value too small, specify minimum */ |
| 399 | return TCP_COOKIE_MIN; | 401 | return TCP_COOKIE_MIN; |
| 400 | } | 402 | |
| 401 | if (sysctl_tcp_cookie_size >= TCP_COOKIE_MAX) { | 403 | if (cookie_size >= TCP_COOKIE_MAX) |
| 402 | /* value too large, specify maximum */ | 404 | /* value too large, specify maximum */ |
| 403 | return TCP_COOKIE_MAX; | 405 | return TCP_COOKIE_MAX; |
| 404 | } | 406 | |
| 405 | if (0x1 & sysctl_tcp_cookie_size) { | 407 | if (cookie_size & 1) |
| 406 | /* 8-bit multiple, illegal, fix it */ | 408 | /* 8-bit multiple, illegal, fix it */ |
| 407 | return (u8)(sysctl_tcp_cookie_size + 0x1); | 409 | cookie_size++; |
| 408 | } | 410 | |
| 409 | return (u8)sysctl_tcp_cookie_size; | 411 | return (u8)cookie_size; |
| 410 | } | 412 | } |
| 411 | 413 | ||
| 412 | /* Write previously computed TCP options to the packet. | 414 | /* Write previously computed TCP options to the packet. |
| @@ -1513,6 +1515,7 @@ static int tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb) | |||
| 1513 | struct tcp_sock *tp = tcp_sk(sk); | 1515 | struct tcp_sock *tp = tcp_sk(sk); |
| 1514 | const struct inet_connection_sock *icsk = inet_csk(sk); | 1516 | const struct inet_connection_sock *icsk = inet_csk(sk); |
| 1515 | u32 send_win, cong_win, limit, in_flight; | 1517 | u32 send_win, cong_win, limit, in_flight; |
| 1518 | int win_divisor; | ||
| 1516 | 1519 | ||
| 1517 | if (TCP_SKB_CB(skb)->flags & TCPHDR_FIN) | 1520 | if (TCP_SKB_CB(skb)->flags & TCPHDR_FIN) |
| 1518 | goto send_now; | 1521 | goto send_now; |
| @@ -1544,13 +1547,14 @@ static int tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb) | |||
| 1544 | if ((skb != tcp_write_queue_tail(sk)) && (limit >= skb->len)) | 1547 | if ((skb != tcp_write_queue_tail(sk)) && (limit >= skb->len)) |
| 1545 | goto send_now; | 1548 | goto send_now; |
| 1546 | 1549 | ||
| 1547 | if (sysctl_tcp_tso_win_divisor) { | 1550 | win_divisor = ACCESS_ONCE(sysctl_tcp_tso_win_divisor); |
| 1551 | if (win_divisor) { | ||
| 1548 | u32 chunk = min(tp->snd_wnd, tp->snd_cwnd * tp->mss_cache); | 1552 | u32 chunk = min(tp->snd_wnd, tp->snd_cwnd * tp->mss_cache); |
| 1549 | 1553 | ||
| 1550 | /* If at least some fraction of a window is available, | 1554 | /* If at least some fraction of a window is available, |
| 1551 | * just use it. | 1555 | * just use it. |
| 1552 | */ | 1556 | */ |
| 1553 | chunk /= sysctl_tcp_tso_win_divisor; | 1557 | chunk /= win_divisor; |
| 1554 | if (limit >= chunk) | 1558 | if (limit >= chunk) |
| 1555 | goto send_now; | 1559 | goto send_now; |
| 1556 | } else { | 1560 | } else { |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 28cb2d733a3c..2d3ded4d0786 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
| @@ -110,7 +110,7 @@ | |||
| 110 | struct udp_table udp_table __read_mostly; | 110 | struct udp_table udp_table __read_mostly; |
| 111 | EXPORT_SYMBOL(udp_table); | 111 | EXPORT_SYMBOL(udp_table); |
| 112 | 112 | ||
| 113 | int sysctl_udp_mem[3] __read_mostly; | 113 | long sysctl_udp_mem[3] __read_mostly; |
| 114 | EXPORT_SYMBOL(sysctl_udp_mem); | 114 | EXPORT_SYMBOL(sysctl_udp_mem); |
| 115 | 115 | ||
| 116 | int sysctl_udp_rmem_min __read_mostly; | 116 | int sysctl_udp_rmem_min __read_mostly; |
| @@ -119,7 +119,7 @@ EXPORT_SYMBOL(sysctl_udp_rmem_min); | |||
| 119 | int sysctl_udp_wmem_min __read_mostly; | 119 | int sysctl_udp_wmem_min __read_mostly; |
| 120 | EXPORT_SYMBOL(sysctl_udp_wmem_min); | 120 | EXPORT_SYMBOL(sysctl_udp_wmem_min); |
| 121 | 121 | ||
| 122 | atomic_t udp_memory_allocated; | 122 | atomic_long_t udp_memory_allocated; |
| 123 | EXPORT_SYMBOL(udp_memory_allocated); | 123 | EXPORT_SYMBOL(udp_memory_allocated); |
| 124 | 124 | ||
| 125 | #define MAX_UDP_PORTS 65536 | 125 | #define MAX_UDP_PORTS 65536 |
| @@ -1899,6 +1899,7 @@ struct proto udp_prot = { | |||
| 1899 | .compat_setsockopt = compat_udp_setsockopt, | 1899 | .compat_setsockopt = compat_udp_setsockopt, |
| 1900 | .compat_getsockopt = compat_udp_getsockopt, | 1900 | .compat_getsockopt = compat_udp_getsockopt, |
| 1901 | #endif | 1901 | #endif |
| 1902 | .clear_sk = sk_prot_clear_portaddr_nulls, | ||
| 1902 | }; | 1903 | }; |
| 1903 | EXPORT_SYMBOL(udp_prot); | 1904 | EXPORT_SYMBOL(udp_prot); |
| 1904 | 1905 | ||
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index ab76aa928fa9..aee9963f7f5a 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c | |||
| @@ -57,6 +57,7 @@ struct proto udplite_prot = { | |||
| 57 | .compat_setsockopt = compat_udp_setsockopt, | 57 | .compat_setsockopt = compat_udp_setsockopt, |
| 58 | .compat_getsockopt = compat_udp_getsockopt, | 58 | .compat_getsockopt = compat_udp_getsockopt, |
| 59 | #endif | 59 | #endif |
| 60 | .clear_sk = sk_prot_clear_portaddr_nulls, | ||
| 60 | }; | 61 | }; |
| 61 | EXPORT_SYMBOL(udplite_prot); | 62 | EXPORT_SYMBOL(udplite_prot); |
| 62 | 63 | ||
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index e048ec62d109..848b35591042 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
| @@ -98,7 +98,11 @@ | |||
| 98 | #endif | 98 | #endif |
| 99 | 99 | ||
| 100 | #define INFINITY_LIFE_TIME 0xFFFFFFFF | 100 | #define INFINITY_LIFE_TIME 0xFFFFFFFF |
| 101 | #define TIME_DELTA(a, b) ((unsigned long)((long)(a) - (long)(b))) | 101 | |
| 102 | static inline u32 cstamp_delta(unsigned long cstamp) | ||
| 103 | { | ||
| 104 | return (cstamp - INITIAL_JIFFIES) * 100UL / HZ; | ||
| 105 | } | ||
| 102 | 106 | ||
| 103 | #define ADDRCONF_TIMER_FUZZ_MINUS (HZ > 50 ? HZ/50 : 1) | 107 | #define ADDRCONF_TIMER_FUZZ_MINUS (HZ > 50 ? HZ/50 : 1) |
| 104 | #define ADDRCONF_TIMER_FUZZ (HZ / 4) | 108 | #define ADDRCONF_TIMER_FUZZ (HZ / 4) |
| @@ -2665,7 +2669,9 @@ static int addrconf_ifdown(struct net_device *dev, int how) | |||
| 2665 | 2669 | ||
| 2666 | ASSERT_RTNL(); | 2670 | ASSERT_RTNL(); |
| 2667 | 2671 | ||
| 2668 | rt6_ifdown(net, dev); | 2672 | /* Flush routes if device is being removed or it is not loopback */ |
| 2673 | if (how || !(dev->flags & IFF_LOOPBACK)) | ||
| 2674 | rt6_ifdown(net, dev); | ||
| 2669 | neigh_ifdown(&nd_tbl, dev); | 2675 | neigh_ifdown(&nd_tbl, dev); |
| 2670 | 2676 | ||
| 2671 | idev = __in6_dev_get(dev); | 2677 | idev = __in6_dev_get(dev); |
| @@ -2740,10 +2746,6 @@ static int addrconf_ifdown(struct net_device *dev, int how) | |||
| 2740 | /* Flag it for later restoration when link comes up */ | 2746 | /* Flag it for later restoration when link comes up */ |
| 2741 | ifa->flags |= IFA_F_TENTATIVE; | 2747 | ifa->flags |= IFA_F_TENTATIVE; |
| 2742 | ifa->state = INET6_IFADDR_STATE_DAD; | 2748 | ifa->state = INET6_IFADDR_STATE_DAD; |
| 2743 | |||
| 2744 | write_unlock_bh(&idev->lock); | ||
| 2745 | |||
| 2746 | in6_ifa_hold(ifa); | ||
| 2747 | } else { | 2749 | } else { |
| 2748 | list_del(&ifa->if_list); | 2750 | list_del(&ifa->if_list); |
| 2749 | 2751 | ||
| @@ -2758,19 +2760,15 @@ static int addrconf_ifdown(struct net_device *dev, int how) | |||
| 2758 | ifa->state = INET6_IFADDR_STATE_DEAD; | 2760 | ifa->state = INET6_IFADDR_STATE_DEAD; |
| 2759 | spin_unlock_bh(&ifa->state_lock); | 2761 | spin_unlock_bh(&ifa->state_lock); |
| 2760 | 2762 | ||
| 2761 | if (state == INET6_IFADDR_STATE_DEAD) | 2763 | if (state != INET6_IFADDR_STATE_DEAD) { |
| 2762 | goto put_ifa; | 2764 | __ipv6_ifa_notify(RTM_DELADDR, ifa); |
| 2763 | } | 2765 | atomic_notifier_call_chain(&inet6addr_chain, |
| 2764 | 2766 | NETDEV_DOWN, ifa); | |
| 2765 | __ipv6_ifa_notify(RTM_DELADDR, ifa); | 2767 | } |
| 2766 | if (ifa->state == INET6_IFADDR_STATE_DEAD) | ||
| 2767 | atomic_notifier_call_chain(&inet6addr_chain, | ||
| 2768 | NETDEV_DOWN, ifa); | ||
| 2769 | |||
| 2770 | put_ifa: | ||
| 2771 | in6_ifa_put(ifa); | ||
| 2772 | 2768 | ||
| 2773 | write_lock_bh(&idev->lock); | 2769 | in6_ifa_put(ifa); |
| 2770 | write_lock_bh(&idev->lock); | ||
| 2771 | } | ||
| 2774 | } | 2772 | } |
| 2775 | 2773 | ||
| 2776 | list_splice(&keep_list, &idev->addr_list); | 2774 | list_splice(&keep_list, &idev->addr_list); |
| @@ -3452,10 +3450,8 @@ static int put_cacheinfo(struct sk_buff *skb, unsigned long cstamp, | |||
| 3452 | { | 3450 | { |
| 3453 | struct ifa_cacheinfo ci; | 3451 | struct ifa_cacheinfo ci; |
| 3454 | 3452 | ||
| 3455 | ci.cstamp = (u32)(TIME_DELTA(cstamp, INITIAL_JIFFIES) / HZ * 100 | 3453 | ci.cstamp = cstamp_delta(cstamp); |
| 3456 | + TIME_DELTA(cstamp, INITIAL_JIFFIES) % HZ * 100 / HZ); | 3454 | ci.tstamp = cstamp_delta(tstamp); |
| 3457 | ci.tstamp = (u32)(TIME_DELTA(tstamp, INITIAL_JIFFIES) / HZ * 100 | ||
| 3458 | + TIME_DELTA(tstamp, INITIAL_JIFFIES) % HZ * 100 / HZ); | ||
| 3459 | ci.ifa_prefered = preferred; | 3455 | ci.ifa_prefered = preferred; |
| 3460 | ci.ifa_valid = valid; | 3456 | ci.ifa_valid = valid; |
| 3461 | 3457 | ||
| @@ -3806,8 +3802,10 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, | |||
| 3806 | array[DEVCONF_AUTOCONF] = cnf->autoconf; | 3802 | array[DEVCONF_AUTOCONF] = cnf->autoconf; |
| 3807 | array[DEVCONF_DAD_TRANSMITS] = cnf->dad_transmits; | 3803 | array[DEVCONF_DAD_TRANSMITS] = cnf->dad_transmits; |
| 3808 | array[DEVCONF_RTR_SOLICITS] = cnf->rtr_solicits; | 3804 | array[DEVCONF_RTR_SOLICITS] = cnf->rtr_solicits; |
| 3809 | array[DEVCONF_RTR_SOLICIT_INTERVAL] = cnf->rtr_solicit_interval; | 3805 | array[DEVCONF_RTR_SOLICIT_INTERVAL] = |
| 3810 | array[DEVCONF_RTR_SOLICIT_DELAY] = cnf->rtr_solicit_delay; | 3806 | jiffies_to_msecs(cnf->rtr_solicit_interval); |
| 3807 | array[DEVCONF_RTR_SOLICIT_DELAY] = | ||
| 3808 | jiffies_to_msecs(cnf->rtr_solicit_delay); | ||
| 3811 | array[DEVCONF_FORCE_MLD_VERSION] = cnf->force_mld_version; | 3809 | array[DEVCONF_FORCE_MLD_VERSION] = cnf->force_mld_version; |
| 3812 | #ifdef CONFIG_IPV6_PRIVACY | 3810 | #ifdef CONFIG_IPV6_PRIVACY |
| 3813 | array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr; | 3811 | array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr; |
| @@ -3821,7 +3819,8 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, | |||
| 3821 | array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo; | 3819 | array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo; |
| 3822 | #ifdef CONFIG_IPV6_ROUTER_PREF | 3820 | #ifdef CONFIG_IPV6_ROUTER_PREF |
| 3823 | array[DEVCONF_ACCEPT_RA_RTR_PREF] = cnf->accept_ra_rtr_pref; | 3821 | array[DEVCONF_ACCEPT_RA_RTR_PREF] = cnf->accept_ra_rtr_pref; |
| 3824 | array[DEVCONF_RTR_PROBE_INTERVAL] = cnf->rtr_probe_interval; | 3822 | array[DEVCONF_RTR_PROBE_INTERVAL] = |
| 3823 | jiffies_to_msecs(cnf->rtr_probe_interval); | ||
| 3825 | #ifdef CONFIG_IPV6_ROUTE_INFO | 3824 | #ifdef CONFIG_IPV6_ROUTE_INFO |
| 3826 | array[DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN] = cnf->accept_ra_rt_info_max_plen; | 3825 | array[DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN] = cnf->accept_ra_rt_info_max_plen; |
| 3827 | #endif | 3826 | #endif |
| @@ -3937,10 +3936,9 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev, | |||
| 3937 | NLA_PUT_U32(skb, IFLA_INET6_FLAGS, idev->if_flags); | 3936 | NLA_PUT_U32(skb, IFLA_INET6_FLAGS, idev->if_flags); |
| 3938 | 3937 | ||
| 3939 | ci.max_reasm_len = IPV6_MAXPLEN; | 3938 | ci.max_reasm_len = IPV6_MAXPLEN; |
| 3940 | ci.tstamp = (__u32)(TIME_DELTA(idev->tstamp, INITIAL_JIFFIES) / HZ * 100 | 3939 | ci.tstamp = cstamp_delta(idev->tstamp); |
| 3941 | + TIME_DELTA(idev->tstamp, INITIAL_JIFFIES) % HZ * 100 / HZ); | 3940 | ci.reachable_time = jiffies_to_msecs(idev->nd_parms->reachable_time); |
| 3942 | ci.reachable_time = idev->nd_parms->reachable_time; | 3941 | ci.retrans_time = jiffies_to_msecs(idev->nd_parms->retrans_time); |
| 3943 | ci.retrans_time = idev->nd_parms->retrans_time; | ||
| 3944 | NLA_PUT(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci); | 3942 | NLA_PUT(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci); |
| 3945 | 3943 | ||
| 3946 | nla = nla_reserve(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(s32)); | 3944 | nla = nla_reserve(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(s32)); |
| @@ -4025,11 +4023,11 @@ void inet6_ifinfo_notify(int event, struct inet6_dev *idev) | |||
| 4025 | kfree_skb(skb); | 4023 | kfree_skb(skb); |
| 4026 | goto errout; | 4024 | goto errout; |
| 4027 | } | 4025 | } |
| 4028 | rtnl_notify(skb, net, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC); | 4026 | rtnl_notify(skb, net, 0, RTNLGRP_IPV6_IFINFO, NULL, GFP_ATOMIC); |
| 4029 | return; | 4027 | return; |
| 4030 | errout: | 4028 | errout: |
| 4031 | if (err < 0) | 4029 | if (err < 0) |
| 4032 | rtnl_set_sk_err(net, RTNLGRP_IPV6_IFADDR, err); | 4030 | rtnl_set_sk_err(net, RTNLGRP_IPV6_IFINFO, err); |
| 4033 | } | 4031 | } |
| 4034 | 4032 | ||
| 4035 | static inline size_t inet6_prefix_nlmsg_size(void) | 4033 | static inline size_t inet6_prefix_nlmsg_size(void) |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 99157b4cd56e..94b5bf132b2e 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
| @@ -56,7 +56,7 @@ | |||
| 56 | #include <net/checksum.h> | 56 | #include <net/checksum.h> |
| 57 | #include <linux/mroute6.h> | 57 | #include <linux/mroute6.h> |
| 58 | 58 | ||
| 59 | static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); | 59 | int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); |
| 60 | 60 | ||
| 61 | int __ip6_local_out(struct sk_buff *skb) | 61 | int __ip6_local_out(struct sk_buff *skb) |
| 62 | { | 62 | { |
| @@ -145,14 +145,6 @@ static int ip6_finish_output2(struct sk_buff *skb) | |||
| 145 | return -EINVAL; | 145 | return -EINVAL; |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | static inline int ip6_skb_dst_mtu(struct sk_buff *skb) | ||
| 149 | { | ||
| 150 | struct ipv6_pinfo *np = skb->sk ? inet6_sk(skb->sk) : NULL; | ||
| 151 | |||
| 152 | return (np && np->pmtudisc == IPV6_PMTUDISC_PROBE) ? | ||
| 153 | skb_dst(skb)->dev->mtu : dst_mtu(skb_dst(skb)); | ||
| 154 | } | ||
| 155 | |||
| 156 | static int ip6_finish_output(struct sk_buff *skb) | 148 | static int ip6_finish_output(struct sk_buff *skb) |
| 157 | { | 149 | { |
| 158 | if ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) || | 150 | if ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) || |
| @@ -601,7 +593,7 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) | |||
| 601 | return offset; | 593 | return offset; |
| 602 | } | 594 | } |
| 603 | 595 | ||
| 604 | static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | 596 | int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) |
| 605 | { | 597 | { |
| 606 | struct sk_buff *frag; | 598 | struct sk_buff *frag; |
| 607 | struct rt6_info *rt = (struct rt6_info*)skb_dst(skb); | 599 | struct rt6_info *rt = (struct rt6_info*)skb_dst(skb); |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 2a59610c2a58..70e891a20fb9 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
| @@ -1175,6 +1175,8 @@ static void ip6_tnl_link_config(struct ip6_tnl *t) | |||
| 1175 | sizeof (struct ipv6hdr); | 1175 | sizeof (struct ipv6hdr); |
| 1176 | 1176 | ||
| 1177 | dev->mtu = rt->rt6i_dev->mtu - sizeof (struct ipv6hdr); | 1177 | dev->mtu = rt->rt6i_dev->mtu - sizeof (struct ipv6hdr); |
| 1178 | if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) | ||
| 1179 | dev->mtu-=8; | ||
| 1178 | 1180 | ||
| 1179 | if (dev->mtu < IPV6_MIN_MTU) | 1181 | if (dev->mtu < IPV6_MIN_MTU) |
| 1180 | dev->mtu = IPV6_MIN_MTU; | 1182 | dev->mtu = IPV6_MIN_MTU; |
| @@ -1363,12 +1365,17 @@ static const struct net_device_ops ip6_tnl_netdev_ops = { | |||
| 1363 | 1365 | ||
| 1364 | static void ip6_tnl_dev_setup(struct net_device *dev) | 1366 | static void ip6_tnl_dev_setup(struct net_device *dev) |
| 1365 | { | 1367 | { |
| 1368 | struct ip6_tnl *t; | ||
| 1369 | |||
| 1366 | dev->netdev_ops = &ip6_tnl_netdev_ops; | 1370 | dev->netdev_ops = &ip6_tnl_netdev_ops; |
| 1367 | dev->destructor = ip6_dev_free; | 1371 | dev->destructor = ip6_dev_free; |
| 1368 | 1372 | ||
| 1369 | dev->type = ARPHRD_TUNNEL6; | 1373 | dev->type = ARPHRD_TUNNEL6; |
| 1370 | dev->hard_header_len = LL_MAX_HEADER + sizeof (struct ipv6hdr); | 1374 | dev->hard_header_len = LL_MAX_HEADER + sizeof (struct ipv6hdr); |
| 1371 | dev->mtu = ETH_DATA_LEN - sizeof (struct ipv6hdr); | 1375 | dev->mtu = ETH_DATA_LEN - sizeof (struct ipv6hdr); |
| 1376 | t = netdev_priv(dev); | ||
| 1377 | if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) | ||
| 1378 | dev->mtu-=8; | ||
| 1372 | dev->flags |= IFF_NOARP; | 1379 | dev->flags |= IFF_NOARP; |
| 1373 | dev->addr_len = sizeof(struct in6_addr); | 1380 | dev->addr_len = sizeof(struct in6_addr); |
| 1374 | dev->features |= NETIF_F_NETNS_LOCAL; | 1381 | dev->features |= NETIF_F_NETNS_LOCAL; |
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 3a3f129a44cb..79d43aa8fa8d 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c | |||
| @@ -286,7 +286,7 @@ found: | |||
| 286 | 286 | ||
| 287 | /* Check for overlap with preceding fragment. */ | 287 | /* Check for overlap with preceding fragment. */ |
| 288 | if (prev && | 288 | if (prev && |
| 289 | (NFCT_FRAG6_CB(prev)->offset + prev->len) - offset > 0) | 289 | (NFCT_FRAG6_CB(prev)->offset + prev->len) > offset) |
| 290 | goto discard_fq; | 290 | goto discard_fq; |
| 291 | 291 | ||
| 292 | /* Look for overlap with succeeding segment. */ | 292 | /* Look for overlap with succeeding segment. */ |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index c7ba3149633f..0f2766453759 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
| @@ -349,7 +349,7 @@ found: | |||
| 349 | 349 | ||
| 350 | /* Check for overlap with preceding fragment. */ | 350 | /* Check for overlap with preceding fragment. */ |
| 351 | if (prev && | 351 | if (prev && |
| 352 | (FRAG6_CB(prev)->offset + prev->len) - offset > 0) | 352 | (FRAG6_CB(prev)->offset + prev->len) > offset) |
| 353 | goto discard_fq; | 353 | goto discard_fq; |
| 354 | 354 | ||
| 355 | /* Look for overlap with succeeding segment. */ | 355 | /* Look for overlap with succeeding segment. */ |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index fc328339be99..7659d6f16e6b 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
| @@ -1565,11 +1565,16 @@ static void rt6_do_pmtu_disc(struct in6_addr *daddr, struct in6_addr *saddr, | |||
| 1565 | { | 1565 | { |
| 1566 | struct rt6_info *rt, *nrt; | 1566 | struct rt6_info *rt, *nrt; |
| 1567 | int allfrag = 0; | 1567 | int allfrag = 0; |
| 1568 | 1568 | again: | |
| 1569 | rt = rt6_lookup(net, daddr, saddr, ifindex, 0); | 1569 | rt = rt6_lookup(net, daddr, saddr, ifindex, 0); |
| 1570 | if (rt == NULL) | 1570 | if (rt == NULL) |
| 1571 | return; | 1571 | return; |
| 1572 | 1572 | ||
| 1573 | if (rt6_check_expired(rt)) { | ||
| 1574 | ip6_del_rt(rt); | ||
| 1575 | goto again; | ||
| 1576 | } | ||
| 1577 | |||
| 1573 | if (pmtu >= dst_mtu(&rt->dst)) | 1578 | if (pmtu >= dst_mtu(&rt->dst)) |
| 1574 | goto out; | 1579 | goto out; |
| 1575 | 1580 | ||
| @@ -1945,8 +1950,12 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, | |||
| 1945 | struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); | 1950 | struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); |
| 1946 | struct neighbour *neigh; | 1951 | struct neighbour *neigh; |
| 1947 | 1952 | ||
| 1948 | if (rt == NULL) | 1953 | if (rt == NULL) { |
| 1954 | if (net_ratelimit()) | ||
| 1955 | pr_warning("IPv6: Maximum number of routes reached," | ||
| 1956 | " consider increasing route/max_size.\n"); | ||
| 1949 | return ERR_PTR(-ENOMEM); | 1957 | return ERR_PTR(-ENOMEM); |
| 1958 | } | ||
| 1950 | 1959 | ||
| 1951 | dev_hold(net->loopback_dev); | 1960 | dev_hold(net->loopback_dev); |
| 1952 | in6_dev_hold(idev); | 1961 | in6_dev_hold(idev); |
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index d6bfaec3bbbf..8c4d00c7cd2b 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
| @@ -606,8 +606,9 @@ static int ipip6_rcv(struct sk_buff *skb) | |||
| 606 | return 0; | 606 | return 0; |
| 607 | } | 607 | } |
| 608 | 608 | ||
| 609 | icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); | 609 | /* no tunnel matched, let upstream know, ipsec may handle it */ |
| 610 | rcu_read_unlock(); | 610 | rcu_read_unlock(); |
| 611 | return 1; | ||
| 611 | out: | 612 | out: |
| 612 | kfree_skb(skb); | 613 | kfree_skb(skb); |
| 613 | return 0; | 614 | return 0; |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 91def93bec85..cd6cb7c3e563 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
| @@ -1477,6 +1477,7 @@ struct proto udpv6_prot = { | |||
| 1477 | .compat_setsockopt = compat_udpv6_setsockopt, | 1477 | .compat_setsockopt = compat_udpv6_setsockopt, |
| 1478 | .compat_getsockopt = compat_udpv6_getsockopt, | 1478 | .compat_getsockopt = compat_udpv6_getsockopt, |
| 1479 | #endif | 1479 | #endif |
| 1480 | .clear_sk = sk_prot_clear_portaddr_nulls, | ||
| 1480 | }; | 1481 | }; |
| 1481 | 1482 | ||
| 1482 | static struct inet_protosw udpv6_protosw = { | 1483 | static struct inet_protosw udpv6_protosw = { |
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c index 5f48fadc27f7..986c4de5292e 100644 --- a/net/ipv6/udplite.c +++ b/net/ipv6/udplite.c | |||
| @@ -55,6 +55,7 @@ struct proto udplitev6_prot = { | |||
| 55 | .compat_setsockopt = compat_udpv6_setsockopt, | 55 | .compat_setsockopt = compat_udpv6_setsockopt, |
| 56 | .compat_getsockopt = compat_udpv6_getsockopt, | 56 | .compat_getsockopt = compat_udpv6_getsockopt, |
| 57 | #endif | 57 | #endif |
| 58 | .clear_sk = sk_prot_clear_portaddr_nulls, | ||
| 58 | }; | 59 | }; |
| 59 | 60 | ||
| 60 | static struct inet_protosw udplite6_protosw = { | 61 | static struct inet_protosw udplite6_protosw = { |
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c index 6434bd5ce088..8e688b3de9ab 100644 --- a/net/ipv6/xfrm6_output.c +++ b/net/ipv6/xfrm6_output.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <linux/netfilter_ipv6.h> | 17 | #include <linux/netfilter_ipv6.h> |
| 18 | #include <net/dst.h> | 18 | #include <net/dst.h> |
| 19 | #include <net/ipv6.h> | 19 | #include <net/ipv6.h> |
| 20 | #include <net/ip6_route.h> | ||
| 20 | #include <net/xfrm.h> | 21 | #include <net/xfrm.h> |
| 21 | 22 | ||
| 22 | int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, | 23 | int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, |
| @@ -88,8 +89,21 @@ static int xfrm6_output_finish(struct sk_buff *skb) | |||
| 88 | return xfrm_output(skb); | 89 | return xfrm_output(skb); |
| 89 | } | 90 | } |
| 90 | 91 | ||
| 92 | static int __xfrm6_output(struct sk_buff *skb) | ||
| 93 | { | ||
| 94 | struct dst_entry *dst = skb_dst(skb); | ||
| 95 | struct xfrm_state *x = dst->xfrm; | ||
| 96 | |||
| 97 | if ((x && x->props.mode == XFRM_MODE_TUNNEL) && | ||
| 98 | ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) || | ||
| 99 | dst_allfrag(skb_dst(skb)))) { | ||
| 100 | return ip6_fragment(skb, xfrm6_output_finish); | ||
| 101 | } | ||
| 102 | return xfrm6_output_finish(skb); | ||
| 103 | } | ||
| 104 | |||
| 91 | int xfrm6_output(struct sk_buff *skb) | 105 | int xfrm6_output(struct sk_buff *skb) |
| 92 | { | 106 | { |
| 93 | return NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING, skb, NULL, | 107 | return NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING, skb, NULL, |
| 94 | skb_dst(skb)->dev, xfrm6_output_finish); | 108 | skb_dst(skb)->dev, __xfrm6_output); |
| 95 | } | 109 | } |
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 7f097989cde2..c9890e25cd4c 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c | |||
| @@ -45,7 +45,6 @@ | |||
| 45 | #include <linux/capability.h> | 45 | #include <linux/capability.h> |
| 46 | #include <linux/module.h> | 46 | #include <linux/module.h> |
| 47 | #include <linux/types.h> | 47 | #include <linux/types.h> |
| 48 | #include <linux/smp_lock.h> | ||
| 49 | #include <linux/socket.h> | 48 | #include <linux/socket.h> |
| 50 | #include <linux/sockios.h> | 49 | #include <linux/sockios.h> |
| 51 | #include <linux/slab.h> | 50 | #include <linux/slab.h> |
| @@ -2281,6 +2280,16 @@ static int irda_getsockopt(struct socket *sock, int level, int optname, | |||
| 2281 | 2280 | ||
| 2282 | switch (optname) { | 2281 | switch (optname) { |
| 2283 | case IRLMP_ENUMDEVICES: | 2282 | case IRLMP_ENUMDEVICES: |
| 2283 | |||
| 2284 | /* Offset to first device entry */ | ||
| 2285 | offset = sizeof(struct irda_device_list) - | ||
| 2286 | sizeof(struct irda_device_info); | ||
| 2287 | |||
| 2288 | if (len < offset) { | ||
| 2289 | err = -EINVAL; | ||
| 2290 | goto out; | ||
| 2291 | } | ||
| 2292 | |||
| 2284 | /* Ask lmp for the current discovery log */ | 2293 | /* Ask lmp for the current discovery log */ |
| 2285 | discoveries = irlmp_get_discoveries(&list.len, self->mask.word, | 2294 | discoveries = irlmp_get_discoveries(&list.len, self->mask.word, |
| 2286 | self->nslots); | 2295 | self->nslots); |
| @@ -2291,15 +2300,9 @@ static int irda_getsockopt(struct socket *sock, int level, int optname, | |||
| 2291 | } | 2300 | } |
| 2292 | 2301 | ||
| 2293 | /* Write total list length back to client */ | 2302 | /* Write total list length back to client */ |
| 2294 | if (copy_to_user(optval, &list, | 2303 | if (copy_to_user(optval, &list, offset)) |
| 2295 | sizeof(struct irda_device_list) - | ||
| 2296 | sizeof(struct irda_device_info))) | ||
| 2297 | err = -EFAULT; | 2304 | err = -EFAULT; |
| 2298 | 2305 | ||
| 2299 | /* Offset to first device entry */ | ||
| 2300 | offset = sizeof(struct irda_device_list) - | ||
| 2301 | sizeof(struct irda_device_info); | ||
| 2302 | |||
| 2303 | /* Copy the list itself - watch for overflow */ | 2306 | /* Copy the list itself - watch for overflow */ |
| 2304 | if (list.len > 2048) { | 2307 | if (list.len > 2048) { |
| 2305 | err = -EINVAL; | 2308 | err = -EINVAL; |
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c index 7fa86373de41..7c567b8aa89a 100644 --- a/net/irda/irnet/irnet_ppp.c +++ b/net/irda/irnet/irnet_ppp.c | |||
| @@ -15,7 +15,6 @@ | |||
| 15 | 15 | ||
| 16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
| 17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
| 18 | #include <linux/smp_lock.h> | ||
| 19 | #include "irnet_ppp.h" /* Private header */ | 18 | #include "irnet_ppp.h" /* Private header */ |
| 20 | /* Please put other headers in irnet.h - Thanks */ | 19 | /* Please put other headers in irnet.h - Thanks */ |
| 21 | 20 | ||
diff --git a/net/irda/irttp.c b/net/irda/irttp.c index 285761e77d90..f6054f9ccbe3 100644 --- a/net/irda/irttp.c +++ b/net/irda/irttp.c | |||
| @@ -550,22 +550,30 @@ EXPORT_SYMBOL(irttp_close_tsap); | |||
| 550 | */ | 550 | */ |
| 551 | int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) | 551 | int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) |
| 552 | { | 552 | { |
| 553 | int ret; | ||
| 554 | |||
| 553 | IRDA_ASSERT(self != NULL, return -1;); | 555 | IRDA_ASSERT(self != NULL, return -1;); |
| 554 | IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;); | 556 | IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;); |
| 555 | IRDA_ASSERT(skb != NULL, return -1;); | 557 | IRDA_ASSERT(skb != NULL, return -1;); |
| 556 | 558 | ||
| 557 | IRDA_DEBUG(4, "%s()\n", __func__); | 559 | IRDA_DEBUG(4, "%s()\n", __func__); |
| 558 | 560 | ||
| 561 | /* Take shortcut on zero byte packets */ | ||
| 562 | if (skb->len == 0) { | ||
| 563 | ret = 0; | ||
| 564 | goto err; | ||
| 565 | } | ||
| 566 | |||
| 559 | /* Check that nothing bad happens */ | 567 | /* Check that nothing bad happens */ |
| 560 | if ((skb->len == 0) || (!self->connected)) { | 568 | if (!self->connected) { |
| 561 | IRDA_DEBUG(1, "%s(), No data, or not connected\n", | 569 | IRDA_WARNING("%s(), Not connected\n", __func__); |
| 562 | __func__); | 570 | ret = -ENOTCONN; |
| 563 | goto err; | 571 | goto err; |
| 564 | } | 572 | } |
| 565 | 573 | ||
| 566 | if (skb->len > self->max_seg_size) { | 574 | if (skb->len > self->max_seg_size) { |
| 567 | IRDA_DEBUG(1, "%s(), UData is too large for IrLAP!\n", | 575 | IRDA_ERROR("%s(), UData is too large for IrLAP!\n", __func__); |
| 568 | __func__); | 576 | ret = -EMSGSIZE; |
| 569 | goto err; | 577 | goto err; |
| 570 | } | 578 | } |
| 571 | 579 | ||
| @@ -576,7 +584,7 @@ int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) | |||
| 576 | 584 | ||
| 577 | err: | 585 | err: |
| 578 | dev_kfree_skb(skb); | 586 | dev_kfree_skb(skb); |
| 579 | return -1; | 587 | return ret; |
| 580 | } | 588 | } |
| 581 | EXPORT_SYMBOL(irttp_udata_request); | 589 | EXPORT_SYMBOL(irttp_udata_request); |
| 582 | 590 | ||
| @@ -599,9 +607,15 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb) | |||
| 599 | IRDA_DEBUG(2, "%s() : queue len = %d\n", __func__, | 607 | IRDA_DEBUG(2, "%s() : queue len = %d\n", __func__, |
| 600 | skb_queue_len(&self->tx_queue)); | 608 | skb_queue_len(&self->tx_queue)); |
| 601 | 609 | ||
| 610 | /* Take shortcut on zero byte packets */ | ||
| 611 | if (skb->len == 0) { | ||
| 612 | ret = 0; | ||
| 613 | goto err; | ||
| 614 | } | ||
| 615 | |||
| 602 | /* Check that nothing bad happens */ | 616 | /* Check that nothing bad happens */ |
| 603 | if ((skb->len == 0) || (!self->connected)) { | 617 | if (!self->connected) { |
| 604 | IRDA_WARNING("%s: No data, or not connected\n", __func__); | 618 | IRDA_WARNING("%s: Not connected\n", __func__); |
| 605 | ret = -ENOTCONN; | 619 | ret = -ENOTCONN; |
| 606 | goto err; | 620 | goto err; |
| 607 | } | 621 | } |
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c index 0bf6a59545ab..522e219f3558 100644 --- a/net/l2tp/l2tp_ip.c +++ b/net/l2tp/l2tp_ip.c | |||
| @@ -674,4 +674,8 @@ MODULE_LICENSE("GPL"); | |||
| 674 | MODULE_AUTHOR("James Chapman <jchapman@katalix.com>"); | 674 | MODULE_AUTHOR("James Chapman <jchapman@katalix.com>"); |
| 675 | MODULE_DESCRIPTION("L2TP over IP"); | 675 | MODULE_DESCRIPTION("L2TP over IP"); |
| 676 | MODULE_VERSION("1.0"); | 676 | MODULE_VERSION("1.0"); |
| 677 | MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET, SOCK_DGRAM, IPPROTO_L2TP); | 677 | |
| 678 | /* Use the value of SOCK_DGRAM (2) directory, because __stringify does't like | ||
| 679 | * enums | ||
| 680 | */ | ||
| 681 | MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET, 2, IPPROTO_L2TP); | ||
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index 582612998211..e35dbe55f520 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c | |||
| @@ -317,8 +317,9 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) | |||
| 317 | goto out; | 317 | goto out; |
| 318 | rc = -ENODEV; | 318 | rc = -ENODEV; |
| 319 | rtnl_lock(); | 319 | rtnl_lock(); |
| 320 | rcu_read_lock(); | ||
| 320 | if (sk->sk_bound_dev_if) { | 321 | if (sk->sk_bound_dev_if) { |
| 321 | llc->dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if); | 322 | llc->dev = dev_get_by_index_rcu(&init_net, sk->sk_bound_dev_if); |
| 322 | if (llc->dev) { | 323 | if (llc->dev) { |
| 323 | if (!addr->sllc_arphrd) | 324 | if (!addr->sllc_arphrd) |
| 324 | addr->sllc_arphrd = llc->dev->type; | 325 | addr->sllc_arphrd = llc->dev->type; |
| @@ -329,13 +330,13 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) | |||
| 329 | !llc_mac_match(addr->sllc_mac, | 330 | !llc_mac_match(addr->sllc_mac, |
| 330 | llc->dev->dev_addr)) { | 331 | llc->dev->dev_addr)) { |
| 331 | rc = -EINVAL; | 332 | rc = -EINVAL; |
| 332 | dev_put(llc->dev); | ||
| 333 | llc->dev = NULL; | 333 | llc->dev = NULL; |
| 334 | } | 334 | } |
| 335 | } | 335 | } |
| 336 | } else | 336 | } else |
| 337 | llc->dev = dev_getbyhwaddr(&init_net, addr->sllc_arphrd, | 337 | llc->dev = dev_getbyhwaddr(&init_net, addr->sllc_arphrd, |
| 338 | addr->sllc_mac); | 338 | addr->sllc_mac); |
| 339 | rcu_read_unlock(); | ||
| 339 | rtnl_unlock(); | 340 | rtnl_unlock(); |
| 340 | if (!llc->dev) | 341 | if (!llc->dev) |
| 341 | goto out; | 342 | goto out; |
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig index 4d6f8653ec88..8e8ea9cb7093 100644 --- a/net/mac80211/Kconfig +++ b/net/mac80211/Kconfig | |||
| @@ -92,7 +92,7 @@ config MAC80211_MESH | |||
| 92 | config MAC80211_LEDS | 92 | config MAC80211_LEDS |
| 93 | bool "Enable LED triggers" | 93 | bool "Enable LED triggers" |
| 94 | depends on MAC80211 | 94 | depends on MAC80211 |
| 95 | select NEW_LEDS | 95 | depends on LEDS_CLASS |
| 96 | select LEDS_TRIGGERS | 96 | select LEDS_TRIGGERS |
| 97 | ---help--- | 97 | ---help--- |
| 98 | This option enables a few LED triggers for different | 98 | This option enables a few LED triggers for different |
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 239c4836a946..077a93dd1671 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c | |||
| @@ -780,6 +780,9 @@ void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | |||
| 780 | 780 | ||
| 781 | mutex_lock(&sdata->u.ibss.mtx); | 781 | mutex_lock(&sdata->u.ibss.mtx); |
| 782 | 782 | ||
| 783 | if (!sdata->u.ibss.ssid_len) | ||
| 784 | goto mgmt_out; /* not ready to merge yet */ | ||
| 785 | |||
| 783 | switch (fc & IEEE80211_FCTL_STYPE) { | 786 | switch (fc & IEEE80211_FCTL_STYPE) { |
| 784 | case IEEE80211_STYPE_PROBE_REQ: | 787 | case IEEE80211_STYPE_PROBE_REQ: |
| 785 | ieee80211_rx_mgmt_probe_req(sdata, mgmt, skb->len); | 788 | ieee80211_rx_mgmt_probe_req(sdata, mgmt, skb->len); |
| @@ -797,6 +800,7 @@ void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | |||
| 797 | break; | 800 | break; |
| 798 | } | 801 | } |
| 799 | 802 | ||
| 803 | mgmt_out: | ||
| 800 | mutex_unlock(&sdata->u.ibss.mtx); | 804 | mutex_unlock(&sdata->u.ibss.mtx); |
| 801 | } | 805 | } |
| 802 | 806 | ||
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index f9163b12c7f1..7aa85591dbe7 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c | |||
| @@ -391,6 +391,9 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
| 391 | u32 hw_reconf_flags = 0; | 391 | u32 hw_reconf_flags = 0; |
| 392 | int i; | 392 | int i; |
| 393 | 393 | ||
| 394 | if (local->scan_sdata == sdata) | ||
| 395 | ieee80211_scan_cancel(local); | ||
| 396 | |||
| 394 | clear_bit(SDATA_STATE_RUNNING, &sdata->state); | 397 | clear_bit(SDATA_STATE_RUNNING, &sdata->state); |
| 395 | 398 | ||
| 396 | /* | 399 | /* |
| @@ -523,9 +526,6 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
| 523 | synchronize_rcu(); | 526 | synchronize_rcu(); |
| 524 | skb_queue_purge(&sdata->skb_queue); | 527 | skb_queue_purge(&sdata->skb_queue); |
| 525 | 528 | ||
| 526 | if (local->scan_sdata == sdata) | ||
| 527 | ieee80211_scan_cancel(local); | ||
| 528 | |||
| 529 | /* | 529 | /* |
| 530 | * Disable beaconing here for mesh only, AP and IBSS | 530 | * Disable beaconing here for mesh only, AP and IBSS |
| 531 | * are already taken care of. | 531 | * are already taken care of. |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 902b03ee8f60..b01e467b76c6 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
| @@ -1788,9 +1788,11 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
| 1788 | 1788 | ||
| 1789 | fwd_skb = skb_copy(skb, GFP_ATOMIC); | 1789 | fwd_skb = skb_copy(skb, GFP_ATOMIC); |
| 1790 | 1790 | ||
| 1791 | if (!fwd_skb && net_ratelimit()) | 1791 | if (!fwd_skb && net_ratelimit()) { |
| 1792 | printk(KERN_DEBUG "%s: failed to clone mesh frame\n", | 1792 | printk(KERN_DEBUG "%s: failed to clone mesh frame\n", |
| 1793 | sdata->name); | 1793 | sdata->name); |
| 1794 | goto out; | ||
| 1795 | } | ||
| 1794 | 1796 | ||
| 1795 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; | 1797 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; |
| 1796 | memcpy(fwd_hdr->addr2, sdata->vif.addr, ETH_ALEN); | 1798 | memcpy(fwd_hdr->addr2, sdata->vif.addr, ETH_ALEN); |
| @@ -1828,6 +1830,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
| 1828 | } | 1830 | } |
| 1829 | } | 1831 | } |
| 1830 | 1832 | ||
| 1833 | out: | ||
| 1831 | if (is_multicast_ether_addr(hdr->addr1) || | 1834 | if (is_multicast_ether_addr(hdr->addr1) || |
| 1832 | sdata->dev->flags & IFF_PROMISC) | 1835 | sdata->dev->flags & IFF_PROMISC) |
| 1833 | return RX_CONTINUE; | 1836 | return RX_CONTINUE; |
| @@ -2247,6 +2250,10 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) | |||
| 2247 | break; | 2250 | break; |
| 2248 | case cpu_to_le16(IEEE80211_STYPE_DEAUTH): | 2251 | case cpu_to_le16(IEEE80211_STYPE_DEAUTH): |
| 2249 | case cpu_to_le16(IEEE80211_STYPE_DISASSOC): | 2252 | case cpu_to_le16(IEEE80211_STYPE_DISASSOC): |
| 2253 | if (is_multicast_ether_addr(mgmt->da) && | ||
| 2254 | !is_broadcast_ether_addr(mgmt->da)) | ||
| 2255 | return RX_DROP_MONITOR; | ||
| 2256 | |||
| 2250 | /* process only for station */ | 2257 | /* process only for station */ |
| 2251 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | 2258 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
| 2252 | return RX_DROP_MONITOR; | 2259 | return RX_DROP_MONITOR; |
| @@ -2741,6 +2748,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
| 2741 | 2748 | ||
| 2742 | if (ieee80211_prepare_and_rx_handle(&rx, skb, true)) | 2749 | if (ieee80211_prepare_and_rx_handle(&rx, skb, true)) |
| 2743 | return; | 2750 | return; |
| 2751 | goto out; | ||
| 2744 | } | 2752 | } |
| 2745 | } | 2753 | } |
| 2746 | 2754 | ||
| @@ -2780,6 +2788,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
| 2780 | return; | 2788 | return; |
| 2781 | } | 2789 | } |
| 2782 | 2790 | ||
| 2791 | out: | ||
| 2783 | dev_kfree_skb(skb); | 2792 | dev_kfree_skb(skb); |
| 2784 | } | 2793 | } |
| 2785 | 2794 | ||
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 96c594309506..7a637b80a62e 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
| @@ -1587,7 +1587,12 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, | |||
| 1587 | list) { | 1587 | list) { |
| 1588 | if (!ieee80211_sdata_running(tmp_sdata)) | 1588 | if (!ieee80211_sdata_running(tmp_sdata)) |
| 1589 | continue; | 1589 | continue; |
| 1590 | if (tmp_sdata->vif.type != NL80211_IFTYPE_AP) | 1590 | if (tmp_sdata->vif.type == |
| 1591 | NL80211_IFTYPE_MONITOR || | ||
| 1592 | tmp_sdata->vif.type == | ||
| 1593 | NL80211_IFTYPE_AP_VLAN || | ||
| 1594 | tmp_sdata->vif.type == | ||
| 1595 | NL80211_IFTYPE_WDS) | ||
| 1591 | continue; | 1596 | continue; |
| 1592 | if (compare_ether_addr(tmp_sdata->vif.addr, | 1597 | if (compare_ether_addr(tmp_sdata->vif.addr, |
| 1593 | hdr->addr2) == 0) { | 1598 | hdr->addr2) == 0) { |
| @@ -1732,15 +1737,13 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
| 1732 | int nh_pos, h_pos; | 1737 | int nh_pos, h_pos; |
| 1733 | struct sta_info *sta = NULL; | 1738 | struct sta_info *sta = NULL; |
| 1734 | u32 sta_flags = 0; | 1739 | u32 sta_flags = 0; |
| 1740 | struct sk_buff *tmp_skb; | ||
| 1735 | 1741 | ||
| 1736 | if (unlikely(skb->len < ETH_HLEN)) { | 1742 | if (unlikely(skb->len < ETH_HLEN)) { |
| 1737 | ret = NETDEV_TX_OK; | 1743 | ret = NETDEV_TX_OK; |
| 1738 | goto fail; | 1744 | goto fail; |
| 1739 | } | 1745 | } |
| 1740 | 1746 | ||
| 1741 | nh_pos = skb_network_header(skb) - skb->data; | ||
| 1742 | h_pos = skb_transport_header(skb) - skb->data; | ||
| 1743 | |||
| 1744 | /* convert Ethernet header to proper 802.11 header (based on | 1747 | /* convert Ethernet header to proper 802.11 header (based on |
| 1745 | * operation mode) */ | 1748 | * operation mode) */ |
| 1746 | ethertype = (skb->data[12] << 8) | skb->data[13]; | 1749 | ethertype = (skb->data[12] << 8) | skb->data[13]; |
| @@ -1913,6 +1916,20 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
| 1913 | goto fail; | 1916 | goto fail; |
| 1914 | } | 1917 | } |
| 1915 | 1918 | ||
| 1919 | /* | ||
| 1920 | * If the skb is shared we need to obtain our own copy. | ||
| 1921 | */ | ||
| 1922 | if (skb_shared(skb)) { | ||
| 1923 | tmp_skb = skb; | ||
| 1924 | skb = skb_copy(skb, GFP_ATOMIC); | ||
| 1925 | kfree_skb(tmp_skb); | ||
| 1926 | |||
| 1927 | if (!skb) { | ||
| 1928 | ret = NETDEV_TX_OK; | ||
| 1929 | goto fail; | ||
| 1930 | } | ||
| 1931 | } | ||
| 1932 | |||
| 1916 | hdr.frame_control = fc; | 1933 | hdr.frame_control = fc; |
| 1917 | hdr.duration_id = 0; | 1934 | hdr.duration_id = 0; |
| 1918 | hdr.seq_ctrl = 0; | 1935 | hdr.seq_ctrl = 0; |
| @@ -1931,6 +1948,9 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
| 1931 | encaps_len = 0; | 1948 | encaps_len = 0; |
| 1932 | } | 1949 | } |
| 1933 | 1950 | ||
| 1951 | nh_pos = skb_network_header(skb) - skb->data; | ||
| 1952 | h_pos = skb_transport_header(skb) - skb->data; | ||
| 1953 | |||
| 1934 | skb_pull(skb, skip_header_bytes); | 1954 | skb_pull(skb, skip_header_bytes); |
| 1935 | nh_pos -= skip_header_bytes; | 1955 | nh_pos -= skip_header_bytes; |
| 1936 | h_pos -= skip_header_bytes; | 1956 | h_pos -= skip_header_bytes; |
diff --git a/net/mac80211/work.c b/net/mac80211/work.c index ae344d1ba056..146097cb43a7 100644 --- a/net/mac80211/work.c +++ b/net/mac80211/work.c | |||
| @@ -1051,11 +1051,13 @@ void ieee80211_work_purge(struct ieee80211_sub_if_data *sdata) | |||
| 1051 | { | 1051 | { |
| 1052 | struct ieee80211_local *local = sdata->local; | 1052 | struct ieee80211_local *local = sdata->local; |
| 1053 | struct ieee80211_work *wk; | 1053 | struct ieee80211_work *wk; |
| 1054 | bool cleanup = false; | ||
| 1054 | 1055 | ||
| 1055 | mutex_lock(&local->mtx); | 1056 | mutex_lock(&local->mtx); |
| 1056 | list_for_each_entry(wk, &local->work_list, list) { | 1057 | list_for_each_entry(wk, &local->work_list, list) { |
| 1057 | if (wk->sdata != sdata) | 1058 | if (wk->sdata != sdata) |
| 1058 | continue; | 1059 | continue; |
| 1060 | cleanup = true; | ||
| 1059 | wk->type = IEEE80211_WORK_ABORT; | 1061 | wk->type = IEEE80211_WORK_ABORT; |
| 1060 | wk->started = true; | 1062 | wk->started = true; |
| 1061 | wk->timeout = jiffies; | 1063 | wk->timeout = jiffies; |
| @@ -1063,7 +1065,8 @@ void ieee80211_work_purge(struct ieee80211_sub_if_data *sdata) | |||
| 1063 | mutex_unlock(&local->mtx); | 1065 | mutex_unlock(&local->mtx); |
| 1064 | 1066 | ||
| 1065 | /* run cleanups etc. */ | 1067 | /* run cleanups etc. */ |
| 1066 | ieee80211_work_work(&local->work_work); | 1068 | if (cleanup) |
| 1069 | ieee80211_work_work(&local->work_work); | ||
| 1067 | 1070 | ||
| 1068 | mutex_lock(&local->mtx); | 1071 | mutex_lock(&local->mtx); |
| 1069 | list_for_each_entry(wk, &local->work_list, list) { | 1072 | list_for_each_entry(wk, &local->work_list, list) { |
diff --git a/net/netfilter/ipvs/Kconfig b/net/netfilter/ipvs/Kconfig index a22dac227055..70bd1d0774c6 100644 --- a/net/netfilter/ipvs/Kconfig +++ b/net/netfilter/ipvs/Kconfig | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | menuconfig IP_VS | 4 | menuconfig IP_VS |
| 5 | tristate "IP virtual server support" | 5 | tristate "IP virtual server support" |
| 6 | depends on NET && INET && NETFILTER | 6 | depends on NET && INET && NETFILTER |
| 7 | depends on (NF_CONNTRACK || NF_CONNTRACK=n) | ||
| 7 | ---help--- | 8 | ---help--- |
| 8 | IP Virtual Server support will let you build a high-performance | 9 | IP Virtual Server support will let you build a high-performance |
| 9 | virtual server based on cluster of two or more real servers. This | 10 | virtual server based on cluster of two or more real servers. This |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 3616f27b9d46..8298e676f5a0 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
| @@ -1610,9 +1610,11 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
| 1610 | 1610 | ||
| 1611 | err = -EINVAL; | 1611 | err = -EINVAL; |
| 1612 | vnet_hdr_len = sizeof(vnet_hdr); | 1612 | vnet_hdr_len = sizeof(vnet_hdr); |
| 1613 | if ((len -= vnet_hdr_len) < 0) | 1613 | if (len < vnet_hdr_len) |
| 1614 | goto out_free; | 1614 | goto out_free; |
| 1615 | 1615 | ||
| 1616 | len -= vnet_hdr_len; | ||
| 1617 | |||
| 1616 | if (skb_is_gso(skb)) { | 1618 | if (skb_is_gso(skb)) { |
| 1617 | struct skb_shared_info *sinfo = skb_shinfo(skb); | 1619 | struct skb_shared_info *sinfo = skb_shinfo(skb); |
| 1618 | 1620 | ||
| @@ -1719,7 +1721,7 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr, | |||
| 1719 | rcu_read_lock(); | 1721 | rcu_read_lock(); |
| 1720 | dev = dev_get_by_index_rcu(sock_net(sk), pkt_sk(sk)->ifindex); | 1722 | dev = dev_get_by_index_rcu(sock_net(sk), pkt_sk(sk)->ifindex); |
| 1721 | if (dev) | 1723 | if (dev) |
| 1722 | strlcpy(uaddr->sa_data, dev->name, 15); | 1724 | strncpy(uaddr->sa_data, dev->name, 14); |
| 1723 | else | 1725 | else |
| 1724 | memset(uaddr->sa_data, 0, 14); | 1726 | memset(uaddr->sa_data, 0, 14); |
| 1725 | rcu_read_unlock(); | 1727 | rcu_read_unlock(); |
| @@ -1742,6 +1744,7 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr, | |||
| 1742 | sll->sll_family = AF_PACKET; | 1744 | sll->sll_family = AF_PACKET; |
| 1743 | sll->sll_ifindex = po->ifindex; | 1745 | sll->sll_ifindex = po->ifindex; |
| 1744 | sll->sll_protocol = po->num; | 1746 | sll->sll_protocol = po->num; |
| 1747 | sll->sll_pkttype = 0; | ||
| 1745 | rcu_read_lock(); | 1748 | rcu_read_lock(); |
| 1746 | dev = dev_get_by_index_rcu(sock_net(sk), po->ifindex); | 1749 | dev = dev_get_by_index_rcu(sock_net(sk), po->ifindex); |
| 1747 | if (dev) { | 1750 | if (dev) { |
diff --git a/net/rds/message.c b/net/rds/message.c index 848cff45183b..1fd3d29023d7 100644 --- a/net/rds/message.c +++ b/net/rds/message.c | |||
| @@ -249,8 +249,10 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned in | |||
| 249 | rm->m_inc.i_hdr.h_len = cpu_to_be32(total_len); | 249 | rm->m_inc.i_hdr.h_len = cpu_to_be32(total_len); |
| 250 | rm->data.op_nents = ceil(total_len, PAGE_SIZE); | 250 | rm->data.op_nents = ceil(total_len, PAGE_SIZE); |
| 251 | rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs); | 251 | rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs); |
| 252 | if (!rm->data.op_sg) | 252 | if (!rm->data.op_sg) { |
| 253 | rds_message_put(rm); | ||
| 253 | return ERR_PTR(-ENOMEM); | 254 | return ERR_PTR(-ENOMEM); |
| 255 | } | ||
| 254 | 256 | ||
| 255 | for (i = 0; i < rm->data.op_nents; ++i) { | 257 | for (i = 0; i < rm->data.op_nents; ++i) { |
| 256 | sg_set_page(&rm->data.op_sg[i], | 258 | sg_set_page(&rm->data.op_sg[i], |
diff --git a/net/rds/rdma.c b/net/rds/rdma.c index 8920f2a83327..4e37c1cbe8b2 100644 --- a/net/rds/rdma.c +++ b/net/rds/rdma.c | |||
| @@ -567,7 +567,7 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm, | |||
| 567 | goto out; | 567 | goto out; |
| 568 | } | 568 | } |
| 569 | 569 | ||
| 570 | if (args->nr_local > (u64)UINT_MAX) { | 570 | if (args->nr_local > UIO_MAXIOV) { |
| 571 | ret = -EMSGSIZE; | 571 | ret = -EMSGSIZE; |
| 572 | goto out; | 572 | goto out; |
| 573 | } | 573 | } |
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c index efd4f95fd050..f23d9155b1ef 100644 --- a/net/sched/cls_basic.c +++ b/net/sched/cls_basic.c | |||
| @@ -268,6 +268,10 @@ static int basic_dump(struct tcf_proto *tp, unsigned long fh, | |||
| 268 | goto nla_put_failure; | 268 | goto nla_put_failure; |
| 269 | 269 | ||
| 270 | nla_nest_end(skb, nest); | 270 | nla_nest_end(skb, nest); |
| 271 | |||
| 272 | if (tcf_exts_dump_stats(skb, &f->exts, &basic_ext_map) < 0) | ||
| 273 | goto nla_put_failure; | ||
| 274 | |||
| 271 | return skb->len; | 275 | return skb->len; |
| 272 | 276 | ||
| 273 | nla_put_failure: | 277 | nla_put_failure: |
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index 3cf478d012dd..7150705f1d0b 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c | |||
| @@ -270,7 +270,6 @@ static unsigned int sfq_drop(struct Qdisc *sch) | |||
| 270 | /* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */ | 270 | /* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */ |
| 271 | d = q->next[q->tail]; | 271 | d = q->next[q->tail]; |
| 272 | q->next[q->tail] = q->next[d]; | 272 | q->next[q->tail] = q->next[d]; |
| 273 | q->allot[q->next[d]] += q->quantum; | ||
| 274 | skb = q->qs[d].prev; | 273 | skb = q->qs[d].prev; |
| 275 | len = qdisc_pkt_len(skb); | 274 | len = qdisc_pkt_len(skb); |
| 276 | __skb_unlink(skb, &q->qs[d]); | 275 | __skb_unlink(skb, &q->qs[d]); |
| @@ -321,14 +320,13 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
| 321 | sfq_inc(q, x); | 320 | sfq_inc(q, x); |
| 322 | if (q->qs[x].qlen == 1) { /* The flow is new */ | 321 | if (q->qs[x].qlen == 1) { /* The flow is new */ |
| 323 | if (q->tail == SFQ_DEPTH) { /* It is the first flow */ | 322 | if (q->tail == SFQ_DEPTH) { /* It is the first flow */ |
| 324 | q->tail = x; | ||
| 325 | q->next[x] = x; | 323 | q->next[x] = x; |
| 326 | q->allot[x] = q->quantum; | ||
| 327 | } else { | 324 | } else { |
| 328 | q->next[x] = q->next[q->tail]; | 325 | q->next[x] = q->next[q->tail]; |
| 329 | q->next[q->tail] = x; | 326 | q->next[q->tail] = x; |
| 330 | q->tail = x; | ||
| 331 | } | 327 | } |
| 328 | q->tail = x; | ||
| 329 | q->allot[x] = q->quantum; | ||
| 332 | } | 330 | } |
| 333 | if (++sch->q.qlen <= q->limit) { | 331 | if (++sch->q.qlen <= q->limit) { |
| 334 | sch->bstats.bytes += qdisc_pkt_len(skb); | 332 | sch->bstats.bytes += qdisc_pkt_len(skb); |
| @@ -359,13 +357,13 @@ sfq_dequeue(struct Qdisc *sch) | |||
| 359 | { | 357 | { |
| 360 | struct sfq_sched_data *q = qdisc_priv(sch); | 358 | struct sfq_sched_data *q = qdisc_priv(sch); |
| 361 | struct sk_buff *skb; | 359 | struct sk_buff *skb; |
| 362 | sfq_index a, old_a; | 360 | sfq_index a, next_a; |
| 363 | 361 | ||
| 364 | /* No active slots */ | 362 | /* No active slots */ |
| 365 | if (q->tail == SFQ_DEPTH) | 363 | if (q->tail == SFQ_DEPTH) |
| 366 | return NULL; | 364 | return NULL; |
| 367 | 365 | ||
| 368 | a = old_a = q->next[q->tail]; | 366 | a = q->next[q->tail]; |
| 369 | 367 | ||
| 370 | /* Grab packet */ | 368 | /* Grab packet */ |
| 371 | skb = __skb_dequeue(&q->qs[a]); | 369 | skb = __skb_dequeue(&q->qs[a]); |
| @@ -376,17 +374,15 @@ sfq_dequeue(struct Qdisc *sch) | |||
| 376 | /* Is the slot empty? */ | 374 | /* Is the slot empty? */ |
| 377 | if (q->qs[a].qlen == 0) { | 375 | if (q->qs[a].qlen == 0) { |
| 378 | q->ht[q->hash[a]] = SFQ_DEPTH; | 376 | q->ht[q->hash[a]] = SFQ_DEPTH; |
| 379 | a = q->next[a]; | 377 | next_a = q->next[a]; |
| 380 | if (a == old_a) { | 378 | if (a == next_a) { |
| 381 | q->tail = SFQ_DEPTH; | 379 | q->tail = SFQ_DEPTH; |
| 382 | return skb; | 380 | return skb; |
| 383 | } | 381 | } |
| 384 | q->next[q->tail] = a; | 382 | q->next[q->tail] = next_a; |
| 385 | q->allot[a] += q->quantum; | ||
| 386 | } else if ((q->allot[a] -= qdisc_pkt_len(skb)) <= 0) { | 383 | } else if ((q->allot[a] -= qdisc_pkt_len(skb)) <= 0) { |
| 387 | q->tail = a; | ||
| 388 | a = q->next[a]; | ||
| 389 | q->allot[a] += q->quantum; | 384 | q->allot[a] += q->quantum; |
| 385 | q->tail = a; | ||
| 390 | } | 386 | } |
| 391 | return skb; | 387 | return skb; |
| 392 | } | 388 | } |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 1ef29c74d85e..e58f9476f29c 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
| @@ -92,7 +92,7 @@ static struct sctp_af *sctp_af_v6_specific; | |||
| 92 | struct kmem_cache *sctp_chunk_cachep __read_mostly; | 92 | struct kmem_cache *sctp_chunk_cachep __read_mostly; |
| 93 | struct kmem_cache *sctp_bucket_cachep __read_mostly; | 93 | struct kmem_cache *sctp_bucket_cachep __read_mostly; |
| 94 | 94 | ||
| 95 | int sysctl_sctp_mem[3]; | 95 | long sysctl_sctp_mem[3]; |
| 96 | int sysctl_sctp_rmem[3]; | 96 | int sysctl_sctp_rmem[3]; |
| 97 | int sysctl_sctp_wmem[3]; | 97 | int sysctl_sctp_wmem[3]; |
| 98 | 98 | ||
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index e34ca9cc1167..fff0926b1111 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
| @@ -111,12 +111,12 @@ static void sctp_sock_migrate(struct sock *, struct sock *, | |||
| 111 | static char *sctp_hmac_alg = SCTP_COOKIE_HMAC_ALG; | 111 | static char *sctp_hmac_alg = SCTP_COOKIE_HMAC_ALG; |
| 112 | 112 | ||
| 113 | extern struct kmem_cache *sctp_bucket_cachep; | 113 | extern struct kmem_cache *sctp_bucket_cachep; |
| 114 | extern int sysctl_sctp_mem[3]; | 114 | extern long sysctl_sctp_mem[3]; |
| 115 | extern int sysctl_sctp_rmem[3]; | 115 | extern int sysctl_sctp_rmem[3]; |
| 116 | extern int sysctl_sctp_wmem[3]; | 116 | extern int sysctl_sctp_wmem[3]; |
| 117 | 117 | ||
| 118 | static int sctp_memory_pressure; | 118 | static int sctp_memory_pressure; |
| 119 | static atomic_t sctp_memory_allocated; | 119 | static atomic_long_t sctp_memory_allocated; |
| 120 | struct percpu_counter sctp_sockets_allocated; | 120 | struct percpu_counter sctp_sockets_allocated; |
| 121 | 121 | ||
| 122 | static void sctp_enter_memory_pressure(struct sock *sk) | 122 | static void sctp_enter_memory_pressure(struct sock *sk) |
| @@ -2932,6 +2932,7 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva | |||
| 2932 | struct sctp_association *asoc = NULL; | 2932 | struct sctp_association *asoc = NULL; |
| 2933 | struct sctp_setpeerprim prim; | 2933 | struct sctp_setpeerprim prim; |
| 2934 | struct sctp_chunk *chunk; | 2934 | struct sctp_chunk *chunk; |
| 2935 | struct sctp_af *af; | ||
| 2935 | int err; | 2936 | int err; |
| 2936 | 2937 | ||
| 2937 | sp = sctp_sk(sk); | 2938 | sp = sctp_sk(sk); |
| @@ -2959,6 +2960,13 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva | |||
| 2959 | if (!sctp_state(asoc, ESTABLISHED)) | 2960 | if (!sctp_state(asoc, ESTABLISHED)) |
| 2960 | return -ENOTCONN; | 2961 | return -ENOTCONN; |
| 2961 | 2962 | ||
| 2963 | af = sctp_get_af_specific(prim.sspp_addr.ss_family); | ||
| 2964 | if (!af) | ||
| 2965 | return -EINVAL; | ||
| 2966 | |||
| 2967 | if (!af->addr_valid((union sctp_addr *)&prim.sspp_addr, sp, NULL)) | ||
| 2968 | return -EADDRNOTAVAIL; | ||
| 2969 | |||
| 2962 | if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim.sspp_addr)) | 2970 | if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim.sspp_addr)) |
| 2963 | return -EADDRNOTAVAIL; | 2971 | return -EADDRNOTAVAIL; |
| 2964 | 2972 | ||
| @@ -5045,7 +5053,7 @@ static int sctp_getsockopt_partial_delivery_point(struct sock *sk, int len, | |||
| 5045 | if (copy_to_user(optval, &val, len)) | 5053 | if (copy_to_user(optval, &val, len)) |
| 5046 | return -EFAULT; | 5054 | return -EFAULT; |
| 5047 | 5055 | ||
| 5048 | return -ENOTSUPP; | 5056 | return 0; |
| 5049 | } | 5057 | } |
| 5050 | 5058 | ||
| 5051 | /* | 5059 | /* |
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c index 832590bbe0c0..50cb57f0919e 100644 --- a/net/sctp/sysctl.c +++ b/net/sctp/sysctl.c | |||
| @@ -54,7 +54,7 @@ static int sack_timer_max = 500; | |||
| 54 | static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */ | 54 | static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */ |
| 55 | static int rwnd_scale_max = 16; | 55 | static int rwnd_scale_max = 16; |
| 56 | 56 | ||
| 57 | extern int sysctl_sctp_mem[3]; | 57 | extern long sysctl_sctp_mem[3]; |
| 58 | extern int sysctl_sctp_rmem[3]; | 58 | extern int sysctl_sctp_rmem[3]; |
| 59 | extern int sysctl_sctp_wmem[3]; | 59 | extern int sysctl_sctp_wmem[3]; |
| 60 | 60 | ||
| @@ -203,7 +203,7 @@ static ctl_table sctp_table[] = { | |||
| 203 | .data = &sysctl_sctp_mem, | 203 | .data = &sysctl_sctp_mem, |
| 204 | .maxlen = sizeof(sysctl_sctp_mem), | 204 | .maxlen = sizeof(sysctl_sctp_mem), |
| 205 | .mode = 0644, | 205 | .mode = 0644, |
| 206 | .proc_handler = proc_dointvec, | 206 | .proc_handler = proc_doulongvec_minmax |
| 207 | }, | 207 | }, |
| 208 | { | 208 | { |
| 209 | .procname = "sctp_rmem", | 209 | .procname = "sctp_rmem", |
diff --git a/net/socket.c b/net/socket.c index 3ca2fd9e3720..088fb3fd45e0 100644 --- a/net/socket.c +++ b/net/socket.c | |||
| @@ -732,6 +732,21 @@ static int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, | |||
| 732 | return ret; | 732 | return ret; |
| 733 | } | 733 | } |
| 734 | 734 | ||
| 735 | /** | ||
| 736 | * kernel_recvmsg - Receive a message from a socket (kernel space) | ||
| 737 | * @sock: The socket to receive the message from | ||
| 738 | * @msg: Received message | ||
| 739 | * @vec: Input s/g array for message data | ||
| 740 | * @num: Size of input s/g array | ||
| 741 | * @size: Number of bytes to read | ||
| 742 | * @flags: Message flags (MSG_DONTWAIT, etc...) | ||
| 743 | * | ||
| 744 | * On return the msg structure contains the scatter/gather array passed in the | ||
| 745 | * vec argument. The array is modified so that it consists of the unfilled | ||
| 746 | * portion of the original array. | ||
| 747 | * | ||
| 748 | * The returned value is the total number of bytes received, or an error. | ||
| 749 | */ | ||
| 735 | int kernel_recvmsg(struct socket *sock, struct msghdr *msg, | 750 | int kernel_recvmsg(struct socket *sock, struct msghdr *msg, |
| 736 | struct kvec *vec, size_t num, size_t size, int flags) | 751 | struct kvec *vec, size_t num, size_t size, int flags) |
| 737 | { | 752 | { |
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 9dab9573be41..92ce94f5146b 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
| @@ -989,20 +989,26 @@ call_refreshresult(struct rpc_task *task) | |||
| 989 | dprint_status(task); | 989 | dprint_status(task); |
| 990 | 990 | ||
| 991 | task->tk_status = 0; | 991 | task->tk_status = 0; |
| 992 | task->tk_action = call_allocate; | 992 | task->tk_action = call_refresh; |
| 993 | if (status >= 0 && rpcauth_uptodatecred(task)) | ||
| 994 | return; | ||
| 995 | switch (status) { | 993 | switch (status) { |
| 996 | case -EACCES: | 994 | case 0: |
| 997 | rpc_exit(task, -EACCES); | 995 | if (rpcauth_uptodatecred(task)) |
| 998 | return; | 996 | task->tk_action = call_allocate; |
| 999 | case -ENOMEM: | ||
| 1000 | rpc_exit(task, -ENOMEM); | ||
| 1001 | return; | 997 | return; |
| 1002 | case -ETIMEDOUT: | 998 | case -ETIMEDOUT: |
| 1003 | rpc_delay(task, 3*HZ); | 999 | rpc_delay(task, 3*HZ); |
| 1000 | case -EAGAIN: | ||
| 1001 | status = -EACCES; | ||
| 1002 | if (!task->tk_cred_retry) | ||
| 1003 | break; | ||
| 1004 | task->tk_cred_retry--; | ||
| 1005 | dprintk("RPC: %5u %s: retry refresh creds\n", | ||
| 1006 | task->tk_pid, __func__); | ||
| 1007 | return; | ||
| 1004 | } | 1008 | } |
| 1005 | task->tk_action = call_refresh; | 1009 | dprintk("RPC: %5u %s: refresh creds failed with error %d\n", |
| 1010 | task->tk_pid, __func__, status); | ||
| 1011 | rpc_exit(task, status); | ||
| 1006 | } | 1012 | } |
| 1007 | 1013 | ||
| 1008 | /* | 1014 | /* |
diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c index f71a73107ae9..80df89d957ba 100644 --- a/net/sunrpc/stats.c +++ b/net/sunrpc/stats.c | |||
| @@ -115,9 +115,7 @@ EXPORT_SYMBOL_GPL(svc_seq_show); | |||
| 115 | */ | 115 | */ |
| 116 | struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt) | 116 | struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt) |
| 117 | { | 117 | { |
| 118 | struct rpc_iostats *new; | 118 | return kcalloc(clnt->cl_maxproc, sizeof(struct rpc_iostats), GFP_KERNEL); |
| 119 | new = kcalloc(clnt->cl_maxproc, sizeof(struct rpc_iostats), GFP_KERNEL); | ||
| 120 | return new; | ||
| 121 | } | 119 | } |
| 122 | EXPORT_SYMBOL_GPL(rpc_alloc_iostats); | 120 | EXPORT_SYMBOL_GPL(rpc_alloc_iostats); |
| 123 | 121 | ||
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index c82fe739fbdc..3f2c5559ca1a 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <linux/sched.h> | 7 | #include <linux/sched.h> |
| 8 | #include <linux/smp_lock.h> | ||
| 9 | #include <linux/errno.h> | 8 | #include <linux/errno.h> |
| 10 | #include <linux/freezer.h> | 9 | #include <linux/freezer.h> |
| 11 | #include <linux/kthread.h> | 10 | #include <linux/kthread.h> |
| @@ -213,6 +212,7 @@ int svc_create_xprt(struct svc_serv *serv, const char *xprt_name, | |||
| 213 | spin_lock(&svc_xprt_class_lock); | 212 | spin_lock(&svc_xprt_class_lock); |
| 214 | list_for_each_entry(xcl, &svc_xprt_class_list, xcl_list) { | 213 | list_for_each_entry(xcl, &svc_xprt_class_list, xcl_list) { |
| 215 | struct svc_xprt *newxprt; | 214 | struct svc_xprt *newxprt; |
| 215 | unsigned short newport; | ||
| 216 | 216 | ||
| 217 | if (strcmp(xprt_name, xcl->xcl_name)) | 217 | if (strcmp(xprt_name, xcl->xcl_name)) |
| 218 | continue; | 218 | continue; |
| @@ -231,8 +231,9 @@ int svc_create_xprt(struct svc_serv *serv, const char *xprt_name, | |||
| 231 | spin_lock_bh(&serv->sv_lock); | 231 | spin_lock_bh(&serv->sv_lock); |
| 232 | list_add(&newxprt->xpt_list, &serv->sv_permsocks); | 232 | list_add(&newxprt->xpt_list, &serv->sv_permsocks); |
| 233 | spin_unlock_bh(&serv->sv_lock); | 233 | spin_unlock_bh(&serv->sv_lock); |
| 234 | newport = svc_xprt_local_port(newxprt); | ||
| 234 | clear_bit(XPT_BUSY, &newxprt->xpt_flags); | 235 | clear_bit(XPT_BUSY, &newxprt->xpt_flags); |
| 235 | return svc_xprt_local_port(newxprt); | 236 | return newport; |
| 236 | } | 237 | } |
| 237 | err: | 238 | err: |
| 238 | spin_unlock(&svc_xprt_class_lock); | 239 | spin_unlock(&svc_xprt_class_lock); |
| @@ -426,8 +427,13 @@ void svc_xprt_received(struct svc_xprt *xprt) | |||
| 426 | { | 427 | { |
| 427 | BUG_ON(!test_bit(XPT_BUSY, &xprt->xpt_flags)); | 428 | BUG_ON(!test_bit(XPT_BUSY, &xprt->xpt_flags)); |
| 428 | xprt->xpt_pool = NULL; | 429 | xprt->xpt_pool = NULL; |
| 430 | /* As soon as we clear busy, the xprt could be closed and | ||
| 431 | * 'put', so we need a reference to call svc_xprt_enqueue with: | ||
| 432 | */ | ||
| 433 | svc_xprt_get(xprt); | ||
| 429 | clear_bit(XPT_BUSY, &xprt->xpt_flags); | 434 | clear_bit(XPT_BUSY, &xprt->xpt_flags); |
| 430 | svc_xprt_enqueue(xprt); | 435 | svc_xprt_enqueue(xprt); |
| 436 | svc_xprt_put(xprt); | ||
| 431 | } | 437 | } |
| 432 | EXPORT_SYMBOL_GPL(svc_xprt_received); | 438 | EXPORT_SYMBOL_GPL(svc_xprt_received); |
| 433 | 439 | ||
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 33217fc3d697..e9f0d5004483 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
| @@ -396,6 +396,7 @@ static int get_name(struct socket *sock, struct sockaddr *uaddr, | |||
| 396 | struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr; | 396 | struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr; |
| 397 | struct tipc_sock *tsock = tipc_sk(sock->sk); | 397 | struct tipc_sock *tsock = tipc_sk(sock->sk); |
| 398 | 398 | ||
| 399 | memset(addr, 0, sizeof(*addr)); | ||
| 399 | if (peer) { | 400 | if (peer) { |
| 400 | if ((sock->state != SS_CONNECTED) && | 401 | if ((sock->state != SS_CONNECTED) && |
| 401 | ((peer != 2) || (sock->state != SS_DISCONNECTING))) | 402 | ((peer != 2) || (sock->state != SS_DISCONNECTING))) |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 3c95304a0817..2268e6798124 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
| @@ -1343,9 +1343,25 @@ static void unix_destruct_scm(struct sk_buff *skb) | |||
| 1343 | sock_wfree(skb); | 1343 | sock_wfree(skb); |
| 1344 | } | 1344 | } |
| 1345 | 1345 | ||
| 1346 | #define MAX_RECURSION_LEVEL 4 | ||
| 1347 | |||
| 1346 | static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb) | 1348 | static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb) |
| 1347 | { | 1349 | { |
| 1348 | int i; | 1350 | int i; |
| 1351 | unsigned char max_level = 0; | ||
| 1352 | int unix_sock_count = 0; | ||
| 1353 | |||
| 1354 | for (i = scm->fp->count - 1; i >= 0; i--) { | ||
| 1355 | struct sock *sk = unix_get_socket(scm->fp->fp[i]); | ||
| 1356 | |||
| 1357 | if (sk) { | ||
| 1358 | unix_sock_count++; | ||
| 1359 | max_level = max(max_level, | ||
| 1360 | unix_sk(sk)->recursion_level); | ||
| 1361 | } | ||
| 1362 | } | ||
| 1363 | if (unlikely(max_level > MAX_RECURSION_LEVEL)) | ||
| 1364 | return -ETOOMANYREFS; | ||
| 1349 | 1365 | ||
| 1350 | /* | 1366 | /* |
| 1351 | * Need to duplicate file references for the sake of garbage | 1367 | * Need to duplicate file references for the sake of garbage |
| @@ -1356,9 +1372,11 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb) | |||
| 1356 | if (!UNIXCB(skb).fp) | 1372 | if (!UNIXCB(skb).fp) |
| 1357 | return -ENOMEM; | 1373 | return -ENOMEM; |
| 1358 | 1374 | ||
| 1359 | for (i = scm->fp->count-1; i >= 0; i--) | 1375 | if (unix_sock_count) { |
| 1360 | unix_inflight(scm->fp->fp[i]); | 1376 | for (i = scm->fp->count - 1; i >= 0; i--) |
| 1361 | return 0; | 1377 | unix_inflight(scm->fp->fp[i]); |
| 1378 | } | ||
| 1379 | return max_level; | ||
| 1362 | } | 1380 | } |
| 1363 | 1381 | ||
| 1364 | static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool send_fds) | 1382 | static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool send_fds) |
| @@ -1393,6 +1411,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
| 1393 | struct sk_buff *skb; | 1411 | struct sk_buff *skb; |
| 1394 | long timeo; | 1412 | long timeo; |
| 1395 | struct scm_cookie tmp_scm; | 1413 | struct scm_cookie tmp_scm; |
| 1414 | int max_level; | ||
| 1396 | 1415 | ||
| 1397 | if (NULL == siocb->scm) | 1416 | if (NULL == siocb->scm) |
| 1398 | siocb->scm = &tmp_scm; | 1417 | siocb->scm = &tmp_scm; |
| @@ -1431,8 +1450,9 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
| 1431 | goto out; | 1450 | goto out; |
| 1432 | 1451 | ||
| 1433 | err = unix_scm_to_skb(siocb->scm, skb, true); | 1452 | err = unix_scm_to_skb(siocb->scm, skb, true); |
| 1434 | if (err) | 1453 | if (err < 0) |
| 1435 | goto out_free; | 1454 | goto out_free; |
| 1455 | max_level = err + 1; | ||
| 1436 | unix_get_secdata(siocb->scm, skb); | 1456 | unix_get_secdata(siocb->scm, skb); |
| 1437 | 1457 | ||
| 1438 | skb_reset_transport_header(skb); | 1458 | skb_reset_transport_header(skb); |
| @@ -1514,6 +1534,8 @@ restart: | |||
| 1514 | if (sock_flag(other, SOCK_RCVTSTAMP)) | 1534 | if (sock_flag(other, SOCK_RCVTSTAMP)) |
| 1515 | __net_timestamp(skb); | 1535 | __net_timestamp(skb); |
| 1516 | skb_queue_tail(&other->sk_receive_queue, skb); | 1536 | skb_queue_tail(&other->sk_receive_queue, skb); |
| 1537 | if (max_level > unix_sk(other)->recursion_level) | ||
| 1538 | unix_sk(other)->recursion_level = max_level; | ||
| 1517 | unix_state_unlock(other); | 1539 | unix_state_unlock(other); |
| 1518 | other->sk_data_ready(other, len); | 1540 | other->sk_data_ready(other, len); |
| 1519 | sock_put(other); | 1541 | sock_put(other); |
| @@ -1544,6 +1566,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
| 1544 | int sent = 0; | 1566 | int sent = 0; |
| 1545 | struct scm_cookie tmp_scm; | 1567 | struct scm_cookie tmp_scm; |
| 1546 | bool fds_sent = false; | 1568 | bool fds_sent = false; |
| 1569 | int max_level; | ||
| 1547 | 1570 | ||
| 1548 | if (NULL == siocb->scm) | 1571 | if (NULL == siocb->scm) |
| 1549 | siocb->scm = &tmp_scm; | 1572 | siocb->scm = &tmp_scm; |
| @@ -1607,10 +1630,11 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
| 1607 | 1630 | ||
| 1608 | /* Only send the fds in the first buffer */ | 1631 | /* Only send the fds in the first buffer */ |
| 1609 | err = unix_scm_to_skb(siocb->scm, skb, !fds_sent); | 1632 | err = unix_scm_to_skb(siocb->scm, skb, !fds_sent); |
| 1610 | if (err) { | 1633 | if (err < 0) { |
| 1611 | kfree_skb(skb); | 1634 | kfree_skb(skb); |
| 1612 | goto out_err; | 1635 | goto out_err; |
| 1613 | } | 1636 | } |
| 1637 | max_level = err + 1; | ||
| 1614 | fds_sent = true; | 1638 | fds_sent = true; |
| 1615 | 1639 | ||
| 1616 | err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size); | 1640 | err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size); |
| @@ -1626,6 +1650,8 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
| 1626 | goto pipe_err_free; | 1650 | goto pipe_err_free; |
| 1627 | 1651 | ||
| 1628 | skb_queue_tail(&other->sk_receive_queue, skb); | 1652 | skb_queue_tail(&other->sk_receive_queue, skb); |
| 1653 | if (max_level > unix_sk(other)->recursion_level) | ||
| 1654 | unix_sk(other)->recursion_level = max_level; | ||
| 1629 | unix_state_unlock(other); | 1655 | unix_state_unlock(other); |
| 1630 | other->sk_data_ready(other, size); | 1656 | other->sk_data_ready(other, size); |
| 1631 | sent += size; | 1657 | sent += size; |
| @@ -1845,6 +1871,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
| 1845 | unix_state_lock(sk); | 1871 | unix_state_lock(sk); |
| 1846 | skb = skb_dequeue(&sk->sk_receive_queue); | 1872 | skb = skb_dequeue(&sk->sk_receive_queue); |
| 1847 | if (skb == NULL) { | 1873 | if (skb == NULL) { |
| 1874 | unix_sk(sk)->recursion_level = 0; | ||
| 1848 | if (copied >= target) | 1875 | if (copied >= target) |
| 1849 | goto unlock; | 1876 | goto unlock; |
| 1850 | 1877 | ||
diff --git a/net/unix/garbage.c b/net/unix/garbage.c index c8df6fda0b1f..f89f83bf828e 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c | |||
| @@ -96,7 +96,7 @@ static DECLARE_WAIT_QUEUE_HEAD(unix_gc_wait); | |||
| 96 | unsigned int unix_tot_inflight; | 96 | unsigned int unix_tot_inflight; |
| 97 | 97 | ||
| 98 | 98 | ||
| 99 | static struct sock *unix_get_socket(struct file *filp) | 99 | struct sock *unix_get_socket(struct file *filp) |
| 100 | { | 100 | { |
| 101 | struct sock *u_sock = NULL; | 101 | struct sock *u_sock = NULL; |
| 102 | struct inode *inode = filp->f_path.dentry->d_inode; | 102 | struct inode *inode = filp->f_path.dentry->d_inode; |
| @@ -259,9 +259,16 @@ static void inc_inflight_move_tail(struct unix_sock *u) | |||
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | static bool gc_in_progress = false; | 261 | static bool gc_in_progress = false; |
| 262 | #define UNIX_INFLIGHT_TRIGGER_GC 16000 | ||
| 262 | 263 | ||
| 263 | void wait_for_unix_gc(void) | 264 | void wait_for_unix_gc(void) |
| 264 | { | 265 | { |
| 266 | /* | ||
| 267 | * If number of inflight sockets is insane, | ||
| 268 | * force a garbage collect right now. | ||
| 269 | */ | ||
| 270 | if (unix_tot_inflight > UNIX_INFLIGHT_TRIGGER_GC && !gc_in_progress) | ||
| 271 | unix_gc(); | ||
| 265 | wait_event(unix_gc_wait, gc_in_progress == false); | 272 | wait_event(unix_gc_wait, gc_in_progress == false); |
| 266 | } | 273 | } |
| 267 | 274 | ||
diff --git a/net/wireless/chan.c b/net/wireless/chan.c index d0c92dddb26b..17cd0c04d139 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c | |||
| @@ -44,6 +44,38 @@ rdev_freq_to_chan(struct cfg80211_registered_device *rdev, | |||
| 44 | return chan; | 44 | return chan; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | static bool can_beacon_sec_chan(struct wiphy *wiphy, | ||
| 48 | struct ieee80211_channel *chan, | ||
| 49 | enum nl80211_channel_type channel_type) | ||
| 50 | { | ||
| 51 | struct ieee80211_channel *sec_chan; | ||
| 52 | int diff; | ||
| 53 | |||
| 54 | switch (channel_type) { | ||
| 55 | case NL80211_CHAN_HT40PLUS: | ||
| 56 | diff = 20; | ||
| 57 | break; | ||
| 58 | case NL80211_CHAN_HT40MINUS: | ||
| 59 | diff = -20; | ||
| 60 | break; | ||
| 61 | default: | ||
| 62 | return false; | ||
| 63 | } | ||
| 64 | |||
| 65 | sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff); | ||
| 66 | if (!sec_chan) | ||
| 67 | return false; | ||
| 68 | |||
| 69 | /* we'll need a DFS capability later */ | ||
| 70 | if (sec_chan->flags & (IEEE80211_CHAN_DISABLED | | ||
| 71 | IEEE80211_CHAN_PASSIVE_SCAN | | ||
| 72 | IEEE80211_CHAN_NO_IBSS | | ||
| 73 | IEEE80211_CHAN_RADAR)) | ||
| 74 | return false; | ||
| 75 | |||
| 76 | return true; | ||
| 77 | } | ||
| 78 | |||
| 47 | int cfg80211_set_freq(struct cfg80211_registered_device *rdev, | 79 | int cfg80211_set_freq(struct cfg80211_registered_device *rdev, |
| 48 | struct wireless_dev *wdev, int freq, | 80 | struct wireless_dev *wdev, int freq, |
| 49 | enum nl80211_channel_type channel_type) | 81 | enum nl80211_channel_type channel_type) |
| @@ -68,6 +100,28 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev, | |||
| 68 | if (!chan) | 100 | if (!chan) |
| 69 | return -EINVAL; | 101 | return -EINVAL; |
| 70 | 102 | ||
| 103 | /* Both channels should be able to initiate communication */ | ||
| 104 | if (wdev && (wdev->iftype == NL80211_IFTYPE_ADHOC || | ||
| 105 | wdev->iftype == NL80211_IFTYPE_AP || | ||
| 106 | wdev->iftype == NL80211_IFTYPE_AP_VLAN || | ||
| 107 | wdev->iftype == NL80211_IFTYPE_MESH_POINT || | ||
| 108 | wdev->iftype == NL80211_IFTYPE_P2P_GO)) { | ||
| 109 | switch (channel_type) { | ||
| 110 | case NL80211_CHAN_HT40PLUS: | ||
| 111 | case NL80211_CHAN_HT40MINUS: | ||
| 112 | if (!can_beacon_sec_chan(&rdev->wiphy, chan, | ||
| 113 | channel_type)) { | ||
| 114 | printk(KERN_DEBUG | ||
| 115 | "cfg80211: Secondary channel not " | ||
| 116 | "allowed to initiate communication\n"); | ||
| 117 | return -EINVAL; | ||
| 118 | } | ||
| 119 | break; | ||
| 120 | default: | ||
| 121 | break; | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 71 | result = rdev->ops->set_channel(&rdev->wiphy, | 125 | result = rdev->ops->set_channel(&rdev->wiphy, |
| 72 | wdev ? wdev->netdev : NULL, | 126 | wdev ? wdev->netdev : NULL, |
| 73 | chan, channel_type); | 127 | chan, channel_type); |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index c506241f8637..4e78e3f26798 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
| @@ -224,8 +224,8 @@ static int nl80211_prepare_netdev_dump(struct sk_buff *skb, | |||
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | *rdev = cfg80211_get_dev_from_ifindex(sock_net(skb->sk), ifidx); | 226 | *rdev = cfg80211_get_dev_from_ifindex(sock_net(skb->sk), ifidx); |
| 227 | if (IS_ERR(dev)) { | 227 | if (IS_ERR(*rdev)) { |
| 228 | err = PTR_ERR(dev); | 228 | err = PTR_ERR(*rdev); |
| 229 | goto out_rtnl; | 229 | goto out_rtnl; |
| 230 | } | 230 | } |
| 231 | 231 | ||
diff --git a/net/x25/x25_facilities.c b/net/x25/x25_facilities.c index 3a8c4c419cd4..55187c8f6420 100644 --- a/net/x25/x25_facilities.c +++ b/net/x25/x25_facilities.c | |||
| @@ -61,6 +61,8 @@ int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities, | |||
| 61 | while (len > 0) { | 61 | while (len > 0) { |
| 62 | switch (*p & X25_FAC_CLASS_MASK) { | 62 | switch (*p & X25_FAC_CLASS_MASK) { |
| 63 | case X25_FAC_CLASS_A: | 63 | case X25_FAC_CLASS_A: |
| 64 | if (len < 2) | ||
| 65 | return 0; | ||
| 64 | switch (*p) { | 66 | switch (*p) { |
| 65 | case X25_FAC_REVERSE: | 67 | case X25_FAC_REVERSE: |
| 66 | if((p[1] & 0x81) == 0x81) { | 68 | if((p[1] & 0x81) == 0x81) { |
| @@ -104,6 +106,8 @@ int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities, | |||
| 104 | len -= 2; | 106 | len -= 2; |
| 105 | break; | 107 | break; |
| 106 | case X25_FAC_CLASS_B: | 108 | case X25_FAC_CLASS_B: |
| 109 | if (len < 3) | ||
| 110 | return 0; | ||
| 107 | switch (*p) { | 111 | switch (*p) { |
| 108 | case X25_FAC_PACKET_SIZE: | 112 | case X25_FAC_PACKET_SIZE: |
| 109 | facilities->pacsize_in = p[1]; | 113 | facilities->pacsize_in = p[1]; |
| @@ -125,6 +129,8 @@ int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities, | |||
| 125 | len -= 3; | 129 | len -= 3; |
| 126 | break; | 130 | break; |
| 127 | case X25_FAC_CLASS_C: | 131 | case X25_FAC_CLASS_C: |
| 132 | if (len < 4) | ||
| 133 | return 0; | ||
| 128 | printk(KERN_DEBUG "X.25: unknown facility %02X, " | 134 | printk(KERN_DEBUG "X.25: unknown facility %02X, " |
| 129 | "values %02X, %02X, %02X\n", | 135 | "values %02X, %02X, %02X\n", |
| 130 | p[0], p[1], p[2], p[3]); | 136 | p[0], p[1], p[2], p[3]); |
| @@ -132,6 +138,8 @@ int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities, | |||
| 132 | len -= 4; | 138 | len -= 4; |
| 133 | break; | 139 | break; |
| 134 | case X25_FAC_CLASS_D: | 140 | case X25_FAC_CLASS_D: |
| 141 | if (len < p[1] + 2) | ||
| 142 | return 0; | ||
| 135 | switch (*p) { | 143 | switch (*p) { |
| 136 | case X25_FAC_CALLING_AE: | 144 | case X25_FAC_CALLING_AE: |
| 137 | if (p[1] > X25_MAX_DTE_FACIL_LEN || p[1] <= 1) | 145 | if (p[1] > X25_MAX_DTE_FACIL_LEN || p[1] <= 1) |
| @@ -149,9 +157,7 @@ int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities, | |||
| 149 | break; | 157 | break; |
| 150 | default: | 158 | default: |
| 151 | printk(KERN_DEBUG "X.25: unknown facility %02X," | 159 | printk(KERN_DEBUG "X.25: unknown facility %02X," |
| 152 | "length %d, values %02X, %02X, " | 160 | "length %d\n", p[0], p[1]); |
| 153 | "%02X, %02X\n", | ||
| 154 | p[0], p[1], p[2], p[3], p[4], p[5]); | ||
| 155 | break; | 161 | break; |
| 156 | } | 162 | } |
| 157 | len -= p[1] + 2; | 163 | len -= p[1] + 2; |
diff --git a/net/x25/x25_link.c b/net/x25/x25_link.c index 73e7b954ad28..b25c6463c3e9 100644 --- a/net/x25/x25_link.c +++ b/net/x25/x25_link.c | |||
| @@ -394,6 +394,7 @@ void __exit x25_link_free(void) | |||
| 394 | list_for_each_safe(entry, tmp, &x25_neigh_list) { | 394 | list_for_each_safe(entry, tmp, &x25_neigh_list) { |
| 395 | nb = list_entry(entry, struct x25_neigh, node); | 395 | nb = list_entry(entry, struct x25_neigh, node); |
| 396 | __x25_remove_neigh(nb); | 396 | __x25_remove_neigh(nb); |
| 397 | dev_put(nb->dev); | ||
| 397 | } | 398 | } |
| 398 | write_unlock_bh(&x25_neigh_list_lock); | 399 | write_unlock_bh(&x25_neigh_list_lock); |
| 399 | } | 400 | } |
diff --git a/net/xfrm/xfrm_hash.c b/net/xfrm/xfrm_hash.c index a2023ec52329..1e98bc0fe0a5 100644 --- a/net/xfrm/xfrm_hash.c +++ b/net/xfrm/xfrm_hash.c | |||
| @@ -19,7 +19,7 @@ struct hlist_head *xfrm_hash_alloc(unsigned int sz) | |||
| 19 | if (sz <= PAGE_SIZE) | 19 | if (sz <= PAGE_SIZE) |
| 20 | n = kzalloc(sz, GFP_KERNEL); | 20 | n = kzalloc(sz, GFP_KERNEL); |
| 21 | else if (hashdist) | 21 | else if (hashdist) |
| 22 | n = __vmalloc(sz, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL); | 22 | n = vzalloc(sz); |
| 23 | else | 23 | else |
| 24 | n = (struct hlist_head *) | 24 | n = (struct hlist_head *) |
| 25 | __get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, | 25 | __get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, |
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index eb96ce52f178..220ebc05c7af 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
| @@ -1268,7 +1268,7 @@ struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x, | |||
| 1268 | 1268 | ||
| 1269 | return xc; | 1269 | return xc; |
| 1270 | error: | 1270 | error: |
| 1271 | kfree(xc); | 1271 | xfrm_state_put(xc); |
| 1272 | return NULL; | 1272 | return NULL; |
| 1273 | } | 1273 | } |
| 1274 | EXPORT_SYMBOL(xfrm_state_migrate); | 1274 | EXPORT_SYMBOL(xfrm_state_migrate); |
