aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-09 14:58:28 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-09 14:58:28 -0500
commitc92f5bdc4b9ba509a93f9e386fbb1fa779d4b0d6 (patch)
tree3ab577abbd875761fbc97d776fd31196c2b3c6a9
parenta121103c922847ba5010819a3f250f1f7fc84ab8 (diff)
parent03430fa10b99e95e3a15eb7c00978fb1652f3b24 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Fix dumping of nft_quota entries, from Pablo Neira Ayuso. 2) Fix out of bounds access in nf_tables discovered by KASAN, from Florian Westphal. 3) Fix IRQ enabling in dp83867 driver, from Grygorii Strashko. 4) Fix unicast filtering in be2net driver, from Ivan Vecera. 5) tg3_get_stats64() can race with driver close and ethtool reconfigurations, fix from Michael Chan. 6) Fix error handling when pass limit is reached in bpf code gen on x86. From Daniel Borkmann. 7) Don't clobber switch ops and use proper MDIO nested reads and writes in bcm_sf2 driver, from Florian Fainelli. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (21 commits) net: dsa: bcm_sf2: Utilize nested MDIO read/write net: dsa: bcm_sf2: Do not clobber b53_switch_ops net: stmmac: fix maxmtu assignment to be within valid range bpf: change back to orig prog on too many passes tg3: Fix race condition in tg3_get_stats64(). be2net: fix unicast list filling be2net: fix accesses to unicast list netlabel: add CALIPSO to the list of built-in protocols vti6: fix device register to report IFLA_INFO_KIND net: phy: dp83867: fix irq generation amd-xgbe: Fix IRQ processing when running in single IRQ mode sh_eth: R8A7740 supports packet shecksumming sh_eth: fix EESIPR values for SH77{34|63} r8169: fix the typo in the comment nl80211: fix sched scan netlink socket owner destruction bridge: netfilter: Fix dropping packets that moving through bridge interface netfilter: ipt_CLUSTERIP: check duplicate config when initializing netfilter: nft_payload: mangle ckecksum if NFT_PAYLOAD_L4CSUM_PSEUDOHDR is set netfilter: nf_tables: fix oob access netfilter: nft_queue: use raw_smp_processor_id() ...
-rw-r--r--arch/x86/net/bpf_jit_comp.c2
-rw-r--r--drivers/net/dsa/bcm_sf2.c11
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-drv.c2
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c3
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c12
-rw-r--r--drivers/net/ethernet/realtek/r8169.c2
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c5
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c10
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c6
-rw-r--r--drivers/net/phy/dp83867.c10
-rw-r--r--net/bridge/br_netfilter_hooks.c2
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c34
-rw-r--r--net/ipv6/ip6_vti.c2
-rw-r--r--net/netfilter/nf_tables_api.c2
-rw-r--r--net/netfilter/nft_payload.c27
-rw-r--r--net/netfilter/nft_queue.c2
-rw-r--r--net/netfilter/nft_quota.c26
-rw-r--r--net/netlabel/netlabel_kapi.c5
-rw-r--r--net/wireless/nl80211.c16
19 files changed, 116 insertions, 63 deletions
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index e76d1af60f7a..bb660e53cbd6 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -1172,6 +1172,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
1172 set_memory_ro((unsigned long)header, header->pages); 1172 set_memory_ro((unsigned long)header, header->pages);
1173 prog->bpf_func = (void *)image; 1173 prog->bpf_func = (void *)image;
1174 prog->jited = 1; 1174 prog->jited = 1;
1175 } else {
1176 prog = orig_prog;
1175 } 1177 }
1176 1178
1177out_addrs: 1179out_addrs:
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 9ec33b51a0ed..2ce7ae97ac91 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -393,7 +393,7 @@ static int bcm_sf2_sw_mdio_read(struct mii_bus *bus, int addr, int regnum)
393 if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr)) 393 if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
394 return bcm_sf2_sw_indir_rw(priv, 1, addr, regnum, 0); 394 return bcm_sf2_sw_indir_rw(priv, 1, addr, regnum, 0);
395 else 395 else
396 return mdiobus_read(priv->master_mii_bus, addr, regnum); 396 return mdiobus_read_nested(priv->master_mii_bus, addr, regnum);
397} 397}
398 398
399static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum, 399static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum,
@@ -407,7 +407,7 @@ static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum,
407 if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr)) 407 if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
408 bcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val); 408 bcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val);
409 else 409 else
410 mdiobus_write(priv->master_mii_bus, addr, regnum, val); 410 mdiobus_write_nested(priv->master_mii_bus, addr, regnum, val);
411 411
412 return 0; 412 return 0;
413} 413}
@@ -982,6 +982,7 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
982 const char *reg_names[BCM_SF2_REGS_NUM] = BCM_SF2_REGS_NAME; 982 const char *reg_names[BCM_SF2_REGS_NUM] = BCM_SF2_REGS_NAME;
983 struct device_node *dn = pdev->dev.of_node; 983 struct device_node *dn = pdev->dev.of_node;
984 struct b53_platform_data *pdata; 984 struct b53_platform_data *pdata;
985 struct dsa_switch_ops *ops;
985 struct bcm_sf2_priv *priv; 986 struct bcm_sf2_priv *priv;
986 struct b53_device *dev; 987 struct b53_device *dev;
987 struct dsa_switch *ds; 988 struct dsa_switch *ds;
@@ -995,6 +996,10 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
995 if (!priv) 996 if (!priv)
996 return -ENOMEM; 997 return -ENOMEM;
997 998
999 ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
1000 if (!ops)
1001 return -ENOMEM;
1002
998 dev = b53_switch_alloc(&pdev->dev, &bcm_sf2_io_ops, priv); 1003 dev = b53_switch_alloc(&pdev->dev, &bcm_sf2_io_ops, priv);
999 if (!dev) 1004 if (!dev)
1000 return -ENOMEM; 1005 return -ENOMEM;
@@ -1014,6 +1019,8 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
1014 ds = dev->ds; 1019 ds = dev->ds;
1015 1020
1016 /* Override the parts that are non-standard wrt. normal b53 devices */ 1021 /* Override the parts that are non-standard wrt. normal b53 devices */
1022 memcpy(ops, ds->ops, sizeof(*ops));
1023 ds->ops = ops;
1017 ds->ops->get_tag_protocol = bcm_sf2_sw_get_tag_protocol; 1024 ds->ops->get_tag_protocol = bcm_sf2_sw_get_tag_protocol;
1018 ds->ops->setup = bcm_sf2_sw_setup; 1025 ds->ops->setup = bcm_sf2_sw_setup;
1019 ds->ops->get_phy_flags = bcm_sf2_sw_get_phy_flags; 1026 ds->ops->get_phy_flags = bcm_sf2_sw_get_phy_flags;
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 155190db682d..9943629fcbf9 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -539,6 +539,7 @@ static irqreturn_t xgbe_isr(int irq, void *data)
539 } 539 }
540 } 540 }
541 541
542isr_done:
542 /* If there is not a separate AN irq, handle it here */ 543 /* If there is not a separate AN irq, handle it here */
543 if (pdata->dev_irq == pdata->an_irq) 544 if (pdata->dev_irq == pdata->an_irq)
544 pdata->phy_if.an_isr(irq, pdata); 545 pdata->phy_if.an_isr(irq, pdata);
@@ -551,7 +552,6 @@ static irqreturn_t xgbe_isr(int irq, void *data)
551 if (pdata->vdata->i2c_support && (pdata->dev_irq == pdata->i2c_irq)) 552 if (pdata->vdata->i2c_support && (pdata->dev_irq == pdata->i2c_irq))
552 pdata->i2c_if.i2c_isr(irq, pdata); 553 pdata->i2c_if.i2c_isr(irq, pdata);
553 554
554isr_done:
555 return IRQ_HANDLED; 555 return IRQ_HANDLED;
556} 556}
557 557
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 185e9e047aa9..ae42de4fdddf 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -8720,11 +8720,14 @@ static void tg3_free_consistent(struct tg3 *tp)
8720 tg3_mem_rx_release(tp); 8720 tg3_mem_rx_release(tp);
8721 tg3_mem_tx_release(tp); 8721 tg3_mem_tx_release(tp);
8722 8722
8723 /* Protect tg3_get_stats64() from reading freed tp->hw_stats. */
8724 tg3_full_lock(tp, 0);
8723 if (tp->hw_stats) { 8725 if (tp->hw_stats) {
8724 dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats), 8726 dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats),
8725 tp->hw_stats, tp->stats_mapping); 8727 tp->hw_stats, tp->stats_mapping);
8726 tp->hw_stats = NULL; 8728 tp->hw_stats = NULL;
8727 } 8729 }
8730 tg3_full_unlock(tp);
8728} 8731}
8729 8732
8730/* 8733/*
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 225e9a4877d7..ec010ced6c99 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -275,8 +275,7 @@ static int be_dev_mac_add(struct be_adapter *adapter, u8 *mac)
275 275
276 /* Check if mac has already been added as part of uc-list */ 276 /* Check if mac has already been added as part of uc-list */
277 for (i = 0; i < adapter->uc_macs; i++) { 277 for (i = 0; i < adapter->uc_macs; i++) {
278 if (ether_addr_equal((u8 *)&adapter->uc_list[i * ETH_ALEN], 278 if (ether_addr_equal(adapter->uc_list[i].mac, mac)) {
279 mac)) {
280 /* mac already added, skip addition */ 279 /* mac already added, skip addition */
281 adapter->pmac_id[0] = adapter->pmac_id[i + 1]; 280 adapter->pmac_id[0] = adapter->pmac_id[i + 1];
282 return 0; 281 return 0;
@@ -1655,14 +1654,12 @@ static void be_clear_mc_list(struct be_adapter *adapter)
1655 1654
1656static int be_uc_mac_add(struct be_adapter *adapter, int uc_idx) 1655static int be_uc_mac_add(struct be_adapter *adapter, int uc_idx)
1657{ 1656{
1658 if (ether_addr_equal((u8 *)&adapter->uc_list[uc_idx * ETH_ALEN], 1657 if (ether_addr_equal(adapter->uc_list[uc_idx].mac, adapter->dev_mac)) {
1659 adapter->dev_mac)) {
1660 adapter->pmac_id[uc_idx + 1] = adapter->pmac_id[0]; 1658 adapter->pmac_id[uc_idx + 1] = adapter->pmac_id[0];
1661 return 0; 1659 return 0;
1662 } 1660 }
1663 1661
1664 return be_cmd_pmac_add(adapter, 1662 return be_cmd_pmac_add(adapter, adapter->uc_list[uc_idx].mac,
1665 (u8 *)&adapter->uc_list[uc_idx * ETH_ALEN],
1666 adapter->if_handle, 1663 adapter->if_handle,
1667 &adapter->pmac_id[uc_idx + 1], 0); 1664 &adapter->pmac_id[uc_idx + 1], 0);
1668} 1665}
@@ -1698,9 +1695,8 @@ static void be_set_uc_list(struct be_adapter *adapter)
1698 } 1695 }
1699 1696
1700 if (adapter->update_uc_list) { 1697 if (adapter->update_uc_list) {
1701 i = 1; /* First slot is claimed by the Primary MAC */
1702
1703 /* cache the uc-list in adapter array */ 1698 /* cache the uc-list in adapter array */
1699 i = 0;
1704 netdev_for_each_uc_addr(ha, netdev) { 1700 netdev_for_each_uc_addr(ha, netdev) {
1705 ether_addr_copy(adapter->uc_list[i].mac, ha->addr); 1701 ether_addr_copy(adapter->uc_list[i].mac, ha->addr);
1706 i++; 1702 i++;
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 44389c90056a..8f1623bf2134 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -696,7 +696,7 @@ enum rtl_tx_desc_bit_1 {
696enum rtl_rx_desc_bit { 696enum rtl_rx_desc_bit {
697 /* Rx private */ 697 /* Rx private */
698 PID1 = (1 << 18), /* Protocol ID bit 1/2 */ 698 PID1 = (1 << 18), /* Protocol ID bit 1/2 */
699 PID0 = (1 << 17), /* Protocol ID bit 2/2 */ 699 PID0 = (1 << 17), /* Protocol ID bit 0/2 */
700 700
701#define RxProtoUDP (PID1) 701#define RxProtoUDP (PID1)
702#define RxProtoTCP (PID0) 702#define RxProtoTCP (PID0)
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 00fafabab1d0..f729a6b43958 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -574,6 +574,7 @@ static struct sh_eth_cpu_data r8a7740_data = {
574 .rpadir_value = 2 << 16, 574 .rpadir_value = 2 << 16,
575 .no_trimd = 1, 575 .no_trimd = 1,
576 .no_ade = 1, 576 .no_ade = 1,
577 .hw_crc = 1,
577 .tsu = 1, 578 .tsu = 1,
578 .select_mii = 1, 579 .select_mii = 1,
579 .shift_rd0 = 1, 580 .shift_rd0 = 1,
@@ -802,7 +803,7 @@ static struct sh_eth_cpu_data sh7734_data = {
802 803
803 .ecsr_value = ECSR_ICD | ECSR_MPD, 804 .ecsr_value = ECSR_ICD | ECSR_MPD,
804 .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP, 805 .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP,
805 .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, 806 .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003f07ff,
806 807
807 .tx_check = EESR_TC1 | EESR_FTC, 808 .tx_check = EESR_TC1 | EESR_FTC,
808 .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | 809 .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT |
@@ -832,7 +833,7 @@ static struct sh_eth_cpu_data sh7763_data = {
832 833
833 .ecsr_value = ECSR_ICD | ECSR_MPD, 834 .ecsr_value = ECSR_ICD | ECSR_MPD,
834 .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP, 835 .ecsipr_value = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP,
835 .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, 836 .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003f07ff,
836 837
837 .tx_check = EESR_TC1 | EESR_FTC, 838 .tx_check = EESR_TC1 | EESR_FTC,
838 .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | 839 .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 39eb7a65bb9f..a276a32d57f2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3319,8 +3319,16 @@ int stmmac_dvr_probe(struct device *device,
3319 ndev->max_mtu = JUMBO_LEN; 3319 ndev->max_mtu = JUMBO_LEN;
3320 else 3320 else
3321 ndev->max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN); 3321 ndev->max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN);
3322 if (priv->plat->maxmtu < ndev->max_mtu) 3322 /* Will not overwrite ndev->max_mtu if plat->maxmtu > ndev->max_mtu
3323 * as well as plat->maxmtu < ndev->min_mtu which is a invalid range.
3324 */
3325 if ((priv->plat->maxmtu < ndev->max_mtu) &&
3326 (priv->plat->maxmtu >= ndev->min_mtu))
3323 ndev->max_mtu = priv->plat->maxmtu; 3327 ndev->max_mtu = priv->plat->maxmtu;
3328 else if (priv->plat->maxmtu < ndev->min_mtu)
3329 netdev_warn(priv->dev,
3330 "%s: warning: maxmtu having invalid value (%d)\n",
3331 __func__, priv->plat->maxmtu);
3324 3332
3325 if (flow_ctrl) 3333 if (flow_ctrl)
3326 priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */ 3334 priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index a2831773431a..3da4737620cb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -89,6 +89,9 @@ static void stmmac_default_data(struct plat_stmmacenet_data *plat)
89 89
90 /* Set default value for unicast filter entries */ 90 /* Set default value for unicast filter entries */
91 plat->unicast_filter_entries = 1; 91 plat->unicast_filter_entries = 1;
92
93 /* Set the maxmtu to a default of JUMBO_LEN */
94 plat->maxmtu = JUMBO_LEN;
92} 95}
93 96
94static int quark_default_data(struct plat_stmmacenet_data *plat, 97static int quark_default_data(struct plat_stmmacenet_data *plat,
@@ -126,6 +129,9 @@ static int quark_default_data(struct plat_stmmacenet_data *plat,
126 /* Set default value for unicast filter entries */ 129 /* Set default value for unicast filter entries */
127 plat->unicast_filter_entries = 1; 130 plat->unicast_filter_entries = 1;
128 131
132 /* Set the maxmtu to a default of JUMBO_LEN */
133 plat->maxmtu = JUMBO_LEN;
134
129 return 0; 135 return 0;
130} 136}
131 137
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 1b639242f9e2..e84ae084e259 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -29,6 +29,7 @@
29#define MII_DP83867_MICR 0x12 29#define MII_DP83867_MICR 0x12
30#define MII_DP83867_ISR 0x13 30#define MII_DP83867_ISR 0x13
31#define DP83867_CTRL 0x1f 31#define DP83867_CTRL 0x1f
32#define DP83867_CFG3 0x1e
32 33
33/* Extended Registers */ 34/* Extended Registers */
34#define DP83867_RGMIICTL 0x0032 35#define DP83867_RGMIICTL 0x0032
@@ -98,6 +99,8 @@ static int dp83867_config_intr(struct phy_device *phydev)
98 micr_status |= 99 micr_status |=
99 (MII_DP83867_MICR_AN_ERR_INT_EN | 100 (MII_DP83867_MICR_AN_ERR_INT_EN |
100 MII_DP83867_MICR_SPEED_CHNG_INT_EN | 101 MII_DP83867_MICR_SPEED_CHNG_INT_EN |
102 MII_DP83867_MICR_AUTONEG_COMP_INT_EN |
103 MII_DP83867_MICR_LINK_STS_CHNG_INT_EN |
101 MII_DP83867_MICR_DUP_MODE_CHNG_INT_EN | 104 MII_DP83867_MICR_DUP_MODE_CHNG_INT_EN |
102 MII_DP83867_MICR_SLEEP_MODE_CHNG_INT_EN); 105 MII_DP83867_MICR_SLEEP_MODE_CHNG_INT_EN);
103 106
@@ -214,6 +217,13 @@ static int dp83867_config_init(struct phy_device *phydev)
214 } 217 }
215 } 218 }
216 219
220 /* Enable Interrupt output INT_OE in CFG3 register */
221 if (phy_interrupt_is_valid(phydev)) {
222 val = phy_read(phydev, DP83867_CFG3);
223 val |= BIT(7);
224 phy_write(phydev, DP83867_CFG3, val);
225 }
226
217 return 0; 227 return 0;
218} 228}
219 229
diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c
index 8ca6a929bf12..95087e6e8258 100644
--- a/net/bridge/br_netfilter_hooks.c
+++ b/net/bridge/br_netfilter_hooks.c
@@ -399,7 +399,7 @@ bridged_dnat:
399 br_nf_hook_thresh(NF_BR_PRE_ROUTING, 399 br_nf_hook_thresh(NF_BR_PRE_ROUTING,
400 net, sk, skb, skb->dev, 400 net, sk, skb, skb->dev,
401 NULL, 401 NULL,
402 br_nf_pre_routing_finish); 402 br_nf_pre_routing_finish_bridge);
403 return 0; 403 return 0;
404 } 404 }
405 ether_addr_copy(eth_hdr(skb)->h_dest, dev->dev_addr); 405 ether_addr_copy(eth_hdr(skb)->h_dest, dev->dev_addr);
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index 21db00d0362b..a6b8c1a4102b 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -144,7 +144,7 @@ clusterip_config_find_get(struct net *net, __be32 clusterip, int entry)
144 rcu_read_lock_bh(); 144 rcu_read_lock_bh();
145 c = __clusterip_config_find(net, clusterip); 145 c = __clusterip_config_find(net, clusterip);
146 if (c) { 146 if (c) {
147 if (unlikely(!atomic_inc_not_zero(&c->refcount))) 147 if (!c->pde || unlikely(!atomic_inc_not_zero(&c->refcount)))
148 c = NULL; 148 c = NULL;
149 else if (entry) 149 else if (entry)
150 atomic_inc(&c->entries); 150 atomic_inc(&c->entries);
@@ -166,14 +166,15 @@ clusterip_config_init_nodelist(struct clusterip_config *c,
166 166
167static struct clusterip_config * 167static struct clusterip_config *
168clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip, 168clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip,
169 struct net_device *dev) 169 struct net_device *dev)
170{ 170{
171 struct net *net = dev_net(dev);
171 struct clusterip_config *c; 172 struct clusterip_config *c;
172 struct clusterip_net *cn = net_generic(dev_net(dev), clusterip_net_id); 173 struct clusterip_net *cn = net_generic(net, clusterip_net_id);
173 174
174 c = kzalloc(sizeof(*c), GFP_ATOMIC); 175 c = kzalloc(sizeof(*c), GFP_ATOMIC);
175 if (!c) 176 if (!c)
176 return NULL; 177 return ERR_PTR(-ENOMEM);
177 178
178 c->dev = dev; 179 c->dev = dev;
179 c->clusterip = ip; 180 c->clusterip = ip;
@@ -185,6 +186,17 @@ clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip,
185 atomic_set(&c->refcount, 1); 186 atomic_set(&c->refcount, 1);
186 atomic_set(&c->entries, 1); 187 atomic_set(&c->entries, 1);
187 188
189 spin_lock_bh(&cn->lock);
190 if (__clusterip_config_find(net, ip)) {
191 spin_unlock_bh(&cn->lock);
192 kfree(c);
193
194 return ERR_PTR(-EBUSY);
195 }
196
197 list_add_rcu(&c->list, &cn->configs);
198 spin_unlock_bh(&cn->lock);
199
188#ifdef CONFIG_PROC_FS 200#ifdef CONFIG_PROC_FS
189 { 201 {
190 char buffer[16]; 202 char buffer[16];
@@ -195,16 +207,16 @@ clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip,
195 cn->procdir, 207 cn->procdir,
196 &clusterip_proc_fops, c); 208 &clusterip_proc_fops, c);
197 if (!c->pde) { 209 if (!c->pde) {
210 spin_lock_bh(&cn->lock);
211 list_del_rcu(&c->list);
212 spin_unlock_bh(&cn->lock);
198 kfree(c); 213 kfree(c);
199 return NULL; 214
215 return ERR_PTR(-ENOMEM);
200 } 216 }
201 } 217 }
202#endif 218#endif
203 219
204 spin_lock_bh(&cn->lock);
205 list_add_rcu(&c->list, &cn->configs);
206 spin_unlock_bh(&cn->lock);
207
208 return c; 220 return c;
209} 221}
210 222
@@ -410,9 +422,9 @@ static int clusterip_tg_check(const struct xt_tgchk_param *par)
410 422
411 config = clusterip_config_init(cipinfo, 423 config = clusterip_config_init(cipinfo,
412 e->ip.dst.s_addr, dev); 424 e->ip.dst.s_addr, dev);
413 if (!config) { 425 if (IS_ERR(config)) {
414 dev_put(dev); 426 dev_put(dev);
415 return -ENOMEM; 427 return PTR_ERR(config);
416 } 428 }
417 dev_mc_add(config->dev, config->clustermac); 429 dev_mc_add(config->dev, config->clustermac);
418 } 430 }
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index f4b4a4a5f4ba..d82042c8d8fd 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -189,12 +189,12 @@ static int vti6_tnl_create2(struct net_device *dev)
189 struct vti6_net *ip6n = net_generic(net, vti6_net_id); 189 struct vti6_net *ip6n = net_generic(net, vti6_net_id);
190 int err; 190 int err;
191 191
192 dev->rtnl_link_ops = &vti6_link_ops;
192 err = register_netdevice(dev); 193 err = register_netdevice(dev);
193 if (err < 0) 194 if (err < 0)
194 goto out; 195 goto out;
195 196
196 strcpy(t->parms.name, dev->name); 197 strcpy(t->parms.name, dev->name);
197 dev->rtnl_link_ops = &vti6_link_ops;
198 198
199 dev_hold(dev); 199 dev_hold(dev);
200 vti6_tnl_link(ip6n, t); 200 vti6_tnl_link(ip6n, t);
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index a019a87e58ee..0db5f9782265 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -2115,7 +2115,7 @@ static void nf_tables_rule_destroy(const struct nft_ctx *ctx,
2115 * is called on error from nf_tables_newrule(). 2115 * is called on error from nf_tables_newrule().
2116 */ 2116 */
2117 expr = nft_expr_first(rule); 2117 expr = nft_expr_first(rule);
2118 while (expr->ops && expr != nft_expr_last(rule)) { 2118 while (expr != nft_expr_last(rule) && expr->ops) {
2119 nf_tables_expr_destroy(ctx, expr); 2119 nf_tables_expr_destroy(ctx, expr);
2120 expr = nft_expr_next(expr); 2120 expr = nft_expr_next(expr);
2121 } 2121 }
diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c
index 36d2b1096546..7d699bbd45b0 100644
--- a/net/netfilter/nft_payload.c
+++ b/net/netfilter/nft_payload.c
@@ -250,6 +250,22 @@ static int nft_payload_l4csum_update(const struct nft_pktinfo *pkt,
250 return 0; 250 return 0;
251} 251}
252 252
253static int nft_payload_csum_inet(struct sk_buff *skb, const u32 *src,
254 __wsum fsum, __wsum tsum, int csum_offset)
255{
256 __sum16 sum;
257
258 if (skb_copy_bits(skb, csum_offset, &sum, sizeof(sum)) < 0)
259 return -1;
260
261 nft_csum_replace(&sum, fsum, tsum);
262 if (!skb_make_writable(skb, csum_offset + sizeof(sum)) ||
263 skb_store_bits(skb, csum_offset, &sum, sizeof(sum)) < 0)
264 return -1;
265
266 return 0;
267}
268
253static void nft_payload_set_eval(const struct nft_expr *expr, 269static void nft_payload_set_eval(const struct nft_expr *expr,
254 struct nft_regs *regs, 270 struct nft_regs *regs,
255 const struct nft_pktinfo *pkt) 271 const struct nft_pktinfo *pkt)
@@ -259,7 +275,6 @@ static void nft_payload_set_eval(const struct nft_expr *expr,
259 const u32 *src = &regs->data[priv->sreg]; 275 const u32 *src = &regs->data[priv->sreg];
260 int offset, csum_offset; 276 int offset, csum_offset;
261 __wsum fsum, tsum; 277 __wsum fsum, tsum;
262 __sum16 sum;
263 278
264 switch (priv->base) { 279 switch (priv->base) {
265 case NFT_PAYLOAD_LL_HEADER: 280 case NFT_PAYLOAD_LL_HEADER:
@@ -282,18 +297,14 @@ static void nft_payload_set_eval(const struct nft_expr *expr,
282 csum_offset = offset + priv->csum_offset; 297 csum_offset = offset + priv->csum_offset;
283 offset += priv->offset; 298 offset += priv->offset;
284 299
285 if (priv->csum_type == NFT_PAYLOAD_CSUM_INET && 300 if ((priv->csum_type == NFT_PAYLOAD_CSUM_INET || priv->csum_flags) &&
286 (priv->base != NFT_PAYLOAD_TRANSPORT_HEADER || 301 (priv->base != NFT_PAYLOAD_TRANSPORT_HEADER ||
287 skb->ip_summed != CHECKSUM_PARTIAL)) { 302 skb->ip_summed != CHECKSUM_PARTIAL)) {
288 if (skb_copy_bits(skb, csum_offset, &sum, sizeof(sum)) < 0)
289 goto err;
290
291 fsum = skb_checksum(skb, offset, priv->len, 0); 303 fsum = skb_checksum(skb, offset, priv->len, 0);
292 tsum = csum_partial(src, priv->len, 0); 304 tsum = csum_partial(src, priv->len, 0);
293 nft_csum_replace(&sum, fsum, tsum);
294 305
295 if (!skb_make_writable(skb, csum_offset + sizeof(sum)) || 306 if (priv->csum_type == NFT_PAYLOAD_CSUM_INET &&
296 skb_store_bits(skb, csum_offset, &sum, sizeof(sum)) < 0) 307 nft_payload_csum_inet(skb, src, fsum, tsum, csum_offset))
297 goto err; 308 goto err;
298 309
299 if (priv->csum_flags && 310 if (priv->csum_flags &&
diff --git a/net/netfilter/nft_queue.c b/net/netfilter/nft_queue.c
index 3e19fa1230dc..dbb6aaff67ec 100644
--- a/net/netfilter/nft_queue.c
+++ b/net/netfilter/nft_queue.c
@@ -38,7 +38,7 @@ static void nft_queue_eval(const struct nft_expr *expr,
38 38
39 if (priv->queues_total > 1) { 39 if (priv->queues_total > 1) {
40 if (priv->flags & NFT_QUEUE_FLAG_CPU_FANOUT) { 40 if (priv->flags & NFT_QUEUE_FLAG_CPU_FANOUT) {
41 int cpu = smp_processor_id(); 41 int cpu = raw_smp_processor_id();
42 42
43 queue = priv->queuenum + cpu % priv->queues_total; 43 queue = priv->queuenum + cpu % priv->queues_total;
44 } else { 44 } else {
diff --git a/net/netfilter/nft_quota.c b/net/netfilter/nft_quota.c
index bd6efc53f26d..2d6fe3559912 100644
--- a/net/netfilter/nft_quota.c
+++ b/net/netfilter/nft_quota.c
@@ -110,30 +110,32 @@ static int nft_quota_obj_init(const struct nlattr * const tb[],
110static int nft_quota_do_dump(struct sk_buff *skb, struct nft_quota *priv, 110static int nft_quota_do_dump(struct sk_buff *skb, struct nft_quota *priv,
111 bool reset) 111 bool reset)
112{ 112{
113 u64 consumed, consumed_cap;
113 u32 flags = priv->flags; 114 u32 flags = priv->flags;
114 u64 consumed;
115
116 if (reset) {
117 consumed = atomic64_xchg(&priv->consumed, 0);
118 if (test_and_clear_bit(NFT_QUOTA_DEPLETED_BIT, &priv->flags))
119 flags |= NFT_QUOTA_F_DEPLETED;
120 } else {
121 consumed = atomic64_read(&priv->consumed);
122 }
123 115
124 /* Since we inconditionally increment consumed quota for each packet 116 /* Since we inconditionally increment consumed quota for each packet
125 * that we see, don't go over the quota boundary in what we send to 117 * that we see, don't go over the quota boundary in what we send to
126 * userspace. 118 * userspace.
127 */ 119 */
128 if (consumed > priv->quota) 120 consumed = atomic64_read(&priv->consumed);
129 consumed = priv->quota; 121 if (consumed >= priv->quota) {
122 consumed_cap = priv->quota;
123 flags |= NFT_QUOTA_F_DEPLETED;
124 } else {
125 consumed_cap = consumed;
126 }
130 127
131 if (nla_put_be64(skb, NFTA_QUOTA_BYTES, cpu_to_be64(priv->quota), 128 if (nla_put_be64(skb, NFTA_QUOTA_BYTES, cpu_to_be64(priv->quota),
132 NFTA_QUOTA_PAD) || 129 NFTA_QUOTA_PAD) ||
133 nla_put_be64(skb, NFTA_QUOTA_CONSUMED, cpu_to_be64(consumed), 130 nla_put_be64(skb, NFTA_QUOTA_CONSUMED, cpu_to_be64(consumed_cap),
134 NFTA_QUOTA_PAD) || 131 NFTA_QUOTA_PAD) ||
135 nla_put_be32(skb, NFTA_QUOTA_FLAGS, htonl(flags))) 132 nla_put_be32(skb, NFTA_QUOTA_FLAGS, htonl(flags)))
136 goto nla_put_failure; 133 goto nla_put_failure;
134
135 if (reset) {
136 atomic64_sub(consumed, &priv->consumed);
137 clear_bit(NFT_QUOTA_DEPLETED_BIT, &priv->flags);
138 }
137 return 0; 139 return 0;
138 140
139nla_put_failure: 141nla_put_failure:
diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
index 28c56b95fb7f..ea7c67050792 100644
--- a/net/netlabel/netlabel_kapi.c
+++ b/net/netlabel/netlabel_kapi.c
@@ -1502,10 +1502,7 @@ static int __init netlbl_init(void)
1502 printk(KERN_INFO "NetLabel: Initializing\n"); 1502 printk(KERN_INFO "NetLabel: Initializing\n");
1503 printk(KERN_INFO "NetLabel: domain hash size = %u\n", 1503 printk(KERN_INFO "NetLabel: domain hash size = %u\n",
1504 (1 << NETLBL_DOMHSH_BITSIZE)); 1504 (1 << NETLBL_DOMHSH_BITSIZE));
1505 printk(KERN_INFO "NetLabel: protocols =" 1505 printk(KERN_INFO "NetLabel: protocols = UNLABELED CIPSOv4 CALIPSO\n");
1506 " UNLABELED"
1507 " CIPSOv4"
1508 "\n");
1509 1506
1510 ret_val = netlbl_domhsh_init(NETLBL_DOMHSH_BITSIZE); 1507 ret_val = netlbl_domhsh_init(NETLBL_DOMHSH_BITSIZE);
1511 if (ret_val != 0) 1508 if (ret_val != 0)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 3df85a751a85..ef5eff93a8b8 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -14502,13 +14502,17 @@ static int nl80211_netlink_notify(struct notifier_block * nb,
14502 14502
14503 list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) { 14503 list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) {
14504 bool schedule_destroy_work = false; 14504 bool schedule_destroy_work = false;
14505 bool schedule_scan_stop = false;
14506 struct cfg80211_sched_scan_request *sched_scan_req = 14505 struct cfg80211_sched_scan_request *sched_scan_req =
14507 rcu_dereference(rdev->sched_scan_req); 14506 rcu_dereference(rdev->sched_scan_req);
14508 14507
14509 if (sched_scan_req && notify->portid && 14508 if (sched_scan_req && notify->portid &&
14510 sched_scan_req->owner_nlportid == notify->portid) 14509 sched_scan_req->owner_nlportid == notify->portid) {
14511 schedule_scan_stop = true; 14510 sched_scan_req->owner_nlportid = 0;
14511
14512 if (rdev->ops->sched_scan_stop &&
14513 rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN)
14514 schedule_work(&rdev->sched_scan_stop_wk);
14515 }
14512 14516
14513 list_for_each_entry_rcu(wdev, &rdev->wiphy.wdev_list, list) { 14517 list_for_each_entry_rcu(wdev, &rdev->wiphy.wdev_list, list) {
14514 cfg80211_mlme_unregister_socket(wdev, notify->portid); 14518 cfg80211_mlme_unregister_socket(wdev, notify->portid);
@@ -14539,12 +14543,6 @@ static int nl80211_netlink_notify(struct notifier_block * nb,
14539 spin_unlock(&rdev->destroy_list_lock); 14543 spin_unlock(&rdev->destroy_list_lock);
14540 schedule_work(&rdev->destroy_work); 14544 schedule_work(&rdev->destroy_work);
14541 } 14545 }
14542 } else if (schedule_scan_stop) {
14543 sched_scan_req->owner_nlportid = 0;
14544
14545 if (rdev->ops->sched_scan_stop &&
14546 rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN)
14547 schedule_work(&rdev->sched_scan_stop_wk);
14548 } 14546 }
14549 } 14547 }
14550 14548