aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-07 15:10:57 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-07 15:10:57 -0500
commit926af6273fc683cd98cd0ce7bf0d04a02eed6742 (patch)
tree99c40d2bc42563a92c2877e58e32a6b4c922ba30
parentb6789123bccba8b5feb9901ed2e8c3c39181979d (diff)
parent912964eacb111551db73429719eb5fadcab0ff8a (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Load correct firmware in rtl8192ce wireless driver, from Jurij Smakov. 2) Fix leak of tx_ring and tx_cq due to overwriting in mlx4 driver, from Martin KaFai Lau. 3) Need to reference count PHY driver module when it is attached, from Mao Wenan. 4) Don't do zero length vzalloc() in ethtool register dump, from Stanislaw Gruszka. 5) Defer net_disable_timestamp() to a workqueue to get out of locking issues, from Eric Dumazet. 6) We cannot drop the SKB dst when IP options refer to them, fix also from Eric Dumazet. 7) Incorrect packet header offset calculations in ip6_gre, again from Eric Dumazet. 8) Missing tcp_v6_restore_cb() causes use-after-free, from Eric too. 9) tcp_splice_read() can get into an infinite loop with URG, and hey it's from Eric once more. 10) vnet_hdr_sz can change asynchronously, so read it once during decision making in macvtap and tun, from Willem de Bruijn. 11) Can't use kernel stack for DMA transfers in USB networking drivers, from Ben Hutchings. 12) Handle csum errors properly in UDP by calling the proper destructor, from Eric Dumazet. 13) For non-deterministic softirq run when scheduling NAPI from a workqueue in mlx4, from Benjamin Poirier. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (28 commits) sctp: check af before verify address in sctp_addr_id2transport sctp: avoid BUG_ON on sctp_wait_for_sndbuf mlx4: Invoke softirqs after napi_reschedule udp: properly cope with csum errors catc: Use heap buffer for memory size test catc: Combine failure cleanup code in catc_probe() rtl8150: Use heap buffers for all register access pegasus: Use heap buffers for all register access macvtap: read vnet_hdr_size once tun: read vnet_hdr_sz once tcp: avoid infinite loop in tcp_splice_read() hns: avoid stack overflow with CONFIG_KASAN ipv6: Fix IPv6 packet loss in scenarios involving roaming + snooping switches ipv6: tcp: add a missing tcp_v6_restore_cb() nl80211: Fix mesh HT operation check mac80211: Fix adding of mesh vendor IEs mac80211: Allocate a sync skcipher explicitly for FILS AEAD mac80211: Fix FILS AEAD protection in Association Request frame ip6_gre: fix ip6gre_err() invalid reads netlabel: out of bound access in cipso_v4_validate() ...
-rw-r--r--drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_ethtool.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c35
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4_en.h3
-rw-r--r--drivers/net/macvtap.c4
-rw-r--r--drivers/net/phy/phy_device.c7
-rw-r--r--drivers/net/tun.c10
-rw-r--r--drivers/net/usb/catc.c56
-rw-r--r--drivers/net/usb/pegasus.c29
-rw-r--r--drivers/net/usb/rtl8150.c34
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c9
-rw-r--r--include/net/cipso_ipv4.h4
-rw-r--r--include/net/sock.h4
-rw-r--r--include/uapi/linux/seg6.h9
-rw-r--r--net/core/datagram.c8
-rw-r--r--net/core/dev.c31
-rw-r--r--net/core/ethtool.c9
-rw-r--r--net/ipv4/cipso_ipv4.c4
-rw-r--r--net/ipv4/ip_sockglue.c9
-rw-r--r--net/ipv4/tcp.c6
-rw-r--r--net/ipv4/udp.c2
-rw-r--r--net/ipv6/addrconf.c10
-rw-r--r--net/ipv6/exthdrs.c31
-rw-r--r--net/ipv6/ip6_gre.c40
-rw-r--r--net/ipv6/seg6_hmac.c8
-rw-r--r--net/ipv6/tcp_ipv6.c24
-rw-r--r--net/ipv6/udp.c2
-rw-r--r--net/mac80211/fils_aead.c6
-rw-r--r--net/mac80211/mesh.c2
-rw-r--r--net/sctp/socket.c5
-rw-r--r--net/wireless/nl80211.c1
32 files changed, 255 insertions, 164 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h
index 87226685f742..8fa18fc17cd2 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h
@@ -1014,9 +1014,7 @@
1014 1014
1015static inline void dsaf_write_reg(void __iomem *base, u32 reg, u32 value) 1015static inline void dsaf_write_reg(void __iomem *base, u32 reg, u32 value)
1016{ 1016{
1017 u8 __iomem *reg_addr = ACCESS_ONCE(base); 1017 writel(value, base + reg);
1018
1019 writel(value, reg_addr + reg);
1020} 1018}
1021 1019
1022#define dsaf_write_dev(a, reg, value) \ 1020#define dsaf_write_dev(a, reg, value) \
@@ -1024,9 +1022,7 @@ static inline void dsaf_write_reg(void __iomem *base, u32 reg, u32 value)
1024 1022
1025static inline u32 dsaf_read_reg(u8 __iomem *base, u32 reg) 1023static inline u32 dsaf_read_reg(u8 __iomem *base, u32 reg)
1026{ 1024{
1027 u8 __iomem *reg_addr = ACCESS_ONCE(base); 1025 return readl(base + reg);
1028
1029 return readl(reg_addr + reg);
1030} 1026}
1031 1027
1032static inline void dsaf_write_syscon(struct regmap *base, u32 reg, u32 value) 1028static inline void dsaf_write_syscon(struct regmap *base, u32 reg, u32 value)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index d5a9372ed84d..9aa422691954 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -1099,7 +1099,7 @@ static int mlx4_en_set_ringparam(struct net_device *dev,
1099 memcpy(&new_prof, priv->prof, sizeof(struct mlx4_en_port_profile)); 1099 memcpy(&new_prof, priv->prof, sizeof(struct mlx4_en_port_profile));
1100 new_prof.tx_ring_size = tx_size; 1100 new_prof.tx_ring_size = tx_size;
1101 new_prof.rx_ring_size = rx_size; 1101 new_prof.rx_ring_size = rx_size;
1102 err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof); 1102 err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof, true);
1103 if (err) 1103 if (err)
1104 goto out; 1104 goto out;
1105 1105
@@ -1774,7 +1774,7 @@ static int mlx4_en_set_channels(struct net_device *dev,
1774 new_prof.tx_ring_num[TX_XDP] = xdp_count; 1774 new_prof.tx_ring_num[TX_XDP] = xdp_count;
1775 new_prof.rx_ring_num = channel->rx_count; 1775 new_prof.rx_ring_num = channel->rx_count;
1776 1776
1777 err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof); 1777 err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof, true);
1778 if (err) 1778 if (err)
1779 goto out; 1779 goto out;
1780 1780
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 761f8b12399c..3b4961a8e8e4 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2042,6 +2042,8 @@ static void mlx4_en_free_resources(struct mlx4_en_priv *priv)
2042 if (priv->tx_cq[t] && priv->tx_cq[t][i]) 2042 if (priv->tx_cq[t] && priv->tx_cq[t][i])
2043 mlx4_en_destroy_cq(priv, &priv->tx_cq[t][i]); 2043 mlx4_en_destroy_cq(priv, &priv->tx_cq[t][i]);
2044 } 2044 }
2045 kfree(priv->tx_ring[t]);
2046 kfree(priv->tx_cq[t]);
2045 } 2047 }
2046 2048
2047 for (i = 0; i < priv->rx_ring_num; i++) { 2049 for (i = 0; i < priv->rx_ring_num; i++) {
@@ -2184,9 +2186,11 @@ static void mlx4_en_update_priv(struct mlx4_en_priv *dst,
2184 2186
2185int mlx4_en_try_alloc_resources(struct mlx4_en_priv *priv, 2187int mlx4_en_try_alloc_resources(struct mlx4_en_priv *priv,
2186 struct mlx4_en_priv *tmp, 2188 struct mlx4_en_priv *tmp,
2187 struct mlx4_en_port_profile *prof) 2189 struct mlx4_en_port_profile *prof,
2190 bool carry_xdp_prog)
2188{ 2191{
2189 int t; 2192 struct bpf_prog *xdp_prog;
2193 int i, t;
2190 2194
2191 mlx4_en_copy_priv(tmp, priv, prof); 2195 mlx4_en_copy_priv(tmp, priv, prof);
2192 2196
@@ -2200,6 +2204,23 @@ int mlx4_en_try_alloc_resources(struct mlx4_en_priv *priv,
2200 } 2204 }
2201 return -ENOMEM; 2205 return -ENOMEM;
2202 } 2206 }
2207
2208 /* All rx_rings has the same xdp_prog. Pick the first one. */
2209 xdp_prog = rcu_dereference_protected(
2210 priv->rx_ring[0]->xdp_prog,
2211 lockdep_is_held(&priv->mdev->state_lock));
2212
2213 if (xdp_prog && carry_xdp_prog) {
2214 xdp_prog = bpf_prog_add(xdp_prog, tmp->rx_ring_num);
2215 if (IS_ERR(xdp_prog)) {
2216 mlx4_en_free_resources(tmp);
2217 return PTR_ERR(xdp_prog);
2218 }
2219 for (i = 0; i < tmp->rx_ring_num; i++)
2220 rcu_assign_pointer(tmp->rx_ring[i]->xdp_prog,
2221 xdp_prog);
2222 }
2223
2203 return 0; 2224 return 0;
2204} 2225}
2205 2226
@@ -2214,7 +2235,6 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
2214{ 2235{
2215 struct mlx4_en_priv *priv = netdev_priv(dev); 2236 struct mlx4_en_priv *priv = netdev_priv(dev);
2216 struct mlx4_en_dev *mdev = priv->mdev; 2237 struct mlx4_en_dev *mdev = priv->mdev;
2217 int t;
2218 2238
2219 en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port); 2239 en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port);
2220 2240
@@ -2248,11 +2268,6 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
2248 mlx4_en_free_resources(priv); 2268 mlx4_en_free_resources(priv);
2249 mutex_unlock(&mdev->state_lock); 2269 mutex_unlock(&mdev->state_lock);
2250 2270
2251 for (t = 0; t < MLX4_EN_NUM_TX_TYPES; t++) {
2252 kfree(priv->tx_ring[t]);
2253 kfree(priv->tx_cq[t]);
2254 }
2255
2256 free_netdev(dev); 2271 free_netdev(dev);
2257} 2272}
2258 2273
@@ -2755,7 +2770,7 @@ static int mlx4_xdp_set(struct net_device *dev, struct bpf_prog *prog)
2755 en_warn(priv, "Reducing the number of TX rings, to not exceed the max total rings number.\n"); 2770 en_warn(priv, "Reducing the number of TX rings, to not exceed the max total rings number.\n");
2756 } 2771 }
2757 2772
2758 err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof); 2773 err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof, false);
2759 if (err) { 2774 if (err) {
2760 if (prog) 2775 if (prog)
2761 bpf_prog_sub(prog, priv->rx_ring_num - 1); 2776 bpf_prog_sub(prog, priv->rx_ring_num - 1);
@@ -3499,7 +3514,7 @@ int mlx4_en_reset_config(struct net_device *dev,
3499 memcpy(&new_prof, priv->prof, sizeof(struct mlx4_en_port_profile)); 3514 memcpy(&new_prof, priv->prof, sizeof(struct mlx4_en_port_profile));
3500 memcpy(&new_prof.hwtstamp_config, &ts_config, sizeof(ts_config)); 3515 memcpy(&new_prof.hwtstamp_config, &ts_config, sizeof(ts_config));
3501 3516
3502 err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof); 3517 err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof, true);
3503 if (err) 3518 if (err)
3504 goto out; 3519 goto out;
3505 3520
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index eac527e25ec9..cc003fdf0ed9 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -514,8 +514,11 @@ void mlx4_en_recover_from_oom(struct mlx4_en_priv *priv)
514 return; 514 return;
515 515
516 for (ring = 0; ring < priv->rx_ring_num; ring++) { 516 for (ring = 0; ring < priv->rx_ring_num; ring++) {
517 if (mlx4_en_is_ring_empty(priv->rx_ring[ring])) 517 if (mlx4_en_is_ring_empty(priv->rx_ring[ring])) {
518 local_bh_disable();
518 napi_reschedule(&priv->rx_cq[ring]->napi); 519 napi_reschedule(&priv->rx_cq[ring]->napi);
520 local_bh_enable();
521 }
519 } 522 }
520} 523}
521 524
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index ba1c6cd0cc79..cec59bc264c9 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -679,7 +679,8 @@ void mlx4_en_set_stats_bitmap(struct mlx4_dev *dev,
679 679
680int mlx4_en_try_alloc_resources(struct mlx4_en_priv *priv, 680int mlx4_en_try_alloc_resources(struct mlx4_en_priv *priv,
681 struct mlx4_en_priv *tmp, 681 struct mlx4_en_priv *tmp,
682 struct mlx4_en_port_profile *prof); 682 struct mlx4_en_port_profile *prof,
683 bool carry_xdp_prog);
683void mlx4_en_safe_replace_resources(struct mlx4_en_priv *priv, 684void mlx4_en_safe_replace_resources(struct mlx4_en_priv *priv,
684 struct mlx4_en_priv *tmp); 685 struct mlx4_en_priv *tmp);
685 686
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 402618565838..c27011bbe30c 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -681,7 +681,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
681 size_t linear; 681 size_t linear;
682 682
683 if (q->flags & IFF_VNET_HDR) { 683 if (q->flags & IFF_VNET_HDR) {
684 vnet_hdr_len = q->vnet_hdr_sz; 684 vnet_hdr_len = READ_ONCE(q->vnet_hdr_sz);
685 685
686 err = -EINVAL; 686 err = -EINVAL;
687 if (len < vnet_hdr_len) 687 if (len < vnet_hdr_len)
@@ -820,7 +820,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
820 820
821 if (q->flags & IFF_VNET_HDR) { 821 if (q->flags & IFF_VNET_HDR) {
822 struct virtio_net_hdr vnet_hdr; 822 struct virtio_net_hdr vnet_hdr;
823 vnet_hdr_len = q->vnet_hdr_sz; 823 vnet_hdr_len = READ_ONCE(q->vnet_hdr_sz);
824 if (iov_iter_count(iter) < vnet_hdr_len) 824 if (iov_iter_count(iter) < vnet_hdr_len)
825 return -EINVAL; 825 return -EINVAL;
826 826
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 92b08383cafa..0d8f4d3847f6 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -920,6 +920,11 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
920 return -EIO; 920 return -EIO;
921 } 921 }
922 922
923 if (!try_module_get(d->driver->owner)) {
924 dev_err(&dev->dev, "failed to get the device driver module\n");
925 return -EIO;
926 }
927
923 get_device(d); 928 get_device(d);
924 929
925 /* Assume that if there is no driver, that it doesn't 930 /* Assume that if there is no driver, that it doesn't
@@ -977,6 +982,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
977error: 982error:
978 phy_detach(phydev); 983 phy_detach(phydev);
979 put_device(d); 984 put_device(d);
985 module_put(d->driver->owner);
980 if (ndev_owner != bus->owner) 986 if (ndev_owner != bus->owner)
981 module_put(bus->owner); 987 module_put(bus->owner);
982 return err; 988 return err;
@@ -1059,6 +1065,7 @@ void phy_detach(struct phy_device *phydev)
1059 bus = phydev->mdio.bus; 1065 bus = phydev->mdio.bus;
1060 1066
1061 put_device(&phydev->mdio.dev); 1067 put_device(&phydev->mdio.dev);
1068 module_put(phydev->mdio.dev.driver->owner);
1062 if (ndev_owner != bus->owner) 1069 if (ndev_owner != bus->owner)
1063 module_put(bus->owner); 1070 module_put(bus->owner);
1064} 1071}
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 2cd10b26b650..bfabe180053e 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1170,9 +1170,11 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1170 } 1170 }
1171 1171
1172 if (tun->flags & IFF_VNET_HDR) { 1172 if (tun->flags & IFF_VNET_HDR) {
1173 if (len < tun->vnet_hdr_sz) 1173 int vnet_hdr_sz = READ_ONCE(tun->vnet_hdr_sz);
1174
1175 if (len < vnet_hdr_sz)
1174 return -EINVAL; 1176 return -EINVAL;
1175 len -= tun->vnet_hdr_sz; 1177 len -= vnet_hdr_sz;
1176 1178
1177 if (!copy_from_iter_full(&gso, sizeof(gso), from)) 1179 if (!copy_from_iter_full(&gso, sizeof(gso), from))
1178 return -EFAULT; 1180 return -EFAULT;
@@ -1183,7 +1185,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1183 1185
1184 if (tun16_to_cpu(tun, gso.hdr_len) > len) 1186 if (tun16_to_cpu(tun, gso.hdr_len) > len)
1185 return -EINVAL; 1187 return -EINVAL;
1186 iov_iter_advance(from, tun->vnet_hdr_sz - sizeof(gso)); 1188 iov_iter_advance(from, vnet_hdr_sz - sizeof(gso));
1187 } 1189 }
1188 1190
1189 if ((tun->flags & TUN_TYPE_MASK) == IFF_TAP) { 1191 if ((tun->flags & TUN_TYPE_MASK) == IFF_TAP) {
@@ -1335,7 +1337,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1335 vlan_hlen = VLAN_HLEN; 1337 vlan_hlen = VLAN_HLEN;
1336 1338
1337 if (tun->flags & IFF_VNET_HDR) 1339 if (tun->flags & IFF_VNET_HDR)
1338 vnet_hdr_sz = tun->vnet_hdr_sz; 1340 vnet_hdr_sz = READ_ONCE(tun->vnet_hdr_sz);
1339 1341
1340 total = skb->len + vlan_hlen + vnet_hdr_sz; 1342 total = skb->len + vlan_hlen + vnet_hdr_sz;
1341 1343
diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c
index 3daa41bdd4ea..0acc9b640419 100644
--- a/drivers/net/usb/catc.c
+++ b/drivers/net/usb/catc.c
@@ -776,7 +776,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
776 struct net_device *netdev; 776 struct net_device *netdev;
777 struct catc *catc; 777 struct catc *catc;
778 u8 broadcast[ETH_ALEN]; 778 u8 broadcast[ETH_ALEN];
779 int i, pktsz; 779 int pktsz, ret;
780 780
781 if (usb_set_interface(usbdev, 781 if (usb_set_interface(usbdev,
782 intf->altsetting->desc.bInterfaceNumber, 1)) { 782 intf->altsetting->desc.bInterfaceNumber, 1)) {
@@ -811,12 +811,8 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
811 if ((!catc->ctrl_urb) || (!catc->tx_urb) || 811 if ((!catc->ctrl_urb) || (!catc->tx_urb) ||
812 (!catc->rx_urb) || (!catc->irq_urb)) { 812 (!catc->rx_urb) || (!catc->irq_urb)) {
813 dev_err(&intf->dev, "No free urbs available.\n"); 813 dev_err(&intf->dev, "No free urbs available.\n");
814 usb_free_urb(catc->ctrl_urb); 814 ret = -ENOMEM;
815 usb_free_urb(catc->tx_urb); 815 goto fail_free;
816 usb_free_urb(catc->rx_urb);
817 usb_free_urb(catc->irq_urb);
818 free_netdev(netdev);
819 return -ENOMEM;
820 } 816 }
821 817
822 /* The F5U011 has the same vendor/product as the netmate but a device version of 0x130 */ 818 /* The F5U011 has the same vendor/product as the netmate but a device version of 0x130 */
@@ -844,15 +840,24 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
844 catc->irq_buf, 2, catc_irq_done, catc, 1); 840 catc->irq_buf, 2, catc_irq_done, catc, 1);
845 841
846 if (!catc->is_f5u011) { 842 if (!catc->is_f5u011) {
843 u32 *buf;
844 int i;
845
847 dev_dbg(dev, "Checking memory size\n"); 846 dev_dbg(dev, "Checking memory size\n");
848 847
849 i = 0x12345678; 848 buf = kmalloc(4, GFP_KERNEL);
850 catc_write_mem(catc, 0x7a80, &i, 4); 849 if (!buf) {
851 i = 0x87654321; 850 ret = -ENOMEM;
852 catc_write_mem(catc, 0xfa80, &i, 4); 851 goto fail_free;
853 catc_read_mem(catc, 0x7a80, &i, 4); 852 }
853
854 *buf = 0x12345678;
855 catc_write_mem(catc, 0x7a80, buf, 4);
856 *buf = 0x87654321;
857 catc_write_mem(catc, 0xfa80, buf, 4);
858 catc_read_mem(catc, 0x7a80, buf, 4);
854 859
855 switch (i) { 860 switch (*buf) {
856 case 0x12345678: 861 case 0x12345678:
857 catc_set_reg(catc, TxBufCount, 8); 862 catc_set_reg(catc, TxBufCount, 8);
858 catc_set_reg(catc, RxBufCount, 32); 863 catc_set_reg(catc, RxBufCount, 32);
@@ -867,6 +872,8 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
867 dev_dbg(dev, "32k Memory\n"); 872 dev_dbg(dev, "32k Memory\n");
868 break; 873 break;
869 } 874 }
875
876 kfree(buf);
870 877
871 dev_dbg(dev, "Getting MAC from SEEROM.\n"); 878 dev_dbg(dev, "Getting MAC from SEEROM.\n");
872 879
@@ -913,16 +920,21 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
913 usb_set_intfdata(intf, catc); 920 usb_set_intfdata(intf, catc);
914 921
915 SET_NETDEV_DEV(netdev, &intf->dev); 922 SET_NETDEV_DEV(netdev, &intf->dev);
916 if (register_netdev(netdev) != 0) { 923 ret = register_netdev(netdev);
917 usb_set_intfdata(intf, NULL); 924 if (ret)
918 usb_free_urb(catc->ctrl_urb); 925 goto fail_clear_intfdata;
919 usb_free_urb(catc->tx_urb); 926
920 usb_free_urb(catc->rx_urb);
921 usb_free_urb(catc->irq_urb);
922 free_netdev(netdev);
923 return -EIO;
924 }
925 return 0; 927 return 0;
928
929fail_clear_intfdata:
930 usb_set_intfdata(intf, NULL);
931fail_free:
932 usb_free_urb(catc->ctrl_urb);
933 usb_free_urb(catc->tx_urb);
934 usb_free_urb(catc->rx_urb);
935 usb_free_urb(catc->irq_urb);
936 free_netdev(netdev);
937 return ret;
926} 938}
927 939
928static void catc_disconnect(struct usb_interface *intf) 940static void catc_disconnect(struct usb_interface *intf)
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index 24e803fe9a53..36674484c6fb 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -126,40 +126,61 @@ static void async_ctrl_callback(struct urb *urb)
126 126
127static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data) 127static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data)
128{ 128{
129 u8 *buf;
129 int ret; 130 int ret;
130 131
132 buf = kmalloc(size, GFP_NOIO);
133 if (!buf)
134 return -ENOMEM;
135
131 ret = usb_control_msg(pegasus->usb, usb_rcvctrlpipe(pegasus->usb, 0), 136 ret = usb_control_msg(pegasus->usb, usb_rcvctrlpipe(pegasus->usb, 0),
132 PEGASUS_REQ_GET_REGS, PEGASUS_REQT_READ, 0, 137 PEGASUS_REQ_GET_REGS, PEGASUS_REQT_READ, 0,
133 indx, data, size, 1000); 138 indx, buf, size, 1000);
134 if (ret < 0) 139 if (ret < 0)
135 netif_dbg(pegasus, drv, pegasus->net, 140 netif_dbg(pegasus, drv, pegasus->net,
136 "%s returned %d\n", __func__, ret); 141 "%s returned %d\n", __func__, ret);
142 else if (ret <= size)
143 memcpy(data, buf, ret);
144 kfree(buf);
137 return ret; 145 return ret;
138} 146}
139 147
140static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data) 148static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size,
149 const void *data)
141{ 150{
151 u8 *buf;
142 int ret; 152 int ret;
143 153
154 buf = kmemdup(data, size, GFP_NOIO);
155 if (!buf)
156 return -ENOMEM;
157
144 ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0), 158 ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0),
145 PEGASUS_REQ_SET_REGS, PEGASUS_REQT_WRITE, 0, 159 PEGASUS_REQ_SET_REGS, PEGASUS_REQT_WRITE, 0,
146 indx, data, size, 100); 160 indx, buf, size, 100);
147 if (ret < 0) 161 if (ret < 0)
148 netif_dbg(pegasus, drv, pegasus->net, 162 netif_dbg(pegasus, drv, pegasus->net,
149 "%s returned %d\n", __func__, ret); 163 "%s returned %d\n", __func__, ret);
164 kfree(buf);
150 return ret; 165 return ret;
151} 166}
152 167
153static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data) 168static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data)
154{ 169{
170 u8 *buf;
155 int ret; 171 int ret;
156 172
173 buf = kmemdup(&data, 1, GFP_NOIO);
174 if (!buf)
175 return -ENOMEM;
176
157 ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0), 177 ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0),
158 PEGASUS_REQ_SET_REG, PEGASUS_REQT_WRITE, data, 178 PEGASUS_REQ_SET_REG, PEGASUS_REQT_WRITE, data,
159 indx, &data, 1, 1000); 179 indx, buf, 1, 1000);
160 if (ret < 0) 180 if (ret < 0)
161 netif_dbg(pegasus, drv, pegasus->net, 181 netif_dbg(pegasus, drv, pegasus->net,
162 "%s returned %d\n", __func__, ret); 182 "%s returned %d\n", __func__, ret);
183 kfree(buf);
163 return ret; 184 return ret;
164} 185}
165 186
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index 95b7bd0d7abc..c81c79110cef 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -155,16 +155,36 @@ static const char driver_name [] = "rtl8150";
155*/ 155*/
156static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data) 156static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)
157{ 157{
158 return usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), 158 void *buf;
159 RTL8150_REQ_GET_REGS, RTL8150_REQT_READ, 159 int ret;
160 indx, 0, data, size, 500); 160
161 buf = kmalloc(size, GFP_NOIO);
162 if (!buf)
163 return -ENOMEM;
164
165 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
166 RTL8150_REQ_GET_REGS, RTL8150_REQT_READ,
167 indx, 0, buf, size, 500);
168 if (ret > 0 && ret <= size)
169 memcpy(data, buf, ret);
170 kfree(buf);
171 return ret;
161} 172}
162 173
163static int set_registers(rtl8150_t * dev, u16 indx, u16 size, void *data) 174static int set_registers(rtl8150_t * dev, u16 indx, u16 size, const void *data)
164{ 175{
165 return usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), 176 void *buf;
166 RTL8150_REQ_SET_REGS, RTL8150_REQT_WRITE, 177 int ret;
167 indx, 0, data, size, 500); 178
179 buf = kmemdup(data, size, GFP_NOIO);
180 if (!buf)
181 return -ENOMEM;
182
183 ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
184 RTL8150_REQ_SET_REGS, RTL8150_REQT_WRITE,
185 indx, 0, buf, size, 500);
186 kfree(buf);
187 return ret;
168} 188}
169 189
170static void async_set_reg_cb(struct urb *urb) 190static void async_set_reg_cb(struct urb *urb)
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
index 691ddef1ae28..a33a06d58a9a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
@@ -92,7 +92,7 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
92 struct rtl_priv *rtlpriv = rtl_priv(hw); 92 struct rtl_priv *rtlpriv = rtl_priv(hw);
93 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 93 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
94 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 94 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
95 char *fw_name = "rtlwifi/rtl8192cfwU.bin"; 95 char *fw_name;
96 96
97 rtl8192ce_bt_reg_init(hw); 97 rtl8192ce_bt_reg_init(hw);
98 98
@@ -164,8 +164,13 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
164 } 164 }
165 165
166 /* request fw */ 166 /* request fw */
167 if (IS_81XXC_VENDOR_UMC_B_CUT(rtlhal->version)) 167 if (IS_VENDOR_UMC_A_CUT(rtlhal->version) &&
168 !IS_92C_SERIAL(rtlhal->version))
169 fw_name = "rtlwifi/rtl8192cfwU.bin";
170 else if (IS_81XXC_VENDOR_UMC_B_CUT(rtlhal->version))
168 fw_name = "rtlwifi/rtl8192cfwU_B.bin"; 171 fw_name = "rtlwifi/rtl8192cfwU_B.bin";
172 else
173 fw_name = "rtlwifi/rtl8192cfw.bin";
169 174
170 rtlpriv->max_fw_size = 0x4000; 175 rtlpriv->max_fw_size = 0x4000;
171 pr_info("Using firmware %s\n", fw_name); 176 pr_info("Using firmware %s\n", fw_name);
diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
index 3ebb168b9afc..a34b141f125f 100644
--- a/include/net/cipso_ipv4.h
+++ b/include/net/cipso_ipv4.h
@@ -309,6 +309,10 @@ static inline int cipso_v4_validate(const struct sk_buff *skb,
309 } 309 }
310 310
311 for (opt_iter = 6; opt_iter < opt_len;) { 311 for (opt_iter = 6; opt_iter < opt_len;) {
312 if (opt_iter + 1 == opt_len) {
313 err_offset = opt_iter;
314 goto out;
315 }
312 tag_len = opt[opt_iter + 1]; 316 tag_len = opt[opt_iter + 1];
313 if ((tag_len == 0) || (tag_len > (opt_len - opt_iter))) { 317 if ((tag_len == 0) || (tag_len > (opt_len - opt_iter))) {
314 err_offset = opt_iter + 1; 318 err_offset = opt_iter + 1;
diff --git a/include/net/sock.h b/include/net/sock.h
index f0e867f58722..c4f5e6fca17c 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2006,7 +2006,9 @@ void sk_reset_timer(struct sock *sk, struct timer_list *timer,
2006void sk_stop_timer(struct sock *sk, struct timer_list *timer); 2006void sk_stop_timer(struct sock *sk, struct timer_list *timer);
2007 2007
2008int __sk_queue_drop_skb(struct sock *sk, struct sk_buff *skb, 2008int __sk_queue_drop_skb(struct sock *sk, struct sk_buff *skb,
2009 unsigned int flags); 2009 unsigned int flags,
2010 void (*destructor)(struct sock *sk,
2011 struct sk_buff *skb));
2010int __sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); 2012int __sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
2011int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); 2013int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
2012 2014
diff --git a/include/uapi/linux/seg6.h b/include/uapi/linux/seg6.h
index c396a8052f73..052799e4d751 100644
--- a/include/uapi/linux/seg6.h
+++ b/include/uapi/linux/seg6.h
@@ -23,14 +23,12 @@ struct ipv6_sr_hdr {
23 __u8 type; 23 __u8 type;
24 __u8 segments_left; 24 __u8 segments_left;
25 __u8 first_segment; 25 __u8 first_segment;
26 __u8 flag_1; 26 __u8 flags;
27 __u8 flag_2; 27 __u16 reserved;
28 __u8 reserved;
29 28
30 struct in6_addr segments[0]; 29 struct in6_addr segments[0];
31}; 30};
32 31
33#define SR6_FLAG1_CLEANUP (1 << 7)
34#define SR6_FLAG1_PROTECTED (1 << 6) 32#define SR6_FLAG1_PROTECTED (1 << 6)
35#define SR6_FLAG1_OAM (1 << 5) 33#define SR6_FLAG1_OAM (1 << 5)
36#define SR6_FLAG1_ALERT (1 << 4) 34#define SR6_FLAG1_ALERT (1 << 4)
@@ -42,8 +40,7 @@ struct ipv6_sr_hdr {
42#define SR6_TLV_PADDING 4 40#define SR6_TLV_PADDING 4
43#define SR6_TLV_HMAC 5 41#define SR6_TLV_HMAC 5
44 42
45#define sr_has_cleanup(srh) ((srh)->flag_1 & SR6_FLAG1_CLEANUP) 43#define sr_has_hmac(srh) ((srh)->flags & SR6_FLAG1_HMAC)
46#define sr_has_hmac(srh) ((srh)->flag_1 & SR6_FLAG1_HMAC)
47 44
48struct sr6_tlv { 45struct sr6_tlv {
49 __u8 type; 46 __u8 type;
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 662bea587165..ea633342ab0d 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -332,7 +332,9 @@ void __skb_free_datagram_locked(struct sock *sk, struct sk_buff *skb, int len)
332EXPORT_SYMBOL(__skb_free_datagram_locked); 332EXPORT_SYMBOL(__skb_free_datagram_locked);
333 333
334int __sk_queue_drop_skb(struct sock *sk, struct sk_buff *skb, 334int __sk_queue_drop_skb(struct sock *sk, struct sk_buff *skb,
335 unsigned int flags) 335 unsigned int flags,
336 void (*destructor)(struct sock *sk,
337 struct sk_buff *skb))
336{ 338{
337 int err = 0; 339 int err = 0;
338 340
@@ -342,6 +344,8 @@ int __sk_queue_drop_skb(struct sock *sk, struct sk_buff *skb,
342 if (skb == skb_peek(&sk->sk_receive_queue)) { 344 if (skb == skb_peek(&sk->sk_receive_queue)) {
343 __skb_unlink(skb, &sk->sk_receive_queue); 345 __skb_unlink(skb, &sk->sk_receive_queue);
344 atomic_dec(&skb->users); 346 atomic_dec(&skb->users);
347 if (destructor)
348 destructor(sk, skb);
345 err = 0; 349 err = 0;
346 } 350 }
347 spin_unlock_bh(&sk->sk_receive_queue.lock); 351 spin_unlock_bh(&sk->sk_receive_queue.lock);
@@ -375,7 +379,7 @@ EXPORT_SYMBOL(__sk_queue_drop_skb);
375 379
376int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags) 380int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
377{ 381{
378 int err = __sk_queue_drop_skb(sk, skb, flags); 382 int err = __sk_queue_drop_skb(sk, skb, flags, NULL);
379 383
380 kfree_skb(skb); 384 kfree_skb(skb);
381 sk_mem_reclaim_partial(sk); 385 sk_mem_reclaim_partial(sk);
diff --git a/net/core/dev.c b/net/core/dev.c
index 7f218e095361..29101c98399f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1695,24 +1695,19 @@ EXPORT_SYMBOL_GPL(net_dec_egress_queue);
1695 1695
1696static struct static_key netstamp_needed __read_mostly; 1696static struct static_key netstamp_needed __read_mostly;
1697#ifdef HAVE_JUMP_LABEL 1697#ifdef HAVE_JUMP_LABEL
1698/* We are not allowed to call static_key_slow_dec() from irq context
1699 * If net_disable_timestamp() is called from irq context, defer the
1700 * static_key_slow_dec() calls.
1701 */
1702static atomic_t netstamp_needed_deferred; 1698static atomic_t netstamp_needed_deferred;
1703#endif 1699static void netstamp_clear(struct work_struct *work)
1704
1705void net_enable_timestamp(void)
1706{ 1700{
1707#ifdef HAVE_JUMP_LABEL
1708 int deferred = atomic_xchg(&netstamp_needed_deferred, 0); 1701 int deferred = atomic_xchg(&netstamp_needed_deferred, 0);
1709 1702
1710 if (deferred) { 1703 while (deferred--)
1711 while (--deferred) 1704 static_key_slow_dec(&netstamp_needed);
1712 static_key_slow_dec(&netstamp_needed); 1705}
1713 return; 1706static DECLARE_WORK(netstamp_work, netstamp_clear);
1714 }
1715#endif 1707#endif
1708
1709void net_enable_timestamp(void)
1710{
1716 static_key_slow_inc(&netstamp_needed); 1711 static_key_slow_inc(&netstamp_needed);
1717} 1712}
1718EXPORT_SYMBOL(net_enable_timestamp); 1713EXPORT_SYMBOL(net_enable_timestamp);
@@ -1720,12 +1715,12 @@ EXPORT_SYMBOL(net_enable_timestamp);
1720void net_disable_timestamp(void) 1715void net_disable_timestamp(void)
1721{ 1716{
1722#ifdef HAVE_JUMP_LABEL 1717#ifdef HAVE_JUMP_LABEL
1723 if (in_interrupt()) { 1718 /* net_disable_timestamp() can be called from non process context */
1724 atomic_inc(&netstamp_needed_deferred); 1719 atomic_inc(&netstamp_needed_deferred);
1725 return; 1720 schedule_work(&netstamp_work);
1726 } 1721#else
1727#endif
1728 static_key_slow_dec(&netstamp_needed); 1722 static_key_slow_dec(&netstamp_needed);
1723#endif
1729} 1724}
1730EXPORT_SYMBOL(net_disable_timestamp); 1725EXPORT_SYMBOL(net_disable_timestamp);
1731 1726
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 236a21e3c878..d92de0a1f0a4 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1405,9 +1405,12 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
1405 if (regs.len > reglen) 1405 if (regs.len > reglen)
1406 regs.len = reglen; 1406 regs.len = reglen;
1407 1407
1408 regbuf = vzalloc(reglen); 1408 regbuf = NULL;
1409 if (reglen && !regbuf) 1409 if (reglen) {
1410 return -ENOMEM; 1410 regbuf = vzalloc(reglen);
1411 if (!regbuf)
1412 return -ENOMEM;
1413 }
1411 1414
1412 ops->get_regs(dev, &regs, regbuf); 1415 ops->get_regs(dev, &regs, regbuf);
1413 1416
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 72d6f056d863..ae206163c273 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -1587,6 +1587,10 @@ int cipso_v4_validate(const struct sk_buff *skb, unsigned char **option)
1587 goto validate_return_locked; 1587 goto validate_return_locked;
1588 } 1588 }
1589 1589
1590 if (opt_iter + 1 == opt_len) {
1591 err_offset = opt_iter;
1592 goto validate_return_locked;
1593 }
1590 tag_len = tag[1]; 1594 tag_len = tag[1];
1591 if (tag_len > (opt_len - opt_iter)) { 1595 if (tag_len > (opt_len - opt_iter)) {
1592 err_offset = opt_iter + 1; 1596 err_offset = opt_iter + 1;
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 53ae0c6315ad..900011709e3b 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -1238,7 +1238,14 @@ void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
1238 pktinfo->ipi_ifindex = 0; 1238 pktinfo->ipi_ifindex = 0;
1239 pktinfo->ipi_spec_dst.s_addr = 0; 1239 pktinfo->ipi_spec_dst.s_addr = 0;
1240 } 1240 }
1241 skb_dst_drop(skb); 1241 /* We need to keep the dst for __ip_options_echo()
1242 * We could restrict the test to opt.ts_needtime || opt.srr,
1243 * but the following is good enough as IP options are not often used.
1244 */
1245 if (unlikely(IPCB(skb)->opt.optlen))
1246 skb_dst_force(skb);
1247 else
1248 skb_dst_drop(skb);
1242} 1249}
1243 1250
1244int ip_setsockopt(struct sock *sk, int level, 1251int ip_setsockopt(struct sock *sk, int level,
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 4a044964da66..0efb4c7f6704 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -770,6 +770,12 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,
770 ret = -EAGAIN; 770 ret = -EAGAIN;
771 break; 771 break;
772 } 772 }
773 /* if __tcp_splice_read() got nothing while we have
774 * an skb in receive queue, we do not want to loop.
775 * This might happen with URG data.
776 */
777 if (!skb_queue_empty(&sk->sk_receive_queue))
778 break;
773 sk_wait_data(sk, &timeo, NULL); 779 sk_wait_data(sk, &timeo, NULL);
774 if (signal_pending(current)) { 780 if (signal_pending(current)) {
775 ret = sock_intr_errno(timeo); 781 ret = sock_intr_errno(timeo);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 1307a7c2e544..8aab7d78d25b 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1501,7 +1501,7 @@ try_again:
1501 return err; 1501 return err;
1502 1502
1503csum_copy_err: 1503csum_copy_err:
1504 if (!__sk_queue_drop_skb(sk, skb, flags)) { 1504 if (!__sk_queue_drop_skb(sk, skb, flags, udp_skb_destructor)) {
1505 UDP_INC_STATS(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite); 1505 UDP_INC_STATS(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
1506 UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite); 1506 UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
1507 } 1507 }
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index f60e88e56255..81f7b4ea4281 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3386,9 +3386,15 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
3386 } 3386 }
3387 3387
3388 if (idev) { 3388 if (idev) {
3389 if (idev->if_flags & IF_READY) 3389 if (idev->if_flags & IF_READY) {
3390 /* device is already configured. */ 3390 /* device is already configured -
3391 * but resend MLD reports, we might
3392 * have roamed and need to update
3393 * multicast snooping switches
3394 */
3395 ipv6_mc_up(idev);
3391 break; 3396 break;
3397 }
3392 idev->if_flags |= IF_READY; 3398 idev->if_flags |= IF_READY;
3393 } 3399 }
3394 3400
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index e4198502fd98..275cac628a95 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -327,7 +327,6 @@ static int ipv6_srh_rcv(struct sk_buff *skb)
327 struct ipv6_sr_hdr *hdr; 327 struct ipv6_sr_hdr *hdr;
328 struct inet6_dev *idev; 328 struct inet6_dev *idev;
329 struct in6_addr *addr; 329 struct in6_addr *addr;
330 bool cleanup = false;
331 int accept_seg6; 330 int accept_seg6;
332 331
333 hdr = (struct ipv6_sr_hdr *)skb_transport_header(skb); 332 hdr = (struct ipv6_sr_hdr *)skb_transport_header(skb);
@@ -351,11 +350,7 @@ static int ipv6_srh_rcv(struct sk_buff *skb)
351#endif 350#endif
352 351
353looped_back: 352looped_back:
354 if (hdr->segments_left > 0) { 353 if (hdr->segments_left == 0) {
355 if (hdr->nexthdr != NEXTHDR_IPV6 && hdr->segments_left == 1 &&
356 sr_has_cleanup(hdr))
357 cleanup = true;
358 } else {
359 if (hdr->nexthdr == NEXTHDR_IPV6) { 354 if (hdr->nexthdr == NEXTHDR_IPV6) {
360 int offset = (hdr->hdrlen + 1) << 3; 355 int offset = (hdr->hdrlen + 1) << 3;
361 356
@@ -418,21 +413,6 @@ looped_back:
418 413
419 ipv6_hdr(skb)->daddr = *addr; 414 ipv6_hdr(skb)->daddr = *addr;
420 415
421 if (cleanup) {
422 int srhlen = (hdr->hdrlen + 1) << 3;
423 int nh = hdr->nexthdr;
424
425 skb_pull_rcsum(skb, sizeof(struct ipv6hdr) + srhlen);
426 memmove(skb_network_header(skb) + srhlen,
427 skb_network_header(skb),
428 (unsigned char *)hdr - skb_network_header(skb));
429 skb->network_header += srhlen;
430 ipv6_hdr(skb)->nexthdr = nh;
431 ipv6_hdr(skb)->payload_len = htons(skb->len -
432 sizeof(struct ipv6hdr));
433 skb_push_rcsum(skb, sizeof(struct ipv6hdr));
434 }
435
436 skb_dst_drop(skb); 416 skb_dst_drop(skb);
437 417
438 ip6_route_input(skb); 418 ip6_route_input(skb);
@@ -453,13 +433,8 @@ looped_back:
453 } 433 }
454 ipv6_hdr(skb)->hop_limit--; 434 ipv6_hdr(skb)->hop_limit--;
455 435
456 /* be sure that srh is still present before reinjecting */ 436 skb_pull(skb, sizeof(struct ipv6hdr));
457 if (!cleanup) { 437 goto looped_back;
458 skb_pull(skb, sizeof(struct ipv6hdr));
459 goto looped_back;
460 }
461 skb_set_transport_header(skb, sizeof(struct ipv6hdr));
462 IP6CB(skb)->nhoff = offsetof(struct ipv6hdr, nexthdr);
463 } 438 }
464 439
465 dst_input(skb); 440 dst_input(skb);
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 558631860d91..630b73be5999 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -367,35 +367,37 @@ static void ip6gre_tunnel_uninit(struct net_device *dev)
367 367
368 368
369static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 369static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
370 u8 type, u8 code, int offset, __be32 info) 370 u8 type, u8 code, int offset, __be32 info)
371{ 371{
372 const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)skb->data; 372 const struct gre_base_hdr *greh;
373 __be16 *p = (__be16 *)(skb->data + offset); 373 const struct ipv6hdr *ipv6h;
374 int grehlen = offset + 4; 374 int grehlen = sizeof(*greh);
375 struct ip6_tnl *t; 375 struct ip6_tnl *t;
376 int key_off = 0;
376 __be16 flags; 377 __be16 flags;
378 __be32 key;
377 379
378 flags = p[0]; 380 if (!pskb_may_pull(skb, offset + grehlen))
379 if (flags&(GRE_CSUM|GRE_KEY|GRE_SEQ|GRE_ROUTING|GRE_VERSION)) { 381 return;
380 if (flags&(GRE_VERSION|GRE_ROUTING)) 382 greh = (const struct gre_base_hdr *)(skb->data + offset);
381 return; 383 flags = greh->flags;
382 if (flags&GRE_KEY) { 384 if (flags & (GRE_VERSION | GRE_ROUTING))
383 grehlen += 4; 385 return;
384 if (flags&GRE_CSUM) 386 if (flags & GRE_CSUM)
385 grehlen += 4; 387 grehlen += 4;
386 } 388 if (flags & GRE_KEY) {
389 key_off = grehlen + offset;
390 grehlen += 4;
387 } 391 }
388 392
389 /* If only 8 bytes returned, keyed message will be dropped here */ 393 if (!pskb_may_pull(skb, offset + grehlen))
390 if (!pskb_may_pull(skb, grehlen))
391 return; 394 return;
392 ipv6h = (const struct ipv6hdr *)skb->data; 395 ipv6h = (const struct ipv6hdr *)skb->data;
393 p = (__be16 *)(skb->data + offset); 396 greh = (const struct gre_base_hdr *)(skb->data + offset);
397 key = key_off ? *(__be32 *)(skb->data + key_off) : 0;
394 398
395 t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr, 399 t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,
396 flags & GRE_KEY ? 400 key, greh->protocol);
397 *(((__be32 *)p) + (grehlen / 4) - 1) : 0,
398 p[1]);
399 if (!t) 401 if (!t)
400 return; 402 return;
401 403
diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c
index 03a064803626..6ef3dfb6e811 100644
--- a/net/ipv6/seg6_hmac.c
+++ b/net/ipv6/seg6_hmac.c
@@ -174,7 +174,7 @@ int seg6_hmac_compute(struct seg6_hmac_info *hinfo, struct ipv6_sr_hdr *hdr,
174 * hash function (RadioGatun) with up to 1216 bits 174 * hash function (RadioGatun) with up to 1216 bits
175 */ 175 */
176 176
177 /* saddr(16) + first_seg(1) + cleanup(1) + keyid(4) + seglist(16n) */ 177 /* saddr(16) + first_seg(1) + flags(1) + keyid(4) + seglist(16n) */
178 plen = 16 + 1 + 1 + 4 + (hdr->first_segment + 1) * 16; 178 plen = 16 + 1 + 1 + 4 + (hdr->first_segment + 1) * 16;
179 179
180 /* this limit allows for 14 segments */ 180 /* this limit allows for 14 segments */
@@ -186,7 +186,7 @@ int seg6_hmac_compute(struct seg6_hmac_info *hinfo, struct ipv6_sr_hdr *hdr,
186 * 186 *
187 * 1. Source IPv6 address (128 bits) 187 * 1. Source IPv6 address (128 bits)
188 * 2. first_segment value (8 bits) 188 * 2. first_segment value (8 bits)
189 * 3. cleanup flag (8 bits: highest bit is cleanup value, others are 0) 189 * 3. Flags (8 bits)
190 * 4. HMAC Key ID (32 bits) 190 * 4. HMAC Key ID (32 bits)
191 * 5. All segments in the segments list (n * 128 bits) 191 * 5. All segments in the segments list (n * 128 bits)
192 */ 192 */
@@ -202,8 +202,8 @@ int seg6_hmac_compute(struct seg6_hmac_info *hinfo, struct ipv6_sr_hdr *hdr,
202 /* first_segment value */ 202 /* first_segment value */
203 *off++ = hdr->first_segment; 203 *off++ = hdr->first_segment;
204 204
205 /* cleanup flag */ 205 /* flags */
206 *off++ = !!(sr_has_cleanup(hdr)) << 7; 206 *off++ = hdr->flags;
207 207
208 /* HMAC Key ID */ 208 /* HMAC Key ID */
209 memcpy(off, &hmackeyid, 4); 209 memcpy(off, &hmackeyid, 4);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index cb8929681dc7..eaad72c3d746 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -991,6 +991,16 @@ drop:
991 return 0; /* don't send reset */ 991 return 0; /* don't send reset */
992} 992}
993 993
994static void tcp_v6_restore_cb(struct sk_buff *skb)
995{
996 /* We need to move header back to the beginning if xfrm6_policy_check()
997 * and tcp_v6_fill_cb() are going to be called again.
998 * ip6_datagram_recv_specific_ctl() also expects IP6CB to be there.
999 */
1000 memmove(IP6CB(skb), &TCP_SKB_CB(skb)->header.h6,
1001 sizeof(struct inet6_skb_parm));
1002}
1003
994static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, 1004static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
995 struct request_sock *req, 1005 struct request_sock *req,
996 struct dst_entry *dst, 1006 struct dst_entry *dst,
@@ -1182,8 +1192,10 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *
1182 sk_gfp_mask(sk, GFP_ATOMIC)); 1192 sk_gfp_mask(sk, GFP_ATOMIC));
1183 consume_skb(ireq->pktopts); 1193 consume_skb(ireq->pktopts);
1184 ireq->pktopts = NULL; 1194 ireq->pktopts = NULL;
1185 if (newnp->pktoptions) 1195 if (newnp->pktoptions) {
1196 tcp_v6_restore_cb(newnp->pktoptions);
1186 skb_set_owner_r(newnp->pktoptions, newsk); 1197 skb_set_owner_r(newnp->pktoptions, newsk);
1198 }
1187 } 1199 }
1188 } 1200 }
1189 1201
@@ -1198,16 +1210,6 @@ out:
1198 return NULL; 1210 return NULL;
1199} 1211}
1200 1212
1201static void tcp_v6_restore_cb(struct sk_buff *skb)
1202{
1203 /* We need to move header back to the beginning if xfrm6_policy_check()
1204 * and tcp_v6_fill_cb() are going to be called again.
1205 * ip6_datagram_recv_specific_ctl() also expects IP6CB to be there.
1206 */
1207 memmove(IP6CB(skb), &TCP_SKB_CB(skb)->header.h6,
1208 sizeof(struct inet6_skb_parm));
1209}
1210
1211/* The socket must have it's spinlock held when we get 1213/* The socket must have it's spinlock held when we get
1212 * here, unless it is a TCP_LISTEN socket. 1214 * here, unless it is a TCP_LISTEN socket.
1213 * 1215 *
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 4d5c4eee4b3f..8990856f5101 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -441,7 +441,7 @@ try_again:
441 return err; 441 return err;
442 442
443csum_copy_err: 443csum_copy_err:
444 if (!__sk_queue_drop_skb(sk, skb, flags)) { 444 if (!__sk_queue_drop_skb(sk, skb, flags, udp_skb_destructor)) {
445 if (is_udp4) { 445 if (is_udp4) {
446 UDP_INC_STATS(sock_net(sk), 446 UDP_INC_STATS(sock_net(sk),
447 UDP_MIB_CSUMERRORS, is_udplite); 447 UDP_MIB_CSUMERRORS, is_udplite);
diff --git a/net/mac80211/fils_aead.c b/net/mac80211/fils_aead.c
index ecfdd97758a3..5c3af5eb4052 100644
--- a/net/mac80211/fils_aead.c
+++ b/net/mac80211/fils_aead.c
@@ -124,7 +124,7 @@ static int aes_siv_encrypt(const u8 *key, size_t key_len,
124 124
125 /* CTR */ 125 /* CTR */
126 126
127 tfm2 = crypto_alloc_skcipher("ctr(aes)", 0, 0); 127 tfm2 = crypto_alloc_skcipher("ctr(aes)", 0, CRYPTO_ALG_ASYNC);
128 if (IS_ERR(tfm2)) { 128 if (IS_ERR(tfm2)) {
129 kfree(tmp); 129 kfree(tmp);
130 return PTR_ERR(tfm2); 130 return PTR_ERR(tfm2);
@@ -183,7 +183,7 @@ static int aes_siv_decrypt(const u8 *key, size_t key_len,
183 183
184 /* CTR */ 184 /* CTR */
185 185
186 tfm2 = crypto_alloc_skcipher("ctr(aes)", 0, 0); 186 tfm2 = crypto_alloc_skcipher("ctr(aes)", 0, CRYPTO_ALG_ASYNC);
187 if (IS_ERR(tfm2)) 187 if (IS_ERR(tfm2))
188 return PTR_ERR(tfm2); 188 return PTR_ERR(tfm2);
189 /* K2 for CTR */ 189 /* K2 for CTR */
@@ -272,7 +272,7 @@ int fils_encrypt_assoc_req(struct sk_buff *skb,
272 crypt_len = skb->data + skb->len - encr; 272 crypt_len = skb->data + skb->len - encr;
273 skb_put(skb, AES_BLOCK_SIZE); 273 skb_put(skb, AES_BLOCK_SIZE);
274 return aes_siv_encrypt(assoc_data->fils_kek, assoc_data->fils_kek_len, 274 return aes_siv_encrypt(assoc_data->fils_kek, assoc_data->fils_kek_len,
275 encr, crypt_len, 1, addr, len, encr); 275 encr, crypt_len, 5, addr, len, encr);
276} 276}
277 277
278int fils_decrypt_assoc_resp(struct ieee80211_sub_if_data *sdata, 278int fils_decrypt_assoc_resp(struct ieee80211_sub_if_data *sdata,
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 42120d965263..50e1b7f78bd4 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -339,7 +339,7 @@ int mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata,
339 /* fast-forward to vendor IEs */ 339 /* fast-forward to vendor IEs */
340 offset = ieee80211_ie_split_vendor(ifmsh->ie, ifmsh->ie_len, 0); 340 offset = ieee80211_ie_split_vendor(ifmsh->ie, ifmsh->ie_len, 0);
341 341
342 if (offset) { 342 if (offset < ifmsh->ie_len) {
343 len = ifmsh->ie_len - offset; 343 len = ifmsh->ie_len - offset;
344 data = ifmsh->ie + offset; 344 data = ifmsh->ie + offset;
345 if (skb_tailroom(skb) < len) 345 if (skb_tailroom(skb) < len)
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 37eeab7899fc..1b5d669e3029 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -239,7 +239,7 @@ static struct sctp_transport *sctp_addr_id2transport(struct sock *sk,
239 union sctp_addr *laddr = (union sctp_addr *)addr; 239 union sctp_addr *laddr = (union sctp_addr *)addr;
240 struct sctp_transport *transport; 240 struct sctp_transport *transport;
241 241
242 if (sctp_verify_addr(sk, laddr, af->sockaddr_len)) 242 if (!af || sctp_verify_addr(sk, laddr, af->sockaddr_len))
243 return NULL; 243 return NULL;
244 244
245 addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep, 245 addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep,
@@ -7426,7 +7426,8 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
7426 */ 7426 */
7427 release_sock(sk); 7427 release_sock(sk);
7428 current_timeo = schedule_timeout(current_timeo); 7428 current_timeo = schedule_timeout(current_timeo);
7429 BUG_ON(sk != asoc->base.sk); 7429 if (sk != asoc->base.sk)
7430 goto do_error;
7430 lock_sock(sk); 7431 lock_sock(sk);
7431 7432
7432 *timeo_p = current_timeo; 7433 *timeo_p = current_timeo;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 5c1b267e22be..aee396b9f190 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5916,6 +5916,7 @@ do { \
5916 break; 5916 break;
5917 } 5917 }
5918 cfg->ht_opmode = ht_opmode; 5918 cfg->ht_opmode = ht_opmode;
5919 mask |= (1 << (NL80211_MESHCONF_HT_OPMODE - 1));
5919 } 5920 }
5920 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout, 5921 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout,
5921 1, 65535, mask, 5922 1, 65535, mask,