aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2013-06-19 19:49:39 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-19 19:49:39 -0400
commitd98cae64e4a733ff377184d78aa0b1f2b54faede (patch)
treee973e3c93fe7e17741567ac3947f5197bc9d582d /net
parent646093a29f85630d8efe2aa38fa585d2c3ea2e46 (diff)
parent4067c666f2dccf56f5db5c182713e68c40d46013 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Conflicts: drivers/net/wireless/ath/ath9k/Kconfig drivers/net/xen-netback/netback.c net/batman-adv/bat_iv_ogm.c net/wireless/nl80211.c The ath9k Kconfig conflict was a change of a Kconfig option name right next to the deletion of another option. The xen-netback conflict was overlapping changes involving the handling of the notify list in xen_netbk_rx_action(). Batman conflict resolution provided by Antonio Quartulli, basically keep everything in both conflict hunks. The nl80211 conflict is a little more involved. In 'net' we added a dynamic memory allocation to nl80211_dump_wiphy() to fix a race that Linus reported. Meanwhile in 'net-next' the handlers were converted to use pre and post doit handlers which use a flag to determine whether to hold the RTNL mutex around the operation. However, the dump handlers to not use this logic. Instead they have to explicitly do the locking. There were apparent bugs in the conversion of nl80211_dump_wiphy() in that we were not dropping the RTNL mutex in all the return paths, and it seems we very much should be doing so. So I fixed that whilst handling the overlapping changes. To simplify the initial returns, I take the RTNL mutex after we try to allocate 'tb'. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/9p/client.c55
-rw-r--r--net/batman-adv/bat_iv_ogm.c87
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c4
-rw-r--r--net/batman-adv/sysfs.c5
-rw-r--r--net/bluetooth/hci_core.c21
-rw-r--r--net/bluetooth/l2cap_core.c73
-rw-r--r--net/bluetooth/mgmt.c23
-rw-r--r--net/bluetooth/smp.c4
-rw-r--r--net/bridge/br_multicast.c5
-rw-r--r--net/ceph/osd_client.c2
-rw-r--r--net/core/ethtool.c6
-rw-r--r--net/core/filter.c2
-rw-r--r--net/core/sock_diag.c9
-rw-r--r--net/ipv4/ip_tunnel.c4
-rw-r--r--net/ipv4/ip_vti.c3
-rw-r--r--net/ipv6/ndisc.c2
-rw-r--r--net/l2tp/l2tp_ppp.c6
-rw-r--r--net/mac80211/cfg.c6
-rw-r--r--net/mac80211/ieee80211_i.h5
-rw-r--r--net/mac80211/mlme.c87
-rw-r--r--net/mac80211/rate.c2
-rw-r--r--net/mac80211/util.c4
-rw-r--r--net/netfilter/ipvs/ip_vs_ctl.c1
-rw-r--r--net/netfilter/nfnetlink_acct.c7
-rw-r--r--net/netfilter/nfnetlink_cttimeout.c7
-rw-r--r--net/netfilter/nfnetlink_queue_core.c6
-rw-r--r--net/netfilter/xt_TCPMSS.c23
-rw-r--r--net/netfilter/xt_TCPOPTSTRIP.c6
-rw-r--r--net/netlink/af_netlink.c2
-rw-r--r--net/packet/af_packet.c5
-rw-r--r--net/sched/sch_api.c11
-rw-r--r--net/sctp/outqueue.c6
-rw-r--r--net/sctp/socket.c6
-rw-r--r--net/wireless/nl80211.c17
34 files changed, 356 insertions, 156 deletions
diff --git a/net/9p/client.c b/net/9p/client.c
index 8eb75425e6e6..addc116cecf0 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -562,36 +562,19 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req,
562 562
563 if (!p9_is_proto_dotl(c)) { 563 if (!p9_is_proto_dotl(c)) {
564 /* Error is reported in string format */ 564 /* Error is reported in string format */
565 uint16_t len; 565 int len;
566 /* 7 = header size for RERROR, 2 is the size of string len; */ 566 /* 7 = header size for RERROR; */
567 int inline_len = in_hdrlen - (7 + 2); 567 int inline_len = in_hdrlen - 7;
568 568
569 /* Read the size of error string */ 569 len = req->rc->size - req->rc->offset;
570 err = p9pdu_readf(req->rc, c->proto_version, "w", &len); 570 if (len > (P9_ZC_HDR_SZ - 7)) {
571 if (err) 571 err = -EFAULT;
572 goto out_err;
573
574 ename = kmalloc(len + 1, GFP_NOFS);
575 if (!ename) {
576 err = -ENOMEM;
577 goto out_err; 572 goto out_err;
578 } 573 }
579 if (len <= inline_len) {
580 /* We have error in protocol buffer itself */
581 if (pdu_read(req->rc, ename, len)) {
582 err = -EFAULT;
583 goto out_free;
584 574
585 } 575 ename = &req->rc->sdata[req->rc->offset];
586 } else { 576 if (len > inline_len) {
587 /* 577 /* We have error in external buffer */
588 * Part of the data is in user space buffer.
589 */
590 if (pdu_read(req->rc, ename, inline_len)) {
591 err = -EFAULT;
592 goto out_free;
593
594 }
595 if (kern_buf) { 578 if (kern_buf) {
596 memcpy(ename + inline_len, uidata, 579 memcpy(ename + inline_len, uidata,
597 len - inline_len); 580 len - inline_len);
@@ -600,19 +583,19 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req,
600 uidata, len - inline_len); 583 uidata, len - inline_len);
601 if (err) { 584 if (err) {
602 err = -EFAULT; 585 err = -EFAULT;
603 goto out_free; 586 goto out_err;
604 } 587 }
605 } 588 }
606 } 589 }
607 ename[len] = 0; 590 ename = NULL;
608 if (p9_is_proto_dotu(c)) { 591 err = p9pdu_readf(req->rc, c->proto_version, "s?d",
609 /* For dotu we also have error code */ 592 &ename, &ecode);
610 err = p9pdu_readf(req->rc, 593 if (err)
611 c->proto_version, "d", &ecode); 594 goto out_err;
612 if (err) 595
613 goto out_free; 596 if (p9_is_proto_dotu(c))
614 err = -ecode; 597 err = -ecode;
615 } 598
616 if (!err || !IS_ERR_VALUE(err)) { 599 if (!err || !IS_ERR_VALUE(err)) {
617 err = p9_errstr2errno(ename, strlen(ename)); 600 err = p9_errstr2errno(ename, strlen(ename));
618 601
@@ -628,8 +611,6 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req,
628 } 611 }
629 return err; 612 return err;
630 613
631out_free:
632 kfree(ename);
633out_err: 614out_err:
634 p9_debug(P9_DEBUG_ERROR, "couldn't parse error%d\n", err); 615 p9_debug(P9_DEBUG_ERROR, "couldn't parse error%d\n", err);
635 return err; 616 return err;
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index d07323b3e9b8..62da5278014a 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -70,6 +70,22 @@ static uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[])
70 70
71 return (uint8_t)(sum / count); 71 return (uint8_t)(sum / count);
72} 72}
73
74/*
75 * batadv_dup_status - duplicate status
76 * @BATADV_NO_DUP: the packet is a duplicate
77 * @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for the
78 * neighbor)
79 * @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor
80 * @BATADV_PROTECTED: originator is currently protected (after reboot)
81 */
82enum batadv_dup_status {
83 BATADV_NO_DUP = 0,
84 BATADV_ORIG_DUP,
85 BATADV_NEIGH_DUP,
86 BATADV_PROTECTED,
87};
88
73static struct batadv_neigh_node * 89static struct batadv_neigh_node *
74batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface, 90batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
75 const uint8_t *neigh_addr, 91 const uint8_t *neigh_addr,
@@ -723,7 +739,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
723 const struct batadv_ogm_packet *batadv_ogm_packet, 739 const struct batadv_ogm_packet *batadv_ogm_packet,
724 struct batadv_hard_iface *if_incoming, 740 struct batadv_hard_iface *if_incoming,
725 const unsigned char *tt_buff, 741 const unsigned char *tt_buff,
726 int is_duplicate) 742 enum batadv_dup_status dup_status)
727{ 743{
728 struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; 744 struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
729 struct batadv_neigh_node *router = NULL; 745 struct batadv_neigh_node *router = NULL;
@@ -749,7 +765,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
749 continue; 765 continue;
750 } 766 }
751 767
752 if (is_duplicate) 768 if (dup_status != BATADV_NO_DUP)
753 continue; 769 continue;
754 770
755 spin_lock_bh(&tmp_neigh_node->lq_update_lock); 771 spin_lock_bh(&tmp_neigh_node->lq_update_lock);
@@ -790,7 +806,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
790 neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv); 806 neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv);
791 spin_unlock_bh(&neigh_node->lq_update_lock); 807 spin_unlock_bh(&neigh_node->lq_update_lock);
792 808
793 if (!is_duplicate) { 809 if (dup_status == BATADV_NO_DUP) {
794 orig_node->last_ttl = batadv_ogm_packet->header.ttl; 810 orig_node->last_ttl = batadv_ogm_packet->header.ttl;
795 neigh_node->last_ttl = batadv_ogm_packet->header.ttl; 811 neigh_node->last_ttl = batadv_ogm_packet->header.ttl;
796 } 812 }
@@ -973,15 +989,16 @@ out:
973 return ret; 989 return ret;
974} 990}
975 991
976/* processes a batman packet for all interfaces, adjusts the sequence number and 992/**
977 * finds out whether it is a duplicate. 993 * batadv_iv_ogm_update_seqnos - process a batman packet for all interfaces,
978 * returns: 994 * adjust the sequence number and find out whether it is a duplicate
979 * 1 the packet is a duplicate 995 * @ethhdr: ethernet header of the packet
980 * 0 the packet has not yet been received 996 * @batadv_ogm_packet: OGM packet to be considered
981 * -1 the packet is old and has been received while the seqno window 997 * @if_incoming: interface on which the OGM packet was received
982 * was protected. Caller should drop it. 998 *
999 * Returns duplicate status as enum batadv_dup_status
983 */ 1000 */
984static int 1001static enum batadv_dup_status
985batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, 1002batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
986 const struct batadv_ogm_packet *batadv_ogm_packet, 1003 const struct batadv_ogm_packet *batadv_ogm_packet,
987 const struct batadv_hard_iface *if_incoming) 1004 const struct batadv_hard_iface *if_incoming)
@@ -989,17 +1006,18 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
989 struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 1006 struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
990 struct batadv_orig_node *orig_node; 1007 struct batadv_orig_node *orig_node;
991 struct batadv_neigh_node *tmp_neigh_node; 1008 struct batadv_neigh_node *tmp_neigh_node;
992 int is_duplicate = 0; 1009 int is_dup;
993 int32_t seq_diff; 1010 int32_t seq_diff;
994 int need_update = 0; 1011 int need_update = 0;
995 int set_mark, ret = -1; 1012 int set_mark;
1013 enum batadv_dup_status ret = BATADV_NO_DUP;
996 uint32_t seqno = ntohl(batadv_ogm_packet->seqno); 1014 uint32_t seqno = ntohl(batadv_ogm_packet->seqno);
997 uint8_t *neigh_addr; 1015 uint8_t *neigh_addr;
998 uint8_t packet_count; 1016 uint8_t packet_count;
999 1017
1000 orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig); 1018 orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig);
1001 if (!orig_node) 1019 if (!orig_node)
1002 return 0; 1020 return BATADV_NO_DUP;
1003 1021
1004 spin_lock_bh(&orig_node->ogm_cnt_lock); 1022 spin_lock_bh(&orig_node->ogm_cnt_lock);
1005 seq_diff = seqno - orig_node->last_real_seqno; 1023 seq_diff = seqno - orig_node->last_real_seqno;
@@ -1007,22 +1025,29 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
1007 /* signalize caller that the packet is to be dropped. */ 1025 /* signalize caller that the packet is to be dropped. */
1008 if (!hlist_empty(&orig_node->neigh_list) && 1026 if (!hlist_empty(&orig_node->neigh_list) &&
1009 batadv_window_protected(bat_priv, seq_diff, 1027 batadv_window_protected(bat_priv, seq_diff,
1010 &orig_node->batman_seqno_reset)) 1028 &orig_node->batman_seqno_reset)) {
1029 ret = BATADV_PROTECTED;
1011 goto out; 1030 goto out;
1031 }
1012 1032
1013 rcu_read_lock(); 1033 rcu_read_lock();
1014 hlist_for_each_entry_rcu(tmp_neigh_node, 1034 hlist_for_each_entry_rcu(tmp_neigh_node,
1015 &orig_node->neigh_list, list) { 1035 &orig_node->neigh_list, list) {
1016 is_duplicate |= batadv_test_bit(tmp_neigh_node->real_bits,
1017 orig_node->last_real_seqno,
1018 seqno);
1019
1020 neigh_addr = tmp_neigh_node->addr; 1036 neigh_addr = tmp_neigh_node->addr;
1037 is_dup = batadv_test_bit(tmp_neigh_node->real_bits,
1038 orig_node->last_real_seqno,
1039 seqno);
1040
1021 if (batadv_compare_eth(neigh_addr, ethhdr->h_source) && 1041 if (batadv_compare_eth(neigh_addr, ethhdr->h_source) &&
1022 tmp_neigh_node->if_incoming == if_incoming) 1042 tmp_neigh_node->if_incoming == if_incoming) {
1023 set_mark = 1; 1043 set_mark = 1;
1024 else 1044 if (is_dup)
1045 ret = BATADV_NEIGH_DUP;
1046 } else {
1025 set_mark = 0; 1047 set_mark = 0;
1048 if (is_dup && (ret != BATADV_NEIGH_DUP))
1049 ret = BATADV_ORIG_DUP;
1050 }
1026 1051
1027 /* if the window moved, set the update flag. */ 1052 /* if the window moved, set the update flag. */
1028 need_update |= batadv_bit_get_packet(bat_priv, 1053 need_update |= batadv_bit_get_packet(bat_priv,
@@ -1042,8 +1067,6 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
1042 orig_node->last_real_seqno = seqno; 1067 orig_node->last_real_seqno = seqno;
1043 } 1068 }
1044 1069
1045 ret = is_duplicate;
1046
1047out: 1070out:
1048 spin_unlock_bh(&orig_node->ogm_cnt_lock); 1071 spin_unlock_bh(&orig_node->ogm_cnt_lock);
1049 batadv_orig_node_free_ref(orig_node); 1072 batadv_orig_node_free_ref(orig_node);
@@ -1065,7 +1088,8 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1065 int is_bidirect; 1088 int is_bidirect;
1066 bool is_single_hop_neigh = false; 1089 bool is_single_hop_neigh = false;
1067 bool is_from_best_next_hop = false; 1090 bool is_from_best_next_hop = false;
1068 int is_duplicate, sameseq, simlar_ttl; 1091 int sameseq, similar_ttl;
1092 enum batadv_dup_status dup_status;
1069 uint32_t if_incoming_seqno; 1093 uint32_t if_incoming_seqno;
1070 uint8_t *prev_sender; 1094 uint8_t *prev_sender;
1071 1095
@@ -1192,10 +1216,10 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1192 if (!orig_node) 1216 if (!orig_node)
1193 return; 1217 return;
1194 1218
1195 is_duplicate = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet, 1219 dup_status = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet,
1196 if_incoming); 1220 if_incoming);
1197 1221
1198 if (is_duplicate == -1) { 1222 if (dup_status == BATADV_PROTECTED) {
1199 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1223 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1200 "Drop packet: packet within seqno protection time (sender: %pM)\n", 1224 "Drop packet: packet within seqno protection time (sender: %pM)\n",
1201 ethhdr->h_source); 1225 ethhdr->h_source);
@@ -1265,11 +1289,12 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1265 * seqno and similar ttl as the non-duplicate 1289 * seqno and similar ttl as the non-duplicate
1266 */ 1290 */
1267 sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno); 1291 sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno);
1268 simlar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl; 1292 similar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl;
1269 if (is_bidirect && (!is_duplicate || (sameseq && simlar_ttl))) 1293 if (is_bidirect && ((dup_status == BATADV_NO_DUP) ||
1294 (sameseq && similar_ttl)))
1270 batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr, 1295 batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
1271 batadv_ogm_packet, if_incoming, 1296 batadv_ogm_packet, if_incoming,
1272 tt_buff, is_duplicate); 1297 tt_buff, dup_status);
1273 1298
1274 /* is single hop (direct) neighbor */ 1299 /* is single hop (direct) neighbor */
1275 if (is_single_hop_neigh) { 1300 if (is_single_hop_neigh) {
@@ -1290,7 +1315,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1290 goto out_neigh; 1315 goto out_neigh;
1291 } 1316 }
1292 1317
1293 if (is_duplicate) { 1318 if (dup_status == BATADV_NEIGH_DUP) {
1294 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1319 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1295 "Drop packet: duplicate packet received\n"); 1320 "Drop packet: duplicate packet received\n");
1296 goto out_neigh; 1321 goto out_neigh;
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index e9d8e0b3c3d0..e14531f1ce1c 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1073,6 +1073,10 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
1073 group = htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN)); 1073 group = htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN));
1074 bat_priv->bla.claim_dest.group = group; 1074 bat_priv->bla.claim_dest.group = group;
1075 1075
1076 /* purge everything when bridge loop avoidance is turned off */
1077 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
1078 oldif = NULL;
1079
1076 if (!oldif) { 1080 if (!oldif) {
1077 batadv_bla_purge_claims(bat_priv, NULL, 1); 1081 batadv_bla_purge_claims(bat_priv, NULL, 1);
1078 batadv_bla_purge_backbone_gw(bat_priv, 1); 1082 batadv_bla_purge_backbone_gw(bat_priv, 1);
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 15a22efa9a67..929e304dacb2 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -582,10 +582,7 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
582 (strncmp(hard_iface->soft_iface->name, buff, IFNAMSIZ) == 0)) 582 (strncmp(hard_iface->soft_iface->name, buff, IFNAMSIZ) == 0))
583 goto out; 583 goto out;
584 584
585 if (!rtnl_trylock()) { 585 rtnl_lock();
586 ret = -ERESTARTSYS;
587 goto out;
588 }
589 586
590 if (status_tmp == BATADV_IF_NOT_IN_USE) { 587 if (status_tmp == BATADV_IF_NOT_IN_USE) {
591 batadv_hardif_disable_interface(hard_iface, 588 batadv_hardif_disable_interface(hard_iface,
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 33843c5c4939..ace5e55fe5a3 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -341,7 +341,6 @@ static void hci_init1_req(struct hci_request *req, unsigned long opt)
341 341
342static void bredr_setup(struct hci_request *req) 342static void bredr_setup(struct hci_request *req)
343{ 343{
344 struct hci_cp_delete_stored_link_key cp;
345 __le16 param; 344 __le16 param;
346 __u8 flt_type; 345 __u8 flt_type;
347 346
@@ -365,10 +364,6 @@ static void bredr_setup(struct hci_request *req)
365 param = __constant_cpu_to_le16(0x7d00); 364 param = __constant_cpu_to_le16(0x7d00);
366 hci_req_add(req, HCI_OP_WRITE_CA_TIMEOUT, 2, &param); 365 hci_req_add(req, HCI_OP_WRITE_CA_TIMEOUT, 2, &param);
367 366
368 bacpy(&cp.bdaddr, BDADDR_ANY);
369 cp.delete_all = 0x01;
370 hci_req_add(req, HCI_OP_DELETE_STORED_LINK_KEY, sizeof(cp), &cp);
371
372 /* Read page scan parameters */ 367 /* Read page scan parameters */
373 if (req->hdev->hci_ver > BLUETOOTH_VER_1_1) { 368 if (req->hdev->hci_ver > BLUETOOTH_VER_1_1) {
374 hci_req_add(req, HCI_OP_READ_PAGE_SCAN_ACTIVITY, 0, NULL); 369 hci_req_add(req, HCI_OP_READ_PAGE_SCAN_ACTIVITY, 0, NULL);
@@ -602,6 +597,16 @@ static void hci_init3_req(struct hci_request *req, unsigned long opt)
602 struct hci_dev *hdev = req->hdev; 597 struct hci_dev *hdev = req->hdev;
603 u8 p; 598 u8 p;
604 599
600 /* Only send HCI_Delete_Stored_Link_Key if it is supported */
601 if (hdev->commands[6] & 0x80) {
602 struct hci_cp_delete_stored_link_key cp;
603
604 bacpy(&cp.bdaddr, BDADDR_ANY);
605 cp.delete_all = 0x01;
606 hci_req_add(req, HCI_OP_DELETE_STORED_LINK_KEY,
607 sizeof(cp), &cp);
608 }
609
605 if (hdev->commands[5] & 0x10) 610 if (hdev->commands[5] & 0x10)
606 hci_setup_link_policy(req); 611 hci_setup_link_policy(req);
607 612
@@ -1555,11 +1560,15 @@ static const struct rfkill_ops hci_rfkill_ops = {
1555static void hci_power_on(struct work_struct *work) 1560static void hci_power_on(struct work_struct *work)
1556{ 1561{
1557 struct hci_dev *hdev = container_of(work, struct hci_dev, power_on); 1562 struct hci_dev *hdev = container_of(work, struct hci_dev, power_on);
1563 int err;
1558 1564
1559 BT_DBG("%s", hdev->name); 1565 BT_DBG("%s", hdev->name);
1560 1566
1561 if (hci_dev_open(hdev->id) < 0) 1567 err = hci_dev_open(hdev->id);
1568 if (err < 0) {
1569 mgmt_set_powered_failed(hdev, err);
1562 return; 1570 return;
1571 }
1563 1572
1564 if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) 1573 if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags))
1565 queue_delayed_work(hdev->req_workqueue, &hdev->power_off, 1574 queue_delayed_work(hdev->req_workqueue, &hdev->power_off,
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index a76d1ac0321b..4be6a264b475 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2852,6 +2852,9 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, u8 code,
2852 BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %u", 2852 BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %u",
2853 conn, code, ident, dlen); 2853 conn, code, ident, dlen);
2854 2854
2855 if (conn->mtu < L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE)
2856 return NULL;
2857
2855 len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen; 2858 len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen;
2856 count = min_t(unsigned int, conn->mtu, len); 2859 count = min_t(unsigned int, conn->mtu, len);
2857 2860
@@ -3677,10 +3680,14 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len)
3677} 3680}
3678 3681
3679static inline int l2cap_command_rej(struct l2cap_conn *conn, 3682static inline int l2cap_command_rej(struct l2cap_conn *conn,
3680 struct l2cap_cmd_hdr *cmd, u8 *data) 3683 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
3684 u8 *data)
3681{ 3685{
3682 struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data; 3686 struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data;
3683 3687
3688 if (cmd_len < sizeof(*rej))
3689 return -EPROTO;
3690
3684 if (rej->reason != L2CAP_REJ_NOT_UNDERSTOOD) 3691 if (rej->reason != L2CAP_REJ_NOT_UNDERSTOOD)
3685 return 0; 3692 return 0;
3686 3693
@@ -3829,11 +3836,14 @@ sendresp:
3829} 3836}
3830 3837
3831static int l2cap_connect_req(struct l2cap_conn *conn, 3838static int l2cap_connect_req(struct l2cap_conn *conn,
3832 struct l2cap_cmd_hdr *cmd, u8 *data) 3839 struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data)
3833{ 3840{
3834 struct hci_dev *hdev = conn->hcon->hdev; 3841 struct hci_dev *hdev = conn->hcon->hdev;
3835 struct hci_conn *hcon = conn->hcon; 3842 struct hci_conn *hcon = conn->hcon;
3836 3843
3844 if (cmd_len < sizeof(struct l2cap_conn_req))
3845 return -EPROTO;
3846
3837 hci_dev_lock(hdev); 3847 hci_dev_lock(hdev);
3838 if (test_bit(HCI_MGMT, &hdev->dev_flags) && 3848 if (test_bit(HCI_MGMT, &hdev->dev_flags) &&
3839 !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &hcon->flags)) 3849 !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &hcon->flags))
@@ -3847,7 +3857,8 @@ static int l2cap_connect_req(struct l2cap_conn *conn,
3847} 3857}
3848 3858
3849static int l2cap_connect_create_rsp(struct l2cap_conn *conn, 3859static int l2cap_connect_create_rsp(struct l2cap_conn *conn,
3850 struct l2cap_cmd_hdr *cmd, u8 *data) 3860 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
3861 u8 *data)
3851{ 3862{
3852 struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data; 3863 struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data;
3853 u16 scid, dcid, result, status; 3864 u16 scid, dcid, result, status;
@@ -3855,6 +3866,9 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,
3855 u8 req[128]; 3866 u8 req[128];
3856 int err; 3867 int err;
3857 3868
3869 if (cmd_len < sizeof(*rsp))
3870 return -EPROTO;
3871
3858 scid = __le16_to_cpu(rsp->scid); 3872 scid = __le16_to_cpu(rsp->scid);
3859 dcid = __le16_to_cpu(rsp->dcid); 3873 dcid = __le16_to_cpu(rsp->dcid);
3860 result = __le16_to_cpu(rsp->result); 3874 result = __le16_to_cpu(rsp->result);
@@ -3952,6 +3966,9 @@ static inline int l2cap_config_req(struct l2cap_conn *conn,
3952 struct l2cap_chan *chan; 3966 struct l2cap_chan *chan;
3953 int len, err = 0; 3967 int len, err = 0;
3954 3968
3969 if (cmd_len < sizeof(*req))
3970 return -EPROTO;
3971
3955 dcid = __le16_to_cpu(req->dcid); 3972 dcid = __le16_to_cpu(req->dcid);
3956 flags = __le16_to_cpu(req->flags); 3973 flags = __le16_to_cpu(req->flags);
3957 3974
@@ -3975,7 +3992,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn,
3975 3992
3976 /* Reject if config buffer is too small. */ 3993 /* Reject if config buffer is too small. */
3977 len = cmd_len - sizeof(*req); 3994 len = cmd_len - sizeof(*req);
3978 if (len < 0 || chan->conf_len + len > sizeof(chan->conf_req)) { 3995 if (chan->conf_len + len > sizeof(chan->conf_req)) {
3979 l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, 3996 l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP,
3980 l2cap_build_conf_rsp(chan, rsp, 3997 l2cap_build_conf_rsp(chan, rsp,
3981 L2CAP_CONF_REJECT, flags), rsp); 3998 L2CAP_CONF_REJECT, flags), rsp);
@@ -4053,14 +4070,18 @@ unlock:
4053} 4070}
4054 4071
4055static inline int l2cap_config_rsp(struct l2cap_conn *conn, 4072static inline int l2cap_config_rsp(struct l2cap_conn *conn,
4056 struct l2cap_cmd_hdr *cmd, u8 *data) 4073 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
4074 u8 *data)
4057{ 4075{
4058 struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data; 4076 struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data;
4059 u16 scid, flags, result; 4077 u16 scid, flags, result;
4060 struct l2cap_chan *chan; 4078 struct l2cap_chan *chan;
4061 int len = le16_to_cpu(cmd->len) - sizeof(*rsp); 4079 int len = cmd_len - sizeof(*rsp);
4062 int err = 0; 4080 int err = 0;
4063 4081
4082 if (cmd_len < sizeof(*rsp))
4083 return -EPROTO;
4084
4064 scid = __le16_to_cpu(rsp->scid); 4085 scid = __le16_to_cpu(rsp->scid);
4065 flags = __le16_to_cpu(rsp->flags); 4086 flags = __le16_to_cpu(rsp->flags);
4066 result = __le16_to_cpu(rsp->result); 4087 result = __le16_to_cpu(rsp->result);
@@ -4161,7 +4182,8 @@ done:
4161} 4182}
4162 4183
4163static inline int l2cap_disconnect_req(struct l2cap_conn *conn, 4184static inline int l2cap_disconnect_req(struct l2cap_conn *conn,
4164 struct l2cap_cmd_hdr *cmd, u8 *data) 4185 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
4186 u8 *data)
4165{ 4187{
4166 struct l2cap_disconn_req *req = (struct l2cap_disconn_req *) data; 4188 struct l2cap_disconn_req *req = (struct l2cap_disconn_req *) data;
4167 struct l2cap_disconn_rsp rsp; 4189 struct l2cap_disconn_rsp rsp;
@@ -4169,6 +4191,9 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn,
4169 struct l2cap_chan *chan; 4191 struct l2cap_chan *chan;
4170 struct sock *sk; 4192 struct sock *sk;
4171 4193
4194 if (cmd_len != sizeof(*req))
4195 return -EPROTO;
4196
4172 scid = __le16_to_cpu(req->scid); 4197 scid = __le16_to_cpu(req->scid);
4173 dcid = __le16_to_cpu(req->dcid); 4198 dcid = __le16_to_cpu(req->dcid);
4174 4199
@@ -4208,12 +4233,16 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn,
4208} 4233}
4209 4234
4210static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, 4235static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn,
4211 struct l2cap_cmd_hdr *cmd, u8 *data) 4236 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
4237 u8 *data)
4212{ 4238{
4213 struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data; 4239 struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data;
4214 u16 dcid, scid; 4240 u16 dcid, scid;
4215 struct l2cap_chan *chan; 4241 struct l2cap_chan *chan;
4216 4242
4243 if (cmd_len != sizeof(*rsp))
4244 return -EPROTO;
4245
4217 scid = __le16_to_cpu(rsp->scid); 4246 scid = __le16_to_cpu(rsp->scid);
4218 dcid = __le16_to_cpu(rsp->dcid); 4247 dcid = __le16_to_cpu(rsp->dcid);
4219 4248
@@ -4243,11 +4272,15 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn,
4243} 4272}
4244 4273
4245static inline int l2cap_information_req(struct l2cap_conn *conn, 4274static inline int l2cap_information_req(struct l2cap_conn *conn,
4246 struct l2cap_cmd_hdr *cmd, u8 *data) 4275 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
4276 u8 *data)
4247{ 4277{
4248 struct l2cap_info_req *req = (struct l2cap_info_req *) data; 4278 struct l2cap_info_req *req = (struct l2cap_info_req *) data;
4249 u16 type; 4279 u16 type;
4250 4280
4281 if (cmd_len != sizeof(*req))
4282 return -EPROTO;
4283
4251 type = __le16_to_cpu(req->type); 4284 type = __le16_to_cpu(req->type);
4252 4285
4253 BT_DBG("type 0x%4.4x", type); 4286 BT_DBG("type 0x%4.4x", type);
@@ -4294,11 +4327,15 @@ static inline int l2cap_information_req(struct l2cap_conn *conn,
4294} 4327}
4295 4328
4296static inline int l2cap_information_rsp(struct l2cap_conn *conn, 4329static inline int l2cap_information_rsp(struct l2cap_conn *conn,
4297 struct l2cap_cmd_hdr *cmd, u8 *data) 4330 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
4331 u8 *data)
4298{ 4332{
4299 struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) data; 4333 struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) data;
4300 u16 type, result; 4334 u16 type, result;
4301 4335
4336 if (cmd_len != sizeof(*rsp))
4337 return -EPROTO;
4338
4302 type = __le16_to_cpu(rsp->type); 4339 type = __le16_to_cpu(rsp->type);
4303 result = __le16_to_cpu(rsp->result); 4340 result = __le16_to_cpu(rsp->result);
4304 4341
@@ -5164,16 +5201,16 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
5164 5201
5165 switch (cmd->code) { 5202 switch (cmd->code) {
5166 case L2CAP_COMMAND_REJ: 5203 case L2CAP_COMMAND_REJ:
5167 l2cap_command_rej(conn, cmd, data); 5204 l2cap_command_rej(conn, cmd, cmd_len, data);
5168 break; 5205 break;
5169 5206
5170 case L2CAP_CONN_REQ: 5207 case L2CAP_CONN_REQ:
5171 err = l2cap_connect_req(conn, cmd, data); 5208 err = l2cap_connect_req(conn, cmd, cmd_len, data);
5172 break; 5209 break;
5173 5210
5174 case L2CAP_CONN_RSP: 5211 case L2CAP_CONN_RSP:
5175 case L2CAP_CREATE_CHAN_RSP: 5212 case L2CAP_CREATE_CHAN_RSP:
5176 err = l2cap_connect_create_rsp(conn, cmd, data); 5213 err = l2cap_connect_create_rsp(conn, cmd, cmd_len, data);
5177 break; 5214 break;
5178 5215
5179 case L2CAP_CONF_REQ: 5216 case L2CAP_CONF_REQ:
@@ -5181,15 +5218,15 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
5181 break; 5218 break;
5182 5219
5183 case L2CAP_CONF_RSP: 5220 case L2CAP_CONF_RSP:
5184 err = l2cap_config_rsp(conn, cmd, data); 5221 err = l2cap_config_rsp(conn, cmd, cmd_len, data);
5185 break; 5222 break;
5186 5223
5187 case L2CAP_DISCONN_REQ: 5224 case L2CAP_DISCONN_REQ:
5188 err = l2cap_disconnect_req(conn, cmd, data); 5225 err = l2cap_disconnect_req(conn, cmd, cmd_len, data);
5189 break; 5226 break;
5190 5227
5191 case L2CAP_DISCONN_RSP: 5228 case L2CAP_DISCONN_RSP:
5192 err = l2cap_disconnect_rsp(conn, cmd, data); 5229 err = l2cap_disconnect_rsp(conn, cmd, cmd_len, data);
5193 break; 5230 break;
5194 5231
5195 case L2CAP_ECHO_REQ: 5232 case L2CAP_ECHO_REQ:
@@ -5200,11 +5237,11 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
5200 break; 5237 break;
5201 5238
5202 case L2CAP_INFO_REQ: 5239 case L2CAP_INFO_REQ:
5203 err = l2cap_information_req(conn, cmd, data); 5240 err = l2cap_information_req(conn, cmd, cmd_len, data);
5204 break; 5241 break;
5205 5242
5206 case L2CAP_INFO_RSP: 5243 case L2CAP_INFO_RSP:
5207 err = l2cap_information_rsp(conn, cmd, data); 5244 err = l2cap_information_rsp(conn, cmd, cmd_len, data);
5208 break; 5245 break;
5209 5246
5210 case L2CAP_CREATE_CHAN_REQ: 5247 case L2CAP_CREATE_CHAN_REQ:
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 35fef22703e9..f8ecbc70293d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2700,7 +2700,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
2700 break; 2700 break;
2701 2701
2702 case DISCOV_TYPE_LE: 2702 case DISCOV_TYPE_LE:
2703 if (!lmp_host_le_capable(hdev)) { 2703 if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) {
2704 err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY, 2704 err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
2705 MGMT_STATUS_NOT_SUPPORTED); 2705 MGMT_STATUS_NOT_SUPPORTED);
2706 mgmt_pending_remove(cmd); 2706 mgmt_pending_remove(cmd);
@@ -3418,6 +3418,27 @@ new_settings:
3418 return err; 3418 return err;
3419} 3419}
3420 3420
3421int mgmt_set_powered_failed(struct hci_dev *hdev, int err)
3422{
3423 struct pending_cmd *cmd;
3424 u8 status;
3425
3426 cmd = mgmt_pending_find(MGMT_OP_SET_POWERED, hdev);
3427 if (!cmd)
3428 return -ENOENT;
3429
3430 if (err == -ERFKILL)
3431 status = MGMT_STATUS_RFKILLED;
3432 else
3433 status = MGMT_STATUS_FAILED;
3434
3435 err = cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_POWERED, status);
3436
3437 mgmt_pending_remove(cmd);
3438
3439 return err;
3440}
3441
3421int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) 3442int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable)
3422{ 3443{
3423 struct cmd_lookup match = { NULL, hdev }; 3444 struct cmd_lookup match = { NULL, hdev };
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index b2296d3857a0..b5562abdd6e0 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -770,7 +770,7 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
770 770
771 BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level); 771 BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level);
772 772
773 if (!lmp_host_le_capable(hcon->hdev)) 773 if (!test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags))
774 return 1; 774 return 1;
775 775
776 if (sec_level == BT_SECURITY_LOW) 776 if (sec_level == BT_SECURITY_LOW)
@@ -851,7 +851,7 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)
851 __u8 reason; 851 __u8 reason;
852 int err = 0; 852 int err = 0;
853 853
854 if (!lmp_host_le_capable(conn->hcon->hdev)) { 854 if (!test_bit(HCI_LE_ENABLED, &conn->hcon->hdev->dev_flags)) {
855 err = -ENOTSUPP; 855 err = -ENOTSUPP;
856 reason = SMP_PAIRING_NOTSUPP; 856 reason = SMP_PAIRING_NOTSUPP;
857 goto done; 857 goto done;
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 37a467697967..31952a103949 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -467,8 +467,9 @@ static struct sk_buff *br_ip6_multicast_alloc_query(struct net_bridge *br,
467 skb_set_transport_header(skb, skb->len); 467 skb_set_transport_header(skb, skb->len);
468 mldq = (struct mld_msg *) icmp6_hdr(skb); 468 mldq = (struct mld_msg *) icmp6_hdr(skb);
469 469
470 interval = ipv6_addr_any(group) ? br->multicast_last_member_interval : 470 interval = ipv6_addr_any(group) ?
471 br->multicast_query_response_interval; 471 br->multicast_query_response_interval :
472 br->multicast_last_member_interval;
472 473
473 mldq->mld_type = ICMPV6_MGM_QUERY; 474 mldq->mld_type = ICMPV6_MGM_QUERY;
474 mldq->mld_code = 0; 475 mldq->mld_code = 0;
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index d5953b87918c..3a246a6cab47 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1675,13 +1675,13 @@ static void kick_requests(struct ceph_osd_client *osdc, int force_resend)
1675 __register_request(osdc, req); 1675 __register_request(osdc, req);
1676 __unregister_linger_request(osdc, req); 1676 __unregister_linger_request(osdc, req);
1677 } 1677 }
1678 reset_changed_osds(osdc);
1678 mutex_unlock(&osdc->request_mutex); 1679 mutex_unlock(&osdc->request_mutex);
1679 1680
1680 if (needmap) { 1681 if (needmap) {
1681 dout("%d requests for down osds, need new map\n", needmap); 1682 dout("%d requests for down osds, need new map\n", needmap);
1682 ceph_monc_request_next_osdmap(&osdc->client->monc); 1683 ceph_monc_request_next_osdmap(&osdc->client->monc);
1683 } 1684 }
1684 reset_changed_osds(osdc);
1685} 1685}
1686 1686
1687 1687
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index cd23d314d68a..9255bbdf81ff 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -60,10 +60,10 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN]
60 [NETIF_F_IPV6_CSUM_BIT] = "tx-checksum-ipv6", 60 [NETIF_F_IPV6_CSUM_BIT] = "tx-checksum-ipv6",
61 [NETIF_F_HIGHDMA_BIT] = "highdma", 61 [NETIF_F_HIGHDMA_BIT] = "highdma",
62 [NETIF_F_FRAGLIST_BIT] = "tx-scatter-gather-fraglist", 62 [NETIF_F_FRAGLIST_BIT] = "tx-scatter-gather-fraglist",
63 [NETIF_F_HW_VLAN_CTAG_TX_BIT] = "tx-vlan-ctag-hw-insert", 63 [NETIF_F_HW_VLAN_CTAG_TX_BIT] = "tx-vlan-hw-insert",
64 64
65 [NETIF_F_HW_VLAN_CTAG_RX_BIT] = "rx-vlan-ctag-hw-parse", 65 [NETIF_F_HW_VLAN_CTAG_RX_BIT] = "rx-vlan-hw-parse",
66 [NETIF_F_HW_VLAN_CTAG_FILTER_BIT] = "rx-vlan-ctag-filter", 66 [NETIF_F_HW_VLAN_CTAG_FILTER_BIT] = "rx-vlan-filter",
67 [NETIF_F_HW_VLAN_STAG_TX_BIT] = "tx-vlan-stag-hw-insert", 67 [NETIF_F_HW_VLAN_STAG_TX_BIT] = "tx-vlan-stag-hw-insert",
68 [NETIF_F_HW_VLAN_STAG_RX_BIT] = "rx-vlan-stag-hw-parse", 68 [NETIF_F_HW_VLAN_STAG_RX_BIT] = "rx-vlan-stag-hw-parse",
69 [NETIF_F_HW_VLAN_STAG_FILTER_BIT] = "rx-vlan-stag-filter", 69 [NETIF_F_HW_VLAN_STAG_FILTER_BIT] = "rx-vlan-stag-filter",
diff --git a/net/core/filter.c b/net/core/filter.c
index dad2a178f9f8..6438f29ff266 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -778,7 +778,7 @@ int sk_detach_filter(struct sock *sk)
778} 778}
779EXPORT_SYMBOL_GPL(sk_detach_filter); 779EXPORT_SYMBOL_GPL(sk_detach_filter);
780 780
781static void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to) 781void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to)
782{ 782{
783 static const u16 decodes[] = { 783 static const u16 decodes[] = {
784 [BPF_S_ALU_ADD_K] = BPF_ALU|BPF_ADD|BPF_K, 784 [BPF_S_ALU_ADD_K] = BPF_ALU|BPF_ADD|BPF_K,
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index d5bef0b0f639..a0e9cf6379de 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -73,8 +73,13 @@ int sock_diag_put_filterinfo(struct user_namespace *user_ns, struct sock *sk,
73 goto out; 73 goto out;
74 } 74 }
75 75
76 if (filter) 76 if (filter) {
77 memcpy(nla_data(attr), filter->insns, len); 77 struct sock_filter *fb = (struct sock_filter *)nla_data(attr);
78 int i;
79
80 for (i = 0; i < filter->len; i++, fb++)
81 sk_decode_filter(&filter->insns[i], fb);
82 }
78 83
79out: 84out:
80 rcu_read_unlock(); 85 rcu_read_unlock();
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 7c79cf8ad449..e189db409b0e 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -853,7 +853,7 @@ void ip_tunnel_dellink(struct net_device *dev, struct list_head *head)
853} 853}
854EXPORT_SYMBOL_GPL(ip_tunnel_dellink); 854EXPORT_SYMBOL_GPL(ip_tunnel_dellink);
855 855
856int __net_init ip_tunnel_init_net(struct net *net, int ip_tnl_net_id, 856int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
857 struct rtnl_link_ops *ops, char *devname) 857 struct rtnl_link_ops *ops, char *devname)
858{ 858{
859 struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id); 859 struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id);
@@ -899,7 +899,7 @@ static void ip_tunnel_destroy(struct ip_tunnel_net *itn, struct list_head *head)
899 unregister_netdevice_queue(itn->fb_tunnel_dev, head); 899 unregister_netdevice_queue(itn->fb_tunnel_dev, head);
900} 900}
901 901
902void __net_exit ip_tunnel_delete_net(struct ip_tunnel_net *itn) 902void ip_tunnel_delete_net(struct ip_tunnel_net *itn)
903{ 903{
904 LIST_HEAD(list); 904 LIST_HEAD(list);
905 905
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 9d2bdb2c1d3f..c118f6b576bb 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -361,8 +361,7 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
361 tunnel->err_count = 0; 361 tunnel->err_count = 0;
362 } 362 }
363 363
364 IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED | 364 memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
365 IPSKB_REROUTED);
366 skb_dst_drop(skb); 365 skb_dst_drop(skb);
367 skb_dst_set(skb, &rt->dst); 366 skb_dst_set(skb, &rt->dst);
368 nf_reset(skb); 367 nf_reset(skb);
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 781dd3c99680..b3b5730b48c5 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1494,7 +1494,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
1494 */ 1494 */
1495 1495
1496 if (ha) 1496 if (ha)
1497 ndisc_fill_addr_option(skb, ND_OPT_TARGET_LL_ADDR, ha); 1497 ndisc_fill_addr_option(buff, ND_OPT_TARGET_LL_ADDR, ha);
1498 1498
1499 /* 1499 /*
1500 * build redirect option and copy skb over to the new packet. 1500 * build redirect option and copy skb over to the new packet.
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 637a341c1e2d..8dec6876dc50 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -346,19 +346,19 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh
346 skb_put(skb, 2); 346 skb_put(skb, 2);
347 347
348 /* Copy user data into skb */ 348 /* Copy user data into skb */
349 error = memcpy_fromiovec(skb->data, m->msg_iov, total_len); 349 error = memcpy_fromiovec(skb_put(skb, total_len), m->msg_iov,
350 total_len);
350 if (error < 0) { 351 if (error < 0) {
351 kfree_skb(skb); 352 kfree_skb(skb);
352 goto error_put_sess_tun; 353 goto error_put_sess_tun;
353 } 354 }
354 skb_put(skb, total_len);
355 355
356 l2tp_xmit_skb(session, skb, session->hdr_len); 356 l2tp_xmit_skb(session, skb, session->hdr_len);
357 357
358 sock_put(ps->tunnel_sock); 358 sock_put(ps->tunnel_sock);
359 sock_put(sk); 359 sock_put(sk);
360 360
361 return error; 361 return total_len;
362 362
363error_put_sess_tun: 363error_put_sess_tun:
364 sock_put(ps->tunnel_sock); 364 sock_put(ps->tunnel_sock);
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 30622101d3b5..a1c6e1ceede8 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1071,6 +1071,12 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
1071 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); 1071 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1072 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); 1072 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
1073 1073
1074 if (sdata->wdev.cac_started) {
1075 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
1076 cfg80211_cac_event(sdata->dev, NL80211_RADAR_CAC_ABORTED,
1077 GFP_KERNEL);
1078 }
1079
1074 drv_stop_ap(sdata->local, sdata); 1080 drv_stop_ap(sdata->local, sdata);
1075 1081
1076 /* free all potentially still buffered bcast frames */ 1082 /* free all potentially still buffered bcast frames */
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 9eed6f1d1614..923e1772e8f3 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1512,10 +1512,11 @@ static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
1512 ieee80211_tx_skb_tid(sdata, skb, 7); 1512 ieee80211_tx_skb_tid(sdata, skb, 7);
1513} 1513}
1514 1514
1515u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, bool action, 1515u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
1516 struct ieee802_11_elems *elems, 1516 struct ieee802_11_elems *elems,
1517 u64 filter, u32 crc); 1517 u64 filter, u32 crc);
1518static inline void ieee802_11_parse_elems(u8 *start, size_t len, bool action, 1518static inline void ieee802_11_parse_elems(const u8 *start, size_t len,
1519 bool action,
1519 struct ieee802_11_elems *elems) 1520 struct ieee802_11_elems *elems)
1520{ 1521{
1521 ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0); 1522 ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index f44f4caa69ee..118540b16729 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -2486,8 +2486,11 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
2486 u16 capab_info, aid; 2486 u16 capab_info, aid;
2487 struct ieee802_11_elems elems; 2487 struct ieee802_11_elems elems;
2488 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; 2488 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
2489 const struct cfg80211_bss_ies *bss_ies = NULL;
2490 struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data;
2489 u32 changed = 0; 2491 u32 changed = 0;
2490 int err; 2492 int err;
2493 bool ret;
2491 2494
2492 /* AssocResp and ReassocResp have identical structure */ 2495 /* AssocResp and ReassocResp have identical structure */
2493 2496
@@ -2519,21 +2522,86 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
2519 ifmgd->aid = aid; 2522 ifmgd->aid = aid;
2520 2523
2521 /* 2524 /*
2525 * Some APs are erroneously not including some information in their
2526 * (re)association response frames. Try to recover by using the data
2527 * from the beacon or probe response. This seems to afflict mobile
2528 * 2G/3G/4G wifi routers, reported models include the "Onda PN51T",
2529 * "Vodafone PocketWiFi 2", "ZTE MF60" and a similar T-Mobile device.
2530 */
2531 if ((assoc_data->wmm && !elems.wmm_param) ||
2532 (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT) &&
2533 (!elems.ht_cap_elem || !elems.ht_operation)) ||
2534 (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) &&
2535 (!elems.vht_cap_elem || !elems.vht_operation))) {
2536 const struct cfg80211_bss_ies *ies;
2537 struct ieee802_11_elems bss_elems;
2538
2539 rcu_read_lock();
2540 ies = rcu_dereference(cbss->ies);
2541 if (ies)
2542 bss_ies = kmemdup(ies, sizeof(*ies) + ies->len,
2543 GFP_ATOMIC);
2544 rcu_read_unlock();
2545 if (!bss_ies)
2546 return false;
2547
2548 ieee802_11_parse_elems(bss_ies->data, bss_ies->len,
2549 false, &bss_elems);
2550 if (assoc_data->wmm &&
2551 !elems.wmm_param && bss_elems.wmm_param) {
2552 elems.wmm_param = bss_elems.wmm_param;
2553 sdata_info(sdata,
2554 "AP bug: WMM param missing from AssocResp\n");
2555 }
2556
2557 /*
2558 * Also check if we requested HT/VHT, otherwise the AP doesn't
2559 * have to include the IEs in the (re)association response.
2560 */
2561 if (!elems.ht_cap_elem && bss_elems.ht_cap_elem &&
2562 !(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) {
2563 elems.ht_cap_elem = bss_elems.ht_cap_elem;
2564 sdata_info(sdata,
2565 "AP bug: HT capability missing from AssocResp\n");
2566 }
2567 if (!elems.ht_operation && bss_elems.ht_operation &&
2568 !(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) {
2569 elems.ht_operation = bss_elems.ht_operation;
2570 sdata_info(sdata,
2571 "AP bug: HT operation missing from AssocResp\n");
2572 }
2573 if (!elems.vht_cap_elem && bss_elems.vht_cap_elem &&
2574 !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) {
2575 elems.vht_cap_elem = bss_elems.vht_cap_elem;
2576 sdata_info(sdata,
2577 "AP bug: VHT capa missing from AssocResp\n");
2578 }
2579 if (!elems.vht_operation && bss_elems.vht_operation &&
2580 !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) {
2581 elems.vht_operation = bss_elems.vht_operation;
2582 sdata_info(sdata,
2583 "AP bug: VHT operation missing from AssocResp\n");
2584 }
2585 }
2586
2587 /*
2522 * We previously checked these in the beacon/probe response, so 2588 * We previously checked these in the beacon/probe response, so
2523 * they should be present here. This is just a safety net. 2589 * they should be present here. This is just a safety net.
2524 */ 2590 */
2525 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT) && 2591 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT) &&
2526 (!elems.wmm_param || !elems.ht_cap_elem || !elems.ht_operation)) { 2592 (!elems.wmm_param || !elems.ht_cap_elem || !elems.ht_operation)) {
2527 sdata_info(sdata, 2593 sdata_info(sdata,
2528 "HT AP is missing WMM params or HT capability/operation in AssocResp\n"); 2594 "HT AP is missing WMM params or HT capability/operation\n");
2529 return false; 2595 ret = false;
2596 goto out;
2530 } 2597 }
2531 2598
2532 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) && 2599 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT) &&
2533 (!elems.vht_cap_elem || !elems.vht_operation)) { 2600 (!elems.vht_cap_elem || !elems.vht_operation)) {
2534 sdata_info(sdata, 2601 sdata_info(sdata,
2535 "VHT AP is missing VHT capability/operation in AssocResp\n"); 2602 "VHT AP is missing VHT capability/operation\n");
2536 return false; 2603 ret = false;
2604 goto out;
2537 } 2605 }
2538 2606
2539 mutex_lock(&sdata->local->sta_mtx); 2607 mutex_lock(&sdata->local->sta_mtx);
@@ -2544,7 +2612,8 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
2544 sta = sta_info_get(sdata, cbss->bssid); 2612 sta = sta_info_get(sdata, cbss->bssid);
2545 if (WARN_ON(!sta)) { 2613 if (WARN_ON(!sta)) {
2546 mutex_unlock(&sdata->local->sta_mtx); 2614 mutex_unlock(&sdata->local->sta_mtx);
2547 return false; 2615 ret = false;
2616 goto out;
2548 } 2617 }
2549 2618
2550 sband = local->hw.wiphy->bands[ieee80211_get_sdata_band(sdata)]; 2619 sband = local->hw.wiphy->bands[ieee80211_get_sdata_band(sdata)];
@@ -2597,7 +2666,8 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
2597 sta->sta.addr); 2666 sta->sta.addr);
2598 WARN_ON(__sta_info_destroy(sta)); 2667 WARN_ON(__sta_info_destroy(sta));
2599 mutex_unlock(&sdata->local->sta_mtx); 2668 mutex_unlock(&sdata->local->sta_mtx);
2600 return false; 2669 ret = false;
2670 goto out;
2601 } 2671 }
2602 2672
2603 mutex_unlock(&sdata->local->sta_mtx); 2673 mutex_unlock(&sdata->local->sta_mtx);
@@ -2637,7 +2707,10 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
2637 ieee80211_sta_rx_notify(sdata, (struct ieee80211_hdr *)mgmt); 2707 ieee80211_sta_rx_notify(sdata, (struct ieee80211_hdr *)mgmt);
2638 ieee80211_sta_reset_beacon_monitor(sdata); 2708 ieee80211_sta_reset_beacon_monitor(sdata);
2639 2709
2640 return true; 2710 ret = true;
2711 out:
2712 kfree(bss_ies);
2713 return ret;
2641} 2714}
2642 2715
2643static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, 2716static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index d3f414fe67e0..a02bef35b134 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -615,7 +615,7 @@ static void rate_control_apply_mask(struct ieee80211_sub_if_data *sdata,
615 if (rates[i].idx < 0) 615 if (rates[i].idx < 0)
616 break; 616 break;
617 617
618 rate_idx_match_mask(&rates[i], sband, mask, chan_width, 618 rate_idx_match_mask(&rates[i], sband, chan_width, mask,
619 mcs_mask); 619 mcs_mask);
620 } 620 }
621} 621}
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 89a83770d152..c75d3db2a31c 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -667,12 +667,12 @@ void ieee80211_queue_delayed_work(struct ieee80211_hw *hw,
667} 667}
668EXPORT_SYMBOL(ieee80211_queue_delayed_work); 668EXPORT_SYMBOL(ieee80211_queue_delayed_work);
669 669
670u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, bool action, 670u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
671 struct ieee802_11_elems *elems, 671 struct ieee802_11_elems *elems,
672 u64 filter, u32 crc) 672 u64 filter, u32 crc)
673{ 673{
674 size_t left = len; 674 size_t left = len;
675 u8 *pos = start; 675 const u8 *pos = start;
676 bool calc_crc = filter != 0; 676 bool calc_crc = filter != 0;
677 DECLARE_BITMAP(seen_elems, 256); 677 DECLARE_BITMAP(seen_elems, 256);
678 const u8 *ie; 678 const u8 *ie;
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index edb88fbcb1bd..47e510819f54 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -2542,6 +2542,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
2542 struct ip_vs_dest *dest; 2542 struct ip_vs_dest *dest;
2543 struct ip_vs_dest_entry entry; 2543 struct ip_vs_dest_entry entry;
2544 2544
2545 memset(&entry, 0, sizeof(entry));
2545 list_for_each_entry(dest, &svc->destinations, n_list) { 2546 list_for_each_entry(dest, &svc->destinations, n_list) {
2546 if (count >= get->num_dests) 2547 if (count >= get->num_dests)
2547 break; 2548 break;
diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
index dc3fd5d44464..c7b6d466a662 100644
--- a/net/netfilter/nfnetlink_acct.c
+++ b/net/netfilter/nfnetlink_acct.c
@@ -149,9 +149,12 @@ nfnl_acct_dump(struct sk_buff *skb, struct netlink_callback *cb)
149 149
150 rcu_read_lock(); 150 rcu_read_lock();
151 list_for_each_entry_rcu(cur, &nfnl_acct_list, head) { 151 list_for_each_entry_rcu(cur, &nfnl_acct_list, head) {
152 if (last && cur != last) 152 if (last) {
153 continue; 153 if (cur != last)
154 continue;
154 155
156 last = NULL;
157 }
155 if (nfnl_acct_fill_info(skb, NETLINK_CB(cb->skb).portid, 158 if (nfnl_acct_fill_info(skb, NETLINK_CB(cb->skb).portid,
156 cb->nlh->nlmsg_seq, 159 cb->nlh->nlmsg_seq,
157 NFNL_MSG_TYPE(cb->nlh->nlmsg_type), 160 NFNL_MSG_TYPE(cb->nlh->nlmsg_type),
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index 701c88a20fea..65074dfb9383 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -220,9 +220,12 @@ ctnl_timeout_dump(struct sk_buff *skb, struct netlink_callback *cb)
220 220
221 rcu_read_lock(); 221 rcu_read_lock();
222 list_for_each_entry_rcu(cur, &cttimeout_list, head) { 222 list_for_each_entry_rcu(cur, &cttimeout_list, head) {
223 if (last && cur != last) 223 if (last) {
224 continue; 224 if (cur != last)
225 continue;
225 226
227 last = NULL;
228 }
226 if (ctnl_timeout_fill_info(skb, NETLINK_CB(cb->skb).portid, 229 if (ctnl_timeout_fill_info(skb, NETLINK_CB(cb->skb).portid,
227 cb->nlh->nlmsg_seq, 230 cb->nlh->nlmsg_seq,
228 NFNL_MSG_TYPE(cb->nlh->nlmsg_type), 231 NFNL_MSG_TYPE(cb->nlh->nlmsg_type),
diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
index c011543bff5d..299a48ae5dc9 100644
--- a/net/netfilter/nfnetlink_queue_core.c
+++ b/net/netfilter/nfnetlink_queue_core.c
@@ -641,9 +641,6 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum)
641 if (queue->copy_mode == NFQNL_COPY_NONE) 641 if (queue->copy_mode == NFQNL_COPY_NONE)
642 return -EINVAL; 642 return -EINVAL;
643 643
644 if ((queue->flags & NFQA_CFG_F_GSO) || !skb_is_gso(entry->skb))
645 return __nfqnl_enqueue_packet(net, queue, entry);
646
647 skb = entry->skb; 644 skb = entry->skb;
648 645
649 switch (entry->pf) { 646 switch (entry->pf) {
@@ -655,6 +652,9 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum)
655 break; 652 break;
656 } 653 }
657 654
655 if ((queue->flags & NFQA_CFG_F_GSO) || !skb_is_gso(skb))
656 return __nfqnl_enqueue_packet(net, queue, entry);
657
658 nf_bridge_adjust_skb_data(skb); 658 nf_bridge_adjust_skb_data(skb);
659 segs = skb_gso_segment(skb, 0); 659 segs = skb_gso_segment(skb, 0);
660 /* Does not use PTR_ERR to limit the number of error codes that can be 660 /* Does not use PTR_ERR to limit the number of error codes that can be
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
index a75240f0d42b..7011c71646f0 100644
--- a/net/netfilter/xt_TCPMSS.c
+++ b/net/netfilter/xt_TCPMSS.c
@@ -45,17 +45,22 @@ optlen(const u_int8_t *opt, unsigned int offset)
45 45
46static int 46static int
47tcpmss_mangle_packet(struct sk_buff *skb, 47tcpmss_mangle_packet(struct sk_buff *skb,
48 const struct xt_tcpmss_info *info, 48 const struct xt_action_param *par,
49 unsigned int in_mtu, 49 unsigned int in_mtu,
50 unsigned int tcphoff, 50 unsigned int tcphoff,
51 unsigned int minlen) 51 unsigned int minlen)
52{ 52{
53 const struct xt_tcpmss_info *info = par->targinfo;
53 struct tcphdr *tcph; 54 struct tcphdr *tcph;
54 unsigned int tcplen, i; 55 unsigned int tcplen, i;
55 __be16 oldval; 56 __be16 oldval;
56 u16 newmss; 57 u16 newmss;
57 u8 *opt; 58 u8 *opt;
58 59
60 /* This is a fragment, no TCP header is available */
61 if (par->fragoff != 0)
62 return XT_CONTINUE;
63
59 if (!skb_make_writable(skb, skb->len)) 64 if (!skb_make_writable(skb, skb->len))
60 return -1; 65 return -1;
61 66
@@ -125,6 +130,18 @@ tcpmss_mangle_packet(struct sk_buff *skb,
125 130
126 skb_put(skb, TCPOLEN_MSS); 131 skb_put(skb, TCPOLEN_MSS);
127 132
133 /*
134 * IPv4: RFC 1122 states "If an MSS option is not received at
135 * connection setup, TCP MUST assume a default send MSS of 536".
136 * IPv6: RFC 2460 states IPv6 has a minimum MTU of 1280 and a minimum
137 * length IPv6 header of 60, ergo the default MSS value is 1220
138 * Since no MSS was provided, we must use the default values
139 */
140 if (par->family == NFPROTO_IPV4)
141 newmss = min(newmss, (u16)536);
142 else
143 newmss = min(newmss, (u16)1220);
144
128 opt = (u_int8_t *)tcph + sizeof(struct tcphdr); 145 opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
129 memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr)); 146 memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
130 147
@@ -182,7 +199,7 @@ tcpmss_tg4(struct sk_buff *skb, const struct xt_action_param *par)
182 __be16 newlen; 199 __be16 newlen;
183 int ret; 200 int ret;
184 201
185 ret = tcpmss_mangle_packet(skb, par->targinfo, 202 ret = tcpmss_mangle_packet(skb, par,
186 tcpmss_reverse_mtu(skb, PF_INET), 203 tcpmss_reverse_mtu(skb, PF_INET),
187 iph->ihl * 4, 204 iph->ihl * 4,
188 sizeof(*iph) + sizeof(struct tcphdr)); 205 sizeof(*iph) + sizeof(struct tcphdr));
@@ -211,7 +228,7 @@ tcpmss_tg6(struct sk_buff *skb, const struct xt_action_param *par)
211 tcphoff = ipv6_skip_exthdr(skb, sizeof(*ipv6h), &nexthdr, &frag_off); 228 tcphoff = ipv6_skip_exthdr(skb, sizeof(*ipv6h), &nexthdr, &frag_off);
212 if (tcphoff < 0) 229 if (tcphoff < 0)
213 return NF_DROP; 230 return NF_DROP;
214 ret = tcpmss_mangle_packet(skb, par->targinfo, 231 ret = tcpmss_mangle_packet(skb, par,
215 tcpmss_reverse_mtu(skb, PF_INET6), 232 tcpmss_reverse_mtu(skb, PF_INET6),
216 tcphoff, 233 tcphoff,
217 sizeof(*ipv6h) + sizeof(struct tcphdr)); 234 sizeof(*ipv6h) + sizeof(struct tcphdr));
diff --git a/net/netfilter/xt_TCPOPTSTRIP.c b/net/netfilter/xt_TCPOPTSTRIP.c
index 1eb1a44bfd3d..b68fa191710f 100644
--- a/net/netfilter/xt_TCPOPTSTRIP.c
+++ b/net/netfilter/xt_TCPOPTSTRIP.c
@@ -48,11 +48,13 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
48 return NF_DROP; 48 return NF_DROP;
49 49
50 len = skb->len - tcphoff; 50 len = skb->len - tcphoff;
51 if (len < (int)sizeof(struct tcphdr) || 51 if (len < (int)sizeof(struct tcphdr))
52 tcp_hdr(skb)->doff * 4 > len)
53 return NF_DROP; 52 return NF_DROP;
54 53
55 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff); 54 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
55 if (tcph->doff * 4 > len)
56 return NF_DROP;
57
56 opt = (u_int8_t *)tcph; 58 opt = (u_int8_t *)tcph;
57 59
58 /* 60 /*
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 8978755251f7..275d901d7e46 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -371,7 +371,7 @@ static int netlink_mmap(struct file *file, struct socket *sock,
371 err = 0; 371 err = 0;
372out: 372out:
373 mutex_unlock(&nlk->pg_vec_lock); 373 mutex_unlock(&nlk->pg_vec_lock);
374 return 0; 374 return err;
375} 375}
376 376
377static void netlink_frame_flush_dcache(const struct nl_mmap_hdr *hdr) 377static void netlink_frame_flush_dcache(const struct nl_mmap_hdr *hdr)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 79fe63246b27..4b66c752eae5 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2851,12 +2851,11 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr,
2851 return -EOPNOTSUPP; 2851 return -EOPNOTSUPP;
2852 2852
2853 uaddr->sa_family = AF_PACKET; 2853 uaddr->sa_family = AF_PACKET;
2854 memset(uaddr->sa_data, 0, sizeof(uaddr->sa_data));
2854 rcu_read_lock(); 2855 rcu_read_lock();
2855 dev = dev_get_by_index_rcu(sock_net(sk), pkt_sk(sk)->ifindex); 2856 dev = dev_get_by_index_rcu(sock_net(sk), pkt_sk(sk)->ifindex);
2856 if (dev) 2857 if (dev)
2857 strncpy(uaddr->sa_data, dev->name, 14); 2858 strlcpy(uaddr->sa_data, dev->name, sizeof(uaddr->sa_data));
2858 else
2859 memset(uaddr->sa_data, 0, 14);
2860 rcu_read_unlock(); 2859 rcu_read_unlock();
2861 *uaddr_len = sizeof(*uaddr); 2860 *uaddr_len = sizeof(*uaddr);
2862 2861
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 2b935e7cfe7b..281c1bded1f6 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -291,17 +291,18 @@ struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct nlattr *ta
291{ 291{
292 struct qdisc_rate_table *rtab; 292 struct qdisc_rate_table *rtab;
293 293
294 if (tab == NULL || r->rate == 0 || r->cell_log == 0 ||
295 nla_len(tab) != TC_RTAB_SIZE)
296 return NULL;
297
294 for (rtab = qdisc_rtab_list; rtab; rtab = rtab->next) { 298 for (rtab = qdisc_rtab_list; rtab; rtab = rtab->next) {
295 if (memcmp(&rtab->rate, r, sizeof(struct tc_ratespec)) == 0) { 299 if (!memcmp(&rtab->rate, r, sizeof(struct tc_ratespec)) &&
300 !memcmp(&rtab->data, nla_data(tab), 1024)) {
296 rtab->refcnt++; 301 rtab->refcnt++;
297 return rtab; 302 return rtab;
298 } 303 }
299 } 304 }
300 305
301 if (tab == NULL || r->rate == 0 || r->cell_log == 0 ||
302 nla_len(tab) != TC_RTAB_SIZE)
303 return NULL;
304
305 rtab = kmalloc(sizeof(*rtab), GFP_KERNEL); 306 rtab = kmalloc(sizeof(*rtab), GFP_KERNEL);
306 if (rtab) { 307 if (rtab) {
307 rtab->rate = *r; 308 rtab->rate = *r;
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 32a4625fef77..be35e2dbcc9a 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -206,6 +206,8 @@ static inline int sctp_cacc_skip(struct sctp_transport *primary,
206 */ 206 */
207void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q) 207void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q)
208{ 208{
209 memset(q, 0, sizeof(struct sctp_outq));
210
209 q->asoc = asoc; 211 q->asoc = asoc;
210 INIT_LIST_HEAD(&q->out_chunk_list); 212 INIT_LIST_HEAD(&q->out_chunk_list);
211 INIT_LIST_HEAD(&q->control_chunk_list); 213 INIT_LIST_HEAD(&q->control_chunk_list);
@@ -213,11 +215,7 @@ void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q)
213 INIT_LIST_HEAD(&q->sacked); 215 INIT_LIST_HEAD(&q->sacked);
214 INIT_LIST_HEAD(&q->abandoned); 216 INIT_LIST_HEAD(&q->abandoned);
215 217
216 q->fast_rtx = 0;
217 q->outstanding_bytes = 0;
218 q->empty = 1; 218 q->empty = 1;
219 q->cork = 0;
220 q->out_qlen = 0;
221} 219}
222 220
223/* Free the outqueue structure and any related pending chunks. 221/* Free the outqueue structure and any related pending chunks.
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 75fe92ac2e9c..32db19ba4a21 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3996,6 +3996,12 @@ static void sctp_destroy_sock(struct sock *sk)
3996 3996
3997 /* Release our hold on the endpoint. */ 3997 /* Release our hold on the endpoint. */
3998 sp = sctp_sk(sk); 3998 sp = sctp_sk(sk);
3999 /* This could happen during socket init, thus we bail out
4000 * early, since the rest of the below is not setup either.
4001 */
4002 if (sp->ep == NULL)
4003 return;
4004
3999 if (sp->do_auto_asconf) { 4005 if (sp->do_auto_asconf) {
4000 sp->do_auto_asconf = 0; 4006 sp->do_auto_asconf = 0;
4001 list_del(&sp->auto_asconf_list); 4007 list_del(&sp->auto_asconf_list);
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 31d265f36d2c..ea74b9dd9d82 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1527,12 +1527,18 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb)
1527 struct cfg80211_registered_device *dev; 1527 struct cfg80211_registered_device *dev;
1528 s64 filter_wiphy = -1; 1528 s64 filter_wiphy = -1;
1529 bool split = false; 1529 bool split = false;
1530 struct nlattr **tb = nl80211_fam.attrbuf; 1530 struct nlattr **tb;
1531 int res; 1531 int res;
1532 1532
1533 /* will be zeroed in nlmsg_parse() */
1534 tb = kmalloc(sizeof(*tb) * (NL80211_ATTR_MAX + 1), GFP_KERNEL);
1535 if (!tb)
1536 return -ENOMEM;
1537
1533 rtnl_lock(); 1538 rtnl_lock();
1539
1534 res = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize, 1540 res = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
1535 tb, nl80211_fam.maxattr, nl80211_policy); 1541 tb, NL80211_ATTR_MAX, nl80211_policy);
1536 if (res == 0) { 1542 if (res == 0) {
1537 split = tb[NL80211_ATTR_SPLIT_WIPHY_DUMP]; 1543 split = tb[NL80211_ATTR_SPLIT_WIPHY_DUMP];
1538 if (tb[NL80211_ATTR_WIPHY]) 1544 if (tb[NL80211_ATTR_WIPHY])
@@ -1544,8 +1550,11 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb)
1544 int ifidx = nla_get_u32(tb[NL80211_ATTR_IFINDEX]); 1550 int ifidx = nla_get_u32(tb[NL80211_ATTR_IFINDEX]);
1545 1551
1546 netdev = dev_get_by_index(sock_net(skb->sk), ifidx); 1552 netdev = dev_get_by_index(sock_net(skb->sk), ifidx);
1547 if (!netdev) 1553 if (!netdev) {
1554 rtnl_unlock();
1555 kfree(tb);
1548 return -ENODEV; 1556 return -ENODEV;
1557 }
1549 if (netdev->ieee80211_ptr) { 1558 if (netdev->ieee80211_ptr) {
1550 dev = wiphy_to_dev( 1559 dev = wiphy_to_dev(
1551 netdev->ieee80211_ptr->wiphy); 1560 netdev->ieee80211_ptr->wiphy);
@@ -1554,6 +1563,7 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb)
1554 dev_put(netdev); 1563 dev_put(netdev);
1555 } 1564 }
1556 } 1565 }
1566 kfree(tb);
1557 1567
1558 list_for_each_entry(dev, &cfg80211_rdev_list, list) { 1568 list_for_each_entry(dev, &cfg80211_rdev_list, list) {
1559 if (!net_eq(wiphy_net(&dev->wiphy), sock_net(skb->sk))) 1569 if (!net_eq(wiphy_net(&dev->wiphy), sock_net(skb->sk)))
@@ -1589,6 +1599,7 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb)
1589 !skb->len && 1599 !skb->len &&
1590 cb->min_dump_alloc < 4096) { 1600 cb->min_dump_alloc < 4096) {
1591 cb->min_dump_alloc = 4096; 1601 cb->min_dump_alloc = 4096;
1602 rtnl_unlock();
1592 return 1; 1603 return 1;
1593 } 1604 }
1594 idx--; 1605 idx--;