summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-02-01 18:56:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-02-01 18:56:08 -0500
commit34229b277480f46c1e9a19f027f30b074512e68b (patch)
tree90d8b43ebceb850b0e7852d75283aebbd2abbc00 /net
parent2c923414d3963b959f65a8a6031972402e6a34a5 (diff)
parent53729eb174c1589f9185340ffe8c10b3f39f3ef3 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: "This looks like a lot but it's a mixture of regression fixes as well as fixes for longer standing issues. 1) Fix on-channel cancellation in mac80211, from Johannes Berg. 2) Handle CHECKSUM_COMPLETE properly in xt_TCPMSS netfilter xtables module, from Eric Dumazet. 3) Avoid infinite loop in UDP SO_REUSEPORT logic, also from Eric Dumazet. 4) Avoid a NULL deref if we try to set SO_REUSEPORT after a socket is bound, from Craig Gallek. 5) GRO key comparisons don't take lightweight tunnels into account, from Jesse Gross. 6) Fix struct pid leak via SCM credentials in AF_UNIX, from Eric Dumazet. 7) We need to set the rtnl_link_ops of ipv6 SIT tunnels before we register them, otherwise the NEWLINK netlink message is missing the proper attributes. From Thadeu Lima de Souza Cascardo. 8) Several Spectrum chip bug fixes for mlxsw switch driver, from Ido Schimmel 9) Handle fragments properly in ipv4 easly socket demux, from Eric Dumazet. 10) Don't ignore the ifindex key specifier on ipv6 output route lookups, from Paolo Abeni" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (128 commits) tcp: avoid cwnd undo after receiving ECN irda: fix a potential use-after-free in ircomm_param_request net: tg3: avoid uninitialized variable warning net: nb8800: avoid uninitialized variable warning net: vxge: avoid unused function warnings net: bgmac: clarify CONFIG_BCMA dependency net: hp100: remove unnecessary #ifdefs net: davinci_cpdma: use dma_addr_t for DMA address ipv6/udp: use sticky pktinfo egress ifindex on connect() ipv6: enforce flowi6_oif usage in ip6_dst_lookup_tail() netlink: not trim skb for mmaped socket when dump vxlan: fix a out of bounds access in __vxlan_find_mac net: dsa: mv88e6xxx: fix port VLAN maps fib_trie: Fix shift by 32 in fib_table_lookup net: moxart: use correct accessors for DMA memory ipv4: ipconfig: avoid unused ic_proto_used symbol bnxt_en: Fix crash in bnxt_free_tx_skbs() during tx timeout. bnxt_en: Exclude rx_drop_pkts hw counter from the stack's rx_dropped counter. bnxt_en: Ring free response from close path should use completion ring net_sched: drr: check for NULL pointer in drr_dequeue ...
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/6lowpan.c7
-rw-r--r--net/bluetooth/hci_request.c28
-rw-r--r--net/bluetooth/l2cap_core.c14
-rw-r--r--net/bluetooth/l2cap_sock.c12
-rw-r--r--net/bluetooth/smp.c16
-rw-r--r--net/bridge/br.c3
-rw-r--r--net/core/dev.c7
-rw-r--r--net/core/sock_reuseport.c9
-rw-r--r--net/ipv4/Kconfig1
-rw-r--r--net/ipv4/fib_trie.c7
-rw-r--r--net/ipv4/inet_diag.c21
-rw-r--r--net/ipv4/ip_fragment.c1
-rw-r--r--net/ipv4/ip_input.c5
-rw-r--r--net/ipv4/ipconfig.c4
-rw-r--r--net/ipv4/netfilter/nf_defrag_ipv4.c2
-rw-r--r--net/ipv4/tcp.c12
-rw-r--r--net/ipv4/tcp_input.c12
-rw-r--r--net/ipv4/tcp_ipv4.c13
-rw-r--r--net/ipv4/udp.c32
-rw-r--r--net/ipv6/Kconfig1
-rw-r--r--net/ipv6/datagram.c3
-rw-r--r--net/ipv6/ip6_output.c6
-rw-r--r--net/ipv6/route.c7
-rw-r--r--net/ipv6/sit.c4
-rw-r--r--net/ipv6/udp.c32
-rw-r--r--net/irda/ircomm/ircomm_param.c3
-rw-r--r--net/iucv/af_iucv.c3
-rw-r--r--net/mac80211/ibss.c1
-rw-r--r--net/mac80211/main.c6
-rw-r--r--net/mac80211/mesh.c11
-rw-r--r--net/mac80211/mesh.h4
-rw-r--r--net/mac80211/mlme.c2
-rw-r--r--net/mac80211/offchannel.c16
-rw-r--r--net/mac80211/scan.c20
-rw-r--r--net/mac80211/sta_info.c2
-rw-r--r--net/mac80211/status.c5
-rw-r--r--net/mac80211/util.c16
-rw-r--r--net/netfilter/ipset/ip_set_hash_netiface.c4
-rw-r--r--net/netfilter/nf_conntrack_core.c38
-rw-r--r--net/netfilter/nf_conntrack_helper.c2
-rw-r--r--net/netfilter/nf_conntrack_netlink.c2
-rw-r--r--net/netfilter/nf_tables_netdev.c8
-rw-r--r--net/netfilter/nfnetlink_cttimeout.c4
-rw-r--r--net/netfilter/nft_byteorder.c6
-rw-r--r--net/netfilter/nft_ct.c2
-rw-r--r--net/netfilter/xt_TCPMSS.c9
-rw-r--r--net/netlink/af_netlink.c3
-rw-r--r--net/rfkill/core.c16
-rw-r--r--net/sched/sch_drr.c2
-rw-r--r--net/sctp/input.c17
-rw-r--r--net/sctp/proc.c12
-rw-r--r--net/sctp/sm_sideeffect.c12
-rw-r--r--net/sctp/socket.c2
-rw-r--r--net/sctp/transport.c8
-rw-r--r--net/switchdev/switchdev.c15
-rw-r--r--net/tipc/subscr.c11
-rw-r--r--net/unix/af_unix.c1
-rw-r--r--net/wireless/reg.c45
58 files changed, 335 insertions, 232 deletions
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index d040365ba98e..8a4cc2f7f0db 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -307,6 +307,9 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
307 307
308 /* check that it's our buffer */ 308 /* check that it's our buffer */
309 if (lowpan_is_ipv6(*skb_network_header(skb))) { 309 if (lowpan_is_ipv6(*skb_network_header(skb))) {
310 /* Pull off the 1-byte of 6lowpan header. */
311 skb_pull(skb, 1);
312
310 /* Copy the packet so that the IPv6 header is 313 /* Copy the packet so that the IPv6 header is
311 * properly aligned. 314 * properly aligned.
312 */ 315 */
@@ -317,6 +320,7 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
317 320
318 local_skb->protocol = htons(ETH_P_IPV6); 321 local_skb->protocol = htons(ETH_P_IPV6);
319 local_skb->pkt_type = PACKET_HOST; 322 local_skb->pkt_type = PACKET_HOST;
323 local_skb->dev = dev;
320 324
321 skb_set_transport_header(local_skb, sizeof(struct ipv6hdr)); 325 skb_set_transport_header(local_skb, sizeof(struct ipv6hdr));
322 326
@@ -335,6 +339,8 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
335 if (!local_skb) 339 if (!local_skb)
336 goto drop; 340 goto drop;
337 341
342 local_skb->dev = dev;
343
338 ret = iphc_decompress(local_skb, dev, chan); 344 ret = iphc_decompress(local_skb, dev, chan);
339 if (ret < 0) { 345 if (ret < 0) {
340 kfree_skb(local_skb); 346 kfree_skb(local_skb);
@@ -343,7 +349,6 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
343 349
344 local_skb->protocol = htons(ETH_P_IPV6); 350 local_skb->protocol = htons(ETH_P_IPV6);
345 local_skb->pkt_type = PACKET_HOST; 351 local_skb->pkt_type = PACKET_HOST;
346 local_skb->dev = dev;
347 352
348 if (give_skb_to_upper(local_skb, dev) 353 if (give_skb_to_upper(local_skb, dev)
349 != NET_RX_SUCCESS) { 354 != NET_RX_SUCCESS) {
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 41b5f3813f02..c78ee2dc9323 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -688,21 +688,29 @@ static u8 update_white_list(struct hci_request *req)
688 * command to remove it from the controller. 688 * command to remove it from the controller.
689 */ 689 */
690 list_for_each_entry(b, &hdev->le_white_list, list) { 690 list_for_each_entry(b, &hdev->le_white_list, list) {
691 struct hci_cp_le_del_from_white_list cp; 691 /* If the device is neither in pend_le_conns nor
692 * pend_le_reports then remove it from the whitelist.
693 */
694 if (!hci_pend_le_action_lookup(&hdev->pend_le_conns,
695 &b->bdaddr, b->bdaddr_type) &&
696 !hci_pend_le_action_lookup(&hdev->pend_le_reports,
697 &b->bdaddr, b->bdaddr_type)) {
698 struct hci_cp_le_del_from_white_list cp;
699
700 cp.bdaddr_type = b->bdaddr_type;
701 bacpy(&cp.bdaddr, &b->bdaddr);
692 702
693 if (hci_pend_le_action_lookup(&hdev->pend_le_conns, 703 hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST,
694 &b->bdaddr, b->bdaddr_type) || 704 sizeof(cp), &cp);
695 hci_pend_le_action_lookup(&hdev->pend_le_reports,
696 &b->bdaddr, b->bdaddr_type)) {
697 white_list_entries++;
698 continue; 705 continue;
699 } 706 }
700 707
701 cp.bdaddr_type = b->bdaddr_type; 708 if (hci_find_irk_by_addr(hdev, &b->bdaddr, b->bdaddr_type)) {
702 bacpy(&cp.bdaddr, &b->bdaddr); 709 /* White list can not be used with RPAs */
710 return 0x00;
711 }
703 712
704 hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST, 713 white_list_entries++;
705 sizeof(cp), &cp);
706 } 714 }
707 715
708 /* Since all no longer valid white list entries have been 716 /* Since all no longer valid white list entries have been
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 39a5149f3010..eb4f5f24cbe3 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -197,10 +197,20 @@ int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm)
197 chan->sport = psm; 197 chan->sport = psm;
198 err = 0; 198 err = 0;
199 } else { 199 } else {
200 u16 p; 200 u16 p, start, end, incr;
201
202 if (chan->src_type == BDADDR_BREDR) {
203 start = L2CAP_PSM_DYN_START;
204 end = L2CAP_PSM_AUTO_END;
205 incr = 2;
206 } else {
207 start = L2CAP_PSM_LE_DYN_START;
208 end = L2CAP_PSM_LE_DYN_END;
209 incr = 1;
210 }
201 211
202 err = -EINVAL; 212 err = -EINVAL;
203 for (p = 0x1001; p < 0x1100; p += 2) 213 for (p = start; p <= end; p += incr)
204 if (!__l2cap_global_chan_by_addr(cpu_to_le16(p), src)) { 214 if (!__l2cap_global_chan_by_addr(cpu_to_le16(p), src)) {
205 chan->psm = cpu_to_le16(p); 215 chan->psm = cpu_to_le16(p);
206 chan->sport = cpu_to_le16(p); 216 chan->sport = cpu_to_le16(p);
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 1bb551527044..e4cae72895a7 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -58,7 +58,7 @@ static int l2cap_validate_bredr_psm(u16 psm)
58 return -EINVAL; 58 return -EINVAL;
59 59
60 /* Restrict usage of well-known PSMs */ 60 /* Restrict usage of well-known PSMs */
61 if (psm < 0x1001 && !capable(CAP_NET_BIND_SERVICE)) 61 if (psm < L2CAP_PSM_DYN_START && !capable(CAP_NET_BIND_SERVICE))
62 return -EACCES; 62 return -EACCES;
63 63
64 return 0; 64 return 0;
@@ -67,11 +67,11 @@ static int l2cap_validate_bredr_psm(u16 psm)
67static int l2cap_validate_le_psm(u16 psm) 67static int l2cap_validate_le_psm(u16 psm)
68{ 68{
69 /* Valid LE_PSM ranges are defined only until 0x00ff */ 69 /* Valid LE_PSM ranges are defined only until 0x00ff */
70 if (psm > 0x00ff) 70 if (psm > L2CAP_PSM_LE_DYN_END)
71 return -EINVAL; 71 return -EINVAL;
72 72
73 /* Restrict fixed, SIG assigned PSM values to CAP_NET_BIND_SERVICE */ 73 /* Restrict fixed, SIG assigned PSM values to CAP_NET_BIND_SERVICE */
74 if (psm <= 0x007f && !capable(CAP_NET_BIND_SERVICE)) 74 if (psm < L2CAP_PSM_LE_DYN_START && !capable(CAP_NET_BIND_SERVICE))
75 return -EACCES; 75 return -EACCES;
76 76
77 return 0; 77 return 0;
@@ -125,6 +125,9 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
125 goto done; 125 goto done;
126 } 126 }
127 127
128 bacpy(&chan->src, &la.l2_bdaddr);
129 chan->src_type = la.l2_bdaddr_type;
130
128 if (la.l2_cid) 131 if (la.l2_cid)
129 err = l2cap_add_scid(chan, __le16_to_cpu(la.l2_cid)); 132 err = l2cap_add_scid(chan, __le16_to_cpu(la.l2_cid));
130 else 133 else
@@ -156,9 +159,6 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
156 break; 159 break;
157 } 160 }
158 161
159 bacpy(&chan->src, &la.l2_bdaddr);
160 chan->src_type = la.l2_bdaddr_type;
161
162 if (chan->psm && bdaddr_type_is_le(chan->src_type)) 162 if (chan->psm && bdaddr_type_is_le(chan->src_type))
163 chan->mode = L2CAP_MODE_LE_FLOWCTL; 163 chan->mode = L2CAP_MODE_LE_FLOWCTL;
164 164
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index ffed8a1d4f27..4b175df35184 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -1072,22 +1072,6 @@ static void smp_notify_keys(struct l2cap_conn *conn)
1072 hcon->dst_type = smp->remote_irk->addr_type; 1072 hcon->dst_type = smp->remote_irk->addr_type;
1073 queue_work(hdev->workqueue, &conn->id_addr_update_work); 1073 queue_work(hdev->workqueue, &conn->id_addr_update_work);
1074 } 1074 }
1075
1076 /* When receiving an indentity resolving key for
1077 * a remote device that does not use a resolvable
1078 * private address, just remove the key so that
1079 * it is possible to use the controller white
1080 * list for scanning.
1081 *
1082 * Userspace will have been told to not store
1083 * this key at this point. So it is safe to
1084 * just remove it.
1085 */
1086 if (!bacmp(&smp->remote_irk->rpa, BDADDR_ANY)) {
1087 list_del_rcu(&smp->remote_irk->list);
1088 kfree_rcu(smp->remote_irk, rcu);
1089 smp->remote_irk = NULL;
1090 }
1091 } 1075 }
1092 1076
1093 if (smp->csrk) { 1077 if (smp->csrk) {
diff --git a/net/bridge/br.c b/net/bridge/br.c
index a1abe4936fe1..3addc05b9a16 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -121,6 +121,7 @@ static struct notifier_block br_device_notifier = {
121 .notifier_call = br_device_event 121 .notifier_call = br_device_event
122}; 122};
123 123
124/* called with RTNL */
124static int br_switchdev_event(struct notifier_block *unused, 125static int br_switchdev_event(struct notifier_block *unused,
125 unsigned long event, void *ptr) 126 unsigned long event, void *ptr)
126{ 127{
@@ -130,7 +131,6 @@ static int br_switchdev_event(struct notifier_block *unused,
130 struct switchdev_notifier_fdb_info *fdb_info; 131 struct switchdev_notifier_fdb_info *fdb_info;
131 int err = NOTIFY_DONE; 132 int err = NOTIFY_DONE;
132 133
133 rtnl_lock();
134 p = br_port_get_rtnl(dev); 134 p = br_port_get_rtnl(dev);
135 if (!p) 135 if (!p)
136 goto out; 136 goto out;
@@ -155,7 +155,6 @@ static int br_switchdev_event(struct notifier_block *unused,
155 } 155 }
156 156
157out: 157out:
158 rtnl_unlock();
159 return err; 158 return err;
160} 159}
161 160
diff --git a/net/core/dev.c b/net/core/dev.c
index cc9e3652cf93..8cba3d852f25 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4351,6 +4351,7 @@ static void gro_list_prepare(struct napi_struct *napi, struct sk_buff *skb)
4351 4351
4352 diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev; 4352 diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev;
4353 diffs |= p->vlan_tci ^ skb->vlan_tci; 4353 diffs |= p->vlan_tci ^ skb->vlan_tci;
4354 diffs |= skb_metadata_dst_cmp(p, skb);
4354 if (maclen == ETH_HLEN) 4355 if (maclen == ETH_HLEN)
4355 diffs |= compare_ether_header(skb_mac_header(p), 4356 diffs |= compare_ether_header(skb_mac_header(p),
4356 skb_mac_header(skb)); 4357 skb_mac_header(skb));
@@ -4548,10 +4549,12 @@ static gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb)
4548 break; 4549 break;
4549 4550
4550 case GRO_MERGED_FREE: 4551 case GRO_MERGED_FREE:
4551 if (NAPI_GRO_CB(skb)->free == NAPI_GRO_FREE_STOLEN_HEAD) 4552 if (NAPI_GRO_CB(skb)->free == NAPI_GRO_FREE_STOLEN_HEAD) {
4553 skb_dst_drop(skb);
4552 kmem_cache_free(skbuff_head_cache, skb); 4554 kmem_cache_free(skbuff_head_cache, skb);
4553 else 4555 } else {
4554 __kfree_skb(skb); 4556 __kfree_skb(skb);
4557 }
4555 break; 4558 break;
4556 4559
4557 case GRO_HELD: 4560 case GRO_HELD:
diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
index 1df98c557440..e92b759d906c 100644
--- a/net/core/sock_reuseport.c
+++ b/net/core/sock_reuseport.c
@@ -93,10 +93,17 @@ static struct sock_reuseport *reuseport_grow(struct sock_reuseport *reuse)
93 * @sk2: Socket belonging to the existing reuseport group. 93 * @sk2: Socket belonging to the existing reuseport group.
94 * May return ENOMEM and not add socket to group under memory pressure. 94 * May return ENOMEM and not add socket to group under memory pressure.
95 */ 95 */
96int reuseport_add_sock(struct sock *sk, const struct sock *sk2) 96int reuseport_add_sock(struct sock *sk, struct sock *sk2)
97{ 97{
98 struct sock_reuseport *reuse; 98 struct sock_reuseport *reuse;
99 99
100 if (!rcu_access_pointer(sk2->sk_reuseport_cb)) {
101 int err = reuseport_alloc(sk2);
102
103 if (err)
104 return err;
105 }
106
100 spin_lock_bh(&reuseport_lock); 107 spin_lock_bh(&reuseport_lock);
101 reuse = rcu_dereference_protected(sk2->sk_reuseport_cb, 108 reuse = rcu_dereference_protected(sk2->sk_reuseport_cb,
102 lockdep_is_held(&reuseport_lock)), 109 lockdep_is_held(&reuseport_lock)),
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index c22920525e5d..775824720b6b 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -353,6 +353,7 @@ config INET_ESP
353 select CRYPTO_CBC 353 select CRYPTO_CBC
354 select CRYPTO_SHA1 354 select CRYPTO_SHA1
355 select CRYPTO_DES 355 select CRYPTO_DES
356 select CRYPTO_ECHAINIV
356 ---help--- 357 ---help---
357 Support for IPsec ESP. 358 Support for IPsec ESP.
358 359
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 7aea0ccb6be6..d07fc076bea0 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1394,9 +1394,10 @@ found:
1394 struct fib_info *fi = fa->fa_info; 1394 struct fib_info *fi = fa->fa_info;
1395 int nhsel, err; 1395 int nhsel, err;
1396 1396
1397 if ((index >= (1ul << fa->fa_slen)) && 1397 if ((BITS_PER_LONG > KEYLENGTH) || (fa->fa_slen < KEYLENGTH)) {
1398 ((BITS_PER_LONG > KEYLENGTH) || (fa->fa_slen != KEYLENGTH))) 1398 if (index >= (1ul << fa->fa_slen))
1399 continue; 1399 continue;
1400 }
1400 if (fa->fa_tos && fa->fa_tos != flp->flowi4_tos) 1401 if (fa->fa_tos && fa->fa_tos != flp->flowi4_tos)
1401 continue; 1402 continue;
1402 if (fi->fib_dead) 1403 if (fi->fib_dead)
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 8bb8e7ad8548..6029157a19ed 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -361,13 +361,20 @@ struct sock *inet_diag_find_one_icsk(struct net *net,
361 req->id.idiag_dport, req->id.idiag_src[0], 361 req->id.idiag_dport, req->id.idiag_src[0],
362 req->id.idiag_sport, req->id.idiag_if); 362 req->id.idiag_sport, req->id.idiag_if);
363#if IS_ENABLED(CONFIG_IPV6) 363#if IS_ENABLED(CONFIG_IPV6)
364 else if (req->sdiag_family == AF_INET6) 364 else if (req->sdiag_family == AF_INET6) {
365 sk = inet6_lookup(net, hashinfo, 365 if (ipv6_addr_v4mapped((struct in6_addr *)req->id.idiag_dst) &&
366 (struct in6_addr *)req->id.idiag_dst, 366 ipv6_addr_v4mapped((struct in6_addr *)req->id.idiag_src))
367 req->id.idiag_dport, 367 sk = inet_lookup(net, hashinfo, req->id.idiag_dst[3],
368 (struct in6_addr *)req->id.idiag_src, 368 req->id.idiag_dport, req->id.idiag_src[3],
369 req->id.idiag_sport, 369 req->id.idiag_sport, req->id.idiag_if);
370 req->id.idiag_if); 370 else
371 sk = inet6_lookup(net, hashinfo,
372 (struct in6_addr *)req->id.idiag_dst,
373 req->id.idiag_dport,
374 (struct in6_addr *)req->id.idiag_src,
375 req->id.idiag_sport,
376 req->id.idiag_if);
377 }
371#endif 378#endif
372 else 379 else
373 return ERR_PTR(-EINVAL); 380 return ERR_PTR(-EINVAL);
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 3f00810b7288..187c6fcc3027 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -661,6 +661,7 @@ int ip_defrag(struct net *net, struct sk_buff *skb, u32 user)
661 struct ipq *qp; 661 struct ipq *qp;
662 662
663 IP_INC_STATS_BH(net, IPSTATS_MIB_REASMREQDS); 663 IP_INC_STATS_BH(net, IPSTATS_MIB_REASMREQDS);
664 skb_orphan(skb);
664 665
665 /* Lookup (or create) queue header */ 666 /* Lookup (or create) queue header */
666 qp = ip_find(net, ip_hdr(skb), user, vif); 667 qp = ip_find(net, ip_hdr(skb), user, vif);
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index b1209b63381f..d77eb0c3b684 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -316,7 +316,10 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
316 const struct iphdr *iph = ip_hdr(skb); 316 const struct iphdr *iph = ip_hdr(skb);
317 struct rtable *rt; 317 struct rtable *rt;
318 318
319 if (sysctl_ip_early_demux && !skb_dst(skb) && !skb->sk) { 319 if (sysctl_ip_early_demux &&
320 !skb_dst(skb) &&
321 !skb->sk &&
322 !ip_is_fragment(iph)) {
320 const struct net_protocol *ipprot; 323 const struct net_protocol *ipprot;
321 int protocol = iph->protocol; 324 int protocol = iph->protocol;
322 325
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 67f7c9de0b16..2ed9dd2b5f2f 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -143,7 +143,11 @@ static char dhcp_client_identifier[253] __initdata;
143 143
144/* Persistent data: */ 144/* Persistent data: */
145 145
146#ifdef IPCONFIG_DYNAMIC
146static int ic_proto_used; /* Protocol used, if any */ 147static int ic_proto_used; /* Protocol used, if any */
148#else
149#define ic_proto_used 0
150#endif
147static __be32 ic_nameservers[CONF_NAMESERVERS_MAX]; /* DNS Server IP addresses */ 151static __be32 ic_nameservers[CONF_NAMESERVERS_MAX]; /* DNS Server IP addresses */
148static u8 ic_domain[64]; /* DNS (not NIS) domain name */ 152static u8 ic_domain[64]; /* DNS (not NIS) domain name */
149 153
diff --git a/net/ipv4/netfilter/nf_defrag_ipv4.c b/net/ipv4/netfilter/nf_defrag_ipv4.c
index 6fb869f646bf..a04dee536b8e 100644
--- a/net/ipv4/netfilter/nf_defrag_ipv4.c
+++ b/net/ipv4/netfilter/nf_defrag_ipv4.c
@@ -27,8 +27,6 @@ static int nf_ct_ipv4_gather_frags(struct net *net, struct sk_buff *skb,
27{ 27{
28 int err; 28 int err;
29 29
30 skb_orphan(skb);
31
32 local_bh_disable(); 30 local_bh_disable();
33 err = ip_defrag(net, skb, user); 31 err = ip_defrag(net, skb, user);
34 local_bh_enable(); 32 local_bh_enable();
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index fd17eec93525..19746b3fcbbe 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -279,6 +279,7 @@
279 279
280#include <asm/uaccess.h> 280#include <asm/uaccess.h>
281#include <asm/ioctls.h> 281#include <asm/ioctls.h>
282#include <asm/unaligned.h>
282#include <net/busy_poll.h> 283#include <net/busy_poll.h>
283 284
284int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT; 285int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT;
@@ -2638,6 +2639,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
2638 const struct inet_connection_sock *icsk = inet_csk(sk); 2639 const struct inet_connection_sock *icsk = inet_csk(sk);
2639 u32 now = tcp_time_stamp; 2640 u32 now = tcp_time_stamp;
2640 unsigned int start; 2641 unsigned int start;
2642 u64 rate64;
2641 u32 rate; 2643 u32 rate;
2642 2644
2643 memset(info, 0, sizeof(*info)); 2645 memset(info, 0, sizeof(*info));
@@ -2703,15 +2705,17 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
2703 info->tcpi_total_retrans = tp->total_retrans; 2705 info->tcpi_total_retrans = tp->total_retrans;
2704 2706
2705 rate = READ_ONCE(sk->sk_pacing_rate); 2707 rate = READ_ONCE(sk->sk_pacing_rate);
2706 info->tcpi_pacing_rate = rate != ~0U ? rate : ~0ULL; 2708 rate64 = rate != ~0U ? rate : ~0ULL;
2709 put_unaligned(rate64, &info->tcpi_pacing_rate);
2707 2710
2708 rate = READ_ONCE(sk->sk_max_pacing_rate); 2711 rate = READ_ONCE(sk->sk_max_pacing_rate);
2709 info->tcpi_max_pacing_rate = rate != ~0U ? rate : ~0ULL; 2712 rate64 = rate != ~0U ? rate : ~0ULL;
2713 put_unaligned(rate64, &info->tcpi_max_pacing_rate);
2710 2714
2711 do { 2715 do {
2712 start = u64_stats_fetch_begin_irq(&tp->syncp); 2716 start = u64_stats_fetch_begin_irq(&tp->syncp);
2713 info->tcpi_bytes_acked = tp->bytes_acked; 2717 put_unaligned(tp->bytes_acked, &info->tcpi_bytes_acked);
2714 info->tcpi_bytes_received = tp->bytes_received; 2718 put_unaligned(tp->bytes_received, &info->tcpi_bytes_received);
2715 } while (u64_stats_fetch_retry_irq(&tp->syncp, start)); 2719 } while (u64_stats_fetch_retry_irq(&tp->syncp, start));
2716 info->tcpi_segs_out = tp->segs_out; 2720 info->tcpi_segs_out = tp->segs_out;
2717 info->tcpi_segs_in = tp->segs_in; 2721 info->tcpi_segs_in = tp->segs_in;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 0003d409fec5..1c2a73406261 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -2164,8 +2164,7 @@ static void tcp_mark_head_lost(struct sock *sk, int packets, int mark_head)
2164{ 2164{
2165 struct tcp_sock *tp = tcp_sk(sk); 2165 struct tcp_sock *tp = tcp_sk(sk);
2166 struct sk_buff *skb; 2166 struct sk_buff *skb;
2167 int cnt, oldcnt; 2167 int cnt, oldcnt, lost;
2168 int err;
2169 unsigned int mss; 2168 unsigned int mss;
2170 /* Use SACK to deduce losses of new sequences sent during recovery */ 2169 /* Use SACK to deduce losses of new sequences sent during recovery */
2171 const u32 loss_high = tcp_is_sack(tp) ? tp->snd_nxt : tp->high_seq; 2170 const u32 loss_high = tcp_is_sack(tp) ? tp->snd_nxt : tp->high_seq;
@@ -2205,9 +2204,10 @@ static void tcp_mark_head_lost(struct sock *sk, int packets, int mark_head)
2205 break; 2204 break;
2206 2205
2207 mss = tcp_skb_mss(skb); 2206 mss = tcp_skb_mss(skb);
2208 err = tcp_fragment(sk, skb, (packets - oldcnt) * mss, 2207 /* If needed, chop off the prefix to mark as lost. */
2209 mss, GFP_ATOMIC); 2208 lost = (packets - oldcnt) * mss;
2210 if (err < 0) 2209 if (lost < skb->len &&
2210 tcp_fragment(sk, skb, lost, mss, GFP_ATOMIC) < 0)
2211 break; 2211 break;
2212 cnt = packets; 2212 cnt = packets;
2213 } 2213 }
@@ -2366,8 +2366,6 @@ static void tcp_undo_cwnd_reduction(struct sock *sk, bool unmark_loss)
2366 tp->snd_ssthresh = tp->prior_ssthresh; 2366 tp->snd_ssthresh = tp->prior_ssthresh;
2367 tcp_ecn_withdraw_cwr(tp); 2367 tcp_ecn_withdraw_cwr(tp);
2368 } 2368 }
2369 } else {
2370 tp->snd_cwnd = max(tp->snd_cwnd, tp->snd_ssthresh);
2371 } 2369 }
2372 tp->snd_cwnd_stamp = tcp_time_stamp; 2370 tp->snd_cwnd_stamp = tcp_time_stamp;
2373 tp->undo_marker = 0; 2371 tp->undo_marker = 0;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 5ced3e4013e3..a4d523709ab3 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -707,7 +707,8 @@ release_sk1:
707 outside socket context is ugly, certainly. What can I do? 707 outside socket context is ugly, certainly. What can I do?
708 */ 708 */
709 709
710static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack, 710static void tcp_v4_send_ack(struct net *net,
711 struct sk_buff *skb, u32 seq, u32 ack,
711 u32 win, u32 tsval, u32 tsecr, int oif, 712 u32 win, u32 tsval, u32 tsecr, int oif,
712 struct tcp_md5sig_key *key, 713 struct tcp_md5sig_key *key,
713 int reply_flags, u8 tos) 714 int reply_flags, u8 tos)
@@ -722,7 +723,6 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack,
722 ]; 723 ];
723 } rep; 724 } rep;
724 struct ip_reply_arg arg; 725 struct ip_reply_arg arg;
725 struct net *net = dev_net(skb_dst(skb)->dev);
726 726
727 memset(&rep.th, 0, sizeof(struct tcphdr)); 727 memset(&rep.th, 0, sizeof(struct tcphdr));
728 memset(&arg, 0, sizeof(arg)); 728 memset(&arg, 0, sizeof(arg));
@@ -784,7 +784,8 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb)
784 struct inet_timewait_sock *tw = inet_twsk(sk); 784 struct inet_timewait_sock *tw = inet_twsk(sk);
785 struct tcp_timewait_sock *tcptw = tcp_twsk(sk); 785 struct tcp_timewait_sock *tcptw = tcp_twsk(sk);
786 786
787 tcp_v4_send_ack(skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt, 787 tcp_v4_send_ack(sock_net(sk), skb,
788 tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt,
788 tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale, 789 tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale,
789 tcp_time_stamp + tcptw->tw_ts_offset, 790 tcp_time_stamp + tcptw->tw_ts_offset,
790 tcptw->tw_ts_recent, 791 tcptw->tw_ts_recent,
@@ -803,8 +804,10 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,
803 /* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV 804 /* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV
804 * sk->sk_state == TCP_SYN_RECV -> for Fast Open. 805 * sk->sk_state == TCP_SYN_RECV -> for Fast Open.
805 */ 806 */
806 tcp_v4_send_ack(skb, (sk->sk_state == TCP_LISTEN) ? 807 u32 seq = (sk->sk_state == TCP_LISTEN) ? tcp_rsk(req)->snt_isn + 1 :
807 tcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt, 808 tcp_sk(sk)->snd_nxt;
809
810 tcp_v4_send_ack(sock_net(sk), skb, seq,
808 tcp_rsk(req)->rcv_nxt, req->rsk_rcv_wnd, 811 tcp_rsk(req)->rcv_nxt, req->rsk_rcv_wnd,
809 tcp_time_stamp, 812 tcp_time_stamp,
810 req->ts_recent, 813 req->ts_recent,
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index dc45b538e237..be0b21852b13 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -499,6 +499,7 @@ static struct sock *udp4_lib_lookup2(struct net *net,
499 struct sock *sk, *result; 499 struct sock *sk, *result;
500 struct hlist_nulls_node *node; 500 struct hlist_nulls_node *node;
501 int score, badness, matches = 0, reuseport = 0; 501 int score, badness, matches = 0, reuseport = 0;
502 bool select_ok = true;
502 u32 hash = 0; 503 u32 hash = 0;
503 504
504begin: 505begin:
@@ -512,14 +513,18 @@ begin:
512 badness = score; 513 badness = score;
513 reuseport = sk->sk_reuseport; 514 reuseport = sk->sk_reuseport;
514 if (reuseport) { 515 if (reuseport) {
515 struct sock *sk2;
516 hash = udp_ehashfn(net, daddr, hnum, 516 hash = udp_ehashfn(net, daddr, hnum,
517 saddr, sport); 517 saddr, sport);
518 sk2 = reuseport_select_sock(sk, hash, skb, 518 if (select_ok) {
519 sizeof(struct udphdr)); 519 struct sock *sk2;
520 if (sk2) { 520
521 result = sk2; 521 sk2 = reuseport_select_sock(sk, hash, skb,
522 goto found; 522 sizeof(struct udphdr));
523 if (sk2) {
524 result = sk2;
525 select_ok = false;
526 goto found;
527 }
523 } 528 }
524 matches = 1; 529 matches = 1;
525 } 530 }
@@ -563,6 +568,7 @@ struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr,
563 unsigned int hash2, slot2, slot = udp_hashfn(net, hnum, udptable->mask); 568 unsigned int hash2, slot2, slot = udp_hashfn(net, hnum, udptable->mask);
564 struct udp_hslot *hslot2, *hslot = &udptable->hash[slot]; 569 struct udp_hslot *hslot2, *hslot = &udptable->hash[slot];
565 int score, badness, matches = 0, reuseport = 0; 570 int score, badness, matches = 0, reuseport = 0;
571 bool select_ok = true;
566 u32 hash = 0; 572 u32 hash = 0;
567 573
568 rcu_read_lock(); 574 rcu_read_lock();
@@ -601,14 +607,18 @@ begin:
601 badness = score; 607 badness = score;
602 reuseport = sk->sk_reuseport; 608 reuseport = sk->sk_reuseport;
603 if (reuseport) { 609 if (reuseport) {
604 struct sock *sk2;
605 hash = udp_ehashfn(net, daddr, hnum, 610 hash = udp_ehashfn(net, daddr, hnum,
606 saddr, sport); 611 saddr, sport);
607 sk2 = reuseport_select_sock(sk, hash, skb, 612 if (select_ok) {
613 struct sock *sk2;
614
615 sk2 = reuseport_select_sock(sk, hash, skb,
608 sizeof(struct udphdr)); 616 sizeof(struct udphdr));
609 if (sk2) { 617 if (sk2) {
610 result = sk2; 618 result = sk2;
611 goto found; 619 select_ok = false;
620 goto found;
621 }
612 } 622 }
613 matches = 1; 623 matches = 1;
614 } 624 }
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index bb7dabe2ebbf..40c897515ddc 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -69,6 +69,7 @@ config INET6_ESP
69 select CRYPTO_CBC 69 select CRYPTO_CBC
70 select CRYPTO_SHA1 70 select CRYPTO_SHA1
71 select CRYPTO_DES 71 select CRYPTO_DES
72 select CRYPTO_ECHAINIV
72 ---help--- 73 ---help---
73 Support for IPsec ESP. 74 Support for IPsec ESP.
74 75
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 517c55b01ba8..428162155280 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -162,6 +162,9 @@ ipv4_connected:
162 fl6.fl6_dport = inet->inet_dport; 162 fl6.fl6_dport = inet->inet_dport;
163 fl6.fl6_sport = inet->inet_sport; 163 fl6.fl6_sport = inet->inet_sport;
164 164
165 if (!fl6.flowi6_oif)
166 fl6.flowi6_oif = np->sticky_pktinfo.ipi6_ifindex;
167
165 if (!fl6.flowi6_oif && (addr_type&IPV6_ADDR_MULTICAST)) 168 if (!fl6.flowi6_oif && (addr_type&IPV6_ADDR_MULTICAST))
166 fl6.flowi6_oif = np->mcast_oif; 169 fl6.flowi6_oif = np->mcast_oif;
167 170
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 23de98f976d5..a163102f1803 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -909,6 +909,7 @@ static int ip6_dst_lookup_tail(struct net *net, const struct sock *sk,
909 struct rt6_info *rt; 909 struct rt6_info *rt;
910#endif 910#endif
911 int err; 911 int err;
912 int flags = 0;
912 913
913 /* The correct way to handle this would be to do 914 /* The correct way to handle this would be to do
914 * ip6_route_get_saddr, and then ip6_route_output; however, 915 * ip6_route_get_saddr, and then ip6_route_output; however,
@@ -940,10 +941,13 @@ static int ip6_dst_lookup_tail(struct net *net, const struct sock *sk,
940 dst_release(*dst); 941 dst_release(*dst);
941 *dst = NULL; 942 *dst = NULL;
942 } 943 }
944
945 if (fl6->flowi6_oif)
946 flags |= RT6_LOOKUP_F_IFACE;
943 } 947 }
944 948
945 if (!*dst) 949 if (!*dst)
946 *dst = ip6_route_output(net, sk, fl6); 950 *dst = ip6_route_output_flags(net, sk, fl6, flags);
947 951
948 err = (*dst)->error; 952 err = (*dst)->error;
949 if (err) 953 if (err)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 3c8834bc822d..ed446639219c 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1183,11 +1183,10 @@ static struct rt6_info *ip6_pol_route_output(struct net *net, struct fib6_table
1183 return ip6_pol_route(net, table, fl6->flowi6_oif, fl6, flags); 1183 return ip6_pol_route(net, table, fl6->flowi6_oif, fl6, flags);
1184} 1184}
1185 1185
1186struct dst_entry *ip6_route_output(struct net *net, const struct sock *sk, 1186struct dst_entry *ip6_route_output_flags(struct net *net, const struct sock *sk,
1187 struct flowi6 *fl6) 1187 struct flowi6 *fl6, int flags)
1188{ 1188{
1189 struct dst_entry *dst; 1189 struct dst_entry *dst;
1190 int flags = 0;
1191 bool any_src; 1190 bool any_src;
1192 1191
1193 dst = l3mdev_rt6_dst_by_oif(net, fl6); 1192 dst = l3mdev_rt6_dst_by_oif(net, fl6);
@@ -1208,7 +1207,7 @@ struct dst_entry *ip6_route_output(struct net *net, const struct sock *sk,
1208 1207
1209 return fib6_rule_lookup(net, fl6, flags, ip6_pol_route_output); 1208 return fib6_rule_lookup(net, fl6, flags, ip6_pol_route_output);
1210} 1209}
1211EXPORT_SYMBOL(ip6_route_output); 1210EXPORT_SYMBOL_GPL(ip6_route_output_flags);
1212 1211
1213struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_orig) 1212struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_orig)
1214{ 1213{
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index e794ef66a401..2066d1c25a11 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -201,14 +201,14 @@ static int ipip6_tunnel_create(struct net_device *dev)
201 if ((__force u16)t->parms.i_flags & SIT_ISATAP) 201 if ((__force u16)t->parms.i_flags & SIT_ISATAP)
202 dev->priv_flags |= IFF_ISATAP; 202 dev->priv_flags |= IFF_ISATAP;
203 203
204 dev->rtnl_link_ops = &sit_link_ops;
205
204 err = register_netdevice(dev); 206 err = register_netdevice(dev);
205 if (err < 0) 207 if (err < 0)
206 goto out; 208 goto out;
207 209
208 ipip6_tunnel_clone_6rd(dev, sitn); 210 ipip6_tunnel_clone_6rd(dev, sitn);
209 211
210 dev->rtnl_link_ops = &sit_link_ops;
211
212 dev_hold(dev); 212 dev_hold(dev);
213 213
214 ipip6_tunnel_link(sitn, t); 214 ipip6_tunnel_link(sitn, t);
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 5d2c2afffe7b..22e28a44e3c8 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -257,6 +257,7 @@ static struct sock *udp6_lib_lookup2(struct net *net,
257 struct sock *sk, *result; 257 struct sock *sk, *result;
258 struct hlist_nulls_node *node; 258 struct hlist_nulls_node *node;
259 int score, badness, matches = 0, reuseport = 0; 259 int score, badness, matches = 0, reuseport = 0;
260 bool select_ok = true;
260 u32 hash = 0; 261 u32 hash = 0;
261 262
262begin: 263begin:
@@ -270,14 +271,18 @@ begin:
270 badness = score; 271 badness = score;
271 reuseport = sk->sk_reuseport; 272 reuseport = sk->sk_reuseport;
272 if (reuseport) { 273 if (reuseport) {
273 struct sock *sk2;
274 hash = udp6_ehashfn(net, daddr, hnum, 274 hash = udp6_ehashfn(net, daddr, hnum,
275 saddr, sport); 275 saddr, sport);
276 sk2 = reuseport_select_sock(sk, hash, skb, 276 if (select_ok) {
277 sizeof(struct udphdr)); 277 struct sock *sk2;
278 if (sk2) { 278
279 result = sk2; 279 sk2 = reuseport_select_sock(sk, hash, skb,
280 goto found; 280 sizeof(struct udphdr));
281 if (sk2) {
282 result = sk2;
283 select_ok = false;
284 goto found;
285 }
281 } 286 }
282 matches = 1; 287 matches = 1;
283 } 288 }
@@ -321,6 +326,7 @@ struct sock *__udp6_lib_lookup(struct net *net,
321 unsigned int hash2, slot2, slot = udp_hashfn(net, hnum, udptable->mask); 326 unsigned int hash2, slot2, slot = udp_hashfn(net, hnum, udptable->mask);
322 struct udp_hslot *hslot2, *hslot = &udptable->hash[slot]; 327 struct udp_hslot *hslot2, *hslot = &udptable->hash[slot];
323 int score, badness, matches = 0, reuseport = 0; 328 int score, badness, matches = 0, reuseport = 0;
329 bool select_ok = true;
324 u32 hash = 0; 330 u32 hash = 0;
325 331
326 rcu_read_lock(); 332 rcu_read_lock();
@@ -358,14 +364,18 @@ begin:
358 badness = score; 364 badness = score;
359 reuseport = sk->sk_reuseport; 365 reuseport = sk->sk_reuseport;
360 if (reuseport) { 366 if (reuseport) {
361 struct sock *sk2;
362 hash = udp6_ehashfn(net, daddr, hnum, 367 hash = udp6_ehashfn(net, daddr, hnum,
363 saddr, sport); 368 saddr, sport);
364 sk2 = reuseport_select_sock(sk, hash, skb, 369 if (select_ok) {
370 struct sock *sk2;
371
372 sk2 = reuseport_select_sock(sk, hash, skb,
365 sizeof(struct udphdr)); 373 sizeof(struct udphdr));
366 if (sk2) { 374 if (sk2) {
367 result = sk2; 375 result = sk2;
368 goto found; 376 select_ok = false;
377 goto found;
378 }
369 } 379 }
370 matches = 1; 380 matches = 1;
371 } 381 }
diff --git a/net/irda/ircomm/ircomm_param.c b/net/irda/ircomm/ircomm_param.c
index 3c4caa60c926..5728e76ca6d5 100644
--- a/net/irda/ircomm/ircomm_param.c
+++ b/net/irda/ircomm/ircomm_param.c
@@ -134,11 +134,10 @@ int ircomm_param_request(struct ircomm_tty_cb *self, __u8 pi, int flush)
134 return -1; 134 return -1;
135 } 135 }
136 skb_put(skb, count); 136 skb_put(skb, count);
137 pr_debug("%s(), skb->len=%d\n", __func__, skb->len);
137 138
138 spin_unlock_irqrestore(&self->spinlock, flags); 139 spin_unlock_irqrestore(&self->spinlock, flags);
139 140
140 pr_debug("%s(), skb->len=%d\n", __func__ , skb->len);
141
142 if (flush) { 141 if (flush) {
143 /* ircomm_tty_do_softint will take care of the rest */ 142 /* ircomm_tty_do_softint will take care of the rest */
144 schedule_work(&self->tqueue); 143 schedule_work(&self->tqueue);
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index ef50a94d3eb7..fc3598a922b0 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -708,6 +708,9 @@ static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr,
708 if (!addr || addr->sa_family != AF_IUCV) 708 if (!addr || addr->sa_family != AF_IUCV)
709 return -EINVAL; 709 return -EINVAL;
710 710
711 if (addr_len < sizeof(struct sockaddr_iucv))
712 return -EINVAL;
713
711 lock_sock(sk); 714 lock_sock(sk);
712 if (sk->sk_state != IUCV_OPEN) { 715 if (sk->sk_state != IUCV_OPEN) {
713 err = -EBADFD; 716 err = -EBADFD;
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index f7fc0e00497f..978d3bc31df7 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -1733,7 +1733,6 @@ void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local)
1733 if (sdata->vif.type != NL80211_IFTYPE_ADHOC) 1733 if (sdata->vif.type != NL80211_IFTYPE_ADHOC)
1734 continue; 1734 continue;
1735 sdata->u.ibss.last_scan_completed = jiffies; 1735 sdata->u.ibss.last_scan_completed = jiffies;
1736 ieee80211_queue_work(&local->hw, &sdata->work);
1737 } 1736 }
1738 mutex_unlock(&local->iflist_mtx); 1737 mutex_unlock(&local->iflist_mtx);
1739} 1738}
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 6bcf0faa4a89..8190bf27ebff 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -248,6 +248,7 @@ static void ieee80211_restart_work(struct work_struct *work)
248 248
249 /* wait for scan work complete */ 249 /* wait for scan work complete */
250 flush_workqueue(local->workqueue); 250 flush_workqueue(local->workqueue);
251 flush_work(&local->sched_scan_stopped_work);
251 252
252 WARN(test_bit(SCAN_HW_SCANNING, &local->scanning), 253 WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
253 "%s called with hardware scan in progress\n", __func__); 254 "%s called with hardware scan in progress\n", __func__);
@@ -256,6 +257,11 @@ static void ieee80211_restart_work(struct work_struct *work)
256 list_for_each_entry(sdata, &local->interfaces, list) 257 list_for_each_entry(sdata, &local->interfaces, list)
257 flush_delayed_work(&sdata->dec_tailroom_needed_wk); 258 flush_delayed_work(&sdata->dec_tailroom_needed_wk);
258 ieee80211_scan_cancel(local); 259 ieee80211_scan_cancel(local);
260
261 /* make sure any new ROC will consider local->in_reconfig */
262 flush_delayed_work(&local->roc_work);
263 flush_work(&local->hw_roc_done);
264
259 ieee80211_reconfig(local); 265 ieee80211_reconfig(local);
260 rtnl_unlock(); 266 rtnl_unlock();
261} 267}
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index fa28500f28fd..6f85b6ab8e51 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -1370,17 +1370,6 @@ out:
1370 sdata_unlock(sdata); 1370 sdata_unlock(sdata);
1371} 1371}
1372 1372
1373void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local)
1374{
1375 struct ieee80211_sub_if_data *sdata;
1376
1377 rcu_read_lock();
1378 list_for_each_entry_rcu(sdata, &local->interfaces, list)
1379 if (ieee80211_vif_is_mesh(&sdata->vif) &&
1380 ieee80211_sdata_running(sdata))
1381 ieee80211_queue_work(&local->hw, &sdata->work);
1382 rcu_read_unlock();
1383}
1384 1373
1385void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata) 1374void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
1386{ 1375{
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index a1596344c3ba..4a8019f79fb2 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -362,14 +362,10 @@ static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
362 return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP; 362 return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP;
363} 363}
364 364
365void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local);
366
367void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata); 365void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata);
368void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata); 366void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata);
369void ieee80211s_stop(void); 367void ieee80211s_stop(void);
370#else 368#else
371static inline void
372ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {}
373static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata) 369static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
374{ return false; } 370{ return false; }
375static inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata) 371static inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 1c342e2592c4..bfbb1acafdd1 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -4005,8 +4005,6 @@ static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data *sdata)
4005 if (!ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR)) 4005 if (!ieee80211_hw_check(&sdata->local->hw, CONNECTION_MONITOR))
4006 ieee80211_queue_work(&sdata->local->hw, 4006 ieee80211_queue_work(&sdata->local->hw,
4007 &sdata->u.mgd.monitor_work); 4007 &sdata->u.mgd.monitor_work);
4008 /* and do all the other regular work too */
4009 ieee80211_queue_work(&sdata->local->hw, &sdata->work);
4010 } 4008 }
4011} 4009}
4012 4010
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index 8b2f4eaac2ba..55a9c5b94ce1 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -252,14 +252,11 @@ static bool ieee80211_recalc_sw_work(struct ieee80211_local *local,
252static void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc, 252static void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc,
253 unsigned long start_time) 253 unsigned long start_time)
254{ 254{
255 struct ieee80211_local *local = roc->sdata->local;
256
257 if (WARN_ON(roc->notified)) 255 if (WARN_ON(roc->notified))
258 return; 256 return;
259 257
260 roc->start_time = start_time; 258 roc->start_time = start_time;
261 roc->started = true; 259 roc->started = true;
262 roc->hw_begun = true;
263 260
264 if (roc->mgmt_tx_cookie) { 261 if (roc->mgmt_tx_cookie) {
265 if (!WARN_ON(!roc->frame)) { 262 if (!WARN_ON(!roc->frame)) {
@@ -274,9 +271,6 @@ static void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc,
274 } 271 }
275 272
276 roc->notified = true; 273 roc->notified = true;
277
278 if (!local->ops->remain_on_channel)
279 ieee80211_recalc_sw_work(local, start_time);
280} 274}
281 275
282static void ieee80211_hw_roc_start(struct work_struct *work) 276static void ieee80211_hw_roc_start(struct work_struct *work)
@@ -291,6 +285,7 @@ static void ieee80211_hw_roc_start(struct work_struct *work)
291 if (!roc->started) 285 if (!roc->started)
292 break; 286 break;
293 287
288 roc->hw_begun = true;
294 ieee80211_handle_roc_started(roc, local->hw_roc_start_time); 289 ieee80211_handle_roc_started(roc, local->hw_roc_start_time);
295 } 290 }
296 291
@@ -413,6 +408,10 @@ void ieee80211_start_next_roc(struct ieee80211_local *local)
413 return; 408 return;
414 } 409 }
415 410
411 /* defer roc if driver is not started (i.e. during reconfig) */
412 if (local->in_reconfig)
413 return;
414
416 roc = list_first_entry(&local->roc_list, struct ieee80211_roc_work, 415 roc = list_first_entry(&local->roc_list, struct ieee80211_roc_work,
417 list); 416 list);
418 417
@@ -534,8 +533,10 @@ ieee80211_coalesce_hw_started_roc(struct ieee80211_local *local,
534 * begin, otherwise they'll both be marked properly by the work 533 * begin, otherwise they'll both be marked properly by the work
535 * struct that runs once the driver notifies us of the beginning 534 * struct that runs once the driver notifies us of the beginning
536 */ 535 */
537 if (cur_roc->hw_begun) 536 if (cur_roc->hw_begun) {
537 new_roc->hw_begun = true;
538 ieee80211_handle_roc_started(new_roc, now); 538 ieee80211_handle_roc_started(new_roc, now);
539 }
539 540
540 return true; 541 return true;
541} 542}
@@ -658,6 +659,7 @@ static int ieee80211_start_roc_work(struct ieee80211_local *local,
658 queued = true; 659 queued = true;
659 roc->on_channel = tmp->on_channel; 660 roc->on_channel = tmp->on_channel;
660 ieee80211_handle_roc_started(roc, now); 661 ieee80211_handle_roc_started(roc, now);
662 ieee80211_recalc_sw_work(local, now);
661 break; 663 break;
662 } 664 }
663 665
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index a413e52f7691..ae980ce8daff 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -314,6 +314,7 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
314 bool was_scanning = local->scanning; 314 bool was_scanning = local->scanning;
315 struct cfg80211_scan_request *scan_req; 315 struct cfg80211_scan_request *scan_req;
316 struct ieee80211_sub_if_data *scan_sdata; 316 struct ieee80211_sub_if_data *scan_sdata;
317 struct ieee80211_sub_if_data *sdata;
317 318
318 lockdep_assert_held(&local->mtx); 319 lockdep_assert_held(&local->mtx);
319 320
@@ -373,7 +374,16 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
373 374
374 ieee80211_mlme_notify_scan_completed(local); 375 ieee80211_mlme_notify_scan_completed(local);
375 ieee80211_ibss_notify_scan_completed(local); 376 ieee80211_ibss_notify_scan_completed(local);
376 ieee80211_mesh_notify_scan_completed(local); 377
378 /* Requeue all the work that might have been ignored while
379 * the scan was in progress; if there was none this will
380 * just be a no-op for the particular interface.
381 */
382 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
383 if (ieee80211_sdata_running(sdata))
384 ieee80211_queue_work(&sdata->local->hw, &sdata->work);
385 }
386
377 if (was_scanning) 387 if (was_scanning)
378 ieee80211_start_next_roc(local); 388 ieee80211_start_next_roc(local);
379} 389}
@@ -1213,6 +1223,14 @@ void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw)
1213 1223
1214 trace_api_sched_scan_stopped(local); 1224 trace_api_sched_scan_stopped(local);
1215 1225
1226 /*
1227 * this shouldn't really happen, so for simplicity
1228 * simply ignore it, and let mac80211 reconfigure
1229 * the sched scan later on.
1230 */
1231 if (local->in_reconfig)
1232 return;
1233
1216 schedule_work(&local->sched_scan_stopped_work); 1234 schedule_work(&local->sched_scan_stopped_work);
1217} 1235}
1218EXPORT_SYMBOL(ieee80211_sched_scan_stopped); 1236EXPORT_SYMBOL(ieee80211_sched_scan_stopped);
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 4402ad5b27d1..a4a4f89d3ba0 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -1453,7 +1453,7 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
1453 1453
1454 more_data = ieee80211_sta_ps_more_data(sta, ignored_acs, reason, driver_release_tids); 1454 more_data = ieee80211_sta_ps_more_data(sta, ignored_acs, reason, driver_release_tids);
1455 1455
1456 if (reason == IEEE80211_FRAME_RELEASE_PSPOLL) 1456 if (driver_release_tids && reason == IEEE80211_FRAME_RELEASE_PSPOLL)
1457 driver_release_tids = 1457 driver_release_tids =
1458 BIT(find_highest_prio_tid(driver_release_tids)); 1458 BIT(find_highest_prio_tid(driver_release_tids));
1459 1459
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index 5bad05e9af90..6101deb805a8 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -51,6 +51,11 @@ static void ieee80211_handle_filtered_frame(struct ieee80211_local *local,
51 struct ieee80211_hdr *hdr = (void *)skb->data; 51 struct ieee80211_hdr *hdr = (void *)skb->data;
52 int ac; 52 int ac;
53 53
54 if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) {
55 ieee80211_free_txskb(&local->hw, skb);
56 return;
57 }
58
54 /* 59 /*
55 * This skb 'survived' a round-trip through the driver, and 60 * This skb 'survived' a round-trip through the driver, and
56 * hopefully the driver didn't mangle it too badly. However, 61 * hopefully the driver didn't mangle it too badly. However,
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 3943d4bf289c..58f58bd5202f 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2043,16 +2043,26 @@ int ieee80211_reconfig(struct ieee80211_local *local)
2043 */ 2043 */
2044 if (sched_scan_req->n_scan_plans > 1 || 2044 if (sched_scan_req->n_scan_plans > 1 ||
2045 __ieee80211_request_sched_scan_start(sched_scan_sdata, 2045 __ieee80211_request_sched_scan_start(sched_scan_sdata,
2046 sched_scan_req)) 2046 sched_scan_req)) {
2047 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
2048 RCU_INIT_POINTER(local->sched_scan_req, NULL);
2047 sched_scan_stopped = true; 2049 sched_scan_stopped = true;
2050 }
2048 mutex_unlock(&local->mtx); 2051 mutex_unlock(&local->mtx);
2049 2052
2050 if (sched_scan_stopped) 2053 if (sched_scan_stopped)
2051 cfg80211_sched_scan_stopped_rtnl(local->hw.wiphy); 2054 cfg80211_sched_scan_stopped_rtnl(local->hw.wiphy);
2052 2055
2053 wake_up: 2056 wake_up:
2054 local->in_reconfig = false; 2057 if (local->in_reconfig) {
2055 barrier(); 2058 local->in_reconfig = false;
2059 barrier();
2060
2061 /* Restart deferred ROCs */
2062 mutex_lock(&local->mtx);
2063 ieee80211_start_next_roc(local);
2064 mutex_unlock(&local->mtx);
2065 }
2056 2066
2057 if (local->monitors == local->open_count && local->monitors > 0) 2067 if (local->monitors == local->open_count && local->monitors > 0)
2058 ieee80211_add_virtual_monitor(local); 2068 ieee80211_add_virtual_monitor(local);
diff --git a/net/netfilter/ipset/ip_set_hash_netiface.c b/net/netfilter/ipset/ip_set_hash_netiface.c
index 43d8c9896fa3..f0f688db6213 100644
--- a/net/netfilter/ipset/ip_set_hash_netiface.c
+++ b/net/netfilter/ipset/ip_set_hash_netiface.c
@@ -164,8 +164,6 @@ hash_netiface4_kadt(struct ip_set *set, const struct sk_buff *skb,
164 }; 164 };
165 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); 165 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
166 166
167 if (e.cidr == 0)
168 return -EINVAL;
169 if (adt == IPSET_TEST) 167 if (adt == IPSET_TEST)
170 e.cidr = HOST_MASK; 168 e.cidr = HOST_MASK;
171 169
@@ -377,8 +375,6 @@ hash_netiface6_kadt(struct ip_set *set, const struct sk_buff *skb,
377 }; 375 };
378 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); 376 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
379 377
380 if (e.cidr == 0)
381 return -EINVAL;
382 if (adt == IPSET_TEST) 378 if (adt == IPSET_TEST)
383 e.cidr = HOST_MASK; 379 e.cidr = HOST_MASK;
384 380
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 3cb3cb831591..58882de06bd7 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -66,6 +66,21 @@ EXPORT_SYMBOL_GPL(nf_conntrack_locks);
66__cacheline_aligned_in_smp DEFINE_SPINLOCK(nf_conntrack_expect_lock); 66__cacheline_aligned_in_smp DEFINE_SPINLOCK(nf_conntrack_expect_lock);
67EXPORT_SYMBOL_GPL(nf_conntrack_expect_lock); 67EXPORT_SYMBOL_GPL(nf_conntrack_expect_lock);
68 68
69static __read_mostly spinlock_t nf_conntrack_locks_all_lock;
70static __read_mostly bool nf_conntrack_locks_all;
71
72void nf_conntrack_lock(spinlock_t *lock) __acquires(lock)
73{
74 spin_lock(lock);
75 while (unlikely(nf_conntrack_locks_all)) {
76 spin_unlock(lock);
77 spin_lock(&nf_conntrack_locks_all_lock);
78 spin_unlock(&nf_conntrack_locks_all_lock);
79 spin_lock(lock);
80 }
81}
82EXPORT_SYMBOL_GPL(nf_conntrack_lock);
83
69static void nf_conntrack_double_unlock(unsigned int h1, unsigned int h2) 84static void nf_conntrack_double_unlock(unsigned int h1, unsigned int h2)
70{ 85{
71 h1 %= CONNTRACK_LOCKS; 86 h1 %= CONNTRACK_LOCKS;
@@ -82,12 +97,12 @@ static bool nf_conntrack_double_lock(struct net *net, unsigned int h1,
82 h1 %= CONNTRACK_LOCKS; 97 h1 %= CONNTRACK_LOCKS;
83 h2 %= CONNTRACK_LOCKS; 98 h2 %= CONNTRACK_LOCKS;
84 if (h1 <= h2) { 99 if (h1 <= h2) {
85 spin_lock(&nf_conntrack_locks[h1]); 100 nf_conntrack_lock(&nf_conntrack_locks[h1]);
86 if (h1 != h2) 101 if (h1 != h2)
87 spin_lock_nested(&nf_conntrack_locks[h2], 102 spin_lock_nested(&nf_conntrack_locks[h2],
88 SINGLE_DEPTH_NESTING); 103 SINGLE_DEPTH_NESTING);
89 } else { 104 } else {
90 spin_lock(&nf_conntrack_locks[h2]); 105 nf_conntrack_lock(&nf_conntrack_locks[h2]);
91 spin_lock_nested(&nf_conntrack_locks[h1], 106 spin_lock_nested(&nf_conntrack_locks[h1],
92 SINGLE_DEPTH_NESTING); 107 SINGLE_DEPTH_NESTING);
93 } 108 }
@@ -102,16 +117,19 @@ static void nf_conntrack_all_lock(void)
102{ 117{
103 int i; 118 int i;
104 119
105 for (i = 0; i < CONNTRACK_LOCKS; i++) 120 spin_lock(&nf_conntrack_locks_all_lock);
106 spin_lock_nested(&nf_conntrack_locks[i], i); 121 nf_conntrack_locks_all = true;
122
123 for (i = 0; i < CONNTRACK_LOCKS; i++) {
124 spin_lock(&nf_conntrack_locks[i]);
125 spin_unlock(&nf_conntrack_locks[i]);
126 }
107} 127}
108 128
109static void nf_conntrack_all_unlock(void) 129static void nf_conntrack_all_unlock(void)
110{ 130{
111 int i; 131 nf_conntrack_locks_all = false;
112 132 spin_unlock(&nf_conntrack_locks_all_lock);
113 for (i = 0; i < CONNTRACK_LOCKS; i++)
114 spin_unlock(&nf_conntrack_locks[i]);
115} 133}
116 134
117unsigned int nf_conntrack_htable_size __read_mostly; 135unsigned int nf_conntrack_htable_size __read_mostly;
@@ -757,7 +775,7 @@ restart:
757 hash = hash_bucket(_hash, net); 775 hash = hash_bucket(_hash, net);
758 for (; i < net->ct.htable_size; i++) { 776 for (; i < net->ct.htable_size; i++) {
759 lockp = &nf_conntrack_locks[hash % CONNTRACK_LOCKS]; 777 lockp = &nf_conntrack_locks[hash % CONNTRACK_LOCKS];
760 spin_lock(lockp); 778 nf_conntrack_lock(lockp);
761 if (read_seqcount_retry(&net->ct.generation, sequence)) { 779 if (read_seqcount_retry(&net->ct.generation, sequence)) {
762 spin_unlock(lockp); 780 spin_unlock(lockp);
763 goto restart; 781 goto restart;
@@ -1382,7 +1400,7 @@ get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data),
1382 for (; *bucket < net->ct.htable_size; (*bucket)++) { 1400 for (; *bucket < net->ct.htable_size; (*bucket)++) {
1383 lockp = &nf_conntrack_locks[*bucket % CONNTRACK_LOCKS]; 1401 lockp = &nf_conntrack_locks[*bucket % CONNTRACK_LOCKS];
1384 local_bh_disable(); 1402 local_bh_disable();
1385 spin_lock(lockp); 1403 nf_conntrack_lock(lockp);
1386 if (*bucket < net->ct.htable_size) { 1404 if (*bucket < net->ct.htable_size) {
1387 hlist_nulls_for_each_entry(h, n, &net->ct.hash[*bucket], hnnode) { 1405 hlist_nulls_for_each_entry(h, n, &net->ct.hash[*bucket], hnnode) {
1388 if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL) 1406 if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL)
diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
index bd9d31537905..3b40ec575cd5 100644
--- a/net/netfilter/nf_conntrack_helper.c
+++ b/net/netfilter/nf_conntrack_helper.c
@@ -425,7 +425,7 @@ static void __nf_conntrack_helper_unregister(struct nf_conntrack_helper *me,
425 } 425 }
426 local_bh_disable(); 426 local_bh_disable();
427 for (i = 0; i < net->ct.htable_size; i++) { 427 for (i = 0; i < net->ct.htable_size; i++) {
428 spin_lock(&nf_conntrack_locks[i % CONNTRACK_LOCKS]); 428 nf_conntrack_lock(&nf_conntrack_locks[i % CONNTRACK_LOCKS]);
429 if (i < net->ct.htable_size) { 429 if (i < net->ct.htable_size) {
430 hlist_nulls_for_each_entry(h, nn, &net->ct.hash[i], hnnode) 430 hlist_nulls_for_each_entry(h, nn, &net->ct.hash[i], hnnode)
431 unhelp(h, me); 431 unhelp(h, me);
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index dbb1bb3edb45..355e8552fd5b 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -840,7 +840,7 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
840 for (; cb->args[0] < net->ct.htable_size; cb->args[0]++) { 840 for (; cb->args[0] < net->ct.htable_size; cb->args[0]++) {
841restart: 841restart:
842 lockp = &nf_conntrack_locks[cb->args[0] % CONNTRACK_LOCKS]; 842 lockp = &nf_conntrack_locks[cb->args[0] % CONNTRACK_LOCKS];
843 spin_lock(lockp); 843 nf_conntrack_lock(lockp);
844 if (cb->args[0] >= net->ct.htable_size) { 844 if (cb->args[0] >= net->ct.htable_size) {
845 spin_unlock(lockp); 845 spin_unlock(lockp);
846 goto out; 846 goto out;
diff --git a/net/netfilter/nf_tables_netdev.c b/net/netfilter/nf_tables_netdev.c
index b6605e000801..5eefe4a355c6 100644
--- a/net/netfilter/nf_tables_netdev.c
+++ b/net/netfilter/nf_tables_netdev.c
@@ -224,12 +224,12 @@ static int __init nf_tables_netdev_init(void)
224 224
225 nft_register_chain_type(&nft_filter_chain_netdev); 225 nft_register_chain_type(&nft_filter_chain_netdev);
226 ret = register_pernet_subsys(&nf_tables_netdev_net_ops); 226 ret = register_pernet_subsys(&nf_tables_netdev_net_ops);
227 if (ret < 0) 227 if (ret < 0) {
228 nft_unregister_chain_type(&nft_filter_chain_netdev); 228 nft_unregister_chain_type(&nft_filter_chain_netdev);
229 229 return ret;
230 }
230 register_netdevice_notifier(&nf_tables_netdev_notifier); 231 register_netdevice_notifier(&nf_tables_netdev_notifier);
231 232 return 0;
232 return ret;
233} 233}
234 234
235static void __exit nf_tables_netdev_exit(void) 235static void __exit nf_tables_netdev_exit(void)
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index 5d010f27ac01..94837d236ab0 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -307,12 +307,12 @@ static void ctnl_untimeout(struct net *net, struct ctnl_timeout *timeout)
307 307
308 local_bh_disable(); 308 local_bh_disable();
309 for (i = 0; i < net->ct.htable_size; i++) { 309 for (i = 0; i < net->ct.htable_size; i++) {
310 spin_lock(&nf_conntrack_locks[i % CONNTRACK_LOCKS]); 310 nf_conntrack_lock(&nf_conntrack_locks[i % CONNTRACK_LOCKS]);
311 if (i < net->ct.htable_size) { 311 if (i < net->ct.htable_size) {
312 hlist_nulls_for_each_entry(h, nn, &net->ct.hash[i], hnnode) 312 hlist_nulls_for_each_entry(h, nn, &net->ct.hash[i], hnnode)
313 untimeout(h, timeout); 313 untimeout(h, timeout);
314 } 314 }
315 spin_unlock(&nf_conntrack_locks[i % CONNTRACK_LOCKS]); 315 nf_conntrack_lock(&nf_conntrack_locks[i % CONNTRACK_LOCKS]);
316 } 316 }
317 local_bh_enable(); 317 local_bh_enable();
318} 318}
diff --git a/net/netfilter/nft_byteorder.c b/net/netfilter/nft_byteorder.c
index 383c17138399..b78c28ba465f 100644
--- a/net/netfilter/nft_byteorder.c
+++ b/net/netfilter/nft_byteorder.c
@@ -46,16 +46,14 @@ static void nft_byteorder_eval(const struct nft_expr *expr,
46 switch (priv->op) { 46 switch (priv->op) {
47 case NFT_BYTEORDER_NTOH: 47 case NFT_BYTEORDER_NTOH:
48 for (i = 0; i < priv->len / 8; i++) { 48 for (i = 0; i < priv->len / 8; i++) {
49 src64 = get_unaligned_be64(&src[i]); 49 src64 = get_unaligned((u64 *)&src[i]);
50 src64 = be64_to_cpu((__force __be64)src64);
51 put_unaligned_be64(src64, &dst[i]); 50 put_unaligned_be64(src64, &dst[i]);
52 } 51 }
53 break; 52 break;
54 case NFT_BYTEORDER_HTON: 53 case NFT_BYTEORDER_HTON:
55 for (i = 0; i < priv->len / 8; i++) { 54 for (i = 0; i < priv->len / 8; i++) {
56 src64 = get_unaligned_be64(&src[i]); 55 src64 = get_unaligned_be64(&src[i]);
57 src64 = (__force u64)cpu_to_be64(src64); 56 put_unaligned(src64, (u64 *)&dst[i]);
58 put_unaligned_be64(src64, &dst[i]);
59 } 57 }
60 break; 58 break;
61 } 59 }
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
index a0eb2161e3ef..d4a4619fcebc 100644
--- a/net/netfilter/nft_ct.c
+++ b/net/netfilter/nft_ct.c
@@ -127,6 +127,7 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
127 NF_CT_LABELS_MAX_SIZE - size); 127 NF_CT_LABELS_MAX_SIZE - size);
128 return; 128 return;
129 } 129 }
130#endif
130 case NFT_CT_BYTES: /* fallthrough */ 131 case NFT_CT_BYTES: /* fallthrough */
131 case NFT_CT_PKTS: { 132 case NFT_CT_PKTS: {
132 const struct nf_conn_acct *acct = nf_conn_acct_find(ct); 133 const struct nf_conn_acct *acct = nf_conn_acct_find(ct);
@@ -138,7 +139,6 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
138 memcpy(dest, &count, sizeof(count)); 139 memcpy(dest, &count, sizeof(count));
139 return; 140 return;
140 } 141 }
141#endif
142 default: 142 default:
143 break; 143 break;
144 } 144 }
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
index b7c43def0dc6..e118397254af 100644
--- a/net/netfilter/xt_TCPMSS.c
+++ b/net/netfilter/xt_TCPMSS.c
@@ -228,7 +228,7 @@ tcpmss_tg6(struct sk_buff *skb, const struct xt_action_param *par)
228{ 228{
229 struct ipv6hdr *ipv6h = ipv6_hdr(skb); 229 struct ipv6hdr *ipv6h = ipv6_hdr(skb);
230 u8 nexthdr; 230 u8 nexthdr;
231 __be16 frag_off; 231 __be16 frag_off, oldlen, newlen;
232 int tcphoff; 232 int tcphoff;
233 int ret; 233 int ret;
234 234
@@ -244,7 +244,12 @@ tcpmss_tg6(struct sk_buff *skb, const struct xt_action_param *par)
244 return NF_DROP; 244 return NF_DROP;
245 if (ret > 0) { 245 if (ret > 0) {
246 ipv6h = ipv6_hdr(skb); 246 ipv6h = ipv6_hdr(skb);
247 ipv6h->payload_len = htons(ntohs(ipv6h->payload_len) + ret); 247 oldlen = ipv6h->payload_len;
248 newlen = htons(ntohs(oldlen) + ret);
249 if (skb->ip_summed == CHECKSUM_COMPLETE)
250 skb->csum = csum_add(csum_sub(skb->csum, oldlen),
251 newlen);
252 ipv6h->payload_len = newlen;
248 } 253 }
249 return XT_CONTINUE; 254 return XT_CONTINUE;
250} 255}
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 81dc1bb6e016..f1ffb34e253f 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2831,7 +2831,8 @@ static int netlink_dump(struct sock *sk)
2831 * reasonable static buffer based on the expected largest dump of a 2831 * reasonable static buffer based on the expected largest dump of a
2832 * single netdev. The outcome is MSG_TRUNC error. 2832 * single netdev. The outcome is MSG_TRUNC error.
2833 */ 2833 */
2834 skb_reserve(skb, skb_tailroom(skb) - alloc_size); 2834 if (!netlink_rx_is_mmaped(sk))
2835 skb_reserve(skb, skb_tailroom(skb) - alloc_size);
2835 netlink_skb_set_owner_r(skb, sk); 2836 netlink_skb_set_owner_r(skb, sk);
2836 2837
2837 len = cb->dump(skb, cb); 2838 len = cb->dump(skb, cb);
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index f53bf3b6558b..cf5b69ab1829 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -1095,17 +1095,6 @@ static unsigned int rfkill_fop_poll(struct file *file, poll_table *wait)
1095 return res; 1095 return res;
1096} 1096}
1097 1097
1098static bool rfkill_readable(struct rfkill_data *data)
1099{
1100 bool r;
1101
1102 mutex_lock(&data->mtx);
1103 r = !list_empty(&data->events);
1104 mutex_unlock(&data->mtx);
1105
1106 return r;
1107}
1108
1109static ssize_t rfkill_fop_read(struct file *file, char __user *buf, 1098static ssize_t rfkill_fop_read(struct file *file, char __user *buf,
1110 size_t count, loff_t *pos) 1099 size_t count, loff_t *pos)
1111{ 1100{
@@ -1122,8 +1111,11 @@ static ssize_t rfkill_fop_read(struct file *file, char __user *buf,
1122 goto out; 1111 goto out;
1123 } 1112 }
1124 mutex_unlock(&data->mtx); 1113 mutex_unlock(&data->mtx);
1114 /* since we re-check and it just compares pointers,
1115 * using !list_empty() without locking isn't a problem
1116 */
1125 ret = wait_event_interruptible(data->read_wait, 1117 ret = wait_event_interruptible(data->read_wait,
1126 rfkill_readable(data)); 1118 !list_empty(&data->events));
1127 mutex_lock(&data->mtx); 1119 mutex_lock(&data->mtx);
1128 1120
1129 if (ret) 1121 if (ret)
diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c
index f26bdea875c1..a1cd778240cd 100644
--- a/net/sched/sch_drr.c
+++ b/net/sched/sch_drr.c
@@ -403,6 +403,8 @@ static struct sk_buff *drr_dequeue(struct Qdisc *sch)
403 if (len <= cl->deficit) { 403 if (len <= cl->deficit) {
404 cl->deficit -= len; 404 cl->deficit -= len;
405 skb = qdisc_dequeue_peeked(cl->qdisc); 405 skb = qdisc_dequeue_peeked(cl->qdisc);
406 if (unlikely(skb == NULL))
407 goto out;
406 if (cl->qdisc->q.qlen == 0) 408 if (cl->qdisc->q.qlen == 0)
407 list_del(&cl->alist); 409 list_del(&cl->alist);
408 410
diff --git a/net/sctp/input.c b/net/sctp/input.c
index bf61dfb8e09e..49d2cc751386 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -935,15 +935,22 @@ static struct sctp_association *__sctp_lookup_association(
935 struct sctp_transport **pt) 935 struct sctp_transport **pt)
936{ 936{
937 struct sctp_transport *t; 937 struct sctp_transport *t;
938 struct sctp_association *asoc = NULL;
938 939
940 rcu_read_lock();
939 t = sctp_addrs_lookup_transport(net, local, peer); 941 t = sctp_addrs_lookup_transport(net, local, peer);
940 if (!t || t->dead) 942 if (!t || !sctp_transport_hold(t))
941 return NULL; 943 goto out;
942 944
943 sctp_association_hold(t->asoc); 945 asoc = t->asoc;
946 sctp_association_hold(asoc);
944 *pt = t; 947 *pt = t;
945 948
946 return t->asoc; 949 sctp_transport_put(t);
950
951out:
952 rcu_read_unlock();
953 return asoc;
947} 954}
948 955
949/* Look up an association. protected by RCU read lock */ 956/* Look up an association. protected by RCU read lock */
@@ -955,9 +962,7 @@ struct sctp_association *sctp_lookup_association(struct net *net,
955{ 962{
956 struct sctp_association *asoc; 963 struct sctp_association *asoc;
957 964
958 rcu_read_lock();
959 asoc = __sctp_lookup_association(net, laddr, paddr, transportp); 965 asoc = __sctp_lookup_association(net, laddr, paddr, transportp);
960 rcu_read_unlock();
961 966
962 return asoc; 967 return asoc;
963} 968}
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index 684c5b31563b..ded7d931a6a5 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -165,8 +165,6 @@ static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_associa
165 list_for_each_entry_rcu(transport, &assoc->peer.transport_addr_list, 165 list_for_each_entry_rcu(transport, &assoc->peer.transport_addr_list,
166 transports) { 166 transports) {
167 addr = &transport->ipaddr; 167 addr = &transport->ipaddr;
168 if (transport->dead)
169 continue;
170 168
171 af = sctp_get_af_specific(addr->sa.sa_family); 169 af = sctp_get_af_specific(addr->sa.sa_family);
172 if (af->cmp_addr(addr, primary)) { 170 if (af->cmp_addr(addr, primary)) {
@@ -380,6 +378,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
380 } 378 }
381 379
382 transport = (struct sctp_transport *)v; 380 transport = (struct sctp_transport *)v;
381 if (!sctp_transport_hold(transport))
382 return 0;
383 assoc = transport->asoc; 383 assoc = transport->asoc;
384 epb = &assoc->base; 384 epb = &assoc->base;
385 sk = epb->sk; 385 sk = epb->sk;
@@ -412,6 +412,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
412 sk->sk_rcvbuf); 412 sk->sk_rcvbuf);
413 seq_printf(seq, "\n"); 413 seq_printf(seq, "\n");
414 414
415 sctp_transport_put(transport);
416
415 return 0; 417 return 0;
416} 418}
417 419
@@ -489,12 +491,12 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
489 } 491 }
490 492
491 tsp = (struct sctp_transport *)v; 493 tsp = (struct sctp_transport *)v;
494 if (!sctp_transport_hold(tsp))
495 return 0;
492 assoc = tsp->asoc; 496 assoc = tsp->asoc;
493 497
494 list_for_each_entry_rcu(tsp, &assoc->peer.transport_addr_list, 498 list_for_each_entry_rcu(tsp, &assoc->peer.transport_addr_list,
495 transports) { 499 transports) {
496 if (tsp->dead)
497 continue;
498 /* 500 /*
499 * The remote address (ADDR) 501 * The remote address (ADDR)
500 */ 502 */
@@ -544,6 +546,8 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
544 seq_printf(seq, "\n"); 546 seq_printf(seq, "\n");
545 } 547 }
546 548
549 sctp_transport_put(tsp);
550
547 return 0; 551 return 0;
548} 552}
549 553
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 2e21384697c2..b5327bb77458 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -259,12 +259,6 @@ void sctp_generate_t3_rtx_event(unsigned long peer)
259 goto out_unlock; 259 goto out_unlock;
260 } 260 }
261 261
262 /* Is this transport really dead and just waiting around for
263 * the timer to let go of the reference?
264 */
265 if (transport->dead)
266 goto out_unlock;
267
268 /* Run through the state machine. */ 262 /* Run through the state machine. */
269 error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT, 263 error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
270 SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_T3_RTX), 264 SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_T3_RTX),
@@ -380,12 +374,6 @@ void sctp_generate_heartbeat_event(unsigned long data)
380 goto out_unlock; 374 goto out_unlock;
381 } 375 }
382 376
383 /* Is this structure just waiting around for us to actually
384 * get destroyed?
385 */
386 if (transport->dead)
387 goto out_unlock;
388
389 error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT, 377 error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
390 SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_HEARTBEAT), 378 SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_HEARTBEAT),
391 asoc->state, asoc->ep, asoc, 379 asoc->state, asoc->ep, asoc,
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 9bb80ec4c08f..5ca2ebfe0be8 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -6636,6 +6636,7 @@ static int sctp_msghdr_parse(const struct msghdr *msg, sctp_cmsgs_t *cmsgs)
6636 6636
6637 if (cmsgs->srinfo->sinfo_flags & 6637 if (cmsgs->srinfo->sinfo_flags &
6638 ~(SCTP_UNORDERED | SCTP_ADDR_OVER | 6638 ~(SCTP_UNORDERED | SCTP_ADDR_OVER |
6639 SCTP_SACK_IMMEDIATELY |
6639 SCTP_ABORT | SCTP_EOF)) 6640 SCTP_ABORT | SCTP_EOF))
6640 return -EINVAL; 6641 return -EINVAL;
6641 break; 6642 break;
@@ -6659,6 +6660,7 @@ static int sctp_msghdr_parse(const struct msghdr *msg, sctp_cmsgs_t *cmsgs)
6659 6660
6660 if (cmsgs->sinfo->snd_flags & 6661 if (cmsgs->sinfo->snd_flags &
6661 ~(SCTP_UNORDERED | SCTP_ADDR_OVER | 6662 ~(SCTP_UNORDERED | SCTP_ADDR_OVER |
6663 SCTP_SACK_IMMEDIATELY |
6662 SCTP_ABORT | SCTP_EOF)) 6664 SCTP_ABORT | SCTP_EOF))
6663 return -EINVAL; 6665 return -EINVAL;
6664 break; 6666 break;
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index aab9e3f29755..a431c14044a4 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -132,8 +132,6 @@ fail:
132 */ 132 */
133void sctp_transport_free(struct sctp_transport *transport) 133void sctp_transport_free(struct sctp_transport *transport)
134{ 134{
135 transport->dead = 1;
136
137 /* Try to delete the heartbeat timer. */ 135 /* Try to delete the heartbeat timer. */
138 if (del_timer(&transport->hb_timer)) 136 if (del_timer(&transport->hb_timer))
139 sctp_transport_put(transport); 137 sctp_transport_put(transport);
@@ -169,7 +167,7 @@ static void sctp_transport_destroy_rcu(struct rcu_head *head)
169 */ 167 */
170static void sctp_transport_destroy(struct sctp_transport *transport) 168static void sctp_transport_destroy(struct sctp_transport *transport)
171{ 169{
172 if (unlikely(!transport->dead)) { 170 if (unlikely(atomic_read(&transport->refcnt))) {
173 WARN(1, "Attempt to destroy undead transport %p!\n", transport); 171 WARN(1, "Attempt to destroy undead transport %p!\n", transport);
174 return; 172 return;
175 } 173 }
@@ -296,9 +294,9 @@ void sctp_transport_route(struct sctp_transport *transport,
296} 294}
297 295
298/* Hold a reference to a transport. */ 296/* Hold a reference to a transport. */
299void sctp_transport_hold(struct sctp_transport *transport) 297int sctp_transport_hold(struct sctp_transport *transport)
300{ 298{
301 atomic_inc(&transport->refcnt); 299 return atomic_add_unless(&transport->refcnt, 1, 0);
302} 300}
303 301
304/* Release a reference to a transport and clean up 302/* Release a reference to a transport and clean up
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index ebc661d3b6e3..47f7da58a7f0 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -20,6 +20,7 @@
20#include <linux/list.h> 20#include <linux/list.h>
21#include <linux/workqueue.h> 21#include <linux/workqueue.h>
22#include <linux/if_vlan.h> 22#include <linux/if_vlan.h>
23#include <linux/rtnetlink.h>
23#include <net/ip_fib.h> 24#include <net/ip_fib.h>
24#include <net/switchdev.h> 25#include <net/switchdev.h>
25 26
@@ -567,7 +568,6 @@ int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj,
567} 568}
568EXPORT_SYMBOL_GPL(switchdev_port_obj_dump); 569EXPORT_SYMBOL_GPL(switchdev_port_obj_dump);
569 570
570static DEFINE_MUTEX(switchdev_mutex);
571static RAW_NOTIFIER_HEAD(switchdev_notif_chain); 571static RAW_NOTIFIER_HEAD(switchdev_notif_chain);
572 572
573/** 573/**
@@ -582,9 +582,9 @@ int register_switchdev_notifier(struct notifier_block *nb)
582{ 582{
583 int err; 583 int err;
584 584
585 mutex_lock(&switchdev_mutex); 585 rtnl_lock();
586 err = raw_notifier_chain_register(&switchdev_notif_chain, nb); 586 err = raw_notifier_chain_register(&switchdev_notif_chain, nb);
587 mutex_unlock(&switchdev_mutex); 587 rtnl_unlock();
588 return err; 588 return err;
589} 589}
590EXPORT_SYMBOL_GPL(register_switchdev_notifier); 590EXPORT_SYMBOL_GPL(register_switchdev_notifier);
@@ -600,9 +600,9 @@ int unregister_switchdev_notifier(struct notifier_block *nb)
600{ 600{
601 int err; 601 int err;
602 602
603 mutex_lock(&switchdev_mutex); 603 rtnl_lock();
604 err = raw_notifier_chain_unregister(&switchdev_notif_chain, nb); 604 err = raw_notifier_chain_unregister(&switchdev_notif_chain, nb);
605 mutex_unlock(&switchdev_mutex); 605 rtnl_unlock();
606 return err; 606 return err;
607} 607}
608EXPORT_SYMBOL_GPL(unregister_switchdev_notifier); 608EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);
@@ -616,16 +616,17 @@ EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);
616 * Call all network notifier blocks. This should be called by driver 616 * Call all network notifier blocks. This should be called by driver
617 * when it needs to propagate hardware event. 617 * when it needs to propagate hardware event.
618 * Return values are same as for atomic_notifier_call_chain(). 618 * Return values are same as for atomic_notifier_call_chain().
619 * rtnl_lock must be held.
619 */ 620 */
620int call_switchdev_notifiers(unsigned long val, struct net_device *dev, 621int call_switchdev_notifiers(unsigned long val, struct net_device *dev,
621 struct switchdev_notifier_info *info) 622 struct switchdev_notifier_info *info)
622{ 623{
623 int err; 624 int err;
624 625
626 ASSERT_RTNL();
627
625 info->dev = dev; 628 info->dev = dev;
626 mutex_lock(&switchdev_mutex);
627 err = raw_notifier_call_chain(&switchdev_notif_chain, val, info); 629 err = raw_notifier_call_chain(&switchdev_notif_chain, val, info);
628 mutex_unlock(&switchdev_mutex);
629 return err; 630 return err;
630} 631}
631EXPORT_SYMBOL_GPL(call_switchdev_notifiers); 632EXPORT_SYMBOL_GPL(call_switchdev_notifiers);
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index 350cca33ee0a..69ee2eeef968 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -289,15 +289,14 @@ static void tipc_subscrb_rcv_cb(struct net *net, int conid,
289 struct sockaddr_tipc *addr, void *usr_data, 289 struct sockaddr_tipc *addr, void *usr_data,
290 void *buf, size_t len) 290 void *buf, size_t len)
291{ 291{
292 struct tipc_subscriber *subscriber = usr_data; 292 struct tipc_subscriber *subscrb = usr_data;
293 struct tipc_subscription *sub = NULL; 293 struct tipc_subscription *sub = NULL;
294 struct tipc_net *tn = net_generic(net, tipc_net_id); 294 struct tipc_net *tn = net_generic(net, tipc_net_id);
295 295
296 tipc_subscrp_create(net, (struct tipc_subscr *)buf, subscriber, &sub); 296 if (tipc_subscrp_create(net, (struct tipc_subscr *)buf, subscrb, &sub))
297 if (sub) 297 return tipc_conn_terminate(tn->topsrv, subscrb->conid);
298 tipc_nametbl_subscribe(sub); 298
299 else 299 tipc_nametbl_subscribe(sub);
300 tipc_conn_terminate(tn->topsrv, subscriber->conid);
301} 300}
302 301
303/* Handle one request to establish a new subscriber */ 302/* Handle one request to establish a new subscriber */
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index c5bf5ef2bf89..49d5093eb055 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2339,6 +2339,7 @@ again:
2339 2339
2340 if (signal_pending(current)) { 2340 if (signal_pending(current)) {
2341 err = sock_intr_errno(timeo); 2341 err = sock_intr_errno(timeo);
2342 scm_destroy(&scm);
2342 goto out; 2343 goto out;
2343 } 2344 }
2344 2345
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 3b0ce1c484a3..547ceecc0523 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -231,20 +231,22 @@ static const struct ieee80211_regdomain world_regdom = {
231 /* IEEE 802.11b/g, channels 1..11 */ 231 /* IEEE 802.11b/g, channels 1..11 */
232 REG_RULE(2412-10, 2462+10, 40, 6, 20, 0), 232 REG_RULE(2412-10, 2462+10, 40, 6, 20, 0),
233 /* IEEE 802.11b/g, channels 12..13. */ 233 /* IEEE 802.11b/g, channels 12..13. */
234 REG_RULE(2467-10, 2472+10, 40, 6, 20, 234 REG_RULE(2467-10, 2472+10, 20, 6, 20,
235 NL80211_RRF_NO_IR), 235 NL80211_RRF_NO_IR | NL80211_RRF_AUTO_BW),
236 /* IEEE 802.11 channel 14 - Only JP enables 236 /* IEEE 802.11 channel 14 - Only JP enables
237 * this and for 802.11b only */ 237 * this and for 802.11b only */
238 REG_RULE(2484-10, 2484+10, 20, 6, 20, 238 REG_RULE(2484-10, 2484+10, 20, 6, 20,
239 NL80211_RRF_NO_IR | 239 NL80211_RRF_NO_IR |
240 NL80211_RRF_NO_OFDM), 240 NL80211_RRF_NO_OFDM),
241 /* IEEE 802.11a, channel 36..48 */ 241 /* IEEE 802.11a, channel 36..48 */
242 REG_RULE(5180-10, 5240+10, 160, 6, 20, 242 REG_RULE(5180-10, 5240+10, 80, 6, 20,
243 NL80211_RRF_NO_IR), 243 NL80211_RRF_NO_IR |
244 NL80211_RRF_AUTO_BW),
244 245
245 /* IEEE 802.11a, channel 52..64 - DFS required */ 246 /* IEEE 802.11a, channel 52..64 - DFS required */
246 REG_RULE(5260-10, 5320+10, 160, 6, 20, 247 REG_RULE(5260-10, 5320+10, 80, 6, 20,
247 NL80211_RRF_NO_IR | 248 NL80211_RRF_NO_IR |
249 NL80211_RRF_AUTO_BW |
248 NL80211_RRF_DFS), 250 NL80211_RRF_DFS),
249 251
250 /* IEEE 802.11a, channel 100..144 - DFS required */ 252 /* IEEE 802.11a, channel 100..144 - DFS required */
@@ -2745,7 +2747,7 @@ static void print_rd_rules(const struct ieee80211_regdomain *rd)
2745 const struct ieee80211_power_rule *power_rule = NULL; 2747 const struct ieee80211_power_rule *power_rule = NULL;
2746 char bw[32], cac_time[32]; 2748 char bw[32], cac_time[32];
2747 2749
2748 pr_info(" (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)\n"); 2750 pr_debug(" (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)\n");
2749 2751
2750 for (i = 0; i < rd->n_reg_rules; i++) { 2752 for (i = 0; i < rd->n_reg_rules; i++) {
2751 reg_rule = &rd->reg_rules[i]; 2753 reg_rule = &rd->reg_rules[i];
@@ -2772,7 +2774,7 @@ static void print_rd_rules(const struct ieee80211_regdomain *rd)
2772 * in certain regions 2774 * in certain regions
2773 */ 2775 */
2774 if (power_rule->max_antenna_gain) 2776 if (power_rule->max_antenna_gain)
2775 pr_info(" (%d KHz - %d KHz @ %s), (%d mBi, %d mBm), (%s)\n", 2777 pr_debug(" (%d KHz - %d KHz @ %s), (%d mBi, %d mBm), (%s)\n",
2776 freq_range->start_freq_khz, 2778 freq_range->start_freq_khz,
2777 freq_range->end_freq_khz, 2779 freq_range->end_freq_khz,
2778 bw, 2780 bw,
@@ -2780,7 +2782,7 @@ static void print_rd_rules(const struct ieee80211_regdomain *rd)
2780 power_rule->max_eirp, 2782 power_rule->max_eirp,
2781 cac_time); 2783 cac_time);
2782 else 2784 else
2783 pr_info(" (%d KHz - %d KHz @ %s), (N/A, %d mBm), (%s)\n", 2785 pr_debug(" (%d KHz - %d KHz @ %s), (N/A, %d mBm), (%s)\n",
2784 freq_range->start_freq_khz, 2786 freq_range->start_freq_khz,
2785 freq_range->end_freq_khz, 2787 freq_range->end_freq_khz,
2786 bw, 2788 bw,
@@ -2813,35 +2815,35 @@ static void print_regdomain(const struct ieee80211_regdomain *rd)
2813 struct cfg80211_registered_device *rdev; 2815 struct cfg80211_registered_device *rdev;
2814 rdev = cfg80211_rdev_by_wiphy_idx(lr->wiphy_idx); 2816 rdev = cfg80211_rdev_by_wiphy_idx(lr->wiphy_idx);
2815 if (rdev) { 2817 if (rdev) {
2816 pr_info("Current regulatory domain updated by AP to: %c%c\n", 2818 pr_debug("Current regulatory domain updated by AP to: %c%c\n",
2817 rdev->country_ie_alpha2[0], 2819 rdev->country_ie_alpha2[0],
2818 rdev->country_ie_alpha2[1]); 2820 rdev->country_ie_alpha2[1]);
2819 } else 2821 } else
2820 pr_info("Current regulatory domain intersected:\n"); 2822 pr_debug("Current regulatory domain intersected:\n");
2821 } else 2823 } else
2822 pr_info("Current regulatory domain intersected:\n"); 2824 pr_debug("Current regulatory domain intersected:\n");
2823 } else if (is_world_regdom(rd->alpha2)) { 2825 } else if (is_world_regdom(rd->alpha2)) {
2824 pr_info("World regulatory domain updated:\n"); 2826 pr_debug("World regulatory domain updated:\n");
2825 } else { 2827 } else {
2826 if (is_unknown_alpha2(rd->alpha2)) 2828 if (is_unknown_alpha2(rd->alpha2))
2827 pr_info("Regulatory domain changed to driver built-in settings (unknown country)\n"); 2829 pr_debug("Regulatory domain changed to driver built-in settings (unknown country)\n");
2828 else { 2830 else {
2829 if (reg_request_cell_base(lr)) 2831 if (reg_request_cell_base(lr))
2830 pr_info("Regulatory domain changed to country: %c%c by Cell Station\n", 2832 pr_debug("Regulatory domain changed to country: %c%c by Cell Station\n",
2831 rd->alpha2[0], rd->alpha2[1]); 2833 rd->alpha2[0], rd->alpha2[1]);
2832 else 2834 else
2833 pr_info("Regulatory domain changed to country: %c%c\n", 2835 pr_debug("Regulatory domain changed to country: %c%c\n",
2834 rd->alpha2[0], rd->alpha2[1]); 2836 rd->alpha2[0], rd->alpha2[1]);
2835 } 2837 }
2836 } 2838 }
2837 2839
2838 pr_info(" DFS Master region: %s", reg_dfs_region_str(rd->dfs_region)); 2840 pr_debug(" DFS Master region: %s", reg_dfs_region_str(rd->dfs_region));
2839 print_rd_rules(rd); 2841 print_rd_rules(rd);
2840} 2842}
2841 2843
2842static void print_regdomain_info(const struct ieee80211_regdomain *rd) 2844static void print_regdomain_info(const struct ieee80211_regdomain *rd)
2843{ 2845{
2844 pr_info("Regulatory domain: %c%c\n", rd->alpha2[0], rd->alpha2[1]); 2846 pr_debug("Regulatory domain: %c%c\n", rd->alpha2[0], rd->alpha2[1]);
2845 print_rd_rules(rd); 2847 print_rd_rules(rd);
2846} 2848}
2847 2849
@@ -2862,7 +2864,8 @@ static int reg_set_rd_user(const struct ieee80211_regdomain *rd,
2862 return -EALREADY; 2864 return -EALREADY;
2863 2865
2864 if (!is_valid_rd(rd)) { 2866 if (!is_valid_rd(rd)) {
2865 pr_err("Invalid regulatory domain detected:\n"); 2867 pr_err("Invalid regulatory domain detected: %c%c\n",
2868 rd->alpha2[0], rd->alpha2[1]);
2866 print_regdomain_info(rd); 2869 print_regdomain_info(rd);
2867 return -EINVAL; 2870 return -EINVAL;
2868 } 2871 }
@@ -2898,7 +2901,8 @@ static int reg_set_rd_driver(const struct ieee80211_regdomain *rd,
2898 return -EALREADY; 2901 return -EALREADY;
2899 2902
2900 if (!is_valid_rd(rd)) { 2903 if (!is_valid_rd(rd)) {
2901 pr_err("Invalid regulatory domain detected:\n"); 2904 pr_err("Invalid regulatory domain detected: %c%c\n",
2905 rd->alpha2[0], rd->alpha2[1]);
2902 print_regdomain_info(rd); 2906 print_regdomain_info(rd);
2903 return -EINVAL; 2907 return -EINVAL;
2904 } 2908 }
@@ -2956,7 +2960,8 @@ static int reg_set_rd_country_ie(const struct ieee80211_regdomain *rd,
2956 */ 2960 */
2957 2961
2958 if (!is_valid_rd(rd)) { 2962 if (!is_valid_rd(rd)) {
2959 pr_err("Invalid regulatory domain detected:\n"); 2963 pr_err("Invalid regulatory domain detected: %c%c\n",
2964 rd->alpha2[0], rd->alpha2[1]);
2960 print_regdomain_info(rd); 2965 print_regdomain_info(rd);
2961 return -EINVAL; 2966 return -EINVAL;
2962 } 2967 }