Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Pull networking fixes from Paolo Abeni:
"Including fixes from bpf and wifi.

Current release - regressions:

- neighbour: fix __randomize_layout crash in struct neighbour

- r8169: fix deadlock on RTL8125 in jumbo mtu mode

Previous releases - regressions:

- wifi:
- mac80211: fix warning at station removal time
- cfg80211: fix CQM for non-range use

- tools: ynl-gen: fix unexpected response handling

- octeontx2-af: fix possible buffer overflow

- dpaa2: recycle the RX buffer only after all processing done

- rswitch: fix missing dev_kfree_skb_any() in error path

Previous releases - always broken:

- ipv4: fix uaf issue when receiving igmp query packet

- wifi: mac80211: fix debugfs deadlock at device removal time

- bpf:
- sockmap: af_unix stream sockets need to hold ref for pair sock
- netdevsim: don't accept device bound programs

- selftests: fix a char signedness issue

- dsa: mv88e6xxx: fix marvell 6350 probe crash

- octeontx2-pf: restore TC ingress police rules when interface is up

- wangxun: fix memory leak on msix entry

- ravb: keep reverse order of operations in ravb_remove()"

* tag 'net-6.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (51 commits)
net: ravb: Keep reverse order of operations in ravb_remove()
net: ravb: Stop DMA in case of failures on ravb_open()
net: ravb: Start TX queues after HW initialization succeeded
net: ravb: Make write access to CXR35 first before accessing other EMAC registers
net: ravb: Use pm_runtime_resume_and_get()
net: ravb: Check return value of reset_control_deassert()
net: libwx: fix memory leak on msix entry
ice: Fix VF Reset paths when interface in a failed over aggregate
bpf, sockmap: Add af_unix test with both sockets in map
bpf, sockmap: af_unix stream sockets need to hold ref for pair sock
tools: ynl-gen: always construct struct ynl_req_state
ethtool: don't propagate EOPNOTSUPP from dumps
ravb: Fix races between ravb_tx_timeout_work() and net related ops
r8169: prevent potential deadlock in rtl8169_close
r8169: fix deadlock on RTL8125 in jumbo mtu mode
neighbour: Fix __randomize_layout crash in struct neighbour
octeontx2-pf: Restore TC ingress police rules when interface is up
octeontx2-pf: Fix adding mbox work queue entry when num_vfs > 64
net: stmmac: xgmac: Disable FPE MMC interrupts
octeontx2-af: Fix possible buffer overflow
...

