aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-18 14:40:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-18 14:40:21 -0400
commit667f867c93d0117dec83bc5be9018d1a3a94044d (patch)
treea2aa5900fb115ce89841cc27120ad196fbe7217c /net
parenta58a260fd96b7217b7abc49d107874206f3c55e3 (diff)
parentc0e01eac7ada785fdeaea1ae5476ec1cf3b00374 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Don't allow negative TCP reordering values, from Soheil Hassas Yeganeh. 2) Don't overflow while parsing ipv6 header options, from Craig Gallek. 3) Handle more cleanly the case where an individual route entry during a dump will not fit into the allocated netlink SKB, from David Ahern. 4) Add missing CONFIG_INET dependency for mlx5e, from Arnd Bergmann. 5) Allow neighbour updates to converge more quickly via gratuitous ARPs, from Ihar Hrachyshka. 6) Fix compile error from CONFIG_INET is disabled, from Eric Dumazet. 7) Fix use after free in x25 protocol init, from Lin Zhang. 8) Valid VLAN pvid ranges passed into br_validate(), from Tobias Jungel. 9) NULL out address lists in child sockets in SCTP, this is similar to the fix we made for inet connection sockets last week. From Eric Dumazet. 10) Fix NULL deref in mlxsw driver, from Ido Schimmel. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (27 commits) mlxsw: spectrum: Avoid possible NULL pointer dereference sh_eth: Do not print an error message for probe deferral sh_eth: Use platform device for printing before register_netdev() mlxsw: spectrum_router: Fix rif counter freeing routine mlxsw: spectrum_dpipe: Fix incorrect entry index cxgb4: update latest firmware version supported qmi_wwan: add another Lenovo EM74xx device ID sctp: do not inherit ipv6_{mc|ac|fl}_list from parent udp: make *udp*_queue_rcv_skb() functions static bridge: netlink: check vlan_default_pvid range net: ethernet: faraday: To support device tree usage. net: x25: fix one potential use-after-free issue bpf: adjust verifier heuristics ipv6: Check ip6_find_1stfragopt() return value properly. selftests/bpf: fix broken build due to types.h bnxt_en: Check status of firmware DCBX agent before setting DCB_CAP_DCBX_HOST. bnxt_en: Call bnxt_dcb_init() after getting firmware DCBX configuration. net: fix compile error in skb_orphan_partial() ipv6: Prevent overrun when parsing v6 header options neighbour: update neigh timestamps iff update is effective ...
Diffstat (limited to 'net')
-rw-r--r--net/bridge/br_netlink.c7
-rw-r--r--net/core/neighbour.c14
-rw-r--r--net/core/rtnetlink.c36
-rw-r--r--net/core/sock.c3
-rw-r--r--net/ipv4/arp.c16
-rw-r--r--net/ipv4/fib_frontend.c15
-rw-r--r--net/ipv4/fib_trie.c26
-rw-r--r--net/ipv4/ipmr.c18
-rw-r--r--net/ipv4/tcp_input.c2
-rw-r--r--net/ipv4/udp.c4
-rw-r--r--net/ipv4/udp_impl.h1
-rw-r--r--net/ipv6/ip6_offload.c7
-rw-r--r--net/ipv6/ip6_output.c5
-rw-r--r--net/ipv6/output_core.c14
-rw-r--r--net/ipv6/udp.c4
-rw-r--r--net/ipv6/udp_impl.h1
-rw-r--r--net/ipv6/udp_offload.c6
-rw-r--r--net/sctp/ipv6.c3
-rw-r--r--net/smc/Kconfig4
-rw-r--r--net/smc/smc_clc.c4
-rw-r--r--net/smc/smc_core.c16
-rw-r--r--net/smc/smc_core.h2
-rw-r--r--net/smc/smc_ib.c21
-rw-r--r--net/smc/smc_ib.h2
-rw-r--r--net/x25/af_x25.c24
-rw-r--r--net/x25/sysctl_net_x25.c5
26 files changed, 157 insertions, 103 deletions
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index c5ce7745b230..574f78824d8a 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -835,6 +835,13 @@ static int br_validate(struct nlattr *tb[], struct nlattr *data[])
835 return -EPROTONOSUPPORT; 835 return -EPROTONOSUPPORT;
836 } 836 }
837 } 837 }
838
839 if (data[IFLA_BR_VLAN_DEFAULT_PVID]) {
840 __u16 defpvid = nla_get_u16(data[IFLA_BR_VLAN_DEFAULT_PVID]);
841
842 if (defpvid >= VLAN_VID_MASK)
843 return -EINVAL;
844 }
838#endif 845#endif
839 846
840 return 0; 847 return 0;
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 58b0bcc125b5..d274f81fcc2c 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1132,10 +1132,6 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
1132 lladdr = neigh->ha; 1132 lladdr = neigh->ha;
1133 } 1133 }
1134 1134
1135 if (new & NUD_CONNECTED)
1136 neigh->confirmed = jiffies;
1137 neigh->updated = jiffies;
1138
1139 /* If entry was valid and address is not changed, 1135 /* If entry was valid and address is not changed,
1140 do not change entry state, if new one is STALE. 1136 do not change entry state, if new one is STALE.
1141 */ 1137 */
@@ -1157,6 +1153,16 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
1157 } 1153 }
1158 } 1154 }
1159 1155
1156 /* Update timestamps only once we know we will make a change to the
1157 * neighbour entry. Otherwise we risk to move the locktime window with
1158 * noop updates and ignore relevant ARP updates.
1159 */
1160 if (new != old || lladdr != neigh->ha) {
1161 if (new & NUD_CONNECTED)
1162 neigh->confirmed = jiffies;
1163 neigh->updated = jiffies;
1164 }
1165
1160 if (new != old) { 1166 if (new != old) {
1161 neigh_del_timer(neigh); 1167 neigh_del_timer(neigh);
1162 if (new & NUD_PROBE) 1168 if (new & NUD_PROBE)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index d7f82c3450b1..49a279a7cc15 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1627,13 +1627,13 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
1627 cb->nlh->nlmsg_seq, 0, 1627 cb->nlh->nlmsg_seq, 0,
1628 flags, 1628 flags,
1629 ext_filter_mask); 1629 ext_filter_mask);
1630 /* If we ran out of room on the first message,
1631 * we're in trouble
1632 */
1633 WARN_ON((err == -EMSGSIZE) && (skb->len == 0));
1634 1630
1635 if (err < 0) 1631 if (err < 0) {
1636 goto out; 1632 if (likely(skb->len))
1633 goto out;
1634
1635 goto out_err;
1636 }
1637 1637
1638 nl_dump_check_consistent(cb, nlmsg_hdr(skb)); 1638 nl_dump_check_consistent(cb, nlmsg_hdr(skb));
1639cont: 1639cont:
@@ -1641,10 +1641,12 @@ cont:
1641 } 1641 }
1642 } 1642 }
1643out: 1643out:
1644 err = skb->len;
1645out_err:
1644 cb->args[1] = idx; 1646 cb->args[1] = idx;
1645 cb->args[0] = h; 1647 cb->args[0] = h;
1646 1648
1647 return skb->len; 1649 return err;
1648} 1650}
1649 1651
1650int rtnl_nla_parse_ifla(struct nlattr **tb, const struct nlattr *head, int len, 1652int rtnl_nla_parse_ifla(struct nlattr **tb, const struct nlattr *head, int len,
@@ -3453,8 +3455,12 @@ static int rtnl_bridge_getlink(struct sk_buff *skb, struct netlink_callback *cb)
3453 err = br_dev->netdev_ops->ndo_bridge_getlink( 3455 err = br_dev->netdev_ops->ndo_bridge_getlink(
3454 skb, portid, seq, dev, 3456 skb, portid, seq, dev,
3455 filter_mask, NLM_F_MULTI); 3457 filter_mask, NLM_F_MULTI);
3456 if (err < 0 && err != -EOPNOTSUPP) 3458 if (err < 0 && err != -EOPNOTSUPP) {
3457 break; 3459 if (likely(skb->len))
3460 break;
3461
3462 goto out_err;
3463 }
3458 } 3464 }
3459 idx++; 3465 idx++;
3460 } 3466 }
@@ -3465,16 +3471,22 @@ static int rtnl_bridge_getlink(struct sk_buff *skb, struct netlink_callback *cb)
3465 seq, dev, 3471 seq, dev,
3466 filter_mask, 3472 filter_mask,
3467 NLM_F_MULTI); 3473 NLM_F_MULTI);
3468 if (err < 0 && err != -EOPNOTSUPP) 3474 if (err < 0 && err != -EOPNOTSUPP) {
3469 break; 3475 if (likely(skb->len))
3476 break;
3477
3478 goto out_err;
3479 }
3470 } 3480 }
3471 idx++; 3481 idx++;
3472 } 3482 }
3473 } 3483 }
3484 err = skb->len;
3485out_err:
3474 rcu_read_unlock(); 3486 rcu_read_unlock();
3475 cb->args[0] = idx; 3487 cb->args[0] = idx;
3476 3488
3477 return skb->len; 3489 return err;
3478} 3490}
3479 3491
3480static inline size_t bridge_nlmsg_size(void) 3492static inline size_t bridge_nlmsg_size(void)
diff --git a/net/core/sock.c b/net/core/sock.c
index e43e71d7856b..727f924b7f91 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -139,10 +139,7 @@
139 139
140#include <trace/events/sock.h> 140#include <trace/events/sock.h>
141 141
142#ifdef CONFIG_INET
143#include <net/tcp.h> 142#include <net/tcp.h>
144#endif
145
146#include <net/busy_poll.h> 143#include <net/busy_poll.h>
147 144
148static DEFINE_MUTEX(proto_list_mutex); 145static DEFINE_MUTEX(proto_list_mutex);
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 0937b34c27ca..d54345a06f72 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -653,6 +653,7 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
653 unsigned char *arp_ptr; 653 unsigned char *arp_ptr;
654 struct rtable *rt; 654 struct rtable *rt;
655 unsigned char *sha; 655 unsigned char *sha;
656 unsigned char *tha = NULL;
656 __be32 sip, tip; 657 __be32 sip, tip;
657 u16 dev_type = dev->type; 658 u16 dev_type = dev->type;
658 int addr_type; 659 int addr_type;
@@ -724,6 +725,7 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
724 break; 725 break;
725#endif 726#endif
726 default: 727 default:
728 tha = arp_ptr;
727 arp_ptr += dev->addr_len; 729 arp_ptr += dev->addr_len;
728 } 730 }
729 memcpy(&tip, arp_ptr, 4); 731 memcpy(&tip, arp_ptr, 4);
@@ -842,8 +844,18 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
842 It is possible, that this option should be enabled for some 844 It is possible, that this option should be enabled for some
843 devices (strip is candidate) 845 devices (strip is candidate)
844 */ 846 */
845 is_garp = arp->ar_op == htons(ARPOP_REQUEST) && tip == sip && 847 is_garp = tip == sip && addr_type == RTN_UNICAST;
846 addr_type == RTN_UNICAST; 848
849 /* Unsolicited ARP _replies_ also require target hwaddr to be
850 * the same as source.
851 */
852 if (is_garp && arp->ar_op == htons(ARPOP_REPLY))
853 is_garp =
854 /* IPv4 over IEEE 1394 doesn't provide target
855 * hardware address field in its ARP payload.
856 */
857 tha &&
858 !memcmp(tha, sha, dev->addr_len);
847 859
848 if (!n && 860 if (!n &&
849 ((arp->ar_op == htons(ARPOP_REPLY) && 861 ((arp->ar_op == htons(ARPOP_REPLY) &&
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 39bd1edee676..83e3ed258467 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -763,7 +763,7 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
763 unsigned int e = 0, s_e; 763 unsigned int e = 0, s_e;
764 struct fib_table *tb; 764 struct fib_table *tb;
765 struct hlist_head *head; 765 struct hlist_head *head;
766 int dumped = 0; 766 int dumped = 0, err;
767 767
768 if (nlmsg_len(cb->nlh) >= sizeof(struct rtmsg) && 768 if (nlmsg_len(cb->nlh) >= sizeof(struct rtmsg) &&
769 ((struct rtmsg *) nlmsg_data(cb->nlh))->rtm_flags & RTM_F_CLONED) 769 ((struct rtmsg *) nlmsg_data(cb->nlh))->rtm_flags & RTM_F_CLONED)
@@ -783,20 +783,27 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
783 if (dumped) 783 if (dumped)
784 memset(&cb->args[2], 0, sizeof(cb->args) - 784 memset(&cb->args[2], 0, sizeof(cb->args) -
785 2 * sizeof(cb->args[0])); 785 2 * sizeof(cb->args[0]));
786 if (fib_table_dump(tb, skb, cb) < 0) 786 err = fib_table_dump(tb, skb, cb);
787 goto out; 787 if (err < 0) {
788 if (likely(skb->len))
789 goto out;
790
791 goto out_err;
792 }
788 dumped = 1; 793 dumped = 1;
789next: 794next:
790 e++; 795 e++;
791 } 796 }
792 } 797 }
793out: 798out:
799 err = skb->len;
800out_err:
794 rcu_read_unlock(); 801 rcu_read_unlock();
795 802
796 cb->args[1] = e; 803 cb->args[1] = e;
797 cb->args[0] = h; 804 cb->args[0] = h;
798 805
799 return skb->len; 806 return err;
800} 807}
801 808
802/* Prepare and feed intra-kernel routing request. 809/* Prepare and feed intra-kernel routing request.
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 1201409ba1dc..51182ff2b441 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1983,6 +1983,8 @@ static int fn_trie_dump_leaf(struct key_vector *l, struct fib_table *tb,
1983 1983
1984 /* rcu_read_lock is hold by caller */ 1984 /* rcu_read_lock is hold by caller */
1985 hlist_for_each_entry_rcu(fa, &l->leaf, fa_list) { 1985 hlist_for_each_entry_rcu(fa, &l->leaf, fa_list) {
1986 int err;
1987
1986 if (i < s_i) { 1988 if (i < s_i) {
1987 i++; 1989 i++;
1988 continue; 1990 continue;
@@ -1993,17 +1995,14 @@ static int fn_trie_dump_leaf(struct key_vector *l, struct fib_table *tb,
1993 continue; 1995 continue;
1994 } 1996 }
1995 1997
1996 if (fib_dump_info(skb, NETLINK_CB(cb->skb).portid, 1998 err = fib_dump_info(skb, NETLINK_CB(cb->skb).portid,
1997 cb->nlh->nlmsg_seq, 1999 cb->nlh->nlmsg_seq, RTM_NEWROUTE,
1998 RTM_NEWROUTE, 2000 tb->tb_id, fa->fa_type,
1999 tb->tb_id, 2001 xkey, KEYLENGTH - fa->fa_slen,
2000 fa->fa_type, 2002 fa->fa_tos, fa->fa_info, NLM_F_MULTI);
2001 xkey, 2003 if (err < 0) {
2002 KEYLENGTH - fa->fa_slen,
2003 fa->fa_tos,
2004 fa->fa_info, NLM_F_MULTI) < 0) {
2005 cb->args[4] = i; 2004 cb->args[4] = i;
2006 return -1; 2005 return err;
2007 } 2006 }
2008 i++; 2007 i++;
2009 } 2008 }
@@ -2025,10 +2024,13 @@ int fib_table_dump(struct fib_table *tb, struct sk_buff *skb,
2025 t_key key = cb->args[3]; 2024 t_key key = cb->args[3];
2026 2025
2027 while ((l = leaf_walk_rcu(&tp, key)) != NULL) { 2026 while ((l = leaf_walk_rcu(&tp, key)) != NULL) {
2028 if (fn_trie_dump_leaf(l, tb, skb, cb) < 0) { 2027 int err;
2028
2029 err = fn_trie_dump_leaf(l, tb, skb, cb);
2030 if (err < 0) {
2029 cb->args[3] = key; 2031 cb->args[3] = key;
2030 cb->args[2] = count; 2032 cb->args[2] = count;
2031 return -1; 2033 return err;
2032 } 2034 }
2033 2035
2034 ++count; 2036 ++count;
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 3a02d52ed50e..551de4d023a8 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1980,6 +1980,20 @@ int ip_mr_input(struct sk_buff *skb)
1980 struct net *net = dev_net(skb->dev); 1980 struct net *net = dev_net(skb->dev);
1981 int local = skb_rtable(skb)->rt_flags & RTCF_LOCAL; 1981 int local = skb_rtable(skb)->rt_flags & RTCF_LOCAL;
1982 struct mr_table *mrt; 1982 struct mr_table *mrt;
1983 struct net_device *dev;
1984
1985 /* skb->dev passed in is the loX master dev for vrfs.
1986 * As there are no vifs associated with loopback devices,
1987 * get the proper interface that does have a vif associated with it.
1988 */
1989 dev = skb->dev;
1990 if (netif_is_l3_master(skb->dev)) {
1991 dev = dev_get_by_index_rcu(net, IPCB(skb)->iif);
1992 if (!dev) {
1993 kfree_skb(skb);
1994 return -ENODEV;
1995 }
1996 }
1983 1997
1984 /* Packet is looped back after forward, it should not be 1998 /* Packet is looped back after forward, it should not be
1985 * forwarded second time, but still can be delivered locally. 1999 * forwarded second time, but still can be delivered locally.
@@ -2017,7 +2031,7 @@ int ip_mr_input(struct sk_buff *skb)
2017 /* already under rcu_read_lock() */ 2031 /* already under rcu_read_lock() */
2018 cache = ipmr_cache_find(mrt, ip_hdr(skb)->saddr, ip_hdr(skb)->daddr); 2032 cache = ipmr_cache_find(mrt, ip_hdr(skb)->saddr, ip_hdr(skb)->daddr);
2019 if (!cache) { 2033 if (!cache) {
2020 int vif = ipmr_find_vif(mrt, skb->dev); 2034 int vif = ipmr_find_vif(mrt, dev);
2021 2035
2022 if (vif >= 0) 2036 if (vif >= 0)
2023 cache = ipmr_cache_find_any(mrt, ip_hdr(skb)->daddr, 2037 cache = ipmr_cache_find_any(mrt, ip_hdr(skb)->daddr,
@@ -2037,7 +2051,7 @@ int ip_mr_input(struct sk_buff *skb)
2037 } 2051 }
2038 2052
2039 read_lock(&mrt_lock); 2053 read_lock(&mrt_lock);
2040 vif = ipmr_find_vif(mrt, skb->dev); 2054 vif = ipmr_find_vif(mrt, dev);
2041 if (vif >= 0) { 2055 if (vif >= 0) {
2042 int err2 = ipmr_cache_unresolved(mrt, vif, skb); 2056 int err2 = ipmr_cache_unresolved(mrt, vif, skb);
2043 read_unlock(&mrt_lock); 2057 read_unlock(&mrt_lock);
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 06e2dbc2b4a2..174d4376baa5 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3190,7 +3190,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
3190 int delta; 3190 int delta;
3191 3191
3192 /* Non-retransmitted hole got filled? That's reordering */ 3192 /* Non-retransmitted hole got filled? That's reordering */
3193 if (reord < prior_fackets) 3193 if (reord < prior_fackets && reord <= tp->fackets_out)
3194 tcp_update_reordering(sk, tp->fackets_out - reord, 0); 3194 tcp_update_reordering(sk, tp->fackets_out - reord, 0);
3195 3195
3196 delta = tcp_is_fack(tp) ? pkts_acked : 3196 delta = tcp_is_fack(tp) ? pkts_acked :
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index ea6e4cff9faf..1d6219bf2d6b 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1612,7 +1612,7 @@ static void udp_v4_rehash(struct sock *sk)
1612 udp_lib_rehash(sk, new_hash); 1612 udp_lib_rehash(sk, new_hash);
1613} 1613}
1614 1614
1615int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) 1615static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1616{ 1616{
1617 int rc; 1617 int rc;
1618 1618
@@ -1657,7 +1657,7 @@ EXPORT_SYMBOL(udp_encap_enable);
1657 * Note that in the success and error cases, the skb is assumed to 1657 * Note that in the success and error cases, the skb is assumed to
1658 * have either been requeued or freed. 1658 * have either been requeued or freed.
1659 */ 1659 */
1660int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) 1660static int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1661{ 1661{
1662 struct udp_sock *up = udp_sk(sk); 1662 struct udp_sock *up = udp_sk(sk);
1663 int is_udplite = IS_UDPLITE(sk); 1663 int is_udplite = IS_UDPLITE(sk);
diff --git a/net/ipv4/udp_impl.h b/net/ipv4/udp_impl.h
index feb50a16398d..a8cf8c6fb60c 100644
--- a/net/ipv4/udp_impl.h
+++ b/net/ipv4/udp_impl.h
@@ -25,7 +25,6 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
25 int flags, int *addr_len); 25 int flags, int *addr_len);
26int udp_sendpage(struct sock *sk, struct page *page, int offset, size_t size, 26int udp_sendpage(struct sock *sk, struct page *page, int offset, size_t size,
27 int flags); 27 int flags);
28int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
29void udp_destroy_sock(struct sock *sk); 28void udp_destroy_sock(struct sock *sk);
30 29
31#ifdef CONFIG_PROC_FS 30#ifdef CONFIG_PROC_FS
diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
index 93e58a5e1837..280268f1dd7b 100644
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -63,7 +63,6 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
63 const struct net_offload *ops; 63 const struct net_offload *ops;
64 int proto; 64 int proto;
65 struct frag_hdr *fptr; 65 struct frag_hdr *fptr;
66 unsigned int unfrag_ip6hlen;
67 unsigned int payload_len; 66 unsigned int payload_len;
68 u8 *prevhdr; 67 u8 *prevhdr;
69 int offset = 0; 68 int offset = 0;
@@ -116,8 +115,10 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
116 skb->network_header = (u8 *)ipv6h - skb->head; 115 skb->network_header = (u8 *)ipv6h - skb->head;
117 116
118 if (udpfrag) { 117 if (udpfrag) {
119 unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr); 118 int err = ip6_find_1stfragopt(skb, &prevhdr);
120 fptr = (struct frag_hdr *)((u8 *)ipv6h + unfrag_ip6hlen); 119 if (err < 0)
120 return ERR_PTR(err);
121 fptr = (struct frag_hdr *)((u8 *)ipv6h + err);
121 fptr->frag_off = htons(offset); 122 fptr->frag_off = htons(offset);
122 if (skb->next) 123 if (skb->next)
123 fptr->frag_off |= htons(IP6_MF); 124 fptr->frag_off |= htons(IP6_MF);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 58f6288e9ba5..d4a31becbd25 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -597,7 +597,10 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
597 int ptr, offset = 0, err = 0; 597 int ptr, offset = 0, err = 0;
598 u8 *prevhdr, nexthdr = 0; 598 u8 *prevhdr, nexthdr = 0;
599 599
600 hlen = ip6_find_1stfragopt(skb, &prevhdr); 600 err = ip6_find_1stfragopt(skb, &prevhdr);
601 if (err < 0)
602 goto fail;
603 hlen = err;
601 nexthdr = *prevhdr; 604 nexthdr = *prevhdr;
602 605
603 mtu = ip6_skb_dst_mtu(skb); 606 mtu = ip6_skb_dst_mtu(skb);
diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
index cd4252346a32..e9065b8d3af8 100644
--- a/net/ipv6/output_core.c
+++ b/net/ipv6/output_core.c
@@ -79,14 +79,13 @@ EXPORT_SYMBOL(ipv6_select_ident);
79int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) 79int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
80{ 80{
81 u16 offset = sizeof(struct ipv6hdr); 81 u16 offset = sizeof(struct ipv6hdr);
82 struct ipv6_opt_hdr *exthdr =
83 (struct ipv6_opt_hdr *)(ipv6_hdr(skb) + 1);
84 unsigned int packet_len = skb_tail_pointer(skb) - 82 unsigned int packet_len = skb_tail_pointer(skb) -
85 skb_network_header(skb); 83 skb_network_header(skb);
86 int found_rhdr = 0; 84 int found_rhdr = 0;
87 *nexthdr = &ipv6_hdr(skb)->nexthdr; 85 *nexthdr = &ipv6_hdr(skb)->nexthdr;
88 86
89 while (offset + 1 <= packet_len) { 87 while (offset <= packet_len) {
88 struct ipv6_opt_hdr *exthdr;
90 89
91 switch (**nexthdr) { 90 switch (**nexthdr) {
92 91
@@ -107,13 +106,16 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
107 return offset; 106 return offset;
108 } 107 }
109 108
110 offset += ipv6_optlen(exthdr); 109 if (offset + sizeof(struct ipv6_opt_hdr) > packet_len)
111 *nexthdr = &exthdr->nexthdr; 110 return -EINVAL;
111
112 exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) + 112 exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) +
113 offset); 113 offset);
114 offset += ipv6_optlen(exthdr);
115 *nexthdr = &exthdr->nexthdr;
114 } 116 }
115 117
116 return offset; 118 return -EINVAL;
117} 119}
118EXPORT_SYMBOL(ip6_find_1stfragopt); 120EXPORT_SYMBOL(ip6_find_1stfragopt);
119 121
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 04862abfe4ec..06ec39b79609 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -526,7 +526,7 @@ out:
526 return; 526 return;
527} 527}
528 528
529int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) 529static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
530{ 530{
531 int rc; 531 int rc;
532 532
@@ -569,7 +569,7 @@ void udpv6_encap_enable(void)
569} 569}
570EXPORT_SYMBOL(udpv6_encap_enable); 570EXPORT_SYMBOL(udpv6_encap_enable);
571 571
572int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) 572static int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
573{ 573{
574 struct udp_sock *up = udp_sk(sk); 574 struct udp_sock *up = udp_sk(sk);
575 int is_udplite = IS_UDPLITE(sk); 575 int is_udplite = IS_UDPLITE(sk);
diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h
index e78bdc76dcc3..f180b3d85e31 100644
--- a/net/ipv6/udp_impl.h
+++ b/net/ipv6/udp_impl.h
@@ -26,7 +26,6 @@ int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
26int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len); 26int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len);
27int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, 27int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
28 int flags, int *addr_len); 28 int flags, int *addr_len);
29int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
30void udpv6_destroy_sock(struct sock *sk); 29void udpv6_destroy_sock(struct sock *sk);
31 30
32#ifdef CONFIG_PROC_FS 31#ifdef CONFIG_PROC_FS
diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
index ac858c480f2f..a2267f80febb 100644
--- a/net/ipv6/udp_offload.c
+++ b/net/ipv6/udp_offload.c
@@ -29,6 +29,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
29 u8 frag_hdr_sz = sizeof(struct frag_hdr); 29 u8 frag_hdr_sz = sizeof(struct frag_hdr);
30 __wsum csum; 30 __wsum csum;
31 int tnl_hlen; 31 int tnl_hlen;
32 int err;
32 33
33 mss = skb_shinfo(skb)->gso_size; 34 mss = skb_shinfo(skb)->gso_size;
34 if (unlikely(skb->len <= mss)) 35 if (unlikely(skb->len <= mss))
@@ -90,7 +91,10 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
90 /* Find the unfragmentable header and shift it left by frag_hdr_sz 91 /* Find the unfragmentable header and shift it left by frag_hdr_sz
91 * bytes to insert fragment header. 92 * bytes to insert fragment header.
92 */ 93 */
93 unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr); 94 err = ip6_find_1stfragopt(skb, &prevhdr);
95 if (err < 0)
96 return ERR_PTR(err);
97 unfrag_ip6hlen = err;
94 nexthdr = *prevhdr; 98 nexthdr = *prevhdr;
95 *prevhdr = NEXTHDR_FRAGMENT; 99 *prevhdr = NEXTHDR_FRAGMENT;
96 unfrag_len = (skb_network_header(skb) - skb_mac_header(skb)) + 100 unfrag_len = (skb_network_header(skb) - skb_mac_header(skb)) +
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 142b70e959af..f5b45b8b8b16 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -677,6 +677,9 @@ static struct sock *sctp_v6_create_accept_sk(struct sock *sk,
677 newnp = inet6_sk(newsk); 677 newnp = inet6_sk(newsk);
678 678
679 memcpy(newnp, np, sizeof(struct ipv6_pinfo)); 679 memcpy(newnp, np, sizeof(struct ipv6_pinfo));
680 newnp->ipv6_mc_list = NULL;
681 newnp->ipv6_ac_list = NULL;
682 newnp->ipv6_fl_list = NULL;
680 683
681 rcu_read_lock(); 684 rcu_read_lock();
682 opt = rcu_dereference(np->opt); 685 opt = rcu_dereference(np->opt);
diff --git a/net/smc/Kconfig b/net/smc/Kconfig
index c717ef0896aa..33954852f3f8 100644
--- a/net/smc/Kconfig
+++ b/net/smc/Kconfig
@@ -8,6 +8,10 @@ config SMC
8 The Linux implementation of the SMC-R solution is designed as 8 The Linux implementation of the SMC-R solution is designed as
9 a separate socket family SMC. 9 a separate socket family SMC.
10 10
11 Warning: SMC will expose all memory for remote reads and writes
12 once a connection is established. Don't enable this option except
13 for tightly controlled lab environment.
14
11 Select this option if you want to run SMC socket applications 15 Select this option if you want to run SMC socket applications
12 16
13config SMC_DIAG 17config SMC_DIAG
diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
index e41f594a1e1d..03ec058d18df 100644
--- a/net/smc/smc_clc.c
+++ b/net/smc/smc_clc.c
@@ -204,7 +204,7 @@ int smc_clc_send_confirm(struct smc_sock *smc)
204 memcpy(&cclc.lcl.mac, &link->smcibdev->mac[link->ibport - 1], ETH_ALEN); 204 memcpy(&cclc.lcl.mac, &link->smcibdev->mac[link->ibport - 1], ETH_ALEN);
205 hton24(cclc.qpn, link->roce_qp->qp_num); 205 hton24(cclc.qpn, link->roce_qp->qp_num);
206 cclc.rmb_rkey = 206 cclc.rmb_rkey =
207 htonl(conn->rmb_desc->mr_rx[SMC_SINGLE_LINK]->rkey); 207 htonl(conn->rmb_desc->rkey[SMC_SINGLE_LINK]);
208 cclc.conn_idx = 1; /* for now: 1 RMB = 1 RMBE */ 208 cclc.conn_idx = 1; /* for now: 1 RMB = 1 RMBE */
209 cclc.rmbe_alert_token = htonl(conn->alert_token_local); 209 cclc.rmbe_alert_token = htonl(conn->alert_token_local);
210 cclc.qp_mtu = min(link->path_mtu, link->peer_mtu); 210 cclc.qp_mtu = min(link->path_mtu, link->peer_mtu);
@@ -256,7 +256,7 @@ int smc_clc_send_accept(struct smc_sock *new_smc, int srv_first_contact)
256 memcpy(&aclc.lcl.mac, link->smcibdev->mac[link->ibport - 1], ETH_ALEN); 256 memcpy(&aclc.lcl.mac, link->smcibdev->mac[link->ibport - 1], ETH_ALEN);
257 hton24(aclc.qpn, link->roce_qp->qp_num); 257 hton24(aclc.qpn, link->roce_qp->qp_num);
258 aclc.rmb_rkey = 258 aclc.rmb_rkey =
259 htonl(conn->rmb_desc->mr_rx[SMC_SINGLE_LINK]->rkey); 259 htonl(conn->rmb_desc->rkey[SMC_SINGLE_LINK]);
260 aclc.conn_idx = 1; /* as long as 1 RMB = 1 RMBE */ 260 aclc.conn_idx = 1; /* as long as 1 RMB = 1 RMBE */
261 aclc.rmbe_alert_token = htonl(conn->alert_token_local); 261 aclc.rmbe_alert_token = htonl(conn->alert_token_local);
262 aclc.qp_mtu = link->path_mtu; 262 aclc.qp_mtu = link->path_mtu;
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index 65020e93ff21..3ac09a629ea1 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -613,19 +613,8 @@ int smc_rmb_create(struct smc_sock *smc)
613 rmb_desc = NULL; 613 rmb_desc = NULL;
614 continue; /* if mapping failed, try smaller one */ 614 continue; /* if mapping failed, try smaller one */
615 } 615 }
616 rc = smc_ib_get_memory_region(lgr->lnk[SMC_SINGLE_LINK].roce_pd, 616 rmb_desc->rkey[SMC_SINGLE_LINK] =
617 IB_ACCESS_REMOTE_WRITE | 617 lgr->lnk[SMC_SINGLE_LINK].roce_pd->unsafe_global_rkey;
618 IB_ACCESS_LOCAL_WRITE,
619 &rmb_desc->mr_rx[SMC_SINGLE_LINK]);
620 if (rc) {
621 smc_ib_buf_unmap(lgr->lnk[SMC_SINGLE_LINK].smcibdev,
622 tmp_bufsize, rmb_desc,
623 DMA_FROM_DEVICE);
624 kfree(rmb_desc->cpu_addr);
625 kfree(rmb_desc);
626 rmb_desc = NULL;
627 continue;
628 }
629 rmb_desc->used = 1; 618 rmb_desc->used = 1;
630 write_lock_bh(&lgr->rmbs_lock); 619 write_lock_bh(&lgr->rmbs_lock);
631 list_add(&rmb_desc->list, 620 list_add(&rmb_desc->list,
@@ -668,6 +657,7 @@ int smc_rmb_rtoken_handling(struct smc_connection *conn,
668 657
669 for (i = 0; i < SMC_RMBS_PER_LGR_MAX; i++) { 658 for (i = 0; i < SMC_RMBS_PER_LGR_MAX; i++) {
670 if ((lgr->rtokens[i][SMC_SINGLE_LINK].rkey == rkey) && 659 if ((lgr->rtokens[i][SMC_SINGLE_LINK].rkey == rkey) &&
660 (lgr->rtokens[i][SMC_SINGLE_LINK].dma_addr == dma_addr) &&
671 test_bit(i, lgr->rtokens_used_mask)) { 661 test_bit(i, lgr->rtokens_used_mask)) {
672 conn->rtoken_idx = i; 662 conn->rtoken_idx = i;
673 return 0; 663 return 0;
diff --git a/net/smc/smc_core.h b/net/smc/smc_core.h
index 27eb38056a27..b013cb43a327 100644
--- a/net/smc/smc_core.h
+++ b/net/smc/smc_core.h
@@ -93,7 +93,7 @@ struct smc_buf_desc {
93 u64 dma_addr[SMC_LINKS_PER_LGR_MAX]; 93 u64 dma_addr[SMC_LINKS_PER_LGR_MAX];
94 /* mapped address of buffer */ 94 /* mapped address of buffer */
95 void *cpu_addr; /* virtual address of buffer */ 95 void *cpu_addr; /* virtual address of buffer */
96 struct ib_mr *mr_rx[SMC_LINKS_PER_LGR_MAX]; 96 u32 rkey[SMC_LINKS_PER_LGR_MAX];
97 /* for rmb only: 97 /* for rmb only:
98 * rkey provided to peer 98 * rkey provided to peer
99 */ 99 */
diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c
index cb69ab977cd7..b31715505a35 100644
--- a/net/smc/smc_ib.c
+++ b/net/smc/smc_ib.c
@@ -37,24 +37,6 @@ u8 local_systemid[SMC_SYSTEMID_LEN] = SMC_LOCAL_SYSTEMID_RESET; /* unique system
37 * identifier 37 * identifier
38 */ 38 */
39 39
40int smc_ib_get_memory_region(struct ib_pd *pd, int access_flags,
41 struct ib_mr **mr)
42{
43 int rc;
44
45 if (*mr)
46 return 0; /* already done */
47
48 /* obtain unique key -
49 * next invocation of get_dma_mr returns a different key!
50 */
51 *mr = pd->device->get_dma_mr(pd, access_flags);
52 rc = PTR_ERR_OR_ZERO(*mr);
53 if (IS_ERR(*mr))
54 *mr = NULL;
55 return rc;
56}
57
58static int smc_ib_modify_qp_init(struct smc_link *lnk) 40static int smc_ib_modify_qp_init(struct smc_link *lnk)
59{ 41{
60 struct ib_qp_attr qp_attr; 42 struct ib_qp_attr qp_attr;
@@ -210,7 +192,8 @@ int smc_ib_create_protection_domain(struct smc_link *lnk)
210{ 192{
211 int rc; 193 int rc;
212 194
213 lnk->roce_pd = ib_alloc_pd(lnk->smcibdev->ibdev, 0); 195 lnk->roce_pd = ib_alloc_pd(lnk->smcibdev->ibdev,
196 IB_PD_UNSAFE_GLOBAL_RKEY);
214 rc = PTR_ERR_OR_ZERO(lnk->roce_pd); 197 rc = PTR_ERR_OR_ZERO(lnk->roce_pd);
215 if (IS_ERR(lnk->roce_pd)) 198 if (IS_ERR(lnk->roce_pd))
216 lnk->roce_pd = NULL; 199 lnk->roce_pd = NULL;
diff --git a/net/smc/smc_ib.h b/net/smc/smc_ib.h
index 7e1f0e24d177..b567152a526d 100644
--- a/net/smc/smc_ib.h
+++ b/net/smc/smc_ib.h
@@ -61,8 +61,6 @@ void smc_ib_dealloc_protection_domain(struct smc_link *lnk);
61int smc_ib_create_protection_domain(struct smc_link *lnk); 61int smc_ib_create_protection_domain(struct smc_link *lnk);
62void smc_ib_destroy_queue_pair(struct smc_link *lnk); 62void smc_ib_destroy_queue_pair(struct smc_link *lnk);
63int smc_ib_create_queue_pair(struct smc_link *lnk); 63int smc_ib_create_queue_pair(struct smc_link *lnk);
64int smc_ib_get_memory_region(struct ib_pd *pd, int access_flags,
65 struct ib_mr **mr);
66int smc_ib_ready_link(struct smc_link *lnk); 64int smc_ib_ready_link(struct smc_link *lnk);
67int smc_ib_modify_qp_rts(struct smc_link *lnk); 65int smc_ib_modify_qp_rts(struct smc_link *lnk);
68int smc_ib_modify_qp_reset(struct smc_link *lnk); 66int smc_ib_modify_qp_reset(struct smc_link *lnk);
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 8b911c29860e..5a1a98df3499 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -1791,32 +1791,40 @@ void x25_kill_by_neigh(struct x25_neigh *nb)
1791 1791
1792static int __init x25_init(void) 1792static int __init x25_init(void)
1793{ 1793{
1794 int rc = proto_register(&x25_proto, 0); 1794 int rc;
1795 1795
1796 if (rc != 0) 1796 rc = proto_register(&x25_proto, 0);
1797 if (rc)
1797 goto out; 1798 goto out;
1798 1799
1799 rc = sock_register(&x25_family_ops); 1800 rc = sock_register(&x25_family_ops);
1800 if (rc != 0) 1801 if (rc)
1801 goto out_proto; 1802 goto out_proto;
1802 1803
1803 dev_add_pack(&x25_packet_type); 1804 dev_add_pack(&x25_packet_type);
1804 1805
1805 rc = register_netdevice_notifier(&x25_dev_notifier); 1806 rc = register_netdevice_notifier(&x25_dev_notifier);
1806 if (rc != 0) 1807 if (rc)
1807 goto out_sock; 1808 goto out_sock;
1808 1809
1809 pr_info("Linux Version 0.2\n"); 1810 rc = x25_register_sysctl();
1811 if (rc)
1812 goto out_dev;
1810 1813
1811 x25_register_sysctl();
1812 rc = x25_proc_init(); 1814 rc = x25_proc_init();
1813 if (rc != 0) 1815 if (rc)
1814 goto out_dev; 1816 goto out_sysctl;
1817
1818 pr_info("Linux Version 0.2\n");
1819
1815out: 1820out:
1816 return rc; 1821 return rc;
1822out_sysctl:
1823 x25_unregister_sysctl();
1817out_dev: 1824out_dev:
1818 unregister_netdevice_notifier(&x25_dev_notifier); 1825 unregister_netdevice_notifier(&x25_dev_notifier);
1819out_sock: 1826out_sock:
1827 dev_remove_pack(&x25_packet_type);
1820 sock_unregister(AF_X25); 1828 sock_unregister(AF_X25);
1821out_proto: 1829out_proto:
1822 proto_unregister(&x25_proto); 1830 proto_unregister(&x25_proto);
diff --git a/net/x25/sysctl_net_x25.c b/net/x25/sysctl_net_x25.c
index a06dfe143c67..ba078c85f0a1 100644
--- a/net/x25/sysctl_net_x25.c
+++ b/net/x25/sysctl_net_x25.c
@@ -73,9 +73,12 @@ static struct ctl_table x25_table[] = {
73 { }, 73 { },
74}; 74};
75 75
76void __init x25_register_sysctl(void) 76int __init x25_register_sysctl(void)
77{ 77{
78 x25_table_header = register_net_sysctl(&init_net, "net/x25", x25_table); 78 x25_table_header = register_net_sysctl(&init_net, "net/x25", x25_table);
79 if (!x25_table_header)
80 return -ENOMEM;
81 return 0;
79} 82}
80 83
81void x25_unregister_sysctl(void) 84void x25_unregister_sysctl(void)