History

Merge tag 'net-6.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Pull networking fixes from Jakub Kicinski: "Including fixes from netfilter, wireless and bluetooth. Kalle Valo steps down after serving as the WiFi driver maintainer for over a decade. Current release - fix to a fix: - vsock: orphan socket after transport release, avoid null-deref - Bluetooth: L2CAP: fix corrupted list in hci_chan_del Current release - regressions: - eth: - stmmac: correct Rx buffer layout when SPH is enabled - iavf: fix a locking bug in an error path - rxrpc: fix alteration of headers whilst zerocopy pending - s390/qeth: move netif_napi_add_tx() and napi_enable() from under BH - Revert "netfilter: flowtable: teardown flow if cached mtu is stale" Current release - new code bugs: - rxrpc: fix ipv6 path MTU discovery, only ipv4 worked - pse-pd: fix deadlock in current limit functions Previous releases - regressions: - rtnetlink: fix netns refleak with rtnl_setlink() - wifi: brcmfmac: use random seed flag for BCM4355 and BCM4364 firmware Previous releases - always broken: - add missing RCU protection of struct net throughout the stack - can: rockchip: bail out if skb cannot be allocated - eth: ti: am65-cpsw: base XDP support fixes Misc: - ethtool: tsconfig: update the format of hwtstamp flags, changes the uAPI but this uAPI was not in any release yet" * tag 'net-6.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (72 commits) net: pse-pd: Fix deadlock in current limit functions rxrpc: Fix ipv6 path MTU discovery Reapply "net: skb: introduce and use a single page frag cache" s390/qeth: move netif_napi_add_tx() and napi_enable() from under BH mlxsw: Add return value check for mlxsw_sp_port_get_stats_raw() ipv6: mcast: add RCU protection to mld_newpack() team: better TEAM_OPTION_TYPE_STRING validation Bluetooth: L2CAP: Fix corrupted list in hci_chan_del Bluetooth: btintel_pcie: Fix a potential race condition Bluetooth: L2CAP: Fix slab-use-after-free Read in l2cap_send_cmd net: ethernet: ti: am65_cpsw: fix tx_cleanup for XDP case net: ethernet: ti: am65-cpsw: fix RX & TX statistics for XDP_TX case net: ethernet: ti: am65-cpsw: fix memleak in certain XDP cases vsock/test: Add test for SO_LINGER null ptr deref vsock: Orphan socket after transport release MAINTAINERS: Add sctp headers to the general netdev entry Revert "netfilter: flowtable: teardown flow if cached mtu is stale" iavf: Fix a locking bug in an error path rxrpc: Fix alteration of headers whilst zerocopy pending net: phylink: make configuring clock-stop dependent on MAC support ...

Linus Torvalds committed 1 year ago

Commit 348f9682 parents 945ce41 488fb6e75 files · +707 −456Browse files

Unified · Split

75 files
  1. .mailmap +1 −0
  2. Documentation/devicetree/bindings/net/wireless/qcom,ath10k.yaml +0 −1
  3. Documentation/devicetree/bindings/net/wireless/qcom,ath11k-pci.yaml +0 −1
  4. Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml +0 −1
  5. Documentation/devicetree/bindings/net/wireless/qcom,ath12k-wsi.yaml +0 −1
  6. Documentation/devicetree/bindings/net/wireless/qcom,ath12k.yaml +0 −1
  7. Documentation/netlink/specs/ethtool.yaml +2 −1
  8. Documentation/networking/iso15765-2.rst +2 −2
  9. MAINTAINERS +3 −5
  10. drivers/bluetooth/btintel_pcie.c +4 −1
  11. drivers/net/can/c_can/c_can_platform.c +3 −2
  12. drivers/net/can/ctucanfd/ctucanfd_base.c +6 −4
  13. drivers/net/can/rockchip/rockchip_canfd-core.c +1 −1
  14. drivers/net/can/usb/etas_es58x/es58x_devlink.c +5 −1
  15. drivers/net/ethernet/intel/iavf/iavf_main.c +1 −1
  16. drivers/net/ethernet/intel/idpf/idpf_lib.c +5 −0
  17. drivers/net/ethernet/intel/idpf/idpf_txrx.c +1 −4
  18. drivers/net/ethernet/intel/igc/igc_main.c +13 −9
  19. drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1 −1
  20. drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c +3 −1
  21. drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 −0
  22. drivers/net/ethernet/ti/am65-cpsw-nuss.c +31 −19
  23. drivers/net/phy/phylink.c +9 −6
  24. drivers/net/pse-pd/pse_core.c +2 −2
  25. drivers/net/team/team_core.c +3 −1
  26. drivers/net/vxlan/vxlan_core.c +5 −2
  27. drivers/net/wireless/ath/ath12k/wmi.c +45 −16
  28. drivers/net/wireless/ath/ath12k/wmi.h +0 −1
  29. drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +2 −2
  30. drivers/ptp/ptp_vmclock.c +21 −26
  31. drivers/s390/net/qeth_core_main.c +5 −3
  32. include/linux/netdevice.h +6 −0
  33. include/net/bluetooth/l2cap.h +2 −1
  34. include/net/ip.h +10 −3
  35. include/net/l3mdev.h +2 −0
  36. include/net/net_namespace.h +1 −1
  37. include/net/route.h +7 −2
  38. include/uapi/linux/ethtool.h +2 −0
  39. net/ax25/af_ax25.c +11 −0
  40. net/batman-adv/bat_v.c +0 −2
  41. net/batman-adv/bat_v_elp.c +86 −36
  42. net/batman-adv/bat_v_elp.h +0 −2
  43. net/batman-adv/translation-table.c +5 −7
  44. net/batman-adv/types.h +0 −3
  45. net/bluetooth/l2cap_core.c +79 −90
  46. net/bluetooth/l2cap_sock.c +7 −8
  47. net/can/j1939/socket.c +2 −2
  48. net/can/j1939/transport.c +3 −2
  49. net/core/fib_rules.c +13 −11
  50. net/core/flow_dissector.c +11 −10
  51. net/core/neighbour.c +6 −2
  52. net/core/rtnetlink.c +1 −0
  53. net/ethtool/common.c +5 −0
  54. net/ethtool/common.h +2 −0
  55. net/ethtool/strset.c +5 −0
  56. net/ethtool/tsconfig.c +23 −10
  57. net/ipv4/arp.c +3 −1
  58. net/ipv4/devinet.c +2 −1
  59. net/ipv4/icmp.c +17 −14
  60. net/ipv4/route.c +21 −9
  61. net/ipv6/icmp.c +23 −19
  62. net/ipv6/ip6_input.c +9 −5
  63. net/ipv6/mcast.c +25 −20
  64. net/ipv6/ndisc.c +13 −11
  65. net/ipv6/route.c +6 −1
  66. net/netfilter/nf_flow_table_ip.c +2 −6
  67. net/openvswitch/datapath.c +9 −3
  68. net/rxrpc/ar-internal.h +3 −4
  69. net/rxrpc/output.c +35 −15
  70. net/rxrpc/peer_event.c +7 −0
  71. net/rxrpc/rxkad.c +5 −8
  72. net/rxrpc/sendmsg.c +1 −3
  73. net/rxrpc/txbuf.c +10 −27
  74. net/vmw_vsock/af_vsock.c +7 −1
  75. tools/testing/vsock/vsock_test.c +41 −0