+1131 -340
+20 -6
drivers/net/dsa/mv88e6xxx/chip.c
··· 577 577 config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100; 578 578 } 579 579 580 + static void mv88e6351_phylink_get_caps(struct mv88e6xxx_chip *chip, int port, 581 + struct phylink_config *config) 582 + { 583 + unsigned long *supported = config->supported_interfaces; 584 + 585 + /* Translate the default cmode */ 586 + mv88e6xxx_translate_cmode(chip->ports[port].cmode, supported); 587 + 588 + config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | 589 + MAC_1000FD; 590 + } 591 + 580 592 static int mv88e6352_get_port4_serdes_cmode(struct mv88e6xxx_chip *chip) 581 593 { 582 594 u16 reg, val; ··· 3892 3880 struct mv88e6xxx_chip *chip = ds->priv; 3893 3881 int err; 3894 3882 3895 - if (chip->info->ops->pcs_ops->pcs_init) { 3883 + if (chip->info->ops->pcs_ops && 3884 + chip->info->ops->pcs_ops->pcs_init) { 3896 3885 err = chip->info->ops->pcs_ops->pcs_init(chip, port); 3897 3886 if (err) 3898 3887 return err; ··· 3908 3895 3909 3896 mv88e6xxx_teardown_devlink_regions_port(ds, port); 3910 3897 3911 - if (chip->info->ops->pcs_ops->pcs_teardown) 3898 + if (chip->info->ops->pcs_ops && 3899 + chip->info->ops->pcs_ops->pcs_teardown) 3912 3900 chip->info->ops->pcs_ops->pcs_teardown(chip, port); 3913 3901 } 3914 3902 ··· 4354 4340 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, 4355 4341 .stu_getnext = mv88e6352_g1_stu_getnext, 4356 4342 .stu_loadpurge = mv88e6352_g1_stu_loadpurge, 4357 - .phylink_get_caps = mv88e6185_phylink_get_caps, 4343 + .phylink_get_caps = mv88e6351_phylink_get_caps, 4358 4344 }; 4359 4345 4360 4346 static const struct mv88e6xxx_ops mv88e6172_ops = { ··· 4454 4440 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, 4455 4441 .stu_getnext = mv88e6352_g1_stu_getnext, 4456 4442 .stu_loadpurge = mv88e6352_g1_stu_loadpurge, 4457 - .phylink_get_caps = mv88e6185_phylink_get_caps, 4443 + .phylink_get_caps = mv88e6351_phylink_get_caps, 4458 4444 }; 4459 4445 4460 4446 static const struct mv88e6xxx_ops mv88e6176_ops = { ··· 5083 5069 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, 5084 5070 .stu_getnext = mv88e6352_g1_stu_getnext, 5085 5071 .stu_loadpurge = mv88e6352_g1_stu_loadpurge, 5086 - .phylink_get_caps = mv88e6185_phylink_get_caps, 5072 + .phylink_get_caps = mv88e6351_phylink_get_caps, 5087 5073 }; 5088 5074 5089 5075 static const struct mv88e6xxx_ops mv88e6351_ops = { ··· 5131 5117 .stu_loadpurge = mv88e6352_g1_stu_loadpurge, 5132 5118 .avb_ops = &mv88e6352_avb_ops, 5133 5119 .ptp_ops = &mv88e6352_ptp_ops, 5134 - .phylink_get_caps = mv88e6185_phylink_get_caps, 5120 + .phylink_get_caps = mv88e6351_phylink_get_caps, 5135 5121 }; 5136 5122 5137 5123 static const struct mv88e6xxx_ops mv88e6352_ops = {
+10 -6
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
··· 516 516 517 517 memcpy(skb->data, fd_vaddr + fd_offset, fd_length); 518 518 519 - dpaa2_eth_recycle_buf(priv, ch, dpaa2_fd_get_addr(fd)); 520 - 521 519 return skb; 522 520 } 523 521 ··· 587 589 struct rtnl_link_stats64 *percpu_stats; 588 590 struct dpaa2_eth_drv_stats *percpu_extras; 589 591 struct device *dev = priv->net_dev->dev.parent; 592 + bool recycle_rx_buf = false; 590 593 void *buf_data; 591 594 u32 xdp_act; 592 595 ··· 617 618 dma_unmap_page(dev, addr, priv->rx_buf_size, 618 619 DMA_BIDIRECTIONAL); 619 620 skb = dpaa2_eth_build_linear_skb(ch, fd, vaddr); 621 + } else { 622 + recycle_rx_buf = true; 620 623 } 621 624 } else if (fd_format == dpaa2_fd_sg) { 622 625 WARN_ON(priv->xdp_prog); ··· 638 637 goto err_build_skb; 639 638 640 639 dpaa2_eth_receive_skb(priv, ch, fd, vaddr, fq, percpu_stats, skb); 640 + 641 + if (recycle_rx_buf) 642 + dpaa2_eth_recycle_buf(priv, ch, dpaa2_fd_get_addr(fd)); 641 643 return; 642 644 643 645 err_build_skb: ··· 1077 1073 dma_addr_t addr; 1078 1074 1079 1075 buffer_start = skb->data - dpaa2_eth_needed_headroom(skb); 1080 - 1081 - /* If there's enough room to align the FD address, do it. 1082 - * It will help hardware optimize accesses. 1083 - */ 1084 1076 aligned_start = PTR_ALIGN(buffer_start - DPAA2_ETH_TX_BUF_ALIGN, 1085 1077 DPAA2_ETH_TX_BUF_ALIGN); 1086 1078 if (aligned_start >= skb->head) 1087 1079 buffer_start = aligned_start; 1080 + else 1081 + return -ENOMEM; 1088 1082 1089 1083 /* Store a backpointer to the skb at the beginning of the buffer 1090 1084 * (in the private data area) such that we can release it ··· 4968 4966 err = dpaa2_eth_dl_port_add(priv); 4969 4967 if (err) 4970 4968 goto err_dl_port_add; 4969 + 4970 + net_dev->needed_headroom = DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN; 4971 4971 4972 4972 err = register_netdev(net_dev); 4973 4973 if (err < 0) {
+1 -1
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
··· 740 740 741 741 static inline unsigned int dpaa2_eth_needed_headroom(struct sk_buff *skb) 742 742 { 743 - unsigned int headroom = DPAA2_ETH_SWA_SIZE; 743 + unsigned int headroom = DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN; 744 744 745 745 /* If we don't have an skb (e.g. XDP buffer), we only need space for 746 746 * the software annotation area
+72 -50
drivers/net/ethernet/intel/ice/ice_lag.c
··· 570 570 } 571 571 572 572 /** 573 + * ice_lag_build_netdev_list - populate the lag struct's netdev list 574 + * @lag: local lag struct 575 + * @ndlist: pointer to netdev list to populate 576 + */ 577 + static void ice_lag_build_netdev_list(struct ice_lag *lag, 578 + struct ice_lag_netdev_list *ndlist) 579 + { 580 + struct ice_lag_netdev_list *nl; 581 + struct net_device *tmp_nd; 582 + 583 + INIT_LIST_HEAD(&ndlist->node); 584 + rcu_read_lock(); 585 + for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) { 586 + nl = kzalloc(sizeof(*nl), GFP_ATOMIC); 587 + if (!nl) 588 + break; 589 + 590 + nl->netdev = tmp_nd; 591 + list_add(&nl->node, &ndlist->node); 592 + } 593 + rcu_read_unlock(); 594 + lag->netdev_head = &ndlist->node; 595 + } 596 + 597 + /** 598 + * ice_lag_destroy_netdev_list - free lag struct's netdev list 599 + * @lag: pointer to local lag struct 600 + * @ndlist: pointer to lag struct netdev list 601 + */ 602 + static void ice_lag_destroy_netdev_list(struct ice_lag *lag, 603 + struct ice_lag_netdev_list *ndlist) 604 + { 605 + struct ice_lag_netdev_list *entry, *n; 606 + 607 + rcu_read_lock(); 608 + list_for_each_entry_safe(entry, n, &ndlist->node, node) { 609 + list_del(&entry->node); 610 + kfree(entry); 611 + } 612 + rcu_read_unlock(); 613 + lag->netdev_head = NULL; 614 + } 615 + 616 + /** 573 617 * ice_lag_move_single_vf_nodes - Move Tx scheduling nodes for single VF 574 618 * @lag: primary interface LAG struct 575 619 * @oldport: lport of previous interface ··· 641 597 void ice_lag_move_new_vf_nodes(struct ice_vf *vf) 642 598 { 643 599 struct ice_lag_netdev_list ndlist; 644 - struct list_head *tmp, *n; 645 600 u8 pri_port, act_port; 646 601 struct ice_lag *lag; 647 602 struct ice_vsi *vsi; ··· 664 621 pri_port = pf->hw.port_info->lport; 665 622 act_port = lag->active_port; 666 623 667 - if (lag->upper_netdev) { 668 - struct ice_lag_netdev_list *nl; 669 - struct net_device *tmp_nd; 670 - 671 - INIT_LIST_HEAD(&ndlist.node); 672 - rcu_read_lock(); 673 - for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) { 674 - nl = kzalloc(sizeof(*nl), GFP_ATOMIC); 675 - if (!nl) 676 - break; 677 - 678 - nl->netdev = tmp_nd; 679 - list_add(&nl->node, &ndlist.node); 680 - } 681 - rcu_read_unlock(); 682 - } 683 - 684 - lag->netdev_head = &ndlist.node; 624 + if (lag->upper_netdev) 625 + ice_lag_build_netdev_list(lag, &ndlist); 685 626 686 627 if (ice_is_feature_supported(pf, ICE_F_SRIOV_LAG) && 687 628 lag->bonded && lag->primary && pri_port != act_port && 688 629 !list_empty(lag->netdev_head)) 689 630 ice_lag_move_single_vf_nodes(lag, pri_port, act_port, vsi->idx); 690 631 691 - list_for_each_safe(tmp, n, &ndlist.node) { 692 - struct ice_lag_netdev_list *entry; 693 - 694 - entry = list_entry(tmp, struct ice_lag_netdev_list, node); 695 - list_del(&entry->node); 696 - kfree(entry); 697 - } 698 - lag->netdev_head = NULL; 632 + ice_lag_destroy_netdev_list(lag, &ndlist); 699 633 700 634 new_vf_unlock: 701 635 mutex_unlock(&pf->lag_mutex); ··· 697 677 if (pf->vsi[i] && (pf->vsi[i]->type == ICE_VSI_VF || 698 678 pf->vsi[i]->type == ICE_VSI_SWITCHDEV_CTRL)) 699 679 ice_lag_move_single_vf_nodes(lag, oldport, newport, i); 680 + } 681 + 682 + /** 683 + * ice_lag_move_vf_nodes_cfg - move vf nodes outside LAG netdev event context 684 + * @lag: local lag struct 685 + * @src_prt: lport value for source port 686 + * @dst_prt: lport value for destination port 687 + * 688 + * This function is used to move nodes during an out-of-netdev-event situation, 689 + * primarily when the driver needs to reconfigure or recreate resources. 690 + * 691 + * Must be called while holding the lag_mutex to avoid lag events from 692 + * processing while out-of-sync moves are happening. Also, paired moves, 693 + * such as used in a reset flow, should both be called under the same mutex 694 + * lock to avoid changes between start of reset and end of reset. 695 + */ 696 + void ice_lag_move_vf_nodes_cfg(struct ice_lag *lag, u8 src_prt, u8 dst_prt) 697 + { 698 + struct ice_lag_netdev_list ndlist; 699 + 700 + ice_lag_build_netdev_list(lag, &ndlist); 701 + ice_lag_move_vf_nodes(lag, src_prt, dst_prt); 702 + ice_lag_destroy_netdev_list(lag, &ndlist); 700 703 } 701 704 702 705 #define ICE_LAG_SRIOV_CP_RECIPE 10 ··· 2094 2051 { 2095 2052 struct ice_lag_netdev_list ndlist; 2096 2053 struct ice_lag *lag, *prim_lag; 2097 - struct list_head *tmp, *n; 2098 2054 u8 act_port, loc_port; 2099 2055 2100 2056 if (!pf->lag || !pf->lag->bonded) ··· 2105 2063 if (lag->primary) { 2106 2064 prim_lag = lag; 2107 2065 } else { 2108 - struct ice_lag_netdev_list *nl; 2109 - struct net_device *tmp_nd; 2110 - 2111 - INIT_LIST_HEAD(&ndlist.node); 2112 - rcu_read_lock(); 2113 - for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) { 2114 - nl = kzalloc(sizeof(*nl), GFP_ATOMIC); 2115 - if (!nl) 2116 - break; 2117 - 2118 - nl->netdev = tmp_nd; 2119 - list_add(&nl->node, &ndlist.node); 2120 - } 2121 - rcu_read_unlock(); 2122 - lag->netdev_head = &ndlist.node; 2066 + ice_lag_build_netdev_list(lag, &ndlist); 2123 2067 prim_lag = ice_lag_find_primary(lag); 2124 2068 } 2125 2069 ··· 2135 2107 2136 2108 ice_clear_rdma_cap(pf); 2137 2109 lag_rebuild_out: 2138 - list_for_each_safe(tmp, n, &ndlist.node) { 2139 - struct ice_lag_netdev_list *entry; 2140 - 2141 - entry = list_entry(tmp, struct ice_lag_netdev_list, node); 2142 - list_del(&entry->node); 2143 - kfree(entry); 2144 - } 2110 + ice_lag_destroy_netdev_list(lag, &ndlist); 2145 2111 mutex_unlock(&pf->lag_mutex); 2146 2112 } 2147 2113
+1
drivers/net/ethernet/intel/ice/ice_lag.h
··· 65 65 void ice_deinit_lag(struct ice_pf *pf); 66 66 void ice_lag_rebuild(struct ice_pf *pf); 67 67 bool ice_lag_is_switchdev_running(struct ice_pf *pf); 68 + void ice_lag_move_vf_nodes_cfg(struct ice_lag *lag, u8 src_prt, u8 dst_prt); 68 69 #endif /* _ICE_LAG_H_ */
+20
drivers/net/ethernet/intel/ice/ice_vf_lib.c
··· 829 829 int ice_reset_vf(struct ice_vf *vf, u32 flags) 830 830 { 831 831 struct ice_pf *pf = vf->pf; 832 + struct ice_lag *lag; 832 833 struct ice_vsi *vsi; 834 + u8 act_prt, pri_prt; 833 835 struct device *dev; 834 836 int err = 0; 835 837 bool rsd; 836 838 837 839 dev = ice_pf_to_dev(pf); 840 + act_prt = ICE_LAG_INVALID_PORT; 841 + pri_prt = pf->hw.port_info->lport; 838 842 839 843 if (flags & ICE_VF_RESET_NOTIFY) 840 844 ice_notify_vf_reset(vf); ··· 847 843 dev_dbg(dev, "Trying to reset VF %d, but all VF resets are disabled\n", 848 844 vf->vf_id); 849 845 return 0; 846 + } 847 + 848 + lag = pf->lag; 849 + mutex_lock(&pf->lag_mutex); 850 + if (lag && lag->bonded && lag->primary) { 851 + act_prt = lag->active_port; 852 + if (act_prt != pri_prt && act_prt != ICE_LAG_INVALID_PORT && 853 + lag->upper_netdev) 854 + ice_lag_move_vf_nodes_cfg(lag, act_prt, pri_prt); 855 + else 856 + act_prt = ICE_LAG_INVALID_PORT; 850 857 } 851 858 852 859 if (flags & ICE_VF_RESET_LOCK) ··· 951 936 out_unlock: 952 937 if (flags & ICE_VF_RESET_LOCK) 953 938 mutex_unlock(&vf->cfg_lock); 939 + 940 + if (lag && lag->bonded && lag->primary && 941 + act_prt != ICE_LAG_INVALID_PORT) 942 + ice_lag_move_vf_nodes_cfg(lag, pri_prt, act_prt); 943 + mutex_unlock(&pf->lag_mutex); 954 944 955 945 return err; 956 946 }
+25
drivers/net/ethernet/intel/ice/ice_virtchnl.c
··· 1603 1603 (struct virtchnl_vsi_queue_config_info *)msg; 1604 1604 struct virtchnl_queue_pair_info *qpi; 1605 1605 struct ice_pf *pf = vf->pf; 1606 + struct ice_lag *lag; 1606 1607 struct ice_vsi *vsi; 1608 + u8 act_prt, pri_prt; 1607 1609 int i = -1, q_idx; 1610 + 1611 + lag = pf->lag; 1612 + mutex_lock(&pf->lag_mutex); 1613 + act_prt = ICE_LAG_INVALID_PORT; 1614 + pri_prt = pf->hw.port_info->lport; 1615 + if (lag && lag->bonded && lag->primary) { 1616 + act_prt = lag->active_port; 1617 + if (act_prt != pri_prt && act_prt != ICE_LAG_INVALID_PORT && 1618 + lag->upper_netdev) 1619 + ice_lag_move_vf_nodes_cfg(lag, act_prt, pri_prt); 1620 + else 1621 + act_prt = ICE_LAG_INVALID_PORT; 1622 + } 1608 1623 1609 1624 if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) 1610 1625 goto error_param; ··· 1744 1729 } 1745 1730 } 1746 1731 1732 + if (lag && lag->bonded && lag->primary && 1733 + act_prt != ICE_LAG_INVALID_PORT) 1734 + ice_lag_move_vf_nodes_cfg(lag, pri_prt, act_prt); 1735 + mutex_unlock(&pf->lag_mutex); 1736 + 1747 1737 /* send the response to the VF */ 1748 1738 return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES, 1749 1739 VIRTCHNL_STATUS_SUCCESS, NULL, 0); ··· 1762 1742 dev_err(ice_pf_to_dev(pf), "VF-%d could not disable TX queue %d\n", 1763 1743 vf->vf_id, i); 1764 1744 } 1745 + 1746 + if (lag && lag->bonded && lag->primary && 1747 + act_prt != ICE_LAG_INVALID_PORT) 1748 + ice_lag_move_vf_nodes_cfg(lag, pri_prt, act_prt); 1749 + mutex_unlock(&pf->lag_mutex); 1765 1750 1766 1751 ice_lag_move_new_vf_nodes(vf); 1767 1752
+2 -2
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
··· 5505 5505 5506 5506 ipolicer = &nix_hw->ipolicer[layer]; 5507 5507 for (idx = 0; idx < req->prof_count[layer]; idx++) { 5508 + if (idx == MAX_BANDPROF_PER_PFFUNC) 5509 + break; 5508 5510 prof_idx = req->prof_idx[layer][idx]; 5509 5511 if (prof_idx >= ipolicer->band_prof.max || 5510 5512 ipolicer->pfvf_map[prof_idx] != pcifunc) ··· 5520 5518 ipolicer->pfvf_map[prof_idx] = 0x00; 5521 5519 ipolicer->match_id[prof_idx] = 0; 5522 5520 rvu_free_rsrc(&ipolicer->band_prof, prof_idx); 5523 - if (idx == MAX_BANDPROF_PER_PFFUNC) 5524 - break; 5525 5521 } 5526 5522 } 5527 5523 mutex_unlock(&rvu->rsrc_lock);
+3
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c
··· 450 450 aq->prof.pebs_mantissa = 0; 451 451 aq->prof_mask.pebs_mantissa = 0xFF; 452 452 453 + aq->prof.hl_en = 0; 454 + aq->prof_mask.hl_en = 1; 455 + 453 456 /* Fill AQ info */ 454 457 aq->qidx = profile; 455 458 aq->ctype = NIX_AQ_CTYPE_BANDPROF;
+2
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
··· 1070 1070 void otx2_shutdown_tc(struct otx2_nic *nic); 1071 1071 int otx2_setup_tc(struct net_device *netdev, enum tc_setup_type type, 1072 1072 void *type_data); 1073 + void otx2_tc_apply_ingress_police_rules(struct otx2_nic *nic); 1074 + 1073 1075 /* CGX/RPM DMAC filters support */ 1074 1076 int otx2_dmacflt_get_max_cnt(struct otx2_nic *pf); 1075 1077 int otx2_dmacflt_add(struct otx2_nic *pf, const u8 *mac, u32 bit_pos);
+7 -2
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
··· 566 566 otx2_write64(pf, RVU_PF_VFPF_MBOX_INTX(1), intr); 567 567 otx2_queue_work(mbox, pf->mbox_pfvf_wq, 64, vfs, intr, 568 568 TYPE_PFVF); 569 - vfs -= 64; 569 + if (intr) 570 + trace_otx2_msg_interrupt(mbox->mbox.pdev, "VF(s) to PF", intr); 571 + vfs = 64; 570 572 } 571 573 572 574 intr = otx2_read64(pf, RVU_PF_VFPF_MBOX_INTX(0)); ··· 576 574 577 575 otx2_queue_work(mbox, pf->mbox_pfvf_wq, 0, vfs, intr, TYPE_PFVF); 578 576 579 - trace_otx2_msg_interrupt(mbox->mbox.pdev, "VF(s) to PF", intr); 577 + if (intr) 578 + trace_otx2_msg_interrupt(mbox->mbox.pdev, "VF(s) to PF", intr); 580 579 581 580 return IRQ_HANDLED; 582 581 } ··· 1872 1869 /* Install DMAC Filters */ 1873 1870 if (pf->flags & OTX2_FLAG_DMACFLTR_SUPPORT) 1874 1871 otx2_dmacflt_reinstall_flows(pf); 1872 + 1873 + otx2_tc_apply_ingress_police_rules(pf); 1875 1874 1876 1875 err = otx2_rxtx_enable(pf, true); 1877 1876 /* If a mbox communication error happens at this point then interface
+98 -28
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
··· 47 47 bool is_act_police; 48 48 u32 prio; 49 49 struct npc_install_flow_req req; 50 + u64 rate; 51 + u32 burst; 52 + bool is_pps; 50 53 }; 51 54 52 55 static void otx2_get_egress_burst_cfg(struct otx2_nic *nic, u32 burst, ··· 287 284 return err; 288 285 } 289 286 287 + static int otx2_tc_act_set_hw_police(struct otx2_nic *nic, 288 + struct otx2_tc_flow *node) 289 + { 290 + int rc; 291 + 292 + mutex_lock(&nic->mbox.lock); 293 + 294 + rc = cn10k_alloc_leaf_profile(nic, &node->leaf_profile); 295 + if (rc) { 296 + mutex_unlock(&nic->mbox.lock); 297 + return rc; 298 + } 299 + 300 + rc = cn10k_set_ipolicer_rate(nic, node->leaf_profile, 301 + node->burst, node->rate, node->is_pps); 302 + if (rc) 303 + goto free_leaf; 304 + 305 + rc = cn10k_map_unmap_rq_policer(nic, node->rq, node->leaf_profile, true); 306 + if (rc) 307 + goto free_leaf; 308 + 309 + mutex_unlock(&nic->mbox.lock); 310 + 311 + return 0; 312 + 313 + free_leaf: 314 + if (cn10k_free_leaf_profile(nic, node->leaf_profile)) 315 + netdev_err(nic->netdev, 316 + "Unable to free leaf bandwidth profile(%d)\n", 317 + node->leaf_profile); 318 + mutex_unlock(&nic->mbox.lock); 319 + return rc; 320 + } 321 + 290 322 static int otx2_tc_act_set_police(struct otx2_nic *nic, 291 323 struct otx2_tc_flow *node, 292 324 struct flow_cls_offload *f, ··· 338 300 return -EINVAL; 339 301 } 340 302 341 - mutex_lock(&nic->mbox.lock); 342 - 343 - rc = cn10k_alloc_leaf_profile(nic, &node->leaf_profile); 344 - if (rc) { 345 - mutex_unlock(&nic->mbox.lock); 346 - return rc; 347 - } 348 - 349 - rc = cn10k_set_ipolicer_rate(nic, node->leaf_profile, burst, rate, pps); 350 - if (rc) 351 - goto free_leaf; 352 - 353 - rc = cn10k_map_unmap_rq_policer(nic, rq_idx, node->leaf_profile, true); 354 - if (rc) 355 - goto free_leaf; 356 - 357 - mutex_unlock(&nic->mbox.lock); 358 - 359 303 req->match_id = mark & 0xFFFFULL; 360 304 req->index = rq_idx; 361 305 req->op = NIX_RX_ACTIONOP_UCAST; 362 - set_bit(rq_idx, &nic->rq_bmap); 306 + 363 307 node->is_act_police = true; 364 308 node->rq = rq_idx; 309 + node->burst = burst; 310 + node->rate = rate; 311 + node->is_pps = pps; 365 312 366 - return 0; 313 + rc = otx2_tc_act_set_hw_police(nic, node); 314 + if (!rc) 315 + set_bit(rq_idx, &nic->rq_bmap); 367 316 368 - free_leaf: 369 - if (cn10k_free_leaf_profile(nic, node->leaf_profile)) 370 - netdev_err(nic->netdev, 371 - "Unable to free leaf bandwidth profile(%d)\n", 372 - node->leaf_profile); 373 - mutex_unlock(&nic->mbox.lock); 374 317 return rc; 375 318 } 376 319 ··· 1063 1044 } 1064 1045 1065 1046 if (flow_node->is_act_police) { 1047 + __clear_bit(flow_node->rq, &nic->rq_bmap); 1048 + 1049 + if (nic->flags & OTX2_FLAG_INTF_DOWN) 1050 + goto free_mcam_flow; 1051 + 1066 1052 mutex_lock(&nic->mbox.lock); 1067 1053 1068 1054 err = cn10k_map_unmap_rq_policer(nic, flow_node->rq, ··· 1083 1059 "Unable to free leaf bandwidth profile(%d)\n", 1084 1060 flow_node->leaf_profile); 1085 1061 1086 - __clear_bit(flow_node->rq, &nic->rq_bmap); 1087 - 1088 1062 mutex_unlock(&nic->mbox.lock); 1089 1063 } 1090 1064 1065 + free_mcam_flow: 1091 1066 otx2_del_mcam_flow_entry(nic, flow_node->entry, NULL); 1092 1067 otx2_tc_update_mcam_table(nic, flow_cfg, flow_node, false); 1093 1068 kfree_rcu(flow_node, rcu); ··· 1105 1082 1106 1083 if (!(nic->flags & OTX2_FLAG_TC_FLOWER_SUPPORT)) 1107 1084 return -ENOMEM; 1085 + 1086 + if (nic->flags & OTX2_FLAG_INTF_DOWN) { 1087 + NL_SET_ERR_MSG_MOD(extack, "Interface not initialized"); 1088 + return -EINVAL; 1089 + } 1108 1090 1109 1091 if (flow_cfg->nr_flows == flow_cfg->max_flows) { 1110 1092 NL_SET_ERR_MSG_MOD(extack, ··· 1470 1442 otx2_destroy_tc_flow_list(nic); 1471 1443 } 1472 1444 EXPORT_SYMBOL(otx2_shutdown_tc); 1445 + 1446 + static void otx2_tc_config_ingress_rule(struct otx2_nic *nic, 1447 + struct otx2_tc_flow *node) 1448 + { 1449 + struct npc_install_flow_req *req; 1450 + 1451 + if (otx2_tc_act_set_hw_police(nic, node)) 1452 + return; 1453 + 1454 + mutex_lock(&nic->mbox.lock); 1455 + 1456 + req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); 1457 + if (!req) 1458 + goto err; 1459 + 1460 + memcpy(req, &node->req, sizeof(struct npc_install_flow_req)); 1461 + 1462 + if (otx2_sync_mbox_msg(&nic->mbox)) 1463 + netdev_err(nic->netdev, 1464 + "Failed to install MCAM flow entry for ingress rule"); 1465 + err: 1466 + mutex_unlock(&nic->mbox.lock); 1467 + } 1468 + 1469 + void otx2_tc_apply_ingress_police_rules(struct otx2_nic *nic) 1470 + { 1471 + struct otx2_flow_config *flow_cfg = nic->flow_cfg; 1472 + struct otx2_tc_flow *node; 1473 + 1474 + /* If any ingress policer rules exist for the interface then 1475 + * apply those rules. Ingress policer rules depend on bandwidth 1476 + * profiles linked to the receive queues. Since no receive queues 1477 + * exist when interface is down, ingress policer rules are stored 1478 + * and configured in hardware after all receive queues are allocated 1479 + * in otx2_open. 1480 + */ 1481 + list_for_each_entry(node, &flow_cfg->flow_list_tc, list) { 1482 + if (node->is_act_police) 1483 + otx2_tc_config_ingress_rule(nic, node); 1484 + } 1485 + } 1486 + EXPORT_SYMBOL(otx2_tc_apply_ingress_police_rules);
+7 -2
drivers/net/ethernet/realtek/r8169_main.c
··· 579 579 enum rtl_flag { 580 580 RTL_FLAG_TASK_ENABLED = 0, 581 581 RTL_FLAG_TASK_RESET_PENDING, 582 + RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE, 582 583 RTL_FLAG_TASK_TX_TIMEOUT, 583 584 RTL_FLAG_MAX 584 585 }; ··· 4583 4582 reset: 4584 4583 rtl_reset_work(tp); 4585 4584 netif_wake_queue(tp->dev); 4585 + } else if (test_and_clear_bit(RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE, tp->wk.flags)) { 4586 + rtl_reset_work(tp); 4586 4587 } 4587 4588 out_unlock: 4588 4589 rtnl_unlock(); ··· 4618 4615 } else { 4619 4616 /* In few cases rx is broken after link-down otherwise */ 4620 4617 if (rtl_is_8125(tp)) 4621 - rtl_reset_work(tp); 4618 + rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE); 4622 4619 pm_runtime_idle(d); 4623 4620 } 4624 4621 ··· 4694 4691 rtl8169_down(tp); 4695 4692 rtl8169_rx_clear(tp); 4696 4693 4697 - cancel_work_sync(&tp->wk.work); 4694 + cancel_work(&tp->wk.work); 4698 4695 4699 4696 free_irq(tp->irq, tp); 4700 4697 ··· 4927 4924 4928 4925 if (pci_dev_run_wake(pdev)) 4929 4926 pm_runtime_get_noresume(&pdev->dev); 4927 + 4928 + cancel_work_sync(&tp->wk.work); 4930 4929 4931 4930 unregister_netdev(tp->dev); 4932 4931
+45 -24
drivers/net/ethernet/renesas/ravb_main.c
··· 515 515 { 516 516 struct ravb_private *priv = netdev_priv(ndev); 517 517 518 + if (priv->phy_interface == PHY_INTERFACE_MODE_MII) { 519 + ravb_write(ndev, (1000 << 16) | CXR35_SEL_XMII_MII, CXR35); 520 + ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1, 0); 521 + } else { 522 + ravb_write(ndev, (1000 << 16) | CXR35_SEL_XMII_RGMII, CXR35); 523 + ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1, 524 + CXR31_SEL_LINK0); 525 + } 526 + 518 527 /* Receive frame limit set register */ 519 528 ravb_write(ndev, GBETH_RX_BUFF_MAX + ETH_FCS_LEN, RFLR); 520 529 ··· 546 537 547 538 /* E-MAC interrupt enable register */ 548 539 ravb_write(ndev, ECSIPR_ICDIP, ECSIPR); 549 - 550 - if (priv->phy_interface == PHY_INTERFACE_MODE_MII) { 551 - ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1, 0); 552 - ravb_write(ndev, (1000 << 16) | CXR35_SEL_XMII_MII, CXR35); 553 - } else { 554 - ravb_modify(ndev, CXR31, CXR31_SEL_LINK0 | CXR31_SEL_LINK1, 555 - CXR31_SEL_LINK0); 556 - } 557 540 } 558 541 559 542 static void ravb_emac_init_rcar(struct net_device *ndev) ··· 1812 1811 if (info->gptp) 1813 1812 ravb_ptp_init(ndev, priv->pdev); 1814 1813 1815 - netif_tx_start_all_queues(ndev); 1816 - 1817 1814 /* PHY control start */ 1818 1815 error = ravb_phy_start(ndev); 1819 1816 if (error) 1820 1817 goto out_ptp_stop; 1818 + 1819 + netif_tx_start_all_queues(ndev); 1821 1820 1822 1821 return 0; 1823 1822 ··· 1825 1824 /* Stop PTP Clock driver */ 1826 1825 if (info->gptp) 1827 1826 ravb_ptp_stop(ndev); 1827 + ravb_stop_dma(ndev); 1828 1828 out_free_irq_mgmta: 1829 1829 if (!info->multi_irqs) 1830 1830 goto out_free_irq; ··· 1876 1874 struct net_device *ndev = priv->ndev; 1877 1875 int error; 1878 1876 1877 + if (!rtnl_trylock()) { 1878 + usleep_range(1000, 2000); 1879 + schedule_work(&priv->work); 1880 + return; 1881 + } 1882 + 1879 1883 netif_tx_stop_all_queues(ndev); 1880 1884 1881 1885 /* Stop PTP Clock driver */ ··· 1915 1907 */ 1916 1908 netdev_err(ndev, "%s: ravb_dmac_init() failed, error %d\n", 1917 1909 __func__, error); 1918 - return; 1910 + goto out_unlock; 1919 1911 } 1920 1912 ravb_emac_init(ndev); 1921 1913 ··· 1925 1917 ravb_ptp_init(ndev, priv->pdev); 1926 1918 1927 1919 netif_tx_start_all_queues(ndev); 1920 + 1921 + out_unlock: 1922 + rtnl_unlock(); 1928 1923 } 1929 1924 1930 1925 /* Packet transmit function for Ethernet AVB */ ··· 2656 2645 ndev->features = info->net_features; 2657 2646 ndev->hw_features = info->net_hw_features; 2658 2647 2659 - reset_control_deassert(rstc); 2648 + error = reset_control_deassert(rstc); 2649 + if (error) 2650 + goto out_free_netdev; 2651 + 2660 2652 pm_runtime_enable(&pdev->dev); 2661 - pm_runtime_get_sync(&pdev->dev); 2653 + error = pm_runtime_resume_and_get(&pdev->dev); 2654 + if (error < 0) 2655 + goto out_rpm_disable; 2662 2656 2663 2657 if (info->multi_irqs) { 2664 2658 if (info->err_mgmt_irqs) ··· 2888 2872 out_disable_refclk: 2889 2873 clk_disable_unprepare(priv->refclk); 2890 2874 out_release: 2891 - free_netdev(ndev); 2892 - 2893 2875 pm_runtime_put(&pdev->dev); 2876 + out_rpm_disable: 2894 2877 pm_runtime_disable(&pdev->dev); 2895 2878 reset_control_assert(rstc); 2879 + out_free_netdev: 2880 + free_netdev(ndev); 2896 2881 return error; 2897 2882 } 2898 2883 ··· 2903 2886 struct ravb_private *priv = netdev_priv(ndev); 2904 2887 const struct ravb_hw_info *info = priv->info; 2905 2888 2906 - /* Stop PTP Clock driver */ 2907 - if (info->ccc_gac) 2908 - ravb_ptp_stop(ndev); 2909 - 2910 - clk_disable_unprepare(priv->gptp_clk); 2911 - clk_disable_unprepare(priv->refclk); 2912 - 2913 - /* Set reset mode */ 2914 - ravb_write(ndev, CCC_OPC_RESET, CCC); 2915 2889 unregister_netdev(ndev); 2916 2890 if (info->nc_queues) 2917 2891 netif_napi_del(&priv->napi[RAVB_NC]); 2918 2892 netif_napi_del(&priv->napi[RAVB_BE]); 2893 + 2919 2894 ravb_mdio_release(priv); 2895 + 2896 + /* Stop PTP Clock driver */ 2897 + if (info->ccc_gac) 2898 + ravb_ptp_stop(ndev); 2899 + 2920 2900 dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, 2921 2901 priv->desc_bat_dma); 2902 + 2903 + /* Set reset mode */ 2904 + ravb_write(ndev, CCC_OPC_RESET, CCC); 2905 + 2906 + clk_disable_unprepare(priv->gptp_clk); 2907 + clk_disable_unprepare(priv->refclk); 2908 + 2922 2909 pm_runtime_put_sync(&pdev->dev); 2923 2910 pm_runtime_disable(&pdev->dev); 2924 2911 reset_control_assert(priv->rstc);
+13 -9
drivers/net/ethernet/renesas/rswitch.c
··· 1504 1504 { 1505 1505 struct rswitch_device *rdev = netdev_priv(ndev); 1506 1506 struct rswitch_gwca_queue *gq = rdev->tx_queue; 1507 + netdev_tx_t ret = NETDEV_TX_OK; 1507 1508 struct rswitch_ext_desc *desc; 1508 - int ret = NETDEV_TX_OK; 1509 1509 dma_addr_t dma_addr; 1510 1510 1511 1511 if (rswitch_get_num_cur_queues(gq) >= gq->ring_size - 1) { ··· 1517 1517 return ret; 1518 1518 1519 1519 dma_addr = dma_map_single(ndev->dev.parent, skb->data, skb->len, DMA_TO_DEVICE); 1520 - if (dma_mapping_error(ndev->dev.parent, dma_addr)) { 1521 - dev_kfree_skb_any(skb); 1522 - return ret; 1523 - } 1520 + if (dma_mapping_error(ndev->dev.parent, dma_addr)) 1521 + goto err_kfree; 1524 1522 1525 1523 gq->skbs[gq->cur] = skb; 1526 1524 desc = &gq->tx_ring[gq->cur]; ··· 1531 1533 struct rswitch_gwca_ts_info *ts_info; 1532 1534 1533 1535 ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC); 1534 - if (!ts_info) { 1535 - dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE); 1536 - return -ENOMEM; 1537 - } 1536 + if (!ts_info) 1537 + goto err_unmap; 1538 1538 1539 1539 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; 1540 1540 rdev->ts_tag++; ··· 1553 1557 1554 1558 gq->cur = rswitch_next_queue_index(gq, true, 1); 1555 1559 rswitch_modify(rdev->addr, GWTRC(gq->index), 0, BIT(gq->index % 32)); 1560 + 1561 + return ret; 1562 + 1563 + err_unmap: 1564 + dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE); 1565 + 1566 + err_kfree: 1567 + dev_kfree_skb_any(skb); 1556 1568 1557 1569 return ret; 1558 1570 }
+4
drivers/net/ethernet/stmicro/stmmac/mmc_core.c
··· 177 177 #define MMC_XGMAC_RX_DISCARD_OCT_GB 0x1b4 178 178 #define MMC_XGMAC_RX_ALIGN_ERR_PKT 0x1bc 179 179 180 + #define MMC_XGMAC_TX_FPE_INTR_MASK 0x204 180 181 #define MMC_XGMAC_TX_FPE_FRAG 0x208 181 182 #define MMC_XGMAC_TX_HOLD_REQ 0x20c 183 + #define MMC_XGMAC_RX_FPE_INTR_MASK 0x224 182 184 #define MMC_XGMAC_RX_PKT_ASSEMBLY_ERR 0x228 183 185 #define MMC_XGMAC_RX_PKT_SMD_ERR 0x22c 184 186 #define MMC_XGMAC_RX_PKT_ASSEMBLY_OK 0x230 ··· 354 352 { 355 353 writel(0x0, mmcaddr + MMC_RX_INTR_MASK); 356 354 writel(0x0, mmcaddr + MMC_TX_INTR_MASK); 355 + writel(MMC_DEFAULT_MASK, mmcaddr + MMC_XGMAC_TX_FPE_INTR_MASK); 356 + writel(MMC_DEFAULT_MASK, mmcaddr + MMC_XGMAC_RX_FPE_INTR_MASK); 357 357 writel(MMC_DEFAULT_MASK, mmcaddr + MMC_XGMAC_RX_IPC_INTR_MASK); 358 358 } 359 359
+1 -1
drivers/net/ethernet/wangxun/libwx/wx_lib.c
··· 1972 1972 if (!pdev->msi_enabled && !pdev->msix_enabled) 1973 1973 return; 1974 1974 1975 - pci_free_irq_vectors(wx->pdev); 1976 1975 if (pdev->msix_enabled) { 1977 1976 kfree(wx->msix_entries); 1978 1977 wx->msix_entries = NULL; 1979 1978 } 1979 + pci_free_irq_vectors(wx->pdev); 1980 1980 } 1981 1981 EXPORT_SYMBOL(wx_reset_interrupt_capability); 1982 1982
+2 -2
drivers/net/netdevsim/bpf.c
··· 93 93 { 94 94 struct nsim_bpf_bound_prog *state; 95 95 96 - if (!prog || !prog->aux->offload) 96 + if (!prog || !bpf_prog_is_offloaded(prog->aux)) 97 97 return; 98 98 99 99 state = prog->aux->offload->dev_priv; ··· 311 311 if (!bpf->prog) 312 312 return 0; 313 313 314 - if (!bpf->prog->aux->offload) { 314 + if (!bpf_prog_is_offloaded(bpf->prog->aux)) { 315 315 NSIM_EA(bpf->extack, "xdpoffload of non-bound program"); 316 316 return -EINVAL; 317 317 }
+6
drivers/net/netkit.c
··· 851 851 return -EACCES; 852 852 } 853 853 854 + if (data[IFLA_NETKIT_PEER_INFO]) { 855 + NL_SET_ERR_MSG_ATTR(extack, data[IFLA_NETKIT_PEER_INFO], 856 + "netkit peer info cannot be changed after device creation"); 857 + return -EINVAL; 858 + } 859 + 854 860 if (data[IFLA_NETKIT_POLICY]) { 855 861 attr = data[IFLA_NETKIT_POLICY]; 856 862 policy = nla_get_u32(attr);
+1 -3
drivers/net/wireless/ath/ath9k/Kconfig
··· 57 57 58 58 config ATH9K_DEBUGFS 59 59 bool "Atheros ath9k debugging" 60 - depends on ATH9K && DEBUG_FS 61 - select MAC80211_DEBUGFS 60 + depends on ATH9K && DEBUG_FS && MAC80211_DEBUGFS 62 61 select ATH9K_COMMON_DEBUG 63 62 help 64 63 Say Y, if you need access to ath9k's statistics for ··· 69 70 config ATH9K_STATION_STATISTICS 70 71 bool "Detailed station statistics" 71 72 depends on ATH9K && ATH9K_DEBUGFS && DEBUG_FS 72 - select MAC80211_DEBUGFS 73 73 default n 74 74 help 75 75 This option enables detailed statistics for association stations.
+3 -1
drivers/net/wireless/intel/iwlwifi/mvm/mld-sta.c
··· 707 707 rcu_dereference_protected(mvm_sta->link[link_id], 708 708 lockdep_is_held(&mvm->mutex)); 709 709 710 - if (WARN_ON(!link_conf || !mvm_link_sta)) 710 + if (WARN_ON(!link_conf || !mvm_link_sta)) { 711 + ret = -EINVAL; 711 712 goto err; 713 + } 712 714 713 715 ret = iwl_mvm_mld_cfg_sta(mvm, sta, vif, link_sta, link_conf, 714 716 mvm_link_sta);
+1
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
··· 375 375 int ret, i, len, offset = 0; 376 376 u8 *clc_base = NULL, hw_encap = 0; 377 377 378 + dev->phy.clc_chan_conf = 0xff; 378 379 if (mt7921_disable_clc || 379 380 mt76_is_usb(&dev->mt76)) 380 381 return 0;
+2 -2
drivers/net/wireless/mediatek/mt76/mt7925/main.c
··· 14 14 static void 15 15 mt7925_init_he_caps(struct mt792x_phy *phy, enum nl80211_band band, 16 16 struct ieee80211_sband_iftype_data *data, 17 - enum nl80211_iftype iftype) 17 + enum nl80211_iftype iftype) 18 18 { 19 19 struct ieee80211_sta_he_cap *he_cap = &data->he_cap; 20 20 struct ieee80211_he_cap_elem *he_cap_elem = &he_cap->he_cap_elem; ··· 53 53 IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO | 54 54 IEEE80211_HE_PHY_CAP2_UL_MU_PARTIAL_MU_MIMO; 55 55 56 - switch (i) { 56 + switch (iftype) { 57 57 case NL80211_IFTYPE_AP: 58 58 he_cap_elem->mac_cap_info[2] |= 59 59 IEEE80211_HE_MAC_CAP2_BSR;
+100
fs/debugfs/file.c
··· 84 84 struct debugfs_fsdata *fsd; 85 85 void *d_fsd; 86 86 87 + /* 88 + * This could only happen if some debugfs user erroneously calls 89 + * debugfs_file_get() on a dentry that isn't even a file, let 90 + * them know about it. 91 + */ 92 + if (WARN_ON(!d_is_reg(dentry))) 93 + return -EINVAL; 94 + 87 95 d_fsd = READ_ONCE(dentry->d_fsdata); 88 96 if (!((unsigned long)d_fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)) { 89 97 fsd = d_fsd; ··· 108 100 kfree(fsd); 109 101 fsd = READ_ONCE(dentry->d_fsdata); 110 102 } 103 + #ifdef CONFIG_LOCKDEP 104 + fsd->lock_name = kasprintf(GFP_KERNEL, "debugfs:%pd", dentry); 105 + lockdep_register_key(&fsd->key); 106 + lockdep_init_map(&fsd->lockdep_map, fsd->lock_name ?: "debugfs", 107 + &fsd->key, 0); 108 + #endif 109 + INIT_LIST_HEAD(&fsd->cancellations); 110 + mutex_init(&fsd->cancellations_mtx); 111 111 } 112 112 113 113 /* ··· 131 115 132 116 if (!refcount_inc_not_zero(&fsd->active_users)) 133 117 return -EIO; 118 + 119 + lock_map_acquire_read(&fsd->lockdep_map); 134 120 135 121 return 0; 136 122 } ··· 151 133 { 152 134 struct debugfs_fsdata *fsd = READ_ONCE(dentry->d_fsdata); 153 135 136 + lock_map_release(&fsd->lockdep_map); 137 + 154 138 if (refcount_dec_and_test(&fsd->active_users)) 155 139 complete(&fsd->active_users_drained); 156 140 } 157 141 EXPORT_SYMBOL_GPL(debugfs_file_put); 142 + 143 + /** 144 + * debugfs_enter_cancellation - enter a debugfs cancellation 145 + * @file: the file being accessed 146 + * @cancellation: the cancellation object, the cancel callback 147 + * inside of it must be initialized 148 + * 149 + * When a debugfs file is removed it needs to wait for all active 150 + * operations to complete. However, the operation itself may need 151 + * to wait for hardware or completion of some asynchronous process 152 + * or similar. As such, it may need to be cancelled to avoid long 153 + * waits or even deadlocks. 154 + * 155 + * This function can be used inside a debugfs handler that may 156 + * need to be cancelled. As soon as this function is called, the 157 + * cancellation's 'cancel' callback may be called, at which point 158 + * the caller should proceed to call debugfs_leave_cancellation() 159 + * and leave the debugfs handler function as soon as possible. 160 + * Note that the 'cancel' callback is only ever called in the 161 + * context of some kind of debugfs_remove(). 162 + * 163 + * This function must be paired with debugfs_leave_cancellation(). 164 + */ 165 + void debugfs_enter_cancellation(struct file *file, 166 + struct debugfs_cancellation *cancellation) 167 + { 168 + struct debugfs_fsdata *fsd; 169 + struct dentry *dentry = F_DENTRY(file); 170 + 171 + INIT_LIST_HEAD(&cancellation->list); 172 + 173 + if (WARN_ON(!d_is_reg(dentry))) 174 + return; 175 + 176 + if (WARN_ON(!cancellation->cancel)) 177 + return; 178 + 179 + fsd = READ_ONCE(dentry->d_fsdata); 180 + if (WARN_ON(!fsd || 181 + ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT))) 182 + return; 183 + 184 + mutex_lock(&fsd->cancellations_mtx); 185 + list_add(&cancellation->list, &fsd->cancellations); 186 + mutex_unlock(&fsd->cancellations_mtx); 187 + 188 + /* if we're already removing wake it up to cancel */ 189 + if (d_unlinked(dentry)) 190 + complete(&fsd->active_users_drained); 191 + } 192 + EXPORT_SYMBOL_GPL(debugfs_enter_cancellation); 193 + 194 + /** 195 + * debugfs_leave_cancellation - leave cancellation section 196 + * @file: the file being accessed 197 + * @cancellation: the cancellation previously registered with 198 + * debugfs_enter_cancellation() 199 + * 200 + * See the documentation of debugfs_enter_cancellation(). 201 + */ 202 + void debugfs_leave_cancellation(struct file *file, 203 + struct debugfs_cancellation *cancellation) 204 + { 205 + struct debugfs_fsdata *fsd; 206 + struct dentry *dentry = F_DENTRY(file); 207 + 208 + if (WARN_ON(!d_is_reg(dentry))) 209 + return; 210 + 211 + fsd = READ_ONCE(dentry->d_fsdata); 212 + if (WARN_ON(!fsd || 213 + ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT))) 214 + return; 215 + 216 + mutex_lock(&fsd->cancellations_mtx); 217 + if (!list_empty(&cancellation->list)) 218 + list_del(&cancellation->list); 219 + mutex_unlock(&fsd->cancellations_mtx); 220 + } 221 + EXPORT_SYMBOL_GPL(debugfs_leave_cancellation); 158 222 159 223 /* 160 224 * Only permit access to world-readable files when the kernel is locked down.
+63 -8
fs/debugfs/inode.c
··· 236 236 237 237 static void debugfs_release_dentry(struct dentry *dentry) 238 238 { 239 - void *fsd = dentry->d_fsdata; 239 + struct debugfs_fsdata *fsd = dentry->d_fsdata; 240 240 241 - if (!((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)) 242 - kfree(dentry->d_fsdata); 241 + if ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT) 242 + return; 243 + 244 + /* check it wasn't a dir (no fsdata) or automount (no real_fops) */ 245 + if (fsd && fsd->real_fops) { 246 + #ifdef CONFIG_LOCKDEP 247 + lockdep_unregister_key(&fsd->key); 248 + kfree(fsd->lock_name); 249 + #endif 250 + WARN_ON(!list_empty(&fsd->cancellations)); 251 + mutex_destroy(&fsd->cancellations_mtx); 252 + } 253 + 254 + kfree(fsd); 243 255 } 244 256 245 257 static struct vfsmount *debugfs_automount(struct path *path) 246 258 { 247 - debugfs_automount_t f; 248 - f = (debugfs_automount_t)path->dentry->d_fsdata; 249 - return f(path->dentry, d_inode(path->dentry)->i_private); 259 + struct debugfs_fsdata *fsd = path->dentry->d_fsdata; 260 + 261 + return fsd->automount(path->dentry, d_inode(path->dentry)->i_private); 250 262 } 251 263 252 264 static const struct dentry_operations debugfs_dops = { ··· 646 634 void *data) 647 635 { 648 636 struct dentry *dentry = start_creating(name, parent); 637 + struct debugfs_fsdata *fsd; 649 638 struct inode *inode; 650 639 651 640 if (IS_ERR(dentry)) 652 641 return dentry; 653 642 643 + fsd = kzalloc(sizeof(*fsd), GFP_KERNEL); 644 + if (!fsd) { 645 + failed_creating(dentry); 646 + return ERR_PTR(-ENOMEM); 647 + } 648 + 649 + fsd->automount = f; 650 + 654 651 if (!(debugfs_allow & DEBUGFS_ALLOW_API)) { 655 652 failed_creating(dentry); 653 + kfree(fsd); 656 654 return ERR_PTR(-EPERM); 657 655 } 658 656 ··· 670 648 if (unlikely(!inode)) { 671 649 pr_err("out of free dentries, can not create automount '%s'\n", 672 650 name); 651 + kfree(fsd); 673 652 return failed_creating(dentry); 674 653 } 675 654 676 655 make_empty_dir_inode(inode); 677 656 inode->i_flags |= S_AUTOMOUNT; 678 657 inode->i_private = data; 679 - dentry->d_fsdata = (void *)f; 658 + dentry->d_fsdata = fsd; 680 659 /* directory inodes start off with i_nlink == 2 (for "." entry) */ 681 660 inc_nlink(inode); 682 661 d_instantiate(dentry, inode); ··· 754 731 fsd = READ_ONCE(dentry->d_fsdata); 755 732 if ((unsigned long)fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT) 756 733 return; 757 - if (!refcount_dec_and_test(&fsd->active_users)) 734 + 735 + lock_map_acquire(&fsd->lockdep_map); 736 + lock_map_release(&fsd->lockdep_map); 737 + 738 + /* if we hit zero, just wait for all to finish */ 739 + if (!refcount_dec_and_test(&fsd->active_users)) { 758 740 wait_for_completion(&fsd->active_users_drained); 741 + return; 742 + } 743 + 744 + /* if we didn't hit zero, try to cancel any we can */ 745 + while (refcount_read(&fsd->active_users)) { 746 + struct debugfs_cancellation *c; 747 + 748 + /* 749 + * Lock the cancellations. Note that the cancellations 750 + * structs are meant to be on the stack, so we need to 751 + * ensure we either use them here or don't touch them, 752 + * and debugfs_leave_cancellation() will wait for this 753 + * to be finished processing before exiting one. It may 754 + * of course win and remove the cancellation, but then 755 + * chances are we never even got into this bit, we only 756 + * do if the refcount isn't zero already. 757 + */ 758 + mutex_lock(&fsd->cancellations_mtx); 759 + while ((c = list_first_entry_or_null(&fsd->cancellations, 760 + typeof(*c), list))) { 761 + list_del_init(&c->list); 762 + c->cancel(dentry, c->cancel_data); 763 + } 764 + mutex_unlock(&fsd->cancellations_mtx); 765 + 766 + wait_for_completion(&fsd->active_users_drained); 767 + } 759 768 } 760 769 761 770 static void remove_one(struct dentry *victim)
+19 -2
fs/debugfs/internal.h
··· 7 7 8 8 #ifndef _DEBUGFS_INTERNAL_H_ 9 9 #define _DEBUGFS_INTERNAL_H_ 10 + #include <linux/lockdep.h> 11 + #include <linux/list.h> 10 12 11 13 struct file_operations; 12 14 ··· 19 17 20 18 struct debugfs_fsdata { 21 19 const struct file_operations *real_fops; 22 - refcount_t active_users; 23 - struct completion active_users_drained; 20 + union { 21 + /* automount_fn is used when real_fops is NULL */ 22 + debugfs_automount_t automount; 23 + struct { 24 + refcount_t active_users; 25 + struct completion active_users_drained; 26 + #ifdef CONFIG_LOCKDEP 27 + struct lockdep_map lockdep_map; 28 + struct lock_class_key key; 29 + char *lock_name; 30 + #endif 31 + 32 + /* protect cancellations */ 33 + struct mutex cancellations_mtx; 34 + struct list_head cancellations; 35 + }; 36 + }; 24 37 }; 25 38 26 39 /*
+19
include/linux/debugfs.h
··· 171 171 ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf, 172 172 size_t count, loff_t *ppos); 173 173 174 + /** 175 + * struct debugfs_cancellation - cancellation data 176 + * @list: internal, for keeping track 177 + * @cancel: callback to call 178 + * @cancel_data: extra data for the callback to call 179 + */ 180 + struct debugfs_cancellation { 181 + struct list_head list; 182 + void (*cancel)(struct dentry *, void *); 183 + void *cancel_data; 184 + }; 185 + 186 + void __acquires(cancellation) 187 + debugfs_enter_cancellation(struct file *file, 188 + struct debugfs_cancellation *cancellation); 189 + void __releases(cancellation) 190 + debugfs_leave_cancellation(struct file *file, 191 + struct debugfs_cancellation *cancellation); 192 + 174 193 #else 175 194 176 195 #include <linux/err.h>
+3 -1
include/linux/ieee80211.h
··· 2830 2830 static inline const struct ieee80211_he_6ghz_oper * 2831 2831 ieee80211_he_6ghz_oper(const struct ieee80211_he_operation *he_oper) 2832 2832 { 2833 - const u8 *ret = (const void *)&he_oper->optional; 2833 + const u8 *ret; 2834 2834 u32 he_oper_params; 2835 2835 2836 2836 if (!he_oper) 2837 2837 return NULL; 2838 + 2839 + ret = (const void *)&he_oper->optional; 2838 2840 2839 2841 he_oper_params = le32_to_cpu(he_oper->he_oper_params); 2840 2842
+1
include/linux/skmsg.h
··· 106 106 struct mutex work_mutex; 107 107 struct sk_psock_work_state work_state; 108 108 struct delayed_work work; 109 + struct sock *sk_pair; 109 110 struct rcu_work rwork; 110 111 }; 111 112
+1
include/net/af_unix.h
··· 75 75 }; 76 76 77 77 #define unix_sk(ptr) container_of_const(ptr, struct unix_sock, sk) 78 + #define unix_peer(sk) (unix_sk(sk)->peer) 78 79 79 80 #define peer_wait peer_wq.wait 80 81
+46
include/net/cfg80211.h
··· 9299 9299 */ 9300 9300 void cfg80211_links_removed(struct net_device *dev, u16 link_mask); 9301 9301 9302 + #ifdef CONFIG_CFG80211_DEBUGFS 9303 + /** 9304 + * wiphy_locked_debugfs_read - do a locked read in debugfs 9305 + * @wiphy: the wiphy to use 9306 + * @file: the file being read 9307 + * @buf: the buffer to fill and then read from 9308 + * @bufsize: size of the buffer 9309 + * @userbuf: the user buffer to copy to 9310 + * @count: read count 9311 + * @ppos: read position 9312 + * @handler: the read handler to call (under wiphy lock) 9313 + * @data: additional data to pass to the read handler 9314 + */ 9315 + ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file, 9316 + char *buf, size_t bufsize, 9317 + char __user *userbuf, size_t count, 9318 + loff_t *ppos, 9319 + ssize_t (*handler)(struct wiphy *wiphy, 9320 + struct file *file, 9321 + char *buf, 9322 + size_t bufsize, 9323 + void *data), 9324 + void *data); 9325 + 9326 + /** 9327 + * wiphy_locked_debugfs_write - do a locked write in debugfs 9328 + * @wiphy: the wiphy to use 9329 + * @file: the file being written to 9330 + * @buf: the buffer to copy the user data to 9331 + * @bufsize: size of the buffer 9332 + * @userbuf: the user buffer to copy from 9333 + * @count: read count 9334 + * @handler: the write handler to call (under wiphy lock) 9335 + * @data: additional data to pass to the write handler 9336 + */ 9337 + ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy, struct file *file, 9338 + char *buf, size_t bufsize, 9339 + const char __user *userbuf, size_t count, 9340 + ssize_t (*handler)(struct wiphy *wiphy, 9341 + struct file *file, 9342 + char *buf, 9343 + size_t count, 9344 + void *data), 9345 + void *data); 9346 + #endif 9347 + 9302 9348 #endif /* __NET_CFG80211_H */
+1 -1
include/net/neighbour.h
··· 162 162 struct rcu_head rcu; 163 163 struct net_device *dev; 164 164 netdevice_tracker dev_tracker; 165 - u8 primary_key[0]; 165 + u8 primary_key[]; 166 166 } __randomize_layout; 167 167 168 168 struct neigh_ops {
+2
kernel/bpf/memalloc.c
··· 978 978 memcg = get_memcg(c); 979 979 old_memcg = set_active_memcg(memcg); 980 980 ret = __alloc(c, NUMA_NO_NODE, GFP_KERNEL | __GFP_NOWARN | __GFP_ACCOUNT); 981 + if (ret) 982 + *(struct bpf_mem_cache **)ret = c; 981 983 set_active_memcg(old_memcg); 982 984 mem_cgroup_put(memcg); 983 985 }
+2
net/core/skmsg.c
··· 826 826 827 827 if (psock->sk_redir) 828 828 sock_put(psock->sk_redir); 829 + if (psock->sk_pair) 830 + sock_put(psock->sk_pair); 829 831 sock_put(psock->sk); 830 832 kfree(psock); 831 833 }
+1
net/ethtool/netlink.c
··· 505 505 ret = skb->len; 506 506 break; 507 507 } 508 + ret = 0; 508 509 } 509 510 rtnl_unlock(); 510 511
+4 -2
net/ipv4/igmp.c
··· 216 216 int tv = get_random_u32_below(max_delay); 217 217 218 218 im->tm_running = 1; 219 - if (!mod_timer(&im->timer, jiffies+tv+2)) 220 - refcount_inc(&im->refcnt); 219 + if (refcount_inc_not_zero(&im->refcnt)) { 220 + if (mod_timer(&im->timer, jiffies + tv + 2)) 221 + ip_ma_put(im); 222 + } 221 223 } 222 224 223 225 static void igmp_gq_start_timer(struct in_device *in_dev)
+1 -1
net/mac80211/Kconfig
··· 88 88 89 89 config MAC80211_DEBUGFS 90 90 bool "Export mac80211 internals in DebugFS" 91 - depends on MAC80211 && DEBUG_FS 91 + depends on MAC80211 && CFG80211_DEBUGFS 92 92 help 93 93 Select this to see extensive information about 94 94 the internal state of mac80211 in debugfs.
+105 -45
net/mac80211/debugfs_netdev.c
··· 22 22 #include "debugfs_netdev.h" 23 23 #include "driver-ops.h" 24 24 25 + struct ieee80211_if_read_sdata_data { 26 + ssize_t (*format)(const struct ieee80211_sub_if_data *, char *, int); 27 + struct ieee80211_sub_if_data *sdata; 28 + }; 29 + 30 + static ssize_t ieee80211_if_read_sdata_handler(struct wiphy *wiphy, 31 + struct file *file, 32 + char *buf, 33 + size_t bufsize, 34 + void *data) 35 + { 36 + struct ieee80211_if_read_sdata_data *d = data; 37 + 38 + return d->format(d->sdata, buf, bufsize); 39 + } 40 + 25 41 static ssize_t ieee80211_if_read_sdata( 26 - struct ieee80211_sub_if_data *sdata, 42 + struct file *file, 27 43 char __user *userbuf, 28 44 size_t count, loff_t *ppos, 29 45 ssize_t (*format)(const struct ieee80211_sub_if_data *sdata, char *, int)) 30 46 { 47 + struct ieee80211_sub_if_data *sdata = file->private_data; 48 + struct ieee80211_if_read_sdata_data data = { 49 + .format = format, 50 + .sdata = sdata, 51 + }; 31 52 char buf[200]; 32 - ssize_t ret = -EINVAL; 33 53 34 - wiphy_lock(sdata->local->hw.wiphy); 35 - ret = (*format)(sdata, buf, sizeof(buf)); 36 - wiphy_unlock(sdata->local->hw.wiphy); 54 + return wiphy_locked_debugfs_read(sdata->local->hw.wiphy, 55 + file, buf, sizeof(buf), 56 + userbuf, count, ppos, 57 + ieee80211_if_read_sdata_handler, 58 + &data); 59 + } 37 60 38 - if (ret >= 0) 39 - ret = simple_read_from_buffer(userbuf, count, ppos, buf, ret); 61 + struct ieee80211_if_write_sdata_data { 62 + ssize_t (*write)(struct ieee80211_sub_if_data *, const char *, int); 63 + struct ieee80211_sub_if_data *sdata; 64 + }; 40 65 41 - return ret; 66 + static ssize_t ieee80211_if_write_sdata_handler(struct wiphy *wiphy, 67 + struct file *file, 68 + char *buf, 69 + size_t count, 70 + void *data) 71 + { 72 + struct ieee80211_if_write_sdata_data *d = data; 73 + 74 + return d->write(d->sdata, buf, count); 42 75 } 43 76 44 77 static ssize_t ieee80211_if_write_sdata( 45 - struct ieee80211_sub_if_data *sdata, 78 + struct file *file, 46 79 const char __user *userbuf, 47 80 size_t count, loff_t *ppos, 48 81 ssize_t (*write)(struct ieee80211_sub_if_data *sdata, const char *, int)) 49 82 { 83 + struct ieee80211_sub_if_data *sdata = file->private_data; 84 + struct ieee80211_if_write_sdata_data data = { 85 + .write = write, 86 + .sdata = sdata, 87 + }; 50 88 char buf[64]; 51 - ssize_t ret; 52 89 53 - if (count >= sizeof(buf)) 54 - return -E2BIG; 90 + return wiphy_locked_debugfs_write(sdata->local->hw.wiphy, 91 + file, buf, sizeof(buf), 92 + userbuf, count, 93 + ieee80211_if_write_sdata_handler, 94 + &data); 95 + } 55 96 56 - if (copy_from_user(buf, userbuf, count)) 57 - return -EFAULT; 58 - buf[count] = '\0'; 97 + struct ieee80211_if_read_link_data { 98 + ssize_t (*format)(const struct ieee80211_link_data *, char *, int); 99 + struct ieee80211_link_data *link; 100 + }; 59 101 60 - wiphy_lock(sdata->local->hw.wiphy); 61 - ret = (*write)(sdata, buf, count); 62 - wiphy_unlock(sdata->local->hw.wiphy); 102 + static ssize_t ieee80211_if_read_link_handler(struct wiphy *wiphy, 103 + struct file *file, 104 + char *buf, 105 + size_t bufsize, 106 + void *data) 107 + { 108 + struct ieee80211_if_read_link_data *d = data; 63 109 64 - return ret; 110 + return d->format(d->link, buf, bufsize); 65 111 } 66 112 67 113 static ssize_t ieee80211_if_read_link( 68 - struct ieee80211_link_data *link, 114 + struct file *file, 69 115 char __user *userbuf, 70 116 size_t count, loff_t *ppos, 71 117 ssize_t (*format)(const struct ieee80211_link_data *link, char *, int)) 72 118 { 119 + struct ieee80211_link_data *link = file->private_data; 120 + struct ieee80211_if_read_link_data data = { 121 + .format = format, 122 + .link = link, 123 + }; 73 124 char buf[200]; 74 - ssize_t ret = -EINVAL; 75 125 76 - wiphy_lock(link->sdata->local->hw.wiphy); 77 - ret = (*format)(link, buf, sizeof(buf)); 78 - wiphy_unlock(link->sdata->local->hw.wiphy); 126 + return wiphy_locked_debugfs_read(link->sdata->local->hw.wiphy, 127 + file, buf, sizeof(buf), 128 + userbuf, count, ppos, 129 + ieee80211_if_read_link_handler, 130 + &data); 131 + } 79 132 80 - if (ret >= 0) 81 - ret = simple_read_from_buffer(userbuf, count, ppos, buf, ret); 133 + struct ieee80211_if_write_link_data { 134 + ssize_t (*write)(struct ieee80211_link_data *, const char *, int); 135 + struct ieee80211_link_data *link; 136 + }; 82 137 83 - return ret; 138 + static ssize_t ieee80211_if_write_link_handler(struct wiphy *wiphy, 139 + struct file *file, 140 + char *buf, 141 + size_t count, 142 + void *data) 143 + { 144 + struct ieee80211_if_write_sdata_data *d = data; 145 + 146 + return d->write(d->sdata, buf, count); 84 147 } 85 148 86 149 static ssize_t ieee80211_if_write_link( 87 - struct ieee80211_link_data *link, 150 + struct file *file, 88 151 const char __user *userbuf, 89 152 size_t count, loff_t *ppos, 90 153 ssize_t (*write)(struct ieee80211_link_data *link, const char *, int)) 91 154 { 155 + struct ieee80211_link_data *link = file->private_data; 156 + struct ieee80211_if_write_link_data data = { 157 + .write = write, 158 + .link = link, 159 + }; 92 160 char buf[64]; 93 - ssize_t ret; 94 161 95 - if (count >= sizeof(buf)) 96 - return -E2BIG; 97 - 98 - if (copy_from_user(buf, userbuf, count)) 99 - return -EFAULT; 100 - buf[count] = '\0'; 101 - 102 - wiphy_lock(link->sdata->local->hw.wiphy); 103 - ret = (*write)(link, buf, count); 104 - wiphy_unlock(link->sdata->local->hw.wiphy); 105 - 106 - return ret; 162 + return wiphy_locked_debugfs_write(link->sdata->local->hw.wiphy, 163 + file, buf, sizeof(buf), 164 + userbuf, count, 165 + ieee80211_if_write_link_handler, 166 + &data); 107 167 } 108 168 109 169 #define IEEE80211_IF_FMT(name, type, field, format_string) \ ··· 233 173 char __user *userbuf, \ 234 174 size_t count, loff_t *ppos) \ 235 175 { \ 236 - return ieee80211_if_read_sdata(file->private_data, \ 176 + return ieee80211_if_read_sdata(file, \ 237 177 userbuf, count, ppos, \ 238 178 ieee80211_if_fmt_##name); \ 239 179 } ··· 243 183 const char __user *userbuf, \ 244 184 size_t count, loff_t *ppos) \ 245 185 { \ 246 - return ieee80211_if_write_sdata(file->private_data, userbuf, \ 186 + return ieee80211_if_write_sdata(file, userbuf, \ 247 187 count, ppos, \ 248 188 ieee80211_if_parse_##name); \ 249 189 } ··· 271 211 char __user *userbuf, \ 272 212 size_t count, loff_t *ppos) \ 273 213 { \ 274 - return ieee80211_if_read_link(file->private_data, \ 214 + return ieee80211_if_read_link(file, \ 275 215 userbuf, count, ppos, \ 276 216 ieee80211_if_fmt_##name); \ 277 217 } ··· 281 221 const char __user *userbuf, \ 282 222 size_t count, loff_t *ppos) \ 283 223 { \ 284 - return ieee80211_if_write_link(file->private_data, userbuf, \ 224 + return ieee80211_if_write_link(file, userbuf, \ 285 225 count, ppos, \ 286 226 ieee80211_if_parse_##name); \ 287 227 }
+42 -32
net/mac80211/debugfs_sta.c
··· 312 312 STA_OPS_RW(aql); 313 313 314 314 315 - static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf, 316 - size_t count, loff_t *ppos) 315 + static ssize_t sta_agg_status_do_read(struct wiphy *wiphy, struct file *file, 316 + char *buf, size_t bufsz, void *data) 317 317 { 318 - char *buf, *p; 319 - ssize_t bufsz = 71 + IEEE80211_NUM_TIDS * 40; 318 + struct sta_info *sta = data; 319 + char *p = buf; 320 320 int i; 321 - struct sta_info *sta = file->private_data; 322 321 struct tid_ampdu_rx *tid_rx; 323 322 struct tid_ampdu_tx *tid_tx; 324 - ssize_t ret; 325 - 326 - buf = kzalloc(bufsz, GFP_KERNEL); 327 - if (!buf) 328 - return -ENOMEM; 329 - p = buf; 330 - 331 - rcu_read_lock(); 332 323 333 324 p += scnprintf(p, bufsz + buf - p, "next dialog_token: %#02x\n", 334 325 sta->ampdu_mlme.dialog_token_allocator + 1); ··· 329 338 for (i = 0; i < IEEE80211_NUM_TIDS; i++) { 330 339 bool tid_rx_valid; 331 340 332 - tid_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[i]); 333 - tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[i]); 341 + tid_rx = wiphy_dereference(wiphy, sta->ampdu_mlme.tid_rx[i]); 342 + tid_tx = wiphy_dereference(wiphy, sta->ampdu_mlme.tid_tx[i]); 334 343 tid_rx_valid = test_bit(i, sta->ampdu_mlme.agg_session_valid); 335 344 336 345 p += scnprintf(p, bufsz + buf - p, "%02d", i); ··· 349 358 tid_tx ? skb_queue_len(&tid_tx->pending) : 0); 350 359 p += scnprintf(p, bufsz + buf - p, "\n"); 351 360 } 352 - rcu_read_unlock(); 353 361 354 - ret = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); 362 + return p - buf; 363 + } 364 + 365 + static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf, 366 + size_t count, loff_t *ppos) 367 + { 368 + struct sta_info *sta = file->private_data; 369 + struct wiphy *wiphy = sta->local->hw.wiphy; 370 + size_t bufsz = 71 + IEEE80211_NUM_TIDS * 40; 371 + char *buf = kmalloc(bufsz, GFP_KERNEL); 372 + ssize_t ret; 373 + 374 + if (!buf) 375 + return -ENOMEM; 376 + 377 + ret = wiphy_locked_debugfs_read(wiphy, file, buf, bufsz, 378 + userbuf, count, ppos, 379 + sta_agg_status_do_read, sta); 355 380 kfree(buf); 381 + 356 382 return ret; 357 383 } 358 384 359 - static ssize_t sta_agg_status_write(struct file *file, const char __user *userbuf, 360 - size_t count, loff_t *ppos) 385 + static ssize_t sta_agg_status_do_write(struct wiphy *wiphy, struct file *file, 386 + char *buf, size_t count, void *data) 361 387 { 362 - char _buf[25] = {}, *buf = _buf; 363 - struct sta_info *sta = file->private_data; 388 + struct sta_info *sta = data; 364 389 bool start, tx; 365 390 unsigned long tid; 366 - char *pos; 391 + char *pos = buf; 367 392 int ret, timeout = 5000; 368 393 369 - if (count > sizeof(_buf)) 370 - return -EINVAL; 371 - 372 - if (copy_from_user(buf, userbuf, count)) 373 - return -EFAULT; 374 - 375 - buf[sizeof(_buf) - 1] = '\0'; 376 - pos = buf; 377 394 buf = strsep(&pos, " "); 378 395 if (!buf) 379 396 return -EINVAL; ··· 419 420 if (ret || tid >= IEEE80211_NUM_TIDS) 420 421 return -EINVAL; 421 422 422 - wiphy_lock(sta->local->hw.wiphy); 423 423 if (tx) { 424 424 if (start) 425 425 ret = ieee80211_start_tx_ba_session(&sta->sta, tid, ··· 430 432 3, true); 431 433 ret = 0; 432 434 } 433 - wiphy_unlock(sta->local->hw.wiphy); 434 435 435 436 return ret ?: count; 437 + } 438 + 439 + static ssize_t sta_agg_status_write(struct file *file, 440 + const char __user *userbuf, 441 + size_t count, loff_t *ppos) 442 + { 443 + struct sta_info *sta = file->private_data; 444 + struct wiphy *wiphy = sta->local->hw.wiphy; 445 + char _buf[26]; 446 + 447 + return wiphy_locked_debugfs_write(wiphy, file, _buf, sizeof(_buf), 448 + userbuf, count, 449 + sta_agg_status_do_write, sta); 436 450 } 437 451 STA_OPS_RW(agg_status); 438 452
+7 -2
net/mac80211/driver-ops.h
··· 23 23 static inline struct ieee80211_sub_if_data * 24 24 get_bss_sdata(struct ieee80211_sub_if_data *sdata) 25 25 { 26 - if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 26 + if (sdata && sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 27 27 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, 28 28 u.ap); 29 29 ··· 695 695 struct ieee80211_sub_if_data *sdata, 696 696 u32 queues, bool drop) 697 697 { 698 - struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL; 698 + struct ieee80211_vif *vif; 699 699 700 700 might_sleep(); 701 701 lockdep_assert_wiphy(local->hw.wiphy); 702 + 703 + sdata = get_bss_sdata(sdata); 704 + vif = sdata ? &sdata->vif : NULL; 702 705 703 706 if (sdata && !check_sdata_in_driver(sdata)) 704 707 return; ··· 718 715 { 719 716 might_sleep(); 720 717 lockdep_assert_wiphy(local->hw.wiphy); 718 + 719 + sdata = get_bss_sdata(sdata); 721 720 722 721 if (sdata && !check_sdata_in_driver(sdata)) 723 722 return;
+1
net/mac80211/ht.c
··· 271 271 case NL80211_CHAN_WIDTH_80: 272 272 case NL80211_CHAN_WIDTH_80P80: 273 273 case NL80211_CHAN_WIDTH_160: 274 + case NL80211_CHAN_WIDTH_320: 274 275 bw = ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 ? 275 276 IEEE80211_STA_RX_BW_40 : IEEE80211_STA_RX_BW_20; 276 277 break;
+1
net/mptcp/options.c
··· 108 108 mp_opt->suboptions |= OPTION_MPTCP_DSS; 109 109 mp_opt->use_map = 1; 110 110 mp_opt->mpc_map = 1; 111 + mp_opt->use_ack = 0; 111 112 mp_opt->data_len = get_unaligned_be16(ptr); 112 113 ptr += 2; 113 114 }
-2
net/unix/af_unix.c
··· 213 213 } 214 214 #endif /* CONFIG_SECURITY_NETWORK */ 215 215 216 - #define unix_peer(sk) (unix_sk(sk)->peer) 217 - 218 216 static inline int unix_our_peer(struct sock *sk, struct sock *osk) 219 217 { 220 218 return unix_peer(osk) == sk;
+5
net/unix/unix_bpf.c
··· 159 159 160 160 int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore) 161 161 { 162 + struct sock *sk_pair; 163 + 162 164 if (restore) { 163 165 sk->sk_write_space = psock->saved_write_space; 164 166 sock_replace_proto(sk, psock->sk_proto); 165 167 return 0; 166 168 } 167 169 170 + sk_pair = unix_peer(sk); 171 + sock_hold(sk_pair); 172 + psock->sk_pair = sk_pair; 168 173 unix_stream_bpf_check_needs_rebuild(psock->sk_proto); 169 174 sock_replace_proto(sk, &unix_stream_bpf_prot); 170 175 return 0;
+4 -2
net/wireless/core.c
··· 191 191 return err; 192 192 } 193 193 194 + wiphy_lock(&rdev->wiphy); 194 195 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { 195 196 if (!wdev->netdev) 196 197 continue; 197 198 nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE); 198 199 } 199 200 200 - wiphy_lock(&rdev->wiphy); 201 201 nl80211_notify_wiphy(rdev, NL80211_CMD_DEL_WIPHY); 202 202 203 203 wiphy_net_set(&rdev->wiphy, net); ··· 206 206 WARN_ON(err); 207 207 208 208 nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY); 209 - wiphy_unlock(&rdev->wiphy); 210 209 211 210 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { 212 211 if (!wdev->netdev) 213 212 continue; 214 213 nl80211_notify_iface(rdev, wdev, NL80211_CMD_NEW_INTERFACE); 215 214 } 215 + wiphy_unlock(&rdev->wiphy); 216 216 217 217 return 0; 218 218 } ··· 221 221 { 222 222 struct cfg80211_registered_device *rdev = data; 223 223 224 + wiphy_lock(&rdev->wiphy); 224 225 rdev_rfkill_poll(rdev); 226 + wiphy_unlock(&rdev->wiphy); 225 227 } 226 228 227 229 void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
+1
net/wireless/core.h
··· 293 293 u32 rssi_hyst; 294 294 s32 last_rssi_event_value; 295 295 enum nl80211_cqm_rssi_threshold_event last_rssi_event_type; 296 + bool use_range_api; 296 297 int n_rssi_thresholds; 297 298 s32 rssi_thresholds[] __counted_by(n_rssi_thresholds); 298 299 };
+160
net/wireless/debugfs.c
··· 4 4 * 5 5 * Copyright 2009 Luis R. Rodriguez <lrodriguez@atheros.com> 6 6 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> 7 + * Copyright (C) 2023 Intel Corporation 7 8 */ 8 9 9 10 #include <linux/slab.h> ··· 110 109 DEBUGFS_ADD(long_retry_limit); 111 110 DEBUGFS_ADD(ht40allow_map); 112 111 } 112 + 113 + struct debugfs_read_work { 114 + struct wiphy_work work; 115 + ssize_t (*handler)(struct wiphy *wiphy, 116 + struct file *file, 117 + char *buf, 118 + size_t count, 119 + void *data); 120 + struct wiphy *wiphy; 121 + struct file *file; 122 + char *buf; 123 + size_t bufsize; 124 + void *data; 125 + ssize_t ret; 126 + struct completion completion; 127 + }; 128 + 129 + static void wiphy_locked_debugfs_read_work(struct wiphy *wiphy, 130 + struct wiphy_work *work) 131 + { 132 + struct debugfs_read_work *w = container_of(work, typeof(*w), work); 133 + 134 + w->ret = w->handler(w->wiphy, w->file, w->buf, w->bufsize, w->data); 135 + complete(&w->completion); 136 + } 137 + 138 + static void wiphy_locked_debugfs_read_cancel(struct dentry *dentry, 139 + void *data) 140 + { 141 + struct debugfs_read_work *w = data; 142 + 143 + wiphy_work_cancel(w->wiphy, &w->work); 144 + complete(&w->completion); 145 + } 146 + 147 + ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file, 148 + char *buf, size_t bufsize, 149 + char __user *userbuf, size_t count, 150 + loff_t *ppos, 151 + ssize_t (*handler)(struct wiphy *wiphy, 152 + struct file *file, 153 + char *buf, 154 + size_t bufsize, 155 + void *data), 156 + void *data) 157 + { 158 + struct debugfs_read_work work = { 159 + .handler = handler, 160 + .wiphy = wiphy, 161 + .file = file, 162 + .buf = buf, 163 + .bufsize = bufsize, 164 + .data = data, 165 + .ret = -ENODEV, 166 + .completion = COMPLETION_INITIALIZER_ONSTACK(work.completion), 167 + }; 168 + struct debugfs_cancellation cancellation = { 169 + .cancel = wiphy_locked_debugfs_read_cancel, 170 + .cancel_data = &work, 171 + }; 172 + 173 + /* don't leak stack data or whatever */ 174 + memset(buf, 0, bufsize); 175 + 176 + wiphy_work_init(&work.work, wiphy_locked_debugfs_read_work); 177 + wiphy_work_queue(wiphy, &work.work); 178 + 179 + debugfs_enter_cancellation(file, &cancellation); 180 + wait_for_completion(&work.completion); 181 + debugfs_leave_cancellation(file, &cancellation); 182 + 183 + if (work.ret < 0) 184 + return work.ret; 185 + 186 + if (WARN_ON(work.ret > bufsize)) 187 + return -EINVAL; 188 + 189 + return simple_read_from_buffer(userbuf, count, ppos, buf, work.ret); 190 + } 191 + EXPORT_SYMBOL_GPL(wiphy_locked_debugfs_read); 192 + 193 + struct debugfs_write_work { 194 + struct wiphy_work work; 195 + ssize_t (*handler)(struct wiphy *wiphy, 196 + struct file *file, 197 + char *buf, 198 + size_t count, 199 + void *data); 200 + struct wiphy *wiphy; 201 + struct file *file; 202 + char *buf; 203 + size_t count; 204 + void *data; 205 + ssize_t ret; 206 + struct completion completion; 207 + }; 208 + 209 + static void wiphy_locked_debugfs_write_work(struct wiphy *wiphy, 210 + struct wiphy_work *work) 211 + { 212 + struct debugfs_write_work *w = container_of(work, typeof(*w), work); 213 + 214 + w->ret = w->handler(w->wiphy, w->file, w->buf, w->count, w->data); 215 + complete(&w->completion); 216 + } 217 + 218 + static void wiphy_locked_debugfs_write_cancel(struct dentry *dentry, 219 + void *data) 220 + { 221 + struct debugfs_write_work *w = data; 222 + 223 + wiphy_work_cancel(w->wiphy, &w->work); 224 + complete(&w->completion); 225 + } 226 + 227 + ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy, 228 + struct file *file, char *buf, size_t bufsize, 229 + const char __user *userbuf, size_t count, 230 + ssize_t (*handler)(struct wiphy *wiphy, 231 + struct file *file, 232 + char *buf, 233 + size_t count, 234 + void *data), 235 + void *data) 236 + { 237 + struct debugfs_write_work work = { 238 + .handler = handler, 239 + .wiphy = wiphy, 240 + .file = file, 241 + .buf = buf, 242 + .count = count, 243 + .data = data, 244 + .ret = -ENODEV, 245 + .completion = COMPLETION_INITIALIZER_ONSTACK(work.completion), 246 + }; 247 + struct debugfs_cancellation cancellation = { 248 + .cancel = wiphy_locked_debugfs_write_cancel, 249 + .cancel_data = &work, 250 + }; 251 + 252 + /* mostly used for strings so enforce NUL-termination for safety */ 253 + if (count >= bufsize) 254 + return -EINVAL; 255 + 256 + memset(buf, 0, bufsize); 257 + 258 + if (copy_from_user(buf, userbuf, count)) 259 + return -EFAULT; 260 + 261 + wiphy_work_init(&work.work, wiphy_locked_debugfs_write_work); 262 + wiphy_work_queue(wiphy, &work.work); 263 + 264 + debugfs_enter_cancellation(file, &cancellation); 265 + wait_for_completion(&work.completion); 266 + debugfs_leave_cancellation(file, &cancellation); 267 + 268 + return work.ret; 269 + } 270 + EXPORT_SYMBOL_GPL(wiphy_locked_debugfs_write);
+36 -19
net/wireless/nl80211.c
··· 3822 3822 struct net_device *dev = wdev->netdev; 3823 3823 void *hdr; 3824 3824 3825 + lockdep_assert_wiphy(&rdev->wiphy); 3826 + 3825 3827 WARN_ON(cmd != NL80211_CMD_NEW_INTERFACE && 3826 3828 cmd != NL80211_CMD_DEL_INTERFACE && 3827 3829 cmd != NL80211_CMD_SET_INTERFACE); ··· 3991 3989 3992 3990 if_idx = 0; 3993 3991 3992 + wiphy_lock(&rdev->wiphy); 3994 3993 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { 3995 3994 if (if_idx < if_start) { 3996 3995 if_idx++; ··· 4001 3998 cb->nlh->nlmsg_seq, NLM_F_MULTI, 4002 3999 rdev, wdev, 4003 4000 NL80211_CMD_NEW_INTERFACE) < 0) { 4001 + wiphy_unlock(&rdev->wiphy); 4004 4002 goto out; 4005 4003 } 4006 4004 if_idx++; 4007 4005 } 4006 + wiphy_unlock(&rdev->wiphy); 4008 4007 4009 4008 wp_idx++; 4010 4009 } ··· 12792 12787 int i, n, low_index; 12793 12788 int err; 12794 12789 12795 - /* RSSI reporting disabled? */ 12796 - if (!cqm_config) 12797 - return rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0); 12798 - 12799 12790 /* 12800 12791 * Obtain current RSSI value if possible, if not and no RSSI threshold 12801 12792 * event has been received yet, we should receive an event after a ··· 12866 12865 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) 12867 12866 return -EOPNOTSUPP; 12868 12867 12869 - if (n_thresholds <= 1 && rdev->ops->set_cqm_rssi_config) { 12870 - if (n_thresholds == 0 || thresholds[0] == 0) /* Disabling */ 12871 - return rdev_set_cqm_rssi_config(rdev, dev, 0, 0); 12872 - 12873 - return rdev_set_cqm_rssi_config(rdev, dev, 12874 - thresholds[0], hysteresis); 12875 - } 12876 - 12877 - if (!wiphy_ext_feature_isset(&rdev->wiphy, 12878 - NL80211_EXT_FEATURE_CQM_RSSI_LIST)) 12879 - return -EOPNOTSUPP; 12880 - 12881 12868 if (n_thresholds == 1 && thresholds[0] == 0) /* Disabling */ 12882 12869 n_thresholds = 0; 12883 12870 12884 12871 old = wiphy_dereference(wdev->wiphy, wdev->cqm_config); 12872 + 12873 + /* if already disabled just succeed */ 12874 + if (!n_thresholds && !old) 12875 + return 0; 12876 + 12877 + if (n_thresholds > 1) { 12878 + if (!wiphy_ext_feature_isset(&rdev->wiphy, 12879 + NL80211_EXT_FEATURE_CQM_RSSI_LIST) || 12880 + !rdev->ops->set_cqm_rssi_range_config) 12881 + return -EOPNOTSUPP; 12882 + } else { 12883 + if (!rdev->ops->set_cqm_rssi_config) 12884 + return -EOPNOTSUPP; 12885 + } 12885 12886 12886 12887 if (n_thresholds) { 12887 12888 cqm_config = kzalloc(struct_size(cqm_config, rssi_thresholds, ··· 12897 12894 memcpy(cqm_config->rssi_thresholds, thresholds, 12898 12895 flex_array_size(cqm_config, rssi_thresholds, 12899 12896 n_thresholds)); 12897 + cqm_config->use_range_api = n_thresholds > 1 || 12898 + !rdev->ops->set_cqm_rssi_config; 12900 12899 12901 12900 rcu_assign_pointer(wdev->cqm_config, cqm_config); 12901 + 12902 + if (cqm_config->use_range_api) 12903 + err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config); 12904 + else 12905 + err = rdev_set_cqm_rssi_config(rdev, dev, 12906 + thresholds[0], 12907 + hysteresis); 12902 12908 } else { 12903 12909 RCU_INIT_POINTER(wdev->cqm_config, NULL); 12910 + /* if enabled as range also disable via range */ 12911 + if (old->use_range_api) 12912 + err = rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0); 12913 + else 12914 + err = rdev_set_cqm_rssi_config(rdev, dev, 0, 0); 12904 12915 } 12905 12916 12906 - err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config); 12907 12917 if (err) { 12908 12918 rcu_assign_pointer(wdev->cqm_config, old); 12909 12919 kfree_rcu(cqm_config, rcu_head); ··· 19025 19009 s32 rssi_level; 19026 19010 19027 19011 cqm_config = wiphy_dereference(wdev->wiphy, wdev->cqm_config); 19028 - if (!wdev->cqm_config) 19012 + if (!cqm_config) 19029 19013 return; 19030 19014 19031 - cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config); 19015 + if (cqm_config->use_range_api) 19016 + cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config); 19032 19017 19033 19018 rssi_level = cqm_config->last_rssi_event_value; 19034 19019 rssi_event = cqm_config->last_rssi_event_type;
+34 -17
tools/net/ynl/generated/ethtool-user.c
··· 1843 1843 int ethtool_linkinfo_set(struct ynl_sock *ys, 1844 1844 struct ethtool_linkinfo_set_req *req) 1845 1845 { 1846 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 1846 1847 struct nlmsghdr *nlh; 1847 1848 int err; 1848 1849 ··· 1863 1862 if (req->_present.transceiver) 1864 1863 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKINFO_TRANSCEIVER, req->transceiver); 1865 1864 1866 - err = ynl_exec(ys, nlh, NULL); 1865 + err = ynl_exec(ys, nlh, &yrs); 1867 1866 if (err < 0) 1868 1867 return -1; 1869 1868 ··· 2068 2067 int ethtool_linkmodes_set(struct ynl_sock *ys, 2069 2068 struct ethtool_linkmodes_set_req *req) 2070 2069 { 2070 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 2071 2071 struct nlmsghdr *nlh; 2072 2072 int err; 2073 2073 ··· 2096 2094 if (req->_present.rate_matching) 2097 2095 mnl_attr_put_u8(nlh, ETHTOOL_A_LINKMODES_RATE_MATCHING, req->rate_matching); 2098 2096 2099 - err = ynl_exec(ys, nlh, NULL); 2097 + err = ynl_exec(ys, nlh, &yrs); 2100 2098 if (err < 0) 2101 2099 return -1; 2102 2100 ··· 2400 2398 2401 2399 int ethtool_debug_set(struct ynl_sock *ys, struct ethtool_debug_set_req *req) 2402 2400 { 2401 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 2403 2402 struct nlmsghdr *nlh; 2404 2403 int err; 2405 2404 ··· 2412 2409 if (req->_present.msgmask) 2413 2410 ethtool_bitset_put(nlh, ETHTOOL_A_DEBUG_MSGMASK, &req->msgmask); 2414 2411 2415 - err = ynl_exec(ys, nlh, NULL); 2412 + err = ynl_exec(ys, nlh, &yrs); 2416 2413 if (err < 0) 2417 2414 return -1; 2418 2415 ··· 2580 2577 2581 2578 int ethtool_wol_set(struct ynl_sock *ys, struct ethtool_wol_set_req *req) 2582 2579 { 2580 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 2583 2581 struct nlmsghdr *nlh; 2584 2582 int err; 2585 2583 ··· 2594 2590 if (req->_present.sopass_len) 2595 2591 mnl_attr_put(nlh, ETHTOOL_A_WOL_SOPASS, req->_present.sopass_len, req->sopass); 2596 2592 2597 - err = ynl_exec(ys, nlh, NULL); 2593 + err = ynl_exec(ys, nlh, &yrs); 2598 2594 if (err < 0) 2599 2595 return -1; 2600 2596 ··· 3049 3045 int ethtool_privflags_set(struct ynl_sock *ys, 3050 3046 struct ethtool_privflags_set_req *req) 3051 3047 { 3048 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 3052 3049 struct nlmsghdr *nlh; 3053 3050 int err; 3054 3051 ··· 3061 3056 if (req->_present.flags) 3062 3057 ethtool_bitset_put(nlh, ETHTOOL_A_PRIVFLAGS_FLAGS, &req->flags); 3063 3058 3064 - err = ynl_exec(ys, nlh, NULL); 3059 + err = ynl_exec(ys, nlh, &yrs); 3065 3060 if (err < 0) 3066 3061 return -1; 3067 3062 ··· 3278 3273 3279 3274 int ethtool_rings_set(struct ynl_sock *ys, struct ethtool_rings_set_req *req) 3280 3275 { 3276 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 3281 3277 struct nlmsghdr *nlh; 3282 3278 int err; 3283 3279 ··· 3318 3312 if (req->_present.tx_push_buf_len_max) 3319 3313 mnl_attr_put_u32(nlh, ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX, req->tx_push_buf_len_max); 3320 3314 3321 - err = ynl_exec(ys, nlh, NULL); 3315 + err = ynl_exec(ys, nlh, &yrs); 3322 3316 if (err < 0) 3323 3317 return -1; 3324 3318 ··· 3501 3495 int ethtool_channels_set(struct ynl_sock *ys, 3502 3496 struct ethtool_channels_set_req *req) 3503 3497 { 3498 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 3504 3499 struct nlmsghdr *nlh; 3505 3500 int err; 3506 3501 ··· 3527 3520 if (req->_present.combined_count) 3528 3521 mnl_attr_put_u32(nlh, ETHTOOL_A_CHANNELS_COMBINED_COUNT, req->combined_count); 3529 3522 3530 - err = ynl_exec(ys, nlh, NULL); 3523 + err = ynl_exec(ys, nlh, &yrs); 3531 3524 if (err < 0) 3532 3525 return -1; 3533 3526 ··· 3805 3798 int ethtool_coalesce_set(struct ynl_sock *ys, 3806 3799 struct ethtool_coalesce_set_req *req) 3807 3800 { 3801 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 3808 3802 struct nlmsghdr *nlh; 3809 3803 int err; 3810 3804 ··· 3869 3861 if (req->_present.tx_aggr_time_usecs) 3870 3862 mnl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS, req->tx_aggr_time_usecs); 3871 3863 3872 - err = ynl_exec(ys, nlh, NULL); 3864 + err = ynl_exec(ys, nlh, &yrs); 3873 3865 if (err < 0) 3874 3866 return -1; 3875 3867 ··· 4044 4036 4045 4037 int ethtool_pause_set(struct ynl_sock *ys, struct ethtool_pause_set_req *req) 4046 4038 { 4039 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4047 4040 struct nlmsghdr *nlh; 4048 4041 int err; 4049 4042 ··· 4064 4055 if (req->_present.stats_src) 4065 4056 mnl_attr_put_u32(nlh, ETHTOOL_A_PAUSE_STATS_SRC, req->stats_src); 4066 4057 4067 - err = ynl_exec(ys, nlh, NULL); 4058 + err = ynl_exec(ys, nlh, &yrs); 4068 4059 if (err < 0) 4069 4060 return -1; 4070 4061 ··· 4251 4242 4252 4243 int ethtool_eee_set(struct ynl_sock *ys, struct ethtool_eee_set_req *req) 4253 4244 { 4245 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4254 4246 struct nlmsghdr *nlh; 4255 4247 int err; 4256 4248 ··· 4273 4263 if (req->_present.tx_lpi_timer) 4274 4264 mnl_attr_put_u32(nlh, ETHTOOL_A_EEE_TX_LPI_TIMER, req->tx_lpi_timer); 4275 4265 4276 - err = ynl_exec(ys, nlh, NULL); 4266 + err = ynl_exec(ys, nlh, &yrs); 4277 4267 if (err < 0) 4278 4268 return -1; 4279 4269 ··· 4447 4437 int ethtool_cable_test_act(struct ynl_sock *ys, 4448 4438 struct ethtool_cable_test_act_req *req) 4449 4439 { 4440 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4450 4441 struct nlmsghdr *nlh; 4451 4442 int err; 4452 4443 ··· 4457 4446 if (req->_present.header) 4458 4447 ethtool_header_put(nlh, ETHTOOL_A_CABLE_TEST_HEADER, &req->header); 4459 4448 4460 - err = ynl_exec(ys, nlh, NULL); 4449 + err = ynl_exec(ys, nlh, &yrs); 4461 4450 if (err < 0) 4462 4451 return -1; 4463 4452 ··· 4476 4465 int ethtool_cable_test_tdr_act(struct ynl_sock *ys, 4477 4466 struct ethtool_cable_test_tdr_act_req *req) 4478 4467 { 4468 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4479 4469 struct nlmsghdr *nlh; 4480 4470 int err; 4481 4471 ··· 4486 4474 if (req->_present.header) 4487 4475 ethtool_header_put(nlh, ETHTOOL_A_CABLE_TEST_TDR_HEADER, &req->header); 4488 4476 4489 - err = ynl_exec(ys, nlh, NULL); 4477 + err = ynl_exec(ys, nlh, &yrs); 4490 4478 if (err < 0) 4491 4479 return -1; 4492 4480 ··· 4794 4782 4795 4783 int ethtool_fec_set(struct ynl_sock *ys, struct ethtool_fec_set_req *req) 4796 4784 { 4785 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 4797 4786 struct nlmsghdr *nlh; 4798 4787 int err; 4799 4788 ··· 4812 4799 if (req->_present.stats) 4813 4800 ethtool_fec_stat_put(nlh, ETHTOOL_A_FEC_STATS, &req->stats); 4814 4801 4815 - err = ynl_exec(ys, nlh, NULL); 4802 + err = ynl_exec(ys, nlh, &yrs); 4816 4803 if (err < 0) 4817 4804 return -1; 4818 4805 ··· 5248 5235 5249 5236 int ethtool_module_set(struct ynl_sock *ys, struct ethtool_module_set_req *req) 5250 5237 { 5238 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 5251 5239 struct nlmsghdr *nlh; 5252 5240 int err; 5253 5241 ··· 5262 5248 if (req->_present.power_mode) 5263 5249 mnl_attr_put_u8(nlh, ETHTOOL_A_MODULE_POWER_MODE, req->power_mode); 5264 5250 5265 - err = ynl_exec(ys, nlh, NULL); 5251 + err = ynl_exec(ys, nlh, &yrs); 5266 5252 if (err < 0) 5267 5253 return -1; 5268 5254 ··· 5411 5397 5412 5398 int ethtool_pse_set(struct ynl_sock *ys, struct ethtool_pse_set_req *req) 5413 5399 { 5400 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 5414 5401 struct nlmsghdr *nlh; 5415 5402 int err; 5416 5403 ··· 5427 5412 if (req->_present.pw_d_status) 5428 5413 mnl_attr_put_u32(nlh, ETHTOOL_A_PODL_PSE_PW_D_STATUS, req->pw_d_status); 5429 5414 5430 - err = ynl_exec(ys, nlh, NULL); 5415 + err = ynl_exec(ys, nlh, &yrs); 5431 5416 if (err < 0) 5432 5417 return -1; 5433 5418 ··· 5761 5746 int ethtool_plca_set_cfg(struct ynl_sock *ys, 5762 5747 struct ethtool_plca_set_cfg_req *req) 5763 5748 { 5749 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 5764 5750 struct nlmsghdr *nlh; 5765 5751 int err; 5766 5752 ··· 5787 5771 if (req->_present.burst_tmr) 5788 5772 mnl_attr_put_u32(nlh, ETHTOOL_A_PLCA_BURST_TMR, req->burst_tmr); 5789 5773 5790 - err = ynl_exec(ys, nlh, NULL); 5774 + err = ynl_exec(ys, nlh, &yrs); 5791 5775 if (err < 0) 5792 5776 return -1; 5793 5777 ··· 6140 6124 6141 6125 int ethtool_mm_set(struct ynl_sock *ys, struct ethtool_mm_set_req *req) 6142 6126 { 6127 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 6143 6128 struct nlmsghdr *nlh; 6144 6129 int err; 6145 6130 ··· 6160 6143 if (req->_present.tx_min_frag_size) 6161 6144 mnl_attr_put_u32(nlh, ETHTOOL_A_MM_TX_MIN_FRAG_SIZE, req->tx_min_frag_size); 6162 6145 6163 - err = ynl_exec(ys, nlh, NULL); 6146 + err = ynl_exec(ys, nlh, &yrs); 6164 6147 if (err < 0) 6165 6148 return -1; 6166 6149
+4 -2
tools/net/ynl/generated/fou-user.c
··· 72 72 73 73 int fou_add(struct ynl_sock *ys, struct fou_add_req *req) 74 74 { 75 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 75 76 struct nlmsghdr *nlh; 76 77 int err; 77 78 ··· 100 99 if (req->_present.ifindex) 101 100 mnl_attr_put_u32(nlh, FOU_ATTR_IFINDEX, req->ifindex); 102 101 103 - err = ynl_exec(ys, nlh, NULL); 102 + err = ynl_exec(ys, nlh, &yrs); 104 103 if (err < 0) 105 104 return -1; 106 105 ··· 118 117 119 118 int fou_del(struct ynl_sock *ys, struct fou_del_req *req) 120 119 { 120 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 121 121 struct nlmsghdr *nlh; 122 122 int err; 123 123 ··· 142 140 if (req->_present.peer_v6_len) 143 141 mnl_attr_put(nlh, FOU_ATTR_PEER_V6, req->_present.peer_v6_len, req->peer_v6); 144 142 145 - err = ynl_exec(ys, nlh, NULL); 143 + err = ynl_exec(ys, nlh, &yrs); 146 144 if (err < 0) 147 145 return -1; 148 146
+2 -1
tools/net/ynl/generated/handshake-user.c
··· 295 295 296 296 int handshake_done(struct ynl_sock *ys, struct handshake_done_req *req) 297 297 { 298 + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; 298 299 struct nlmsghdr *nlh; 299 300 int err; 300 301 ··· 309 308 for (unsigned int i = 0; i < req->n_remote_auth; i++) 310 309 mnl_attr_put_u32(nlh, HANDSHAKE_A_DONE_REMOTE_AUTH, req->remote_auth[i]); 311 310 312 - err = ynl_exec(ys, nlh, NULL); 311 + err = ynl_exec(ys, nlh, &yrs); 313 312 if (err < 0) 314 313 return -1; 315 314
+4 -6
tools/net/ynl/ynl-gen-c.py
··· 1709 1709 ret_ok = '0' 1710 1710 ret_err = '-1' 1711 1711 direction = "request" 1712 - local_vars = ['struct nlmsghdr *nlh;', 1712 + local_vars = ['struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };', 1713 + 'struct nlmsghdr *nlh;', 1713 1714 'int err;'] 1714 1715 1715 1716 if 'reply' in ri.op[ri.op_mode]: 1716 1717 ret_ok = 'rsp' 1717 1718 ret_err = 'NULL' 1718 - local_vars += [f'{type_name(ri, rdir(direction))} *rsp;', 1719 - 'struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };'] 1719 + local_vars += [f'{type_name(ri, rdir(direction))} *rsp;'] 1720 1720 1721 1721 print_prototype(ri, direction, terminate=False) 1722 1722 ri.cw.block_start() ··· 1732 1732 attr.attr_put(ri, "req") 1733 1733 ri.cw.nl() 1734 1734 1735 - parse_arg = "NULL" 1736 1735 if 'reply' in ri.op[ri.op_mode]: 1737 1736 ri.cw.p('rsp = calloc(1, sizeof(*rsp));') 1738 1737 ri.cw.p('yrs.yarg.data = rsp;') ··· 1741 1742 else: 1742 1743 ri.cw.p(f'yrs.rsp_cmd = {ri.op.rsp_value};') 1743 1744 ri.cw.nl() 1744 - parse_arg = '&yrs' 1745 - ri.cw.p(f"err = ynl_exec(ys, nlh, {parse_arg});") 1745 + ri.cw.p("err = ynl_exec(ys, nlh, &yrs);") 1746 1746 ri.cw.p('if (err < 0)') 1747 1747 if 'reply' in ri.op[ri.op_mode]: 1748 1748 ri.cw.p('goto err_free;')
+40 -11
tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
··· 1337 1337 } 1338 1338 1339 1339 static void pairs_redir_to_connected(int cli0, int peer0, int cli1, int peer1, 1340 - int sock_mapfd, int verd_mapfd, enum redir_mode mode) 1340 + int sock_mapfd, int nop_mapfd, 1341 + int verd_mapfd, enum redir_mode mode) 1341 1342 { 1342 1343 const char *log_prefix = redir_mode_str(mode); 1343 1344 unsigned int pass; ··· 1351 1350 err = add_to_sockmap(sock_mapfd, peer0, peer1); 1352 1351 if (err) 1353 1352 return; 1353 + 1354 + if (nop_mapfd >= 0) { 1355 + err = add_to_sockmap(nop_mapfd, cli0, cli1); 1356 + if (err) 1357 + return; 1358 + } 1354 1359 1355 1360 n = write(cli1, "a", 1); 1356 1361 if (n < 0) ··· 1394 1387 goto close0; 1395 1388 c1 = sfd[0], p1 = sfd[1]; 1396 1389 1397 - pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, verd_mapfd, mode); 1390 + pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, -1, verd_mapfd, mode); 1398 1391 1399 1392 xclose(c1); 1400 1393 xclose(p1); ··· 1684 1677 if (err) 1685 1678 goto close_cli0; 1686 1679 1687 - pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, verd_mapfd, mode); 1680 + pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, -1, verd_mapfd, mode); 1688 1681 1689 1682 xclose(c1); 1690 1683 xclose(p1); ··· 1742 1735 if (err) 1743 1736 goto close; 1744 1737 1745 - pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, verd_mapfd, mode); 1738 + pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, -1, verd_mapfd, mode); 1746 1739 1747 1740 xclose(c1); 1748 1741 xclose(p1); ··· 1777 1770 xbpf_prog_detach2(verdict, sock_map, BPF_SK_SKB_VERDICT); 1778 1771 } 1779 1772 1780 - static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd, 1781 - int verd_mapfd, enum redir_mode mode) 1773 + static void unix_inet_redir_to_connected(int family, int type, 1774 + int sock_mapfd, int nop_mapfd, 1775 + int verd_mapfd, 1776 + enum redir_mode mode) 1782 1777 { 1783 1778 int c0, c1, p0, p1; 1784 1779 int sfd[2]; ··· 1794 1785 goto close_cli0; 1795 1786 c1 = sfd[0], p1 = sfd[1]; 1796 1787 1797 - pairs_redir_to_connected(c0, p0, c1, p1, sock_mapfd, verd_mapfd, mode); 1788 + pairs_redir_to_connected(c0, p0, c1, p1, 1789 + sock_mapfd, nop_mapfd, verd_mapfd, mode); 1798 1790 1799 1791 xclose(c1); 1800 1792 xclose(p1); ··· 1809 1799 struct bpf_map *inner_map, int family) 1810 1800 { 1811 1801 int verdict = bpf_program__fd(skel->progs.prog_skb_verdict); 1802 + int nop_map = bpf_map__fd(skel->maps.nop_map); 1812 1803 int verdict_map = bpf_map__fd(skel->maps.verdict_map); 1813 1804 int sock_map = bpf_map__fd(inner_map); 1814 1805 int err; ··· 1819 1808 return; 1820 1809 1821 1810 skel->bss->test_ingress = false; 1822 - unix_inet_redir_to_connected(family, SOCK_DGRAM, sock_map, verdict_map, 1811 + unix_inet_redir_to_connected(family, SOCK_DGRAM, 1812 + sock_map, -1, verdict_map, 1823 1813 REDIR_EGRESS); 1824 - unix_inet_redir_to_connected(family, SOCK_STREAM, sock_map, verdict_map, 1814 + unix_inet_redir_to_connected(family, SOCK_DGRAM, 1815 + sock_map, -1, verdict_map, 1816 + REDIR_EGRESS); 1817 + 1818 + unix_inet_redir_to_connected(family, SOCK_DGRAM, 1819 + sock_map, nop_map, verdict_map, 1820 + REDIR_EGRESS); 1821 + unix_inet_redir_to_connected(family, SOCK_STREAM, 1822 + sock_map, nop_map, verdict_map, 1825 1823 REDIR_EGRESS); 1826 1824 skel->bss->test_ingress = true; 1827 - unix_inet_redir_to_connected(family, SOCK_DGRAM, sock_map, verdict_map, 1825 + unix_inet_redir_to_connected(family, SOCK_DGRAM, 1826 + sock_map, -1, verdict_map, 1828 1827 REDIR_INGRESS); 1829 - unix_inet_redir_to_connected(family, SOCK_STREAM, sock_map, verdict_map, 1828 + unix_inet_redir_to_connected(family, SOCK_STREAM, 1829 + sock_map, -1, verdict_map, 1830 + REDIR_INGRESS); 1831 + 1832 + unix_inet_redir_to_connected(family, SOCK_DGRAM, 1833 + sock_map, nop_map, verdict_map, 1834 + REDIR_INGRESS); 1835 + unix_inet_redir_to_connected(family, SOCK_STREAM, 1836 + sock_map, nop_map, verdict_map, 1830 1837 REDIR_INGRESS); 1831 1838 1832 1839 xbpf_prog_detach2(verdict, sock_map, BPF_SK_SKB_VERDICT);
+7
tools/testing/selftests/bpf/progs/test_sockmap_listen.c
··· 15 15 } sock_map SEC(".maps"); 16 16 17 17 struct { 18 + __uint(type, BPF_MAP_TYPE_SOCKMAP); 19 + __uint(max_entries, 2); 20 + __type(key, __u32); 21 + __type(value, __u64); 22 + } nop_map SEC(".maps"); 23 + 24 + struct { 18 25 __uint(type, BPF_MAP_TYPE_SOCKHASH); 19 26 __uint(max_entries, 2); 20 27 __type(key, __u32);
-1
tools/testing/selftests/net/af_unix/diag_uid.c
··· 148 148 .msg_iov = &iov, 149 149 .msg_iovlen = 1 150 150 }; 151 - struct unix_diag_req *udr; 152 151 struct nlmsghdr *nlh; 153 152 int ret; 154 153
+1 -1
tools/testing/selftests/net/cmsg_sender.c
··· 416 416 { 417 417 struct addrinfo hints, *ai; 418 418 struct iovec iov[1]; 419 + unsigned char *buf; 419 420 struct msghdr msg; 420 421 char cbuf[1024]; 421 - char *buf; 422 422 int err; 423 423 int fd; 424 424
+2 -2
tools/testing/selftests/net/ipsec.c
··· 2263 2263 2264 2264 int main(int argc, char **argv) 2265 2265 { 2266 - unsigned int nr_process = 1; 2266 + long nr_process = 1; 2267 2267 int route_sock = -1, ret = KSFT_SKIP; 2268 2268 int test_desc_fd[2]; 2269 2269 uint32_t route_seq; ··· 2284 2284 exit_usage(argv); 2285 2285 } 2286 2286 2287 - if (nr_process > MAX_PROCESSES || !nr_process) { 2287 + if (nr_process > MAX_PROCESSES || nr_process < 1) { 2288 2288 printk("nr_process should be between [1; %u]", 2289 2289 MAX_PROCESSES); 2290 2290 exit_usage(argv);
+4 -7
tools/testing/selftests/net/mptcp/mptcp_connect.c
··· 18 18 19 19 #include <sys/ioctl.h> 20 20 #include <sys/poll.h> 21 + #include <sys/random.h> 21 22 #include <sys/sendfile.h> 22 23 #include <sys/stat.h> 23 24 #include <sys/socket.h> ··· 1126 1125 1127 1126 static void init_rng(void) 1128 1127 { 1129 - int fd = open("/dev/urandom", O_RDONLY); 1130 1128 unsigned int foo; 1131 1129 1132 - if (fd > 0) { 1133 - int ret = read(fd, &foo, sizeof(foo)); 1134 - 1135 - if (ret < 0) 1136 - srand(fd + foo); 1137 - close(fd); 1130 + if (getrandom(&foo, sizeof(foo), 0) == -1) { 1131 + perror("getrandom"); 1132 + exit(1); 1138 1133 } 1139 1134 1140 1135 srand(foo);
+4 -7
tools/testing/selftests/net/mptcp/mptcp_inq.c
··· 18 18 #include <time.h> 19 19 20 20 #include <sys/ioctl.h> 21 + #include <sys/random.h> 21 22 #include <sys/socket.h> 22 23 #include <sys/types.h> 23 24 #include <sys/wait.h> ··· 520 519 521 520 static void init_rng(void) 522 521 { 523 - int fd = open("/dev/urandom", O_RDONLY); 524 522 unsigned int foo; 525 523 526 - if (fd > 0) { 527 - int ret = read(fd, &foo, sizeof(foo)); 528 - 529 - if (ret < 0) 530 - srand(fd + foo); 531 - close(fd); 524 + if (getrandom(&foo, sizeof(foo), 0) == -1) { 525 + perror("getrandom"); 526 + exit(1); 532 527 } 533 528 534 529 srand(foo);