.mailmap+1−0
@@ -376,6 +376,7 @@ Juha Yrjola <juha.yrjola@solidboot.com> · 375 unmodified lines
376376 Julien Thierry <julien.thierry.kdev@gmail.com> <julien.thierry@arm.com>
377377 Iskren Chernev <me@iskren.info> <iskren.chernev@gmail.com>
378378 Kalle Valo <kvalo@kernel.org> <kvalo@codeaurora.org>
379+Kalle Valo <kvalo@kernel.org> <quic_kvalo@quicinc.com>
379380 Kalyan Thota <quic_kalyant@quicinc.com> <kalyan_t@codeaurora.org>
380381 Karthikeyan Periyasamy <quic_periyasa@quicinc.com> <periyasa@codeaurora.org>
381382 Kathiravan T <quic_kathirav@quicinc.com> <kathirav@codeaurora.org>
Documentation/devicetree/bindings/net/wireless/qcom,ath10k.yaml+0−1
@@ -7,7 +7,6 @@ $schema: http://devicetree.org/meta-schemas/core.yaml# · 6 unmodified lines
77 title: Qualcomm Technologies ath10k wireless devices
88
99 maintainers:
10− - Kalle Valo <kvalo@kernel.org>
1110 - Jeff Johnson <jjohnson@kernel.org>
1211
1312 description:
Documentation/devicetree/bindings/net/wireless/qcom,ath11k-pci.yaml+0−1
@@ -8,7 +8,6 @@ $schema: http://devicetree.org/meta-schemas/core.yaml# · 7 unmodified lines
88 title: Qualcomm Technologies ath11k wireless devices (PCIe)
99
1010 maintainers:
11− - Kalle Valo <kvalo@kernel.org>
1211 - Jeff Johnson <jjohnson@kernel.org>
1312
1413 description: |
Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml+0−1
@@ -8,7 +8,6 @@ $schema: http://devicetree.org/meta-schemas/core.yaml# · 7 unmodified lines
88 title: Qualcomm Technologies ath11k wireless devices
99
1010 maintainers:
11− - Kalle Valo <kvalo@kernel.org>
1211 - Jeff Johnson <jjohnson@kernel.org>
1312
1413 description: |
Documentation/devicetree/bindings/net/wireless/qcom,ath12k-wsi.yaml+0−1
@@ -9,7 +9,6 @@ title: Qualcomm Technologies ath12k wireless devices (PCIe) with WSI interface · 8 unmodified lines
99
1010 maintainers:
1111 - Jeff Johnson <jjohnson@kernel.org>
12− - Kalle Valo <kvalo@kernel.org>
1312
1413 description: |
1514 Qualcomm Technologies IEEE 802.11be PCIe devices with WSI interface.
Documentation/devicetree/bindings/net/wireless/qcom,ath12k.yaml+0−1
@@ -9,7 +9,6 @@ title: Qualcomm Technologies ath12k wireless devices (PCIe) · 8 unmodified lines
99
1010 maintainers:
1111 - Jeff Johnson <quic_jjohnson@quicinc.com>
12− - Kalle Valo <kvalo@kernel.org>
1312
1413 description:
1514 Qualcomm Technologies IEEE 802.11be PCIe devices.
Documentation/netlink/specs/ethtool.yaml+2−1
@@ -1524,7 +1524,8 @@ attribute-sets: · 1523 unmodified lines
15241524 nested-attributes: bitset
15251525 -
15261526 name: hwtstamp-flags
1527− type: u32
1527+ type: nest
1528+ nested-attributes: bitset
15281529
15291530 operations:
15301531 enum-model: directional
Documentation/networking/iso15765-2.rst+2−2
@@ -369,8 +369,8 @@ to their default. · 368 unmodified lines
369369
370370 addr.can_family = AF_CAN;
371371 addr.can_ifindex = if_nametoindex("can0");
372− addr.tp.tx_id = 0x18DA42F1 | CAN_EFF_FLAG;
373− addr.tp.rx_id = 0x18DAF142 | CAN_EFF_FLAG;
372+ addr.can_addr.tp.tx_id = 0x18DA42F1 | CAN_EFF_FLAG;
373+ addr.can_addr.tp.rx_id = 0x18DAF142 | CAN_EFF_FLAG;
374374
375375 ret = bind(s, (struct sockaddr *)&addr, sizeof(addr));
376376 if (ret < 0)
MAINTAINERS+3−5
@@ -3654,7 +3654,6 @@ F: Documentation/devicetree/bindings/phy/phy-ath79-usb.txt · 3653 unmodified lines
36543654 F: drivers/phy/qualcomm/phy-ath79-usb.c
36553655
36563656 ATHEROS ATH GENERIC UTILITIES
3657−M: Kalle Valo <kvalo@kernel.org>
36583657 M: Jeff Johnson <jjohnson@kernel.org>
36593658 L: linux-wireless@vger.kernel.org
36603659 S: Supported
@@ -16438,7 +16437,7 @@ X: drivers/net/can/ · 12777 unmodified lines
1643816437 X: drivers/net/wireless/
1643916438
1644016439 NETWORKING DRIVERS (WIRELESS)
16441−M: Kalle Valo <kvalo@kernel.org>
16440+M: Johannes Berg <johannes@sipsolutions.net>
1644216441 L: linux-wireless@vger.kernel.org
1644316442 S: Maintained
1644416443 W: https://wireless.wiki.kernel.org/
@@ -16509,6 +16508,7 @@ F: include/linux/netdev* · 64 unmodified lines
1650916508 F: include/linux/netlink.h
1651016509 F: include/linux/netpoll.h
1651116510 F: include/linux/rtnetlink.h
16511+F: include/linux/sctp.h
1651216512 F: include/linux/seq_file_net.h
1651316513 F: include/linux/skbuff*
1651416514 F: include/net/
@@ -16525,6 +16525,7 @@ F: include/uapi/linux/netdev* · 10 unmodified lines
1652516525 F: include/uapi/linux/netlink.h
1652616526 F: include/uapi/linux/netlink_diag.h
1652716527 F: include/uapi/linux/rtnetlink.h
16528+F: include/uapi/linux/sctp.h
1652816529 F: lib/net_utils.c
1652916530 F: lib/random32.c
1653016531 F: net/
@@ -19355,7 +19356,6 @@ Q: http://patchwork.linuxtv.org/project/linux-media/list/ · 2824 unmodified lines
1935519356 F: drivers/media/tuners/qt1010*
1935619357
1935719358 QUALCOMM ATH12K WIRELESS DRIVER
19358−M: Kalle Valo <kvalo@kernel.org>
1935919359 M: Jeff Johnson <jjohnson@kernel.org>
1936019360 L: ath12k@lists.infradead.org
1936119361 S: Supported
@@ -19365,7 +19365,6 @@ F: drivers/net/wireless/ath/ath12k/ · 3 unmodified lines
1936519365 N: ath12k
1936619366
1936719367 QUALCOMM ATHEROS ATH10K WIRELESS DRIVER
19368−M: Kalle Valo <kvalo@kernel.org>
1936919368 M: Jeff Johnson <jjohnson@kernel.org>
1937019369 L: ath10k@lists.infradead.org
1937119370 S: Supported
@@ -19375,7 +19374,6 @@ F: drivers/net/wireless/ath/ath10k/ · 3 unmodified lines
1937519374 N: ath10k
1937619375
1937719376 QUALCOMM ATHEROS ATH11K WIRELESS DRIVER
19378−M: Kalle Valo <kvalo@kernel.org>
1937919377 M: Jeff Johnson <jjohnson@kernel.org>
1938019378 L: ath11k@lists.infradead.org
1938119379 S: Supported
drivers/bluetooth/btintel_pcie.c+4−1
@@ -1320,6 +1320,10 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev, · 1319 unmodified lines
13201320 if (opcode == 0xfc01)
13211321 btintel_pcie_inject_cmd_complete(hdev, opcode);
13221322 }
1323+ /* Firmware raises alive interrupt on HCI_OP_RESET */
1324+ if (opcode == HCI_OP_RESET)
1325+ data->gp0_received = false;
1326+
13231327 hdev->stat.cmd_tx++;
13241328 break;
13251329 case HCI_ACLDATA_PKT:
@@ -1357,7 +1361,6 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev, · 31 unmodified lines
13571361 opcode, btintel_pcie_alivectxt_state2str(old_ctxt),
13581362 btintel_pcie_alivectxt_state2str(data->alive_intr_ctxt));
13591363 if (opcode == HCI_OP_RESET) {
1360− data->gp0_received = false;
13611364 ret = wait_event_timeout(data->gp0_wait_q,
13621365 data->gp0_received,
13631366 msecs_to_jiffies(BTINTEL_DEFAULT_INTR_TIMEOUT_MS));
drivers/net/can/c_can/c_can_platform.c+3−2
@@ -385,15 +385,16 @@ static int c_can_plat_probe(struct platform_device *pdev) · 384 unmodified lines
385385 if (ret) {
386386 dev_err(&pdev->dev, "registering %s failed (err=%d)\n",
387387 KBUILD_MODNAME, ret);
388− goto exit_free_device;
388+ goto exit_pm_runtime;
389389 }
390390
391391 dev_info(&pdev->dev, "%s device registered (regs=%p, irq=%d)\n",
392392 KBUILD_MODNAME, priv->base, dev->irq);
393393 return 0;
394394
395−exit_free_device:
395+exit_pm_runtime:
396396 pm_runtime_disable(priv->device);
397+exit_free_device:
397398 free_c_can_dev(dev);
398399 exit:
399400 dev_err(&pdev->dev, "probe failed\n");
drivers/net/can/ctucanfd/ctucanfd_base.c+6−4
@@ -867,10 +867,12 @@ static void ctucan_err_interrupt(struct net_device *ndev, u32 isr) · 866 unmodified lines
867867 }
868868 break;
869869 case CAN_STATE_ERROR_ACTIVE:
870− cf->can_id |= CAN_ERR_CNT;
871− cf->data[1] = CAN_ERR_CRTL_ACTIVE;
872− cf->data[6] = bec.txerr;
873− cf->data[7] = bec.rxerr;
870+ if (skb) {
871+ cf->can_id |= CAN_ERR_CNT;
872+ cf->data[1] = CAN_ERR_CRTL_ACTIVE;
873+ cf->data[6] = bec.txerr;
874+ cf->data[7] = bec.rxerr;
875+ }
874876 break;
875877 default:
876878 netdev_warn(ndev, "unhandled error state (%d:%s)!\n",
drivers/net/can/rockchip/rockchip_canfd-core.c+1−1
@@ -622,7 +622,7 @@ rkcanfd_handle_rx_fifo_overflow_int(struct rkcanfd_priv *priv) · 621 unmodified lines
622622 netdev_dbg(priv->ndev, "RX-FIFO overflow\n");
623623
624624 skb = rkcanfd_alloc_can_err_skb(priv, &cf, &timestamp);
625− if (skb)
625+ if (!skb)
626626 return 0;
627627
628628 rkcanfd_get_berr_counter_corrected(priv, &bec);
drivers/net/can/usb/etas_es58x/es58x_devlink.c+5−1
@@ -248,7 +248,11 @@ static int es58x_devlink_info_get(struct devlink *devlink, · 247 unmodified lines
248248 return ret;
249249 }
250250
251− return devlink_info_serial_number_put(req, es58x_dev->udev->serial);
251+ if (es58x_dev->udev->serial)
252+ ret = devlink_info_serial_number_put(req,
253+ es58x_dev->udev->serial);
254+
255+ return ret;
252256 }
253257
254258 const struct devlink_ops es58x_dl_ops = {
drivers/net/ethernet/intel/iavf/iavf_main.c+1−1
@@ -2903,8 +2903,8 @@ static void iavf_watchdog_task(struct work_struct *work) · 2902 unmodified lines
29032903 }
29042904
29052905 mutex_unlock(&adapter->crit_lock);
2906− netdev_unlock(netdev);
29072906 restart_watchdog:
2907+ netdev_unlock(netdev);
29082908 if (adapter->state >= __IAVF_DOWN)
29092909 queue_work(adapter->wq, &adapter->adminq_task);
29102910 if (adapter->aq_required)
drivers/net/ethernet/intel/idpf/idpf_lib.c+5−0
@@ -2159,8 +2159,13 @@ static int idpf_open(struct net_device *netdev) · 2158 unmodified lines
21592159 idpf_vport_ctrl_lock(netdev);
21602160 vport = idpf_netdev_to_vport(netdev);
21612161
2162+ err = idpf_set_real_num_queues(vport);
2163+ if (err)
2164+ goto unlock;
2165+
21622166 err = idpf_vport_open(vport);
21632167
2168+unlock:
21642169 idpf_vport_ctrl_unlock(netdev);
21652170
21662171 return err;
drivers/net/ethernet/intel/idpf/idpf_txrx.c+1−4
@@ -3008,8 +3008,6 @@ static int idpf_rx_rsc(struct idpf_rx_queue *rxq, struct sk_buff *skb, · 3007 unmodified lines
30083008 return -EINVAL;
30093009
30103010 rsc_segments = DIV_ROUND_UP(skb->data_len, rsc_seg_len);
3011− if (unlikely(rsc_segments == 1))
3012− return 0;
30133011
30143012 NAPI_GRO_CB(skb)->count = rsc_segments;
30153013 skb_shinfo(skb)->gso_size = rsc_seg_len;
@@ -3072,6 +3070,7 @@ idpf_rx_process_skb_fields(struct idpf_rx_queue *rxq, struct sk_buff *skb, · 56 unmodified lines
30723070 idpf_rx_hash(rxq, skb, rx_desc, decoded);
30733071
30743072 skb->protocol = eth_type_trans(skb, rxq->netdev);
3073+ skb_record_rx_queue(skb, rxq->idx);
30753074
30763075 if (le16_get_bits(rx_desc->hdrlen_flags,
30773076 VIRTCHNL2_RX_FLEX_DESC_ADV_RSC_M))
@@ -3080,8 +3079,6 @@ idpf_rx_process_skb_fields(struct idpf_rx_queue *rxq, struct sk_buff *skb, · 2 unmodified lines
30803079 csum_bits = idpf_rx_splitq_extract_csum_bits(rx_desc);
30813080 idpf_rx_csum(rxq, skb, csum_bits, decoded);
30823081
3083− skb_record_rx_queue(skb, rxq->idx);
3084−
30853082 return 0;
30863083 }
30873084
drivers/net/ethernet/intel/igc/igc_main.c+13−9
@@ -1096,6 +1096,7 @@ static int igc_init_empty_frame(struct igc_ring *ring, · 1095 unmodified lines
10961096 return -ENOMEM;
10971097 }
10981098
1099+ buffer->type = IGC_TX_BUFFER_TYPE_SKB;
10991100 buffer->skb = skb;
11001101 buffer->protocol = 0;
11011102 buffer->bytecount = skb->len;
@@ -2701,8 +2702,9 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget) · 1599 unmodified lines
27012702 }
27022703
27032704 static struct sk_buff *igc_construct_skb_zc(struct igc_ring *ring,
2704− struct xdp_buff *xdp)
2705+ struct igc_xdp_buff *ctx)
27052706 {
2707+ struct xdp_buff *xdp = &ctx->xdp;
27062708 unsigned int totalsize = xdp->data_end - xdp->data_meta;
27072709 unsigned int metasize = xdp->data - xdp->data_meta;
27082710 struct sk_buff *skb;
@@ -2721,27 +2723,28 @@ static struct sk_buff *igc_construct_skb_zc(struct igc_ring *ring, · 12 unmodified lines
27212723 __skb_pull(skb, metasize);
27222724 }
27232725
2726+ if (ctx->rx_ts) {
2727+ skb_shinfo(skb)->tx_flags |= SKBTX_HW_TSTAMP_NETDEV;
2728+ skb_hwtstamps(skb)->netdev_data = ctx->rx_ts;
2729+ }
2730+
27242731 return skb;
27252732 }
27262733
27272734 static void igc_dispatch_skb_zc(struct igc_q_vector *q_vector,
27282735 union igc_adv_rx_desc *desc,
2729− struct xdp_buff *xdp,
2730− ktime_t timestamp)
2736+ struct igc_xdp_buff *ctx)
27312737 {
27322738 struct igc_ring *ring = q_vector->rx.ring;
27332739 struct sk_buff *skb;
27342740
2735− skb = igc_construct_skb_zc(ring, xdp);
2741+ skb = igc_construct_skb_zc(ring, ctx);
27362742 if (!skb) {
27372743 ring->rx_stats.alloc_failed++;
27382744 set_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &ring->flags);
27392745 return;
27402746 }
27412747
2742− if (timestamp)
2743− skb_hwtstamps(skb)->hwtstamp = timestamp;
2744−
27452748 if (igc_cleanup_headers(ring, desc, skb))
27462749 return;
27472750
@@ -2777,7 +2780,6 @@ static int igc_clean_rx_irq_zc(struct igc_q_vector *q_vector, const int budget) · 29 unmodified lines
27772780 union igc_adv_rx_desc *desc;
27782781 struct igc_rx_buffer *bi;
27792782 struct igc_xdp_buff *ctx;
2780− ktime_t timestamp = 0;
27812783 unsigned int size;
27822784 int res;
27832785
@@ -2807,6 +2809,8 @@ static int igc_clean_rx_irq_zc(struct igc_q_vector *q_vector, const int budget) · 23 unmodified lines
28072809 */
28082810 bi->xdp->data_meta += IGC_TS_HDR_LEN;
28092811 size -= IGC_TS_HDR_LEN;
2812+ } else {
2813+ ctx->rx_ts = NULL;
28102814 }
28112815
28122816 bi->xdp->data_end = bi->xdp->data + size;
@@ -2815,7 +2819,7 @@ static int igc_clean_rx_irq_zc(struct igc_q_vector *q_vector, const int budget) · 2 unmodified lines
28152819 res = __igc_xdp_run_prog(adapter, prog, bi->xdp);
28162820 switch (res) {
28172821 case IGC_XDP_PASS:
2818− igc_dispatch_skb_zc(q_vector, desc, bi->xdp, timestamp);
2822+ igc_dispatch_skb_zc(q_vector, desc, ctx);
28192823 fallthrough;
28202824 case IGC_XDP_CONSUMED:
28212825 xsk_buff_free(bi->xdp);
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c+1−1
@@ -2105,7 +2105,7 @@ static void ixgbe_put_rx_buffer(struct ixgbe_ring *rx_ring, · 2104 unmodified lines
21052105 /* hand second half of page back to the ring */
21062106 ixgbe_reuse_rx_page(rx_ring, rx_buffer);
21072107 } else {
2108− if (!IS_ERR(skb) && IXGBE_CB(skb)->dma == rx_buffer->dma) {
2108+ if (skb && IXGBE_CB(skb)->dma == rx_buffer->dma) {
21092109 /* the page has been released from the ring */
21102110 IXGBE_CB(skb)->page_released = true;
21112111 } else {
drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c+3−1
@@ -768,7 +768,9 @@ static void __mlxsw_sp_port_get_stats(struct net_device *dev, · 767 unmodified lines
768768 err = mlxsw_sp_get_hw_stats_by_group(&hw_stats, &len, grp);
769769 if (err)
770770 return;
771− mlxsw_sp_port_get_stats_raw(dev, grp, prio, ppcnt_pl);
771+ err = mlxsw_sp_port_get_stats_raw(dev, grp, prio, ppcnt_pl);
772+ if (err)
773+ return;
772774 for (i = 0; i < len; i++) {
773775 data[data_index + i] = hw_stats[i].getter(ppcnt_pl);
774776 if (!hw_stats[i].cells_bytes)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c+5−0
@@ -2094,6 +2094,11 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv, · 2093 unmodified lines
20942094 pp_params.offset = stmmac_rx_offset(priv);
20952095 pp_params.max_len = dma_conf->dma_buf_sz;
20962096
2097+ if (priv->sph) {
2098+ pp_params.offset = 0;
2099+ pp_params.max_len += stmmac_rx_offset(priv);
2100+ }
2101+
20972102 rx_q->page_pool = page_pool_create(&pp_params);
20982103 if (IS_ERR(rx_q->page_pool)) {
20992104 ret = PTR_ERR(rx_q->page_pool);
drivers/net/ethernet/ti/am65-cpsw-nuss.c+31−19
@@ -828,21 +828,30 @@ static void am65_cpsw_nuss_xmit_free(struct am65_cpsw_tx_chn *tx_chn, · 827 unmodified lines
828828 static void am65_cpsw_nuss_tx_cleanup(void *data, dma_addr_t desc_dma)
829829 {
830830 struct am65_cpsw_tx_chn *tx_chn = data;
831+ enum am65_cpsw_tx_buf_type buf_type;
831832 struct cppi5_host_desc_t *desc_tx;
833+ struct xdp_frame *xdpf;
832834 struct sk_buff *skb;
833835 void **swdata;
834836
835837 desc_tx = k3_cppi_desc_pool_dma2virt(tx_chn->desc_pool, desc_dma);
836838 swdata = cppi5_hdesc_get_swdata(desc_tx);
837− skb = *(swdata);
838− am65_cpsw_nuss_xmit_free(tx_chn, desc_tx);
839+ buf_type = am65_cpsw_nuss_buf_type(tx_chn, desc_dma);
840+ if (buf_type == AM65_CPSW_TX_BUF_TYPE_SKB) {
841+ skb = *(swdata);
842+ dev_kfree_skb_any(skb);
843+ } else {
844+ xdpf = *(swdata);
845+ xdp_return_frame(xdpf);
846+ }
839847
840− dev_kfree_skb_any(skb);
848+ am65_cpsw_nuss_xmit_free(tx_chn, desc_tx);
841849 }
842850
843851 static struct sk_buff *am65_cpsw_build_skb(void *page_addr,
844852 struct net_device *ndev,
845− unsigned int len)
853+ unsigned int len,
854+ unsigned int headroom)
846855 {
847856 struct sk_buff *skb;
848857
@@ -852,7 +861,7 @@ static struct sk_buff *am65_cpsw_build_skb(void *page_addr, · 3 unmodified lines
852861 if (unlikely(!skb))
853862 return NULL;
854863
855− skb_reserve(skb, AM65_CPSW_HEADROOM);
864+ skb_reserve(skb, headroom);
856865 skb->dev = ndev;
857866
858867 return skb;
@@ -1169,9 +1178,11 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow, · 310 unmodified lines
11691178 struct xdp_frame *xdpf;
11701179 struct bpf_prog *prog;
11711180 struct page *page;
1181+ int pkt_len;
11721182 u32 act;
11731183 int err;
11741184
1185+ pkt_len = *len;
11751186 prog = READ_ONCE(port->xdp_prog);
11761187 if (!prog)
11771188 return AM65_CPSW_XDP_PASS;
@@ -1189,8 +1200,10 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow, · 11 unmodified lines
11891200 netif_txq = netdev_get_tx_queue(ndev, tx_chn->id);
11901201
11911202 xdpf = xdp_convert_buff_to_frame(xdp);
1192− if (unlikely(!xdpf))
1203+ if (unlikely(!xdpf)) {
1204+ ndev->stats.tx_dropped++;
11931205 goto drop;
1206+ }
11941207
11951208 __netif_tx_lock(netif_txq, cpu);
11961209 err = am65_cpsw_xdp_tx_frame(ndev, tx_chn, xdpf,
@@ -1199,14 +1212,14 @@ static int am65_cpsw_run_xdp(struct am65_cpsw_rx_flow *flow, · 2 unmodified lines
11991212 if (err)
12001213 goto drop;
12011214
1202− dev_sw_netstats_tx_add(ndev, 1, *len);
1215+ dev_sw_netstats_rx_add(ndev, pkt_len);
12031216 ret = AM65_CPSW_XDP_CONSUMED;
12041217 goto out;
12051218 case XDP_REDIRECT:
12061219 if (unlikely(xdp_do_redirect(ndev, xdp, prog)))
12071220 goto drop;
12081221
1209− dev_sw_netstats_rx_add(ndev, *len);
1222+ dev_sw_netstats_rx_add(ndev, pkt_len);
12101223 ret = AM65_CPSW_XDP_REDIRECT;
12111224 goto out;
12121225 default:
@@ -1315,16 +1328,8 @@ static int am65_cpsw_nuss_rx_packets(struct am65_cpsw_rx_flow *flow, · 102 unmodified lines
13151328 dev_dbg(dev, "%s rx csum_info:%#x\n", __func__, csum_info);
13161329
13171330 dma_unmap_single(rx_chn->dma_dev, buf_dma, buf_dma_len, DMA_FROM_DEVICE);
1318−
13191331 k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx);
13201332
1321− skb = am65_cpsw_build_skb(page_addr, ndev,
1322− AM65_CPSW_MAX_PACKET_SIZE);
1323− if (unlikely(!skb)) {
1324− new_page = page;
1325− goto requeue;
1326− }
1327−
13281333 if (port->xdp_prog) {
13291334 xdp_init_buff(&xdp, PAGE_SIZE, &port->xdp_rxq[flow->id]);
13301335 xdp_prepare_buff(&xdp, page_addr, AM65_CPSW_HEADROOM,
@@ -1334,9 +1339,16 @@ static int am65_cpsw_nuss_rx_packets(struct am65_cpsw_rx_flow *flow, · 3 unmodified lines
13341339 if (*xdp_state != AM65_CPSW_XDP_PASS)
13351340 goto allocate;
13361341
1337− /* Compute additional headroom to be reserved */
1338− headroom = (xdp.data - xdp.data_hard_start) - skb_headroom(skb);
1339− skb_reserve(skb, headroom);
1342+ headroom = xdp.data - xdp.data_hard_start;
1343+ } else {
1344+ headroom = AM65_CPSW_HEADROOM;
1345+ }
1346+
1347+ skb = am65_cpsw_build_skb(page_addr, ndev,
1348+ AM65_CPSW_MAX_PACKET_SIZE, headroom);
1349+ if (unlikely(!skb)) {
1350+ new_page = page;
1351+ goto requeue;
13401352 }
13411353
13421354 ndev_priv = netdev_priv(ndev);
drivers/net/phy/phylink.c+9−6
@@ -2265,12 +2265,15 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, · 2264 unmodified lines
22652265 /* Allow the MAC to stop its clock if the PHY has the capability */
22662266 pl->mac_tx_clk_stop = phy_eee_tx_clock_stop_capable(phy) > 0;
22672267
2268− /* Explicitly configure whether the PHY is allowed to stop it's
2269− * receive clock.
2270− */
2271− ret = phy_eee_rx_clock_stop(phy, pl->config->eee_rx_clk_stop_enable);
2272− if (ret == -EOPNOTSUPP)
2273− ret = 0;
2268+ if (pl->mac_supports_eee_ops) {
2269+ /* Explicitly configure whether the PHY is allowed to stop it's
2270+ * receive clock.
2271+ */
2272+ ret = phy_eee_rx_clock_stop(phy,
2273+ pl->config->eee_rx_clk_stop_enable);
2274+ if (ret == -EOPNOTSUPP)
2275+ ret = 0;
2276+ }
22742277
22752278 return ret;
22762279 }
drivers/net/pse-pd/pse_core.c+2−2
@@ -319,7 +319,7 @@ static int pse_pi_get_current_limit(struct regulator_dev *rdev) · 318 unmodified lines
319319 goto out;
320320 mW = ret;
321321
322− ret = pse_pi_get_voltage(rdev);
322+ ret = _pse_pi_get_voltage(rdev);
323323 if (!ret) {
324324 dev_err(pcdev->dev, "Voltage null\n");
325325 ret = -ERANGE;
@@ -356,7 +356,7 @@ static int pse_pi_set_current_limit(struct regulator_dev *rdev, int min_uA, · 30 unmodified lines
356356
357357 id = rdev_get_id(rdev);
358358 mutex_lock(&pcdev->lock);
359− ret = pse_pi_get_voltage(rdev);
359+ ret = _pse_pi_get_voltage(rdev);
360360 if (!ret) {
361361 dev_err(pcdev->dev, "Voltage null\n");
362362 ret = -ERANGE;
drivers/net/team/team_core.c+3−1
@@ -2639,7 +2639,9 @@ int team_nl_options_set_doit(struct sk_buff *skb, struct genl_info *info) · 2638 unmodified lines
26392639 ctx.data.u32_val = nla_get_u32(attr_data);
26402640 break;
26412641 case TEAM_OPTION_TYPE_STRING:
2642− if (nla_len(attr_data) > TEAM_STRING_MAX_LEN) {
2642+ if (nla_len(attr_data) > TEAM_STRING_MAX_LEN ||
2643+ !memchr(nla_data(attr_data), '\0',
2644+ nla_len(attr_data))) {
26432645 err = -EINVAL;
26442646 goto team_put;
26452647 }
drivers/net/vxlan/vxlan_core.c+5−2
@@ -2898,8 +2898,11 @@ static int vxlan_init(struct net_device *dev) · 2897 unmodified lines
28982898 struct vxlan_dev *vxlan = netdev_priv(dev);
28992899 int err;
29002900
2901− if (vxlan->cfg.flags & VXLAN_F_VNIFILTER)
2902− vxlan_vnigroup_init(vxlan);
2901+ if (vxlan->cfg.flags & VXLAN_F_VNIFILTER) {
2902+ err = vxlan_vnigroup_init(vxlan);
2903+ if (err)
2904+ return err;
2905+ }
29032906
29042907 err = gro_cells_init(&vxlan->gro_cells, dev);
29052908 if (err)
drivers/net/wireless/ath/ath12k/wmi.c+45−16
@@ -4851,6 +4851,22 @@ static struct ath12k_reg_rule · 4850 unmodified lines
48514851 return reg_rule_ptr;
48524852 }
48534853
4854+static u8 ath12k_wmi_ignore_num_extra_rules(struct ath12k_wmi_reg_rule_ext_params *rule,
4855+ u32 num_reg_rules)
4856+{
4857+ u8 num_invalid_5ghz_rules = 0;
4858+ u32 count, start_freq;
4859+
4860+ for (count = 0; count < num_reg_rules; count++) {
4861+ start_freq = le32_get_bits(rule[count].freq_info, REG_RULE_START_FREQ);
4862+
4863+ if (start_freq >= ATH12K_MIN_6G_FREQ)
4864+ num_invalid_5ghz_rules++;
4865+ }
4866+
4867+ return num_invalid_5ghz_rules;
4868+}
4869+
48544870 static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab,
48554871 struct sk_buff *skb,
48564872 struct ath12k_reg_info *reg_info)
@@ -4861,6 +4877,7 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab, · 4 unmodified lines
48614877 u32 num_2g_reg_rules, num_5g_reg_rules;
48624878 u32 num_6g_reg_rules_ap[WMI_REG_CURRENT_MAX_AP_TYPE];
48634879 u32 num_6g_reg_rules_cl[WMI_REG_CURRENT_MAX_AP_TYPE][WMI_REG_MAX_CLIENT_TYPE];
4880+ u8 num_invalid_5ghz_ext_rules;
48644881 u32 total_reg_rules = 0;
48654882 int ret, i, j;
48664883
@@ -4954,20 +4971,6 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab, · 87 unmodified lines
49544971
49554972 memcpy(reg_info->alpha2, &ev->alpha2, REG_ALPHA2_LEN);
49564973
4957− /* FIXME: Currently FW includes 6G reg rule also in 5G rule
4958− * list for country US.
4959− * Having same 6G reg rule in 5G and 6G rules list causes
4960− * intersect check to be true, and same rules will be shown
4961− * multiple times in iw cmd. So added hack below to avoid
4962− * parsing 6G rule from 5G reg rule list, and this can be
4963− * removed later, after FW updates to remove 6G reg rule
4964− * from 5G rules list.
4965− */
4966− if (memcmp(reg_info->alpha2, "US", 2) == 0) {
4967− reg_info->num_5g_reg_rules = REG_US_5G_NUM_REG_RULES;
4968− num_5g_reg_rules = reg_info->num_5g_reg_rules;
4969− }
4970−
49714974 reg_info->dfs_region = le32_to_cpu(ev->dfs_region);
49724975 reg_info->phybitmap = le32_to_cpu(ev->phybitmap);
49734976 reg_info->num_phy = le32_to_cpu(ev->num_phy);
@@ -5070,8 +5073,29 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab, · 96 unmodified lines
50705073 }
50715074 }
50725075
5076+ ext_wmi_reg_rule += num_2g_reg_rules;
5077+
5078+ /* Firmware might include 6 GHz reg rule in 5 GHz rule list
5079+ * for few countries along with separate 6 GHz rule.
5080+ * Having same 6 GHz reg rule in 5 GHz and 6 GHz rules list
5081+ * causes intersect check to be true, and same rules will be
5082+ * shown multiple times in iw cmd.
5083+ * Hence, avoid parsing 6 GHz rule from 5 GHz reg rule list
5084+ */
5085+ num_invalid_5ghz_ext_rules = ath12k_wmi_ignore_num_extra_rules(ext_wmi_reg_rule,
5086+ num_5g_reg_rules);
5087+
5088+ if (num_invalid_5ghz_ext_rules) {
5089+ ath12k_dbg(ab, ATH12K_DBG_WMI,
5090+ "CC: %s 5 GHz reg rules number %d from fw, %d number of invalid 5 GHz rules",
5091+ reg_info->alpha2, reg_info->num_5g_reg_rules,
5092+ num_invalid_5ghz_ext_rules);
5093+
5094+ num_5g_reg_rules = num_5g_reg_rules - num_invalid_5ghz_ext_rules;
5095+ reg_info->num_5g_reg_rules = num_5g_reg_rules;
5096+ }
5097+
50735098 if (num_5g_reg_rules) {
5074− ext_wmi_reg_rule += num_2g_reg_rules;
50755099 reg_info->reg_rules_5g_ptr =
50765100 create_ext_reg_rules_from_wmi(num_5g_reg_rules,
50775101 ext_wmi_reg_rule);
@@ -5083,7 +5107,12 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab, · 5 unmodified lines
50835107 }
50845108 }
50855109
5086− ext_wmi_reg_rule += num_5g_reg_rules;
5110+ /* We have adjusted the number of 5 GHz reg rules above. But still those
5111+ * many rules needs to be adjusted in ext_wmi_reg_rule.
5112+ *
5113+ * NOTE: num_invalid_5ghz_ext_rules will be 0 for rest other cases.
5114+ */
5115+ ext_wmi_reg_rule += (num_5g_reg_rules + num_invalid_5ghz_ext_rules);
50875116
50885117 for (i = 0; i < WMI_REG_CURRENT_MAX_AP_TYPE; i++) {
50895118 reg_info->reg_rules_6g_ap_ptr[i] =
drivers/net/wireless/ath/ath12k/wmi.h+0−1
@@ -4073,7 +4073,6 @@ struct ath12k_wmi_eht_rate_set_params { · 4072 unmodified lines
40734073 #define MAX_REG_RULES 10
40744074 #define REG_ALPHA2_LEN 2
40754075 #define MAX_6G_REG_RULES 5
4076−#define REG_US_5G_NUM_REG_RULES 4
40774076
40784077 enum wmi_start_event_param {
40794078 WMI_VDEV_START_RESP_EVENT = 0,
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c+2−2
@@ -2712,7 +2712,7 @@ static const struct pci_device_id brcmf_pcie_devid_table[] = { · 2711 unmodified lines
27122712 BRCMF_PCIE_DEVICE(BRCM_PCIE_4350_DEVICE_ID, WCC),
27132713 BRCMF_PCIE_DEVICE_SUB(0x4355, BRCM_PCIE_VENDOR_ID_BROADCOM, 0x4355, WCC),
27142714 BRCMF_PCIE_DEVICE(BRCM_PCIE_4354_RAW_DEVICE_ID, WCC),
2715− BRCMF_PCIE_DEVICE(BRCM_PCIE_4355_DEVICE_ID, WCC),
2715+ BRCMF_PCIE_DEVICE(BRCM_PCIE_4355_DEVICE_ID, WCC_SEED),
27162716 BRCMF_PCIE_DEVICE(BRCM_PCIE_4356_DEVICE_ID, WCC),
27172717 BRCMF_PCIE_DEVICE(BRCM_PCIE_43567_DEVICE_ID, WCC),
27182718 BRCMF_PCIE_DEVICE(BRCM_PCIE_43570_DEVICE_ID, WCC),
@@ -2723,7 +2723,7 @@ static const struct pci_device_id brcmf_pcie_devid_table[] = { · 4 unmodified lines
27232723 BRCMF_PCIE_DEVICE(BRCM_PCIE_43602_2G_DEVICE_ID, WCC),
27242724 BRCMF_PCIE_DEVICE(BRCM_PCIE_43602_5G_DEVICE_ID, WCC),
27252725 BRCMF_PCIE_DEVICE(BRCM_PCIE_43602_RAW_DEVICE_ID, WCC),
2726− BRCMF_PCIE_DEVICE(BRCM_PCIE_4364_DEVICE_ID, WCC),
2726+ BRCMF_PCIE_DEVICE(BRCM_PCIE_4364_DEVICE_ID, WCC_SEED),
27272727 BRCMF_PCIE_DEVICE(BRCM_PCIE_4365_DEVICE_ID, BCA),
27282728 BRCMF_PCIE_DEVICE(BRCM_PCIE_4365_2G_DEVICE_ID, BCA),
27292729 BRCMF_PCIE_DEVICE(BRCM_PCIE_4365_5G_DEVICE_ID, BCA),
drivers/ptp/ptp_vmclock.c+21−26
@@ -414,16 +414,16 @@ static ssize_t vmclock_miscdev_read(struct file *fp, char __user *buf, · 413 unmodified lines
414414 }
415415
416416 static const struct file_operations vmclock_miscdev_fops = {
417+ .owner = THIS_MODULE,
417418 .mmap = vmclock_miscdev_mmap,
418419 .read = vmclock_miscdev_read,
419420 };
420421
421422 /* module operations */
422423
423−static void vmclock_remove(struct platform_device *pdev)
424+static void vmclock_remove(void *data)
424425 {
425− struct device *dev = &pdev->dev;
426− struct vmclock_state *st = dev_get_drvdata(dev);
426+ struct vmclock_state *st = data;
427427
428428 if (st->ptp_clock)
429429 ptp_clock_unregister(st->ptp_clock);
@@ -506,14 +506,13 @@ static int vmclock_probe(struct platform_device *pdev) · 76 unmodified lines
506506
507507 if (ret) {
508508 dev_info(dev, "Failed to obtain physical address: %d\n", ret);
509− goto out;
509+ return ret;
510510 }
511511
512512 if (resource_size(&st->res) < VMCLOCK_MIN_SIZE) {
513513 dev_info(dev, "Region too small (0x%llx)\n",
514514 resource_size(&st->res));
515− ret = -EINVAL;
516− goto out;
515+ return -EINVAL;
517516 }
518517 st->clk = devm_memremap(dev, st->res.start, resource_size(&st->res),
519518 MEMREMAP_WB | MEMREMAP_DEC);
@@ -521,31 +520,34 @@ static int vmclock_probe(struct platform_device *pdev) · 1 unmodified line
521520 ret = PTR_ERR(st->clk);
522521 dev_info(dev, "failed to map shared memory\n");
523522 st->clk = NULL;
524− goto out;
523+ return ret;
525524 }
526525
527526 if (le32_to_cpu(st->clk->magic) != VMCLOCK_MAGIC ||
528527 le32_to_cpu(st->clk->size) > resource_size(&st->res) ||
529528 le16_to_cpu(st->clk->version) != 1) {
530529 dev_info(dev, "vmclock magic fields invalid\n");
531− ret = -EINVAL;
532− goto out;
530+ return -EINVAL;
533531 }
534532
535533 ret = ida_alloc(&vmclock_ida, GFP_KERNEL);
536534 if (ret < 0)
537− goto out;
535+ return ret;
538536
539537 st->index = ret;
540538 ret = devm_add_action_or_reset(&pdev->dev, vmclock_put_idx, st);
541539 if (ret)
542− goto out;
540+ return ret;
543541
544542 st->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "vmclock%d", st->index);
545− if (!st->name) {
546− ret = -ENOMEM;
547− goto out;
548− }
543+ if (!st->name)
544+ return -ENOMEM;
545+
546+ st->miscdev.minor = MISC_DYNAMIC_MINOR;
547+
548+ ret = devm_add_action_or_reset(&pdev->dev, vmclock_remove, st);
549+ if (ret)
550+ return ret;
549551
550552 /*
551553 * If the structure is big enough, it can be mapped to userspace.
@@ -554,13 +556,12 @@ static int vmclock_probe(struct platform_device *pdev) · 2 unmodified lines
554556 * cross that bridge if/when we come to it.
555557 */
556558 if (le32_to_cpu(st->clk->size) >= PAGE_SIZE) {
557− st->miscdev.minor = MISC_DYNAMIC_MINOR;
558559 st->miscdev.fops = &vmclock_miscdev_fops;
559560 st->miscdev.name = st->name;
560561
561562 ret = misc_register(&st->miscdev);
562563 if (ret)
563− goto out;
564+ return ret;
564565 }
565566
566567 /* If there is valid clock information, register a PTP clock */
@@ -570,16 +571,14 @@ static int vmclock_probe(struct platform_device *pdev) · 3 unmodified lines
570571 if (IS_ERR(st->ptp_clock)) {
571572 ret = PTR_ERR(st->ptp_clock);
572573 st->ptp_clock = NULL;
573− vmclock_remove(pdev);
574− goto out;
574+ return ret;
575575 }
576576 }
577577
578578 if (!st->miscdev.minor && !st->ptp_clock) {
579579 /* Neither miscdev nor PTP registered */
580580 dev_info(dev, "vmclock: Neither miscdev nor PTP available; not registering\n");
581− ret = -ENODEV;
582− goto out;
581+ return -ENODEV;
583582 }
584583
585584 dev_info(dev, "%s: registered %s%s%s\n", st->name,
@@ -587,10 +586,7 @@ static int vmclock_probe(struct platform_device *pdev) · 1 unmodified line
587586 (st->miscdev.minor && st->ptp_clock) ? ", " : "",
588587 st->ptp_clock ? "PTP" : "");
589588
590− dev_set_drvdata(dev, st);
591−
592− out:
593− return ret;
589+ return 0;
594590 }
595591
596592 static const struct acpi_device_id vmclock_acpi_ids[] = {
@@ -601,7 +597,6 @@ MODULE_DEVICE_TABLE(acpi, vmclock_acpi_ids); · 4 unmodified lines
601597
602598 static struct platform_driver vmclock_platform_driver = {
603599 .probe = vmclock_probe,
604− .remove = vmclock_remove,
605600 .driver = {
606601 .name = "vmclock",
607602 .acpi_match_table = vmclock_acpi_ids,
drivers/s390/net/qeth_core_main.c+5−3
@@ -7050,14 +7050,16 @@ int qeth_open(struct net_device *dev) · 7049 unmodified lines
70507050 card->data.state = CH_STATE_UP;
70517051 netif_tx_start_all_queues(dev);
70527052
7053− local_bh_disable();
70547053 qeth_for_each_output_queue(card, queue, i) {
70557054 netif_napi_add_tx(dev, &queue->napi, qeth_tx_poll);
70567055 napi_enable(&queue->napi);
7057− napi_schedule(&queue->napi);
70587056 }
7059−
70607057 napi_enable(&card->napi);
7058+
7059+ local_bh_disable();
7060+ qeth_for_each_output_queue(card, queue, i) {
7061+ napi_schedule(&queue->napi);
7062+ }
70617063 napi_schedule(&card->napi);
70627064 /* kick-start the NAPI softirq: */
70637065 local_bh_enable();
include/linux/netdevice.h+6−0
@@ -2663,6 +2663,12 @@ struct net *dev_net(const struct net_device *dev) · 2662 unmodified lines
26632663 return read_pnet(&dev->nd_net);
26642664 }
26652665
2666+static inline
2667+struct net *dev_net_rcu(const struct net_device *dev)
2668+{
2669+ return read_pnet_rcu(&dev->nd_net);
2670+}
2671+
26662672 static inline
26672673 void dev_net_set(struct net_device *dev, struct net *net)
26682674 {
include/net/bluetooth/l2cap.h+2−1
@@ -668,7 +668,7 @@ struct l2cap_conn { · 667 unmodified lines
668668 struct l2cap_chan *smp;
669669
670670 struct list_head chan_l;
671− struct mutex chan_lock;
671+ struct mutex lock;
672672 struct kref ref;
673673 struct list_head users;
674674 };
@@ -970,6 +970,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err); · 295 unmodified lines
970970 void l2cap_send_conn_req(struct l2cap_chan *chan);
971971
972972 struct l2cap_conn *l2cap_conn_get(struct l2cap_conn *conn);
973+struct l2cap_conn *l2cap_conn_hold_unless_zero(struct l2cap_conn *conn);
973974 void l2cap_conn_put(struct l2cap_conn *conn);
974975
975976 int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user);
include/net/ip.h+10−3
@@ -471,9 +471,12 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst, · 470 unmodified lines
471471 bool forwarding)
472472 {
473473 const struct rtable *rt = dst_rtable(dst);
474− struct net *net = dev_net(dst->dev);
475− unsigned int mtu;
474+ unsigned int mtu, res;
475+ struct net *net;
476+
477+ rcu_read_lock();
476478
479+ net = dev_net_rcu(dst->dev);
477480 if (READ_ONCE(net->ipv4.sysctl_ip_fwd_use_pmtu) ||
478481 ip_mtu_locked(dst) ||
479482 !forwarding) {
@@ -497,7 +500,11 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst, · 17 unmodified lines
497500 out:
498501 mtu = min_t(unsigned int, mtu, IP_MAX_MTU);
499502
500− return mtu - lwtunnel_headroom(dst->lwtstate, mtu);
503+ res = mtu - lwtunnel_headroom(dst->lwtstate, mtu);
504+
505+ rcu_read_unlock();
506+
507+ return res;
501508 }
502509
503510 static inline unsigned int ip_skb_dst_mtu(struct sock *sk,
include/net/l3mdev.h+2−0
@@ -198,10 +198,12 @@ struct sk_buff *l3mdev_l3_out(struct sock *sk, struct sk_buff *skb, u16 proto) · 197 unmodified lines
198198 if (netif_is_l3_slave(dev)) {
199199 struct net_device *master;
200200
201+ rcu_read_lock();
201202 master = netdev_master_upper_dev_get_rcu(dev);
202203 if (master && master->l3mdev_ops->l3mdev_l3_out)
203204 skb = master->l3mdev_ops->l3mdev_l3_out(master, sk,
204205 skb, proto);
206+ rcu_read_unlock();
205207 }
206208
207209 return skb;
include/net/net_namespace.h+1−1
@@ -398,7 +398,7 @@ static inline struct net *read_pnet(const possible_net_t *pnet) · 397 unmodified lines
398398 #endif
399399 }
400400
401−static inline struct net *read_pnet_rcu(possible_net_t *pnet)
401+static inline struct net *read_pnet_rcu(const possible_net_t *pnet)
402402 {
403403 #ifdef CONFIG_NET_NS
404404 return rcu_dereference(pnet->net);
include/net/route.h+7−2
@@ -382,10 +382,15 @@ static inline int inet_iif(const struct sk_buff *skb) · 381 unmodified lines
382382 static inline int ip4_dst_hoplimit(const struct dst_entry *dst)
383383 {
384384 int hoplimit = dst_metric_raw(dst, RTAX_HOPLIMIT);
385− struct net *net = dev_net(dst->dev);
386385
387− if (hoplimit == 0)
386+ if (hoplimit == 0) {
387+ const struct net *net;
388+
389+ rcu_read_lock();
390+ net = dev_net_rcu(dst->dev);
388391 hoplimit = READ_ONCE(net->ipv4.sysctl_ip_default_ttl);
392+ rcu_read_unlock();
393+ }
389394 return hoplimit;
390395 }
391396
include/uapi/linux/ethtool.h+2−0
@@ -682,6 +682,7 @@ enum ethtool_link_ext_substate_module { · 681 unmodified lines
682682 * @ETH_SS_STATS_ETH_CTRL: names of IEEE 802.3 MAC Control statistics
683683 * @ETH_SS_STATS_RMON: names of RMON statistics
684684 * @ETH_SS_STATS_PHY: names of PHY(dev) statistics
685+ * @ETH_SS_TS_FLAGS: hardware timestamping flags
685686 *
686687 * @ETH_SS_COUNT: number of defined string sets
687688 */
@@ -708,6 +709,7 @@ enum ethtool_stringset { · 20 unmodified lines
708709 ETH_SS_STATS_ETH_CTRL,
709710 ETH_SS_STATS_RMON,
710711 ETH_SS_STATS_PHY,
712+ ETH_SS_TS_FLAGS,
711713
712714 /* add new constants above here */
713715 ETH_SS_COUNT
net/ax25/af_ax25.c+11−0
@@ -685,6 +685,15 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, · 684 unmodified lines
685685 break;
686686 }
687687
688+ if (ax25->ax25_dev) {
689+ if (dev == ax25->ax25_dev->dev) {
690+ rcu_read_unlock();
691+ break;
692+ }
693+ netdev_put(ax25->ax25_dev->dev, &ax25->dev_tracker);
694+ ax25_dev_put(ax25->ax25_dev);
695+ }
696+
688697 ax25->ax25_dev = ax25_dev_ax25dev(dev);
689698 if (!ax25->ax25_dev) {
690699 rcu_read_unlock();
@@ -692,6 +701,8 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, · 1 unmodified line
692701 break;
693702 }
694703 ax25_fillin_cb(ax25, ax25->ax25_dev);
704+ netdev_hold(dev, &ax25->dev_tracker, GFP_ATOMIC);
705+ ax25_dev_hold(ax25->ax25_dev);
695706 rcu_read_unlock();
696707 break;
697708
net/batman-adv/bat_v.c+0−2
@@ -113,8 +113,6 @@ static void · 112 unmodified lines
113113 batadv_v_hardif_neigh_init(struct batadv_hardif_neigh_node *hardif_neigh)
114114 {
115115 ewma_throughput_init(&hardif_neigh->bat_v.throughput);
116− INIT_WORK(&hardif_neigh->bat_v.metric_work,
117− batadv_v_elp_throughput_metric_update);
118116 }
119117
120118 /**
net/batman-adv/bat_v_elp.c+86−36
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818 #include <linux/if_ether.h>
1919 #include <linux/jiffies.h>
2020 #include <linux/kref.h>
21+#include <linux/list.h>
2122 #include <linux/minmax.h>
2223 #include <linux/netdevice.h>
2324 #include <linux/nl80211.h>
@@ -26,6 +27,7 @@ · 2 unmodified lines
2627 #include <linux/rcupdate.h>
2728 #include <linux/rtnetlink.h>
2829 #include <linux/skbuff.h>
30+#include <linux/slab.h>
2931 #include <linux/stddef.h>
3032 #include <linux/string.h>
3133 #include <linux/types.h>
@@ -41,6 +43,18 @@ · 9 unmodified lines
4143 #include "routing.h"
4244 #include "send.h"
4345
46+/**
47+ * struct batadv_v_metric_queue_entry - list of hardif neighbors which require
48+ * and metric update
49+ */
50+struct batadv_v_metric_queue_entry {
51+ /** @hardif_neigh: hardif neighbor scheduled for metric update */
52+ struct batadv_hardif_neigh_node *hardif_neigh;
53+
54+ /** @list: list node for metric_queue */
55+ struct list_head list;
56+};
57+
4458 /**
4559 * batadv_v_elp_start_timer() - restart timer for ELP periodic work
4660 * @hard_iface: the interface for which the timer has to be reset
@@ -59,25 +73,36 @@ static void batadv_v_elp_start_timer(struct batadv_hard_iface *hard_iface) · 12 unmodified lines
5973 /**
6074 * batadv_v_elp_get_throughput() - get the throughput towards a neighbour
6175 * @neigh: the neighbour for which the throughput has to be obtained
76+ * @pthroughput: calculated throughput towards the given neighbour in multiples
77+ * of 100kpbs (a value of '1' equals 0.1Mbps, '10' equals 1Mbps, etc).
6278 *
63− * Return: The throughput towards the given neighbour in multiples of 100kpbs
64− * (a value of '1' equals 0.1Mbps, '10' equals 1Mbps, etc).
79+ * Return: true when value behind @pthroughput was set
6580 */
66−static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh)
81+static bool batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh,
82+ u32 *pthroughput)
6783 {
6884 struct batadv_hard_iface *hard_iface = neigh->if_incoming;
85+ struct net_device *soft_iface = hard_iface->soft_iface;
6986 struct ethtool_link_ksettings link_settings;
7087 struct net_device *real_netdev;
7188 struct station_info sinfo;
7289 u32 throughput;
7390 int ret;
7491
92+ /* don't query throughput when no longer associated with any
93+ * batman-adv interface
94+ */
95+ if (!soft_iface)
96+ return false;
97+
7598 /* if the user specified a customised value for this interface, then
7699 * return it directly
77100 */
78101 throughput = atomic_read(&hard_iface->bat_v.throughput_override);
79− if (throughput != 0)
80− return throughput;
102+ if (throughput != 0) {
103+ *pthroughput = throughput;
104+ return true;
105+ }
81106
82107 /* if this is a wireless device, then ask its throughput through
83108 * cfg80211 API
@@ -104,27 +129,39 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh) · 20 unmodified lines
104129 * possible to delete this neighbor. For now set
105130 * the throughput metric to 0.
106131 */
107− return 0;
132+ *pthroughput = 0;
133+ return true;
108134 }
109135 if (ret)
110136 goto default_throughput;
111137
112− if (sinfo.filled & BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT))
113− return sinfo.expected_throughput / 100;
138+ if (sinfo.filled & BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT)) {
139+ *pthroughput = sinfo.expected_throughput / 100;
140+ return true;
141+ }
114142
115143 /* try to estimate the expected throughput based on reported tx
116144 * rates
117145 */
118− if (sinfo.filled & BIT(NL80211_STA_INFO_TX_BITRATE))
119− return cfg80211_calculate_bitrate(&sinfo.txrate) / 3;
146+ if (sinfo.filled & BIT(NL80211_STA_INFO_TX_BITRATE)) {
147+ *pthroughput = cfg80211_calculate_bitrate(&sinfo.txrate) / 3;
148+ return true;
149+ }
120150
121151 goto default_throughput;
122152 }
123153
154+ /* only use rtnl_trylock because the elp worker will be cancelled while
155+ * the rntl_lock is held. the cancel_delayed_work_sync() would otherwise
156+ * wait forever when the elp work_item was started and it is then also
157+ * trying to rtnl_lock
158+ */
159+ if (!rtnl_trylock())
160+ return false;
161+
124162 /* if not a wifi interface, check if this device provides data via
125163 * ethtool (e.g. an Ethernet adapter)
126164 */
127− rtnl_lock();
128165 ret = __ethtool_get_link_ksettings(hard_iface->net_dev, &link_settings);
129166 rtnl_unlock();
130167 if (ret == 0) {
@@ -135,13 +172,15 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh) · 4 unmodified lines
135172 hard_iface->bat_v.flags &= ~BATADV_FULL_DUPLEX;
136173
137174 throughput = link_settings.base.speed;
138− if (throughput && throughput != SPEED_UNKNOWN)
139− return throughput * 10;
175+ if (throughput && throughput != SPEED_UNKNOWN) {
176+ *pthroughput = throughput * 10;
177+ return true;
178+ }
140179 }
141180
142181 default_throughput:
143182 if (!(hard_iface->bat_v.flags & BATADV_WARNING_DEFAULT)) {
144− batadv_info(hard_iface->soft_iface,
183+ batadv_info(soft_iface,
145184 "WiFi driver or ethtool info does not provide information about link speeds on interface %s, therefore defaulting to hardcoded throughput values of %u.%1u Mbps. Consider overriding the throughput manually or checking your driver.\n",
146185 hard_iface->net_dev->name,
147186 BATADV_THROUGHPUT_DEFAULT_VALUE / 10,
@@ -150,31 +189,26 @@ default_throughput: · 2 unmodified lines
150189 }
151190
152191 /* if none of the above cases apply, return the base_throughput */
153− return BATADV_THROUGHPUT_DEFAULT_VALUE;
192+ *pthroughput = BATADV_THROUGHPUT_DEFAULT_VALUE;
193+ return true;
154194 }
155195
156196 /**
157197 * batadv_v_elp_throughput_metric_update() - worker updating the throughput
158198 * metric of a single hop neighbour
159− * @work: the work queue item
199+ * @neigh: the neighbour to probe
160200 */
161−void batadv_v_elp_throughput_metric_update(struct work_struct *work)
201+static void
202+batadv_v_elp_throughput_metric_update(struct batadv_hardif_neigh_node *neigh)
162203 {
163− struct batadv_hardif_neigh_node_bat_v *neigh_bat_v;
164− struct batadv_hardif_neigh_node *neigh;
165−
166− neigh_bat_v = container_of(work, struct batadv_hardif_neigh_node_bat_v,
167− metric_work);
168− neigh = container_of(neigh_bat_v, struct batadv_hardif_neigh_node,
169− bat_v);
204+ u32 throughput;
205+ bool valid;
170206
171− ewma_throughput_add(&neigh->bat_v.throughput,
172− batadv_v_elp_get_throughput(neigh));
207+ valid = batadv_v_elp_get_throughput(neigh, &throughput);
208+ if (!valid)
209+ return;
173210
174− /* decrement refcounter to balance increment performed before scheduling
175− * this task
176− */
177− batadv_hardif_neigh_put(neigh);
211+ ewma_throughput_add(&neigh->bat_v.throughput, throughput);
178212 }
179213
180214 /**
@@ -248,14 +282,16 @@ batadv_v_elp_wifi_neigh_probe(struct batadv_hardif_neigh_node *neigh) · 67 unmodified lines
248282 */
249283 static void batadv_v_elp_periodic_work(struct work_struct *work)
250284 {
285+ struct batadv_v_metric_queue_entry *metric_entry;
286+ struct batadv_v_metric_queue_entry *metric_safe;
251287 struct batadv_hardif_neigh_node *hardif_neigh;
252288 struct batadv_hard_iface *hard_iface;
253289 struct batadv_hard_iface_bat_v *bat_v;
254290 struct batadv_elp_packet *elp_packet;
291+ struct list_head metric_queue;
255292 struct batadv_priv *bat_priv;
256293 struct sk_buff *skb;
257294 u32 elp_interval;
258− bool ret;
259295
260296 bat_v = container_of(work, struct batadv_hard_iface_bat_v, elp_wq.work);
261297 hard_iface = container_of(bat_v, struct batadv_hard_iface, bat_v);
@@ -291,6 +327,8 @@ static void batadv_v_elp_periodic_work(struct work_struct *work) · 29 unmodified lines
291327
292328 atomic_inc(&hard_iface->bat_v.elp_seqno);
293329
330+ INIT_LIST_HEAD(&metric_queue);
331+
294332 /* The throughput metric is updated on each sent packet. This way, if a
295333 * node is dead and no longer sends packets, batman-adv is still able to
296334 * react timely to its death.
@@ -315,16 +353,28 @@ static void batadv_v_elp_periodic_work(struct work_struct *work) · 18 unmodified lines
315353
316354 /* Reading the estimated throughput from cfg80211 is a task that
317355 * may sleep and that is not allowed in an rcu protected
318− * context. Therefore schedule a task for that.
356+ * context. Therefore add it to metric_queue and process it
357+ * outside rcu protected context.
319358 */
320− ret = queue_work(batadv_event_workqueue,
321− &hardif_neigh->bat_v.metric_work);
322−
323− if (!ret)
359+ metric_entry = kzalloc(sizeof(*metric_entry), GFP_ATOMIC);
360+ if (!metric_entry) {
324361 batadv_hardif_neigh_put(hardif_neigh);
362+ continue;
363+ }
364+
365+ metric_entry->hardif_neigh = hardif_neigh;
366+ list_add(&metric_entry->list, &metric_queue);
325367 }
326368 rcu_read_unlock();
327369
370+ list_for_each_entry_safe(metric_entry, metric_safe, &metric_queue, list) {
371+ batadv_v_elp_throughput_metric_update(metric_entry->hardif_neigh);
372+
373+ batadv_hardif_neigh_put(metric_entry->hardif_neigh);
374+ list_del(&metric_entry->list);
375+ kfree(metric_entry);
376+ }
377+
328378 restart_timer:
329379 batadv_v_elp_start_timer(hard_iface);
330380 out:
net/batman-adv/bat_v_elp.h+0−2
@@ -10,7 +10,6 @@ · 9 unmodified lines
1010 #include "main.h"
1111
1212 #include <linux/skbuff.h>
13−#include <linux/workqueue.h>
1413
1514 int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface);
1615 void batadv_v_elp_iface_disable(struct batadv_hard_iface *hard_iface);
@@ -19,6 +18,5 @@ void batadv_v_elp_iface_activate(struct batadv_hard_iface *primary_iface, · 2 unmodified lines
1918 void batadv_v_elp_primary_iface_set(struct batadv_hard_iface *primary_iface);
2019 int batadv_v_elp_packet_recv(struct sk_buff *skb,
2120 struct batadv_hard_iface *if_incoming);
22−void batadv_v_elp_throughput_metric_update(struct work_struct *work);
2321
2422 #endif /* _NET_BATMAN_ADV_BAT_V_ELP_H_ */
net/batman-adv/translation-table.c+5−7
@@ -3937,23 +3937,21 @@ static void batadv_tt_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, · 3936 unmodified lines
39373937 struct batadv_tvlv_tt_change *tt_change;
39383938 struct batadv_tvlv_tt_data *tt_data;
39393939 u16 num_entries, num_vlan;
3940− size_t flex_size;
3940+ size_t tt_data_sz;
39413941
39423942 if (tvlv_value_len < sizeof(*tt_data))
39433943 return;
39443944
39453945 tt_data = tvlv_value;
3946− tvlv_value_len -= sizeof(*tt_data);
3947−
39483946 num_vlan = ntohs(tt_data->num_vlan);
39493947
3950− flex_size = flex_array_size(tt_data, vlan_data, num_vlan);
3951− if (tvlv_value_len < flex_size)
3948+ tt_data_sz = struct_size(tt_data, vlan_data, num_vlan);
3949+ if (tvlv_value_len < tt_data_sz)
39523950 return;
39533951
39543952 tt_change = (struct batadv_tvlv_tt_change *)((void *)tt_data
3955− + flex_size);
3956− tvlv_value_len -= flex_size;
3953+ + tt_data_sz);
3954+ tvlv_value_len -= tt_data_sz;
39573955
39583956 num_entries = batadv_tt_entries(tvlv_value_len);
39593957
net/batman-adv/types.h+0−3
@@ -596,9 +596,6 @@ struct batadv_hardif_neigh_node_bat_v { · 595 unmodified lines
596596 * neighbor
597597 */
598598 unsigned long last_unicast_tx;
599−
600− /** @metric_work: work queue callback item for metric update */
601− struct work_struct metric_work;
602599 };
603600
604601 /**
net/bluetooth/l2cap_core.c+79−90
@@ -119,7 +119,6 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, · 118 unmodified lines
119119 {
120120 struct l2cap_chan *c;
121121
122− mutex_lock(&conn->chan_lock);
123122 c = __l2cap_get_chan_by_scid(conn, cid);
124123 if (c) {
125124 /* Only lock if chan reference is not 0 */
@@ -127,7 +126,6 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, · 1 unmodified line
127126 if (c)
128127 l2cap_chan_lock(c);
129128 }
130− mutex_unlock(&conn->chan_lock);
131129
132130 return c;
133131 }
@@ -140,7 +138,6 @@ static struct l2cap_chan *l2cap_get_chan_by_dcid(struct l2cap_conn *conn, · 6 unmodified lines
140138 {
141139 struct l2cap_chan *c;
142140
143− mutex_lock(&conn->chan_lock);
144141 c = __l2cap_get_chan_by_dcid(conn, cid);
145142 if (c) {
146143 /* Only lock if chan reference is not 0 */
@@ -148,7 +145,6 @@ static struct l2cap_chan *l2cap_get_chan_by_dcid(struct l2cap_conn *conn, · 1 unmodified line
148145 if (c)
149146 l2cap_chan_lock(c);
150147 }
151− mutex_unlock(&conn->chan_lock);
152148
153149 return c;
154150 }
@@ -418,7 +414,7 @@ static void l2cap_chan_timeout(struct work_struct *work) · 263 unmodified lines
418414 if (!conn)
419415 return;
420416
421− mutex_lock(&conn->chan_lock);
417+ mutex_lock(&conn->lock);
422418 /* __set_chan_timer() calls l2cap_chan_hold(chan) while scheduling
423419 * this work. No need to call l2cap_chan_hold(chan) here again.
424420 */
@@ -439,7 +435,7 @@ static void l2cap_chan_timeout(struct work_struct *work) · 14 unmodified lines
439435 l2cap_chan_unlock(chan);
440436 l2cap_chan_put(chan);
441437
442− mutex_unlock(&conn->chan_lock);
438+ mutex_unlock(&conn->lock);
443439 }
444440
445441 struct l2cap_chan *l2cap_chan_create(void)
@@ -641,9 +637,9 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) · 195 unmodified lines
641637
642638 void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
643639 {
644− mutex_lock(&conn->chan_lock);
640+ mutex_lock(&conn->lock);
645641 __l2cap_chan_add(conn, chan);
646− mutex_unlock(&conn->chan_lock);
642+ mutex_unlock(&conn->lock);
647643 }
648644
649645 void l2cap_chan_del(struct l2cap_chan *chan, int err)
@@ -731,9 +727,9 @@ void l2cap_chan_list(struct l2cap_conn *conn, l2cap_chan_func_t func, · 81 unmodified lines
731727 if (!conn)
732728 return;
733729
734− mutex_lock(&conn->chan_lock);
730+ mutex_lock(&conn->lock);
735731 __l2cap_chan_list(conn, func, data);
736− mutex_unlock(&conn->chan_lock);
732+ mutex_unlock(&conn->lock);
737733 }
738734
739735 EXPORT_SYMBOL_GPL(l2cap_chan_list);
@@ -745,7 +741,7 @@ static void l2cap_conn_update_id_addr(struct work_struct *work) · 5 unmodified lines
745741 struct hci_conn *hcon = conn->hcon;
746742 struct l2cap_chan *chan;
747743
748− mutex_lock(&conn->chan_lock);
744+ mutex_lock(&conn->lock);
749745
750746 list_for_each_entry(chan, &conn->chan_l, list) {
751747 l2cap_chan_lock(chan);
@@ -754,7 +750,7 @@ static void l2cap_conn_update_id_addr(struct work_struct *work) · 2 unmodified lines
754750 l2cap_chan_unlock(chan);
755751 }
756752
757− mutex_unlock(&conn->chan_lock);
753+ mutex_unlock(&conn->lock);
758754 }
759755
760756 static void l2cap_chan_le_connect_reject(struct l2cap_chan *chan)
@@ -948,6 +944,16 @@ static u8 l2cap_get_ident(struct l2cap_conn *conn) · 187 unmodified lines
948944 return id;
949945 }
950946
947+static void l2cap_send_acl(struct l2cap_conn *conn, struct sk_buff *skb,
948+ u8 flags)
949+{
950+ /* Check if the hcon still valid before attempting to send */
951+ if (hci_conn_valid(conn->hcon->hdev, conn->hcon))
952+ hci_send_acl(conn->hchan, skb, flags);
953+ else
954+ kfree_skb(skb);
955+}
956+
951957 static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len,
952958 void *data)
953959 {
@@ -970,7 +976,7 @@ static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, · 16 unmodified lines
970976 bt_cb(skb)->force_active = BT_POWER_FORCE_ACTIVE_ON;
971977 skb->priority = HCI_PRIO_MAX;
972978
973− hci_send_acl(conn->hchan, skb, flags);
979+ l2cap_send_acl(conn, skb, flags);
974980 }
975981
976982 static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb)
@@ -1497,8 +1503,6 @@ static void l2cap_conn_start(struct l2cap_conn *conn) · 520 unmodified lines
14971503
14981504 BT_DBG("conn %p", conn);
14991505
1500− mutex_lock(&conn->chan_lock);
1501−
15021506 list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) {
15031507 l2cap_chan_lock(chan);
15041508
@@ -1567,8 +1571,6 @@ static void l2cap_conn_start(struct l2cap_conn *conn) · 62 unmodified lines
15671571
15681572 l2cap_chan_unlock(chan);
15691573 }
1570−
1571− mutex_unlock(&conn->chan_lock);
15721574 }
15731575
15741576 static void l2cap_le_conn_ready(struct l2cap_conn *conn)
@@ -1614,7 +1616,7 @@ static void l2cap_conn_ready(struct l2cap_conn *conn) · 39 unmodified lines
16141616 if (hcon->type == ACL_LINK)
16151617 l2cap_request_info(conn);
16161618
1617− mutex_lock(&conn->chan_lock);
1619+ mutex_lock(&conn->lock);
16181620
16191621 list_for_each_entry(chan, &conn->chan_l, list) {
16201622
@@ -1632,7 +1634,7 @@ static void l2cap_conn_ready(struct l2cap_conn *conn) · 11 unmodified lines
16321634 l2cap_chan_unlock(chan);
16331635 }
16341636
1635− mutex_unlock(&conn->chan_lock);
1637+ mutex_unlock(&conn->lock);
16361638
16371639 if (hcon->type == LE_LINK)
16381640 l2cap_le_conn_ready(conn);
@@ -1647,14 +1649,10 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err) · 8 unmodified lines
16471649
16481650 BT_DBG("conn %p", conn);
16491651
1650− mutex_lock(&conn->chan_lock);
1651−
16521652 list_for_each_entry(chan, &conn->chan_l, list) {
16531653 if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags))
16541654 l2cap_chan_set_err(chan, err);
16551655 }
1656−
1657− mutex_unlock(&conn->chan_lock);
16581656 }
16591657
16601658 static void l2cap_info_timeout(struct work_struct *work)
@@ -1665,7 +1663,9 @@ static void l2cap_info_timeout(struct work_struct *work) · 4 unmodified lines
16651663 conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
16661664 conn->info_ident = 0;
16671665
1666+ mutex_lock(&conn->lock);
16681667 l2cap_conn_start(conn);
1668+ mutex_unlock(&conn->lock);
16691669 }
16701670
16711671 /*
@@ -1757,6 +1757,8 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) · 85 unmodified lines
17571757
17581758 BT_DBG("hcon %p conn %p, err %d", hcon, conn, err);
17591759
1760+ mutex_lock(&conn->lock);
1761+
17601762 kfree_skb(conn->rx_skb);
17611763
17621764 skb_queue_purge(&conn->pending_rx);
@@ -1775,8 +1777,6 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) · 12 unmodified lines
17751777 /* Force the connection to be immediately dropped */
17761778 hcon->disc_timeout = 0;
17771779
1778− mutex_lock(&conn->chan_lock);
1779−
17801780 /* Kill channels */
17811781 list_for_each_entry_safe(chan, l, &conn->chan_l, list) {
17821782 l2cap_chan_hold(chan);
@@ -1790,15 +1790,14 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) · 7 unmodified lines
17901790 l2cap_chan_put(chan);
17911791 }
17921792
1793− mutex_unlock(&conn->chan_lock);
1794−
1795− hci_chan_del(conn->hchan);
1796−
17971793 if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT)
17981794 cancel_delayed_work_sync(&conn->info_timer);
17991795
1800− hcon->l2cap_data = NULL;
1796+ hci_chan_del(conn->hchan);
18011797 conn->hchan = NULL;
1798+
1799+ hcon->l2cap_data = NULL;
1800+ mutex_unlock(&conn->lock);
18021801 l2cap_conn_put(conn);
18031802 }
18041803
@@ -2916,8 +2915,6 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb) · 1111 unmodified lines
29162915
29172916 BT_DBG("conn %p", conn);
29182917
2919− mutex_lock(&conn->chan_lock);
2920−
29212918 list_for_each_entry(chan, &conn->chan_l, list) {
29222919 if (chan->chan_type != L2CAP_CHAN_RAW)
29232920 continue;
@@ -2932,8 +2929,6 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb) · 8 unmodified lines
29322929 if (chan->ops->recv(chan, nskb))
29332930 kfree_skb(nskb);
29342931 }
2935−
2936− mutex_unlock(&conn->chan_lock);
29372932 }
29382933
29392934 /* ---- L2CAP signalling commands ---- */
@@ -3952,7 +3947,6 @@ static void l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, · 1012 unmodified lines
39523947 goto response;
39533948 }
39543949
3955− mutex_lock(&conn->chan_lock);
39563950 l2cap_chan_lock(pchan);
39573951
39583952 /* Check if the ACL is secure enough (if not SDP) */
@@ -4059,7 +4053,6 @@ response: · 100 unmodified lines
40594053 }
40604054
40614055 l2cap_chan_unlock(pchan);
4062− mutex_unlock(&conn->chan_lock);
40634056 l2cap_chan_put(pchan);
40644057 }
40654058
@@ -4098,27 +4091,19 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn, · 32 unmodified lines
40984091 BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x",
40994092 dcid, scid, result, status);
41004093
4101− mutex_lock(&conn->chan_lock);
4102−
41034094 if (scid) {
41044095 chan = __l2cap_get_chan_by_scid(conn, scid);
4105− if (!chan) {
4106− err = -EBADSLT;
4107− goto unlock;
4108− }
4096+ if (!chan)
4097+ return -EBADSLT;
41094098 } else {
41104099 chan = __l2cap_get_chan_by_ident(conn, cmd->ident);
4111− if (!chan) {
4112− err = -EBADSLT;
4113− goto unlock;
4114− }
4100+ if (!chan)
4101+ return -EBADSLT;
41154102 }
41164103
41174104 chan = l2cap_chan_hold_unless_zero(chan);
4118− if (!chan) {
4119− err = -EBADSLT;
4120− goto unlock;
4121− }
4105+ if (!chan)
4106+ return -EBADSLT;
41224107
41234108 err = 0;
41244109
@@ -4156,9 +4141,6 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn, · 31 unmodified lines
41564141 l2cap_chan_unlock(chan);
41574142 l2cap_chan_put(chan);
41584143
4159−unlock:
4160− mutex_unlock(&conn->chan_lock);
4161−
41624144 return err;
41634145 }
41644146
@@ -4446,11 +4428,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, · 281 unmodified lines
44464428
44474429 chan->ops->set_shutdown(chan);
44484430
4449− l2cap_chan_unlock(chan);
4450− mutex_lock(&conn->chan_lock);
4451− l2cap_chan_lock(chan);
44524431 l2cap_chan_del(chan, ECONNRESET);
4453− mutex_unlock(&conn->chan_lock);
44544432
44554433 chan->ops->close(chan);
44564434
@@ -4487,11 +4465,7 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, · 30 unmodified lines
44874465 return 0;
44884466 }
44894467
4490− l2cap_chan_unlock(chan);
4491− mutex_lock(&conn->chan_lock);
4492− l2cap_chan_lock(chan);
44934468 l2cap_chan_del(chan, 0);
4494− mutex_unlock(&conn->chan_lock);
44954469
44964470 chan->ops->close(chan);
44974471
@@ -4689,13 +4663,9 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn, · 191 unmodified lines
46894663 BT_DBG("dcid 0x%4.4x mtu %u mps %u credits %u result 0x%2.2x",
46904664 dcid, mtu, mps, credits, result);
46914665
4692− mutex_lock(&conn->chan_lock);
4693−
46944666 chan = __l2cap_get_chan_by_ident(conn, cmd->ident);
4695− if (!chan) {
4696− err = -EBADSLT;
4697− goto unlock;
4698− }
4667+ if (!chan)
4668+ return -EBADSLT;
46994669
47004670 err = 0;
47014671
@@ -4743,9 +4713,6 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn, · 41 unmodified lines
47434713
47444714 l2cap_chan_unlock(chan);
47454715
4746−unlock:
4747− mutex_unlock(&conn->chan_lock);
4748−
47494716 return err;
47504717 }
47514718
@@ -4857,7 +4824,6 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, · 105 unmodified lines
48574824 goto response;
48584825 }
48594826
4860− mutex_lock(&conn->chan_lock);
48614827 l2cap_chan_lock(pchan);
48624828
48634829 if (!smp_sufficient_security(conn->hcon, pchan->sec_level,
@@ -4923,7 +4889,6 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, · 59 unmodified lines
49234889
49244890 response_unlock:
49254891 l2cap_chan_unlock(pchan);
4926− mutex_unlock(&conn->chan_lock);
49274892 l2cap_chan_put(pchan);
49284893
49294894 if (result == L2CAP_CR_PEND)
@@ -5057,7 +5022,6 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, · 127 unmodified lines
50575022 goto response;
50585023 }
50595024
5060− mutex_lock(&conn->chan_lock);
50615025 l2cap_chan_lock(pchan);
50625026
50635027 if (!smp_sufficient_security(conn->hcon, pchan->sec_level,
@@ -5132,7 +5096,6 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, · 68 unmodified lines
51325096
51335097 unlock:
51345098 l2cap_chan_unlock(pchan);
5135− mutex_unlock(&conn->chan_lock);
51365099 l2cap_chan_put(pchan);
51375100
51385101 response:
@@ -5169,8 +5132,6 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, · 30 unmodified lines
51695132 BT_DBG("mtu %u mps %u credits %u result 0x%4.4x", mtu, mps, credits,
51705133 result);
51715134
5172− mutex_lock(&conn->chan_lock);
5173−
51745135 cmd_len -= sizeof(*rsp);
51755136
51765137 list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) {
@@ -5256,8 +5217,6 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, · 79 unmodified lines
52565217 l2cap_chan_unlock(chan);
52575218 }
52585219
5259− mutex_unlock(&conn->chan_lock);
5260−
52615220 return err;
52625221 }
52635222
@@ -5370,8 +5329,6 @@ static inline int l2cap_le_command_rej(struct l2cap_conn *conn, · 106 unmodified lines
53705329 if (cmd_len < sizeof(*rej))
53715330 return -EPROTO;
53725331
5373− mutex_lock(&conn->chan_lock);
5374−
53755332 chan = __l2cap_get_chan_by_ident(conn, cmd->ident);
53765333 if (!chan)
53775334 goto done;
@@ -5386,7 +5343,6 @@ static inline int l2cap_le_command_rej(struct l2cap_conn *conn, · 8 unmodified lines
53865343 l2cap_chan_put(chan);
53875344
53885345 done:
5389− mutex_unlock(&conn->chan_lock);
53905346 return 0;
53915347 }
53925348
@@ -6841,8 +6797,12 @@ static void process_pending_rx(struct work_struct *work) · 1448 unmodified lines
68416797
68426798 BT_DBG("");
68436799
6800+ mutex_lock(&conn->lock);
6801+
68446802 while ((skb = skb_dequeue(&conn->pending_rx)))
68456803 l2cap_recv_frame(conn, skb);
6804+
6805+ mutex_unlock(&conn->lock);
68466806 }
68476807
68486808 static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon)
@@ -6881,7 +6841,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon) · 32 unmodified lines
68816841 conn->local_fixed_chan |= L2CAP_FC_SMP_BREDR;
68826842
68836843 mutex_init(&conn->ident_lock);
6884− mutex_init(&conn->chan_lock);
6844+ mutex_init(&conn->lock);
68856845
68866846 INIT_LIST_HEAD(&conn->chan_l);
68876847 INIT_LIST_HEAD(&conn->users);
@@ -7072,7 +7032,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, · 184 unmodified lines
70727032 }
70737033 }
70747034
7075− mutex_lock(&conn->chan_lock);
7035+ mutex_lock(&conn->lock);
70767036 l2cap_chan_lock(chan);
70777037
70787038 if (cid && __l2cap_get_chan_by_dcid(conn, cid)) {
@@ -7113,7 +7073,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, · 34 unmodified lines
71137073
71147074 chan_unlock:
71157075 l2cap_chan_unlock(chan);
7116− mutex_unlock(&conn->chan_lock);
7076+ mutex_unlock(&conn->lock);
71177077 done:
71187078 hci_dev_unlock(hdev);
71197079 hci_dev_put(hdev);
@@ -7325,7 +7285,7 @@ static void l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) · 205 unmodified lines
73257285
73267286 BT_DBG("conn %p status 0x%2.2x encrypt %u", conn, status, encrypt);
73277287
7328− mutex_lock(&conn->chan_lock);
7288+ mutex_lock(&conn->lock);
73297289
73307290 list_for_each_entry(chan, &conn->chan_l, list) {
73317291 l2cap_chan_lock(chan);
@@ -7399,7 +7359,7 @@ static void l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) · 67 unmodified lines
73997359 l2cap_chan_unlock(chan);
74007360 }
74017361
7402− mutex_unlock(&conn->chan_lock);
7362+ mutex_unlock(&conn->lock);
74037363 }
74047364
74057365 /* Append fragment into frame respecting the maximum len of rx_skb */
@@ -7466,19 +7426,45 @@ static void l2cap_recv_reset(struct l2cap_conn *conn) · 60 unmodified lines
74667426 conn->rx_len = 0;
74677427 }
74687428
7429+struct l2cap_conn *l2cap_conn_hold_unless_zero(struct l2cap_conn *c)
7430+{
7431+ if (!c)
7432+ return NULL;
7433+
7434+ BT_DBG("conn %p orig refcnt %u", c, kref_read(&c->ref));
7435+
7436+ if (!kref_get_unless_zero(&c->ref))
7437+ return NULL;
7438+
7439+ return c;
7440+}
7441+
74697442 void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
74707443 {
7471− struct l2cap_conn *conn = hcon->l2cap_data;
7444+ struct l2cap_conn *conn;
74727445 int len;
74737446
7447+ /* Lock hdev to access l2cap_data to avoid race with l2cap_conn_del */
7448+ hci_dev_lock(hcon->hdev);
7449+
7450+ conn = hcon->l2cap_data;
7451+
74747452 if (!conn)
74757453 conn = l2cap_conn_add(hcon);
74767454
7477− if (!conn)
7478− goto drop;
7455+ conn = l2cap_conn_hold_unless_zero(conn);
7456+
7457+ hci_dev_unlock(hcon->hdev);
7458+
7459+ if (!conn) {
7460+ kfree_skb(skb);
7461+ return;
7462+ }
74797463
74807464 BT_DBG("conn %p len %u flags 0x%x", conn, skb->len, flags);
74817465
7466+ mutex_lock(&conn->lock);
7467+
74827468 switch (flags) {
74837469 case ACL_START:
74847470 case ACL_START_NO_FLUSH:
@@ -7503,7 +7489,7 @@ void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) · 18 unmodified lines
75037489 if (len == skb->len) {
75047490 /* Complete frame received */
75057491 l2cap_recv_frame(conn, skb);
7506− return;
7492+ goto unlock;
75077493 }
75087494
75097495 BT_DBG("Start: total len %d, frag len %u", len, skb->len);
@@ -7567,6 +7553,9 @@ void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) · 57 unmodified lines
75677553
75687554 drop:
75697555 kfree_skb(skb);
7556+unlock:
7557+ mutex_unlock(&conn->lock);
7558+ l2cap_conn_put(conn);
75707559 }
75717560
75727561 static struct hci_cb l2cap_cb = {
net/bluetooth/l2cap_sock.c+7−8
@@ -1326,9 +1326,10 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) · 1325 unmodified lines
13261326 /* prevent sk structure from being freed whilst unlocked */
13271327 sock_hold(sk);
13281328
1329− chan = l2cap_pi(sk)->chan;
13301329 /* prevent chan structure from being freed whilst unlocked */
1331− l2cap_chan_hold(chan);
1330+ chan = l2cap_chan_hold_unless_zero(l2cap_pi(sk)->chan);
1331+ if (!chan)
1332+ goto shutdown_already;
13321333
13331334 BT_DBG("chan %p state %s", chan, state_to_string(chan->state));
13341335
@@ -1358,22 +1359,20 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) · 23 unmodified lines
13581359 release_sock(sk);
13591360
13601361 l2cap_chan_lock(chan);
1361− conn = chan->conn;
1362− if (conn)
1363− /* prevent conn structure from being freed */
1364− l2cap_conn_get(conn);
1362+ /* prevent conn structure from being freed */
1363+ conn = l2cap_conn_hold_unless_zero(chan->conn);
13651364 l2cap_chan_unlock(chan);
13661365
13671366 if (conn)
13681367 /* mutex lock must be taken before l2cap_chan_lock() */
1369− mutex_lock(&conn->chan_lock);
1368+ mutex_lock(&conn->lock);
13701369
13711370 l2cap_chan_lock(chan);
13721371 l2cap_chan_close(chan, 0);
13731372 l2cap_chan_unlock(chan);
13741373
13751374 if (conn) {
1376− mutex_unlock(&conn->chan_lock);
1375+ mutex_unlock(&conn->lock);
13771376 l2cap_conn_put(conn);
13781377 }
13791378
net/can/j1939/socket.c+2−2
@@ -1132,7 +1132,7 @@ static int j1939_sk_send_loop(struct j1939_priv *priv, struct sock *sk, · 1131 unmodified lines
11321132
11331133 todo_size = size;
11341134
1135− while (todo_size) {
1135+ do {
11361136 struct j1939_sk_buff_cb *skcb;
11371137
11381138 segment_size = min_t(size_t, J1939_MAX_TP_PACKET_SIZE,
@@ -1177,7 +1177,7 @@ static int j1939_sk_send_loop(struct j1939_priv *priv, struct sock *sk, · 38 unmodified lines
11771177
11781178 todo_size -= segment_size;
11791179 session->total_queued_size += segment_size;
1180− }
1180+ } while (todo_size);
11811181
11821182 switch (ret) {
11831183 case 0: /* OK */
net/can/j1939/transport.c+3−2
@@ -382,8 +382,9 @@ sk_buff *j1939_session_skb_get_by_offset(struct j1939_session *session, · 381 unmodified lines
382382 skb_queue_walk(&session->skb_queue, do_skb) {
383383 do_skcb = j1939_skb_to_cb(do_skb);
384384
385− if (offset_start >= do_skcb->offset &&
386− offset_start < (do_skcb->offset + do_skb->len)) {
385+ if ((offset_start >= do_skcb->offset &&
386+ offset_start < (do_skcb->offset + do_skb->len)) ||
387+ (offset_start == 0 && do_skcb->offset == 0 && do_skb->len == 0)) {
387388 skb = do_skb;
388389 }
389390 }
net/core/fib_rules.c+13−11
@@ -37,8 +37,8 @@ static const struct fib_kuid_range fib_kuid_range_unset = { · 36 unmodified lines
3737
3838 bool fib_rule_matchall(const struct fib_rule *rule)
3939 {
40− if (rule->iifindex || rule->oifindex || rule->mark || rule->tun_id ||
41− rule->flags)
40+ if (READ_ONCE(rule->iifindex) || READ_ONCE(rule->oifindex) ||
41+ rule->mark || rule->tun_id || rule->flags)
4242 return false;
4343 if (rule->suppress_ifgroup != -1 || rule->suppress_prefixlen != -1)
4444 return false;
@@ -261,12 +261,14 @@ static int fib_rule_match(struct fib_rule *rule, struct fib_rules_ops *ops, · 216 unmodified lines
261261 struct flowi *fl, int flags,
262262 struct fib_lookup_arg *arg)
263263 {
264− int ret = 0;
264+ int iifindex, oifindex, ret = 0;
265265
266− if (rule->iifindex && (rule->iifindex != fl->flowi_iif))
266+ iifindex = READ_ONCE(rule->iifindex);
267+ if (iifindex && (iifindex != fl->flowi_iif))
267268 goto out;
268269
269− if (rule->oifindex && (rule->oifindex != fl->flowi_oif))
270+ oifindex = READ_ONCE(rule->oifindex);
271+ if (oifindex && (oifindex != fl->flowi_oif))
270272 goto out;
271273
272274 if ((rule->mark ^ fl->flowi_mark) & rule->mark_mask)
@@ -1041,14 +1043,14 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule, · 768 unmodified lines
10411043 if (rule->iifname[0]) {
10421044 if (nla_put_string(skb, FRA_IIFNAME, rule->iifname))
10431045 goto nla_put_failure;
1044− if (rule->iifindex == -1)
1046+ if (READ_ONCE(rule->iifindex) == -1)
10451047 frh->flags |= FIB_RULE_IIF_DETACHED;
10461048 }
10471049
10481050 if (rule->oifname[0]) {
10491051 if (nla_put_string(skb, FRA_OIFNAME, rule->oifname))
10501052 goto nla_put_failure;
1051− if (rule->oifindex == -1)
1053+ if (READ_ONCE(rule->oifindex) == -1)
10521054 frh->flags |= FIB_RULE_OIF_DETACHED;
10531055 }
10541056
@@ -1220,10 +1222,10 @@ static void attach_rules(struct list_head *rules, struct net_device *dev) · 165 unmodified lines
12201222 list_for_each_entry(rule, rules, list) {
12211223 if (rule->iifindex == -1 &&
12221224 strcmp(dev->name, rule->iifname) == 0)
1223− rule->iifindex = dev->ifindex;
1225+ WRITE_ONCE(rule->iifindex, dev->ifindex);
12241226 if (rule->oifindex == -1 &&
12251227 strcmp(dev->name, rule->oifname) == 0)
1226− rule->oifindex = dev->ifindex;
1228+ WRITE_ONCE(rule->oifindex, dev->ifindex);
12271229 }
12281230 }
12291231
@@ -1233,9 +1235,9 @@ static void detach_rules(struct list_head *rules, struct net_device *dev) · 3 unmodified lines
12331235
12341236 list_for_each_entry(rule, rules, list) {
12351237 if (rule->iifindex == dev->ifindex)
1236− rule->iifindex = -1;
1238+ WRITE_ONCE(rule->iifindex, -1);
12371239 if (rule->oifindex == dev->ifindex)
1238− rule->oifindex = -1;
1240+ WRITE_ONCE(rule->oifindex, -1);
12391241 }
12401242 }
12411243
net/core/flow_dissector.c+11−10
@@ -1108,10 +1108,12 @@ bool __skb_flow_dissect(const struct net *net, · 1107 unmodified lines
11081108 FLOW_DISSECTOR_KEY_BASIC,
11091109 target_container);
11101110
1111+ rcu_read_lock();
1112+
11111113 if (skb) {
11121114 if (!net) {
11131115 if (skb->dev)
1114− net = dev_net(skb->dev);
1116+ net = dev_net_rcu(skb->dev);
11151117 else if (skb->sk)
11161118 net = sock_net(skb->sk);
11171119 }
@@ -1122,7 +1124,6 @@ bool __skb_flow_dissect(const struct net *net, · 4 unmodified lines
11221124 enum netns_bpf_attach_type type = NETNS_BPF_FLOW_DISSECTOR;
11231125 struct bpf_prog_array *run_array;
11241126
1125− rcu_read_lock();
11261127 run_array = rcu_dereference(init_net.bpf.run_array[type]);
11271128 if (!run_array)
11281129 run_array = rcu_dereference(net->bpf.run_array[type]);
@@ -1150,17 +1151,17 @@ bool __skb_flow_dissect(const struct net *net, · 21 unmodified lines
11501151 prog = READ_ONCE(run_array->items[0].prog);
11511152 result = bpf_flow_dissect(prog, &ctx, n_proto, nhoff,
11521153 hlen, flags);
1153− if (result == BPF_FLOW_DISSECTOR_CONTINUE)
1154− goto dissect_continue;
1155− __skb_flow_bpf_to_target(&flow_keys, flow_dissector,
1156− target_container);
1157− rcu_read_unlock();
1158− return result == BPF_OK;
1154+ if (result != BPF_FLOW_DISSECTOR_CONTINUE) {
1155+ __skb_flow_bpf_to_target(&flow_keys, flow_dissector,
1156+ target_container);
1157+ rcu_read_unlock();
1158+ return result == BPF_OK;
1159+ }
11591160 }
1160−dissect_continue:
1161− rcu_read_unlock();
11621161 }
11631162
1163+ rcu_read_unlock();
1164+
11641165 if (dissector_uses_key(flow_dissector,
11651166 FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
11661167 struct ethhdr *eth = eth_hdr(skb);
net/core/neighbour.c+6−2
@@ -3447,10 +3447,12 @@ static const struct seq_operations neigh_stat_seq_ops = { · 3446 unmodified lines
34473447 static void __neigh_notify(struct neighbour *n, int type, int flags,
34483448 u32 pid)
34493449 {
3450− struct net *net = dev_net(n->dev);
34513450 struct sk_buff *skb;
34523451 int err = -ENOBUFS;
3452+ struct net *net;
34533453
3454+ rcu_read_lock();
3455+ net = dev_net_rcu(n->dev);
34543456 skb = nlmsg_new(neigh_nlmsg_size(), GFP_ATOMIC);
34553457 if (skb == NULL)
34563458 goto errout;
@@ -3463,9 +3465,11 @@ static void __neigh_notify(struct neighbour *n, int type, int flags, · 6 unmodified lines
34633465 goto errout;
34643466 }
34653467 rtnl_notify(skb, net, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC);
3466− return;
3468+ goto out;
34673469 errout:
34683470 rtnl_set_sk_err(net, RTNLGRP_NEIGH, err);
3471+out:
3472+ rcu_read_unlock();
34693473 }
34703474
34713475 void neigh_app_ns(struct neighbour *n)
net/core/rtnetlink.c+1−0
@@ -3432,6 +3432,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, · 3431 unmodified lines
34323432 err = -ENODEV;
34333433
34343434 rtnl_nets_unlock(&rtnl_nets);
3435+ rtnl_nets_destroy(&rtnl_nets);
34353436 errout:
34363437 return err;
34373438 }
net/ethtool/common.c+5−0
@@ -462,6 +462,11 @@ const char ts_rx_filter_names[][ETH_GSTRING_LEN] = { · 461 unmodified lines
462462 };
463463 static_assert(ARRAY_SIZE(ts_rx_filter_names) == __HWTSTAMP_FILTER_CNT);
464464
465+const char ts_flags_names[][ETH_GSTRING_LEN] = {
466+ [const_ilog2(HWTSTAMP_FLAG_BONDED_PHC_INDEX)] = "bonded-phc-index",
467+};
468+static_assert(ARRAY_SIZE(ts_flags_names) == __HWTSTAMP_FLAG_CNT);
469+
465470 const char udp_tunnel_type_names[][ETH_GSTRING_LEN] = {
466471 [ETHTOOL_UDP_TUNNEL_TYPE_VXLAN] = "vxlan",
467472 [ETHTOOL_UDP_TUNNEL_TYPE_GENEVE] = "geneve",
net/ethtool/common.h+2−0
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313 ETHTOOL_LINK_MODE_ ## speed ## base ## type ## _ ## duplex ## _BIT
1414
1515 #define __SOF_TIMESTAMPING_CNT (const_ilog2(SOF_TIMESTAMPING_LAST) + 1)
16+#define __HWTSTAMP_FLAG_CNT (const_ilog2(HWTSTAMP_FLAG_LAST) + 1)
1617
1718 struct link_mode_info {
1819 int speed;
@@ -38,6 +39,7 @@ extern const char wol_mode_names[][ETH_GSTRING_LEN]; · 19 unmodified lines
3839 extern const char sof_timestamping_names[][ETH_GSTRING_LEN];
3940 extern const char ts_tx_type_names[][ETH_GSTRING_LEN];
4041 extern const char ts_rx_filter_names[][ETH_GSTRING_LEN];
42+extern const char ts_flags_names[][ETH_GSTRING_LEN];
4143 extern const char udp_tunnel_type_names[][ETH_GSTRING_LEN];
4244
4345 int __ethtool_get_link(struct net_device *dev);
net/ethtool/strset.c+5−0
@@ -75,6 +75,11 @@ static const struct strset_info info_template[] = { · 74 unmodified lines
7575 .count = __HWTSTAMP_FILTER_CNT,
7676 .strings = ts_rx_filter_names,
7777 },
78+ [ETH_SS_TS_FLAGS] = {
79+ .per_dev = false,
80+ .count = __HWTSTAMP_FLAG_CNT,
81+ .strings = ts_flags_names,
82+ },
7883 [ETH_SS_UDP_TUNNEL_TYPES] = {
7984 .per_dev = false,
8085 .count = __ETHTOOL_UDP_TUNNEL_TYPE_CNT,
net/ethtool/tsconfig.c+23−10
@@ -54,7 +54,7 @@ static int tsconfig_prepare_data(const struct ethnl_req_info *req_base, · 53 unmodified lines
5454
5555 data->hwtst_config.tx_type = BIT(cfg.tx_type);
5656 data->hwtst_config.rx_filter = BIT(cfg.rx_filter);
57− data->hwtst_config.flags = BIT(cfg.flags);
57+ data->hwtst_config.flags = cfg.flags;
5858
5959 data->hwprov_desc.index = -1;
6060 hwprov = rtnl_dereference(dev->hwprov);
@@ -91,10 +91,16 @@ static int tsconfig_reply_size(const struct ethnl_req_info *req_base, · 30 unmodified lines
9191
9292 BUILD_BUG_ON(__HWTSTAMP_TX_CNT > 32);
9393 BUILD_BUG_ON(__HWTSTAMP_FILTER_CNT > 32);
94+ BUILD_BUG_ON(__HWTSTAMP_FLAG_CNT > 32);
9495
95− if (data->hwtst_config.flags)
96− /* _TSCONFIG_HWTSTAMP_FLAGS */
97− len += nla_total_size(sizeof(u32));
96+ if (data->hwtst_config.flags) {
97+ ret = ethnl_bitset32_size(&data->hwtst_config.flags,
98+ NULL, __HWTSTAMP_FLAG_CNT,
99+ ts_flags_names, compact);
100+ if (ret < 0)
101+ return ret;
102+ len += ret; /* _TSCONFIG_HWTSTAMP_FLAGS */
103+ }
98104
99105 if (data->hwtst_config.tx_type) {
100106 ret = ethnl_bitset32_size(&data->hwtst_config.tx_type,
@@ -130,8 +136,10 @@ static int tsconfig_fill_reply(struct sk_buff *skb, · 29 unmodified lines
130136 int ret;
131137
132138 if (data->hwtst_config.flags) {
133− ret = nla_put_u32(skb, ETHTOOL_A_TSCONFIG_HWTSTAMP_FLAGS,
134− data->hwtst_config.flags);
139+ ret = ethnl_put_bitset32(skb, ETHTOOL_A_TSCONFIG_HWTSTAMP_FLAGS,
140+ &data->hwtst_config.flags, NULL,
141+ __HWTSTAMP_FLAG_CNT,
142+ ts_flags_names, compact);
135143 if (ret < 0)
136144 return ret;
137145 }
@@ -180,7 +188,7 @@ const struct nla_policy ethnl_tsconfig_set_policy[ETHTOOL_A_TSCONFIG_MAX + 1] = · 42 unmodified lines
180188 [ETHTOOL_A_TSCONFIG_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy),
181189 [ETHTOOL_A_TSCONFIG_HWTSTAMP_PROVIDER] =
182190 NLA_POLICY_NESTED(ethnl_ts_hwtst_prov_policy),
183− [ETHTOOL_A_TSCONFIG_HWTSTAMP_FLAGS] = { .type = NLA_U32 },
191+ [ETHTOOL_A_TSCONFIG_HWTSTAMP_FLAGS] = { .type = NLA_NESTED },
184192 [ETHTOOL_A_TSCONFIG_RX_FILTERS] = { .type = NLA_NESTED },
185193 [ETHTOOL_A_TSCONFIG_TX_TYPES] = { .type = NLA_NESTED },
186194 };
@@ -296,6 +304,7 @@ static int ethnl_set_tsconfig(struct ethnl_req_info *req_base, · 109 unmodified lines
296304
297305 BUILD_BUG_ON(__HWTSTAMP_TX_CNT >= 32);
298306 BUILD_BUG_ON(__HWTSTAMP_FILTER_CNT >= 32);
307+ BUILD_BUG_ON(__HWTSTAMP_FLAG_CNT > 32);
299308
300309 if (!netif_device_present(dev))
301310 return -ENODEV;
@@ -377,9 +386,13 @@ static int ethnl_set_tsconfig(struct ethnl_req_info *req_base, · 75 unmodified lines
377386 }
378387
379388 if (tb[ETHTOOL_A_TSCONFIG_HWTSTAMP_FLAGS]) {
380− ethnl_update_u32(&hwtst_config.flags,
381− tb[ETHTOOL_A_TSCONFIG_HWTSTAMP_FLAGS],
382− &config_mod);
389+ ret = ethnl_update_bitset32(&hwtst_config.flags,
390+ __HWTSTAMP_FLAG_CNT,
391+ tb[ETHTOOL_A_TSCONFIG_HWTSTAMP_FLAGS],
392+ ts_flags_names, info->extack,
393+ &config_mod);
394+ if (ret < 0)
395+ goto err_free_hwprov;
383396 }
384397
385398 ret = net_hwtstamp_validate(&hwtst_config);
net/ipv4/arp.c+3−1
@@ -659,10 +659,12 @@ static int arp_xmit_finish(struct net *net, struct sock *sk, struct sk_buff *skb · 658 unmodified lines
659659 */
660660 void arp_xmit(struct sk_buff *skb)
661661 {
662+ rcu_read_lock();
662663 /* Send it off, maybe filter it using firewalling first. */
663664 NF_HOOK(NFPROTO_ARP, NF_ARP_OUT,
664− dev_net(skb->dev), NULL, skb, NULL, skb->dev,
665+ dev_net_rcu(skb->dev), NULL, skb, NULL, skb->dev,
665666 arp_xmit_finish);
667+ rcu_read_unlock();
666668 }
667669 EXPORT_SYMBOL(arp_xmit);
668670
net/ipv4/devinet.c+2−1
@@ -1371,10 +1371,11 @@ __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope) · 1370 unmodified lines
13711371 __be32 addr = 0;
13721372 unsigned char localnet_scope = RT_SCOPE_HOST;
13731373 struct in_device *in_dev;
1374− struct net *net = dev_net(dev);
1374+ struct net *net;
13751375 int master_idx;
13761376
13771377 rcu_read_lock();
1378+ net = dev_net_rcu(dev);
13781379 in_dev = __in_dev_get_rcu(dev);
13791380 if (!in_dev)
13801381 goto no_in_dev;
net/ipv4/icmp.c+17−14
@@ -399,10 +399,10 @@ static void icmp_push_reply(struct sock *sk, · 398 unmodified lines
399399
400400 static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
401401 {
402− struct ipcm_cookie ipc;
403402 struct rtable *rt = skb_rtable(skb);
404− struct net *net = dev_net(rt->dst.dev);
403+ struct net *net = dev_net_rcu(rt->dst.dev);
405404 bool apply_ratelimit = false;
405+ struct ipcm_cookie ipc;
406406 struct flowi4 fl4;
407407 struct sock *sk;
408408 struct inet_sock *inet;
@@ -608,12 +608,14 @@ void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info, · 199 unmodified lines
608608 struct sock *sk;
609609
610610 if (!rt)
611− goto out;
611+ return;
612+
613+ rcu_read_lock();
612614
613615 if (rt->dst.dev)
614− net = dev_net(rt->dst.dev);
616+ net = dev_net_rcu(rt->dst.dev);
615617 else if (skb_in->dev)
616− net = dev_net(skb_in->dev);
618+ net = dev_net_rcu(skb_in->dev);
617619 else
618620 goto out;
619621
@@ -785,7 +787,8 @@ out_unlock: · 165 unmodified lines
785787 icmp_xmit_unlock(sk);
786788 out_bh_enable:
787789 local_bh_enable();
788−out:;
790+out:
791+ rcu_read_unlock();
789792 }
790793 EXPORT_SYMBOL(__icmp_send);
791794
@@ -834,7 +837,7 @@ static void icmp_socket_deliver(struct sk_buff *skb, u32 info) · 42 unmodified lines
834837 * avoid additional coding at protocol handlers.
835838 */
836839 if (!pskb_may_pull(skb, iph->ihl * 4 + 8)) {
837− __ICMP_INC_STATS(dev_net(skb->dev), ICMP_MIB_INERRORS);
840+ __ICMP_INC_STATS(dev_net_rcu(skb->dev), ICMP_MIB_INERRORS);
838841 return;
839842 }
840843
@@ -868,7 +871,7 @@ static enum skb_drop_reason icmp_unreach(struct sk_buff *skb) · 27 unmodified lines
868871 struct net *net;
869872 u32 info = 0;
870873
871− net = dev_net(skb_dst(skb)->dev);
874+ net = dev_net_rcu(skb_dst(skb)->dev);
872875
873876 /*
874877 * Incomplete header ?
@@ -979,7 +982,7 @@ out_err: · 104 unmodified lines
979982 static enum skb_drop_reason icmp_redirect(struct sk_buff *skb)
980983 {
981984 if (skb->len < sizeof(struct iphdr)) {
982− __ICMP_INC_STATS(dev_net(skb->dev), ICMP_MIB_INERRORS);
985+ __ICMP_INC_STATS(dev_net_rcu(skb->dev), ICMP_MIB_INERRORS);
983986 return SKB_DROP_REASON_PKT_TOO_SMALL;
984987 }
985988
@@ -1011,7 +1014,7 @@ static enum skb_drop_reason icmp_echo(struct sk_buff *skb) · 25 unmodified lines
10111014 struct icmp_bxm icmp_param;
10121015 struct net *net;
10131016
1014− net = dev_net(skb_dst(skb)->dev);
1017+ net = dev_net_rcu(skb_dst(skb)->dev);
10151018 /* should there be an ICMP stat for ignored echos? */
10161019 if (READ_ONCE(net->ipv4.sysctl_icmp_echo_ignore_all))
10171020 return SKB_NOT_DROPPED_YET;
@@ -1040,9 +1043,9 @@ static enum skb_drop_reason icmp_echo(struct sk_buff *skb) · 22 unmodified lines
10401043
10411044 bool icmp_build_probe(struct sk_buff *skb, struct icmphdr *icmphdr)
10421045 {
1046+ struct net *net = dev_net_rcu(skb->dev);
10431047 struct icmp_ext_hdr *ext_hdr, _ext_hdr;
10441048 struct icmp_ext_echo_iio *iio, _iio;
1045− struct net *net = dev_net(skb->dev);
10461049 struct inet6_dev *in6_dev;
10471050 struct in_device *in_dev;
10481051 struct net_device *dev;
@@ -1181,7 +1184,7 @@ static enum skb_drop_reason icmp_timestamp(struct sk_buff *skb) · 132 unmodified lines
11811184 return SKB_NOT_DROPPED_YET;
11821185
11831186 out_err:
1184− __ICMP_INC_STATS(dev_net(skb_dst(skb)->dev), ICMP_MIB_INERRORS);
1187+ __ICMP_INC_STATS(dev_net_rcu(skb_dst(skb)->dev), ICMP_MIB_INERRORS);
11851188 return SKB_DROP_REASON_PKT_TOO_SMALL;
11861189 }
11871190
@@ -1198,7 +1201,7 @@ int icmp_rcv(struct sk_buff *skb) · 10 unmodified lines
11981201 {
11991202 enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
12001203 struct rtable *rt = skb_rtable(skb);
1201− struct net *net = dev_net(rt->dst.dev);
1204+ struct net *net = dev_net_rcu(rt->dst.dev);
12021205 struct icmphdr *icmph;
12031206
12041207 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
@@ -1371,9 +1374,9 @@ int icmp_err(struct sk_buff *skb, u32 info) · 166 unmodified lines
13711374 struct iphdr *iph = (struct iphdr *)skb->data;
13721375 int offset = iph->ihl<<2;
13731376 struct icmphdr *icmph = (struct icmphdr *)(skb->data + offset);
1377+ struct net *net = dev_net_rcu(skb->dev);
13741378 int type = icmp_hdr(skb)->type;
13751379 int code = icmp_hdr(skb)->code;
1376− struct net *net = dev_net(skb->dev);
13771380
13781381 /*
13791382 * Use ping_err to handle all icmp errors except those
net/ipv4/route.c+21−9
@@ -390,7 +390,13 @@ static inline int ip_rt_proc_init(void) · 389 unmodified lines
390390
391391 static inline bool rt_is_expired(const struct rtable *rth)
392392 {
393− return rth->rt_genid != rt_genid_ipv4(dev_net(rth->dst.dev));
393+ bool res;
394+
395+ rcu_read_lock();
396+ res = rth->rt_genid != rt_genid_ipv4(dev_net_rcu(rth->dst.dev));
397+ rcu_read_unlock();
398+
399+ return res;
394400 }
395401
396402 void rt_cache_flush(struct net *net)
@@ -1002,9 +1008,9 @@ out: kfree_skb_reason(skb, reason); · 605 unmodified lines
10021008 static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
10031009 {
10041010 struct dst_entry *dst = &rt->dst;
1005− struct net *net = dev_net(dst->dev);
10061011 struct fib_result res;
10071012 bool lock = false;
1013+ struct net *net;
10081014 u32 old_mtu;
10091015
10101016 if (ip_mtu_locked(dst))
@@ -1014,6 +1020,8 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) · 3 unmodified lines
10141020 if (old_mtu < mtu)
10151021 return;
10161022
1023+ rcu_read_lock();
1024+ net = dev_net_rcu(dst->dev);
10171025 if (mtu < net->ipv4.ip_rt_min_pmtu) {
10181026 lock = true;
10191027 mtu = min(old_mtu, net->ipv4.ip_rt_min_pmtu);
@@ -1021,9 +1029,8 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) · 1 unmodified line
10211029
10221030 if (rt->rt_pmtu == mtu && !lock &&
10231031 time_before(jiffies, dst->expires - net->ipv4.ip_rt_mtu_expires / 2))
1024− return;
1032+ goto out;
10251033
1026− rcu_read_lock();
10271034 if (fib_lookup(net, fl4, &res, 0) == 0) {
10281035 struct fib_nh_common *nhc;
10291036
@@ -1037,14 +1044,14 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) · 7 unmodified lines
10371044 update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
10381045 jiffies + net->ipv4.ip_rt_mtu_expires);
10391046 }
1040− rcu_read_unlock();
1041− return;
1047+ goto out;
10421048 }
10431049 #endif /* CONFIG_IP_ROUTE_MULTIPATH */
10441050 nhc = FIB_RES_NHC(res);
10451051 update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
10461052 jiffies + net->ipv4.ip_rt_mtu_expires);
10471053 }
1054+out:
10481055 rcu_read_unlock();
10491056 }
10501057
@@ -1307,10 +1314,15 @@ static void set_class_tag(struct rtable *rt, u32 tag) · 256 unmodified lines
13071314
13081315 static unsigned int ipv4_default_advmss(const struct dst_entry *dst)
13091316 {
1310− struct net *net = dev_net(dst->dev);
13111317 unsigned int header_size = sizeof(struct tcphdr) + sizeof(struct iphdr);
1312− unsigned int advmss = max_t(unsigned int, ipv4_mtu(dst) - header_size,
1313− net->ipv4.ip_rt_min_advmss);
1318+ unsigned int advmss;
1319+ struct net *net;
1320+
1321+ rcu_read_lock();
1322+ net = dev_net_rcu(dst->dev);
1323+ advmss = max_t(unsigned int, ipv4_mtu(dst) - header_size,
1324+ net->ipv4.ip_rt_min_advmss);
1325+ rcu_read_unlock();
13141326
13151327 return min(advmss, IPV4_MAX_PMTU - header_size);
13161328 }
net/ipv6/icmp.c+23−19
@@ -76,7 +76,7 @@ static int icmpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, · 75 unmodified lines
7676 {
7777 /* icmpv6_notify checks 8 bytes can be pulled, icmp6hdr is 8 bytes */
7878 struct icmp6hdr *icmp6 = (struct icmp6hdr *) (skb->data + offset);
79− struct net *net = dev_net(skb->dev);
79+ struct net *net = dev_net_rcu(skb->dev);
8080
8181 if (type == ICMPV6_PKT_TOOBIG)
8282 ip6_update_pmtu(skb, net, info, skb->dev->ifindex, 0, sock_net_uid(net, NULL));
@@ -473,7 +473,10 @@ void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, · 390 unmodified lines
473473
474474 if (!skb->dev)
475475 return;
476− net = dev_net(skb->dev);
476+
477+ rcu_read_lock();
478+
479+ net = dev_net_rcu(skb->dev);
477480 mark = IP6_REPLY_MARK(net, skb->mark);
478481 /*
479482 * Make sure we respect the rules
@@ -496,7 +499,7 @@ void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, · 16 unmodified lines
496499 !(type == ICMPV6_PARAMPROB &&
497500 code == ICMPV6_UNK_OPTION &&
498501 (opt_unrec(skb, info))))
499− return;
502+ goto out;
500503
501504 saddr = NULL;
502505 }
@@ -526,7 +529,7 @@ void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, · 23 unmodified lines
526529 if ((addr_type == IPV6_ADDR_ANY) || (addr_type & IPV6_ADDR_MULTICAST)) {
527530 net_dbg_ratelimited("icmp6_send: addr_any/mcast source [%pI6c > %pI6c]\n",
528531 &hdr->saddr, &hdr->daddr);
529− return;
532+ goto out;
530533 }
531534
532535 /*
@@ -535,7 +538,7 @@ void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, · 2 unmodified lines
535538 if (is_ineligible(skb)) {
536539 net_dbg_ratelimited("icmp6_send: no reply to icmp error [%pI6c > %pI6c]\n",
537540 &hdr->saddr, &hdr->daddr);
538− return;
541+ goto out;
539542 }
540543
541544 /* Needed by both icmpv6_global_allow and icmpv6_xmit_lock */
@@ -582,7 +585,7 @@ void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, · 40 unmodified lines
582585 np = inet6_sk(sk);
583586
584587 if (!icmpv6_xrlim_allow(sk, type, &fl6, apply_ratelimit))
585− goto out;
588+ goto out_unlock;
586589
587590 tmp_hdr.icmp6_type = type;
588591 tmp_hdr.icmp6_code = code;
@@ -600,7 +603,7 @@ void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, · 11 unmodified lines
600603
601604 dst = icmpv6_route_lookup(net, skb, sk, &fl6);
602605 if (IS_ERR(dst))
603− goto out;
606+ goto out_unlock;
604607
605608 ipc6.hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst);
606609
@@ -616,7 +619,6 @@ void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, · 9 unmodified lines
616619 goto out_dst_release;
617620 }
618621
619− rcu_read_lock();
620622 idev = __in6_dev_get(skb->dev);
621623
622624 if (ip6_append_data(sk, icmpv6_getfrag, &msg,
@@ -630,13 +632,15 @@ void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, · 7 unmodified lines
630632 icmpv6_push_pending_frames(sk, &fl6, &tmp_hdr,
631633 len + sizeof(struct icmp6hdr));
632634 }
633− rcu_read_unlock();
635+
634636 out_dst_release:
635637 dst_release(dst);
636−out:
638+out_unlock:
637639 icmpv6_xmit_unlock(sk);
638640 out_bh_enable:
639641 local_bh_enable();
642+out:
643+ rcu_read_unlock();
640644 }
641645 EXPORT_SYMBOL(icmp6_send);
642646
@@ -679,8 +683,8 @@ int ip6_err_gen_icmpv6_unreach(struct sk_buff *skb, int nhs, int type, · 36 unmodified lines
679683 skb_pull(skb2, nhs);
680684 skb_reset_network_header(skb2);
681685
682− rt = rt6_lookup(dev_net(skb->dev), &ipv6_hdr(skb2)->saddr, NULL, 0,
683− skb, 0);
686+ rt = rt6_lookup(dev_net_rcu(skb->dev), &ipv6_hdr(skb2)->saddr,
687+ NULL, 0, skb, 0);
684688
685689 if (rt && rt->dst.dev)
686690 skb2->dev = rt->dst.dev;
@@ -717,7 +721,7 @@ EXPORT_SYMBOL(ip6_err_gen_icmpv6_unreach); · 30 unmodified lines
717721
718722 static enum skb_drop_reason icmpv6_echo_reply(struct sk_buff *skb)
719723 {
720− struct net *net = dev_net(skb->dev);
724+ struct net *net = dev_net_rcu(skb->dev);
721725 struct sock *sk;
722726 struct inet6_dev *idev;
723727 struct ipv6_pinfo *np;
@@ -832,7 +836,7 @@ enum skb_drop_reason icmpv6_notify(struct sk_buff *skb, u8 type, · 108 unmodified lines
832836 u8 code, __be32 info)
833837 {
834838 struct inet6_skb_parm *opt = IP6CB(skb);
835− struct net *net = dev_net(skb->dev);
839+ struct net *net = dev_net_rcu(skb->dev);
836840 const struct inet6_protocol *ipprot;
837841 enum skb_drop_reason reason;
838842 int inner_offset;
@@ -889,7 +893,7 @@ out: · 50 unmodified lines
889893 static int icmpv6_rcv(struct sk_buff *skb)
890894 {
891895 enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
892− struct net *net = dev_net(skb->dev);
896+ struct net *net = dev_net_rcu(skb->dev);
893897 struct net_device *dev = icmp6_dev(skb);
894898 struct inet6_dev *idev = __in6_dev_get(dev);
895899 const struct in6_addr *saddr, *daddr;
@@ -921,7 +925,7 @@ static int icmpv6_rcv(struct sk_buff *skb) · 25 unmodified lines
921925 skb_set_network_header(skb, nh);
922926 }
923927
924− __ICMP6_INC_STATS(dev_net(dev), idev, ICMP6_MIB_INMSGS);
928+ __ICMP6_INC_STATS(dev_net_rcu(dev), idev, ICMP6_MIB_INMSGS);
925929
926930 saddr = &ipv6_hdr(skb)->saddr;
927931 daddr = &ipv6_hdr(skb)->daddr;
@@ -939,7 +943,7 @@ static int icmpv6_rcv(struct sk_buff *skb) · 11 unmodified lines
939943
940944 type = hdr->icmp6_type;
941945
942− ICMP6MSGIN_INC_STATS(dev_net(dev), idev, type);
946+ ICMP6MSGIN_INC_STATS(dev_net_rcu(dev), idev, type);
943947
944948 switch (type) {
945949 case ICMPV6_ECHO_REQUEST:
@@ -1034,9 +1038,9 @@ static int icmpv6_rcv(struct sk_buff *skb) · 88 unmodified lines
10341038
10351039 csum_error:
10361040 reason = SKB_DROP_REASON_ICMP_CSUM;
1037− __ICMP6_INC_STATS(dev_net(dev), idev, ICMP6_MIB_CSUMERRORS);
1041+ __ICMP6_INC_STATS(dev_net_rcu(dev), idev, ICMP6_MIB_CSUMERRORS);
10381042 discard_it:
1039− __ICMP6_INC_STATS(dev_net(dev), idev, ICMP6_MIB_INERRORS);
1043+ __ICMP6_INC_STATS(dev_net_rcu(dev), idev, ICMP6_MIB_INERRORS);
10401044 drop_no_count:
10411045 kfree_skb_reason(skb, reason);
10421046 return 0;
net/ipv6/ip6_input.c+9−5
@@ -477,9 +477,7 @@ discard: · 476 unmodified lines
477477 static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
478478 {
479479 skb_clear_delivery_time(skb);
480− rcu_read_lock();
481480 ip6_protocol_deliver_rcu(net, skb, 0, false);
482− rcu_read_unlock();
483481
484482 return 0;
485483 }
@@ -487,9 +485,15 @@ static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *sk · 1 unmodified line
487485
488486 int ip6_input(struct sk_buff *skb)
489487 {
490− return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_IN,
491− dev_net(skb->dev), NULL, skb, skb->dev, NULL,
492− ip6_input_finish);
488+ int res;
489+
490+ rcu_read_lock();
491+ res = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_IN,
492+ dev_net_rcu(skb->dev), NULL, skb, skb->dev, NULL,
493+ ip6_input_finish);
494+ rcu_read_unlock();
495+
496+ return res;
493497 }
494498 EXPORT_SYMBOL_GPL(ip6_input);
495499
net/ipv6/mcast.c+25−20
@@ -1773,21 +1773,19 @@ static struct sk_buff *mld_newpack(struct inet6_dev *idev, unsigned int mtu) · 1772 unmodified lines
17731773 struct net_device *dev = idev->dev;
17741774 int hlen = LL_RESERVED_SPACE(dev);
17751775 int tlen = dev->needed_tailroom;
1776− struct net *net = dev_net(dev);
17771776 const struct in6_addr *saddr;
17781777 struct in6_addr addr_buf;
17791778 struct mld2_report *pmr;
17801779 struct sk_buff *skb;
17811780 unsigned int size;
17821781 struct sock *sk;
1783− int err;
1782+ struct net *net;
17841783
1785− sk = net->ipv6.igmp_sk;
17861784 /* we assume size > sizeof(ra) here
17871785 * Also try to not allocate high-order pages for big MTU
17881786 */
17891787 size = min_t(int, mtu, PAGE_SIZE / 2) + hlen + tlen;
1790− skb = sock_alloc_send_skb(sk, size, 1, &err);
1788+ skb = alloc_skb(size, GFP_KERNEL);
17911789 if (!skb)
17921790 return NULL;
17931791
@@ -1795,6 +1793,12 @@ static struct sk_buff *mld_newpack(struct inet6_dev *idev, unsigned int mtu) · 1 unmodified line
17951793 skb_reserve(skb, hlen);
17961794 skb_tailroom_reserve(skb, mtu, tlen);
17971795
1796+ rcu_read_lock();
1797+
1798+ net = dev_net_rcu(dev);
1799+ sk = net->ipv6.igmp_sk;
1800+ skb_set_owner_w(skb, sk);
1801+
17981802 if (ipv6_get_lladdr(dev, &addr_buf, IFA_F_TENTATIVE)) {
17991803 /* <draft-ietf-magma-mld-source-05.txt>:
18001804 * use unspecified address as the source address
@@ -1806,6 +1810,8 @@ static struct sk_buff *mld_newpack(struct inet6_dev *idev, unsigned int mtu) · 5 unmodified lines
18061810
18071811 ip6_mc_hdr(sk, skb, dev, saddr, &mld2_all_mcr, NEXTHDR_HOP, 0);
18081812
1813+ rcu_read_unlock();
1814+
18091815 skb_put_data(skb, ra, sizeof(ra));
18101816
18111817 skb_set_transport_header(skb, skb_tail_pointer(skb) - skb->data);
@@ -2165,21 +2171,21 @@ static void mld_send_cr(struct inet6_dev *idev) · 353 unmodified lines
21652171
21662172 static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
21672173 {
2168− struct net *net = dev_net(dev);
2169− struct sock *sk = net->ipv6.igmp_sk;
2174+ const struct in6_addr *snd_addr, *saddr;
2175+ int err, len, payload_len, full_len;
2176+ struct in6_addr addr_buf;
21702177 struct inet6_dev *idev;
21712178 struct sk_buff *skb;
21722179 struct mld_msg *hdr;
2173− const struct in6_addr *snd_addr, *saddr;
2174− struct in6_addr addr_buf;
21752180 int hlen = LL_RESERVED_SPACE(dev);
21762181 int tlen = dev->needed_tailroom;
2177− int err, len, payload_len, full_len;
21782182 u8 ra[8] = { IPPROTO_ICMPV6, 0,
21792183 IPV6_TLV_ROUTERALERT, 2, 0, 0,
21802184 IPV6_TLV_PADN, 0 };
2181− struct flowi6 fl6;
21822185 struct dst_entry *dst;
2186+ struct flowi6 fl6;
2187+ struct net *net;
2188+ struct sock *sk;
21832189
21842190 if (type == ICMPV6_MGM_REDUCTION)
21852191 snd_addr = &in6addr_linklocal_allrouters;
@@ -2190,19 +2196,21 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type) · 4 unmodified lines
21902196 payload_len = len + sizeof(ra);
21912197 full_len = sizeof(struct ipv6hdr) + payload_len;
21922198
2193− rcu_read_lock();
2194− IP6_INC_STATS(net, __in6_dev_get(dev), IPSTATS_MIB_OUTREQUESTS);
2195− rcu_read_unlock();
2199+ skb = alloc_skb(hlen + tlen + full_len, GFP_KERNEL);
21962200
2197− skb = sock_alloc_send_skb(sk, hlen + tlen + full_len, 1, &err);
2201+ rcu_read_lock();
21982202
2203+ net = dev_net_rcu(dev);
2204+ idev = __in6_dev_get(dev);
2205+ IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTREQUESTS);
21992206 if (!skb) {
2200− rcu_read_lock();
2201− IP6_INC_STATS(net, __in6_dev_get(dev),
2202− IPSTATS_MIB_OUTDISCARDS);
2207+ IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS);
22032208 rcu_read_unlock();
22042209 return;
22052210 }
2211+ sk = net->ipv6.igmp_sk;
2212+ skb_set_owner_w(skb, sk);
2213+
22062214 skb->priority = TC_PRIO_CONTROL;
22072215 skb_reserve(skb, hlen);
22082216
@@ -2227,9 +2235,6 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type) · 18 unmodified lines
22272235 IPPROTO_ICMPV6,
22282236 csum_partial(hdr, len, 0));
22292237
2230− rcu_read_lock();
2231− idev = __in6_dev_get(skb->dev);
2232−
22332238 icmpv6_flow_init(sk, &fl6, type,
22342239 &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr,
22352240 skb->dev->ifindex);
net/ipv6/ndisc.c+13−11
@@ -418,15 +418,11 @@ static struct sk_buff *ndisc_alloc_skb(struct net_device *dev, · 417 unmodified lines
418418 {
419419 int hlen = LL_RESERVED_SPACE(dev);
420420 int tlen = dev->needed_tailroom;
421− struct sock *sk = dev_net(dev)->ipv6.ndisc_sk;
422421 struct sk_buff *skb;
423422
424423 skb = alloc_skb(hlen + sizeof(struct ipv6hdr) + len + tlen, GFP_ATOMIC);
425− if (!skb) {
426− ND_PRINTK(0, err, "ndisc: %s failed to allocate an skb\n",
427− __func__);
424+ if (!skb)
428425 return NULL;
429− }
430426
431427 skb->protocol = htons(ETH_P_IPV6);
432428 skb->dev = dev;
@@ -437,7 +433,9 @@ static struct sk_buff *ndisc_alloc_skb(struct net_device *dev, · 4 unmodified lines
437433 /* Manually assign socket ownership as we avoid calling
438434 * sock_alloc_send_pskb() to bypass wmem buffer limits
439435 */
440− skb_set_owner_w(skb, sk);
436+ rcu_read_lock();
437+ skb_set_owner_w(skb, dev_net_rcu(dev)->ipv6.ndisc_sk);
438+ rcu_read_unlock();
441439
442440 return skb;
443441 }
@@ -473,16 +471,20 @@ static void ip6_nd_hdr(struct sk_buff *skb, · 29 unmodified lines
473471 void ndisc_send_skb(struct sk_buff *skb, const struct in6_addr *daddr,
474472 const struct in6_addr *saddr)
475473 {
474+ struct icmp6hdr *icmp6h = icmp6_hdr(skb);
476475 struct dst_entry *dst = skb_dst(skb);
477− struct net *net = dev_net(skb->dev);
478− struct sock *sk = net->ipv6.ndisc_sk;
479476 struct inet6_dev *idev;
477+ struct net *net;
478+ struct sock *sk;
480479 int err;
481− struct icmp6hdr *icmp6h = icmp6_hdr(skb);
482480 u8 type;
483481
484482 type = icmp6h->icmp6_type;
485483
484+ rcu_read_lock();
485+
486+ net = dev_net_rcu(skb->dev);
487+ sk = net->ipv6.ndisc_sk;
486488 if (!dst) {
487489 struct flowi6 fl6;
488490 int oif = skb->dev->ifindex;
@@ -490,6 +492,7 @@ void ndisc_send_skb(struct sk_buff *skb, const struct in6_addr *daddr, · 1 unmodified line
490492 icmpv6_flow_init(sk, &fl6, type, saddr, daddr, oif);
491493 dst = icmp6_dst_alloc(skb->dev, &fl6);
492494 if (IS_ERR(dst)) {
495+ rcu_read_unlock();
493496 kfree_skb(skb);
494497 return;
495498 }
@@ -504,7 +507,6 @@ void ndisc_send_skb(struct sk_buff *skb, const struct in6_addr *daddr, · 8 unmodified lines
504507
505508 ip6_nd_hdr(skb, saddr, daddr, READ_ONCE(inet6_sk(sk)->hop_limit), skb->len);
506509
507− rcu_read_lock();
508510 idev = __in6_dev_get(dst->dev);
509511 IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTREQUESTS);
510512
@@ -1694,7 +1696,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) · 1183 unmodified lines
16941696 bool ret;
16951697
16961698 if (netif_is_l3_master(skb->dev)) {
1697− dev = __dev_get_by_index(dev_net(skb->dev), IPCB(skb)->iif);
1699+ dev = dev_get_by_index_rcu(dev_net(skb->dev), IPCB(skb)->iif);
16981700 if (!dev)
16991701 return;
17001702 }
net/ipv6/route.c+6−1
@@ -3196,13 +3196,18 @@ static unsigned int ip6_default_advmss(const struct dst_entry *dst) · 3195 unmodified lines
31963196 {
31973197 struct net_device *dev = dst->dev;
31983198 unsigned int mtu = dst_mtu(dst);
3199− struct net *net = dev_net(dev);
3199+ struct net *net;
32003200
32013201 mtu -= sizeof(struct ipv6hdr) + sizeof(struct tcphdr);
32023202
3203+ rcu_read_lock();
3204+
3205+ net = dev_net_rcu(dev);
32033206 if (mtu < net->ipv6.sysctl.ip6_rt_min_advmss)
32043207 mtu = net->ipv6.sysctl.ip6_rt_min_advmss;
32053208
3209+ rcu_read_unlock();
3210+
32063211 /*
32073212 * Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and
32083213 * corresponding MSS is IPV6_MAXPLEN - tcp_header_size.
net/netfilter/nf_flow_table_ip.c+2−6
@@ -381,10 +381,8 @@ static int nf_flow_offload_forward(struct nf_flowtable_ctx *ctx, · 380 unmodified lines
381381 flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]);
382382
383383 mtu = flow->tuplehash[dir].tuple.mtu + ctx->offset;
384− if (unlikely(nf_flow_exceeds_mtu(skb, mtu))) {
385− flow_offload_teardown(flow);
384+ if (unlikely(nf_flow_exceeds_mtu(skb, mtu)))
386385 return 0;
387− }
388386
389387 iph = (struct iphdr *)(skb_network_header(skb) + ctx->offset);
390388 thoff = (iph->ihl * 4) + ctx->offset;
@@ -662,10 +660,8 @@ static int nf_flow_offload_ipv6_forward(struct nf_flowtable_ctx *ctx, · 271 unmodified lines
662660 flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]);
663661
664662 mtu = flow->tuplehash[dir].tuple.mtu + ctx->offset;
665− if (unlikely(nf_flow_exceeds_mtu(skb, mtu))) {
666− flow_offload_teardown(flow);
663+ if (unlikely(nf_flow_exceeds_mtu(skb, mtu)))
667664 return 0;
668− }
669665
670666 ip6h = (struct ipv6hdr *)(skb_network_header(skb) + ctx->offset);
671667 thoff = sizeof(*ip6h) + ctx->offset;
net/openvswitch/datapath.c+9−3
@@ -2101,6 +2101,7 @@ static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb, · 2100 unmodified lines
21012101 {
21022102 struct ovs_header *ovs_header;
21032103 struct ovs_vport_stats vport_stats;
2104+ struct net *net_vport;
21042105 int err;
21052106
21062107 ovs_header = genlmsg_put(skb, portid, seq, &dp_vport_genl_family,
@@ -2117,12 +2118,15 @@ static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb, · 10 unmodified lines
21172118 nla_put_u32(skb, OVS_VPORT_ATTR_IFINDEX, vport->dev->ifindex))
21182119 goto nla_put_failure;
21192120
2120− if (!net_eq(net, dev_net(vport->dev))) {
2121− int id = peernet2id_alloc(net, dev_net(vport->dev), gfp);
2121+ rcu_read_lock();
2122+ net_vport = dev_net_rcu(vport->dev);
2123+ if (!net_eq(net, net_vport)) {
2124+ int id = peernet2id_alloc(net, net_vport, GFP_ATOMIC);
21222125
21232126 if (nla_put_s32(skb, OVS_VPORT_ATTR_NETNSID, id))
2124− goto nla_put_failure;
2127+ goto nla_put_failure_unlock;
21252128 }
2129+ rcu_read_unlock();
21262130
21272131 ovs_vport_get_stats(vport, &vport_stats);
21282132 if (nla_put_64bit(skb, OVS_VPORT_ATTR_STATS,
@@ -2143,6 +2147,8 @@ static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb, · 14 unmodified lines
21432147 genlmsg_end(skb, ovs_header);
21442148 return 0;
21452149
2150+nla_put_failure_unlock:
2151+ rcu_read_unlock();
21462152 nla_put_failure:
21472153 err = -EMSGSIZE;
21482154 error:
net/rxrpc/ar-internal.h+3−4
@@ -327,8 +327,8 @@ struct rxrpc_local { · 326 unmodified lines
327327 * packet with a maximum set of jumbo subpackets or a PING ACK padded
328328 * out to 64K with zeropages for PMTUD.
329329 */
330− struct kvec kvec[RXRPC_MAX_NR_JUMBO > 3 + 16 ?
331− RXRPC_MAX_NR_JUMBO : 3 + 16];
330+ struct kvec kvec[1 + RXRPC_MAX_NR_JUMBO > 3 + 16 ?
331+ 1 + RXRPC_MAX_NR_JUMBO : 3 + 16];
332332 };
333333
334334 /*
@@ -874,8 +874,7 @@ struct rxrpc_txbuf { · 539 unmodified lines
874874 #define RXRPC_TXBUF_RESENT 0x100 /* Set if has been resent */
875875 __be16 cksum; /* Checksum to go in header */
876876 bool jumboable; /* Can be non-terminal jumbo subpacket */
877− u8 nr_kvec; /* Amount of kvec[] used */
878− struct kvec kvec[1];
877+ void *data; /* Data with preceding jumbo header */
879878 };
880879
881880 static inline bool rxrpc_sending_to_server(const struct rxrpc_txbuf *txb)
net/rxrpc/output.c+35−15
@@ -428,13 +428,13 @@ int rxrpc_send_abort_packet(struct rxrpc_call *call) · 427 unmodified lines
428428 static size_t rxrpc_prepare_data_subpacket(struct rxrpc_call *call,
429429 struct rxrpc_send_data_req *req,
430430 struct rxrpc_txbuf *txb,
431+ struct rxrpc_wire_header *whdr,
431432 rxrpc_serial_t serial, int subpkt)
432433 {
433− struct rxrpc_wire_header *whdr = txb->kvec[0].iov_base;
434− struct rxrpc_jumbo_header *jumbo = (void *)(whdr + 1) - sizeof(*jumbo);
434+ struct rxrpc_jumbo_header *jumbo = txb->data - sizeof(*jumbo);
435435 enum rxrpc_req_ack_trace why;
436436 struct rxrpc_connection *conn = call->conn;
437− struct kvec *kv = &call->local->kvec[subpkt];
437+ struct kvec *kv = &call->local->kvec[1 + subpkt];
438438 size_t len = txb->pkt_len;
439439 bool last;
440440 u8 flags;
@@ -491,18 +491,15 @@ static size_t rxrpc_prepare_data_subpacket(struct rxrpc_call *call, · 50 unmodified lines
491491 }
492492 dont_set_request_ack:
493493
494− /* The jumbo header overlays the wire header in the txbuf. */
494+ /* There's a jumbo header prepended to the data if we need it. */
495495 if (subpkt < req->n - 1)
496496 flags |= RXRPC_JUMBO_PACKET;
497497 else
498498 flags &= ~RXRPC_JUMBO_PACKET;
499499 if (subpkt == 0) {
500500 whdr->flags = flags;
501− whdr->serial = htonl(txb->serial);
502501 whdr->cksum = txb->cksum;
503− whdr->serviceId = htons(conn->service_id);
504− kv->iov_base = whdr;
505− len += sizeof(*whdr);
502+ kv->iov_base = txb->data;
506503 } else {
507504 jumbo->flags = flags;
508505 jumbo->pad = 0;
@@ -535,7 +532,9 @@ static unsigned int rxrpc_prepare_txqueue(struct rxrpc_txqueue *tq, · 26 unmodified lines
535532 /*
536533 * Prepare a (jumbo) packet for transmission.
537534 */
538−static size_t rxrpc_prepare_data_packet(struct rxrpc_call *call, struct rxrpc_send_data_req *req)
535+static size_t rxrpc_prepare_data_packet(struct rxrpc_call *call,
536+ struct rxrpc_send_data_req *req,
537+ struct rxrpc_wire_header *whdr)
539538 {
540539 struct rxrpc_txqueue *tq = req->tq;
541540 rxrpc_serial_t serial;
@@ -549,6 +548,18 @@ static size_t rxrpc_prepare_data_packet(struct rxrpc_call *call, struct rxrpc_se · 7 unmodified lines
549548 /* Each transmission of a Tx packet needs a new serial number */
550549 serial = rxrpc_get_next_serials(call->conn, req->n);
551550
551+ whdr->epoch = htonl(call->conn->proto.epoch);
552+ whdr->cid = htonl(call->cid);
553+ whdr->callNumber = htonl(call->call_id);
554+ whdr->seq = htonl(seq);
555+ whdr->serial = htonl(serial);
556+ whdr->type = RXRPC_PACKET_TYPE_DATA;
557+ whdr->flags = 0;
558+ whdr->userStatus = 0;
559+ whdr->securityIndex = call->security_ix;
560+ whdr->_rsvd = 0;
561+ whdr->serviceId = htons(call->conn->service_id);
562+
552563 call->tx_last_serial = serial + req->n - 1;
553564 call->tx_last_sent = req->now;
554565 xmit_ts = rxrpc_prepare_txqueue(tq, req);
@@ -576,7 +587,7 @@ static size_t rxrpc_prepare_data_packet(struct rxrpc_call *call, struct rxrpc_se · 21 unmodified lines
576587 if (i + 1 == req->n)
577588 /* Only sample the last subpacket in a jumbo. */
578589 __set_bit(ix, &tq->rtt_samples);
579− len += rxrpc_prepare_data_subpacket(call, req, txb, serial, i);
590+ len += rxrpc_prepare_data_subpacket(call, req, txb, whdr, serial, i);
580591 serial++;
581592 seq++;
582593 i++;
@@ -618,6 +629,7 @@ static size_t rxrpc_prepare_data_packet(struct rxrpc_call *call, struct rxrpc_se · 35 unmodified lines
618629 }
619630
620631 rxrpc_set_keepalive(call, req->now);
632+ page_frag_free(whdr);
621633 return len;
622634 }
623635
@@ -626,25 +638,33 @@ static size_t rxrpc_prepare_data_packet(struct rxrpc_call *call, struct rxrpc_se · 2 unmodified lines
626638 */
627639 void rxrpc_send_data_packet(struct rxrpc_call *call, struct rxrpc_send_data_req *req)
628640 {
641+ struct rxrpc_wire_header *whdr;
629642 struct rxrpc_connection *conn = call->conn;
630643 enum rxrpc_tx_point frag;
631644 struct rxrpc_txqueue *tq = req->tq;
632645 struct rxrpc_txbuf *txb;
633646 struct msghdr msg;
634647 rxrpc_seq_t seq = req->seq;
635− size_t len;
648+ size_t len = sizeof(*whdr);
636649 bool new_call = test_bit(RXRPC_CALL_BEGAN_RX_TIMER, &call->flags);
637650 int ret, stat_ix;
638651
639652 _enter("%x,%x-%x", tq->qbase, seq, seq + req->n - 1);
640653
654+ whdr = page_frag_alloc(&call->local->tx_alloc, sizeof(*whdr), GFP_NOFS);
655+ if (!whdr)
656+ return; /* Drop the packet if no memory. */
657+
658+ call->local->kvec[0].iov_base = whdr;
659+ call->local->kvec[0].iov_len = sizeof(*whdr);
660+
641661 stat_ix = umin(req->n, ARRAY_SIZE(call->rxnet->stat_tx_jumbo)) - 1;
642662 atomic_inc(&call->rxnet->stat_tx_jumbo[stat_ix]);
643663
644− len = rxrpc_prepare_data_packet(call, req);
664+ len += rxrpc_prepare_data_packet(call, req, whdr);
645665 txb = tq->bufs[seq & RXRPC_TXQ_MASK];
646666
647− iov_iter_kvec(&msg.msg_iter, WRITE, call->local->kvec, req->n, len);
667+ iov_iter_kvec(&msg.msg_iter, WRITE, call->local->kvec, 1 + req->n, len);
648668
649669 msg.msg_name = &call->peer->srx.transport;
650670 msg.msg_namelen = call->peer->srx.transport_len;
@@ -695,13 +715,13 @@ void rxrpc_send_data_packet(struct rxrpc_call *call, struct rxrpc_send_data_req · 44 unmodified lines
695715
696716 if (ret == -EMSGSIZE) {
697717 rxrpc_inc_stat(call->rxnet, stat_tx_data_send_msgsize);
698− trace_rxrpc_tx_packet(call->debug_id, call->local->kvec[0].iov_base, frag);
718+ trace_rxrpc_tx_packet(call->debug_id, whdr, frag);
699719 ret = 0;
700720 } else if (ret < 0) {
701721 rxrpc_inc_stat(call->rxnet, stat_tx_data_send_fail);
702722 trace_rxrpc_tx_fail(call->debug_id, txb->serial, ret, frag);
703723 } else {
704− trace_rxrpc_tx_packet(call->debug_id, call->local->kvec[0].iov_base, frag);
724+ trace_rxrpc_tx_packet(call->debug_id, whdr, frag);
705725 }
706726
707727 rxrpc_tx_backoff(call, ret);
net/rxrpc/peer_event.c+7−0
@@ -169,6 +169,13 @@ void rxrpc_input_error(struct rxrpc_local *local, struct sk_buff *skb) · 168 unmodified lines
169169 goto out;
170170 }
171171
172+ if ((serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6 &&
173+ serr->ee.ee_type == ICMPV6_PKT_TOOBIG &&
174+ serr->ee.ee_code == 0)) {
175+ rxrpc_adjust_mtu(peer, serr->ee.ee_info);
176+ goto out;
177+ }
178+
172179 rxrpc_store_error(peer, skb);
173180 out:
174181 rxrpc_put_peer(peer, rxrpc_peer_put_input_error);
net/rxrpc/rxkad.c+5−8
@@ -257,8 +257,7 @@ static int rxkad_secure_packet_auth(const struct rxrpc_call *call, · 256 unmodified lines
257257 struct rxrpc_txbuf *txb,
258258 struct skcipher_request *req)
259259 {
260− struct rxrpc_wire_header *whdr = txb->kvec[0].iov_base;
261− struct rxkad_level1_hdr *hdr = (void *)(whdr + 1);
260+ struct rxkad_level1_hdr *hdr = txb->data;
262261 struct rxrpc_crypt iv;
263262 struct scatterlist sg;
264263 size_t pad;
@@ -274,7 +273,7 @@ static int rxkad_secure_packet_auth(const struct rxrpc_call *call, · 9 unmodified lines
274273 pad = RXKAD_ALIGN - pad;
275274 pad &= RXKAD_ALIGN - 1;
276275 if (pad) {
277− memset(txb->kvec[0].iov_base + txb->offset, 0, pad);
276+ memset(txb->data + txb->offset, 0, pad);
278277 txb->pkt_len += pad;
279278 }
280279
@@ -300,8 +299,7 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call, · 19 unmodified lines
300299 struct skcipher_request *req)
301300 {
302301 const struct rxrpc_key_token *token;
303− struct rxrpc_wire_header *whdr = txb->kvec[0].iov_base;
304− struct rxkad_level2_hdr *rxkhdr = (void *)(whdr + 1);
302+ struct rxkad_level2_hdr *rxkhdr = txb->data;
305303 struct rxrpc_crypt iv;
306304 struct scatterlist sg;
307305 size_t content, pad;
@@ -319,7 +317,7 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call, · 11 unmodified lines
319317 txb->pkt_len = round_up(content, RXKAD_ALIGN);
320318 pad = txb->pkt_len - content;
321319 if (pad)
322− memset(txb->kvec[0].iov_base + txb->offset, 0, pad);
320+ memset(txb->data + txb->offset, 0, pad);
323321
324322 /* encrypt from the session key */
325323 token = call->conn->key->payload.data[0];
@@ -407,9 +405,8 @@ static int rxkad_secure_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb) · 81 unmodified lines
407405
408406 /* Clear excess space in the packet */
409407 if (txb->pkt_len < txb->alloc_size) {
410− struct rxrpc_wire_header *whdr = txb->kvec[0].iov_base;
411408 size_t gap = txb->alloc_size - txb->pkt_len;
412− void *p = whdr + 1;
409+ void *p = txb->data;
413410
414411 memset(p + txb->pkt_len, 0, gap);
415412 }
net/rxrpc/sendmsg.c+1−3
@@ -419,7 +419,7 @@ reload: · 418 unmodified lines
419419 size_t copy = umin(txb->space, msg_data_left(msg));
420420
421421 _debug("add %zu", copy);
422− if (!copy_from_iter_full(txb->kvec[0].iov_base + txb->offset,
422+ if (!copy_from_iter_full(txb->data + txb->offset,
423423 copy, &msg->msg_iter))
424424 goto efault;
425425 _debug("added");
@@ -445,8 +445,6 @@ reload: · 19 unmodified lines
445445 ret = call->security->secure_packet(call, txb);
446446 if (ret < 0)
447447 goto out;
448−
449− txb->kvec[0].iov_len += txb->len;
450448 rxrpc_queue_packet(rx, call, txb, notify_end_tx);
451449 txb = NULL;
452450 }
net/rxrpc/txbuf.c+10−27
@@ -19,17 +19,19 @@ atomic_t rxrpc_nr_txbuf; · 18 unmodified lines
1919 struct rxrpc_txbuf *rxrpc_alloc_data_txbuf(struct rxrpc_call *call, size_t data_size,
2020 size_t data_align, gfp_t gfp)
2121 {
22− struct rxrpc_wire_header *whdr;
2322 struct rxrpc_txbuf *txb;
24− size_t total, hoff;
23+ size_t total, doff, jsize = sizeof(struct rxrpc_jumbo_header);
2524 void *buf;
2625
2726 txb = kzalloc(sizeof(*txb), gfp);
2827 if (!txb)
2928 return NULL;
3029
31− hoff = round_up(sizeof(*whdr), data_align) - sizeof(*whdr);
32− total = hoff + sizeof(*whdr) + data_size;
30+ /* We put a jumbo header in the buffer, but not a full wire header to
31+ * avoid delayed-corruption problems with zerocopy.
32+ */
33+ doff = round_up(jsize, data_align);
34+ total = doff + data_size;
3335
3436 data_align = umax(data_align, L1_CACHE_BYTES);
3537 mutex_lock(&call->conn->tx_data_alloc_lock);
@@ -41,30 +43,15 @@ struct rxrpc_txbuf *rxrpc_alloc_data_txbuf(struct rxrpc_call *call, size_t data_ · 5 unmodified lines
4143 return NULL;
4244 }
4345
44− whdr = buf + hoff;
45−
4646 refcount_set(&txb->ref, 1);
4747 txb->call_debug_id = call->debug_id;
4848 txb->debug_id = atomic_inc_return(&rxrpc_txbuf_debug_ids);
4949 txb->alloc_size = data_size;
5050 txb->space = data_size;
51− txb->offset = sizeof(*whdr);
51+ txb->offset = 0;
5252 txb->flags = call->conn->out_clientflag;
5353 txb->seq = call->send_top + 1;
54− txb->nr_kvec = 1;
55− txb->kvec[0].iov_base = whdr;
56− txb->kvec[0].iov_len = sizeof(*whdr);
57−
58− whdr->epoch = htonl(call->conn->proto.epoch);
59− whdr->cid = htonl(call->cid);
60− whdr->callNumber = htonl(call->call_id);
61− whdr->seq = htonl(txb->seq);
62− whdr->type = RXRPC_PACKET_TYPE_DATA;
63− whdr->flags = 0;
64− whdr->userStatus = 0;
65− whdr->securityIndex = call->security_ix;
66− whdr->_rsvd = 0;
67− whdr->serviceId = htons(call->dest_srx.srx_service);
54+ txb->data = buf + doff;
6855
6956 trace_rxrpc_txbuf(txb->debug_id, txb->call_debug_id, txb->seq, 1,
7057 rxrpc_txbuf_alloc_data);
@@ -90,14 +77,10 @@ void rxrpc_see_txbuf(struct rxrpc_txbuf *txb, enum rxrpc_txbuf_trace what) · 19 unmodified lines
9077
9178 static void rxrpc_free_txbuf(struct rxrpc_txbuf *txb)
9279 {
93− int i;
94−
9580 trace_rxrpc_txbuf(txb->debug_id, txb->call_debug_id, txb->seq, 0,
9681 rxrpc_txbuf_free);
97− for (i = 0; i < txb->nr_kvec; i++)
98− if (txb->kvec[i].iov_base &&
99− !is_zero_pfn(page_to_pfn(virt_to_page(txb->kvec[i].iov_base))))
100− page_frag_free(txb->kvec[i].iov_base);
82+ if (txb->data)
83+ page_frag_free(txb->data);
10184 kfree(txb);
10285 atomic_dec(&rxrpc_nr_txbuf);
10386 }
net/vmw_vsock/af_vsock.c+7−1
@@ -824,13 +824,19 @@ static void __vsock_release(struct sock *sk, int level) · 823 unmodified lines
824824 */
825825 lock_sock_nested(sk, level);
826826
827− sock_orphan(sk);
827+ /* Indicate to vsock_remove_sock() that the socket is being released and
828+ * can be removed from the bound_table. Unlike transport reassignment
829+ * case, where the socket must remain bound despite vsock_remove_sock()
830+ * being called from the transport release() callback.
831+ */
832+ sock_set_flag(sk, SOCK_DEAD);
828833
829834 if (vsk->transport)
830835 vsk->transport->release(vsk);
831836 else if (sock_type_connectible(sk->sk_type))
832837 vsock_remove_sock(vsk);
833838
839+ sock_orphan(sk);
834840 sk->sk_shutdown = SHUTDOWN_MASK;
835841
836842 skb_queue_purge(&sk->sk_receive_queue);
tools/testing/vsock/vsock_test.c+41−0
@@ -1788,6 +1788,42 @@ static void test_stream_connect_retry_server(const struct test_opts *opts) · 1787 unmodified lines
17881788 close(fd);
17891789 }
17901790
1791+static void test_stream_linger_client(const struct test_opts *opts)
1792+{
1793+ struct linger optval = {
1794+ .l_onoff = 1,
1795+ .l_linger = 1
1796+ };
1797+ int fd;
1798+
1799+ fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
1800+ if (fd < 0) {
1801+ perror("connect");
1802+ exit(EXIT_FAILURE);
1803+ }
1804+
1805+ if (setsockopt(fd, SOL_SOCKET, SO_LINGER, &optval, sizeof(optval))) {
1806+ perror("setsockopt(SO_LINGER)");
1807+ exit(EXIT_FAILURE);
1808+ }
1809+
1810+ close(fd);
1811+}
1812+
1813+static void test_stream_linger_server(const struct test_opts *opts)
1814+{
1815+ int fd;
1816+
1817+ fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
1818+ if (fd < 0) {
1819+ perror("accept");
1820+ exit(EXIT_FAILURE);
1821+ }
1822+
1823+ vsock_wait_remote_close(fd);
1824+ close(fd);
1825+}
1826+
17911827 static struct test_case test_cases[] = {
17921828 {
17931829 .name = "SOCK_STREAM connection reset",
@@ -1943,6 +1979,11 @@ static struct test_case test_cases[] = { · 149 unmodified lines
19431979 .run_client = test_stream_connect_retry_client,
19441980 .run_server = test_stream_connect_retry_server,
19451981 },
1982+ {
1983+ .name = "SOCK_STREAM SO_LINGER null-ptr-deref",
1984+ .run_client = test_stream_linger_client,
1985+ .run_server = test_stream_linger_server,
1986+ },
19461987 {},
19471988 };
19481989