6.18.40-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 943/1611 net: hns3: unify copper port ksettings configuration path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuaisong Yang <[email protected]>
[ Upstream commit d77e98f8b2b382b06be7f17e482480dd8c4c5046 ]
Refactor hns3_set_link_ksettings() and hclge_set_phy_link_ksettings() to unify the configuration path for copper ports.
Previously, netdevs with a native kernel phy attached bypassed the main MAC parameter caching logic and returned early via phy_ethtool_ksettings_set(). This prevented the driver from updating hdev->hw.mac.req_xxx variables for kernel PHY setups, leaving them out-of-sync during reset recovery.
Clean this up by routing all copper port configurations through ops->set_phy_link_ksettings(), and perform driver-level or kernel-level PHY arbitration inside hclge_set_phy_link_ksettings() via hnae3_dev_phy_imp_supported(). This ensures that the user's intended link profiles (req_speed, req_duplex, req_autoneg) are uniformly recorded across all copper and fiber deployment topologies, laying the groundwork for stable reset recovery.
For copper ports where neither IMP firmware nor a kernel PHY is available (e.g. PHY_INEXISTENT), hclge_set_phy_link_ksettings() returns -ENODEV. In hns3_set_link_ksettings(), this is caught so the configuration falls through to the existing MAC-level path (check_ksettings_param -> cfg_mac_speed_dup_h), preserving compatibility with PHY-less copper deployments.
Stable-dep-of: c711f6d1cee9 ("net: hns3: fix permanent link down deadlock after reset")
--- .../ethernet/hisilicon/hns3/hns3_ethtool.c | 31 +++++++++---------- .../hisilicon/hns3/hns3pf/hclge_main.c | 28 +++++++++++++++-- 2 files changed, 40 insertions(+), 19 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +15 -16
@@ -811,12 +811,11 @@ static int hns3_get_link_ksettings(struct net_device *netdev, }static int hns3_check_ksettings_param (const struct net_device *netdev, -const struct ethtool_link_ksettings *cmd) +const struct ethtool_link_ksettings *cmd, +u8 media_type) {struct hnae3_handle *handle =hns3_get_handle (netdev);const struct hnae3_ae_ops *ops =hns3_get_ops (handle); -u8 module_type =HNAE3_MODULE_TYPE_UNKNOWN ; -u8 media_type =HNAE3_MEDIA_TYPE_UNKNOWN ;u32 lane_num;u8 autoneg;u32 speed;
@@ -836,9 +835,6 @@ static int hns3_check_ksettings_param(const struct net_device *netdev,return 0 ; } -if (ops->get_media_type) - ops->get_media_type (handle, &media_type, &module_type); -if (cmd->base.duplex ==DUPLEX_HALF && media_type !=HNAE3_MEDIA_TYPE_COPPER ) { netdev_err(netdev,
@@ -863,6 +859,8 @@ static int hns3_set_link_ksettings(struct net_device *netdev,struct hnae3_handle *handle =hns3_get_handle (netdev);struct hnae3_ae_dev *ae_dev =hns3_get_ae_dev (handle);const struct hnae3_ae_ops *ops =hns3_get_ops (handle); +u8 module_type =HNAE3_MODULE_TYPE_UNKNOWN ; +u8 media_type =HNAE3_MEDIA_TYPE_UNKNOWN ;int ret;/* Chip don't support this mode. */
@@ -878,22 +876,23 @@ static int hns3_set_link_ksettings(struct net_device *netdev, cmd->base.autoneg, cmd->base.speed, cmd->base.duplex, cmd->lanes); -/* Only support ksettings_set for netdev with phy attached for now */ -if (netdev->phydev) { -if (cmd->base.speed ==SPEED_1000 && - cmd->base.autoneg ==AUTONEG_DISABLE ) -return -EINVAL ; +if (!ops->get_media_type) +return -EOPNOTSUPP ; + ops->get_media_type (handle, &media_type, &module_type); -return phy_ethtool_ksettings_set (netdev->phydev, cmd); - }else if (test_bit (HNAE3_DEV_SUPPORT_PHY_IMP_B , ae_dev->caps) && - ops->set_phy_link_ksettings) { -return ops->set_phy_link_ksettings (handle, cmd); +if (media_type ==HNAE3_MEDIA_TYPE_COPPER ) { +if (!ops->set_phy_link_ksettings) +return -EOPNOTSUPP ; + ret = ops->set_phy_link_ksettings (handle, cmd); +if (ret != -ENODEV ) +return ret; +/* PHY_INEXISTENT, use MAC-level configuration */ }if (ae_dev->dev_version <HNAE3_DEVICE_VERSION_V2 )return -EOPNOTSUPP ; - ret =hns3_check_ksettings_param (netdev, cmd); + ret =hns3_check_ksettings_param (netdev, cmd, media_type);if (ret)return ret;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +25 -3
@@ -3358,8 +3358,8 @@ static int hclge_get_phy_link_ksettings(struct hnae3_handle *handle, }static int -hclge_set_phy_link_ksettings (struct hnae3_handle *handle, -const struct ethtool_link_ksettings *cmd) +hclge_ethtool_ksettings_set (struct hnae3_handle *handle, +const struct ethtool_link_ksettings *cmd) {struct hclge_desc desc[HCLGE_PHY_LINK_SETTING_BD_NUM ];struct hclge_vport *vport =hclge_get_vport (handle);
@@ -3400,10 +3400,32 @@ hclge_set_phy_link_ksettings(struct hnae3_handle *handle,return ret; } +linkmode_copy (hdev->hw.mac.advertising, cmd->link_modes.advertising); +return 0 ; +} + +static int +hclge_set_phy_link_ksettings (struct hnae3_handle *handle, +const struct ethtool_link_ksettings *cmd) +{ +struct hclge_vport *vport =hclge_get_vport (handle); +struct hclge_dev *hdev = vport->back; +int ret = -ENODEV ; + +if (hnae3_dev_phy_imp_supported (hdev)) { + ret =hclge_ethtool_ksettings_set (handle, cmd); + }else if (handle->netdev->phydev) { +if (cmd->base.speed ==SPEED_1000 && + cmd->base.autoneg ==AUTONEG_DISABLE ) +return -EINVAL ; + ret =phy_ethtool_ksettings_set (handle->netdev->phydev, cmd); + } +if (ret) +return ret; + hdev->hw.mac.req_autoneg = cmd->base.autoneg; hdev->hw.mac.req_speed = cmd->base.speed; hdev->hw.mac.req_duplex = cmd->base.duplex; -linkmode_copy (hdev->hw.mac.advertising, cmd->link_modes.advertising);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 944/1611 net: hns3: refactor MAC autoneg and speed configuration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuaisong Yang <[email protected]>
[ Upstream commit c01f6e6bdc1ccd21b2d07d23f50b82437b8cbf88 ]
Extract the MAC autoneg and speed/duplex/lane configuration logic out of hclge_mac_init() and encapsulate it into a new dedicated helper function hclge_set_autoneg_speed_dup().
In the init path (hclge_init_ae_dev), this helper is now called after hclge_update_port_info() so that firmware-reported autoneg values are already populated before applying the link configuration.
Introduce a separate req_lane_num field in struct hclge_mac to isolate the user-requested lane count from mac.lane_num, which firmware may overwrite via hclge_get_sfp_info() with stale values from a prior link lifecycle (e.g., lane_num=4 from 100G). During probe, req_lane_num is initialized to 0, which instructs firmware to auto-select the correct lane count for the current speed, rather than reusing the firmware- reported mac.lane_num that may be inconsistent with the target speed. This prevents probe failures from mismatched (speed, lane_num) pairs.
In the reset path (hclge_reset_ae_dev), it runs immediately after hclge_mac_init(), using the previously cached req_* values to restore the link without re-querying firmware.
Stable-dep-of: c711f6d1cee9 ("net: hns3: fix permanent link down deadlock after reset")
--- .../hisilicon/hns3/hns3pf/hclge_main.c | 55 ++++++++++++++----- .../hisilicon/hns3/hns3pf/hclge_main.h | 1 + 2 files changed, 42 insertions(+), 14 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +41 -14
@@ -1577,6 +1577,11 @@ static int hclge_configure(struct hclge_dev *hdev) hdev->hw.mac.req_autoneg =AUTONEG_ENABLE ; hdev->hw.mac.req_duplex =DUPLEX_FULL ; +/* When lane_num is 0, the firmware will automatically +* select the appropriate lane_num based on the speed. +*/ + hdev->hw.mac.req_lane_num =0 ; +hclge_parse_link_mode (hdev, cfg.speed_ability); hdev->hw.mac.max_speed =hclge_get_max_speed (cfg.speed_ability);
@@ -2652,6 +2657,7 @@ static int hclge_cfg_mac_speed_dup_h(struct hnae3_handle *handle, int speed,if (ret)return ret; + hdev->hw.mac.req_lane_num = lane_num; hdev->hw.mac.req_speed = (u32 )speed; hdev->hw.mac.req_duplex = duplex;
@@ -2957,20 +2963,6 @@ static int hclge_mac_init(struct hclge_dev *hdev)if (!test_bit (HCLGE_STATE_RST_HANDLING , &hdev->state)) hdev->hw.mac.duplex =HCLGE_MAC_FULL ; -if (hdev->hw.mac.support_autoneg) { - ret =hclge_set_autoneg_en (hdev, hdev->hw.mac.autoneg); -if (ret) -return ret; - } - -if (!hdev->hw.mac.autoneg) { - ret =hclge_cfg_mac_speed_dup_hw (hdev, hdev->hw.mac.req_speed, - hdev->hw.mac.req_duplex, - hdev->hw.mac.lane_num); -if (ret) -return ret; - } - mac->link =0 ;if (mac->user_fec_mode &BIT (HNAE3_FEC_USER_DEF )) {
@@ -11748,6 +11740,27 @@ static int hclge_set_wol(struct hnae3_handle *handle,return ret; } +static int hclge_set_autoneg_speed_dup (struct hclge_dev *hdev) +{ +int ret; + +if (hdev->hw.mac.support_autoneg) { + ret =hclge_set_autoneg_en (hdev, hdev->hw.mac.autoneg); +if (ret) +return ret; + } + +if (!hdev->hw.mac.autoneg) { + ret =hclge_cfg_mac_speed_dup_hw (hdev, hdev->hw.mac.req_speed, + hdev->hw.mac.req_duplex, + hdev->hw.mac.req_lane_num); +if (ret) +return ret; + } + +return 0 ; +} +static int hclge_init_ae_dev (struct hnae3_ae_dev *ae_dev) {struct pci_dev *pdev = ae_dev->pdev;
@@ -11909,6 +11922,13 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)if (ret) goto err_ptp_uninit; + ret =hclge_set_autoneg_speed_dup (hdev); +if (ret) { +dev_err (&pdev->dev, +"failed to set autoneg speed duplex, ret = %d\n" , ret); + goto err_ptp_uninit; + } +INIT_KFIFO (hdev->mac_tnl_log);hclge_dcb_ops_set (hdev);
@@ -12239,6 +12259,13 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev)return ret; } + ret =hclge_set_autoneg_speed_dup (hdev); +if (ret) { +dev_err (&pdev->dev, +"failed to set autoneg speed duplex, ret = %d\n" , ret); +return ret; + } + ret =hclge_tp_port_init (hdev);if (ret) { dev_err(&pdev->dev, "failed to init tp port, ret = %d\n",
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +1 -0
@@ -287,6 +287,7 @@ struct hclge_mac {u8 support_autoneg;u8 speed_type;/* 0: sfp speed, 1: active speed */ u8 lane_num; +u8 req_lane_num;u32 speed;u32 req_speed;u32 max_speed;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 945/1611 net: hns3: fix permanent link down deadlock after reset
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuaisong Yang <[email protected]>
[ Upstream commit c711f6d1cee955e04d1cd1f76cd8abd024b27a72 ]
Fix a critical race condition deadlock where the network interface remains permanently Link Down after a hardware reset under specific ethtool sequences.
This issue exclusively manifests in firmware-controlled PHY topologies where the driver relies on the IMP firmware to arbitrate link parameters. Standard devices driven by the kernel's native PHY_LIB are unaffected.
The deadlock occurs via the following path:
1. User disables autoneg and forces an unmatched speed, forcing link
down: ethtool -s ethx autoneg off speed 10 duplex full
2. User re-enables autoneg: ethtool -s ethx autoneg on. The netdev stack passes cmd->base.speed as SPEED_UNKNOWN (0xffffffff).
3. Driver saves req_autoneg=1, but before the interface can link up, a hardware reset is triggered.
4. During reset recovery, MAC init reads the un-synchronized runtime state mac.autoneg (which is still 0/OFF), misinterprets it as forced mode, and pushes the cached SPEED_UNKNOWN into the hardware registers, causing the MAC firmware state machine to freeze. Meanwhile, PHY init reads req_autoneg=1 and enables PHY autoneg.
Since the MAC is frozen with 0xffffffff and PHY is running autoneg, they mismatch permanently.
Fix this by:
1. Intercepting SPEED_UNKNOWN/DUPLEX_UNKNOWN in hclge_set_phy_link_ksettings() and hclge_cfg_mac_speed_dup_h() to prevent it from corrupting the driver's cached valid configuration.
2. Save req_autoneg in hclge_set_autoneg().
3. Aligning the state judgment in hclge_set_autoneg_speed_dup() to use req_autoneg instead of the un-synchronized runtime mac.autoneg, ensuring both MAC and PHY consistently enter the autoneg branch to eliminate configuration discrepancies during reset recovery.
--- .../hisilicon/hns3/hns3pf/hclge_main.c | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +15 -7
@@ -2658,8 +2658,10 @@ static int hclge_cfg_mac_speed_dup_h(struct hnae3_handle *handle, int speed,return ret; hdev->hw.mac.req_lane_num = lane_num; - hdev->hw.mac.req_speed = (u32 )speed; - hdev->hw.mac.req_duplex = duplex; +if (speed !=SPEED_UNKNOWN ) + hdev->hw.mac.req_speed = (u32 )speed; +if (duplex !=DUPLEX_UNKNOWN ) + hdev->hw.mac.req_duplex = duplex;return 0 ; }
@@ -2690,6 +2692,7 @@ static int hclge_set_autoneg(struct hnae3_handle *handle, bool enable) {struct hclge_vport *vport =hclge_get_vport (handle);struct hclge_dev *hdev = vport->back; +int ret;if (!hdev->hw.mac.support_autoneg) {if (enable) {
@@ -2701,7 +2704,10 @@ static int hclge_set_autoneg(struct hnae3_handle *handle, bool enable) } } -return hclge_set_autoneg_en (hdev, enable); + ret =hclge_set_autoneg_en (hdev, enable); +if (!ret) + hdev->hw.mac.req_autoneg = enable; +return ret; }static int hclge_get_autoneg (struct hnae3_handle *handle)
@@ -3416,8 +3422,10 @@ hclge_set_phy_link_ksettings(struct hnae3_handle *handle,return ret; hdev->hw.mac.req_autoneg = cmd->base.autoneg; - hdev->hw.mac.req_speed = cmd->base.speed; - hdev->hw.mac.req_duplex = cmd->base.duplex; +if (cmd->base.speed !=SPEED_UNKNOWN ) + hdev->hw.mac.req_speed = cmd->base.speed; +if (cmd->base.duplex !=DUPLEX_UNKNOWN ) + hdev->hw.mac.req_duplex = cmd->base.duplex;return 0 ; }
@@ -11745,12 +11753,12 @@ static int hclge_set_autoneg_speed_dup(struct hclge_dev *hdev)int ret;if (hdev->hw.mac.support_autoneg) { - ret =hclge_set_autoneg_en (hdev, hdev->hw.mac.autoneg); + ret =hclge_set_autoneg_en (hdev, hdev->hw.mac.req_autoneg);if (ret)return ret; } -if (!hdev->hw.mac.autoneg) { +if (!hdev->hw.mac.req_autoneg) { ret =hclge_cfg_mac_speed_dup_hw (hdev, hdev->hw.mac.req_speed, hdev->hw.mac.req_duplex, hdev->hw.mac.req_lane_num);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 946/1611 net: hns3: differentiate autoneg default values between copper and fiber
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuaisong Yang <[email protected]>
[ Upstream commit d9d349c4e8a0acd73bac8baa3605443c0df5eb26 ]
Fix a link loss issue during driver initialization on optical ports connected to forced-mode (non-autoneg) remote switches.
Previously, during driver probe or initialization, hclge_configure() blindly hardcoded hdev->hw.mac.req_autoneg to AUTONEG_ENABLE for all media types. While this is necessary for copper (BASE-T) ports to establish a link, many high-speed optical (fiber) ports in data centers are connected to switches running in forced mode (fixed speed, autoneg disabled). Forcing autoneg on these optical ports during initialization causes a permanent link failure since the remote end refuses to respond to autoneg pulses.
Fix this by implementing media-type differentiated initialization in hclge_init_ae_dev(). Copper ports continue to default to AUTONEG_ENABLE, while optical ports strictly inherit the preset autoneg status pre-configured by the firmware (hdev->hw.mac.autoneg), preserving native compatibility with forced-mode network environments.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +7 -0
@@ -11930,6 +11930,13 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)if (ret) goto err_ptp_uninit; +if (hdev->hw.mac.media_type !=HNAE3_MEDIA_TYPE_COPPER ) { + hdev->hw.mac.req_autoneg = hdev->hw.mac.autoneg; +if (hdev->hw.mac.autoneg ==AUTONEG_DISABLE && + hdev->hw.mac.speed !=SPEED_UNKNOWN ) + hdev->hw.mac.req_speed = hdev->hw.mac.speed; + } + ret =hclge_set_autoneg_speed_dup (hdev);if (ret) { dev_err(&pdev->dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 947/1611 ALSA: FCP: Fix NULL pointer dereference in interface lookup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaming Zhang <[email protected]>
[ Upstream commit e1e31e0ec8a609e17fd2e86b77bc00d9cbb24d7c ]
A malformed USB device can provide a vendor-specific interface without any endpoint descriptors. fcp_find_fc_interface() currently selects the first vendor-specific interface and reads endpoint 0 from it, without checking whether the interface actually has any endpoints.
When bNumEndpoints is zero, no endpoint array is allocated for the parsed alternate setting, so get_endpoint(..., 0) yields an invalid endpoint descriptor pointer. Dereferencing it through usb_endpoint_num() then triggers a NULL pointer dereference.
Skip vendor-specific interfaces that do not have any endpoints.
--- sound/usb/fcp.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/fcp.c +2 -0
@@ -1083,6 +1083,8 @@ static int fcp_find_fc_interface(struct usb_mixer_interface *mixer)if (desc->bInterfaceClass !=255 )continue ; +if (desc->bNumEndpoints <1 ) +continue ; epd =get_endpoint (intf->altsetting,0 ); private->bInterfaceNumber = desc->bInterfaceNumber;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 948/1611 tracing: probes: fix typo in a log message
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kaiser <[email protected]>
[ Upstream commit 72c8646956ffc8050bb8be5988a0f28fc37e1ac4 ]
Fix a typo ("Invalid $-variable") in a log message.
--- kernel/trace/trace_probe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_probe.h +1 -1
@@ -509,7 +509,7 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,C (NO_RETVAL ,"This function returns 'void' type" ), \C (BAD_STACK_NUM ,"Invalid stack number" ), \C (BAD_ARG_NUM ,"Invalid argument number" ), \ -C (BAD_VAR ,"Invalid $-valiable specified" ), \ +C (BAD_VAR ,"Invalid $-variable specified" ), \C (BAD_REG_NAME ,"Invalid register name" ), \C (BAD_MEM_ADDR ,"Invalid memory address" ), \ C(BAD_IMM, "Invalid immediate value"), \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 949/1611 spi: sh-msiof: abort transfers when reset times out
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 6dbaa4d288432c697cea47028480481b8b29bd6a ]
sh_msiof_spi_reset_regs() asserts TX/RX reset and polls until the reset bits clear, but the poll result is ignored. sh_msiof_transfer_one() can therefore continue programming a transfer after the controller did not leave reset.
Return the reset poll result from the helper and abort the transfer on timeout, matching the existing transfer path's error-return style.
--- drivers/spi/spi-sh-msiof.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/spi/spi-sh-msiof.c +6 -4
@@ -114,7 +114,7 @@ static irqreturn_t sh_msiof_spi_irq(int irq, void *data)return IRQ_HANDLED ; } -static void sh_msiof_spi_reset_regs (struct sh_msiof_spi_priv *p) +static int sh_msiof_spi_reset_regs (struct sh_msiof_spi_priv *p) {u32 mask =SICTR_TXRST |SICTR_RXRST ;u32 data;
@@ -123,8 +123,8 @@ static void sh_msiof_spi_reset_regs(struct sh_msiof_spi_priv *p) data |= mask;sh_msiof_write (p,SICTR , data); -readl_poll_timeout_atomic (p->mapbase +SICTR , data, !(data & mask),1 , -100 ); +return readl_poll_timeout_atomic (p->mapbase +SICTR , data, + !(data & mask),1 ,100 ); } static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
@@ -834,7 +834,9 @@ static int sh_msiof_transfer_one(struct spi_controller *ctlr,int ret;/* reset registers */ -sh_msiof_spi_reset_regs (p); + ret =sh_msiof_spi_reset_regs (p); +if (ret) +return ret;/* setup clocks (clock already enabled in chipselect()) */ if (!spi_controller_is_target (p->ctlr))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 950/1611 ACPI: RIMT: Only defer the IOMMU configuration in init stage
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yicong Yang <[email protected]>
[ Upstream commit b8f62414fa05144924257db283c5c35f74d21121 ]
The IOMMU configuration will be deferred if the IOMMU driver isn't probed by the time. Make this deferral only in the initialization stage with driver_deferred_probe_check_state(). Otherwise the devices depends on IOMMU will be deferred forever in case the IOMMU device probe failed or it doesn't appear in the ACPI namespace.
--- drivers/acpi/riscv/rimt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/acpi/riscv/rimt.c +4 -3
@@ -9,6 +9,7 @@#include <linux/acpi.h> #include <linux/acpi_rimt.h> +#include <linux/device/driver.h> #include <linux/iommu.h> #include <linux/list.h> #include <linux/pci.h>
@@ -257,11 +258,11 @@ static int rimt_iommu_xlate(struct device *dev, struct acpi_rimt_node *node, u32 rimt_fwnode =rimt_get_fwnode (node);/* -* The IOMMU drivers may not be probed yet. -* Defer the IOMMU configuration +* The IOMMU drivers may not be probed yet. Defer the IOMMU +* configuration if it's still in initialization stage. */ if (!rimt_fwnode) -return -EPROBE_DEFER ; +return driver_deferred_probe_check_state (dev);/* * EPROBE_DEFER ensures IOMMU is probed before the devices that
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 951/1611 riscv: Fix 32-bit call_on_irq_stack() frame pointer ABI
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Holland <[email protected]>
[ Upstream commit c4c7756a81b5baef286bf9be1ea404f3e4dd7a3c ]
call_on_irq_stack() uses struct member offsets to set up its link in the frame record list. On riscv32, struct stackframe is the wrong size to maintain stack pointer alignment, so STACKFRAME_SIZE_ON_STACK includes padding. However, the ABI requires the frame record to be placed immediately below the address stored in s0, so the padding must come before the struct members.
Fix the layout by making STACKFRAME_FP and STACKFRAME_RA the negative offsets from s0, instead of the positive offsets from sp.
--- arch/riscv/kernel/asm-offsets.c | 4 ++-- arch/riscv/kernel/entry.S | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
arch/riscv/kernel/asm-offsets.c +2 -2
@@ -497,8 +497,8 @@ void asm_offsets(void)OFFSET (SBI_HART_BOOT_STACK_PTR_OFFSET , sbi_hart_boot_data, stack_ptr);DEFINE (STACKFRAME_SIZE_ON_STACK ,ALIGN (sizeof (struct stackframe ),STACK_ALIGN )); -OFFSET (STACKFRAME_FP , stackframe, fp); -OFFSET (STACKFRAME_RA , stackframe, ra); +DEFINE (STACKFRAME_FP , offsetof(struct stackframe , fp) -sizeof (struct stackframe )); +DEFINE (STACKFRAME_RA , offsetof(struct stackframe , ra) -sizeof (struct stackframe ));#ifdef CONFIG_FUNCTION_TRACER DEFINE (FTRACE_OPS_FUNC , offsetof(struct ftrace_ops , func));#ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
arch/riscv/kernel/entry.S +4 -4
@@ -351,8 +351,8 @@ SYM_CODE_END(ret_from_fork_user_asm) SYM_FUNC_START(call_on_irq_stack) /* Create a frame record to save ra and s0 (fp) */ addi sp, sp, -STACKFRAME_SIZE_ON_STACK - REG_S ra, STACKFRAME_RA(sp) - REG_S s0, STACKFRAME_FP(sp) + REG_S ra, (STACKFRAME_SIZE_ON_STACK + STACKFRAME_RA)(sp) + REG_S s0, (STACKFRAME_SIZE_ON_STACK + STACKFRAME_FP)(sp) addi s0, sp, STACKFRAME_SIZE_ON_STACK /* Switch to the per-CPU shadow call stack */
@@ -370,8 +370,8 @@ SYM_FUNC_START(call_on_irq_stack) /* Switch back to the thread stack and restore ra and s0 */ addi sp, s0, -STACKFRAME_SIZE_ON_STACK - REG_L ra, STACKFRAME_RA(sp) - REG_L s0, STACKFRAME_FP(sp) + REG_L ra, (STACKFRAME_SIZE_ON_STACK + STACKFRAME_RA)(sp) + REG_L s0, (STACKFRAME_SIZE_ON_STACK + STACKFRAME_FP)(sp) addi sp, sp, STACKFRAME_SIZE_ON_STACK ret
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 952/1611 gpio: mvebu: fail probe if gpiochip registration fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 479e91fc92416a4d54d2b3150aa1e4550d9cc759 ]
mvebu_gpio_probe() registers the GPIO chip with devm_gpiochip_add_data() but ignores the return value. If registration fails, probe continues and leaves later code operating on a GPIO chip that was never published to gpiolib.
Return the registration error so the device fails probe cleanly.
--- drivers/gpio/gpio-mvebu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpio/gpio-mvebu.c +4 -1
@@ -1222,7 +1222,10 @@ static int mvebu_gpio_probe(struct platform_device *pdev)BUG (); } -devm_gpiochip_add_data (&pdev->dev, &mvchip->chip, mvchip); + err =devm_gpiochip_add_data (&pdev->dev, &mvchip->chip, mvchip); +if (err) +return dev_err_probe (&pdev->dev, err, +"failed to register gpiochip\n" );/* Some MVEBU SoCs have simple PWM support for GPIO lines */ if (IS_REACHABLE (CONFIG_PWM )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 953/1611 gpio: htc-egpio: use managed gpiochip registration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 17326db5f0ab4ec1901e75d052b5ebef486b467f ]
egpio_probe() registers each nested gpio_chip with gpiochip_add_data() but ignores the return value. If one registration fails, probe still returns success even though one of the chips was not published to gpiolib.
Use devm_gpiochip_add_data() and fail probe if any chip registration fails. This lets devres unwind already registered chips and prevents the driver from publishing a partially initialized device.
--- drivers/gpio/gpio-htc-egpio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpio/gpio-htc-egpio.c +5 -1
@@ -268,6 +268,7 @@ static int __init egpio_probe(struct platform_device *pdev)struct gpio_chip *chip;unsigned int irq, irq_end;int i; +int ret;/* Initialize ei data structure. */ ei =devm_kzalloc (&pdev->dev,sizeof (*ei),GFP_KERNEL );
@@ -331,7 +332,10 @@ static int __init egpio_probe(struct platform_device *pdev) chip->base = pdata->chip[i].gpio_base; chip->ngpio = pdata->chip[i].num_gpios; -gpiochip_add_data (chip, &ei->chip[i]); + ret =devm_gpiochip_add_data (&pdev->dev, chip, &ei->chip[i]); +if (ret) +return dev_err_probe (&pdev->dev, ret, +"failed to register gpiochip %d\n" , i); }/* Set initial pin values */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 954/1611 net: pse-pd: scope pse_control regulator handle to kref lifetime
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Corey Leavitt <[email protected]>
[ Upstream commit 16759757c4d28e958fd5a5a1fe0f86828872f28d ]
__pse_control_release() drops psec->ps via devm_regulator_put(), which only succeeds if the devres entry added by the matching devm_regulator_get_exclusive() is still present on pcdev->dev at the time the pse_control's kref hits zero.
That assumption does not hold when the controller is unbound while a pse_control still has consumers: pcdev->dev's devres list is released LIFO, so every per-attach regulator-GET devres runs (and regulator_put()s the underlying regulator) before pse_controller_unregister() itself is invoked. Any later pse_control_put() from that unbind path then reads psec->ps as a dangling pointer inside devm_regulator_put() and WARNs at drivers/regulator/devres.c:232 (devres_release() fails to find the already-released match).
The pse_control's consumer handle is logically scoped to the pse_control's refcount, not to pcdev->dev's devres lifetime. Switch to the plain regulator_get_exclusive() / regulator_put() pair so the regulator put in __pse_control_release() no longer depends on the controller's devres still being present. No change to the regulator-framework-visible refcount or lifetime of the underlying
regulator: a single get paired with a single put. The existing devm_regulator_register() for the per-PI rails is unchanged (those ARE correctly scoped to the controller's lifetime).
This addresses only the regulator handle. The same unbind-while-held scenario also leaves __pse_control_release() reading psec->pcdev->pi[] and psec->pcdev->owner after pse_controller_unregister() has freed pcdev->pi, because the controller does not drain its outstanding pse_control references on unregister. That wider pse_control vs pcdev lifetime problem pre-dates this change and is addressed by the PSE controller notifier series, which drains phydev->psec on PSE_UNREGISTERED before pcdev->pi is freed.
--- drivers/net/pse-pd/pse_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/pse-pd/pse_core.c +3 -3
@@ -1362,7 +1362,7 @@ static void __pse_control_release(struct kref *kref)if (psec->pcdev->pi[psec->id].admin_state_enabled)regulator_disable (psec->ps); -devm_regulator_put (psec->ps); +regulator_put (psec->ps);module_put (psec->pcdev->owner);
@@ -1431,8 +1431,8 @@ pse_control_get_internal(struct pse_controller_dev *pcdev, unsigned int index, goto free_psec; pcdev->pi[index].admin_state_enabled = ret; - psec->ps =devm_regulator_get_exclusive (pcdev->dev, -rdev_get_name (pcdev->pi[index].rdev)); + psec->ps =regulator_get_exclusive (pcdev->dev, +rdev_get_name (pcdev->pi[index].rdev));if (IS_ERR (psec->ps)) { ret =PTR_ERR (psec->ps); goto put_module;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 955/1611 seg6: validate SRH length before reading fixed fields
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuoqi Gui <[email protected]>
[ Upstream commit a75d99f46bf21b45965ce39c5cfb3b8bb5ffb1aa ]
seg6_validate_srh() reads fixed SRH fields such as srh->type and srh->hdrlen before checking that the supplied length covers the fixed struct ipv6_sr_hdr fields.
The BPF SEG6 encap path reaches this with a BPF program-supplied pointer and length: bpf_lwt_push_encap() and the SEG6 local BPF END_B6 and END_B6_ENCAP actions call bpf_push_seg6_encap(), which forwards the length to seg6_validate_srh() with no minimum-size guard. A 2-byte SEG6 encap header can therefore make the validator read srh->type at offset 2 beyond the caller-supplied buffer.
Reject lengths shorter than the fixed SRH at the top of seg6_validate_srh(), before any field is read. This fixes the BPF helper path and keeps the common validator robust.
--- net/ipv6/seg6.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/seg6.c +3 -0
@@ -29,6 +29,9 @@ bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len, bool reduced)int max_last_entry;int trailing; +if (len <sizeof (*srh)) +return false; +if (srh->type !=IPV6_SRCRT_TYPE_4 )return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 956/1611 qede: fix out-of-bounds check for cqe->len_list[]
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matvey Kovalev <[email protected]>
[ Upstream commit f9ba47fce5932c15891c89c60e76dfaca919cb8d ]
Move index check before element access.
--- drivers/net/ethernet/qlogic/qede/qede_fp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/qlogic/qede/qede_fp.c +2 -2
@@ -961,7 +961,7 @@ static inline void qede_tpa_cont(struct qede_dev *edev, {int i; -for (i =0 ; cqe->len_list[i] && i <ARRAY_SIZE (cqe->len_list); i++) +for (i =0 ; i <ARRAY_SIZE (cqe->len_list) && cqe->len_list[i]; i++)qede_fill_frag_skb (edev, rxq, cqe->tpa_agg_index,le16_to_cpu (cqe->len_list[i]));
@@ -986,7 +986,7 @@ static int qede_tpa_end(struct qede_dev *edev,dma_unmap_page (rxq->dev, tpa_info->buffer.mapping,PAGE_SIZE , rxq->data_direction); -for (i =0 ; cqe->len_list[i] && i <ARRAY_SIZE (cqe->len_list); i++) +for (i =0 ; i <ARRAY_SIZE (cqe->len_list) && cqe->len_list[i]; i++)qede_fill_frag_skb (edev, rxq, cqe->tpa_agg_index,le16_to_cpu (cqe->len_list[i]));if (unlikely (i >1 ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 957/1611 net: enetc: check the number of BDs needed for xdp_frame
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Fang <[email protected]>
[ Upstream commit 555c5475e787802eeae0d2b91c2f66c330db2767 ]
The size of xdp_redirect_arr array is ENETC_MAX_SKB_FRAGS. However, the number of fragments contained in xdp_frame may be greater than or equal to ENETC_MAX_SKB_FRAGS, which will cause the access to xdp_redirect_arr to be out of bounds.
--- drivers/net/ethernet/freescale/enetc/enetc.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/freescale/enetc/enetc.c +7 -0
@@ -1774,6 +1774,7 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames, {struct enetc_tx_swbd xdp_redirect_arr[ENETC_MAX_SKB_FRAGS ] = {0 };struct enetc_ndev_priv *priv =netdev_priv (ndev); +struct skb_shared_info *shinfo;struct enetc_bdr *tx_ring;int xdp_tx_bd_cnt, i, k;int xdp_tx_frm_cnt =0 ;
@@ -1789,6 +1790,12 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames,prefetchw (ENETC_TXBD (*tx_ring, tx_ring->next_to_use));for (k =0 ; k < num_frames; k++) { +if (xdp_frame_has_frags (frames[k])) { + shinfo =xdp_get_shared_info_from_frame (frames[k]); +if (unlikely ((shinfo->nr_frags +1 ) >ENETC_MAX_SKB_FRAGS )) +break ; + } + xdp_tx_bd_cnt =enetc_xdp_frame_to_xdp_tx_swbd (tx_ring, xdp_redirect_arr, frames[k]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 958/1611 sctp: fix SCTP_RESET_STREAMS stream list length limit
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yousef Alhouseen <[email protected]>
[ Upstream commit 2b9f5ef534184bd81b8a4772780626c40eed1fd5 ]
SCTP_RESET_STREAMS carries a flexible array of u16 stream IDs, but the optlen clamps treat USHRT_MAX as a byte count and then multiply sizeof(__u16) by the fixed header size.
That caps the copied and validated option buffer at about 64 KiB, which rejects valid requests containing more than about half of the u16 stream ID range.
Use struct_size_t() for the maximum struct sctp_reset_streams layout instead, so the bound matches the flexible array described by srs_number_streams.
--- net/sctp/socket.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/sctp/socket.c +5 -4
@@ -4110,8 +4110,9 @@ static int sctp_setsockopt_reset_streams(struct sock *sk,if (optlen <sizeof (*params))return -EINVAL ;/* srs_number_streams is u16, so optlen can't be bigger than this. */ - optlen = min_t(unsigned int, optlen, USHRT_MAX + -sizeof (__u16) *sizeof (*params)); + optlen = min_t(unsigned int, optlen, + struct_size_t(struct sctp_reset_streams, srs_stream_list, +USHRT_MAX ));if (params->srs_number_streams *sizeof (__u16) > optlen -sizeof (*params))
@@ -4597,8 +4598,8 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,if (optlen >0 ) {/* Trim it to the biggest size sctp sockopt may need if necessary */ optlen = min_t(unsigned int, optlen, -PAGE_ALIGN (USHRT_MAX + -sizeof (__u16) *sizeof (struct sctp_reset_streams ))); + PAGE_ALIGN(struct_size_t(struct sctp_reset_streams, + srs_stream_list,USHRT_MAX ))); kopt =memdup_sockptr (optval, optlen);if (IS_ERR (kopt))return PTR_ERR (kopt);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 959/1611 sctp: add INIT verification after cookie unpacking
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit 414c5447fe6a200613dd46d7fdc8454622076cb1 ]
In SCTP handshake, the INIT chunk is initially processed by the server and embedded into the cookie carried in INIT-ACK. The client then returns this cookie via COOKIE-ECHO, where the server unpacks it and reconstructs the original INIT chunk.
When cookie authentication is enabled, the cookie contents are protected against tampering, so reusing the unpacked INIT without re-verification is safe.
However, when cookie authentication is disabled, the reconstructed INIT can no longer be trusted. In this case, the INIT must be explicitly validated after unpacking to avoid processing potentially tampered data.
Add sctp_verify_init() checks after cookie unpacking in COOKIE-ECHO processing paths (sctp_sf_do_5_1D_ce() and sctp_sf_do_5_2_4_dupcook()) when cookie_auth_enable is disabled. On failure, the new association is freed and the packet is discarded.
Also tighten cookie validation in sctp_unpack_cookie() by verifying the embedded chunk type is SCTP_CID_INIT before treating it as an INIT chunk.
Finally, update sctp_verify_init() to validate parameter bounds using the actual embedded INIT length instead of chunk->chunk_end, since the INIT stored in COOKIE-ECHO may not span the entire chunk buffer.
--- net/sctp/sm_make_chunk.c | 5 ++++- net/sctp/sm_statefuns.c | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 4 deletions(-)
net/sctp/sm_make_chunk.c +4 -1
@@ -1761,6 +1761,8 @@ struct sctp_association *sctp_unpack_cookie( bear_cookie = &cookie->c; ch = (struct sctp_chunkhdr *)(bear_cookie +1 ); +if (ch->type !=SCTP_CID_INIT ) + goto malformed; chlen =ntohs (ch->length);if (chlen <sizeof (struct sctp_init_chunk )) goto malformed;
@@ -2298,7 +2300,8 @@ int sctp_verify_init(struct net *net, const struct sctp_endpoint *ep,* VIOLATION error. We build the ERROR chunk here and let the normal * error handling code build and send the packet. */ -if (param.v != (void *)chunk->chunk_end) +if (param.v != (void *)peer_init + +SCTP_PAD4 (ntohs (peer_init->chunk_hdr.length)))return sctp_process_inv_paramlength (asoc, param.p, chunk, errp);/* The only missing mandatory param possible today is
net/sctp/sm_statefuns.c +33 -3
@@ -705,11 +705,12 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net, struct sctp_cmd_seq *commands) {struct sctp_ulpevent *ev, *ai_ev =NULL , *auth_ev =NULL ; +struct sctp_chunk *err_chk_p =NULL ;struct sctp_association *new_asoc;struct sctp_init_chunk *peer_init;struct sctp_chunk *chunk = arg; -struct sctp_chunk *err_chk_p;struct sctp_chunk *repl; +enum sctp_cid cid;struct sock *sk;int error =0 ;
@@ -783,6 +784,19 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net, } } + peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr +1 ); + cid = peer_init->chunk_hdr.type; +if (!sctp_sk (sk)->cookie_auth_enable && + !sctp_verify_init (net, ep, asoc, cid, peer_init, chunk, + &err_chk_p)) { +sctp_association_free (new_asoc); +if (err_chk_p) +sctp_chunk_free (err_chk_p); +return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); + } +if (err_chk_p) +sctp_chunk_free (err_chk_p); +if (security_sctp_assoc_request (new_asoc, chunk->head_skb ?: chunk->skb)) {sctp_association_free (new_asoc);return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands);
@@ -796,7 +810,6 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,/* This is a brand-new association, so these are not yet side * effects--it is safe to run them here. */ - peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr +1 );if (!sctp_process_init (new_asoc, chunk, &chunk->subh.cookie_hdr->c.peer_addr, peer_init,GFP_ATOMIC ))
@@ -2210,10 +2223,12 @@ enum sctp_disposition sctp_sf_do_5_2_4_dupcook(void *arg, struct sctp_cmd_seq *commands) { + struct sctp_chunk *err_chk_p = NULL;struct sctp_association *new_asoc; +struct sctp_init_chunk *peer_init;struct sctp_chunk *chunk = arg;enum sctp_disposition retval; -struct sctp_chunk *err_chk_p; +enum sctp_cid cid;int error =0 ;char action;
@@ -2282,6 +2297,21 @@ enum sctp_disposition sctp_sf_do_5_2_4_dupcook(switch (action) {case 'A' :/* Association restart. */ case 'B' :/* Collision case B. */ + peer_init = (struct sctp_init_chunk *) + (chunk->subh.cookie_hdr +1 ); + cid = peer_init->chunk_hdr.type; +if (!sctp_sk (ep->base.sk)->cookie_auth_enable && + !sctp_verify_init (net, ep, asoc, cid, peer_init, chunk, + &err_chk_p)) { +sctp_association_free (new_asoc); +if (err_chk_p) +sctp_chunk_free (err_chk_p); +return sctp_sf_pdiscard (net, ep, asoc, type, arg, + commands); + } +if (err_chk_p) +sctp_chunk_free (err_chk_p); + fallthrough;case 'D' :/* Collision case D. */ /* Update socket peer label if first association. */ if (security_sctp_assoc_request((struct sctp_association *)asoc,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 960/1611 MIPS: DEC: Ensure RTC platform device deregistration upon failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
[ Upstream commit eacaf5ae747f7dead6cc268de17a7382d79031fc ]
Switch RTC platform device registration from platform_device_register() to platform_add_devices() so as to make sure any failure will result in automatic device unregistration.
--- arch/mips/dec/platform.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/mips/dec/platform.c +5 -1
@@ -38,6 +38,10 @@ static struct platform_device dec_rtc_device = { .num_resources = ARRAY_SIZE(dec_rtc_resources), }; +static struct platform_device *dec_rtc_devices[]__initdata = { + &dec_rtc_device, +}; +static struct resource dec_dz_resources[] = { { .name ="dz" , .flags =IORESOURCE_MEM , }, { .name ="dz" , .flags =IORESOURCE_IRQ , },
@@ -137,7 +141,7 @@ static int __init dec_add_devices(void) } num_zs = i; - ret1 =platform_device_register (&dec_rtc_device); + ret1 =platform_add_devices (dec_rtc_devices,1 ); ret2 =IS_ENABLED (CONFIG_32BIT ) ?platform_add_devices (dec_dz_devices, num_dz) :0 ; ret3 =platform_add_devices (dec_zs_devices, num_zs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 961/1611 MIPS: mm: Add check for highmem before removing memory block
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Hendry <[email protected]>
[ Upstream commit 6d5fbecd0213489bc4de71a0da194d18e654fd6e ]
If a device has less physical memory than the highmem threshold bootmem_init() doesn't set highstart_pfn. This results in highmem_init() wrongly disabling the entire memory range if the cpu doesn't support highmem. Add a check that highstart_pfn is non zero before removing the highmem block.
--- arch/mips/mm/init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/mips/mm/init.c +3 -2
@@ -435,10 +435,11 @@ static inline void __init highmem_init(void)unsigned long tmp;/* -* If CPU cannot support HIGHMEM discard the memory above highstart_pfn +* If CPU cannot support HIGHMEM discard any memory above highstart_pfn */ if (cpu_has_dc_aliases) { -memblock_remove (PFN_PHYS (highstart_pfn),-1 ); +if (highstart_pfn) +memblock_remove (PFN_PHYS (highstart_pfn),-1 );return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 962/1611 ASoC: codecs: lpass-va-macro: add SM6115 compatible
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
[ Upstream commit 893e2fd509e968cc1d76caadee0f5d2f2c72f137 ]
SM6115 does not have "macro" clock, so its bindings differ with existing SoC support in va-macro. So add dedicated compatible in both driver and dt-bindings to be able to address that difference.
Stable-dep-of: 0773610eef71 ("ASoC: codecs: lpass-va-macro: Fix LPASS Codec Version for SC7280")
--- sound/soc/codecs/lpass-va-macro.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/lpass-va-macro.c +1 -0
@@ -1723,6 +1723,7 @@ static const struct dev_pm_ops va_macro_pm_ops = {static const struct of_device_id va_macro_dt_match[] = { { .compatible ="qcom,sc7280-lpass-va-macro" , .data = &sm8250_va_data }, + { .compatible ="qcom,sm6115-lpass-va-macro" , .data = &sm8450_va_data }, { .compatible ="qcom,sm8250-lpass-va-macro" , .data = &sm8250_va_data }, { .compatible ="qcom,sm8450-lpass-va-macro" , .data = &sm8450_va_data }, { .compatible ="qcom,sm8550-lpass-va-macro" , .data = &sm8550_va_data },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 963/1611 ASoC: codecs: lpass-va-macro: Fix LPASS Codec Version for SC7280
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Weiss <[email protected]>
[ Upstream commit 0773610eef71c30df3cb4c113c8215625d2a7c23 ]
According to both the static definition in downstream...
yupik-audio-overlay.dtsi: qcom,bolero-version = <4>; #define BOLERO_VERSION_2_0 0x0004)
and the runtime detection:
CDC_VA_TOP_CSR_CORE_ID_0=0x1
CDC_VA_TOP_CSR_CORE_ID_1=0xf
SC7280 has LPASS Codec Version 2.0 and not, as declared with sm8250_va_data LPASS_CODEC_VERSION_1_0.
Create new va_macro_data with .version not set to use the runtime detection and correctly get .version = LPASS_CODEC_VERSION_2_0.
--- sound/soc/codecs/lpass-va-macro.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
sound/soc/codecs/lpass-va-macro.c +6 -1
@@ -236,6 +236,11 @@ static const struct va_macro_data sm8250_va_data = { .version = LPASS_CODEC_VERSION_1_0, }; +static const struct va_macro_data sc7280_va_data = { + .has_swr_master = false, + .has_npl_clk = false, +}; +static const struct va_macro_data sm8450_va_data = { .has_swr_master = true, .has_npl_clk = true,
@@ -1722,7 +1727,7 @@ static const struct dev_pm_ops va_macro_pm_ops = { };static const struct of_device_id va_macro_dt_match[] = { - { .compatible ="qcom,sc7280-lpass-va-macro" , .data = &sm8250_va_data }, + { .compatible ="qcom,sc7280-lpass-va-macro" , .data = &sc7280_va_data }, { .compatible ="qcom,sm6115-lpass-va-macro" , .data = &sm8450_va_data }, { .compatible ="qcom,sm8250-lpass-va-macro" , .data = &sm8250_va_data }, { .compatible ="qcom,sm8450-lpass-va-macro" , .data = &sm8450_va_data },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 964/1611 hwmon: adm1275: Prevent reading uninitialized stack
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
[ Upstream commit 553f9517813912a5ab661af5504485d96824a61c ]
While adding support for the ROHM BD127X0 hot-swap controllers, sashiko reported an error in device-name comparison, which can lead to reading uninitialized stack memory.
Quoting Sashiko:
This is a pre-existing issue, but I noticed that just before this block in adm1275_probe(), there might be an out-of-bounds stack read:
ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, block_buffer);
if (ret < 0) { ... }
for (mid = adm1275_id; mid->name[0]; mid++) {
if (!strncasecmp(mid->name, block_buffer, strlen(mid->name)))
break;
}Since i2c_smbus_read_block_data() reads up to 32 bytes into the uninitialized stack array block_buffer without appending a null terminator, strncasecmp() could read past the valid bytes returned in ret.
For example, if the device returns a shorter string like "adm12", checking it against "adm1275" up to the length of "adm1275" will continue reading into uninitialized stack bounds.
Prevent reading uninitialized memory by zeroing the stack array.
--- drivers/hwmon/pmbus/adm1275.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/adm1275.c +1 -1
@@ -512,7 +512,7 @@ static int adm1275_enable_vout_temp(struct adm1275_data *data,static int adm1275_probe (struct i2c_client *client) {s32 (*config_read_fn)(const struct i2c_client *client,u8 reg); -u8 block_buffer[I2C_SMBUS_BLOCK_MAX +1 ]; +u8 block_buffer[I2C_SMBUS_BLOCK_MAX +1 ] = {0 };int config, device_config;int ret;struct pmbus_driver_info *info;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 965/1611 hwmon: (pmbus) Fix passing events to regulator core
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 9ef7dacd44216bf5ea05c8aef49eba4d145f4047 ]
Sashiko reports:
Commit 754bd2b4a084 ("hwmon: (pmbus/core) Protect regulator operations with mutex") introduced a worker to batch regulator events over time using atomic_or(). The delayed worker then passes the combined bitmask unmodified to regulator_notifier_call_chain().
The core regulator subsystem's regulator_handle_critical() function evaluates the event parameter using a strict switch statement. If multiple distinct faults occur before the worker runs (e.g., REGULATOR_EVENT_UNDER_VOLTAGE | REGULATOR_EVENT_OVER_CURRENT), the combined bitmask fails to match any case. This leaves the reason as NULL and completely bypasses the critical hw_protection_trigger().
Fix the problem by passing events bit by bit to the regulator event handler.
--- drivers/hwmon/pmbus/pmbus_core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +9 -4
@@ -3381,18 +3381,23 @@ static void pmbus_regulator_notify_worker(struct work_struct *work)int i, j;for (i =0 ; i < data->info->pages; i++) { -int event; +unsigned int event; event =atomic_xchg (&data->regulator_events[i],0 );if (!event)continue ;for (j =0 ; j < data->info->num_regulators; j++) { -if (i ==rdev_get_id (data->rdevs[j])) { +if (i !=rdev_get_id (data->rdevs[j])) +continue ; +while (event) { +unsigned int _event =BIT (__ffs (event)); +regulator_notifier_call_chain (data->rdevs[j], - event,NULL ); -break ; + _event,NULL ); + event &= ~_event; } +break ; } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 966/1611 hwmon: (aspeed-g6-pwm-tach) Guard fan RPM calculation against divide-by-zero
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit fe87b8dc67f1b2c64e76a66e78468c533d3c44ca ]
Sashiko reports:
In the aspeed-g6-pwm-tacho driver, the aspeed_tach_val_to_rpm() function calculates the fan RPM using the tachometer value. However, it does not check if the tachometer value is zero before performing the division.
If the hardware reports a tachometer value of 0 (which can happen due to an extremely fast pulse, a stuck edge, or a hardware glitch), the calculated tach_div evaluates to 0. The subsequent call to do_div() with tach_div as the divisor triggers a divide-by-zero exception, leading to a kernel panic.
Check the divisor against zero to fix the problem.
--- drivers/hwmon/aspeed-g6-pwm-tach.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hwmon/aspeed-g6-pwm-tach.c +4 -1
@@ -293,7 +293,10 @@ static int aspeed_tach_val_to_rpm(struct aspeed_pwm_tach_data *priv, u32 tach_va priv->clk_rate, tach_val, tach_div); rpm = (u64 )priv->clk_rate *60 ; -do_div (rpm, tach_div); +if (tach_div) +do_div (rpm, tach_div); +else + rpm =0 ;return (int )rpm; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 967/1611 eth: fbnic: dont cache shinfo across skb realloc
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 62b68b774f06bf52e329f254f0199bc43d350ccf ]
fbnic_tx_lso() calls skb_cow_head() which may reallocate the skb including the shared info. We can't use the pointer calculated before the call.
BUG: KASAN: slab-use-after-free in fbnic_tx_lso.isra.0+0x668/0x8e0
Read of size 4 at addr ff110000262edd98 by task swapper/5/0
Call Trace:
fbnic_tx_lso.isra.0+0x668/0x8e0
fbnic_xmit_frame+0x622/0xba0
dev_hard_start_xmit+0xf4/0x620
Allocated by task 8653:
__alloc_skb+0x11e/0x5f0
alloc_skb_with_frags+0xcc/0x6c0
sock_alloc_send_pskb+0x327/0x3f0
__ip_append_data+0x188b/0x47a0
ip_make_skb+0x24a/0x300
udp_sendmsg+0x14d2/0x21e0
Freed by task 0:
kfree+0x123/0x5a0
pskb_expand_head+0x36c/0xfa0
fbnic_tx_lso.isra.0+0x500/0x8e0
fbnic_xmit_frame+0x622/0xba0
dev_hard_start_xmit+0xf4/0x620
sch_direct_xmit+0x25b/0x1100
The buggy address belongs to the object at ff110000262edc40
which belongs to the cache skbuff_small_head of size 640
The buggy address is located 344 bytes inside of
freed 640-byte region [ff110000262edc40, ff110000262ede--- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +6 -5
@@ -194,16 +194,18 @@ static bool fbnic_tx_tstamp(struct sk_buff *skb)static bool fbnic_tx_lso (struct fbnic_ring *ring,struct sk_buff *skb, -struct skb_shared_info *shinfo,__le64 *meta, -unsigned int *l2len,unsigned int *i3len) +__le64 *meta,unsigned int *l2len,unsigned int *i3len) {unsigned int l3_type, l4_type, l4len, hdrlen; +struct skb_shared_info *shinfo;unsigned char *l4hdr;__be16 payload_len;if (unlikely (skb_cow_head (skb,0 )))return true; + shinfo =skb_shinfo (skb); +if (shinfo->gso_type &SKB_GSO_PARTIAL ) { l3_type =FBNIC_TWD_L3_TYPE_OTHER ; }else if (!skb->encapsulation) {
@@ -258,7 +260,6 @@ fbnic_tx_lso(struct fbnic_ring *ring, struct sk_buff *skb,static bool fbnic_tx_offloads (struct fbnic_ring *ring,struct sk_buff *skb,__le64 *meta) { -struct skb_shared_info *shinfo =skb_shinfo (skb);unsigned int l2len, i3len;if (fbnic_tx_tstamp (skb))
@@ -273,8 +274,8 @@ fbnic_tx_offloads(struct fbnic_ring *ring, struct sk_buff *skb, __le64 *meta) *meta |=cpu_to_le64 (FIELD_PREP (FBNIC_TWD_CSUM_OFFSET_MASK , skb->csum_offset /2 )); -if (shinfo->gso_size) { -if (fbnic_tx_lso (ring, skb, shinfo, meta, &l2len, &i3len)) +if (skb_is_gso (skb)) { +if (fbnic_tx_lso (ring, skb, meta, &l2len, &i3len))return true; }else { *meta |=cpu_to_le64 (FBNIC_TWD_FLAG_REQ_CSO );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 968/1611 ipv6: fib6: fix NULL deref in fib6_walk_continue() on multi-batch dump
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengfei Zhang <[email protected]>
[ Upstream commit 9facb861dc6b9b9ea9793ef5032a9a826f7a4229 ]
inet6_dump_fib() saves its progress in cb->args[1] as a positional index within the current hash chain. Between batches, a concurrent fib6_new_table() can insert a new table at the chain head, shifting all existing entries. The saved index then lands on a different table, causing fib6_dump_table() to set w->root to the wrong table while w->node still points into the previous one. fib6_walk_continue() dereferences w->node->parent (NULL) and panics:
BUG: kernel NULL pointer dereference, address: 0000000000000008 RIP: 0010:fib6_walk_continue+0x6e/0x170 Call Trace: <TASK> fib6_dump_table.isra.0+0xc5/0x240 inet6_dump_fib+0xf6/0x420 rtnl_dumpit+0x30/0xa0 netlink_dump+0x15b/0x460 netlink_recvmsg+0x1d6/0x2a0 ____sys_recvmsg+0x17a/0x190
Fix by storing tb->tb6_id in cb->args[1] instead of a positional index. On resume, skip entries until the id matches; a concurrent head-insert can never match the saved id, so the walker always resumes on the correct table.
--- net/ipv6/ip6_fib.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
net/ipv6/ip6_fib.c +8 -9
@@ -634,12 +634,12 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) };const struct nlmsghdr *nlh = cb->nlh;struct net *net =sock_net (skb->sk); -unsigned int e =0 , s_e;struct hlist_head *head;struct fib6_walker *w;struct fib6_table *tb;unsigned int h, s_h;int err =0 ; +u32 s_id;rcu_read_lock ();if (cb->strict_check) {
@@ -699,23 +699,22 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) } s_h = cb->args[0 ]; - s_e = cb->args[1 ]; + s_id = cb->args[1 ]; -for (h = s_h; h <FIB6_TABLE_HASHSZ ; h++, s_e =0 ) { - e =0 ; +for (h = s_h; h <FIB6_TABLE_HASHSZ ; h++, s_id =0 ) { head = &net->ipv6.fib_table_hash[h];hlist_for_each_entry_rcu (tb, head, tb6_hlist) { -if (e < s_e) - goto next; +if (s_id && tb->tb6_id != s_id) +continue ; + + s_id =0 ; + cb->args[1 ] = tb->tb6_id; err =fib6_dump_table (tb, skb, cb);if (err !=0 ) goto out; -next: - e++; } } out: - cb->args[1 ] = e; cb->args[0 ] = h; unlock:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 969/1611 usbnet: gl620a: fix out-of-bounds read in genelink_rx_fixup()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 8ff7f2a6da4fccaa5cc9be7251a24e71e29fbd1a ]
genelink_rx_fixup() splits an aggregated RX frame into its individual packets, using a per-packet length taken from device-supplied data. That length is only bounded by GL_MAX_PACKET_LEN (1514); it is never compared against how many bytes were actually received.
A malicious GeneLink (GL620A) device can therefore send a short URB whose header claims packet_count > 1 and a first packet of up to 1514 bytes.
skb_put_data(gl_skb, packet->packet_data, size);
then copies past the end of the receive buffer and hands the adjacent slab contents up the network stack, an out-of-bounds read that leaks kernel heap. No privilege is required: the path runs in the usbnet RX softirq as soon as the interface is up.
BUG: KASAN: slab-out-of-bounds in genelink_rx_fixup (drivers/net/usb/gl620a.c:112)
Read of size 1514 at addr ffff888011309708 by task ksoftirqd/0/14
Call Trace:
...
__asan_memcpy (mm/kasan/shadow.c:105)
genelink_rx_fixup (include/linux/skbuff.h:2814 drivers/net/usb/gl620a.c:112)
usbnet_bh (drivers/net/usb/usbnet.c:572 drivers/net/usb/usbnet.c:1589)
process_one_work (kernel/workqueue.c:3322)
bh_worker (kernel/workqueue.c:3405)
tasklet_action (kernel/softirq.c:965)
handle_softirqs (kernel/softirq.c:622)
run_ksoftirqd (kernel/softirq.c:1076)
...skb_pull() already verifies that the requested length fits the buffer and returns NULL otherwise. Move it ahead of the copy and check its result, so a packet that overruns the received data is rejected before it is read. Well-formed frames, whose packets are fully present, are unaffected.
--- drivers/net/usb/gl620a.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/usb/gl620a.c +3 -3
@@ -104,6 +104,9 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)return 0 ; } +if (!skb_pull (skb, size +4 )) +return 0 ; +// allocate the skb for the individual packet gl_skb =alloc_skb (size,GFP_ATOMIC );if (gl_skb) {
@@ -116,9 +119,6 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)// advance to the next packet packet = (struct gl_packet *)&packet->packet_data[size]; count--; - -// shift the data pointer to the next gl_packet -skb_pull (skb, size +4 ); }// skip the packet length field 4 bytes
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 970/1611 net: phy: sfp: free mii_bus in sfp_i2c_mdiobus_destroy
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Wozniak <[email protected]>
[ Upstream commit 8f31efff9206f9f0adb853cad6916086aac4d5ef ]
sfp_i2c_mdiobus_create() allocates the I2C MDIO bus with mdio_i2c_alloc(), a plain (non-devm) allocation, and registers it. sfp_i2c_mdiobus_destroy() only unregisters the bus and clears sfp->i2c_mii without calling mdiobus_free(). As the only reference to the bus is then cleared, the struct mii_bus is leaked.
This is hit whenever a copper/RollBall SFP module that instantiated an MDIO bus is removed: sfp_sm_main() takes the global teardown path and calls sfp_i2c_mdiobus_destroy(). sfp_cleanup(), on driver unbind, frees sfp->i2c_mii directly, which is why the leak only triggered on module hot-removal and not on unbind.
Free the bus in sfp_i2c_mdiobus_destroy() to match the allocation done in sfp_i2c_mdiobus_create().
--- drivers/net/phy/sfp.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/sfp.c +1 -0
@@ -850,6 +850,7 @@ static int sfp_i2c_mdiobus_create(struct sfp *sfp)static void sfp_i2c_mdiobus_destroy (struct sfp *sfp) {mdiobus_unregister (sfp->i2c_mii); +mdiobus_free (sfp->i2c_mii); sfp->i2c_mii =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 971/1611 net: libwx: fix VMDQ mask for 1-queue mode
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawen Wu <[email protected]>
[ Upstream commit 6ab752e0b59b825c127d5c86438bee1e8b1641ea ]
In wx_set_vmdq_queues(), the VMDQ mask was not set for the devices not supporting WX_FLAG_MULTI_64_FUNC, i.e., NGBE devices. A mask of 0 causes __ALIGN_MASK(1, ~vmdq->mask) to return 0, which incorrectly sets q_per_pool to 0 in wx_write_qde().
Fix the VMDQ 1-queue mask to 0x7F then ensures that __ALIGN_MASK(1, ~0x7F) correctly evaluates to 1.
--- drivers/net/ethernet/wangxun/libwx/wx_lib.c | 1 + drivers/net/ethernet/wangxun/libwx/wx_type.h | 1 + 2 files changed, 2 insertions(+)
drivers/net/ethernet/wangxun/libwx/wx_lib.c +1 -0
@@ -1745,6 +1745,7 @@ static bool wx_set_vmdq_queues(struct wx *wx) rss_i =4 ; } }else { + vmdq_m =WX_VMDQ_1Q_MASK ;/* double check we are limited to maximum pools */ vmdq_i =min_t (u16,8 , vmdq_i);
drivers/net/ethernet/wangxun/libwx/wx_type.h +1 -0
@@ -471,6 +471,7 @@ enum WX_MSCA_CMD_value {#define WX_VMDQ_4Q_MASK 0x7C#define WX_VMDQ_2Q_MASK 0x7E +#define WX_VMDQ_1Q_MASK 0x7F/****************** Manageablility Host Interface defines ********************/ #define WX_HI_MAX_BLOCK_BYTE_LENGTH 256/* Num of bytes in range */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 972/1611 net: gianfar: dispose irq mappings on probe failure and device removal
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit dbf803bc4a8b0522c9a12560c20905a5952d1cb9 ]
irq_of_parse_and_map() creates irqdomain mappings that should be balanced with irq_dispose_mapping(). The driver never called irq_dispose_mapping(), leaking mappings on probe failure and device removal.
Fix by adding irq_dispose_mapping() in free_gfar_dev() and expanding its loop from priv->num_grps to MAXGROUPS so the error path also catches partially-initialized groups. All irqinfo pointers are pre-initialized to NULL in gfar_of_init(), making the NULL-guarded walk in free_gfar_dev() safe for every scenario.
gfar_parse_group() itself is left as a simple parse function with no resource management; cleanup is centralized in the caller's error path.
--- drivers/net/ethernet/freescale/gianfar.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/ethernet/freescale/gianfar.c +11 -5
@@ -471,10 +471,13 @@ static void free_gfar_dev(struct gfar_private *priv) {int i, j; -for (i =0 ; i < priv->num_grps; i++) +for (i =0 ; i <MAXGROUPS ; i++)for (j =0 ; j <GFAR_NUM_IRQS ; j++) { -kfree (priv->gfargrp[i].irqinfo[j]); - priv->gfargrp[i].irqinfo[j] =NULL ; +if (priv->gfargrp[i].irqinfo[j]) { +irq_dispose_mapping (priv->gfargrp[i].irqinfo[j]->irq); +kfree (priv->gfargrp[i].irqinfo[j]); + priv->gfargrp[i].irqinfo[j] =NULL ; + } }free_netdev (priv->ndev);
@@ -619,7 +622,7 @@ static phy_interface_t gfar_get_interface(struct net_device *dev)static int gfar_of_init (struct platform_device *ofdev,struct net_device **pdev) {const char *model; -int err =0 , i; +int err =0 , i, j;phy_interface_t interface;struct net_device *dev =NULL ;struct gfar_private *priv =NULL ;
@@ -705,8 +708,11 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) priv->rx_list.count =0 ;mutex_init (&priv->rx_queue_access); -for (i =0 ; i <MAXGROUPS ; i++) +for (i =0 ; i <MAXGROUPS ; i++) { priv->gfargrp[i].regs =NULL ; +for (j =0 ; j <GFAR_NUM_IRQS ; j++) + priv->gfargrp[i].irqinfo[j] =NULL ; + }/* Parse and initialize group specific information */ if (priv->mode ==MQ_MG_MODE ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 973/1611 net/sched: sch_teql: Introduce slaves_lock to avoid race condition and UAF
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit e5b811fe793166aecc59b085c1b7c31262ef2316 ]
The teql master->slaves singly linked list is not protected against multiple writes. It can be mod'ed concurently from teql_master_xmit(), teql_dequeue(), teql_init() and teql_destroy() without holding any list lock or RCU protection.
[email protected] has demonstrated that the qdisc is freed after an RCU grace period, but teql_master_xmit() running on another CPU can still hold a stale pointer into the list, resulting in a slab-use-after-free:
BUG: KASAN: slab-use-after-free in teql_master_xmit+0xf0f/0x16b0 Read of size 8 at addr ffff888013fb0440 by task poc/332
Freed 512-byte region [ffff888013fb0400, ffff888013fb0600) (kmalloc-512)
The fix?
Add a per-master slaves_lock spinlock that serializes all mutations of master->slaves and the NEXT_SLAVE() links in teql_destroy() and teql_qdisc_init(). teql_master_xmit() also takes the same slaves_lock around those updates.
Annotate master->slaves and the per-slave ->next pointer with __rcu and use the appropriate RCU accessors everywhere they are touched:rcu_assign_pointer() on the writer side (under slaves_lock), rcu_dereference_protected() for the writer-side loads (also under slaves_lock), rcu_dereference_bh() for the loads in teql_master_xmit() and rtnl_dereference() for the loads in teql_master_open()/teql_master_mtu(), which run under RTNL.
Pair this with rcu_read_lock_bh()/rcu_read_unlock_bh() around the list traversal in teql_master_xmit(), so that readers either observe a fully linked list or are deferred until the in-flight mutation completes. The two early-return paths in teql_master_xmit() are updated to release the RCU-bh read-side critical section before returning, since leaving it held would disable BH on that CPU for good.
--- net/sched/sch_teql.c | 125 +++++++++++++++++++++++++++++-------------- 1 file changed, 86 insertions(+), 39 deletions(-)
net/sched/sch_teql.c +86 -39
@@ -52,7 +52,8 @@struct teql_master {struct Qdisc_ops qops;struct net_device *dev; -struct Qdisc *slaves; +struct Qdisc __rcu *slaves; +spinlock_t slaves_lock;/* serializes writes to ->slaves */ struct list_head master_list;unsigned long tx_bytes;unsigned long tx_packets;
@@ -61,7 +62,7 @@ struct teql_master { };struct teql_sched_data { -struct Qdisc *next; +struct Qdisc __rcu *next;struct teql_master *m;struct sk_buff_head q; };
@@ -101,7 +102,9 @@ teql_dequeue(struct Qdisc *sch)if (skb ==NULL ) {struct net_device *m =qdisc_dev (q);if (m) { - dat->m->slaves = sch; +spin_lock_bh (&dat->m->slaves_lock); +rcu_assign_pointer (dat->m->slaves, sch); +spin_unlock_bh (&dat->m->slaves_lock);netif_wake_queue (m); } }else {
@@ -132,34 +135,49 @@ teql_destroy(struct Qdisc *sch)struct Qdisc *q, *prev;struct teql_sched_data *dat =qdisc_priv (sch);struct teql_master *master = dat->m; +struct netdev_queue *txq =NULL ; +bool reset_master_queue = false;if (!master)return ; - prev = master->slaves; +spin_lock_bh (&master->slaves_lock); + prev =rcu_dereference_protected (master->slaves, +lockdep_is_held (&master->slaves_lock));if (prev) {do { - q =NEXT_SLAVE (prev); -if (q == sch) { -NEXT_SLAVE (prev) =NEXT_SLAVE (q); -if (q == master->slaves) { - master->slaves =NEXT_SLAVE (q); -if (q == master->slaves) { -struct netdev_queue *txq; - - txq =netdev_get_tx_queue (master->dev,0 ); - master->slaves =NULL ; - -dev_reset_queue (master->dev, - txq,NULL ); - } - } -skb_queue_purge (&dat->q); -break ; +struct Qdisc *head, *next; + + q =rcu_dereference_protected (NEXT_SLAVE (prev), +lockdep_is_held (&master->slaves_lock)); +if (q != sch) { + prev = q; +continue ; } - }while ((prev = q) != master->slaves); + next =rcu_dereference_protected (NEXT_SLAVE (q), +lockdep_is_held (&master->slaves_lock)); +rcu_assign_pointer (NEXT_SLAVE (prev), next); + + head =rcu_dereference_protected (master->slaves, +lockdep_is_held (&master->slaves_lock)); +if (q == head) { +rcu_assign_pointer (master->slaves, next); +if (q == next) { + txq =netdev_get_tx_queue (master->dev,0 ); +rcu_assign_pointer (master->slaves,NULL ); + reset_master_queue = true; + } + } +skb_queue_purge (&dat->q); +break ; + }while (prev !=rcu_dereference_protected (master->slaves, +lockdep_is_held (&master->slaves_lock))); } +spin_unlock_bh (&master->slaves_lock); + +if (reset_master_queue) +dev_reset_queue (master->dev, txq,NULL ); } static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,
@@ -168,6 +186,7 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,struct net_device *dev =qdisc_dev (sch);struct teql_master *m = (struct teql_master *)sch->ops;struct teql_sched_data *q =qdisc_priv (sch); +struct Qdisc *first;if (dev->hard_header_len > m->dev->hard_header_len)return -EINVAL ;
@@ -184,7 +203,9 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,skb_queue_head_init (&q->q); -if (m->slaves) { +spin_lock_bh (&m->slaves_lock); + first =rcu_dereference_protected (m->slaves,lockdep_is_held (&m->slaves_lock)); +if (first) {if (m->dev->flags &IFF_UP ) { if ((m->dev->flags & IFF_POINTOPOINT && !(dev->flags & IFF_POINTOPOINT)) ||
@@ -192,8 +213,10 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt, !(dev->flags & IFF_BROADCAST)) || (m->dev->flags & IFF_MULTICAST && !(dev->flags & IFF_MULTICAST)) || - dev->mtu < m->dev->mtu) + dev->mtu < m->dev->mtu) { +spin_unlock_bh (&m->slaves_lock);return -EINVAL ; + } }else {if (!(dev->flags&IFF_POINTOPOINT )) m->dev->flags &= ~IFF_POINTOPOINT ;
@@ -204,14 +227,17 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,if (dev->mtu < m->dev->mtu) m->dev->mtu = dev->mtu; } - q->next =NEXT_SLAVE (m->slaves); -NEXT_SLAVE (m->slaves) = sch; +rcu_assign_pointer (q->next, +rcu_dereference_protected (NEXT_SLAVE (first), +lockdep_is_held (&m->slaves_lock))); +rcu_assign_pointer (NEXT_SLAVE (first), sch); }else { - q->next = sch; - m->slaves = sch; +rcu_assign_pointer (q->next, sch); +rcu_assign_pointer (m->slaves, sch); m->dev->mtu = dev->mtu; m->dev->flags = (m->dev->flags&~FMASK )|(dev->flags&FMASK ); } +spin_unlock_bh (&m->slaves_lock);return 0 ; }
@@ -285,7 +311,9 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev)int subq =skb_get_queue_mapping (skb);struct sk_buff *skb_res =NULL ; - start = master->slaves; +rcu_read_lock_bh (); + + start =rcu_dereference_bh (master->slaves); restart: nores =0 ;
@@ -317,10 +345,17 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev) netdev_start_xmit(skb, slave, slave_txq, false) == NETDEV_TX_OK) {__netif_tx_unlock (slave_txq); - master->slaves =NEXT_SLAVE (q); +spin_lock_bh (&master->slaves_lock); +if (rcu_dereference_protected (master->slaves, +lockdep_is_held (&master->slaves_lock)) == q) +rcu_assign_pointer (master->slaves, +rcu_dereference_protected (NEXT_SLAVE (q), +lockdep_is_held (&master->slaves_lock))); +spin_unlock_bh (&master->slaves_lock);netif_wake_queue (dev); master->tx_packets++; master->tx_bytes += length; +rcu_read_unlock_bh ();return NETDEV_TX_OK ; }__netif_tx_unlock (slave_txq);
@@ -329,14 +364,21 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev) busy =1 ;break ;case 1 : - master->slaves =NEXT_SLAVE (q); +spin_lock_bh (&master->slaves_lock); +if (rcu_dereference_protected (master->slaves, +lockdep_is_held (&master->slaves_lock)) == q) +rcu_assign_pointer (master->slaves, +rcu_dereference_protected (NEXT_SLAVE (q), +lockdep_is_held (&master->slaves_lock))); +spin_unlock_bh (&master->slaves_lock); +rcu_read_unlock_bh ();return NETDEV_TX_OK ;default : nores =1 ;break ; }__skb_pull (skb,skb_network_offset (skb)); - }while ((q =NEXT_SLAVE (q)) != start); + }while ((q =rcu_dereference_bh (NEXT_SLAVE (q))) != start);if (nores && skb_res ==NULL ) { skb_res = skb;
@@ -345,29 +387,32 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev)if (busy) {netif_stop_queue (dev); +rcu_read_unlock_bh ();return NETDEV_TX_BUSY ; } master->tx_errors++; drop: master->tx_dropped++; +rcu_read_unlock_bh ();dev_kfree_skb (skb);return NETDEV_TX_OK ; }static int teql_master_open (struct net_device *dev) { -struct Qdisc *q; +struct Qdisc *q, *first;struct teql_master *m =netdev_priv (dev);int mtu =0xFFFE ;unsigned int flags =IFF_NOARP |IFF_MULTICAST ; -if (m->slaves ==NULL ) + first =rtnl_dereference (m->slaves); +if (!first)return -EUNATCH ; flags =FMASK ; - q = m->slaves; + q = first; do { struct net_device *slave = qdisc_dev(q);
@@ -389,7 +434,7 @@ static int teql_master_open(struct net_device *dev) flags &= ~IFF_BROADCAST ;if (!(slave->flags&IFF_MULTICAST )) flags &= ~IFF_MULTICAST ; - }while ((q =NEXT_SLAVE (q)) != m->slaves); + }while ((q =rtnl_dereference (NEXT_SLAVE (q))) != first); m->dev->mtu = mtu; m->dev->flags = (m->dev->flags&~FMASK ) | flags;
@@ -417,14 +462,15 @@ static void teql_master_stats64(struct net_device *dev,static int teql_master_mtu (struct net_device *dev,int new_mtu) {struct teql_master *m =netdev_priv (dev); -struct Qdisc *q; +struct Qdisc *q, *first; - q = m->slaves; + first =rtnl_dereference (m->slaves); + q = first;if (q) {do {if (new_mtu >qdisc_dev (q)->mtu)return -EINVAL ; - }while ((q =NEXT_SLAVE (q)) != m->slaves); + }while ((q =rtnl_dereference (NEXT_SLAVE (q))) != first); }WRITE_ONCE (dev->mtu, new_mtu);
@@ -444,6 +490,7 @@ static __init void teql_master_setup(struct net_device *dev)struct teql_master *master =netdev_priv (dev);struct Qdisc_ops *ops = &master->qops; +spin_lock_init (&master->slaves_lock); master->dev = dev; ops->priv_size =sizeof (struct teql_sched_data );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 974/1611 bridge: stp: Fix a potential use-after-free when deleting a bridge
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 2a00517db8de4be7df3d483b215c5544fb30a191 ]
The three STP timers are not supposed to be armed while the bridge is administratively down. They are synchronously deactivated when the bridge is put administratively down and the various call sites check for 'IFF_UP' before arming them.
This check is missing from br_topology_change_detection() and it is possible to engineer a situation in which the topology change timer is armed while the bridge is administratively down, resulting in a use-after-free [1] when the bridge is deleted.
Fix by adding the missing check and for good measures synchronously shutdown the three timers when the bridge is deleted.
[1]
ODEBUG: free active (active state 0) object: ffff88811662b9b0 object type: timer_list hint: br_topology_change_timer_expired (net/bridge/br_stp_timer.c:120)
WARNING: lib/debugobjects.c:629 at debug_print_object+0x1bc/0x450, CPU#9: ip/359
--- net/bridge/br_if.c | 3 +++ net/bridge/br_stp.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-)
net/bridge/br_if.c +3 -0
@@ -391,6 +391,9 @@ void br_dev_delete(struct net_device *dev, struct list_head *head)br_fdb_delete_by_port (br,NULL ,0 ,1 ); +timer_shutdown_sync (&br->hello_timer); +timer_shutdown_sync (&br->topology_change_timer); +timer_shutdown_sync (&br->tcn_timer);cancel_delayed_work_sync (&br->gc_work);br_sysfs_delbr (br->dev);
net/bridge/br_stp.c +2 -1
@@ -371,7 +371,8 @@ void br_topology_change_detection(struct net_bridge *br) {int isroot =br_is_root_bridge (br); -if (br->stp_enabled !=BR_KERNEL_STP ) +if (br->stp_enabled !=BR_KERNEL_STP || + !(br->dev->flags &IFF_UP ))return ; br_info(br, "topology change detected, %s\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 975/1611 drm/panthor: Fix potential invalid pointer deref in group_process_tiler_oom()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Brezillon <[email protected]>
[ Upstream commit b39436d0ba1571dbcda69d20ec567344b3eecfc7 ]
If heaps is an ERR_PTR(), panthor_heap_pool_put() will deref an invalid pointer. Make sure we set it to NULL in that case.
--- drivers/gpu/drm/panthor/panthor_sched.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_sched.c +4 -1
@@ -1488,7 +1488,10 @@ static int group_process_tiler_oom(struct panthor_group *group, u32 cs_id)if (unlikely (csg_id <0 ))return 0 ; -if (IS_ERR (heaps) || frag_end > vt_end || vt_end >= vt_start) { +if (IS_ERR (heaps)) { + ret = -EINVAL ; + heaps =NULL ; + }else if (frag_end > vt_end || vt_end >= vt_start) { ret = -EINVAL ; }else {/* We do the allocation without holding the scheduler lock to avoid
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 976/1611 drm/panthor: Dont overrule pending immediate ticks in sched_resume_tick()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Brezillon <[email protected]>
[ Upstream commit 6fec8b473497b7f32e604a6dd92b32b0889af3e8 ]
We schedule immediate ticks when we need to process events on CSGs, but those immediate ticks don't change the resched_target because we want the other groups to stay scheduled for the remaining of the GPU timeslot they were given. Make sure these immediate ticks don't get overruled by a sched_queue_delayed_work() that would delay the tick execution.
--- drivers/gpu/drm/panthor/panthor_sched.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_sched.c +8 -1
@@ -2588,7 +2588,14 @@ static void sched_resume_tick(struct panthor_device *ptdev)else delay_jiffies =0 ; -sched_queue_delayed_work (sched, tick, delay_jiffies); +/* We schedule immediate ticks when we need to process events on CSGs, +* but those don't change the resched_target because we want the other +* groups to stay scheduled for the remaining of the GPU timeslot they +* were given. Make sure those immediate ticks don't get overruled by +* a sched_queue_delayed_work() that would delay the tick execution. +*/ +if (!delayed_work_pending (&sched->tick_work)) +sched_queue_delayed_work (sched, tick, delay_jiffies); }static void group_schedule_locked (struct panthor_group *group,u32 queue_mask)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 977/1611 drm/panthor: Fix a leak when a group is evicted before the tiler OOM is serviced
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Brezillon <[email protected]>
[ Upstream commit 6efeb9ddb4fbf5ac30aff03e8f09ffbdf966abd0 ]
A group ref is tied to the pending tiler_oom_work, so we need to release it if the cancel was effective.
--- drivers/gpu/drm/panthor/panthor_sched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_sched.c +2 -1
@@ -1039,7 +1039,8 @@ group_unbind_locked(struct panthor_group *group)/* Tiler OOM events will be re-issued next time the group is scheduled. */ atomic_set (&group->tiler_oom,0 ); -cancel_work (&group->tiler_oom_work); +if (cancel_work (&group->tiler_oom_work)) +group_put (group);for (u32 i =0 ; i < group->queue_count; i++) group->queues[i]->doorbell_id =-1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 978/1611 drm/panthor: Interrupt group start/resumption if group_bind_locked() fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Brezillon <[email protected]>
[ Upstream commit 1f27cef1f41dac0bd254d8741766f189936c9880 ]
group_bind_locked() can fail if the MMU block is stuck. This is normally a reset situation, but by the time we reset the GPU, we might have tried to resume a group that's not resident, which will probably trip out the FW. So let's avoid that by bailing out when group_bind_locked() returns an error. We don't even try to start more groups because the GPU will be reset anyway.
--- drivers/gpu/drm/panthor/panthor_sched.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_sched.c +7 -1
@@ -2289,7 +2289,13 @@ tick_ctx_apply(struct panthor_scheduler *sched, struct panthor_sched_tick_ctx *c csg_iface =panthor_fw_get_csg_iface (ptdev, csg_id); csg_slot = &sched->csg_slots[csg_id]; -group_bind_locked (group, csg_id); + ret =group_bind_locked (group, csg_id); +if (ret) { +panthor_device_schedule_reset (ptdev); + ctx->csg_upd_failed_mask |=BIT (csg_id); +return ; + } +csg_slot_prog_locked (ptdev, csg_id, new_csg_prio--); csgs_upd_ctx_queue_reqs(ptdev, &upd_ctx, csg_id, group->state == PANTHOR_CS_GROUP_SUSPENDED ?
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 979/1611 tracing/eprobes: Allow use of BTF names to dereference pointers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
[ Upstream commit 69efd863a78584b9416ed6be0e1e7349124b4a00 ]
Add syntax to the parsing of eprobes to be able to typecast a trace event field that is a pointer to a structure.
Currently, a dereference must be a number, where the user has to figure out manually the offset of a member of a structure that they want to dereference.
But for event probes that records a field that happens to be a pointer to a structure, it cannot dereference these values with BTF naming, but must use numerical offsets.
For example, to find out what device a sk_buff is pointing to in the net_dev_xmit trace event, one must first use gdb to find the offsets of the members of the structures:
(gdb) p &((struct sk_buff *)0)->dev
$1 = (struct net_device **) 0x10
(gdb) p &((struct net_device *)0)->name
$2 = (char (*)[16]) 0x118
And then use the raw numbers to dereference:
# echo 'e:xmit net.net_dev_xmit +0x118(+0x10($skbaddr)):string' >> dynamic_events
If BTF is in the kernel, then instead, the skbaddr can be typecast to sk_buff and use the normal dereference logic.
# echo 'e:xmit net.net_dev_xmit (sk_buff)skbaddr->dev->name:string' >> dynamic_events
# echo 1 > events/eprobes/xmit/enable
# cat trace
[..]
sshd-session-1022 [000] b..2. 860.249343: xmit: (net.net_dev_xmit) arg1="enp7s0"
sshd-session-1022 [000] b..2. 860.250061: xmit: (net.net_dev_xmit) arg1="enp7s0"
sshd-session-1022 [000] b..2. 860.250142: xmit: (net.net_dev_xmit) arg1="enp7s0"
sshd-session-1022 [000] b..2. 860.263553: xmit: (net.net_dev_xmit) arg1="enp7s0"
sshd-session-1022 [000] b..2. 860.283820: xmit: (net.net_dev_xmit) arg1="enp7s0"
sshd-session-1022 [000] b..2. 860.302716: xmit: (net.net_dev_xmit) arg1="enp7s0"
sshd-session-1022 [000] b..2. 860.322905: xmit: (net.net_dev_xmit) arg1="enp7s0"
sshd-session-1022 [000] b..2. 860.342828: xmit: (net.net_dev_xmit) arg1="enp7s0"
sshd-session-1022 [000] b..2. 860.362268: xmit: (net.net_dev_xmit) arg1="enp7s0"
sshd-session-1022 [000] b..2. 860.382335: xmit: (net.net_dev_xmit) arg1="enp7s0"
sshd-session-1022 [000] b..2. 860.400856: xmit: (net.net_dev_xmit) arg1="enp7s0"
sshd-session-1022 [000] b..2. 860.419893: xmit: (net.net_dev_xmit) arg1="enp7s0"The syntax is simply: (STRUCT)(FIELD)->MEMBER[->MEMBER..]
Also add comments around the #else and #endif of #ifdef CONFIG_PROBE_EVENTS_BTF_ARGS to know what they are for.
Stable-dep-of: 251a8fe1b9ae ("tracing/probes: Remove WARN_ON_ONCE from parse_btf_arg")
--- Documentation/trace/eprobetrace.rst | 4 + kernel/trace/trace_probe.c | 173 +++++++++++++++++++++++----- kernel/trace/trace_probe.h | 5 +- 3 files changed, 154 insertions(+), 28 deletions(-)
Documentation/trace/eprobetrace.rst +4 -0
@@ -46,6 +46,10 @@ Synopsis of eprobe_events (x8/x16/x32/x64), VFS layer common type(%pd/%pD), "char", "string", "ustring", "symbol", "symstr" and "bitfield" are supported. + (STRUCT)FIELD->MEMBER[->MEMBER] : If BTF is supported, typecast FIELD to + a pointer to STRUCT and then derference the pointer defined by + ->MEMBER. Note that when this is used, the FIELD name does not + need to be prefixed with a '$'. Types -----
kernel/trace/trace_probe.c +146 -27
273 lines not on this page · raw message
kernel/trace/trace_probe.h +4 -1
@@ -422,7 +422,9 @@ struct traceprobe_parse_context {const struct btf_param *params;/* Parameter of the function */ s32 nr_params;/* The number of the parameters */ struct btf *btf;/* The BTF to be used */ +struct btf *struct_btf;/* The BTF to be used for structs */ const struct btf_type *last_type;/* Saved type */ +const struct btf_type *last_struct;/* Saved structure */ u32 last_bitoffs;/* Saved bitoffs */ u32 last_bitsize;/* Saved bitsize */ struct trace_probe *tp;
@@ -563,7 +565,8 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,C (NEED_STRING_TYPE ,"$comm and immediate-string only accepts string type" ),\C (TOO_MANY_ARGS ,"Too many arguments are specified" ), \C (TOO_MANY_EARGS ,"Too many entry arguments specified" ), \ -C (EVENT_TOO_BIG ,"Event too big (too many fields?)" ), +C (EVENT_TOO_BIG ,"Event too big (too many fields?)" ), \ +C (TYPECAST_NOT_EVENT ,"Typecasts are only for eprobe fields" ), #undef C #define C(a, b) TP_ERR_##a
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 980/1611 tracing/probes: Remove WARN_ON_ONCE from parse_btf_arg
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit 251a8fe1b9aedccd298b77bc28426d564c5a923f ]
Sashiko found that user can cause this WARN_ON_ONCE() easily with adding a kprobe event based on a raw address with BTF parameter.
Since this is not an unexpected condition, remove the WARN_ON_ONCE().
--- kernel/trace/trace_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_probe.c +1 -1
@@ -677,7 +677,7 @@ static int parse_btf_arg(char *varname,int i, is_ptr, ret;u32 tid; -if (WARN_ON_ONCE (!ctx->funcname && !(ctx->flags &TPARG_FL_TEVENT ))) +if (!ctx->funcname && !(ctx->flags &TPARG_FL_TEVENT ))return -EINVAL ; is_ptr =split_next_field (varname, &field, ctx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 981/1611 tracing/events: Fix to check the simple_tsk_fn creation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit cda1fbfc5313bb90daa271d45eea4a8d317a8544 ]
Sashiko pointed that this sample code does not correctly handle the failure of thread creation because kthread_run() can return -errno.
Check the simple_tsk_fn is correctly initialized (created) or not.
--- samples/trace_events/trace-events-sample.c | 4 ++++ 1 file changed, 4 insertions(+)
samples/trace_events/trace-events-sample.c +4 -0
@@ -107,6 +107,10 @@ int foo_bar_reg(void)* for consistency sake, we still take the thread_mutex. */ simple_tsk_fn =kthread_run (simple_thread_fn,NULL ,"event-sample-fn" ); +if (IS_ERR_OR_NULL (simple_tsk_fn)) { +pr_err ("Failed to create simple_thread_fn\n" ); + simple_tsk_fn =NULL ; + } out:mutex_unlock (&thread_mutex);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 982/1611 tracing: eprobe: read the complete FILTER_PTR_STRING pointer
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kaiser <[email protected]>
[ Upstream commit 206b25c09080cc20fd4c2bea12d59df4b7ba2121 ]
For a char * element in an event, the FILTER_PTR_STRING filter type is used. When the event occurs, a pointer is stored in the ringbuffer.
If an eprobe references such a char * element of a "base event", the stored pointer is truncated when it's read from the ringbuffer.
$ cd /sys/kernel/tracing $ echo 'e rcu.rcu_utilization $s:x64 $s:string' > dynamic_events $ echo 1 > tracing_on $ echo 1 > events/eprobes/enable $ sleep 1 $ echo 0 > events/eprobes/enable $ cat trace <idle>-0 ...: (rcu.rcu_utilization) arg1=0x4f arg2=(fault) <idle>-0 ...: (rcu.rcu_utilization) arg1=0x2 arg2=(fault)
The problem is in get_event_field
val = (unsigned long)(*(char *)addr);
addr points to the position in the ringbuffer where the pointer was stored. The assignment reads only the lowest byte of the pointer.
Fix the cast to read the whole pointer. The output of the test above is now
<idle>-0 ... arg1=0xffffffff81c7d3f3 arg2="Start scheduler-tick" <idle>-0 ... arg1=0xffffffff81c57340 arg2="End scheduler-tick"
--- kernel/trace/trace_eprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_eprobe.c +1 -1
@@ -315,7 +315,7 @@ get_event_field(struct fetch_insn *code, void *rec) val = (unsigned long )addr;break ;case FILTER_PTR_STRING : - val = (unsigned long )(*(char *)addr); + val = *(unsigned long *)addr;break ;default :WARN_ON_ONCE (1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 983/1611 tracing/fprobe: Fix NULL pointer dereference in fprobe_fgraph_entry()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sechang Lim <[email protected]>
[ Upstream commit 367c49d6e283c17b56a31e7a8d964a079244264c ]
fprobe_fgraph_entry() sizes a shadow-stack reservation in one walk of the per-ip fprobe list and fills it in a second walk, both under rcu_read_lock() only. A fprobe registered on an already-live ip can become visible between the two walks, so the fill walk processes an exit_handler the sizing walk did not count and used runs past reserved_words. If the sizing walk counted nothing, fgraph_data is NULL and the first write_fprobe_header() faults:
Oops: general protection fault, probably for non-canonical address ... KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:fprobe_fgraph_entry+0xa38/0xf10 kernel/trace/fprobe.c:167 Call Trace: <TASK> function_graph_enter_regs+0x44c/0xa10 kernel/trace/fgraph.c:677 ftrace_graph_func+0xc5/0x140 arch/x86/kernel/ftrace.c:671 __kernel_text_address+0x9/0x40 kernel/extable.c:78 arch_stack_walk+0x117/0x170 arch/x86/kernel/stacktrace.c:26 kmem_cache_free+0x188/0x580 mm/slub.c:6378 tcp_data_queue+0x18d/0x6550 net/ipv4/tcp_input.c:5590 [...] </TASK>
The list cannot be frozen across the two walks, so skip a node that does not fit the reservation and count it as missed.
--- kernel/trace/fprobe.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
kernel/trace/fprobe.c +10 -0
@@ -474,6 +474,16 @@ static int fprobe_fgraph_entry(struct ftrace_graph_ent *trace, struct fgraph_opscontinue ; data_size = fp->entry_data_size; +/* +* The list may have grown since it was sized, so this node +* may not fit. Skip it as missed rather than overrun the +* reservation. +*/ +if (fp->exit_handler && + used +FPROBE_HEADER_SIZE_IN_LONG +SIZE_IN_LONG (data_size) > reserved_words) { + fp->nmissed++; +continue ; + }if (data_size && fp->exit_handler) data = fgraph_data + used +FPROBE_HEADER_SIZE_IN_LONG ;else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 984/1611 tracing/probes: Make the $ prefix mandatory for comm access
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit a369299c3f785cf556bbef2de2db0aa2d294c4c9 ]
Since $comm or $COMM are not event field but special fetcharg variables to access current->comm, It should not be accessed without '$' prefix even with typecast.
--- kernel/trace/trace_probe.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
kernel/trace/trace_probe.c +7 -5
@@ -341,10 +341,6 @@ static int parse_trace_event(char *arg, struct fetch_insn *code, ret =parse_trace_event_arg (arg, code, ctx);if (!ret)return 0 ; -if (strcmp (arg,"comm" ) ==0 ||strcmp (arg,"COMM" ) ==0 ) { - code->op =FETCH_OP_COMM ; -return 0 ; - }return -EINVAL ; }
@@ -1073,8 +1069,14 @@ static int parse_probe_vars(char *orig_arg, const struct fetch_type *t,int len;if (ctx->flags &TPARG_FL_TEVENT ) { -if (parse_trace_event (arg, code, ctx) <0 ) +if (parse_trace_event (arg, code, ctx) <0 ) { +/* 'comm' should be checked after field parsing. */ +if (strcmp (arg,"comm" ) ==0 ||strcmp (arg,"COMM" ) ==0 ) { + code->op =FETCH_OP_COMM ; +return 0 ; + } goto inval; + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 985/1611 irqchip/gic-v3-its: Fix OF node reference leak
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 2e1368a9d61bdf5502ddade004f223a5831c5b8c ]
of_get_cpu_node() returns a referenced device node. In its_cpu_init_collection(), the Cavium 23144 workaround only uses the node to compare the CPU NUMA node, but the reference is never dropped.
Use the device_node cleanup helper for the CPU node reference so it is released when leaving the workaround block, including the NUMA mismatch return path.
--- drivers/irqchip/irq-gic-v3-its.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +2 -4
@@ -3291,11 +3291,9 @@ static void its_cpu_init_collection(struct its_node *its)/* avoid cross node collections and its mapping */ if (its->flags &ITS_FLAGS_WORKAROUND_CAVIUM_23144 ) { -struct device_node *cpu_node; + struct device_node *cpu_node __free(device_node) = of_get_cpu_node(cpu, NULL); - cpu_node =of_get_cpu_node (cpu,NULL ); -if (its->numa_node !=NUMA_NO_NODE && - its->numa_node !=of_node_to_nid (cpu_node)) +if (its->numa_node !=NUMA_NO_NODE && its->numa_node !=of_node_to_nid (cpu_node))return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 986/1611 irqchip/ts4800: Fix missing chained handler cleanup on remove
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingshuang Fu <[email protected]>
[ Upstream commit 98bf7e54cec07d514b3575c11896a8b12d50ecc4 ]
The driver installs a chained handler for the parent interrupt during probe using irq_set_chained_handler_and_data(), but the remove function does not clear this handler. This leaves a dangling handler that may be called when the parent interrupt fires after the driver has been removed, potentially accessing freed memory and causing a kernel crash.
Additionally, the parent_irq obtained via irq_of_parse_and_map() is not stored, making it inaccessible in the remove function. Moreover, interrupt mappings created during probe are not properly disposed.
Fix this by:
- Saving parent_irq in probe
- Clearing the chained handler with NULL in ts4800_ic_remove()
- Disposing all IRQ mappings before domain removal to prevent resource leaks
--- drivers/irqchip/irq-ts4800.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/irqchip/irq-ts4800.c +10 -0
@@ -28,6 +28,7 @@ struct ts4800_irq_data {void __iomem *base;struct platform_device *pdev;struct irq_domain *domain; +unsigned int parent_irq; };static void ts4800_irq_mask (struct irq_data *d)
@@ -134,6 +135,7 @@ static int ts4800_ic_probe(struct platform_device *pdev)irq_set_chained_handler_and_data (parent_irq, ts4800_ic_chained_handle_irq, data); + data->parent_irq = parent_irq;platform_set_drvdata (pdev, data);return 0 ;
@@ -142,6 +144,14 @@ static int ts4800_ic_probe(struct platform_device *pdev)static void ts4800_ic_remove (struct platform_device *pdev) {struct ts4800_irq_data *data =platform_get_drvdata (pdev); +unsigned int hwirq; + +irq_set_chained_handler_and_data (data->parent_irq,NULL ,NULL ); + +for (hwirq =0 ; hwirq <8 ; hwirq++) +irq_dispose_mapping (irq_find_mapping (data->domain, hwirq)); + +irq_dispose_mapping (data->parent_irq);irq_domain_remove (data->domain); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 987/1611 sctp: fix addr_wq_timer race in sctp_free_addr_wq()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit 976c19de0f22a857ba0112f39635f8fd7a257568 ]
sctp_free_addr_wq() previously removed addr_wq_timer using timer_delete() while holding addr_wq_lock. However, timer_delete() does not guarantee that a currently running timer handler has completed.
This allows a race with sctp_addr_wq_timeout_handler(), where the handler may still run after addr_waitq has been freed, acquire addr_wq_lock, and access freed memory, leading to a use-after-free.
Fix this by calling timer_shutdown_sync() before taking addr_wq_lock. This guarantees that any in-flight timer handler has finished and prevents the timer from being re-armed during teardown, making subsequent cleanup safe.
--- net/sctp/protocol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sctp/protocol.c +2 -1
@@ -695,8 +695,9 @@ static void sctp_free_addr_wq(struct net *net)struct sctp_sockaddr_entry *addrw;struct sctp_sockaddr_entry *temp; +timer_shutdown_sync (&net->sctp.addr_wq_timer); +spin_lock_bh (&net->sctp.addr_wq_lock); -timer_delete (&net->sctp.addr_wq_timer);list_for_each_entry_safe (addrw, temp, &net->sctp.addr_waitq, list) {list_del (&addrw->list);kfree (addrw);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 988/1611 virtio_net: disable cb when NAPI is busy-polled
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Longjun Tang <[email protected]>
[ Upstream commit 1eb8fc67ca41db71c90866ff76c990d85247daef ]
When busy-poll is active, napi_schedule_prep() returns false in virtqueue_napi_schedule(), so virtqueue_disable_cb() is skipped. The device may keep firing irqs until reaches virtqueue_napi_complete(). Under load (received == budget), it will lead to a large number of spurious interrupts.
Fix it by disabling the callback at the virtnet_poll() entry. This keeps the callback off while we poll and it is re-enabled by virtqueue_napi_complete() when going idle.
--- drivers/net/virtio_net.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/virtio_net.c +3 -0
@@ -3128,6 +3128,9 @@ static int virtnet_poll(struct napi_struct *napi, int budget)unsigned int xdp_xmit =0 ;bool napi_complete; +if (budget) +virtqueue_disable_cb (rq->vq); +virtnet_poll_cleantx (rq, budget); received =virtnet_receive (rq, budget, &xdp_xmit);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 989/1611 cxgb4: Fix decode strings dump for T6 adapters
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gleb Markov <[email protected]>
[ Upstream commit 5d6dc22d62682d93f5f55f145ad792f2891de911 ]
Depending on the value of chip_version, the correct decode set is selected. However, the subsequent matching with the t4 encoding type in the if-else block results in a reassignment, which leads to the loss of support for t6_decode as well as reinitializing of values t4_decode and t5_decode.
The component history shows that the if-else block previously used for this purpose, as well as the execution order, was not affected by the change.
Furthermore, it is suggested by the execution order that the scenario with overwriting and loss of support will be implemented.
Delete the if-else block.
--- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +0 -8
@@ -6737,14 +6737,6 @@ void t4_sge_decode_idma_state(struct adapter *adapter, int state)return ; } -if (is_t4 (adapter->params.chip)) { - sge_idma_decode = (const char **)t4_decode; - sge_idma_decode_nstates =ARRAY_SIZE (t4_decode); - }else { - sge_idma_decode = (const char **)t5_decode; - sge_idma_decode_nstates =ARRAY_SIZE (t5_decode); - } -if (state < sge_idma_decode_nstates)CH_WARN (adapter,"idma state %s\n" , sge_idma_decode[state]);else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 990/1611 selftests: drv-net: tso: dont touch dangerous feature bits
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 2f7f2e311106cb838d3f3fb6ef25effdb3f8e366 ]
query_nic_features() detects which offloads depend on tx-gso-partial by enabling everything, turning tx-gso-partial off, and seeing which active features drop out. Enabling all hw features is dangerous:
we may end up enabling rx-fcs and loopback for example. For the ice driver we end up getting into problems with feature dependencies so the cleanup isn't successful either, and the test exits with rx-fcs and loopback enabled.
Scope the feature probing just to segmentation bits.
--- tools/testing/selftests/drivers/net/hw/tso.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
tools/testing/selftests/drivers/net/hw/tso.py +6 -10
@@ -184,28 +184,24 @@ def query_nic_features(cfg) -> None: cfg.wanted_features.add(f["name"]) cfg.hw_features = set() - hw_all_features_cmd = "" for f in features["hw"]["bits"]["bit"]: if f.get("value", False): - feature = f["name"] - cfg.hw_features.add(feature) - hw_all_features_cmd += f" {feature} on" - try: - ethtool(f"-K {cfg.ifname} {hw_all_features_cmd}") - except Exception as e: - ksft_pr(f"WARNING: failure enabling all hw features: {e}") - ksft_pr("partial gso feature detection may be impacted") + cfg.hw_features.add(f["name"]) # Check which features are supported via GSO partial cfg.partial_features = set() if 'tx-gso-partial' in cfg.hw_features: + seg_features = {f for f in cfg.hw_features if "segmentation" in f} + ethtool(f"-K {cfg.ifname} " + + " ".join(f"{f} on" for f in seg_features)) + ethtool(f"-K {cfg.ifname} tx-gso-partial off") no_partial = set() features = cfg.ethnl.features_get({"header": {"dev-index": cfg.ifindex}}) for f in features["active"]["bits"]["bit"]: no_partial.add(f["name"]) - cfg.partial_features = cfg.hw_features - no_partial + cfg.partial_features = seg_features - no_partial ethtool(f"-K {cfg.ifname} tx-gso-partial on") restore_wanted_features(cfg)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 991/1611 net/sched: act_bpf: use rcu_dereference_bh() to read the filter
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sechang Lim <[email protected]>
[ Upstream commit adc49c7ba690c9b33b8392ec27397456b65d0893 ]
tcf_bpf_act() can run from the tc egress path, which holds only rcu_read_lock_bh(), but reads prog->filter with rcu_dereference() and trips lockdep:
WARNING: suspicious RCU usage
net/sched/act_bpf.c:47 suspicious rcu_dereference_check() usage! 1 lock held by syz.2.1588/12756:
#0: (rcu_read_lock_bh){....}-{1:3}, at: __dev_queue_xmit net/core/dev.c:4792
tcf_bpf_act+0x6ae/0x940 net/sched/act_bpf.c:47 tcf_classify+0x6e4/0x1080 net/sched/cls_api.c:1860 sch_handle_egress net/core/dev.c:4545 [inline] __dev_queue_xmit+0x2185/0x2c00 net/core/dev.c:4808 packet_sendmsg+0x3dfa/0x5120 net/packet/af_packet.c:3114
The other tc actions and cls_bpf already use rcu_dereference_bh() here. Do the same.
--- net/sched/act_bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/act_bpf.c +1 -1
@@ -44,7 +44,7 @@ TC_INDIRECT_SCOPE int tcf_bpf_act(struct sk_buff *skb,tcf_lastuse_update (&prog->tcf_tm);bstats_update (this_cpu_ptr (prog->common.cpu_bstats), skb); - filter =rcu_dereference (prog->filter); + filter =rcu_dereference_bh (prog->filter);if (at_ingress) {__skb_push (skb, skb->mac_len); filter_res =bpf_prog_run_data_pointers (filter, skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 992/1611 ksmbd: reject undersized DACLs before parsing ACEs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haofeng Li <[email protected]>
[ Upstream commit 60908f7ebcd9b6cde74ad5711fab0f49c7970949 ]
parse_dacl() limits the attacker-controlled ACE count by comparing it with the number of minimal ACEs that fit in the DACL size. The DACL size field is 16 bits, but the expression subtracts sizeof(struct smb_acl). Because sizeof() is unsigned, a DACL size smaller than the ACL header underflows to a large size_t.
A malicious client can reach this with:
SMB2_SET_INFO (InfoType=SMB2_O_INFO_SECURITY)
-> smb2_set_info_sec()
-> set_info_sec()
-> parse_sec_desc()
-> parse_dacl()
-> init_acl_state(..., 0xffff)
-> init_acl_state(..., 0xffff)
-> kmalloc_objs(..., 0xffff)Thus a malformed security descriptor can make num_aces pass the guard and drive large temporary ACL state and pointer-array allocations.
Reject DACLs smaller than struct smb_acl before doing the subtraction, so the ACE count check cannot be bypassed by the underflow.
--- fs/smb/server/smbacl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/smb/server/smbacl.c +6 -1
@@ -374,6 +374,7 @@ static void parse_dacl(struct mnt_idmap *idmap, {int i, ret;u16 num_aces =0 ; +u16 dacl_size;unsigned int acl_size;char *acl_base;struct smb_ace **ppace;
@@ -403,7 +404,11 @@ static void parse_dacl(struct mnt_idmap *idmap,if (num_aces <=0 )return ; -if (num_aces > (le16_to_cpu (pdacl->size) -sizeof (struct smb_acl )) / + dacl_size =le16_to_cpu (pdacl->size); +if (dacl_size <sizeof (struct smb_acl )) +return ; + +if (num_aces > (dacl_size -sizeof (struct smb_acl )) / (offsetof(struct smb_ace , sid) + offsetof(struct smb_sid , sub_auth) +sizeof (__le16)))return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 993/1611 ksmbd: fix use-after-free of fp->owner.name in durable handle owner check
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gil Portnoy <[email protected]>
[ Upstream commit 38637163501fd9e2f684b8cd275d0db5d79f37c6 ]
Two concurrent SMB2 durable reconnects (DH2C/DHnC) on the same persistent_id race the fp->owner.name compare-read in ksmbd_vfs_compare_durable_owner() against the kfree() in ksmbd_reopen_durable_fd()'s reopen-success path. fp->owner.name is a standalone kstrdup() buffer whose lifetime is independent of the fp refcount, and the two sites share no lock: the compare reads the buffer while the reopen frees it, so the strcmp() can dereference freed memory.
Commit 7ce4fc40018d ("ksmbd: fix durable reconnect double-bind race in ksmbd_reopen_durable_fd") made the fp->conn claim atomic under global_ft.lock (closing the owner.name double-free and the ksmbd_file write-UAF), but the compare-read versus reopen-free pair was left unserialized.
BUG: KASAN: slab-use-after-free in strcmp+0x2c/0x80
Read of size 1 by task kworker
strcmp
ksmbd_vfs_compare_durable_owner
smb2_check_durable_oplock
smb2_open
Freed by task kworker:
kfree
ksmbd_reopen_durable_fd
smb2_open
Allocated by task kworker:
kstrdup
session_fd_check
smb2_session_logoff
The buggy address belongs to the cache kmalloc-8Serialize both sides of the race with fp->f_lock. The global durable file-table lock still protects the durable reconnect claim, but fp->owner.name is per-open state and does not need to block unrelated durable table lookups or reconnects. The teardown is left at its existing location after the reopen-success point so that an __open_id() rollback still retains owner.name for a later legitimate reconnect to verify.
--- fs/smb/server/vfs_cache.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)
fs/smb/server/vfs_cache.c +21 -8
@@ -980,16 +980,21 @@ void ksmbd_stop_durable_scavenger(void)static int ksmbd_vfs_copy_durable_owner (struct ksmbd_file *fp,struct ksmbd_user *user) { +char *name; +if (!user)return -EINVAL ;/* Duplicate the user name to ensure identity persistence */ - fp->owner.name =kstrdup (user->name,GFP_KERNEL ); -if (!fp->owner.name) + name =kstrdup (user->name,GFP_KERNEL ); +if (!name)return -ENOMEM ; +spin_lock (&fp->f_lock); fp->owner.uid = user->uid; fp->owner.gid = user->gid; + fp->owner.name = name; +spin_unlock (&fp->f_lock);return 0 ; }
@@ -1007,18 +1012,24 @@ static int ksmbd_vfs_copy_durable_owner(struct ksmbd_file *fp,bool ksmbd_vfs_compare_durable_owner (struct ksmbd_file *fp,struct ksmbd_user *user) { -if (!user || !fp->owner.name) +bool ret = false; + +if (!user)return false; +spin_lock (&fp->f_lock); +if (!fp->owner.name) + goto out; +/* Check if the UID and GID match first (fast path) */ if (fp->owner.uid != user->uid || fp->owner.gid != user->gid) -return false; + goto out;/* Validate the account name to ensure the same SecurityContext */ -if (strcmp (fp->owner.name, user->name)) -return false; - -return true; + ret = (strcmp (fp->owner.name, user->name) ==0 ); +out: +spin_unlock (&fp->f_lock); +return ret; } static bool session_fd_check(struct ksmbd_tree_connect *tcon,
@@ -1172,9 +1183,11 @@ int ksmbd_reopen_durable_fd(struct ksmbd_work *work, struct ksmbd_file *fp) }up_write (&ci->m_lock); +spin_lock (&fp->f_lock); fp->owner.uid = fp->owner.gid =0 ;kfree (fp->owner.name); fp->owner.name =NULL ; +spin_unlock (&fp->f_lock);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 994/1611 gpio: timberdale: Return -ENOMEM on dynamic memory allocation in probe
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Zapolskiy <[email protected]>
[ Upstream commit 8d7e62d5e9b2d2ff146f472a9215d7e29c7e2307 ]
Out of memory situation on driver's probe is expected to be reported to the driver's framework with a proper -ENOMEM error code.
--- drivers/gpio/gpio-timberdale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-timberdale.c +1 -1
@@ -235,7 +235,7 @@ static int timbgpio_probe(struct platform_device *pdev) tgpio =devm_kzalloc (dev,sizeof (*tgpio),GFP_KERNEL );if (!tgpio) -return -EINVAL ; +return -ENOMEM ; tgpio->irq_base = pdata->irq_base;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 995/1611 pinctrl: meson: restore non-sleeping GPIO access
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viacheslav Bocharov <[email protected]>
[ Upstream commit 9777530157e7b82fd994327ff878c4245dadc931 ]
Commit 28f240683871 ("pinctrl: meson: mark the GPIO controller as sleeping") set gpio_chip.can_sleep = true to work around gpio-shared-proxy holding a spinlock across a sleeping pinctrl config path. That locking bug is now fixed in the shared-proxy itself ("gpio:
shared-proxy: always serialize with a sleeping mutex"), so the controller-wide workaround is no longer needed; the meson GPIO controller does not sleep.
meson_gpio_get/set/direction_* access MMIO through regmap. The regmap_mmio bus uses fast I/O (spinlock) locking, so these value callbacks do not contain sleeping operations. Since gpio_chip.can_sleep describes the get/set value path, restore can_sleep = false.
Marking the controller sleeping also broke atomic value consumers such as w1-gpio (1-Wire bitbang): w1_io.c runs its read time slot under local_irq_save() and uses the non-cansleep gpiod_set_value() / gpiod_get_value(), which with can_sleep=true trigger WARN_ON(can_sleep) in gpiolib on every transferred bit (from w1_gpio_write_bit() / w1_gpio_read_bit() via w1_reset_bus() and w1_search()). The printk and stack dump inside the IRQs-off, microsecond-scale time slot destroy the bit timing, so reset/presence detection and ROM search fail: the bus master registers but w1_master_slave_count stays at 0 and no devices are found. Verified on an Amlogic A113X board (DS18B20 on GPIOA_14):
with can_sleep restored to false the warnings are gone and the sensor is detected and read again.
This must not be applied or backported without the shared-proxy locking fix above; otherwise the original Khadas VIM3 splat returns on boards that genuinely share a meson GPIO.
--- drivers/pinctrl/meson/pinctrl-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/meson/pinctrl-meson.c +1 -1
@@ -619,7 +619,7 @@ static int meson_gpiolib_register(struct meson_pinctrl *pc) pc->chip.set = meson_gpio_set; pc->chip.base =-1 ; pc->chip.ngpio = pc->data->num_pins; - pc->chip.can_sleep = true; + pc->chip.can_sleep = false; ret =gpiochip_add_data (&pc->chip, pc);if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 996/1611 net/sched: dualpi2: clear stale classification on filter miss
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit bf83ee45874e9f071478bed39f9cf40cc741629f ]
DualPI2 leaves previous classification state attached to an skb when filter classification returns no match. The enqueue path can then act on stale state from an earlier classification attempt.
A filter miss should fall back to the default class without reusing old per-packet classification data.
Initialize the classification result to CLASSIC before running the classifier. Explicit L4S, priority, and successful filter classification can still override that default.
--- net/sched/sch_dualpi2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/sched/sch_dualpi2.c +3 -3
@@ -346,6 +346,8 @@ static int dualpi2_skb_classify(struct dualpi2_sched_data *q,struct tcf_proto *fl;int result; + cb->classified =DUALPI2_C_CLASSIC ; +dualpi2_read_ect (skb);if (cb->ect & q->ecn_mask) { cb->classified =DUALPI2_C_L4S ;
@@ -359,10 +361,8 @@ static int dualpi2_skb_classify(struct dualpi2_sched_data *q, } fl =rcu_dereference_bh (q->tcf_filters); -if (!fl) { - cb->classified =DUALPI2_C_CLASSIC ; +if (!fl)return NET_XMIT_SUCCESS ; - } result =tcf_classify (skb,NULL , fl, &res, false);if (result >=0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 997/1611 net/sched: hhf: clear heavy-hitter state on reset
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit a225f8c20712713406ae47024b8df42deacddd4a ]
HHF reset does not clear the classifier state used to identify heavy hitters. Packets after reset can therefore be scheduled using flow history from before the reset.
The reset operation should return the qdisc to an empty state.
Clear the heavy-hitter classifier tables when HHF is reset.
--- net/sched/sch_hhf.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
net/sched/sch_hhf.c +27 -0
@@ -461,12 +461,39 @@ static struct sk_buff *hhf_dequeue(struct Qdisc *sch)return skb; } +static void hhf_reset_classifier (struct hhf_sched_data *q) +{ +int i; + +if (!q->hh_flows) +return ; + +for (i =0 ; i <HH_FLOWS_CNT ; i++) { +struct hh_flow_state *flow, *next; +struct list_head *head = &q->hh_flows[i]; + +list_for_each_entry_safe (flow, next, head, flowchain) { +list_del (&flow->flowchain); +kfree (flow); + } + } +WRITE_ONCE (q->hh_flows_current_cnt,0 ); + +for (i =0 ; i <HHF_ARRAYS_CNT ; i++) { +if (q->hhf_valid_bits[i]) +bitmap_zero (q->hhf_valid_bits[i],HHF_ARRAYS_LEN ); + } + q->hhf_arrays_reset_timestamp =hhf_time_stamp (); +} +static void hhf_reset (struct Qdisc *sch) { +struct hhf_sched_data *q =qdisc_priv (sch);struct sk_buff *skb;while ((skb =hhf_dequeue (sch)) !=NULL )rtnl_kfree_skbs (skb, skb); +hhf_reset_classifier (q); }static void hhf_destroy (struct Qdisc *sch)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 998/1611 fs: refuse O_TMPFILE creation with an unmapped fsuid or fsgid
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 539dce1144651f7976fa418e618b0b574bf15eeb ]
vfs_tmpfile() never checked that the caller's fsuid and fsgid map into the filesystem. On an idmapped mount whose idmapping does not cover the caller's fs{u,g}id, the ->tmpfile() instance initializes the new inode through inode_init_owner(), where mapped_fsuid()/mapped_fsgid() return INVALID_UID/INVALID_GID, and the tmpfile ends up owned by (uid_t)-1.
Every other creation path already refuses this: may_o_create() (O_CREAT) and may_create_dentry() (mkdir, mknod, symlink, link) bail out with -EOVERFLOW via fsuidgid_has_mapping() precisely so that an object cannot be created with an owner the filesystem cannot represent. An O_TMPFILE is no exception: it is created I_LINKABLE and linkat(2) can splice it into the namespace afterwards, so the same guarantee must hold.
Add the missing fsuidgid_has_mapping() check to vfs_tmpfile(). On a non-idmapped mount the caller's fs{u,g}id always map in the superblock's user namespace, so this is a no-op there and only takes effect on an idmapped mount that does not map the caller. It applies to every filesystem that sets FS_ALLOW_IDMAP and implements ->tmpfile() (tmpfs, ext4, btrfs, xfs, f2fs, ...), and to overlayfs, whose upper-layer tmpfile creation funnels through vfs_tmpfile() via backing_tmpfile_open().
--- fs/namei.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/namei.c +4 -0
@@ -4011,6 +4011,10 @@ int vfs_tmpfile(struct mnt_idmap *idmap,int error;int open_flag = file->f_flags; +/* A tmpfile is I_LINKABLE, so guard its owner like may_o_create(). */ +if (!fsuidgid_has_mapping (dir->i_sb, idmap)) +return -EOVERFLOW ; +/* we want directory to be writable */ error =inode_permission (idmap, dir,MAY_WRITE |MAY_EXEC );if (error)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 999/1611 afs: Fix error code in afs_extract_vl_addrs()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 4897cb71d4ab1f7e1a214adb1e4b80176702368d ]
The error codes on these paths are only set on the first iteration through the loop. Set the correct error code on every iteration.
--- fs/afs/vl_list.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/afs/vl_list.c +3 -1
@@ -93,7 +93,7 @@ static struct afs_addr_list *afs_extract_vl_addrs(struct afs_net *net, {struct afs_addr_list *alist;const u8 *b = *_b; -int ret = -EINVAL ; +int ret; alist =afs_alloc_addrlist (nr_addrs);if (!alist)
@@ -111,6 +111,7 @@ static struct afs_addr_list *afs_extract_vl_addrs(struct afs_net *net,case DNS_ADDRESS_IS_IPV4 :if (end - b <4 ) {_leave (" = -EINVAL [short inet]" ); + ret = -EINVAL ; goto error; }memcpy (x, b,4 );
@@ -123,6 +124,7 @@ static struct afs_addr_list *afs_extract_vl_addrs(struct afs_net *net,case DNS_ADDRESS_IS_IPV6 :if (end - b <16 ) {_leave (" = -EINVAL [short inet6]" ); + ret = -EINVAL ; goto error; }memcpy (x, b,16 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1000/1611 afs: Fix double netfs initialisation in afs_root_iget()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 733a984a4ee7345325e47efb505eebfe67b299bc ]
Fix afs_root_iget() to leave initialisation of the netfs_inode part of the afs_vnode to afs_inode_init_from_status().
--- fs/afs/inode.c | 1 - 1 file changed, 1 deletion(-)
fs/afs/inode.c +0 -1
@@ -643,7 +643,6 @@ struct inode *afs_root_iget(struct super_block *sb, struct key *key) vnode =AFS_FS_I (inode); vnode->cb_v_check =atomic_read (&as->volume->cb_v_break); -afs_set_netfs_context (vnode); op =afs_alloc_operation (key, as->volume);if (IS_ERR (op)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1001/1611 afs: use kvfree() to free memory allocated by kvcalloc()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zilin Guan <[email protected]>
[ Upstream commit cb39654926f8e7a08ecc1dcb3941628855275940 ]
op->more_files is allocated with kvcalloc() but released via afs_put_operation(), which uses kfree() internally. This mismach prevents the resource from being released properly and may lead to undefined behavior.
Fix this by using kvfree() to free op->more_files to match its allocation method.
--- fs/afs/fs_operation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/fs_operation.c +1 -1
@@ -348,7 +348,7 @@ int afs_put_operation(struct afs_operation *op)for (i =0 ; i < op->nr_files -2 ; i++)if (op->more_files[i].put_vnode)iput (&op->more_files[i].vnode->netfs.inode); -kfree (op->more_files); +kvfree (op->more_files); }if (op->estate) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1002/1611 afs: Remove erroneous seq |= 1 in volume lookup loop
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit a58edda50a3ec08e6adac1d04dc3e488494e412d ]
The seq |= 1 operation in the volume lookup loop is incorrect because:
seq is already incremented at start, making it odd in next iteration which triggers lock, but The |= 1 operation causes seq to be even and unintended lockless operation
Remove this erroneous operation to maintain proper lock sequencing.
--- fs/afs/callback.c | 1 - 1 file changed, 1 deletion(-)
fs/afs/callback.c +0 -1
@@ -140,7 +140,6 @@ static struct afs_volume *afs_lookup_volume_rcu(struct afs_cell *cell,break ;if (!need_seqretry (&cell->volume_lock, seq))break ; - seq |=1 ;/* Want a lock next time */ }done_seqretry (&cell->volume_lock, seq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1003/1611 afs: Fix bulk lookup malfunction due to change in dir_emit() API
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 2f79d1b93c62470fe02dbdc24770f1ae5a9e1be6 ]
afs_do_lookup() and afs_do_lookup_one() use the same directory parsing code as afs_readdir() and were supplying alternative dir_context actors to retrieve dirents, but because lookup needs the vnode's uniquifier as part of the reference, but not the DT flags, the uniquifier was being passed in the dt flags argument to the lookup actors.
Unfortunately, commit c644bce62b9c, added to fix overlayfs with fuse, broke this by masking off part of the uniquifier. This doesn't matter enough to be directly noticeable, instead causing bulk advance inode lookups to fail (which are retried later) and may cause dir revalidation to malfunction if the uniquifier is changed by masking.
Fix this by making the afs directory parsing code take special ->actor values of AFS_LOOKUP or AFS_LOOKUP_ONE instead that tell it to call afs_lookup_filldir() or afs_lookup_one_filldir() directly rather than going through dir_emit(). dir_emit() is still used for readdir.
--- fs/afs/dir.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-)
fs/afs/dir.c +25 -15
@@ -28,9 +28,11 @@ static int afs_d_revalidate(struct inode *dir, const struct qstr *name,static int afs_d_delete (const struct dentry *dentry);static void afs_d_iput (struct dentry *dentry,struct inode *inode);static bool afs_lookup_one_filldir (struct dir_context *ctx,const char *name,int nlen, -loff_t fpos,u64 ino,unsigned dtype); +u64 ino,u32 uniquifier); +#define AFS_LOOKUP_ONE ((filldir_t)0x123UL)static bool afs_lookup_filldir (struct dir_context *ctx,const char *name,int nlen, -loff_t fpos,u64 ino,unsigned dtype); +u64 ino,u32 uniquifier); +#define AFS_LOOKUP ((filldir_t)0x137UL)static int afs_create (struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,umode_t mode,bool excl); static struct dentry *afs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
@@ -434,11 +436,18 @@ static int afs_dir_iterate_block(struct afs_vnode *dvnode, }/* found the next entry */ -if (!dir_emit (ctx, dire->u.name, nlen, -ntohl (dire->u.vnode), - (ctx->actor == afs_lookup_filldir || - ctx->actor == afs_lookup_one_filldir)? -ntohl (dire->u.unique) :DT_UNKNOWN )) { +if (ctx->actor ==AFS_LOOKUP ) { +if (!afs_lookup_filldir (ctx, dire->u.name, nlen, +ntohl (dire->u.vnode), +ntohl (dire->u.unique))) +return 0 ; + }else if (ctx->actor ==AFS_LOOKUP_ONE ) { +if (!afs_lookup_one_filldir (ctx, dire->u.name, nlen, +ntohl (dire->u.vnode), +ntohl (dire->u.unique))) +return 0 ; + }else if (!dir_emit (ctx, dire->u.name, nlen, +ntohl (dire->u.vnode),DT_UNKNOWN )) {_leave (" = 0 [full]" );return 0 ; }
@@ -558,6 +567,7 @@ static int afs_readdir(struct file *file, struct dir_context *ctx) {afs_dataversion_t dir_version; + ctx->dt_flags_mask =UINT_MAX ;return afs_dir_iterate (file_inode (file), ctx, file, &dir_version); }
@@ -567,14 +577,14 @@ static int afs_readdir(struct file *file, struct dir_context *ctx)* uniquifier through dtype */ static bool afs_lookup_one_filldir (struct dir_context *ctx,const char *name, -int nlen,loff_t fpos,u64 ino,unsigned dtype) +int nlen,u64 ino,u32 uniquifier) {struct afs_lookup_one_cookie *cookie = container_of(ctx, struct afs_lookup_one_cookie, ctx);_enter ("{%s,%u},%s,%u,,%llu,%u" , cookie->name.name, cookie->name.len, name, nlen, - (unsigned long long ) ino, dtype); + (unsigned long long ) ino, uniquifier);/* insanity checks first */ BUILD_BUG_ON (sizeof (union afs_xdr_dir_block ) !=2048 );
@@ -587,7 +597,7 @@ static bool afs_lookup_one_filldir(struct dir_context *ctx, const char *name, } cookie->fid.vnode = ino; - cookie->fid.unique = dtype; + cookie->fid.unique = uniquifier; cookie->found =1 ;_leave (" = false [found]" );
@@ -604,7 +614,7 @@ static int afs_do_lookup_one(struct inode *dir, const struct qstr *name, {struct afs_super_info *as = dir->i_sb->s_fs_info;struct afs_lookup_one_cookie cookie = { - .ctx.actor = afs_lookup_one_filldir, + .ctx.actor =AFS_LOOKUP_ONE , .name = *name, .fid.vid = as->volume->vid };
@@ -635,14 +645,14 @@ static int afs_do_lookup_one(struct inode *dir, const struct qstr *name,* uniquifier through dtype */ static bool afs_lookup_filldir (struct dir_context *ctx,const char *name, -int nlen,loff_t fpos,u64 ino,unsigned dtype) +int nlen,u64 ino,u32 uniquifier) {struct afs_lookup_cookie *cookie = container_of(ctx, struct afs_lookup_cookie, ctx);_enter ("{%s,%u},%s,%u,,%llu,%u" , cookie->name.name, cookie->name.len, name, nlen, - (unsigned long long ) ino, dtype); + (unsigned long long ) ino, uniquifier);/* insanity checks first */ BUILD_BUG_ON (sizeof (union afs_xdr_dir_block ) !=2048 );
@@ -650,7 +660,7 @@ static bool afs_lookup_filldir(struct dir_context *ctx, const char *name,if (cookie->nr_fids <50 ) { cookie->fids[cookie->nr_fids].vnode = ino; - cookie->fids[cookie->nr_fids].unique = dtype; + cookie->fids[cookie->nr_fids].unique = uniquifier; cookie->nr_fids++; }
@@ -791,7 +801,7 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry)for (i =0 ; i <ARRAY_SIZE (cookie->fids); i++) cookie->fids[i].vid = dvnode->fid.vid; - cookie->ctx.actor = afs_lookup_filldir; + cookie->ctx.actor =AFS_LOOKUP ; cookie->name = dentry->d_name; cookie->nr_fids =2 ;/* slot 1 is saved for the fid we actually want * and slot 0 for the directory */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1004/1611 afs: Fix misplaced inc of net->cells_outstanding
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit c9c3b615a462a4023bd148f02c564e175ed10502 ]
Fix net->cells_outstanding being incremented before the check for failure of idr_alloc_cyclic(), leaving the count incremented on error.
--- fs/afs/cell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/cell.c +1 -1
@@ -205,11 +205,11 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net, cell->dns_source = vllist->source; cell->dns_status = vllist->status;smp_store_release (&cell->dns_lookup_count,1 );/* vs source/status */ -atomic_inc (&net->cells_outstanding); ret =idr_alloc_cyclic (&net->cells_dyn_ino, cell,2 ,INT_MAX /2 ,GFP_KERNEL );if (ret <0 ) goto error; +atomic_inc (&net->cells_outstanding); cell->dynroot_ino = ret; cell->debug_id =atomic_inc_return (&cell_debug_id);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1005/1611 afs: Fix reinitialisation of the inode, in particular ->lock_work
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 5597fbd1e7c161914f20315a726e54025b0fdadb ]
It seems that initalising afs_vnode::lock_work a single time in the slab's init function isn't sufficient for work_structs. This results in the DEBUG_OBJECTS debugging stuff producing a warning occasionally when running the generic/131 xfstest:
ODEBUG: activate not available (active state 0) object: 0000000016d8760f object type: work_struct hint: afs_lock_work+0x0/0x220
WARNING: lib/debugobjects.c:629 at debug_print_object+0x4b/0x90, CPU#3: locktest/7695 ... CPU: 3 UID: 0 PID: 7695 Comm: locktest Tainted: G S 7.1.0-build3+ #2771 PREEMPT ... RIP: 0010:debug_print_object+0x65/0x90 ... Call Trace: <TASK> ? __pfx_afs_lock_work+0x10/0x10 debug_object_activate+0x122/0x170 insert_work+0x25/0x60 __queue_work+0x2e0/0x340 queue_delayed_work_on+0x48/0x70 afs_fl_release_private+0x57/0x70 locks_release_private+0x5c/0xa0 locks_free_lock+0xe/0x20 posix_lock_inode+0x55f/0x5b0 locks_lock_inode_wait+0x81/0x140 ? file_write_and_wait_range+0x50/0x70 afs_lock+0xcd/0x110 fcntl_setlk+0x10d/0x260 do_fcntl+0x24e/0x5b0 __do_sys_fcntl+0x6a/0x90 do_syscall_64+0x11e/0x310 entry_SYSCALL_64_after_hwframe+0x71/0x79
Fix this by reinitialising ->lock_work after allocating an inode.
Also, flush ->lock_work when the inode is being evicted to make sure it's not still running.
--- fs/afs/inode.c | 1 + fs/afs/super.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
fs/afs/inode.c +1 -0
@@ -758,6 +758,7 @@ void afs_evict_inode(struct inode *inodeafs_single_writepages (inode->i_mapping, &wbc); } +flush_delayed_work (&vnode->lock_work);netfs_wait_for_outstanding_io (inode);truncate_inode_pages_final (&inode->i_data);netfs_free_folioq_buffer (vnode->directory);
fs/afs/super.c +1 -1
@@ -660,7 +660,6 @@ static void afs_i_init_once(void *_vnodeINIT_LIST_HEAD (&vnode->wb_keys);INIT_LIST_HEAD (&vnode->pending_locks);INIT_LIST_HEAD (&vnode->granted_locks); -INIT_DELAYED_WORK (&vnode->lock_work, afs_lock_work);INIT_LIST_HEAD (&vnode->cb_mmap_link);seqlock_init (&vnode->cb_lock); }
@@ -694,6 +693,7 @@ static struct inode *afs_alloc_inode(strinit_rwsem (&vnode->rmdir_lock);INIT_WORK (&vnode->cb_work, afs_invalidate_mmap_work); +INIT_DELAYED_WORK (&vnode->lock_work, afs_lock_work);_leave (" = %p" , &vnode->netfs.inode);return &vnode->netfs.inode;
Greg Kroah-Hartman
maintainerPATCH 1006/1611 afs: Fix callback service message parsers to pass through -EAGAIN
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 0f36469d7ce98b362934113c550d08bb0c784231 ]
The AFS filesystem client uses an rxrpc server to listen for callback notifications. Each callback call type handler has a delivery function that parses the incoming request stream, and this should return -EAGAIN the last packet hasn't yet been seen, but all currently queued received data is consumed. afs_extract_data() does this, but the -EAGAIN return is switched to 0 inadvertantly
Fix callback service message parsers to pass through -EAGAIN
--- fs/afs/cmservice.c | 2 -- 1 file changed, 2 deletions(-)
fs/afs/cmservice.c +0 -2
@@ -335,7 +335,6 @@ static int afs_deliver_cb_init_call_back ret =afs_extract_data (call, false);switch (ret) {case 0 :break ; -case -EAGAIN :return 0 ;default :return ret; }
@@ -457,7 +456,6 @@ static int afs_deliver_cb_probe_uuid(str ret =afs_extract_data (call, false);switch (ret) {case 0 :break ; -case -EAGAIN :return 0 ;default :return ret; }
Greg Kroah-Hartman
maintainerPATCH 1007/1611 afs: Fix missing NULL pointer check in afs_break_some_callbacks()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 794a01110390c1b76f59ece773fb0fbfd89c6f5c ]
Fix afs_break_some_callbacks() to check to see if afs_lookup_volume_rcu() returned NULL (e.g. the specified volume is unknown).
--- fs/afs/callback.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/afs/callback.c +5 -1
@@ -220,7 +220,11 @@ static void afs_break_some_callbacks(struct afs_server *server,rcu_read_lock (); volume =afs_lookup_volume_rcu (server->cell, vid); -if (cbb->fid.vnode ==0 && cbb->fid.unique ==0 ) { +if (!volume) { +/* Ignore breaks on unknown volumes. */ +rcu_read_unlock (); + *_count =0 ; + }else if (cbb->fid.vnode ==0 && cbb->fid.unique ==0 ) {afs_break_volume_callback (server, volume); *_count -=1 ;if (*_count)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1008/1611 afs: Fix vllist leak
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit fc10c0ecf06f2981af5d04357612b00051e03e9e ]
Fix a leak of the new vllist in afs_update_cell() in the event that it is an empty list (nr_servers == 0), in which case the old list isn't displaced unless the old list is also empty.
--- fs/afs/cell.c | 2 ++ 1 file changed, 2 insertions(+)
fs/afs/cell.c +2 -0
@@ -547,6 +547,8 @@ static int afs_update_cell(struct afs_cell *cell)rcu_assign_pointer (cell->vl_servers, vllist); cell->dns_source = vllist->source; old = p; + }else { + old = vllist; }write_unlock (&cell->vl_servers_lock);afs_put_vlserverlist (cell->net, old);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1009/1611 afs: Fix lack of locking around modifications of net->cells_dyn_ino
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 55e841836c6f4646490f7b0347192b7a92d431ba ]
Fix the lack of locking around modifications of net->cells_dyn_ino by taking net->cells_lock exclusively. This also requires to cell to be removed from net->cells_dyn_ino in afs_destroy_cell_work() rather than in afs_cell_destroy() as the latter runs in RCU cleanup context and sleeping locks cannot be taken there.
--- fs/afs/cell.c | 8 +++++++- fs/afs/dynroot.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-)
fs/afs/cell.c +7 -1
@@ -205,8 +205,10 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net, cell->dns_source = vllist->source; cell->dns_status = vllist->status;smp_store_release (&cell->dns_lookup_count,1 );/* vs source/status */ +down_write (&net->cells_lock); ret =idr_alloc_cyclic (&net->cells_dyn_ino, cell,2 ,INT_MAX /2 ,GFP_KERNEL ); +up_write (&net->cells_lock);if (ret <0 ) goto error;atomic_inc (&net->cells_outstanding);
@@ -579,7 +581,6 @@ static void afs_cell_destroy(struct rcu_head *rcu)afs_put_vlserverlist (net,rcu_access_pointer (cell->vl_servers));afs_unuse_cell (cell->alias_of, afs_cell_trace_unuse_alias);key_put (cell->anonymous_key); -idr_remove (&net->cells_dyn_ino, cell->dynroot_ino);kfree (cell->name -1 );kfree (cell);
@@ -594,6 +595,11 @@ static void afs_destroy_cell_work(struct work_struct *work)afs_see_cell (cell, afs_cell_trace_destroy);timer_delete_sync (&cell->management_timer);cancel_work_sync (&cell->manager); + +down_write (&cell->net->cells_lock); +idr_remove (&cell->net->cells_dyn_ino, cell->dynroot_ino); +up_write (&cell->net->cells_lock); +call_rcu (&cell->rcu, afs_cell_destroy); }
fs/afs/dynroot.c +1 -1
@@ -278,7 +278,7 @@ static struct dentry *afs_lookup_atcell(struct inode *dir, struct dentry *dentry }/* -* Transcribe the cell database into readdir content under the RCU read lock. +* Transcribe the cell database into readdir content under net->cells_lock. * Each cell produces two entries, one prefixed with a dot and one not. */ static int afs_dynroot_readdir_cells (struct afs_net *net,struct dir_context *ctx)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1010/1611 afs: Fix premature cell exposure through /afs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 26f17ce6fa3f05cb5965790499c1839094260de4 ]
AFS cell records are prematurely exposured through the /afs dynamic root by virtue of adding them immediately to the net->cells_dyn_ino IDR when the cell is allocated rather than when it is added to the lookup tree. This allows a candidate record to be accessed, even if it's actually a duplicate or not published yet.
Fix this by not adding the cell to cells_dyn_ino until it's confirmed non-duplicate and is being published. A flag is then used to record whether it is added to the IDR to make removal from the IDR conditional.
--- fs/afs/cell.c | 27 +++++++++++++++++---------- fs/afs/internal.h | 1 + 2 files changed, 18 insertions(+), 10 deletions(-)
fs/afs/cell.c +17 -10
@@ -205,14 +205,7 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net, cell->dns_source = vllist->source; cell->dns_status = vllist->status;smp_store_release (&cell->dns_lookup_count,1 );/* vs source/status */ -down_write (&net->cells_lock); - ret =idr_alloc_cyclic (&net->cells_dyn_ino, cell, -2 ,INT_MAX /2 ,GFP_KERNEL ); -up_write (&net->cells_lock); -if (ret <0 ) - goto error;atomic_inc (&net->cells_outstanding); - cell->dynroot_ino = ret; cell->debug_id =atomic_inc_return (&cell_debug_id);trace_afs_cell (cell->debug_id,1 ,0 , afs_cell_trace_alloc);
@@ -306,6 +299,13 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net, goto cell_already_exists; } + ret =idr_alloc_cyclic (&net->cells_dyn_ino, candidate, +2 ,INT_MAX /2 ,GFP_KERNEL ); +if (ret <0 ) + goto cant_alloc_ino; + candidate->dynroot_ino = ret; +set_bit (AFS_CELL_FL_HAVE_INO , &candidate->flags); + cell = candidate; candidate =NULL ;afs_use_cell (cell, trace);
@@ -380,6 +380,11 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,_leave (" = %p [cell]" , cell);return cell; +cant_alloc_ino: +up_write (&net->cells_lock); +afs_put_cell (candidate, afs_cell_trace_put_candidate); + goto error_noput; + cell_already_exists:_debug ("cell exists" ); cell = cursor;
@@ -596,9 +601,11 @@ static void afs_destroy_cell_work(struct work_struct *work)timer_delete_sync (&cell->management_timer);cancel_work_sync (&cell->manager); -down_write (&cell->net->cells_lock); -idr_remove (&cell->net->cells_dyn_ino, cell->dynroot_ino); -up_write (&cell->net->cells_lock); +if (test_bit (AFS_CELL_FL_HAVE_INO , &cell->flags)) { +down_write (&cell->net->cells_lock); +idr_remove (&cell->net->cells_dyn_ino, cell->dynroot_ino); +up_write (&cell->net->cells_lock); + }call_rcu (&cell->rcu, afs_cell_destroy); }
fs/afs/internal.h +1 -0
@@ -389,6 +389,7 @@ struct afs_cell {#define AFS_CELL_FL_NO_GC 0/* The cell was added manually, don't auto-gc */ #define AFS_CELL_FL_DO_LOOKUP 1/* DNS lookup requested */ #define AFS_CELL_FL_CHECK_ALIAS 2/* Need to check for aliases */ +#define AFS_CELL_FL_HAVE_INO 3/* Have dynroot_ino */ enum afs_cell_state state;short error; enum dns_record_source dns_source:8; /* Latest source of data from lookup */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1011/1611 afs: Fix the volume AFS_VOLUME_RM_TREE is set on
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 56b4e4b26f84411d880f968a539207b0a8889c8c ]
Fix afs_insert_volume_into_cell() to set AFS_VOLUME_RM_TREE on the volume replaced, not the new volume, as it's now removed from the cell's volume tree. This will cause the old volume to be removed from the tree twice and the new volume never to be removed.
--- fs/afs/volume.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/volume.c +1 -1
@@ -40,7 +40,7 @@ static struct afs_volume *afs_insert_volume_into_cell(struct afs_cell *cell, goto found; } -set_bit (AFS_VOLUME_RM_TREE , &volume->flags); +set_bit (AFS_VOLUME_RM_TREE , &p->flags);rb_replace_node_rcu (&p->cell_node, &volume->cell_node, &cell->volumes); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1012/1611 afs: Fix unchecked-length string display in debug statement
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 903d37c97228258da71e092f8b4ab260ce81497d ]
Fix afs_extract_vlserver_list() to limit the length of the displayed string in a debug statement().
--- fs/afs/vl_list.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/afs/vl_list.c +5 -1
@@ -201,6 +201,8 @@ struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *cell, b +=sizeof (*hdr);while (end - b >=sizeof (bs)) { +int nlen; + bs.name_len =afs_extract_le16 (&b); bs.priority =afs_extract_le16 (&b); bs.weight =afs_extract_le16 (&b);
@@ -210,10 +212,12 @@ struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *cell, bs.protocol = *b++; bs.nr_addrs = *b++; + nlen =min3 (bs.name_len, end - b,255 ); +_debug ("extract %u %u %u %u %u %u %*.*s" , bs.name_len, bs.priority, bs.weight, bs.port, bs.protocol, bs.nr_addrs, - bs.name_len, bs.name_len, b); + bs.name_len, nlen, b);if (end - b < bs.name_len)break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1013/1611 minix: avoid overflow in bitmap block count calculation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit fb3e566cafc38fe3ba35e6843a2d529a3748870c ]
minix_check_superblock() uses minix_blocks_needed() to verify that the on-disk imap and zmap block counts are large enough for the advertised inode and zone counts.
The helper currently performs DIV_ROUND_UP() in unsigned int arithmetic. A Minix v3 image can set s_ninodes or s_zones near UINT_MAX so the addition inside DIV_ROUND_UP() wraps to zero. That makes a zero imap/zmap block count look valid, after which minix_fill_super() can dereference s_imap[0] or s_zmap[0] even though no bitmap buffers were allocated.
Impact: mounting a crafted Minix v3 image whose s_ninodes or s_zones is near UINT_MAX makes minix_check_superblock() accept a zero bitmap-block count and minix_fill_super() dereference s_imap[0]/s_zmap[0], panicking the kernel.
The divisor is the bitmap capacity in bits, blocksize * 8, which is always a power of two: minix_fill_super() obtains the block size through sb_set_blocksize(), and blk_validate_block_size() rejects any size that is not a power of two. Use DIV_ROUND_UP_POW2(), which divides before adding the round-up term and so cannot overflow for a power-of-two divisor.
--- fs/minix/minix.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/minix/minix.h +1 -1
@@ -91,7 +91,7 @@ static inline struct minix_inode_info *minix_i(struct inode *inode)static inline unsigned minix_blocks_needed (unsigned bits,unsigned blocksize) { -return DIV_ROUND_UP (bits, blocksize *8 ); +return DIV_ROUND_UP_POW2 (bits, blocksize *8 ); } #if defined(CONFIG_MINIX_FS_NATIVE_ENDIAN) && \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1014/1611 ovl: fix comment about locking order
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
[ Upstream commit fd5637a2fe6dd4448392738691d63e5559fafb12 ]
Forgot to update the comment when we changed the locking order.
--- fs/overlayfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/overlayfs/inode.c +2 -2
@@ -800,8 +800,8 @@ static const struct address_space_operations ovl_aops = {* * This chain is valid: * - inode->i_rwsem (inode_lock[2]) -* - upper_mnt->mnt_sb->s_writers (ovl_want_write[0]) * - OVL_I(inode)->lock (ovl_inode_lock[2]) +* - upper_mnt->mnt_sb->s_writers (ovl_want_write[0]) * - OVL_I(lowerinode)->lock (ovl_inode_lock[1]) * * And this chain is valid:
@@ -814,8 +814,8 @@ static const struct address_space_operations ovl_aops = {* held, because it is in reverse order of the non-nested case using the same * upper fs: * - inode->i_rwsem (inode_lock[1]) -* - upper_mnt->mnt_sb->s_writers (ovl_want_write[0]) * - OVL_I(inode)->lock (ovl_inode_lock[1]) +* - upper_mnt->mnt_sb->s_writers (ovl_want_write[0]) */ #define OVL_MAX_NESTING FILESYSTEM_MAX_STACK_DEPTH
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1015/1611 iomap: guard io_size EOF trim against concurrent truncate underflow
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Morduan Zang <[email protected]>
[ Upstream commit 55ec50d046c03b3724741957f7b007856e36dbe7 ]
iomap: fix zero padding data issue in concurrent append writes changed ioend accounting so that io_size tracks only valid data within EOF. This trims io_size when a writeback range extends past end_pos:
ioend->io_size += map_len;
if (ioend->io_offset + ioend->io_size > end_pos)
ioend->io_size = end_pos - ioend->io_offset;However, if end_pos ends up below ioend->io_offset, the subtraction becomes negative and is stored in size_t io_size, causing an unsigned wrap to a huge value. This can happen when writeback continues past byte-level EOF up to a block-aligned range, or when a concurrent truncate shrinks the file after end_pos was sampled in iomap_writeback_handle_eof().
A wrapped io_size can mislead append detection and corrupt completion-time size handling, since filesystem end_io paths consume io_size for decisions such as on-disk EOF updates and unwritten/COW completion ranges.
Fix this by clamping io_size to zero when EOF has moved to or before the ioend start offset. This preserves the original intent of trimming io_size to valid in-EOF data while avoiding the underflow.
--- fs/iomap/ioend.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/iomap/ioend.c +6 -2
@@ -239,8 +239,12 @@ ssize_t iomap_add_to_ioend(struct iomap_writepage_ctx *wpc, struct folio *folio,* appending writes. */ ioend->io_size += map_len; -if (ioend->io_offset + ioend->io_size > end_pos) - ioend->io_size = end_pos - ioend->io_offset; +if (ioend->io_offset + ioend->io_size > end_pos) { +if (ioend->io_offset >= end_pos) + ioend->io_size =0 ; +else + ioend->io_size = end_pos - ioend->io_offset; + }wbc_account_cgroup_owner (wpc->wbc, folio, map_len);return map_len;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1016/1611 netfs: Fix netfs_create_write_req() to handle async cache object creation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit dbd6f56d975b23241b7bbb11bb8f562af548a0aa ]
netfs_create_write_req() will skip caching if the fscache cookie is disabled, but this is a problem because async cache object creation might not have got far enough yet that has been enabled - thereby causing the call to fscache_begin_write_operation() to be skipped.
Fix this by removing the checks on the cookie and delegating this to fscache_begin_write_operation().
--- fs/netfs/write_issue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/netfs/write_issue.c +1 -1
@@ -106,7 +106,7 @@ struct netfs_io_request *netfs_create_write_req(struct address_space *mapping,_enter ("R=%x" , wreq->debug_id); ictx =netfs_inode (wreq->inode); -if (is_cacheable &&netfs_is_cache_enabled (ictx)) +if (is_cacheable)fscache_begin_write_operation (&wreq->cache_resources,netfs_i_cookie (ictx));if (rolling_buffer_init (&wreq->buffer, wreq->debug_id,ITER_SOURCE ) <0 ) goto nomem;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1017/1611 netfs: Fix writethrough to use collection offload
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit ba6a9f6533c77c628eef0c0c5c19cd316e2be1b4 ]
Fix writethrough write to set NETFS_RREQ_OFFLOAD_COLLECTION on the request so that collection is processed asynchronously rather than only right at the end - and also so that asynchronous O_SYNC writes get collected at all.
--- fs/netfs/write_issue.c | 1 + 1 file changed, 1 insertion(+)
fs/netfs/write_issue.c +1 -0
@@ -627,6 +627,7 @@ struct netfs_io_request *netfs_begin_writethrough(struct kiocb *iocb, size_t len } wreq->io_streams[0 ].avail = true; +__set_bit (NETFS_RREQ_OFFLOAD_COLLECTION , &wreq->flags);trace_netfs_write (wreq, netfs_write_trace_writethrough);return wreq; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1018/1611 netfs: Fix writeback error handling
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit ac5f95ac5d6d0f4c567b8b642825705a2bf0d79e ]
Fix the error handling in writeback_iter() loop. If an error occurs, writeback_iter() needs to be called again with *error set to the error so that it can clean up iteration state. Further, the current folio needs unlocking and redirtying.
--- fs/netfs/write_issue.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
fs/netfs/write_issue.c +8 -3
@@ -587,8 +587,6 @@ int netfs_writepages(struct address_space *mapping, } error =netfs_write_folio (wreq, wbc, folio); -if (error <0 ) -break ; }while ((folio =writeback_iter (mapping, wbc, folio, &error)));netfs_end_issue_write (wreq);
@@ -601,7 +599,14 @@ int netfs_writepages(struct address_space *mapping,return error; couldnt_start: -netfs_kill_dirty_pages (mapping, wbc, folio); +if (error == -ENOMEM ) { +folio_redirty_for_writepage (wbc, folio); +folio_unlock (folio); + folio =writeback_iter (mapping, wbc, folio, &error); +WARN_ON_ONCE (folio !=NULL ); + }else { +netfs_kill_dirty_pages (mapping, wbc, folio); + } out:mutex_unlock (&ictx->wb_lock);_leave (" = %d" , error);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1019/1611 netfs: Fix folio state after ENOMEM whilst under writeback iteration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit b6a713fd34b9498ee2164d5d3e8460732a392efc ]
Fix the state of the current folio when ENOMEM occurs during writeback iteration. The folio needs to be redirtied and unlocked before the terminal writeback_iter() is invoked.
--- fs/netfs/write_issue.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/netfs/write_issue.c +4 -0
@@ -587,6 +587,10 @@ int netfs_writepages(struct address_space *mapping, } error =netfs_write_folio (wreq, wbc, folio); +if (error == -ENOMEM ) { +folio_redirty_for_writepage (wbc, folio); +folio_unlock (folio); + } }while ((folio =writeback_iter (mapping, wbc, folio, &error)));netfs_end_issue_write (wreq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1020/1611 drm/xe/pt: Fix NULL pointer dereference in xe_pt_zap_ptes_entry()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francois Dugast <[email protected]>
[ Upstream commit 3feeb667197bd58a17f4edfdbcad249ffcb3c864 ]
The page-table walk framework may pass a NULL *child pointer for unpopulated entries. xe_pt_zap_ptes_entry() called container_of(*child) before checking for NULL, then dereferenced the result, causing a crash.
Move the container_of() call after a NULL guard, so the function returns early instead of proceeding with an invalid pointer. XE_WARN_ON is kept to help root cause the issue, but we now bail instead of crashing the driver.
v2: Comment that triggering XE_WARN_ON is unexpected behavior (Matt Brost)
--- drivers/gpu/drm/xe/xe_pt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_pt.c +10 -2
@@ -860,12 +860,20 @@ static int xe_pt_zap_ptes_entry(struct xe_ptw *parent, pgoff_t offset, {struct xe_pt_zap_ptes_walk *xe_walk =container_of (walk,typeof (*xe_walk), base); -struct xe_pt *xe_child =container_of (*child,typeof (*xe_child), base); +struct xe_pt *xe_child;pgoff_t end_offset; -XE_WARN_ON (!*child);XE_WARN_ON (!level); +/* +* Below would be unexpected behavior that needs to be root caused +* but better warn and bail than crash the driver. +*/ +if (XE_WARN_ON (!*child)) +return 0 ; + + xe_child =container_of (*child,typeof (*xe_child), base); +/* * Note that we're called from an entry callback, and we're dealing * with the child of that entry rather than the parent, so need to
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1021/1611 drm/xe/userptr: Hold notifier_lock for write on inject test path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuicheng Lin <[email protected]>
[ Upstream commit dca6e08c923a44d2d66b955e03dd57a3a38c2b94 ]
When CONFIG_DRM_XE_USERPTR_INVAL_INJECT=y, xe_pt_svm_userptr_pre_commit() runs vma_check_userptr() with the svm notifier_lock taken for read. The test injection causes vma_check_userptr() to call xe_vma_userptr_force_invalidate(), which feeds into xe_vma_userptr_do_inval() with drm_gpusvm_ctx.in_notifier=true. That flag tells drm_gpusvm_unmap_pages() the caller already holds notifier_lock for write and only asserts the mode. Because the caller actually holds it for read, the assertion fires:
WARNING: drivers/gpu/drm/drm_gpusvm.c:1669 at \
drm_gpusvm_unmap_pages+0xd4/0x130 [drm_gpusvm_helper]
Call Trace:
xe_vma_userptr_do_inval+0x40d/0xfd0 [xe]
xe_vma_userptr_invalidate_pass1+0x3e6/0x8d0 [xe]
xe_vma_userptr_force_invalidate+0xde/0x290 [xe]
vma_check_userptr.constprop.0+0x1c6/0x220 [xe]
xe_pt_svm_userptr_pre_commit+0x6a3/0xc60 [xe]
...
xe_vm_bind_ioctl+0x3a0a/0x4480 [xe]Acquire notifier_lock for write in pre-commit when the inject Kconfig is enabled, via new helpers xe_pt_svm_userptr_notifier_lock()/_unlock(). Rename xe_svm_assert_held_read() to xe_svm_assert_held_read_or_inject_write() so it asserts the correct mode under each build configuration. Production builds (CONFIG_DRM_XE_USERPTR_INVAL_INJECT=n) keep the existing read-mode behavior bit-for-bit.
--- drivers/gpu/drm/xe/xe_pt.c | 43 ++++++++++++++++++++++++++++++------- drivers/gpu/drm/xe/xe_svm.h | 15 +++++++++++-- 2 files changed, 48 insertions(+), 10 deletions(-)
drivers/gpu/drm/xe/xe_pt.c +35 -8
@@ -1061,7 +1061,7 @@ static void xe_pt_commit_locks_assert(struct xe_vma *vma)xe_pt_commit_prepare_locks_assert (vma);if (xe_vma_is_userptr (vma)) -xe_svm_assert_held_read (vm); +xe_svm_assert_held_read_or_inject_write (vm); } static void xe_pt_commit(struct xe_vma *vma,
@@ -1388,6 +1388,33 @@ static int xe_pt_pre_commit(struct xe_migrate_pt_update *pt_update) pt_update_ops, rftree); } +/* +* Acquire/release the svm notifier_lock around xe_pt_svm_userptr_pre_commit() +* and the matching late release in xe_pt_update_ops_run(). Read mode by +* default; write mode when CONFIG_DRM_XE_USERPTR_INVAL_INJECT is on, +* because a userptr op in this critical section may invoke the injected +* xe_vma_userptr_force_invalidate() path that calls +* drm_gpusvm_unmap_pages() with ctx->in_notifier=true, which requires the +* lock held for write. +*/ +static void xe_pt_svm_userptr_notifier_lock (struct xe_vm *vm) +{ +#if IS_ENABLED (CONFIG_DRM_XE_USERPTR_INVAL_INJECT ) +down_write (&vm->svm.gpusvm.notifier_lock); +#else +xe_svm_notifier_lock (vm); +#endif +} + +static void xe_pt_svm_userptr_notifier_unlock (struct xe_vm *vm) +{ +#if IS_ENABLED (CONFIG_DRM_XE_USERPTR_INVAL_INJECT ) +up_write (&vm->svm.gpusvm.notifier_lock); +#else +xe_svm_notifier_unlock (vm); +#endif +} +#if IS_ENABLED (CONFIG_DRM_GPUSVM )#ifdef CONFIG_DRM_XE_USERPTR_INVAL_INJECT
@@ -1419,7 +1446,7 @@ static int vma_check_userptr(struct xe_vm *vm, struct xe_vma *vma,struct xe_userptr_vma *uvma;unsigned long notifier_seq; -xe_svm_assert_held_read (vm); +xe_svm_assert_held_read_or_inject_write (vm);if (!xe_vma_is_userptr (vma))return 0 ;
@@ -1449,7 +1476,7 @@ static int op_check_svm_userptr(struct xe_vm *vm, struct xe_vma_op *op, {int err =0 ; -xe_svm_assert_held_read (vm); +xe_svm_assert_held_read_or_inject_write (vm);switch (op->base.op) {case DRM_GPUVA_OP_MAP :
@@ -1521,12 +1548,12 @@ static int xe_pt_svm_userptr_pre_commit(struct xe_migrate_pt_update *pt_update)if (err)return err; -xe_svm_notifier_lock (vm); +xe_pt_svm_userptr_notifier_lock (vm);list_for_each_entry (op, &vops->list, link) { err =op_check_svm_userptr (vm, op, pt_update_ops);if (err) { -xe_svm_notifier_unlock (vm); +xe_pt_svm_userptr_notifier_unlock (vm);break ; } }
@@ -2192,7 +2219,7 @@ static void bind_op_commit(struct xe_vm *vm, struct xe_tile *tile, vma->tile_invalidated & ~BIT(tile->id)); vma->tile_staged &= ~BIT (tile->id);if (xe_vma_is_userptr (vma)) { -xe_svm_assert_held_read (vm); +xe_svm_assert_held_read_or_inject_write (vm);to_userptr_vma (vma)->userptr.initial_bind = true; }
@@ -2228,7 +2255,7 @@ static void unbind_op_commit(struct xe_vm *vm, struct xe_tile *tile,if (!vma->tile_present) {list_del_init (&vma->combined_links.rebind);if (xe_vma_is_userptr (vma)) { -xe_svm_assert_held_read (vm); +xe_svm_assert_held_read_or_inject_write (vm);spin_lock (&vm->userptr.invalidated_lock);list_del_init (&to_userptr_vma (vma)->userptr.invalidate_link);
@@ -2517,7 +2544,7 @@ xe_pt_update_ops_run(struct xe_tile *tile, struct xe_vma_ops *vops) }if (pt_update_ops->needs_svm_lock) -xe_svm_notifier_unlock (vm); +xe_pt_svm_userptr_notifier_unlock (vm);xe_tlb_inval_job_put (mjob);xe_tlb_inval_job_put (ijob);
drivers/gpu/drm/xe/xe_svm.h +13 -2
@@ -353,8 +353,19 @@ static inline void xe_svm_flush(struct xe_vm *vm)#define xe_svm_assert_in_notifier (vm__) \ lockdep_assert_held_write(&(vm__)->svm.gpusvm.notifier_lock) -#define xe_svm_assert_held_read (vm__) \ +/* +* Assert the svm notifier_lock is held. Read mode by default; write mode +* when CONFIG_DRM_XE_USERPTR_INVAL_INJECT is on, because that path forces +* a userptr invalidation that ends in drm_gpusvm_unmap_pages() with +* ctx->in_notifier=true, which requires the lock held for write. +*/ +#if IS_ENABLED (CONFIG_DRM_XE_USERPTR_INVAL_INJECT ) +#define xe_svm_assert_held_read_or_inject_write (vm__) \ + lockdep_assert_held_write(&(vm__)->svm.gpusvm.notifier_lock) +#else +#define xe_svm_assert_held_read_or_inject_write (vm__) \ lockdep_assert_held_read(&(vm__)->svm.gpusvm.notifier_lock) +#endif #define xe_svm_notifier_lock (vm__) \ drm_gpusvm_notifier_lock(&(vm__)->svm.gpusvm)
@@ -368,7 +379,7 @@ static inline void xe_svm_flush(struct xe_vm *vm)#else #define xe_svm_assert_in_notifier (...) do {} while (0) -static inline void xe_svm_assert_held_read (struct xe_vm *vm) +static inline void xe_svm_assert_held_read_or_inject_write (struct xe_vm *vm) { }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1022/1611 drm/xe/hw_engine: Fix double-free of managed BO in error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuicheng Lin <[email protected]>
[ Upstream commit 7ac3cae7a251d28e9079de07a991bd4eb2bb7fd8 ]
The error path in hw_engine_init() explicitly frees a BO allocated with xe_managed_bo_create_pin_map() via xe_bo_unpin_map_no_vm(). Since the managed BO already has a devm cleanup action registered, this causes a double-free when devm unwinds during probe failure.
Remove the explicit free and let devm handle it, consistent with all other xe_managed_bo_create_pin_map() callers.
--- drivers/gpu/drm/xe/xe_hw_engine.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_hw_engine.c +1 -3
@@ -619,7 +619,7 @@ static int hw_engine_init(struct xe_gt *gt, struct xe_hw_engine *hwe, hwe->exl_port =xe_execlist_port_create (xe, hwe);if (IS_ERR (hwe->exl_port)) { err =PTR_ERR (hwe->exl_port); - goto err_hwsp; + goto err_name; } }else {/* GSCCS has a special interrupt for reset */
@@ -639,8 +639,6 @@ static int hw_engine_init(struct xe_gt *gt, struct xe_hw_engine *hwe,return devm_add_action_or_reset (xe->drm.dev, hw_engine_fini, hwe); -err_hwsp: -xe_bo_unpin_map_no_vm (hwe->hwsp); err_name: hwe->name =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1023/1611 drm/xe/pf: Dont attempt to process FAST_REQ or EVENT relays
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Wajdeczko <[email protected]>
[ Upstream commit ed8b0d731892c68b41ecbd27c952af284816dec1 ]
Currently defined VF/PF relay actions use regular REQUEST messages only and the PF shouldn't attempt to handle FAST_REQUEST nor EVENT messages as this would result in breaking the VFPF ABI protocol and also might trigger an assert on the PF side.
--- drivers/gpu/drm/xe/xe_guc_relay.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_guc_relay.c +9 -4
@@ -677,12 +677,17 @@ static int relay_action_handler(struct xe_guc_relay *relay, u32 origin,return relay_testloop_action_handler (relay, origin, msg, len, response, size); type =FIELD_GET (GUC_HXG_MSG_0_TYPE , msg[0 ]); +relay_assert (relay,guc_hxg_type_is_action (type)); -if (IS_SRIOV_PF (relay_to_xe (relay))) - ret =xe_gt_sriov_pf_service_process_request (gt, origin, msg, len, response, size); -else +if (IS_SRIOV_PF (relay_to_xe (relay))) { +if (type ==GUC_HXG_TYPE_REQUEST ) + ret =xe_gt_sriov_pf_service_process_request (gt, origin, msg, len, + response, size); +else + ret = -EOPNOTSUPP ; + }else { ret = -EOPNOTSUPP ; - + }if (type ==GUC_HXG_TYPE_EVENT )relay_assert (relay, ret <=0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1024/1611 x86/uprobes: Keep shadow stack in sync for emulated CALLs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Windsor <[email protected]>
[ Upstream commit abf08854d224085e2ebb3ba660e7995909f47d6a ]
Uprobe CALL emulation updates the normal user stack, but not the CET user shadow stack. The subsequent RET then sees a stale shadow stack entry and raises #CP.
Update the relative CALL emulation and XOL CALL fixup paths to keep the shadow stack in sync.
--- arch/x86/kernel/uprobes.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/x86/kernel/uprobes.c +11 -1
@@ -1269,9 +1269,15 @@ static int default_post_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regslong correction = utask->vaddr - utask->xol_vaddr; regs->ip += correction; }else if (auprobe->defparam.fixups &UPROBE_FIX_CALL ) { +unsigned long retaddr = utask->vaddr + auprobe->defparam.ilen; +int err; + regs->sp +=sizeof_long (regs);/* Pop incorrect return address */ -if (emulate_push_stack (regs, utask->vaddr + auprobe->defparam.ilen)) +if (emulate_push_stack (regs, retaddr))return -ERESTART ; + err =shstk_update_last_frame (retaddr); +if (err) +return err; }/* popf; tell the caller to not touch TF */ if (auprobe->defparam.fixups &UPROBE_FIX_SETF )
@@ -1361,6 +1367,10 @@ static bool branch_emulate_op(struct arch_uprobe *auprobe, struct pt_regs *regs)*/ if (emulate_push_stack (regs, new_ip))return false; +if (shstk_push (new_ip) == -EFAULT ) { + regs->sp +=sizeof_long (regs); +return false; + } }else if (!check_jmp_cond (auprobe, regs)) { offs =0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1025/1611 uprobes/x86: Use proper mm_struct in __in_uprobe_trampoline
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
[ Upstream commit 169328645663bae30e9abad4012d52441e085a71 ]
In the unregister path we use __in_uprobe_trampoline check with current->mm for the VMA lookup, which is wrong, because we are in the tracer context, not the traced process.
Add mm_struct pointer argument to __in_uprobe_trampoline and changing related callers to pass proper mm_struct pointer.
--- arch/x86/kernel/uprobes.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/x86/kernel/uprobes.c +7 -7
@@ -761,9 +761,9 @@ void arch_uprobe_clear_state(struct mm_struct *mm)destroy_uprobe_trampoline (tramp); } -static bool __in_uprobe_trampoline (unsigned long ip) +static bool __in_uprobe_trampoline (struct mm_struct *mm,unsigned long ip) { -struct vm_area_struct *vma =vma_lookup (current->mm, ip); +struct vm_area_struct *vma =vma_lookup (mm, ip);return vma &&vma_is_special_mapping (vma, &tramp_mapping); }
@@ -776,14 +776,14 @@ static bool in_uprobe_trampoline(unsigned long ip)rcu_read_lock ();if (mmap_lock_speculate_try_begin (mm, &seq)) { - found =__in_uprobe_trampoline (ip); + found =__in_uprobe_trampoline (mm, ip); retry =mmap_lock_speculate_retry (mm, seq); }rcu_read_unlock ();if (retry) {mmap_read_lock (mm); - found =__in_uprobe_trampoline (ip); + found =__in_uprobe_trampoline (mm, ip);mmap_read_unlock (mm); }return found;
@@ -1044,7 +1044,7 @@ static int copy_from_vaddr(struct mm_struct *mm, unsigned long vaddr, void *dst,return 0 ; } -static bool __is_optimized (uprobe_opcode_t *insn,unsigned long vaddr) +static bool __is_optimized (struct mm_struct *mm,uprobe_opcode_t *insn,unsigned long vaddr) {struct __packed __arch_relative_insn {u8 op;
@@ -1053,7 +1053,7 @@ static bool __is_optimized(uprobe_opcode_t *insn, unsigned long vaddr)if (!is_call_insn (insn))return false; -return __in_uprobe_trampoline (vaddr +5 + call->raddr); +return __in_uprobe_trampoline (mm, vaddr +5 + call->raddr); }static int is_optimized (struct mm_struct *mm,unsigned long vaddr)
@@ -1064,7 +1064,7 @@ static int is_optimized(struct mm_struct *mm, unsigned long vaddr) err =copy_from_vaddr (mm, vaddr, &insn,5 );if (err)return err; -return __is_optimized ((uprobe_opcode_t *)&insn, vaddr); +return __is_optimized (mm, (uprobe_opcode_t *)&insn, vaddr); }static bool should_optimize (struct arch_uprobe *auprobe)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1026/1611 cifs: Fix missing credit release on failure in cifs_issue_read()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit c16b8c4cfb4fe2244cc33e469a93c1ab8684146b ]
Fix missing release of credits in the failure path in cifs_issue_read() lest retrying the subreq just overwrites the credits value.
--- fs/smb/client/file.c | 1 + 1 file changed, 1 insertion(+)
fs/smb/client/file.c +1 -0
@@ -242,6 +242,7 @@ static void cifs_issue_read(struct netfs_io_subrequest *subreq)return ; failed: +add_credits_and_wake_if (rdata->server, &rdata->credits,0 ); subreq->error = rc;netfs_read_subreq_terminated (subreq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1027/1611 ata: sata_gemini: unwind clocks on IDE pinctrl errors
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit c0ace4130e813acbabdfaa28d4e94a849c2ffdd7 ]
gemini_sata_bridge_init() prepares and enables both SATA PCLKs, then disables them again while keeping the clocks prepared for later bridge start and stop operations. If gemini_setup_ide_pins() fails after that, gemini_sata_probe() returns directly and skips the existing out_unprep_clk unwind path.
Route the IDE pinctrl failure through out_unprep_clk so the clocks prepared by gemini_sata_bridge_init() are unprepared before probe fails.
--- drivers/ata/sata_gemini.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/sata_gemini.c +1 -1
@@ -353,7 +353,7 @@ static int gemini_sata_probe(struct platform_device *pdev)if (sg->ide_pins) { ret =gemini_setup_ide_pins (dev);if (ret) -return ret; + goto out_unprep_clk; }dev_info (dev,"set up the Gemini IDE/SATA nexus\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1028/1611 ata: libata-scsi: limit simulated SCSI command copy to response length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karuna Ramkumar <[email protected]>
[ Upstream commit cd64be0ecd399fa2b1ab60b3aaf2b2b744243467 ]
The function ata_scsi_rbuf_fill() is used to copy the response of emulated SCSI commands from ata_scsi_rbuf to the SCSI command's scatterlist.
Currently, sg_copy_from_buffer() is called with the size argument set to ATA_SCSI_RBUF_SIZE (2048 bytes). Since ata_scsi_rbuf is zeroed out before the simulation actor is invoked, copying the full buffer size causes the remainder of the SCSI command's transfer buffer (beyond the actual response length 'len') to be overwritten with zeroes. This clobbers any pre-existing sentinel values or data in the caller's buffer tail, even though the correct residual count is reported via scsi_set_resid().
Fix this by passing the actual response length 'len' as the copy size to sg_copy_from_buffer(), ensuring that the tail of the caller's buffer remains untouched. Also, add a defensive check to ensure that the actor does not return a length exceeding the static buffer capacity. If this occurs, trigger a WARN_ON(), fail the command with an aborted command error, and return immediately without copying any data.
The fix was tested by invoking an SCSI SG_IO INQUIRY on an ATA disk on vanilla build, and build with the fix. Confirmed that the input buffer's tail end remains unmodified with the fix.
--- drivers/ata/libata-scsi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/ata/libata-scsi.c +6 -1
@@ -1930,8 +1930,13 @@ static void ata_scsi_rbuf_fill(struct ata_device *dev, struct scsi_cmnd *cmd,memset (ata_scsi_rbuf,0 ,ATA_SCSI_RBUF_SIZE ); len =actor (dev, cmd, ata_scsi_rbuf);if (len) { +if (WARN_ON (len >ATA_SCSI_RBUF_SIZE )) { +ata_scsi_set_sense (dev, cmd,ABORTED_COMMAND ,0 ,0 ); +spin_unlock_irqrestore (&ata_scsi_rbuf_lock, flags); +return ; + }sg_copy_from_buffer (scsi_sglist (cmd),scsi_sg_count (cmd), - ata_scsi_rbuf,ATA_SCSI_RBUF_SIZE ); + ata_scsi_rbuf, len); cmd->result =SAM_STAT_GOOD ;if (scsi_bufflen (cmd) > len)scsi_set_resid (cmd,scsi_bufflen (cmd) - len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1029/1611 HID: picolcd: prevent NULL pointer dereference in picolcd_send_and_wait()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Georgiy Osokin <[email protected]>
[ Upstream commit 0021eb09041f021c079be1022934a280f7f176c0 ]
In picolcd_send_and_wait(), an integer overflow of the signed loop counter 'k' can theoretically lead to a NULL pointer dereference of 'raw_data'. If the loop executes more than INT_MAX times, 'k' becomes negative, making the condition 'k < size' true even when 'size' is 0.
Change the type of 'k' to 'unsigned int' to prevent the overflow and eliminate the out-of-bounds access.
Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.
--- drivers/hid/hid-picolcd_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hid/hid-picolcd_core.c +2 -1
@@ -72,7 +72,8 @@ struct picolcd_pending *picolcd_send_and_wait(struct hid_device *hdev,struct picolcd_pending *work;struct hid_report *report =picolcd_out_report (report_id, hdev);unsigned long flags; -int i, j, k; +int i, j; +unsigned int k;if (!report || !data)return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1030/1611 HID: core: Fix OOB read in hid_get_report for numbered reports
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lee Jones <[email protected]>
[ Upstream commit af1a9b65ebe8a948eda805c14b78d4d0767cb1b5 ]
When a caller passes a size of 0 to hid_report_raw_event() for a numbered report, the function originally called hid_get_report() before performing any size validation.
Inside hid_get_report(), if the report is numbered (report_enum->numbered is true), it unconditionally dereferences data[0] to extract the report ID. With a size of 0, this results in an out-of-bounds read or kernel panic.
Fix this by moving the numbered report size validation check before the call to hid_get_report(), ensuring that size is at least 1 before dereferencing the data pointer.
--- drivers/hid/hid-core.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/hid/hid-core.c +7 -0
@@ -2041,6 +2041,13 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *u8 *cdata = data;int ret =0 ; +if (report_enum->numbered && (size <1 || bufsize <1 )) { +hid_warn_ratelimited (hid, +"Event data for numbered report is too short (%d vs %zu)\n" , + size, bufsize); +return -EINVAL ; + } + report =hid_get_report (report_enum, data);if (!report)return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1031/1611 arm64/mm: Optimize TLB flush in unmap_hotplug_[pmd|pud]_range()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anshuman Khandual <[email protected]>
[ Upstream commit ff4c5a0de1f2ef7737a8688a86e19301e567020d ]
Commit 48478b9f7913 ("arm64/mm: Enable batched TLB flush in unmap_hotplug_range") inadvertently introduced redundant TLB invalidation when clearing a block entry, resulting in unnecessary broadcast invalidation on CPUs without support for range-based invalidation.
Re-introduce the old behaviour, along with some expanded comments to help people working in this area next time around.
--- arch/arm64/mm/mmu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arm64/mm/mmu.c +9 -2
@@ -1515,7 +1515,13 @@ static void unmap_hotplug_pmd_range(pud_t *pudp, unsigned long addr,if (free_mapped) {/* CONT blocks are not supported in the vmemmap */ WARN_ON (pmd_cont (pmd)); -flush_tlb_kernel_range (addr, addr +PMD_SIZE ); +/* +* Invalidating a block entry requires just +* a single overlapping TLB invalidation, +* so limit the range of the flush to a single +* page. +*/ +flush_tlb_kernel_range (addr, addr +PAGE_SIZE );free_hotplug_page_range (pmd_page (pmd),PMD_SIZE , altmap); }
@@ -1545,7 +1551,8 @@ static void unmap_hotplug_pud_range(p4d_t *p4dp, unsigned long addr,if (pud_sect (pud)) {pud_clear (pudp);if (free_mapped) { -flush_tlb_kernel_range (addr, addr +PUD_SIZE ); +/* See comment in unmap_hotplug_pmd_range(). */ +flush_tlb_kernel_range (addr, addr +PAGE_SIZE );free_hotplug_page_range (pud_page (pud),PUD_SIZE , altmap); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1032/1611 HID: bpf: Fix hid_bpf_get_data() range check
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yiyang Chen <[email protected]>
[ Upstream commit 2d044049421dd48212b28646a850749d4a2d57fa ]
hid_bpf_get_data() returns a pointer into the HID-BPF context data when the caller-provided offset and size fit inside ctx->allocated_size.
The current check adds rdwr_buf_size and offset before comparing the result against ctx->allocated_size. Since both values are unsigned, a very large size can wrap the sum below ctx->allocated_size and make the helper return a pointer even though the requested range is not contained in the backing buffer.
Use check_add_overflow() to reject wrapped range ends before comparing the requested range end against ctx->allocated_size.
--- drivers/hid/bpf/hid_bpf_dispatch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hid/bpf/hid_bpf_dispatch.c +4 -1
@@ -17,6 +17,7 @@#include <linux/kfifo.h> #include <linux/minmax.h> #include <linux/module.h> +#include <linux/overflow.h> #include "hid_bpf_dispatch.h" const struct hid_ops *hid_ops;
@@ -296,13 +297,15 @@ __bpf_kfunc __u8 * hid_bpf_get_data(struct hid_bpf_ctx *ctx, unsigned int offset, const size_t rdwr_buf_size) { struct hid_bpf_ctx_kern *ctx_kern; +size_t end;if (!ctx)return NULL ; ctx_kern = container_of(ctx, struct hid_bpf_ctx_kern, ctx); -if (rdwr_buf_size + offset > ctx->allocated_size) +if (check_add_overflow (rdwr_buf_size, offset, &end) || + end > ctx->allocated_size)return NULL ;return ctx_kern->data + offset;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1033/1611 selftests/hid: Load only requested struct_ops maps
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yiyang Chen <[email protected]>
[ Upstream commit 5aad55011a37d999cf99d14bafb6a093a1a70466 ]
The HID selftest skeleton contains several struct_ops maps, but each test usually wants to load only the programs named by that test.
load_programs() disabled auto-attach for all maps, but left struct_ops autocreate enabled. libbpf can enable autoload for programs referenced by autocreated struct_ops maps, so an unrelated program can be loaded and fail even when the current test does not use it.
Disable autocreate for all struct_ops maps by default, then re-enable it only for the maps selected by the test before loading the skeleton.
--- tools/testing/selftests/hid/hid_bpf.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
tools/testing/selftests/hid/hid_bpf.c +18 -7
@@ -86,6 +86,20 @@ static void load_programs(const struct test_program programs[], self->skel =hid__open (); ASSERT_OK_PTR(self->skel) TEARDOWN_LOG("Error while calling hid__open"); +/* +* Disable all struct_ops maps by default so libbpf does not autoload +* programs referenced by maps that are unrelated to the current test. +*/ +bpf_object__for_each_map (iter_map, *self->skel->skeleton->obj) { +if (bpf_map__type (iter_map) ==BPF_MAP_TYPE_STRUCT_OPS ) { + err =bpf_map__set_autocreate (iter_map, false); + ASSERT_OK(err) TH_LOG("can not disable struct_ops map '%s'", + bpf_map__name(iter_map)); + } + +bpf_map__set_autoattach (iter_map, false); + } +for (int i =0 ; i < progs_count; i++) {struct bpf_program *prog;struct bpf_map *map;
@@ -102,6 +116,10 @@ static void load_programs(const struct test_program programs[], ASSERT_OK_PTR(map) TH_LOG("can not find struct_ops by name '%s'", programs[i].name + 4); + err =bpf_map__set_autocreate (map, true); + ASSERT_OK(err) TH_LOG("can not enable struct_ops map '%s'", + programs[i].name + 4); +/* hid_id is the first field of struct hid_bpf_ops */ ops_hid_id =bpf_map__initial_value (map,NULL ); ASSERT_OK_PTR(ops_hid_id) TH_LOG("unable to retrieve struct_ops data");
@@ -109,13 +127,6 @@ static void load_programs(const struct test_program programs[], *ops_hid_id = self->hid.hid_id; } -/* we disable the auto-attach feature of all maps because we -* only want the tested one to be manually attached in the next -* call to bpf_map__attach_struct_ops() -*/ -bpf_object__for_each_map (iter_map, *self->skel->skeleton->obj) -bpf_map__set_autoattach (iter_map, false); - err =hid__load (self->skel); ASSERT_OK(err) TH_LOG("hid_skel_load failed: %d", err);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1034/1611 selftests/hid: Cover hid_bpf_get_data() size overflow
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yiyang Chen <[email protected]>
[ Upstream commit eebbef7c468a5cb58c4772849ee5066441166cf0 ]
Add a HID-BPF regression check for hid_bpf_get_data() requests whose size would overflow when added to the offset.
The new rdesc fixup callback asks for offset 2 and size ~0ULL, then records whether the helper returns NULL. A vulnerable kernel returns a non-NULL pointer because the runtime check wraps the addition. A fixed kernel rejects the request. The callback records the helper result without dereferencing any returned pointer.
The callback reports the helper result through BSS and returns 0 intentionally. hid_rdesc_fixup return values are consumed as report descriptor fixup results, so a positive test-result value would be interpreted as a replacement report descriptor size.
Also add KHDR_INCLUDES to the HID selftest build so hid_bpf.c sees the current kernel UAPI HID definitions on systems whose installed headers do not provide enum hid_report_type.
--- tools/testing/selftests/hid/Makefile | 2 +- tools/testing/selftests/hid/hid_bpf.c | 11 +++++++++++ tools/testing/selftests/hid/progs/hid.c | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-)
tools/testing/selftests/hid/Makefile +1 -1
@@ -24,7 +24,7 @@ CXX ?= $(CROSS_COMPILE)g++ HOSTPKG_CONFIG := pkg-config -CFLAGS += -g -O0 -rdynamic -Wall -Werror -I$(OUTPUT) +CFLAGS += -g -O0 -rdynamic -Wall -Werror -I$(OUTPUT) $(KHDR_INCLUDES) CFLAGS += -I$(OUTPUT)/tools/include LDLIBS += -lelf -lz -lrt -lpthread
tools/testing/selftests/hid/hid_bpf.c +11 -0
@@ -898,6 +898,17 @@ TEST_F(hid_bpf, test_rdesc_fixup)ASSERT_EQ (rpt_desc.value[4 ],0x42 ); } +TEST_F(hid_bpf, test_rdesc_fixup_get_data_overflow) +{ +const struct test_program progs[] = { + { .name ="hid_rdesc_fixup_get_data_overflow" }, + }; + +LOAD_PROGRAMS (progs); + +ASSERT_EQ (self->skel->bss->get_data_overflow_check,1 ); +} +static int libbpf_print_fn (enum libbpf_print_level level,const char *format,va_list args) {
tools/testing/selftests/hid/progs/hid.c +15 -0
@@ -13,6 +13,7 @@ struct attach_prog_args {__u64 callback_check =52 ;__u64 callback2_check =52 ; +__u64 get_data_overflow_check; SEC("?struct_ops/hid_device_event")int BPF_PROG (hid_first_event ,struct hid_bpf_ctx *hid_ctx,enum hid_report_type type)
@@ -240,6 +241,20 @@ struct hid_bpf_ops rdesc_fixup = { .hid_rdesc_fixup = (void *)hid_rdesc_fixup, }; +SEC("?struct_ops.s/hid_rdesc_fixup") +int BPF_PROG (hid_rdesc_fixup_get_data_overflow ,struct hid_bpf_ctx *hid_ctx) +{ +if (!hid_bpf_get_data (hid_ctx,2 /* offset */ , ~0ULL /* size */ )) + get_data_overflow_check =1 ; + +return 0 ; +} + +SEC(".struct_ops.link") +struct hid_bpf_ops rdesc_fixup_get_data_overflow = { + .hid_rdesc_fixup = (void *)hid_rdesc_fixup_get_data_overflow, +}; + SEC("?struct_ops/hid_device_event")int BPF_PROG (hid_test_insert1 ,struct hid_bpf_ctx *hid_ctx,enum hid_report_type type) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1035/1611 arm64/sysreg: Fix BWE field encoding in ID_AA64DFR2_EL1
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia He <[email protected]>
[ Upstream commit 6666336d8fe5f3f0cd3f8da2865ca78110a6e170 ]
Commit 93d7356e4b30 ("arm64: sysreg: Describe ID_AA64DFR2_EL1 fields") encodes the FEAT_BWE2 value of the BWE field as '0b0002'. Binary literals only accept the digits 0 and 1, so the intended value is 2, i.e. 0b0010.
The macro generated by gen-sysreg.awk currently expands to
#define ID_AA64DFR2_EL1_BWE_FEAT_BWE2 UL(0b0002)
is not legal C and would fail to compile if any in-tree code referenced it. At present no caller uses this enum value, so the kernel still builds cleanly, but the bug is latent.
Fix the typo by using the correct binary literal 0b0010.
--- arch/arm64/tools/sysreg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/tools/sysreg +1 -1
@@ -1793,7 +1793,7 @@ Res0 15:8 UnsignedEnum 7:4 BWE 0b0000 NI 0b0001 FEAT_BWE - 0b0002 FEAT_BWE2 + 0b0010 FEAT_BWE2 EndEnum UnsignedEnum 3:0 STEP 0b0000 NI
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1036/1611 net: usb: net1080: validate packet_len before pad-byte access in rx_fixup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 03f384bc0cb8d4a1301d4f5b0baef2d980258383 ]
For an even packet_len, net1080_rx_fixup() reads the pad byte at skb->data[packet_len] before the skb->len != packet_len check further down, and packet_len is only bounded against NC_MAX_PACKET. A malicious NetChip 1080 device can send a short frame advertising a large even packet_len (e.g. 0x4000), so the pad-byte read lands past the end of the skb:
BUG: KASAN: slab-out-of-bounds in net1080_rx_fixup Read of size 1 at addr ffff8880106c83c6 by task ksoftirqd/0/14 ... net1080_rx_fixup (drivers/net/usb/net1080.c:384) usbnet_bh (drivers/net/usb/usbnet.c:1589) process_one_work (kernel/workqueue.c:3322) bh_worker (kernel/workqueue.c:3708) tasklet_action (kernel/softirq.c:965) handle_softirqs (kernel/softirq.c:622) ...
Reject the frame when packet_len >= skb->len before reading.
--- drivers/net/usb/net1080.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/net1080.c +1 -1
@@ -381,7 +381,7 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)skb_trim (skb, skb->len -sizeof *trailer);if ((packet_len &0x01 ) ==0 ) { -if (skb->data [packet_len] !=PAD_BYTE ) { +if (packet_len >= skb->len || skb->data[packet_len] !=PAD_BYTE ) { dev->net->stats.rx_frame_errors++;netdev_dbg (dev->net,"bad pad\n" );return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1037/1611 gue: validate REMCSUM private option length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qihang <[email protected]>
[ Upstream commit d335dcc6f521571d57117b8deeebc940836e5450 ]
GUE private flags can indicate that remote checksum offload metadata is present. The private flags field itself is accounted for by guehdr_flags_len(), but guehdr_priv_flags_len() currently returns 0 even when GUE_PFLAG_REMCSUM is set.
This lets a packet with only the private flags field pass validate_gue_flags(), after which gue_remcsum() and gue_gro_remcsum() read the missing REMCSUM start/offset fields from the following bytes.
Account for GUE_PLEN_REMCSUM when GUE_PFLAG_REMCSUM is present so that malformed packets are rejected during option validation.
--- include/net/gue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/gue.h +1 -1
@@ -80,7 +80,7 @@ static inline size_t guehdr_flags_len(__be16 flags)static inline size_t guehdr_priv_flags_len (__be32 flags) { -return 0 ; +return (flags &GUE_PFLAG_REMCSUM ) ?GUE_PLEN_REMCSUM :0 ; }/* Validate standard and private flags. Returns non-zero (meaning invalid)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1038/1611 netfilter: xt_u32: reject invalid shift counts
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wyatt Feng <[email protected]>
[ Upstream commit 64cdf7d30ac18e43df6c48004435febb965809a8 ]
u32_match_it() executes rule-supplied shift operands on a 32-bit value. A malformed u32 rule can provide a shift count of 32 or more, triggering an undefined shift out-of-bounds during packet evaluation.
Validate XT_U32_LEFTSH and XT_U32_RIGHTSH operands in u32_mt_checkentry() and reject malformed rules before they reach the packet path.
--- net/netfilter/xt_u32.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
net/netfilter/xt_u32.c +11 -1
@@ -106,7 +106,7 @@ static int u32_mt_checkentry(const struct xt_mtchk_param *par) {const struct xt_u32 *data = par->matchinfo;const struct xt_u32_test *ct; -unsigned int i; +unsigned int i, j;if (data->ntests >ARRAY_SIZE (data->tests))return -EINVAL ;
@@ -117,6 +117,16 @@ static int u32_mt_checkentry(const struct xt_mtchk_param *par)if (ct->nnums >ARRAY_SIZE (ct->location) || ct->nvalues >ARRAY_SIZE (ct->value))return -EINVAL ; + +for (j =1 ; j < ct->nnums; ++j) { +switch (ct->location[j].nextop) { +case XT_U32_LEFTSH : +case XT_U32_RIGHTSH : +if (ct->location[j].number >=32 ) +return -EINVAL ; +break ; + } + } }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1039/1611 netfilter: xt_rateest: fix u64 truncation in xt_rateest_mt()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Wu <[email protected]>
[ Upstream commit 444853cd438201007da5359821adcc2995655ab1 ]
On links faster than ~34 Gbps, where byte rate may exceed 2^32-1 (~ 4.3 GBps), the comparison result becomes incorrect because the truncated value no longer reflects the actual estimator rate.
Fix by changing the local variables to u64.
--- net/netfilter/xt_rateest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/xt_rateest.c +1 -1
@@ -16,7 +16,7 @@ xt_rateest_mt(const struct sk_buff *skb, struct xt_action_param *par) {const struct xt_rateest_match_info *info = par->matchinfo;struct gnet_stats_rate_est64 sample = {0 }; -u_int32_t bps1, bps2, pps1, pps2; +u64 bps1, bps2, pps1, pps2;bool ret = true;gen_estimator_read (&info->est1->rate_est, &sample);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1040/1611 netfilter: ip6tables: mark malformed IPv6 extension headers for hotdrop
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhixing Chen <[email protected]>
[ Upstream commit 43ccc20b5a733226417832cf16ef45322e594990 ]
The ah, hbh and rt matches check that the fixed extension header is present, then use the header length field to derive the advertised extension header length for matching.
For the ah match, add the missing advertised-length check. For hbh and rt, update the existing advertised-length checks. In all three cases, set hotdrop to true before returning false when the advertised extension header length exceeds the available skb data.
Returning false treats the packet as a rule mismatch. Set hotdrop to true and drop malformed packets so they cannot bypass rules intended to drop packets with these IPv6 extension headers.
--- net/ipv6/netfilter/ip6t_ah.c | 5 +++++ net/ipv6/netfilter/ip6t_hbh.c | 1 + net/ipv6/netfilter/ip6t_rt.c | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-)
net/ipv6/netfilter/ip6t_ah.c +5 -0
@@ -56,6 +56,11 @@ static bool ah_mt6(const struct sk_buff *skb, struct xt_action_param *par) } hdrlen =ipv6_authlen (ah); +if (skb->len - ptr < hdrlen) { +/* Packet smaller than its length field */ + par->hotdrop = true; +return false; + }pr_debug ("IPv6 AH LEN %u %u " , hdrlen, ah->hdrlen);pr_debug ("RES %04X " , ah->reserved);
net/ipv6/netfilter/ip6t_hbh.c +1 -0
@@ -75,6 +75,7 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par) hdrlen =ipv6_optlen (oh);if (skb->len - ptr < hdrlen) {/* Packet smaller than it's length field */ + par->hotdrop = true;return false; }
net/ipv6/netfilter/ip6t_rt.c +2 -1
@@ -56,7 +56,8 @@ static bool rt_mt6(const struct sk_buff *skb, struct xt_action_param *par) hdrlen =ipv6_optlen (rh);if (skb->len - ptr < hdrlen) { -/* Pcket smaller than its length field */ +/* Packet smaller than its length field */ + par->hotdrop = true;return false; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1041/1611 netfilter: nft_set_rbtree: get command skips end element with open interval
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit d63611cbe8af99dd61b118ee6e5b5e3e518250b2 ]
The get command on intervals provide partial matches such as subranges for usability reasons. However, an open interval has no closing end element. If the closing element matches within the range of the open internal, ie. its closest match is the start element of the open range, then, return 0 but offer no matching element to userspace through netlink as a special case. Userspace provides at least a matching start element in this case and the closing end element matching the open interal is ignored.
Another possibility is to report the matching start element of the open interval for this end interval. However, this results in duplicated matching being listed in userspace because userspace does not expect a start element as response to a end element.
--- net/netfilter/nf_tables_api.c | 3 +++ net/netfilter/nft_set_rbtree.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +3 -0
@@ -6552,6 +6552,9 @@ static int nft_get_set_elem(struct nft_ctx *ctx, const struct nft_set *set,if (err <0 )return err; +if (!elem.priv) +return 0 ; + err = -ENOMEM ; skb =nlmsg_new (NLMSG_GOODSIZE ,GFP_ATOMIC );if (skb ==NULL )
net/netfilter/nft_set_rbtree.c +6 -2
@@ -184,10 +184,14 @@ nft_rbtree_get(const struct net *net, const struct nft_set *set,if (!interval ||nft_set_elem_expired (interval->from))return ERR_PTR (-ENOENT ); -if (flags &NFT_SET_ELEM_INTERVAL_END ) +if (flags &NFT_SET_ELEM_INTERVAL_END ) { +if (!interval->to) +return NULL ; + rbe = container_of(interval->to, struct nft_rbtree_elem, ext); -else + }else { rbe = container_of(interval->from, struct nft_rbtree_elem, ext); + }return &rbe->priv; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1042/1611 netfilter: xt_connmark: reject invalid shift parameters
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wyatt Feng <[email protected]>
[ Upstream commit 1b47026fb4b35bac850ad6e8a4ad7fc018e09ebc ]
Revision 2 of the CONNMARK target accepts user-controlled shift parameters and applies them to 32-bit mark values in connmark_tg_shift().
A shift_bits value of 32 or more triggers an undefined-shift bug when the rule is evaluated. Invalid shift_dir values are also accepted and silently fall back to the left-shift path.
Reject invalid revision-2 shift parameters in connmark_tg_check() so malformed rules fail at installation time, before they can reach the packet path.
--- net/netfilter/xt_connmark.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/netfilter/xt_connmark.c +12 -2
@@ -112,6 +112,16 @@ static int connmark_tg_check(const struct xt_tgchk_param *par)return ret; } +static int connmark_tg_check_v2 (const struct xt_tgchk_param *par) +{ +const struct xt_connmark_tginfo2 *info = par->targinfo; + +if (info->shift_dir >D_SHIFT_RIGHT || info->shift_bits >=32 ) +return -EINVAL ; + +return connmark_tg_check (par); +} +static void connmark_tg_destroy (const struct xt_tgdtor_param *par) {nf_ct_netns_put (par->net, par->family);
@@ -162,7 +172,7 @@ static struct xt_target connmark_tg_reg[] __read_mostly = { .name = "CONNMARK", .revision = 2, .family = NFPROTO_IPV4, - .checkentry = connmark_tg_check, + .checkentry = connmark_tg_check_v2, .target = connmark_tg_v2, .targetsize = sizeof(struct xt_connmark_tginfo2), .destroy = connmark_tg_destroy,
@@ -183,7 +193,7 @@ static struct xt_target connmark_tg_reg[] __read_mostly = { .name = "CONNMARK", .revision = 2, .family = NFPROTO_IPV6, - .checkentry = connmark_tg_check, + .checkentry = connmark_tg_check_v2, .target = connmark_tg_v2, .targetsize = sizeof(struct xt_connmark_tginfo2), .destroy = connmark_tg_destroy,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1043/1611 net/mlx5: LAG, MPESW, Fix missing complete() on devcom error
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shay Drory <[email protected]>
[ Upstream commit d4b85f9a668b9c44216bb78daf4ec1a915cc92d1 ]
mlx5_mpesw_work() returned without calling complete() when mlx5_lag_get_devcom_comp() returned NULL. A caller that queued the work and waited on mpesww->comp would block indefinitely.
Funnel the early-return path through a new "complete" label so the waiter is always woken.
--- drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c +5 -2
@@ -139,8 +139,10 @@ static void mlx5_mpesw_work(struct work_struct *work)struct mlx5_lag *ldev = mpesww->lag; devcom =mlx5_lag_get_devcom_comp (ldev); -if (!devcom) -return ; +if (!devcom) { + mpesww->result = -ENODEV ; + goto complete; + }mlx5_devcom_comp_lock (devcom);mutex_lock (&ldev->lock);
@@ -156,6 +158,7 @@ static void mlx5_mpesw_work(struct work_struct *work) unlock:mutex_unlock (&ldev->lock);mlx5_devcom_comp_unlock (devcom); +complete:complete (&mpesww->comp); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1044/1611 net/mlx5e: Fix HV VHCA stats zero-sized buffer allocation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Liu <[email protected]>
[ Upstream commit 25f6b929c7e379cbea7cb8caa67b49b2d1efae17 ]
mlx5e_hv_vhca_stats_create() is called from mlx5e_nic_enable(), before mlx5e_open(). At that point priv->stats_nch is still zero, because it is only ever incremented in mlx5e_channel_stats_alloc(), which is reached only from mlx5e_open_channel().
mlx5e_hv_vhca_stats_buf_size() therefore returns 0, and kvzalloc(0, GFP_KERNEL) returns ZERO_SIZE_PTR ((void *)16) rather than NULL. The "if (!buf)" guard does not catch this, and mlx5e_hv_vhca_stats_create() completes "successfully" with priv->stats_agent.buf set to ZERO_SIZE_PTR.
Once channels are opened (priv->stats_nch > 0) and the hypervisor enables stats reporting, mlx5e_hv_vhca_stats_work() recomputes buf_len using the new non-zero stats_nch and calls memset(buf, 0, buf_len) on ZERO_SIZE_PTR, faulting at address 0x10.
Allocate the buffer based on priv->max_nch, which is set in mlx5e_priv_init() and is the upper bound on stats_nch:
- Add a separate helper mlx5e_hv_vhca_stats_buf_max_size() that returns sizeof(per_ring_stats) * max(max_nch, stats_nch), and use it for the kvzalloc() in mlx5e_hv_vhca_stats_create().
- Keep mlx5e_hv_vhca_stats_buf_size() (which returns based on stats_nch) for the worker's active payload size, so the wire format (block->rings = stats_nch) and the amount of data filled by mlx5e_hv_vhca_fill_stats() are unchanged.
The max(max_nch, stats_nch) guard handles the rare case where mlx5e_attach_netdev() recomputes max_nch downward across a detach/resume cycle while priv->stats_nch persists (mlx5e_detach_netdev does not call mlx5e_priv_cleanup, so stats_nch is only reset when the netdev is destroyed). Without the guard, the worker could compute buf_len from stats_nch and overrun the smaller buffer allocated based on the reduced max_nch.
Allocating a non-zero buffer also makes the kvzalloc() failure path in mlx5e_hv_vhca_stats_create() reachable for the first time: it returns early without (re)creating the agent. Clear priv->stats_agent.{agent,buf} in mlx5e_hv_vhca_stats_destroy() after freeing them, so that if a later create() bails out on this path, a subsequent teardown does not double-free the stale agent/buffer left from a previous enable/disable cycle.
This mirrors the existing mlx5e pattern of preallocating arrays of size max_nch (e.g. priv->channel_stats) and lazily populating entries up to stats_nch on demand.
--- .../net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c +9 -1
@@ -54,6 +54,12 @@ static int mlx5e_hv_vhca_stats_buf_size(struct mlx5e_priv *priv) priv->stats_nch); } +static int mlx5e_hv_vhca_stats_buf_max_size (struct mlx5e_priv *priv) +{ +return (sizeof (struct mlx5e_hv_vhca_per_ring_stats ) * +max (priv->max_nch, priv->stats_nch)); +} +static void mlx5e_hv_vhca_stats_work (struct work_struct *work) {struct mlx5e_hv_vhca_stats_agent *sagent;
@@ -122,7 +128,7 @@ static void mlx5e_hv_vhca_stats_cleanup(struct mlx5_hv_vhca_agent *agent)void mlx5e_hv_vhca_stats_create (struct mlx5e_priv *priv) { -int buf_len =mlx5e_hv_vhca_stats_buf_size (priv); +int buf_len =mlx5e_hv_vhca_stats_buf_max_size (priv);struct mlx5_hv_vhca_agent *agent; priv->stats_agent.buf =kvzalloc (buf_len,GFP_KERNEL );
@@ -155,5 +161,7 @@ void mlx5e_hv_vhca_stats_destroy(struct mlx5e_priv *priv)return ;mlx5_hv_vhca_agent_destroy (priv->stats_agent.agent); + priv->stats_agent.agent =NULL ;kvfree (priv->stats_agent.buf); + priv->stats_agent.buf =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1045/1611 net/mlx5e: Fix HV VHCA stats agent registration race
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Liu <[email protected]>
[ Upstream commit 89b25b5f46f488ea3b29b3444864c76944c9075b ]
mlx5e_hv_vhca_stats_create() registers the stats agent through mlx5_hv_vhca_agent_create(). The helper publishes the agent in hv_vhca->agents[type] under agents_lock and immediately schedules an asynchronous control invalidation on the HV VHCA workqueue before returning to mlx5e.
The asynchronous invalidation invokes the control agent's invalidate callback, which reads the hypervisor control block and forwards the command to mlx5e_hv_vhca_stats_control(). That callback may either:
- call cancel_delayed_work_sync(&priv->stats_agent.work), or
- call queue_delayed_work(priv->wq, &sagent->work, sagent->delay).
However, the delayed_work and priv->stats_agent.agent are only initialized after mlx5_hv_vhca_agent_create() returns to mlx5e:
agent = mlx5_hv_vhca_agent_create(...); /* publish + invalidate */
...
priv->stats_agent.agent = agent; /* too late */
INIT_DELAYED_WORK(&priv->stats_agent.work, ...); /* too late */If the asynchronous control path runs before the two assignments above, it can:
- Operate on an uninitialized delayed_work whose timer.function is NULL. queue_delayed_work() calls add_timer() unconditionally, so when the timer expires the timer softirq invokes a NULL function pointer.
- Re-initialize the timer later through INIT_DELAYED_WORK() while the timer is already enqueued in the timer wheel, corrupting the hlist (entry.pprev cleared while the previous bucket node still points at this entry).
- When the worker eventually runs, mlx5e_hv_vhca_stats_work() reads
sagent->agent (NULL) and dereferences it inside
mlx5_hv_vhca_agent_write().Fix this by:
- Initializing priv->stats_agent.work before invoking mlx5_hv_vhca_agent_create(), so the work is always in a valid state when the control callback observes it.
- Adding a struct mlx5_hv_vhca_agent **ctx_update out-parameter to mlx5_hv_vhca_agent_create(). The helper writes the agent pointer to *ctx_update before publishing into hv_vhca->agents[] and triggering the agents_update flow, so any callback subsequently invoked from that flow already sees a valid priv->stats_agent.agent. This avoids having the control callback participate in agent initialization.
While at it, access priv->stats_agent.agent with READ_ONCE()/WRITE_ONCE() for the cross-CPU access with the worker, and clear priv->stats_agent.buf on the agent_create() failure path.
--- .../mellanox/mlx5/core/en/hv_vhca_stats.c | 21 +++++++++++-------- .../ethernet/mellanox/mlx5/core/lib/hv_vhca.c | 8 +++++-- .../ethernet/mellanox/mlx5/core/lib/hv_vhca.h | 6 ++++-- 3 files changed, 22 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c +12 -9
@@ -73,7 +73,7 @@ static void mlx5e_hv_vhca_stats_work(struct work_struct *work) sagent = container_of(dwork, struct mlx5e_hv_vhca_stats_agent, work); priv = container_of(sagent, struct mlx5e_priv, stats_agent); buf_len =mlx5e_hv_vhca_stats_buf_size (priv); - agent = sagent->agent; + agent =READ_ONCE (sagent->agent); buf = sagent->buf;memset (buf,0 , buf_len);
@@ -135,11 +135,14 @@ void mlx5e_hv_vhca_stats_create(struct mlx5e_priv *priv)if (!priv->stats_agent.buf)return ; +INIT_DELAYED_WORK (&priv->stats_agent.work, mlx5e_hv_vhca_stats_work); + agent =mlx5_hv_vhca_agent_create (priv->mdev->hv_vhca,MLX5_HV_VHCA_AGENT_STATS , mlx5e_hv_vhca_stats_control,NULL , mlx5e_hv_vhca_stats_cleanup, - priv); + priv, + &priv->stats_agent.agent);if (IS_ERR_OR_NULL (agent)) {if (IS_ERR (agent))
@@ -148,20 +151,20 @@ void mlx5e_hv_vhca_stats_create(struct mlx5e_priv *priv) agent);kvfree (priv->stats_agent.buf); -return ; + priv->stats_agent.buf =NULL ; } - - priv->stats_agent.agent = agent; -INIT_DELAYED_WORK (&priv->stats_agent.work, mlx5e_hv_vhca_stats_work); }void mlx5e_hv_vhca_stats_destroy (struct mlx5e_priv *priv) { -if (IS_ERR_OR_NULL (priv->stats_agent.agent)) +struct mlx5_hv_vhca_agent *agent; + + agent =READ_ONCE (priv->stats_agent.agent); +if (IS_ERR_OR_NULL (agent))return ; -mlx5_hv_vhca_agent_destroy (priv->stats_agent.agent); - priv->stats_agent.agent =NULL ; +mlx5_hv_vhca_agent_destroy (agent); +WRITE_ONCE (priv->stats_agent.agent,NULL );kvfree (priv->stats_agent.buf); priv->stats_agent.buf =NULL ; }
drivers/net/ethernet/mellanox/mlx5/core/lib/hv_vhca.c +6 -2
@@ -190,7 +190,7 @@ mlx5_hv_vhca_control_agent_create(struct mlx5_hv_vhca *hv_vhca)return mlx5_hv_vhca_agent_create (hv_vhca,MLX5_HV_VHCA_AGENT_CONTROL ,NULL , mlx5_hv_vhca_control_agent_invalidate, -NULL ,NULL ); +NULL ,NULL ,NULL ); }static void mlx5_hv_vhca_control_agent_destroy (struct mlx5_hv_vhca_agent *agent)
@@ -256,7 +256,8 @@ mlx5_hv_vhca_agent_create(struct mlx5_hv_vhca *hv_vhca,void (*invalidate)(struct mlx5_hv_vhca_agent *,u64 block_mask), void (*cleaup)(struct mlx5_hv_vhca_agent *agent), - void *priv) + void *priv, + struct mlx5_hv_vhca_agent **ctx_update) { struct mlx5_hv_vhca_agent *agent;
@@ -284,6 +285,9 @@ mlx5_hv_vhca_agent_create(struct mlx5_hv_vhca *hv_vhca, agent->invalidate = invalidate; agent->cleanup = cleaup; +if (ctx_update) +WRITE_ONCE (*ctx_update, agent); +mutex_lock (&hv_vhca->agents_lock); hv_vhca->agents[type] = agent;mutex_unlock (&hv_vhca->agents_lock);
drivers/net/ethernet/mellanox/mlx5/core/lib/hv_vhca.h +4 -2
@@ -43,7 +43,8 @@ mlx5_hv_vhca_agent_create(struct mlx5_hv_vhca *hv_vhca,void (*invalidate)(struct mlx5_hv_vhca_agent *,u64 block_mask), void (*cleanup)(struct mlx5_hv_vhca_agent *agent), - void *context); + void *context, + struct mlx5_hv_vhca_agent **ctx_update);void mlx5_hv_vhca_agent_destroy (struct mlx5_hv_vhca_agent *agent); int mlx5_hv_vhca_agent_write(struct mlx5_hv_vhca_agent *agent,
@@ -84,7 +85,8 @@ mlx5_hv_vhca_agent_create(struct mlx5_hv_vhca *hv_vhca,void (*invalidate)(struct mlx5_hv_vhca_agent *,u64 block_mask), void (*cleanup)(struct mlx5_hv_vhca_agent *agent), - void *context) + void *context, + struct mlx5_hv_vhca_agent **ctx_update) { return NULL; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1046/1611 net/mlx5e: Fix publication race for priv->channel_stats[]
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Liu <[email protected]>
[ Upstream commit 5a799714e8ca0bce9ea40694f49914cf1adbbaa9 ]
mlx5e_channel_stats_alloc() publishes a new entry to priv->channel_stats[] and then increments priv->stats_nch as a publication token, but neither store carries any memory barrier:
priv->channel_stats[ix] = kvzalloc_node(...); if (!priv->channel_stats[ix]) return -ENOMEM; priv->stats_nch++;
Concurrent readers compute the loop bound from priv->stats_nch and then dereference priv->channel_stats[i] using plain accesses, e.g.
for (i = 0; i < priv->stats_nch; i++) {
struct mlx5e_channel_stats *cs = priv->channel_stats[i];
... cs->rq.packets ...
}On weakly-ordered architectures (ARM, PowerPC, RISC-V) the writes to channel_stats[ix] and stats_nch may become visible to other CPUs out of program order. A reader can observe stats_nch == N while still seeing channel_stats[N-1] == NULL, leading to a NULL pointer dereference in the channel_stats loop.
This has been observed in production on BlueField-3 DPUs (arm64), where ovs-vswitchd queries netdev statistics over netlink during NIC bringup, racing mlx5e_open_channel() -> mlx5e_channel_stats_alloc() on another CPU:
Unable to handle kernel NULL pointer dereference at virtual address 0x840 Hardware name: BlueField-3 DPU pc : mlx5e_fold_sw_stats64+0x30/0x180 [mlx5_core] Call trace: mlx5e_fold_sw_stats64+0x30/0x180 [mlx5_core] dev_get_stats+0x50/0xc0 ovs_vport_get_stats+0x38/0xac [openvswitch] ovs_vport_cmd_fill_info+0x194/0x290 [openvswitch] ovs_vport_cmd_get+0xbc/0x10c [openvswitch] genl_family_rcv_msg_doit+0xd0/0x160 genl_rcv_msg+0xec/0x1f0 netlink_rcv_skb+0x64/0x130 genl_rcv+0x40/0x60 netlink_unicast+0x2fc/0x370 netlink_sendmsg+0x1dc/0x454 ... __arm64_sys_sendmsg+0x2c/0x40
Add mlx5e_stats_nch_write() and mlx5e_stats_nch_read() helpers in en.h that wrap the smp_store_release()/smp_load_acquire() pair on stats_nch. The release/acquire pair establishes the contract:
stats_nch == N => channel_stats[0..N-1] are visible and non-NULL.
Publish the stats_nch increment via mlx5e_stats_nch_write() in the writer (mlx5e_channel_stats_alloc()), and read stats_nch via mlx5e_stats_nch_read() in all readers: mlx5e RX/TX queue stats, mlx5e_get_base_stats(), ethtool channels stats, IPoIB stats, the sw_stats fold and the HV VHCA stats agent.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 12 ++++++++++++ .../ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c | 10 ++++++---- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 14 ++++++++------ drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 9 +++++---- .../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 3 ++- 5 files changed, 33 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +12 -0
@@ -963,6 +963,18 @@ struct mlx5e_priv {struct ethtool_fec_hist_range *fec_ranges; }; +static inline u16 mlx5e_stats_nch_read (const struct mlx5e_priv *priv) +{ +/* Pairs with smp_store_release in mlx5e_stats_nch_write(). */ +return smp_load_acquire (&priv->stats_nch); +} + +static inline void mlx5e_stats_nch_write (struct mlx5e_priv *priv,u16 n) +{ +/* Pairs with smp_load_acquire in mlx5e_stats_nch_read(). */ +smp_store_release (&priv->stats_nch, n); +} +struct mlx5e_dev {struct net_device *netdev;struct devlink_port dl_port;
drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c +6 -4
@@ -33,9 +33,10 @@ mlx5e_hv_vhca_fill_ring_stats(struct mlx5e_priv *priv, int ch,static void mlx5e_hv_vhca_fill_stats (struct mlx5e_priv *priv,void *data,int buf_len) { +u16 nch =mlx5e_stats_nch_read (priv);int ch, i =0 ; -for (ch =0 ; ch < priv->stats_nch; ch++) { +for (ch =0 ; ch < nch; ch++) {void *buf = data + i; if (WARN_ON_ONCE(buf +
@@ -50,8 +51,9 @@ static void mlx5e_hv_vhca_fill_stats(struct mlx5e_priv *priv, void *data,static int mlx5e_hv_vhca_stats_buf_size (struct mlx5e_priv *priv) { -return (sizeof (struct mlx5e_hv_vhca_per_ring_stats ) * - priv->stats_nch); +u16 nch =mlx5e_stats_nch_read (priv); + +return sizeof (struct mlx5e_hv_vhca_per_ring_stats ) * nch; }static int mlx5e_hv_vhca_stats_buf_max_size (struct mlx5e_priv *priv)
@@ -106,7 +108,7 @@ static void mlx5e_hv_vhca_stats_control(struct mlx5_hv_vhca_agent *agent, sagent = &priv->stats_agent; block->version =MLX5_HV_VHCA_STATS_VERSION ; - block->rings = priv->stats_nch; + block->rings =mlx5e_stats_nch_read (priv);if (!block->command) {cancel_delayed_work_sync (&priv->stats_agent.work);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +8 -6
@@ -2718,7 +2718,7 @@ static int mlx5e_channel_stats_alloc(struct mlx5e_priv *priv, int ix, int cpu) GFP_KERNEL, cpu_to_node(cpu));if (!priv->channel_stats[ix])return -ENOMEM ; - priv->stats_nch++; +mlx5e_stats_nch_write (priv, priv->stats_nch +1 );return 0 ; }
@@ -3951,9 +3951,10 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,void mlx5e_fold_sw_stats64 (struct mlx5e_priv *priv,struct rtnl_link_stats64 *s) { +u16 nch =mlx5e_stats_nch_read (priv);int i; -for (i =0 ; i < priv->stats_nch; i++) { +for (i =0 ; i < nch; i++) {struct mlx5e_channel_stats *channel_stats = priv->channel_stats[i];struct mlx5e_rq_stats *xskrq_stats = &channel_stats->xskrq;struct mlx5e_rq_stats *rq_stats = &channel_stats->rq;
@@ -5411,7 +5412,7 @@ static void mlx5e_get_queue_stats_rx(struct net_device *dev, int i,struct mlx5e_rq_stats *xskrq_stats;struct mlx5e_rq_stats *rq_stats; -if (mlx5e_is_uplink_rep (priv) || !priv->stats_nch) +if (mlx5e_is_uplink_rep (priv) || !mlx5e_stats_nch_read (priv))return ; channel_stats = priv->channel_stats[i];
@@ -5430,7 +5431,7 @@ static void mlx5e_get_queue_stats_tx(struct net_device *dev, int i,struct mlx5e_priv *priv =netdev_priv (dev);struct mlx5e_sq_stats *sq_stats; -if (!priv->stats_nch) +if (!mlx5e_stats_nch_read (priv))return ;/* no special case needed for ptp htb etc since txq2sq_stats is kept up
@@ -5447,6 +5448,7 @@ static void mlx5e_get_base_stats(struct net_device *dev, struct netdev_queue_stats_tx *tx) {struct mlx5e_priv *priv =netdev_priv (dev); +u16 nch =mlx5e_stats_nch_read (priv);struct mlx5e_ptp *ptp_channel;int i, tc;
@@ -5455,7 +5457,7 @@ static void mlx5e_get_base_stats(struct net_device *dev, rx->bytes =0 ; rx->alloc_fail =0 ; -for (i = priv->channels.params.num_channels; i < priv->stats_nch; i++) { +for (i = priv->channels.params.num_channels; i < nch; i++) {struct netdev_queue_stats_rx rx_i = {0 };mlx5e_get_queue_stats_rx (dev, i, &rx_i);
@@ -5480,7 +5482,7 @@ static void mlx5e_get_base_stats(struct net_device *dev, tx->packets =0 ; tx->bytes =0 ; -for (i =0 ; i < priv->stats_nch; i++) { +for (i =0 ; i < nch; i++) {struct mlx5e_channel_stats *channel_stats = priv->channel_stats[i];/* handle two cases:
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +5 -4
@@ -516,6 +516,7 @@ static void mlx5e_stats_update_stats_rq_page_pool(struct mlx5e_channel *c)static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS (sw) {struct mlx5e_sw_stats *s = &priv->stats.sw; +u16 nch =mlx5e_stats_nch_read (priv);int i;memset (s,0 ,sizeof (*s));
@@ -523,7 +524,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(sw)for (i =0 ; i < priv->channels.num; i++)/* for active channels only */ mlx5e_stats_update_stats_rq_page_pool (priv->channels.c[i]); -for (i =0 ; i < priv->stats_nch; i++) { +for (i =0 ; i < nch; i++) {struct mlx5e_channel_stats *channel_stats = priv->channel_stats[i];
@@ -2585,7 +2586,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(ptp) { return; }static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS (channels) { -int max_nch = priv->stats_nch; +int max_nch =mlx5e_stats_nch_read (priv);return (NUM_RQ_STATS * max_nch) + (NUM_CH_STATS * max_nch) +
@@ -2598,8 +2599,8 @@ static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(channels)static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS (channels) { +int max_nch =mlx5e_stats_nch_read (priv);bool is_xsk = priv->xsk.ever_used; -int max_nch = priv->stats_nch;int i, j, tc;for (i =0 ; i < max_nch; i++)
@@ -2631,8 +2632,8 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(channels)static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS (channels) { +int max_nch =mlx5e_stats_nch_read (priv);bool is_xsk = priv->xsk.ever_used; -int max_nch = priv->stats_nch;int i, j, tc;for (i =0 ; i < max_nch; i++)
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +2 -1
@@ -117,10 +117,11 @@ void mlx5i_cleanup(struct mlx5e_priv *priv)static void mlx5i_grp_sw_update_stats (struct mlx5e_priv *priv) { +u16 nch =mlx5e_stats_nch_read (priv);struct rtnl_link_stats64 s = {};int i, j; -for (i =0 ; i < priv->stats_nch; i++) { +for (i =0 ; i < nch; i++) {struct mlx5e_channel_stats *channel_stats;struct mlx5e_rq_stats *rq_stats;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1047/1611 net: microchip: vcap: fix races on the shared Super VCAP block
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Emil Schulz Østergaard <[email protected]>
[ Upstream commit d7a8d500d7e42837bd8dce40cb52c97c6e8706a9 ]
The VCAP instances on a chip are not independent, yet they are locked independently. On sparx5 and lan969x the IS0 and IS2 instances are backed by the same Super VCAP hardware block and share its cache and command registers: every access drives the shared VCAP_SUPER_CTRL register and moves data through the shared cache registers.
Accessing one instance therefore races with accessing another. The per-instance admin->lock cannot prevent this, as each instance takes a different lock.
The locking issue is mostly disguised by the fact that the core usage of the vcap api runs under rtnl. However, the full rule dump in debugfs decodes rules straight from hardware (a READ command followed by a cache read) and runs outside rtnl, so it races a concurrent tc-flower rule write to another Super VCAP instance.
Besides corrupting the dump, the read repopulates the shared cache between the writers cache fill and its write command, so the writer commits the wrong data and corrupts the hardware entry.
Introduce vcap_lock() and vcap_unlock() helpers and route every rule lock site in the VCAP API and its debugfs code through them. Replace the per-instance admin->lock with a single mutex in struct vcap_control that serializes access to all instances. The helpers reach it through a new admin->vctrl back-pointer, and the clients initialise and destroy the control lock instead of a per-instance one.
No path holds more than one instance lock, so collapsing them onto a single mutex cannot self-deadlock.
--- .../microchip/lan966x/lan966x_vcap_impl.c | 5 +- .../microchip/sparx5/sparx5_vcap_impl.c | 5 +- .../net/ethernet/microchip/vcap/vcap_api.c | 72 +++++++++++-------- .../net/ethernet/microchip/vcap/vcap_api.h | 3 +- .../microchip/vcap/vcap_api_debugfs.c | 8 +-- .../microchip/vcap/vcap_api_debugfs_kunit.c | 3 +- .../ethernet/microchip/vcap/vcap_api_kunit.c | 3 +- .../microchip/vcap/vcap_api_private.h | 3 + 8 files changed, 60 insertions(+), 42 deletions(-)
drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.c +3 -2
@@ -601,7 +601,6 @@ static void lan966x_vcap_admin_free(struct vcap_admin *admin)kfree (admin->cache.keystream);kfree (admin->cache.maskstream);kfree (admin->cache.actionstream); -mutex_destroy (&admin->lock);kfree (admin); }
@@ -615,7 +614,7 @@ lan966x_vcap_admin_alloc(struct lan966x *lan966x, struct vcap_control *ctrl,if (!admin)return ERR_PTR (-ENOMEM ); -mutex_init (&admin->lock); + admin->vctrl = ctrl;INIT_LIST_HEAD (&admin->list);INIT_LIST_HEAD (&admin->rules);INIT_LIST_HEAD (&admin->enabled);
@@ -721,6 +720,7 @@ int lan966x_vcap_init(struct lan966x *lan966x) ctrl->ops = &lan966x_vcap_ops;INIT_LIST_HEAD (&ctrl->list); +mutex_init (&ctrl->lock);for (int i =0 ; i <ARRAY_SIZE (lan966x_vcap_inst_cfg); ++i) { cfg = &lan966x_vcap_inst_cfg[i];
@@ -780,5 +780,6 @@ void lan966x_vcap_deinit(struct lan966x *lan966x)lan966x_vcap_admin_free (admin); } +mutex_destroy (&ctrl->lock);kfree (ctrl); }
drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.c +3 -2
@@ -1930,7 +1930,6 @@ static void sparx5_vcap_admin_free(struct vcap_admin *admin) {if (!admin)return ; -mutex_destroy (&admin->lock);kfree (admin->cache.keystream);kfree (admin->cache.maskstream);kfree (admin->cache.actionstream);
@@ -1950,7 +1949,7 @@ sparx5_vcap_admin_alloc(struct sparx5 *sparx5, struct vcap_control *ctrl,INIT_LIST_HEAD (&admin->list);INIT_LIST_HEAD (&admin->rules);INIT_LIST_HEAD (&admin->enabled); -mutex_init (&admin->lock); + admin->vctrl = ctrl; admin->vtype = cfg->vtype; admin->vinst = cfg->vinst; admin->ingress = cfg->ingress;
@@ -2059,6 +2058,7 @@ int sparx5_vcap_init(struct sparx5 *sparx5) ctrl->ops = &sparx5_vcap_ops;INIT_LIST_HEAD (&ctrl->list); +mutex_init (&ctrl->lock);for (idx =0 ; idx <ARRAY_SIZE (sparx5_vcap_inst_cfg); ++idx) { cfg = &consts->vcaps_cfg[idx]; admin =sparx5_vcap_admin_alloc (sparx5, ctrl, cfg);
@@ -2097,5 +2097,6 @@ void sparx5_vcap_destroy(struct sparx5 *sparx5)list_del (&admin->list);sparx5_vcap_admin_free (admin); } +mutex_destroy (&ctrl->lock);kfree (ctrl); }
drivers/net/ethernet/microchip/vcap/vcap_api.c +41 -31
235 lines not on this page · raw message
drivers/net/ethernet/microchip/vcap/vcap_api.h +2 -1
@@ -164,7 +164,7 @@ struct vcap_admin {struct list_head list;/* for insertion in vcap_control */ struct list_head rules;/* list of rules */ struct list_head enabled;/* list of enabled ports */ -struct mutex lock;/* control access to rules */ +struct vcap_control *vctrl;/* the control instance owning this vcap */ enum vcap_type vtype;/* type of vcap */ int vinst;/* instance number within the same type */ int first_cid;/* first chain id in this vcap */
@@ -275,6 +275,7 @@ struct vcap_control {const struct vcap_info *vcaps;/* client supplied vcap models */ const struct vcap_statistics *stats;/* client supplied vcap stats */ struct list_head list;/* list of vcap instances */ + struct mutex lock; /* serialize access to all vcap instances */ };#endif /* __VCAP_API__ */
drivers/net/ethernet/microchip/vcap/vcap_api_debugfs.c +4 -4
@@ -410,9 +410,9 @@ static int vcap_debugfs_show(struct seq_file *m, void *unused) };int ret; -mutex_lock (&info->admin->lock); +vcap_lock (info->admin); ret =vcap_show_admin (info->vctrl, info->admin, &out); -mutex_unlock (&info->admin->lock); +vcap_unlock (info->admin);return ret; }DEFINE_SHOW_ATTRIBUTE (vcap_debugfs);
@@ -427,9 +427,9 @@ static int vcap_raw_debugfs_show(struct seq_file *m, void *unused) };int ret; -mutex_lock (&info->admin->lock); +vcap_lock (info->admin); ret =vcap_show_admin_raw (info->vctrl, info->admin, &out); -mutex_unlock (&info->admin->lock); +vcap_unlock (info->admin);return ret; }DEFINE_SHOW_ATTRIBUTE (vcap_raw_debugfs);
drivers/net/ethernet/microchip/vcap/vcap_api_debugfs_kunit.c +2 -1
@@ -243,10 +243,11 @@ static void vcap_test_api_init(struct vcap_admin *admin) {/* Initialize the shared objects */ INIT_LIST_HEAD (&test_vctrl.list); +mutex_init (&test_vctrl.lock);INIT_LIST_HEAD (&admin->list);INIT_LIST_HEAD (&admin->rules);INIT_LIST_HEAD (&admin->enabled); -mutex_init (&admin->lock); + admin->vctrl = &test_vctrl;list_add_tail (&admin->list, &test_vctrl.list);memset (test_updateaddr,0 ,sizeof (test_updateaddr)); test_updateaddridx =0 ;
drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c +2 -1
@@ -233,10 +233,11 @@ static void vcap_test_api_init(struct vcap_admin *admin) {/* Initialize the shared objects */ INIT_LIST_HEAD (&test_vctrl.list); +mutex_init (&test_vctrl.lock);INIT_LIST_HEAD (&admin->list);INIT_LIST_HEAD (&admin->rules);INIT_LIST_HEAD (&admin->enabled); -mutex_init (&admin->lock); + admin->vctrl = &test_vctrl;list_add_tail (&admin->list, &test_vctrl.list);memset (test_updateaddr,0 ,sizeof (test_updateaddr)); test_updateaddridx =0 ;
drivers/net/ethernet/microchip/vcap/vcap_api_private.h +3 -0
@@ -50,6 +50,9 @@ struct vcap_stream_iter {/* Check that the control has a valid set of callbacks */ int vcap_api_check (struct vcap_control *ctrl); +/* Serialize access to the vcap instances of a control */ +void vcap_lock (struct vcap_admin *admin); +void vcap_unlock (struct vcap_admin *admin);/* Erase the VCAP cache area used or encoding and decoding */ void vcap_erase_cache (struct vcap_rule_internal *ri);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1048/1611 qede: fix off-by-one in BD ring consumption on build_skb failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shigeru Yoshida <[email protected]>
[ Upstream commit a0a558ca7e75b49e71f8c545c30e8c005e6e4e2f ]
qede_rx_build_skb() and qede_tpa_rx_build_skb() do not check for a NULL return from qede_build_skb(). When it returns NULL under memory pressure, the functions still consume a BD from the ring before returning NULL. The callers then recycle additional BDs, resulting in one extra BD being consumed (off-by-one). This desynchronizes the BD ring, which can corrupt DMA page reference counts and lead to SLUB freelist corruption.
Commit 4e910dbe3650 ("qede: confirm skb is allocated before using") added a NULL check inside qede_build_skb() to prevent a NULL pointer dereference, but did not address the missing NULL checks in the callers, making this off-by-one reachable.
Fix this by adding NULL checks for the return value of qede_build_skb() in both qede_rx_build_skb() and qede_tpa_rx_build_skb(), returning NULL immediately before any BD ring manipulation.
--- drivers/net/ethernet/qlogic/qede/qede_fp.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/qlogic/qede/qede_fp.c +5 -0
@@ -765,6 +765,9 @@ qede_tpa_rx_build_skb(struct qede_dev *edev,struct sk_buff *skb; skb =qede_build_skb (rxq, bd, len, pad); +if (unlikely (!skb)) +return NULL ; + bd->page_offset += rxq->rx_buf_seg_size;if (bd->page_offset ==PAGE_SIZE ) {
@@ -812,6 +815,8 @@ qede_rx_build_skb(struct qede_dev *edev, } skb =qede_build_skb (rxq, bd, len, pad); +if (unlikely (!skb)) +return NULL ;if (unlikely (qede_realloc_rx_buffer (rxq, bd))) {/* Incr page ref count to reuse on allocation failure so
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1049/1611 net: qualcomm: rmnet: validate MAP frame length before ingress parsing
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit f0f1887a9e30712a1df03e152dce6fb91344b1f3 ]
When ingress deaggregation is disabled, rmnet_map_ingress_handler() passes the skb straight to __rmnet_map_ingress_handler(), skipping the length validation that rmnet_map_deaggregate() performs on the aggregated path. The parser then dereferences the MAP header and csum header/trailer based on the on-wire pkt_len without checking skb->len, so a short frame is read out of bounds:
BUG: KASAN: slab-out-of-bounds in rmnet_map_checksum_downlink_packet Read of size 1 at addr ffff88801118ed00 by task exploit/147 Call Trace: ... rmnet_map_checksum_downlink_packet (drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:413) __rmnet_map_ingress_handler (drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:96) rmnet_rx_handler (drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:129) __netif_receive_skb_core.constprop.0 (net/core/dev.c:6089) netif_receive_skb (net/core/dev.c:6460) tun_get_user (drivers/net/tun.c:1955) tun_chr_write_iter (drivers/net/tun.c:2001) vfs_write (fs/read_write.c:688) ksys_write (fs/read_write.c:740) do_syscall_64 (arch/x86/entry/syscall_64.c:94) ...
Factor that validation out of rmnet_map_deaggregate() into rmnet_map_validate_packet_len() and run it on the no-aggregation path too. The MAP header is bounds-checked first, since this path can receive a frame shorter than the header.
--- .../ethernet/qualcomm/rmnet/rmnet_handlers.c | 5 +- .../net/ethernet/qualcomm/rmnet/rmnet_map.h | 1 + .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 72 ++++++++++--------- 3 files changed, 45 insertions(+), 33 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +4 -1
@@ -126,7 +126,10 @@ rmnet_map_ingress_handler(struct sk_buff *skb,consume_skb (skb); }else { -__rmnet_map_ingress_handler (skb, port); +if (rmnet_map_validate_packet_len (skb, port)) +__rmnet_map_ingress_handler (skb, port); +else +kfree_skb (skb); } }
drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +1 -0
@@ -59,5 +59,6 @@ void rmnet_map_tx_aggregate_init(struct rmnet_port *port);void rmnet_map_tx_aggregate_exit (struct rmnet_port *port);void rmnet_map_update_ul_agg_config (struct rmnet_port *port,u32 size,u32 count,u32 time); +u32 rmnet_map_validate_packet_len (struct sk_buff *skb,struct rmnet_port *port);#endif /* _RMNET_MAP_H_ */
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +40 -32
94 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1050/1611 net/sched: act_pedit: fix TOCTOU heap OOB write in tc offload
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 8b519cbcabe836a441369fbec1a8a6518a709251 ]
There is a TOCTOU race condition in flower lockless approach between sizing a flow_rule buffer and filling it. [email protected] reports:
The cls_flower classifier operates with TCF_PROTO_OPS_DOIT_UNLOCKED (fl_change runs without RTNL), while RTM_NEWACTION holds RTNL, so the independent locking domains make the race reachable in practice. KASAN confirms:
BUG: KASAN: slab-out-of-bounds in tcf_pedit_offload_act_setup+0x81b/0x930 Write of size 4 at addr ffff888001f27520 by task poc-toctou/312 The buggy address is located 0 bytes to the right of allocated 288-byte region [ffff888001f27400, ffff888001f27520) (cache kmalloc-512)
Note: The result is a heap OOB write attacker-controlled content into the adjacent slab object (requires CAP_NET_ADMIN).
The fix introduces reading tcfp_nkeys under act->tcfa_lock in all places using a new tcf_pedit_nkeys_locked() which replaces the old tcf_pedit_nkeys(). Additionally we close the remaining TOCTOU window between the sizing read and the fill reads by more careful accounting.
Rather than silently truncating the key count, which leads to incorrect action semantics offloaded to hardware and secondary OOB writes if the remaining capacity is zero or consumed by prior actions, we enforce remaining capacity checks and return -ENOSPC if the required space exceeds the remaining capacity.
--- include/net/tc_act/tc_pedit.h | 18 ++++++++---------- net/sched/act_api.c | 13 +++++++++---- net/sched/act_pedit.c | 13 +++++++++++-- net/sched/cls_api.c | 22 +++++++++++++++++----- 4 files changed, 45 insertions(+), 21 deletions(-)
include/net/tc_act/tc_pedit.h +8 -10
@@ -37,17 +37,15 @@ static inline bool is_tcf_pedit(const struct tc_action *a)return false; } -static inline int tcf_pedit_nkeys (const struct tc_action *a) +/* Must be called with act->tcfa_lock held to ensure consistency of parallel +* reads of the same action's pedit keys (e.g. flow_offload count vs fill). +* Note, this is only used for pedit offload. +*/ +static inline int tcf_pedit_nkeys_locked (const struct tc_action *a) { -struct tcf_pedit_parms *parms; -int nkeys; - -rcu_read_lock (); - parms =to_pedit_parms (a); - nkeys = parms->tcfp_nkeys; -rcu_read_unlock (); - -return nkeys; +lockdep_assert_held (&a->tcfa_lock); +return rcu_dereference_protected (to_pedit (a)->parms, +lockdep_is_held (&a->tcfa_lock))->tcfp_nkeys; }static inline u32 tcf_pedit_htype (const struct tc_action *a,int index)
net/sched/act_api.c +9 -4
@@ -148,10 +148,15 @@ static void offload_action_hw_count_dec(struct tc_action *act,static unsigned int tcf_offload_act_num_actions_single (struct tc_action *act) { -if (is_tcf_pedit (act)) -return tcf_pedit_nkeys (act); -else -return 1 ; +unsigned int count; + +if (is_tcf_pedit (act)) { +spin_lock_bh (&act->tcfa_lock); + count =tcf_pedit_nkeys_locked (act); +spin_unlock_bh (&act->tcfa_lock); +return count; + } +return 1 ; }static bool tc_act_skip_hw (u32 flags)
net/sched/act_pedit.c +11 -2
@@ -563,9 +563,18 @@ static int tcf_pedit_offload_act_setup(struct tc_action *act, void *entry_data, {if (bind) {struct flow_action_entry *entry = entry_data; +int nkeys =tcf_pedit_nkeys_locked (act);int k; -for (k =0 ; k <tcf_pedit_nkeys (act); k++) { +/* If the required keys exceed the remaining capacity return +* -ENOSPC to abort the offload and fallback to software. +*/ +if (nkeys > *index_inc) { +NL_SET_ERR_MSG_MOD (extack,"Not enough space to offload all pedit keys" ); +return -ENOSPC ; + } + +for (k =0 ; k < nkeys; k++) {switch (tcf_pedit_cmd (act, k)) {case TCA_PEDIT_KEY_EX_CMD_SET : entry->id =FLOW_ACTION_MANGLE ;
@@ -602,7 +611,7 @@ static int tcf_pedit_offload_act_setup(struct tc_action *act, void *entry_data,return -EOPNOTSUPP ; } -for (k =1 ; k <tcf_pedit_nkeys (act); k++) { +for (k =1 ; k <tcf_pedit_nkeys_locked (act); k++) {if (cmd !=tcf_pedit_cmd (act, k)) {NL_SET_ERR_MSG_MOD (extack,"Unsupported pedit command offload" );return -EOPNOTSUPP ;
net/sched/cls_api.c +17 -5
@@ -3887,12 +3887,21 @@ int tc_setup_action(struct flow_action *flow_action, entry = &flow_action->entries[j];spin_lock_bh (&act->tcfa_lock); + +/* Abort the offload if we have exhausted the allocated capacity */ +if (j >= flow_action->num_entries) { +NL_SET_ERR_MSG_MOD (extack,"Flow action buffer overflow" ); + err = -ENOSPC ; + goto err_out_locked; + } + err =tcf_act_get_user_cookie (entry, act);if (err) goto err_out_locked; - index =0 ; - err =tc_setup_offload_act (act, entry, &index, extack); + index = flow_action->num_entries - j; + err =tc_setup_offload_act (act, entry, &index, + extack);if (err) goto err_out_locked;
@@ -3946,10 +3955,13 @@ unsigned int tcf_exts_num_actions(struct tcf_exts *exts)int i;tcf_exts_for_each_action (i, act, exts) { -if (is_tcf_pedit (act)) - num_acts +=tcf_pedit_nkeys (act); -else +if (is_tcf_pedit (act)) { +spin_lock_bh (&act->tcfa_lock); + num_acts +=tcf_pedit_nkeys_locked (act); +spin_unlock_bh (&act->tcfa_lock); + }else { num_acts++; + } }return num_acts; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1051/1611 net/smc: fix UAF in smc_cdc_rx_handler() by pinning the socket
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 9d160b35cc34a2ba8229d07651468a7848325135 ]
smc_cdc_rx_handler() looks up the connection by token under the link group's conns_lock, drops the lock, and then dereferences conn and the smc_sock derived from it, ending in sock_hold(&smc->sk) inside smc_cdc_msg_recv(). No reference is held across the lock release.
The only reference pinning the socket while the connection is discoverable in the link group is taken in smc_lgr_register_conn() (sock_hold) and dropped in __smc_lgr_unregister_conn() (sock_put), both under conns_lock. Once the handler drops conns_lock, a concurrent close() -> smc_release() -> smc_conn_free() -> smc_lgr_unregister_conn() can drop that reference and free the smc_sock, so the handler's later sock_hold() runs on freed memory:
WARNING: lib/refcount.c:25 at refcount_warn_saturate Workqueue: rxe_wq do_work refcount_warn_saturate (lib/refcount.c:25) smc_cdc_msg_recv (net/smc/smc_cdc.c:430) smc_cdc_rx_handler (net/smc/smc_cdc.c:502) smc_wr_rx_tasklet_fn (net/smc/smc_wr.c:445) tasklet_action_common (kernel/softirq.c:938) handle_softirqs (kernel/softirq.c:622) Kernel panic - not syncing: panic_on_warn set
Only SMC-R is affected. The SMC-D receive tasklet is stopped by tasklet_kill(&conn->rx_tsklet) in smc_conn_free() before the connection is unregistered, so it cannot run concurrently with the free.
Take the socket reference while still holding conns_lock, so the registration reference can no longer be the last one, and drop it once the handler is done.
--- net/smc/smc_cdc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
net/smc/smc_cdc.c +10 -5
@@ -470,9 +470,9 @@ static void smc_cdc_rx_handler(struct ib_wc *wc, void *buf) {struct smc_link *link = (struct smc_link *)wc->qp->qp_context;struct smc_cdc_msg *cdc = buf; +struct smc_sock *smc =NULL ;struct smc_connection *conn;struct smc_link_group *lgr; -struct smc_sock *smc;if (wc->byte_len < offsetof(struct smc_cdc_msg , reserved))return ;/* short message */
@@ -483,21 +483,26 @@ static void smc_cdc_rx_handler(struct ib_wc *wc, void *buf) lgr =smc_get_lgr (link);read_lock_bh (&lgr->conns_lock); conn =smc_lgr_find_conn (ntohl (cdc->token), lgr); -read_unlock_bh (&lgr->conns_lock); -if (!conn || conn->out_of_sync) +if (!conn || conn->out_of_sync) { +read_unlock_bh (&lgr->conns_lock);return ; + } smc = container_of(conn, struct smc_sock, conn); +sock_hold (&smc->sk); +read_unlock_bh (&lgr->conns_lock);if (cdc->prod_flags.failover_validation) {smc_cdc_msg_validate (smc, cdc, link); -return ; + goto out; }if (smc_cdc_before (ntohs (cdc->seqno), conn->local_rx_ctrl.seqno))/* received seqno is old */ -return ; + goto out;smc_cdc_msg_recv (smc, cdc); +out: +sock_put (&smc->sk); }static struct smc_wr_rx_handler smc_cdc_rx_handlers[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1052/1611 amt: fix size calculation in amt_get_size()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9e05e91a9a847ed57926414bd7c2c5e54d6c56c6 ]
amt_get_size() incorrectly used sizeof(struct iphdr) for the sizes of IFLA_AMT_DISCOVERY_IP, IFLA_AMT_REMOTE_IP, and IFLA_AMT_LOCAL_IP. These attributes contain IPv4 addresses (__be32), not full IP headers.
Replace sizeof(struct iphdr) with sizeof(__be32) to avoid over-allocating netlink message space.
--- drivers/net/amt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/amt.c +3 -3
@@ -3301,9 +3301,9 @@ static size_t amt_get_size(const struct net_device *dev)nla_total_size (sizeof (__u16)) +/* IFLA_AMT_GATEWAY_PORT */ nla_total_size (sizeof (__u32)) +/* IFLA_AMT_LINK */ nla_total_size (sizeof (__u32)) +/* IFLA_MAX_TUNNELS */ -nla_total_size (sizeof (struct iphdr )) +/* IFLA_AMT_DISCOVERY_IP */ -nla_total_size (sizeof (struct iphdr )) +/* IFLA_AMT_REMOTE_IP */ -nla_total_size (sizeof (struct iphdr ));/* IFLA_AMT_LOCAL_IP */ +nla_total_size (sizeof (__be32)) +/* IFLA_AMT_DISCOVERY_IP */ +nla_total_size (sizeof (__be32)) +/* IFLA_AMT_REMOTE_IP */ +nla_total_size (sizeof (__be32));/* IFLA_AMT_LOCAL_IP */ }static int amt_fill_info (struct sk_buff *skb,const struct net_device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1053/1611 Bluetooth: 6lowpan: hold L2CAP conn across debugfs control
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 518aa9505fa10ea5662349e5d2efd8c9e32a820b ]
get_l2cap_conn() looks up an LE hci_conn under hdev protection, but then drops that protection before reading hcon->l2cap_data and before lowpan_control_write() later dereferences conn->hcon. A disconnect or device close can tear down the same L2CAP connection in that window.
The buggy scenario involves two paths, with each column showing the order within that path:
6LoWPAN control write: HCI disconnect/device close:
1. get_l2cap_conn() finds hcon 1. hci_disconn_cfm() dispatches
and hcon->l2cap_data. the L2CAP disconnect callback.
2. get_l2cap_conn() drops hdev 2. l2cap_conn_del() clears
protection and returns conn. hcon->l2cap_data and drops the
L2CAP connection reference.
3. lowpan_control_write() reads 3. hci_conn_del() removes and drops
conn->hcon. the HCI connection.Take a reference to the L2CAP connection with l2cap_conn_hold_unless_zero() while hdev is still locked, and drop that reference after the debugfs command's last use of conn. This mirrors the existing L2CAP ACL receive-side handoff and keeps the connection dereferenceable after leaving hdev protection. Export the existing helper so the bluetooth_6lowpan module can use the same lifetime primitive.
Validation reproduced this kernel report:
BUG: KASAN: slab-use-after-free in lowpan_control_write+0x374/0x520 The buggy address belongs to the object at ffff888111b9d000 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 0 bytes inside of freed 1024-byte region [ffff888111b9d000, ffff888111b9d400) Read of size 8 Call trace: dump_stack_lvl+0x66/0xa0 print_report+0xce/0x5f0 lowpan_control_write+0x374/0x520 (net/bluetooth/6lowpan.c:1131) srso_alias_return_thunk+0x5/0xfbef5 __virt_addr_valid+0x19f/0x330 kasan_report+0xe0/0x110 __debugfs_file_get+0xf7/0x400 full_proxy_write+0x9e/0xd0 vfs_write+0x1b0/0x810 ksys_write+0xd2/0x170 dnotify_flush+0x32/0x220 do_syscall_64+0x115/0x6a0 (arch/x86/entry/syscall_64.c:87) entry_SYSCALL_64_after_hwframe+0x77/0x7f Allocated by task stack: kasan_save_stack+0x33/0x60 kasan_save_track+0x17/0x60 __kasan_kmalloc+0xaa/0xb0 l2cap_conn_add+0x45/0x520 l2cap_chan_connect+0xac6/0xd90 l2cap_sock_connect+0x216/0x350 __sys_connect+0x101/0x130 __x64_sys_connect+0x40/0x50 do_syscall_64+0x115/0x6a0 (arch/x86/entry/syscall_64.c:87) entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task stack: kasan_save_stack+0x33/0x60 kasan_save_track+0x17/0x60 kasan_save_free_info+0x3b/0x60 __kasan_slab_free+0x5f/0x80 kfree+0x313/0x590 hci_conn_hash_flush+0xc0/0x140 hci_dev_close_sync+0x41a/0xb00 hci_dev_close+0x12f/0x160 hci_sock_ioctl+0x157/0x570 sock_do_ioctl+0xf7/0x210 sock_ioctl+0x32f/0x490 __x64_sys_ioctl+0xc7/0x110 do_syscall_64+0x115/0x6a0 (arch/x86/entry/syscall_64.c:87) entry_SYSCALL_64_after_hwframe+0x77/0x7f kasan_record_aux_stack+0xa7/0xc0 insert_work+0x32/0x100 __queue_work+0x262/0xa60 queue_work_on+0xad/0xb0 l2cap_connect_cfm+0x4ef/0x670 hci_le_remote_feat_complete_evt+0x247/0x430 hci_event_packet+0x360/0x6f0 hci_rx_work+0x2ae/0x7a0 process_one_work+0x4fd/0xbc0 worker_thread+0x2d8/0x570 kthread+0x1ad/0x1f0 ret_from_fork+0x3c9/0x540 ret_from_fork_asm+0x1a/0x30
--- net/bluetooth/6lowpan.c | 21 +++++++++++++++------ net/bluetooth/l2cap_core.c | 1 + 2 files changed, 16 insertions(+), 6 deletions(-)
net/bluetooth/6lowpan.c +15 -6
@@ -997,16 +997,19 @@ static int get_l2cap_conn(char *buf, bdaddr_t *addr, u8 *addr_type,hci_dev_lock (hdev); hcon =hci_conn_hash_lookup_le (hdev, addr, le_addr_type); -hci_dev_unlock (hdev); -hci_dev_put (hdev); - -if (!hcon) +if (!hcon) { +hci_dev_unlock (hdev); +hci_dev_put (hdev);return -ENOENT ; + } - *conn = (struct l2cap_conn *)hcon->l2cap_data; + *conn =l2cap_conn_hold_unless_zero (hcon->l2cap_data);BT_DBG ("conn %p dst %pMR type %u" , *conn, &hcon->dst, hcon->dst_type); +hci_dev_unlock (hdev); +hci_dev_put (hdev); +return 0 ; }
@@ -1153,18 +1156,22 @@ static ssize_t lowpan_control_write(struct file *fp,if (conn) {struct lowpan_peer *peer; -if (!is_bt_6lowpan (conn->hcon)) +if (!is_bt_6lowpan (conn->hcon)) { +l2cap_conn_put (conn);return -EINVAL ; + } peer =lookup_peer (conn);if (peer) {BT_DBG ("6LoWPAN connection already exists" ); +l2cap_conn_put (conn);return -EALREADY ; }BT_DBG ("conn %p dst %pMR type %d user %u" , conn, &conn->hcon->dst, conn->hcon->dst_type, addr_type); +l2cap_conn_put (conn); } ret =bt_6lowpan_connect (&addr, addr_type);
@@ -1180,6 +1187,8 @@ static ssize_t lowpan_control_write(struct file *fp,return ret; ret =bt_6lowpan_disconnect (conn, addr_type); +if (conn) +l2cap_conn_put (conn);if (ret <0 )return ret;
net/bluetooth/l2cap_core.c +1 -0
@@ -7715,6 +7715,7 @@ struct l2cap_conn *l2cap_conn_hold_unless_zero(struct l2cap_conn *c)return c; } +EXPORT_SYMBOL (l2cap_conn_hold_unless_zero);int l2cap_recv_acldata (struct hci_dev *hdev,u16 handle,struct sk_buff *skb,u16 flags)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1054/1611 Bluetooth: MGMT: Fix adv monitor add failure cleanup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 384a4b2fef9ffe5e270ee5558975c0504881c5fb ]
hci_add_adv_monitor() publishes a new adv_monitor in hdev->adv_monitors_idr before the powered MSFT setup step. The MSFT offload add path can then fail either locally before the controller add command completes, or in the MSFT add callback. In the current queued management add flow, hci_cmd_sync_work() still invokes mgmt_add_adv_patterns_monitor_complete() with the original pending command after msft_add_monitor_pattern() returns.
The buggy scenario involves two paths, with each column showing the order within that path:
MSFT add handling MGMT completion 1. insert monitor and handle 1. receive sync error 2. send MSFT add command 2. call add-monitor completion 3. callback sees bad response 3. load cmd->user_data 4. callback frees monitor 4. read monitor->handle
Local MSFT setup failures have the other half of the same ownership bug:
they return an error after the IDR insertion, but no later code removes the failed monitor from the IDR.
Keep ownership with the pending management command until its completion. For normal management adds, the MSFT add callback now records successful controller state and returns errors to its caller. The management completion frees the monitor on non-success after copying the response handle, while resume/reregister callback-error cleanup remains in the MSFT callback. The success path keeps the existing bookkeeping.
Validation reproduced this kernel report:
BUG: KASAN: slab-use-after-free in mgmt_add_adv_patterns_monitor_complete+0xfb/0x260 [bluetooth] Call Trace: <TASK> dump_stack_lvl+0x66/0xa0 print_report+0xce/0x5f0 ? mgmt_add_adv_patterns_monitor_complete+0xfb/0x260 [bluetooth] ? srso_alias_return_thunk+0x5/0xfbef5 ? __virt_addr_valid+0x19f/0x330 ? mgmt_add_adv_patterns_monitor_complete+0xfb/0x260 [bluetooth] kasan_report+0xe0/0x110 ? mgmt_add_adv_patterns_monitor_complete+0xfb/0x260 [bluetooth] mgmt_add_adv_patterns_monitor_complete+0xfb/0x260 [bluetooth] ? srso_alias_return_thunk+0x5/0xfbef5 ? 0xffffffffc00d00da ? __pfx_mgmt_add_adv_patterns_monitor_complete+0x10/0x10 [bluetooth] ? __pfx_mgmt_add_adv_patterns_monitor_complete+0x10/0x10 [bluetooth] ? hci_cmd_sync_work+0x1ab/0x210 [bluetooth] hci_cmd_sync_work+0x1c0/0x210 [bluetooth] ? __pfx_mgmt_add_adv_patterns_monitor_complete+0x10/0x10 [bluetooth] process_one_work+0x4fd/0xbc0 ? __pfx_process_one_work+0x10/0x10 ? srso_alias_return_thunk+0x5/0xfbef5 ? srso_alias_return_thunk+0x5/0xfbef5 ? __list_add_valid_or_report+0x37/0xf0 ? __pfx_hci_cmd_sync_work+0x10/0x10 [bluetooth] ? srso_alias_return_thunk+0x5/0xfbef5 worker_thread+0x2d8/0x570 ? __pfx_worker_thread+0x10/0x10 kthread+0x1ad/0x1f0 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x3c9/0x540 ? __pfx_ret_from_fork+0x10/0x10 ? srso_alias_return_thunk+0x5/0xfbef5 ? __switch_to+0x2e9/0x730 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Allocated by task 471 on cpu 3 at 285.205389s: kasan_save_stack+0x33/0x60 kasan_save_track+0x17/0x60 __kasan_kmalloc+0xaa/0xb0 add_adv_patterns_monitor_rssi+0xd5/0x230 [bluetooth] hci_sock_sendmsg+0x96b/0xf80 [bluetooth] __sys_sendto+0x2bc/0x2d0 __x64_sys_sendto+0x76/0x90 do_syscall_64+0x115/0x6a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 454 on cpu 2 at 285.217112s: kasan_save_stack+0x33/0x60 kasan_save_track+0x17/0x60 kasan_save_free_info+0x3b/0x60 __kasan_slab_free+0x5f/0x80 kfree+0x313/0x590 msft_add_monitor_sync+0x54a/0x570 [bluetooth] hci_add_adv_monitor+0x133/0x180 [bluetooth] hci_cmd_sync_work+0x187/0x210 [bluetooth] process_one_work+0x4fd/0xbc0 worker_thread+0x2d8/0x570 kthread+0x1ad/0x1f0 ret_from_fork+0x3c9/0x540 ret_from_fork_asm+0x1a/0x30
--- net/bluetooth/mgmt.c | 2 ++ net/bluetooth/msft.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
net/bluetooth/mgmt.c +2 -0
@@ -5296,6 +5296,8 @@ static void mgmt_add_adv_patterns_monitor_complete(struct hci_dev *hdev,if (monitor->state ==ADV_MONITOR_STATE_NOT_REGISTERED ) monitor->state =ADV_MONITOR_STATE_REGISTERED ;hci_update_passive_scan (hdev); + }else { +hci_free_adv_monitor (hdev, monitor); } mgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode,
net/bluetooth/msft.c +1 -1
@@ -291,7 +291,7 @@ static int msft_le_monitor_advertisement_cb(struct hci_dev *hdev, u16 opcode, monitor->state =ADV_MONITOR_STATE_OFFLOADED ; unlock: -if (status) +if (status && msft->resuming)hci_free_adv_monitor (hdev, monitor);hci_dev_unlock (hdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1055/1611 Bluetooth: sco: Fix a race condition in sco_sock_timeout()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sungwoo Kim <[email protected]>
[ Upstream commit 0f8a5dcc66648b6e1458a9f3ba4c5a0463a228fc ]
sco_sock_timeout() runs asynchronously and lock_sock(sk). If the socket is closing while the timer is running, it holds the same lock (lock_sock(sk)) twice, leading to a deadlock.
CPU 0 CPU 1
==================== ======================sco_sock_close()
sco_sock_timeout()lock_sock(sk) // <-- LOCK
__sco_sock_close()
sco_chan_del()
sco_conn_put()
sco_conn_free()
disable_delayed_work_sync()
lock(sk) // <-- SAME LOCKFix this by moving disable_delayed_work_sync() outside of lock_sock(sk), ensuring that no lock_sock(sk) is held before sco_sock_timeout().
Lockdep splat:
WARNING: possible circular locking dependency detected 6.13.0-rc4 #7 Not tainted
syz-executor292/9514 is trying to acquire lock:ffff8881115d5070 ((work_completion)(&(&conn->timeout_work)->work)){+.+.}-{0:0}, at: rcu_lock_acquire sect/v6.13-rc4/./include/linux/rcupdate.h:337 [inline] ffff8881115d5070 ((work_completion)(&(&conn->timeout_work)->work)){+.+.}-{0:0}, at: rcu_read_lock sect/v6.13-rc4/./include/linux/rcupdate.h:849 [inline] ffff8881115d5070 ((work_completion)(&(&conn->timeout_work)->work)){+.+.}-{0:0}, at: start_flush_work sect/v6.13-rc4/kernel/workqueue.c:4137 [inline] ffff8881115d5070 ((work_completion)(&(&conn->timeout_work)->work)){+.+.}-{0:0}, at: __flush_work+0xd1/0xc40 sect/v6.13-rc4/kernel/workqueue.c:4195
but task is already holding lock:ffff88807db3a258 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at: lock_sock sect/v6.13-rc4/./include/net/sock.h:1623 [inline] ffff88807db3a258 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at: sco_sock_close+0x25/0x100 sect/v6.13-rc4/net/bluetooth/sco.c:524
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}:
lock_acquire+0x1c4/0x520 sect/v6.13-rc4/kernel/locking/lockdep.c:5849
lock_sock_nested+0x48/0x130 sect/v6.13-rc4/net/core/sock.c:3622
lock_sock sect/v6.13-rc4/./include/net/sock.h:1623 [inline]
sco_sock_timeout+0xbe/0x270 sect/v6.13-rc4/net/bluetooth/sco.c:158
process_one_work sect/v6.13-rc4/kernel/workqueue.c:3229 [inline]
process_scheduled_works+0xa99/0x18f0 sect/v6.13-rc4/kernel/workqueue.c:3310
worker_thread+0x8a9/0xd80 sect/v6.13-rc4/kernel/workqueue.c:3391
kthread+0x2c6/0x360 sect/v6.13-rc4/kernel/kthread.c:389
ret_from_fork+0x4e/0x80 sect/v6.13-rc4/arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 sect/v6.13-rc4/arch/x86/entry/entry_64.S:244-> #0 ((work_completion)(&(&conn->timeout_work)->work)){+.+.}-{0:0}:
check_prev_add sect/v6.13-rc4/kernel/locking/lockdep.c:3161 [inline]
check_prevs_add sect/v6.13-rc4/kernel/locking/lockdep.c:3280 [inline]
validate_chain+0x1888/0x5760 sect/v6.13-rc4/kernel/locking/lockdep.c:3904
__lock_acquire+0x13b4/0x2120 sect/v6.13-rc4/kernel/locking/lockdep.c:5226
lock_acquire+0x1c4/0x520 sect/v6.13-rc4/kernel/locking/lockdep.c:5849
touch_work_lockdep_map sect/v6.13-rc4/kernel/workqueue.c:3909 [inline]
start_flush_work sect/v6.13-rc4/kernel/workqueue.c:4163 [inline]
__flush_work+0x70f/0xc40 sect/v6.13-rc4/kernel/workqueue.c:4195
__cancel_work_sync sect/v6.13-rc4/kernel/workqueue.c:4351 [inline]
disable_delayed_work_sync+0xbb/0xf0 sect/v6.13-rc4/kernel/workqueue.c:4514
sco_conn_free sect/v6.13-rc4/net/bluetooth/sco.c:95 [inline]
kref_put sect/v6.13-rc4/./include/linux/kref.h:65 [inline]
sco_conn_put+0x18f/0x270 sect/v6.13-rc4/net/bluetooth/sco.c:107
sco_chan_del+0xe2/0x210 sect/v6.13-rc4/net/bluetooth/sco.c:236
sco_sock_close+0x8f/0x100 sect/v6.13-rc4/net/bluetooth/sco.c:526
sco_sock_release+0x62/0x2d0 sect/v6.13-rc4/net/bluetooth/sco.c:1300
__sock_release+0xe1/0x2d0 sect/v6.13-rc4/net/socket.c:640
sock_close+0x1c/0x30 sect/v6.13-rc4/net/socket.c:1408
__fput+0x2bd/0xa80 sect/v6.13-rc4/fs/file_table.c:450
__fput_sync+0x15e/0x1c0 sect/v6.13-rc4/fs/file_table.c:535
__do_sys_close sect/v6.13-rc4/fs/open.c:1554 [inline]
__se_sys_close sect/v6.13-rc4/fs/open.c:1539 [inline]
__x64_sys_close+0x93/0x120 sect/v6.13-rc4/fs/open.c:1539
do_syscall_x64 sect/v6.13-rc4/arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xee/0x210 sect/v6.13-rc4/arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f--- net/bluetooth/sco.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
net/bluetooth/sco.c +14 -1
@@ -566,10 +566,23 @@ static void __sco_sock_close(struct sock *sk)/* Must be called on unlocked socket. */ static void sco_sock_close (struct sock *sk) { +struct sco_conn *conn; + +lock_sock (sk); + conn =sco_pi (sk)->conn; +if (conn) +sco_conn_hold (conn); +release_sock (sk); + +if (conn) +disable_delayed_work_sync (&conn->timeout_work); +lock_sock (sk); -sco_sock_clear_timer (sk);__sco_sock_close (sk);release_sock (sk); + +if (conn) +sco_conn_put (conn); }static void sco_sock_init (struct sock *sk,struct sock *parent)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1056/1611 Bluetooth: ISO: exclude RFU bits from ISO_SDU_Length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit fd076d8deeab6f9f18ef13400f89e1f550df665b ]
slen contains ISO_SDU_Length (12 bits), RFU (2 bits), Packet_Status_Flags (2 bits).
Exclude the RFU bits from hci_iso_data_len. Also add masks to the pack macro.
--- include/net/bluetooth/hci.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/net/bluetooth/hci.h +3 -2
@@ -2993,8 +2993,9 @@ static inline struct hci_iso_hdr *hci_iso_hdr(const struct sk_buff *skb)#define hci_iso_flags_pack (pb, ts) ((pb & 0x03) | ((ts & 0x01) << 2))/* ISO data length and flags pack/unpack */ -#define hci_iso_data_len_pack (h, f) ((__u16) ((h) | ((f) << 14))) -#define hci_iso_data_len (h) ((h) & 0x3fff) +#define hci_iso_data_len_pack (h, f) ((__u16) (((h) & 0x0fff) | \ + (((f) & 0x3) << 14))) +#define hci_iso_data_len (h) ((h) & 0x0fff)#define hci_iso_data_flags (h) ((h) >> 14)/* codec transport types */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1057/1611 Bluetooth: bpa10x: avoid OOB read of revision string in bpa10x_setup()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit dd068ef044128db655f48323a4acfd5907e04903 ]
bpa10x_setup() sends the vendor command 0xfc0e and passes the response to bt_dev_info() and hci_set_fw_info() as a "%s" string starting at skb->data + 1, without checking the length:
bt_dev_info(hdev, "%s", (char *)(skb->data + 1)); hci_set_fw_info(hdev, "%s", skb->data + 1);
A device that returns a one-byte response (status only) leaves skb->data + 1 past the end of the data, and the %s walk reads adjacent slab memory until it meets a NUL. The same happens when the payload is not NUL-terminated within skb->len. The out-of-bounds bytes end up in the kernel log and the firmware-info debugfs file.
Print the revision string with a bounded "%.*s" limited to skb->len - 1 instead. This keeps the string readable for well-behaved devices while never reading past the received data, and does not fail setup, so a device returning a short or unterminated response keeps working.
--- drivers/bluetooth/bpa10x.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/bluetooth/bpa10x.c +6 -2
@@ -255,9 +255,13 @@ static int bpa10x_setup(struct hci_dev *hdev)if (IS_ERR (skb))return PTR_ERR (skb); -bt_dev_info (hdev,"%s" , (char *)(skb->data +1 )); +/* Bounded print: the device controls skb->len. */ +if (skb->len >1 ) { +int len = skb->len -1 ; -hci_set_fw_info (hdev,"%s" , skb->data +1 ); +bt_dev_info (hdev,"%.*s" , len, (char *)(skb->data +1 )); +hci_set_fw_info (hdev,"%.*s" , len, skb->data +1 ); + }kfree_skb (skb);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1058/1611 Bluetooth: L2CAP: fix tx ident leak for commands without a response
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stig Hornang <[email protected]>
[ Upstream commit 6e1930ece855a4c256f1c7e6632d634cfb9888b5 ]
Commit 6c3ea155e5ee ("Bluetooth: L2CAP: Fix not tracking outstanding TX ident") changed ident allocation to use an IDA, releasing idents in l2cap_put_ident() when the matching response command is received.
But identifiers allocated for commands that have no response defined are never released. In particular L2CAP_LE_CREDITS is sent repeatedly for the lifetime of an LE CoC channel, so a peer streaming data to the host exhausts the 1-255 ident range after 254 credit packets. From then on l2cap_get_ident() fails:
kernel: Bluetooth: Unable to allocate ident: -28
and every subsequent L2CAP_LE_CREDITS packet is sent with ident 0, which is invalid (Core Spec, Vol 3, Part A, Section 4: "Signaling identifier 0x00 is an invalid identifier and shall never be used in any command"). Remote stacks that validate the ident drop these commands, never receive new credits, and the channel stalls permanently. With default socket buffers this happens after roughly 0.5 MB of received data (the exact amount depends on the socket receive buffer):
< ACL Data TX: Handle 2048 flags 0x00 dlen 12
LE L2CAP: LE Flow Control Credit (0x16) ident 0 len 4
Source CID: 64
Credits: 1
Release the ident immediately after sending L2CAP_LE_CREDITS since no response will ever release it. Use a local variable instead of chan->ident so that an ident that an EXT_FLOWCTL channel may be waiting on (e.g. a pending reconfigure) is not overwritten by a credit packet.
Also add the missing L2CAP_LE_CONN_RSP case to l2cap_put_ident() so idents allocated for outgoing L2CAP_LE_CONN_REQ commands are released when the response arrives.
--- net/bluetooth/l2cap_core.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_core.c +13 -2
@@ -4832,6 +4832,7 @@ static void l2cap_put_ident(struct l2cap_conn *conn, u8 code, u8 id)case L2CAP_ECHO_RSP :case L2CAP_INFO_RSP :case L2CAP_CONN_PARAM_UPDATE_RSP : +case L2CAP_LE_CONN_RSP :case L2CAP_ECRED_CONN_RSP :case L2CAP_ECRED_RECONF_RSP :/* First do a lookup since the remote may send bogus ids that
@@ -6729,6 +6730,7 @@ static void l2cap_chan_le_send_credits(struct l2cap_chan *chan)struct l2cap_conn *conn = chan->conn;struct l2cap_le_credits pkt;u16 return_credits =l2cap_le_rx_credits (chan); +int ident;if (chan->mode !=L2CAP_MODE_LE_FLOWCTL && chan->mode !=L2CAP_MODE_EXT_FLOWCTL )
@@ -6746,9 +6748,18 @@ static void l2cap_chan_le_send_credits(struct l2cap_chan *chan) pkt.cid =cpu_to_le16 (chan->scid); pkt.credits =cpu_to_le16 (return_credits); - chan->ident =l2cap_get_ident (conn); + ident =l2cap_get_ident (conn); -l2cap_send_cmd (conn, chan->ident,L2CAP_LE_CREDITS ,sizeof (pkt), &pkt); +l2cap_send_cmd (conn, ident,L2CAP_LE_CREDITS ,sizeof (pkt), &pkt); + +/* L2CAP_LE_CREDITS has no response so the ident is never released by +* l2cap_put_ident() - release it right away, otherwise the tx_ida +* range is exhausted after 254 packets and from then on credits are +* sent with the invalid ident 0, which some remote stacks ignore, +* stalling the channel. +*/ +if (ident >0 ) +ida_free (&conn->tx_ida, ident); }void l2cap_chan_rx_avail (struct l2cap_chan *chan,ssize_t rx_avail)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1059/1611 ring-buffer: Fix event length with forced 8-byte alignment
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Wang <[email protected]>
[ Upstream commit c37e0a4b79a6bbb96ce5ffe279d7c001e20529e0 ]
When RB_FORCE_8BYTE_ALIGNMENT is true, rb_calculate_event_length() reserves the space of event->array[0] for placing the data length and rb_update_event() stores the data length in event->array[0] accordingly. As a result the whole event length will add extra 4 bytes for sizeof(event.array[0]) unconditionally.
But ring_buffer_event_length() only subtracts the sizeof(event->array[0]) for events larger than RB_MAX_SMALL_DATA + sizeof(event->array[0]). As a result, small events on architectures with RB_FORCE_8BYTE_ALIGNMENT=true report a data length that is 4 bytes larger than expected.
To fix it, add the RB_FORCE_8BYTE_ALIGNMENT as a condition to subtract the size of that length field whenever RB_FORCE_8BYTE_ALIGNMENT is true.
This issue is observed in a riscv64 kernel with CONFIG_HAVE_64BIT_ALIGNED_ACCESS set to y, when we run ftrace selftest trace_marker_raw.tc, we get the weird log: for cases where the id is 1..100, the number of data field is 8*N, but once id exceeds 100, the number of data field becomes 8*N+4:
# 1 buf: 58 00 00 00 80 5e d1 63 (number of data field is 8*1)
...
# a buf: 58 ... (number of data field is 8*2) ... # 64 buf: 58 ... (number of data field is 8*13) # 65 buf: 58 ... (number of data field is 8*13+4)
After applying this change, the number of data field keeps being 8*N+4 consistently.
--- kernel/trace/ring_buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/ring_buffer.c +2 -1
@@ -281,7 +281,8 @@ unsigned ring_buffer_event_length(struct ring_buffer_event *event)if (event->type_len >RINGBUF_TYPE_DATA_TYPE_LEN_MAX )return length; length -=RB_EVNT_HDR_SIZE ; -if (length >RB_MAX_SMALL_DATA +sizeof (event->array[0 ])) +if (length >RB_MAX_SMALL_DATA +sizeof (event->array[0 ]) || +RB_FORCE_8BYTE_ALIGNMENT ) length -=sizeof (event->array[0 ]);return length; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1060/1611 accel/amdxdna: Use unsigned long for nr_pages in amdxdna_hmm_register()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Hou <[email protected]>
[ Upstream commit 18aaebdf43366954345a6721ed2bff3ac3c9fa61 ]
nr_pages is declared as u32 in amdxdna_hmm_register(), which may not be large enough to represent the number of pages for large mappings.
Use unsigned long for nr_pages to avoid potential overflow.
--- drivers/accel/amdxdna/amdxdna_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/amdxdna/amdxdna_gem.c +1 -1
@@ -196,7 +196,7 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,unsigned long len = vma->vm_end - vma->vm_start;unsigned long addr = vma->vm_start;struct amdxdna_umap *mapp; -u32 nr_pages; +unsigned long nr_pages;int ret;if (!xdna->dev_info->ops->hmm_invalidate)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1061/1611 net/tls: Consume empty data records in tls_sw_read_sock()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 3be28e2c9cd0230cb51fd4967df095273afd3848 ]
A peer may send a zero-length TLS application_data record; TLS 1.3 explicitly permits these as a traffic-analysis countermeasure (RFC 8446, Section 5.1). After decryption such a record has full_len ==
0. tls_sw_read_sock() hands it to the read_actor, which has no payload to consume and returns zero. The loop treats a zero return as backpressure (used <= 0), requeues the skb at the head of rx_list, and stops. rx_list is serviced head-first on the next call, so the empty record is dequeued, fails the same way, and is requeued again; every later record on the connection is blocked behind it.
tls_sw_recvmsg() does not stall on this: a zero-length data record copies nothing and falls through to consume_skb(). Mirror that in the read_sock() path by recognizing an empty data record before the actor runs, consuming it, and continuing.
--- net/tls/tls_sw.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
net/tls/tls_sw.c +11 -0
@@ -2424,6 +2424,17 @@ int tls_sw_read_sock(struct sock *sk, read_descriptor_t *desc, goto read_sock_requeue; } +/* An empty data record (legal in TLS 1.3) gives a zero +* read_actor return, indistinguishable from the consumer +* stalling; the used <= 0 path would requeue it at the +* head of rx_list and block all later records. Consume it +* here instead. +*/ +if (rxm->full_len ==0 ) { +consume_skb (skb); +continue ; + } + used =read_actor (desc, skb, rxm->offset, rxm->full_len);if (used <=0 ) {if (!copied)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1062/1611 net: usb: lan78xx: disable VLAN filter in promiscuous mode
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Enrico Pozzobon <[email protected]>
[ Upstream commit 60444706aa17616efc03190d099ac347e28b3d0a ]
The hardware VLAN filter (RFE_CTL_VLAN_FILTER_) drops VLAN-tagged frames whose VID has not been registered via lan78xx_vlan_rx_add_vid(). It is left enabled in promiscuous mode, so packet capture (e.g. tcpdump or Wireshark) does not see tagged frames for unregistered VIDs.
Clear the filter while the interface is promiscuous and restore it from NETIF_F_HW_VLAN_CTAG_FILTER otherwise. Enforce the same condition in lan78xx_set_features() so netdev_update_features() cannot re-enable the filter while promiscuous.
--- drivers/net/usb/lan78xx.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/net/usb/lan78xx.c +14 -4
@@ -1499,6 +1499,17 @@ static void lan78xx_deferred_multicast_write(struct work_struct *param)return ; } +static void lan78xx_update_vlan_filter (struct lan78xx_priv *pdata, +struct net_device *netdev, +netdev_features_t features) +{ +if ((features &NETIF_F_HW_VLAN_CTAG_FILTER ) && + !(netdev->flags &IFF_PROMISC )) + pdata->rfe_ctl |=RFE_CTL_VLAN_FILTER_ ; +else + pdata->rfe_ctl &= ~RFE_CTL_VLAN_FILTER_ ; +} +static void lan78xx_set_multicast (struct net_device *netdev) {struct lan78xx_net *dev =netdev_priv (netdev);
@@ -1533,6 +1544,8 @@ static void lan78xx_set_multicast(struct net_device *netdev) } } +lan78xx_update_vlan_filter (pdata, dev->net, dev->net->features); +if (netdev_mc_count (dev->net)) {struct netdev_hw_addr *ha;int i;
@@ -3074,10 +3087,7 @@ static int lan78xx_set_features(struct net_device *netdev,else pdata->rfe_ctl &= ~RFE_CTL_VLAN_STRIP_ ; -if (features &NETIF_F_HW_VLAN_CTAG_FILTER ) - pdata->rfe_ctl |=RFE_CTL_VLAN_FILTER_ ; -else - pdata->rfe_ctl &= ~RFE_CTL_VLAN_FILTER_ ; +lan78xx_update_vlan_filter (pdata, netdev, features);spin_unlock_irqrestore (&pdata->rfe_ctl_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1063/1611 gpio: dwapb: Use modern PM macros
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jisheng Zhang <[email protected]>
[ Upstream commit 3f19e57cbfb55d743d60aeebf5d5c48cc7fd5d4e ]
Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.
This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.
Stable-dep-of: d775b9451eb8 ("gpio: dwapb: Defer clock gating until noirq")
--- drivers/gpio/gpio-dwapb.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/gpio/gpio-dwapb.c +4 -14
@@ -79,7 +79,6 @@ struct dwapb_platform_data {unsigned int nports; }; -#ifdef CONFIG_PM_SLEEP/* Store GPIO context across system-wide suspend/resume transitions */ struct dwapb_context {u32 data;
@@ -92,7 +91,6 @@ struct dwapb_context {u32 int_deb;u32 wake_en; }; -#endif struct dwapb_gpio_port_irqchip {unsigned int nr_irqs;
@@ -103,9 +101,7 @@ struct dwapb_gpio_port {struct gpio_generic_chip chip;struct dwapb_gpio_port_irqchip *pirq;struct dwapb_gpio *gpio; -#ifdef CONFIG_PM_SLEEP struct dwapb_context *ctx; -#endif unsigned int idx; };
@@ -363,7 +359,6 @@ static int dwapb_irq_set_type(struct irq_data *d, u32 type)return 0 ; } -#ifdef CONFIG_PM_SLEEP static int dwapb_irq_set_wake (struct irq_data *d,unsigned int enable) {struct gpio_chip *gc =irq_data_get_irq_chip_data (d);
@@ -378,9 +373,6 @@ static int dwapb_irq_set_wake(struct irq_data *d, unsigned int enable)return 0 ; } -#else -#define dwapb_irq_set_wake NULL -#endif static const struct irq_chip dwapb_irq_chip = { .name =DWAPB_DRIVER_NAME ,
@@ -390,7 +382,7 @@ static const struct irq_chip dwapb_irq_chip = { .irq_set_type = dwapb_irq_set_type, .irq_enable = dwapb_irq_enable, .irq_disable = dwapb_irq_disable, - .irq_set_wake = dwapb_irq_set_wake, + .irq_set_wake = pm_sleep_ptr(dwapb_irq_set_wake), .flags = IRQCHIP_IMMUTABLE, GPIOCHIP_IRQ_RESOURCE_HELPERS, };
@@ -759,7 +751,6 @@ static int dwapb_gpio_probe(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_SLEEP static int dwapb_gpio_suspend (struct device *dev) {struct dwapb_gpio *gpio =dev_get_drvdata (dev);
@@ -844,15 +835,14 @@ static int dwapb_gpio_resume(struct device *dev)return 0 ; } -#endif -static SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, dwapb_gpio_suspend, - dwapb_gpio_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, + dwapb_gpio_suspend, dwapb_gpio_resume);static struct platform_driver dwapb_gpio_driver = { .driver = { .name =DWAPB_DRIVER_NAME , - .pm = &dwapb_gpio_pm_ops, + .pm =pm_sleep_ptr (&dwapb_gpio_pm_ops), .of_match_table = dwapb_of_match, .acpi_match_table = dwapb_acpi_match, },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1064/1611 gpio: dwapb: reduce allocation to single kzalloc
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 9a5bf2f53b76b1619c602f9e751fe4c0e64713ca ]
Instead of kzalloc + kcalloc, Combine the two using a flexible array member.
Allows using __counted_by for extra runtime analysis. Move counting variable to right after allocation as required by __counted_by.
Stable-dep-of: d775b9451eb8 ("gpio: dwapb: Defer clock gating until noirq")
--- drivers/gpio/gpio-dwapb.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/gpio/gpio-dwapb.c +5 -14
@@ -75,8 +75,8 @@ struct dwapb_port_property { };struct dwapb_platform_data { -struct dwapb_port_property *properties;unsigned int nports; + struct dwapb_port_property properties[] __counted_by(nports); };/* Store GPIO context across system-wide suspend/resume transitions */
@@ -114,11 +114,11 @@ static inline struct dwapb_gpio *to_dwapb_gpio(struct gpio_chip *gc)struct dwapb_gpio {struct device *dev;void __iomem *regs; -struct dwapb_gpio_port *ports;unsigned int nr_ports;unsigned int flags;struct reset_control *rst;struct clk_bulk_data clks[DWAPB_NR_CLOCKS ]; + struct dwapb_gpio_port ports[] __counted_by(nr_ports); };static inline u32 gpio_reg_v2_convert (unsigned int offset)
@@ -585,14 +585,10 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev)if (nports ==0 )return ERR_PTR (-ENODEV ); - pdata =devm_kzalloc (dev,sizeof (*pdata),GFP_KERNEL ); + pdata =devm_kzalloc (dev,struct_size (pdata, properties, nports),GFP_KERNEL );if (!pdata)return ERR_PTR (-ENOMEM ); - pdata->properties =devm_kcalloc (dev, nports,sizeof (*pp),GFP_KERNEL ); -if (!pdata->properties) -return ERR_PTR (-ENOMEM ); - pdata->nports = nports; i =0 ;
@@ -714,22 +710,17 @@ static int dwapb_gpio_probe(struct platform_device *pdev)if (IS_ERR (pdata))return PTR_ERR (pdata); - gpio =devm_kzalloc (&pdev->dev,sizeof (*gpio),GFP_KERNEL ); + gpio =devm_kzalloc (&pdev->dev,struct_size (gpio, ports, pdata->nports),GFP_KERNEL );if (!gpio)return -ENOMEM ; - gpio->dev = &pdev->dev; gpio->nr_ports = pdata->nports; + gpio->dev = &pdev->dev; err =dwapb_get_reset (gpio);if (err)return err; - gpio->ports =devm_kcalloc (&pdev->dev, gpio->nr_ports, -sizeof (*gpio->ports),GFP_KERNEL ); -if (!gpio->ports) -return -ENOMEM ; - gpio->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (gpio->regs))return PTR_ERR (gpio->regs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1065/1611 gpio: dwapb: Defer clock gating until noirq
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Wang <[email protected]>
[ Upstream commit d775b9451eb8f52021dea6483ad758fef81dbf1e ]
GPIO consumers such as gpio-keys can enable IRQ wake and adjust the wake trigger type from their suspend callbacks. If the DWAPB controller suspends first, masking interrupts and disabling its clocks in the normal suspend phase prevents that late wake configuration from reliably reaching the hardware. Systems with real DWAPB bus clocks then fail to wake from s2idle through GPIO keys.
Save the register context in the normal suspend callback, but defer IRQ masking and clock gating until suspend_noirq. At that point all consumers have finished configuring wake IRQs, so keep the clocks enabled when wake lines are armed and only gate them when no wake source is active. Resume_noirq reenables clocks, if they were gated, before the normal resume path restores registers.
Propagate wake requests to the parent irqchip while keeping the local wake mask in sync with failures.
--- drivers/gpio/gpio-dwapb.c | 79 +++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 12 deletions(-)
drivers/gpio/gpio-dwapb.c +67 -12
@@ -118,6 +118,7 @@ struct dwapb_gpio {unsigned int flags;struct reset_control *rst;struct clk_bulk_data clks[DWAPB_NR_CLOCKS ]; +bool clocks_on_for_wake; struct dwapb_gpio_port ports[] __counted_by(nr_ports); };
@@ -365,11 +366,24 @@ static int dwapb_irq_set_wake(struct irq_data *d, unsigned int enable)struct dwapb_gpio *gpio =to_dwapb_gpio (gc);struct dwapb_context *ctx = gpio->ports[0 ].ctx;irq_hw_number_t bit =irqd_to_hwirq (d); +u32 wake_en = ctx->wake_en;if (enable) - ctx->wake_en |=BIT (bit); + wake_en |=BIT (bit);else - ctx->wake_en &= ~BIT (bit); + wake_en &= ~BIT (bit); + +#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY +if (d->parent_data && !!ctx->wake_en != !!wake_en) { +int err; + + err =irq_chip_set_wake_parent (d, enable); +if (err) +return err; + } +#endif + + ctx->wake_en = wake_en;return 0 ; }
@@ -749,6 +763,8 @@ static int dwapb_gpio_suspend(struct device *dev)int i; scoped_guard(gpio_generic_lock_irqsave, gen_gc) { + gpio->clocks_on_for_wake = false; +for (i =0 ; i < gpio->nr_ports; i++) {unsigned int offset;unsigned int idx = gpio->ports[i].idx;
@@ -770,11 +786,38 @@ static int dwapb_gpio_suspend(struct device *dev) ctx->int_pol =dwapb_read (gpio,GPIO_INT_POLARITY ); ctx->int_type =dwapb_read (gpio,GPIO_INTTYPE_LEVEL ); ctx->int_deb =dwapb_read (gpio,GPIO_PORTA_DEBOUNCE ); + } + } + } + +return 0 ; +} + +static int dwapb_gpio_suspend_noirq (struct device *dev) +{ +struct dwapb_gpio *gpio =dev_get_drvdata (dev); +struct gpio_generic_chip *gen_gc = &gpio->ports[0 ].chip; +bool wake_enabled = false; +int i; + + scoped_guard(gpio_generic_lock_irqsave, gen_gc) { +for (i =0 ; i < gpio->nr_ports; i++) { +unsigned int idx = gpio->ports[i].idx; +struct dwapb_context *ctx = gpio->ports[i].ctx; -/* Mask out interrupts */ +if (idx ==0 ) { + wake_enabled = ctx->wake_en;dwapb_write (gpio,GPIO_INTMASK , ~ctx->wake_en); +break ; } } + + gpio->clocks_on_for_wake = wake_enabled; + } + +if (wake_enabled) { +device_set_wakeup_path (dev); +return 0 ; }clk_bulk_disable_unprepare (DWAPB_NR_CLOCKS , gpio->clks);
@@ -782,18 +825,27 @@ static int dwapb_gpio_suspend(struct device *dev)return 0 ; } -static int dwapb_gpio_resume (struct device *dev) +static int dwapb_gpio_resume_noirq (struct device *dev) {struct dwapb_gpio *gpio =dev_get_drvdata (dev); -struct gpio_chip *gc = &gpio->ports[0 ].chip.gc; -struct gpio_generic_chip *gen_gc =to_gpio_generic_chip (gc); -int i, err; +int err; + +if (gpio->clocks_on_for_wake) +return 0 ; err =clk_bulk_prepare_enable (DWAPB_NR_CLOCKS , gpio->clks); -if (err) { +if (err)dev_err (gpio->dev,"Cannot reenable APB/Debounce clocks\n" ); -return err; - } + +return err; +} + +static int dwapb_gpio_resume (struct device *dev) +{ +struct dwapb_gpio *gpio =dev_get_drvdata (dev); +struct gpio_chip *gc = &gpio->ports[0 ].chip.gc; +struct gpio_generic_chip *gen_gc =to_gpio_generic_chip (gc); +int i;guard (gpio_generic_lock_irqsave)(gen_gc);
@@ -827,8 +879,11 @@ static int dwapb_gpio_resume(struct device *dev)return 0 ; } -static DEFINE_SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, - dwapb_gpio_suspend, dwapb_gpio_resume); +static const struct dev_pm_ops dwapb_gpio_pm_ops = { + SYSTEM_SLEEP_PM_OPS(dwapb_gpio_suspend, dwapb_gpio_resume) +NOIRQ_SYSTEM_SLEEP_PM_OPS (dwapb_gpio_suspend_noirq, + dwapb_gpio_resume_noirq) +};static struct platform_driver dwapb_gpio_driver = { .driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1066/1611 tracing: Make tracepoint_printk static as not exported
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Dooks <[email protected]>
[ Upstream commit d5c6785f94ead7cd76b38af301ac63cb673485bc ]
The tracepoint_printk symbol is not exported, so make it static to remove the following sparse warning:
kernel/trace/trace.c:90:5: warning: symbol 'tracepoint_printk' was not declared. Should it be static?
--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
@@ -88,7 +88,7 @@ void __init disable_tracing_selftest(const char *reason)/* Pipe tracepoints to printk */ static struct trace_iterator *tracepoint_print_iter; -int tracepoint_printk; +static int tracepoint_printk;static bool tracepoint_printk_stop_on_boot__initdata ;static bool traceoff_after_boot__initdata ;static DEFINE_STATIC_KEY_FALSE (tracepoint_printk_key);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1067/1611 accel/amdxdna: Fix potential amdxdna_umap lifetime race
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Hou <[email protected]>
[ Upstream commit 14f172eff9c19f8043a9858845f33cd034f3a41e ]
amdxdna_umap_release() calls the blocking mmu_interval_notifier_remove() before removing the object from abo->mem.umap_list. If aie2_populate_range() runs concurrently, it may obtain a reference to an amdxdna_umap that is being released, leading to a potential use-after-free.
Use kref_get_unless_zero() in aie2_populate_range() when acquiring a reference. If the reference count has already dropped to zero, release is in progress and the entry is skipped.
--- drivers/accel/amdxdna/aie2_ctx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/accel/amdxdna/aie2_ctx.c +2 -2
@@ -794,7 +794,7 @@ static int aie2_populate_range(struct amdxdna_gem_obj *abo) found = false;down_write (&xdna->notifier_lock);list_for_each_entry (mapp, &abo->mem.umap_list, node) { -if (mapp->invalid) { +if (mapp->invalid &&kref_get_unless_zero (&mapp->refcnt)) { found = true;break ; }
@@ -805,7 +805,7 @@ static int aie2_populate_range(struct amdxdna_gem_obj *abo)up_write (&xdna->notifier_lock);return 0 ; } -kref_get (&mapp->refcnt); +up_write (&xdna->notifier_lock); XDNA_DBG(xdna, "populate memory range %lx %lx",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1068/1611 drm/v3d: Reject invalid indirect BO handle in indirect CSD setup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit 2f8b8593c7832fad655290cef9e99af05b1b52b3 ]
v3d_get_cpu_indirect_csd_params() looks up the indirect buffer object from a userspace-supplied handle but never checks the result. A bogus or stale handle makes drm_gem_object_lookup() return NULL, which is then stored in info->indirect and only dereferenced later when the indirect CSD job runs, turning a userspace mistake into a NULL pointer dereference in the kernel.
Bail out with -ENOENT as soon as the lookup fails, so the bad handle is rejected at submission time.
--- drivers/gpu/drm/v3d/v3d_submit.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/v3d/v3d_submit.c +2 -0
@@ -462,6 +462,8 @@ v3d_get_cpu_indirect_csd_params(struct drm_file *file_priv, sizeof(indirect_csd.wg_uniform_offsets)); info->indirect =drm_gem_object_lookup (file_priv, indirect_csd.indirect); +if (!info->indirect) +return -ENOENT ; return v3d_setup_csd_jobs_and_bos(file_priv, v3d, &indirect_csd.submit, &info->job, &info->clean_job,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1069/1611 net: mdio: select REGMAP_MMIO instead of depending on it
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 1a3267a8c9ecabb8e27f5cbda6d19295d5e41beb ]
REGMAP_MMIO is a hidden (non-user-visible) tristate symbol. Using depends on it is incorrect because there is no way for the user to enable it directly. Change to select, which is the convention used by every other driver in the tree that needs REGMAP_MMIO.
--- drivers/net/mdio/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mdio/Kconfig +2 -1
@@ -123,7 +123,8 @@ config MDIO_MVUSB config MDIO_MSCC_MIIM tristate "Microsemi MIIM interface support" - depends on HAS_IOMEM && REGMAP_MMIO + depends on HAS_IOMEM + select REGMAP_MMIO help This driver supports the MIIM (MDIO) interface found in the network switches of the Microsemi SoCs; it is recommended to switch on
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1070/1611 net/sched: cake: reject overhead values that underflow length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit b7f97cae7ec1b6c3c32843c42be218690d310467 ]
CAKE accepts signed overhead values and stores them in an s16, but the adjusted packet length calculation uses unsigned arithmetic. A negative effective length can therefore wrap to a large value.
Such configurations make rate accounting depend on integer wraparound rather than on the packet size userspace intended to model. A static netlink lower bound is not enough because packets reaching CAKE can be smaller than any reasonable manual-overhead allowance.
Fold the signed overhead adjustment into the existing datapath MPU clamp so negative adjusted lengths are clamped before link-layer framing adjustments.
--- net/sched/sch_cake.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
net/sched/sch_cake.c +1 -4
@@ -1368,10 +1368,7 @@ static u32 cake_calc_overhead(struct cake_sched_data *q, u32 len, u32 off)if (q->min_netlen > len) q->min_netlen = len; - len += q->rate_overhead; - -if (len < q->rate_mpu) - len = q->rate_mpu; + len =max ((s32 )len + q->rate_overhead, (s32 )q->rate_mpu);if (q->atm_mode ==CAKE_ATM_ATM ) { len +=47 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1071/1611 octeontx2-pf: check DMAC extraction support before filtering
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suman Ghosh <[email protected]>
[ Upstream commit 235acadd310533ba386ae61ad155b72bee381559 ]
Currently, configuring a VF MAC address via the PF (e.g., 'ip link set <pf> vf 0 mac <mac>') blindly attempts to install a DMAC-based hardware filter. However, the hardware parser profile might not support DMAC extraction.
Check if the hardware parsing profile supports DMAC extraction before adding the filter. Additionally, emit a warning message to inform the operator if the MAC filter installation fails due to missing DMAC extraction support. Update config->mac only after hardware programming succeeds in otx2_set_vf_mac().
--- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +37 -6
@@ -2530,10 +2530,42 @@ EXPORT_SYMBOL(otx2_ioctl);static int otx2_do_set_vf_mac (struct otx2_nic *pf,int vf,const u8 *mac) { +struct npc_get_field_status_req *freq; +struct npc_get_field_status_rsp *frsp;struct npc_install_flow_req *req;int err;mutex_lock (&pf->mbox.lock); + +/* Skip installing the DMAC filter if the hardware parser profile +* does not support DMAC extraction. +*/ + freq =otx2_mbox_alloc_msg_npc_get_field_status (&pf->mbox); +if (!freq) { + err = -ENOMEM ; + goto out; + } + + freq->field =NPC_DMAC ; + err =otx2_sync_mbox_msg (&pf->mbox); +if (err) + goto out; + + frsp = (struct npc_get_field_status_rsp *)otx2_mbox_get_rsp + (&pf->mbox.mbox,0 , &freq->hdr); +if (IS_ERR (frsp)) { + err =PTR_ERR (frsp); + goto out; + } + +if (!frsp->enable) { +netdev_warn (pf->netdev, +"VF %d MAC filter not installed: DMAC extraction not supported by parser profile\n" , + vf); + err = -EOPNOTSUPP ; + goto out; + } + req =otx2_mbox_alloc_msg_npc_install_flow (&pf->mbox);if (!req) { err = -ENOMEM ;
@@ -2572,13 +2604,12 @@ static int otx2_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)if (!is_valid_ether_addr (mac))return -EINVAL ; - config = &pf->vf_configs[vf]; -ether_addr_copy (config->mac, mac); - ret =otx2_do_set_vf_mac (pf, vf, mac); -if (ret ==0 ) -dev_info (&pdev->dev, -"Load/Reload VF driver\n" ); +if (ret ==0 ) { + config = &pf->vf_configs[vf]; +ether_addr_copy (config->mac, mac); +dev_info (&pdev->dev,"Load/Reload VF driver\n" ); + }return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1072/1611 perf/x86/amd/core: Avoid enabling BRS from the SVM reload path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sandipan Das <[email protected]>
[ Upstream commit 07c60dda9c059c09f83d42a3ebda2e7cc1cf3bc2 ]
Branch Sampling (BRS) and Last Branch Record (LBR) are mutually exclusive hardware features, and users of both are tracked via cpuc->lbr_users.
When SVM is toggled on a CPU, the host perf events are reprogrammed to update the HostOnly filter bit (set when virtualization is enabled, cleared when it is disabled). On PerfMonV2-capable processors, this reprogramming is performed by calling amd_pmu_enable_all() to rewrite the event selectors. However, amd_pmu_enable_all() also calls amd_brs_enable_all(), which enables BRS whenever cpuc->lbr_users > 0. Having active LBR events satisfies this gating on processors that have LBR but not BRS. The kernel then tries to set the BRS enable bit in DebugExtnCfg (MSR 0xc000010f). Since that bit is deprecated on such hardware, the write results in a #GP:
Call Trace: <IRQ> amd_pmu_enable_all+0x1d/0x90 amd_pmu_disable_virt+0x62/0xb0 kvm_arch_disable_virtualization_cpu+0xa/0x40 [kvm] hardware_disable_nolock+0x1a/0x30 [kvm] __flush_smp_call_function_queue+0x9b/0x410 __sysvec_call_function+0x18/0xc0 sysvec_call_function+0x69/0x90 </IRQ> <TASK> asm_sysvec_call_function+0x16/0x20 RIP: 0010:cpuidle_enter_state+0xc4/0x450 ? cpuidle_enter_state+0xb7/0x450 cpuidle_enter+0x29/0x40 cpuidle_idle_call+0xf5/0x160 do_idle+0x7b/0xe0 cpu_startup_entry+0x26/0x30 start_secondary+0x115/0x140 secondary_startup_64_no_verify+0x194/0x19b </TASK>
Fix this by ensuring that BRS is not enabled from the event selector reprogramming path even when cpuc->lbr_users > 0.
--- arch/x86/events/amd/core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/x86/events/amd/core.c +8 -4
@@ -751,13 +751,11 @@ static void amd_pmu_enable_event(struct perf_event *event)x86_pmu_enable_event (event); } -static void amd_pmu_enable_all (int added) +static void __amd_pmu_enable_all (void ) {struct cpu_hw_events *cpuc =this_cpu_ptr (&cpu_hw_events);int idx; -amd_brs_enable_all (); -for_each_set_bit (idx, x86_pmu.cntr_mask,X86_PMC_IDX_MAX ) {/* only activate events which are marked as active */ if (!test_bit (idx, cpuc->active_mask))
@@ -772,6 +770,12 @@ static void amd_pmu_enable_all(int added) } } +static void amd_pmu_enable_all (int added) +{ +amd_brs_enable_all (); +__amd_pmu_enable_all (); +} +static void amd_pmu_v2_enable_event (struct perf_event *event) {struct hw_perf_event *hwc = &event->hw;
@@ -1556,7 +1560,7 @@ static inline void amd_pmu_reload_virt(void)* set global enable bits once again */ amd_pmu_v2_disable_all (); -amd_pmu_enable_all (0 ); +__amd_pmu_enable_all ();amd_pmu_v2_enable_all (0 );return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1073/1611 gpio: mvebu: free generic chips on unbind
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit b11c513ad943f35cf5e8007d3a56279c79b7ed4b ]
irq_alloc_domain_generic_chips() allocates generic chip data that must be freed via irq_domain_remove_generic_chips(). The devres action mvebu_gpio_remove_irq_domain() only called irq_domain_remove(), which only frees the generic chips if IRQ_DOMAIN_FLAG_DESTROY_GC is set. Call irq_domain_remove_generic_chips() explicitly before irq_domain_remove() instead.
--- drivers/gpio/gpio-mvebu.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpio-mvebu.c +1 -0
@@ -1111,6 +1111,7 @@ static void mvebu_gpio_remove_irq_domain(void *data) {struct irq_domain *domain = data; +irq_domain_remove_generic_chips (domain);irq_domain_remove (domain); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1074/1611 ipv4: igmp: Fix potential UAF in igmp_gq_start_timer()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 7b19c0f81ed1fdaec6bc522569be367199a9edf3 ]
A race condition exists between device teardown (inetdev_destroy) and incoming IGMP query processing (igmp_rcv), leading to a Use-After-Free in the IGMP timer callback.
During device destruction, inetdev_destroy() drops the primary reference to in_device, which can drop its refcount to 0. The actual freeing of in_device memory is deferred via RCU (using call_rcu()).
Concurrently, igmp_rcv() runs under RCU read lock and obtains the in_device pointer. Because the memory is RCU-protected, CPU-0 can safely dereference in_device even if its refcount has hit 0.
However, if CPU-0 calls igmp_gq_start_timer() and re-arms the timer, it attempts to acquire a reference using in_dev_hold(). This increments the refcount from 0 to 1, triggering a "refcount_t: addition on 0" warning. Since the in_device memory is still scheduled to be freed after the RCU grace period (as the free callback does not check the refcount again), the device is freed while the timer is still armed. When the timer expires, it accesses the freed memory, causing a kernel panic.
Fix this by using refcount_inc_not_zero() (via a new helper in_dev_hold_safe()) to prevent acquiring a reference if the device is already being destroyed. If the refcount is 0, we do not arm the timer.
A similar issue in IPv6 MLD is fixed in a subsequent patch.
--- include/linux/inetdevice.h | 5 +++++ net/ipv4/igmp.c | 14 +++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-)
include/linux/inetdevice.h +5 -0
@@ -293,6 +293,11 @@ static inline void in_dev_put(struct in_device *idev)#define __in_dev_put (idev) refcount_dec(&(idev)->refcnt)#define in_dev_hold (idev) refcount_inc(&(idev)->refcnt) +static inline bool in_dev_hold_safe (struct in_device *idev) +{ +return refcount_inc_not_zero (&idev->refcnt); +} +#endif /* __KERNEL__ */ static __inline____be32 inet_make_mask (int logmask)
net/ipv4/igmp.c +9 -5
@@ -235,16 +235,20 @@ static void igmp_gq_start_timer(struct in_device *in_dev)return ; in_dev->mr_gq_running =1 ; -if (!mod_timer (&in_dev->mr_gq_timer, exp)) -in_dev_hold (in_dev); +if (in_dev_hold_safe (in_dev)) { +if (mod_timer (&in_dev->mr_gq_timer, exp)) +in_dev_put (in_dev); + } }static void igmp_ifc_start_timer (struct in_device *in_dev,int delay) { -int tv =get_random_u32_below (delay); +if (in_dev_hold_safe (in_dev)) { +int tv =get_random_u32_below (delay); -if (!mod_timer (&in_dev->mr_ifc_timer, jiffies+tv+2 )) -in_dev_hold (in_dev); +if (mod_timer (&in_dev->mr_ifc_timer, jiffies + tv +2 )) +in_dev_put (in_dev); + } }static void igmp_mod_timer (struct ip_mc_list *im,int max_delay)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1075/1611 ipv6: mcast: Fix potential UAF in MLD delayed work
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9b26518b6896a16b809b1e42986f4ebac7bccc1e ]
A race condition exists between device teardown and incoming MLD query processing, leading to a Use-After-Free in the MLD delayed work.
During device destruction, the primary reference to inet6_dev is dropped, which can drop its refcount to 0. The actual freeing of inet6_dev memory is deferred via RCU.
Concurrently, the packet receive path runs under RCU read lock and obtains the inet6_dev pointer. Because the memory is RCU-protected, CPU-0 can safely dereference inet6_dev even if its refcount has hit 0.
However, if CPU-0 calls igmp6_event_query() and schedules delayed work, it attempts to acquire a reference using in6_dev_hold(). This increments the refcount from 0 to 1, triggering a "refcount_t: addition on 0" warning. Since the inet6_dev memory is still scheduled to be freed after the RCU grace period, the device is freed while the work is still scheduled. When the work runs, it accesses the freed memory, causing a kernel panic.
Fix this by using refcount_inc_not_zero() (via a new helper in6_dev_hold_safe()) to prevent acquiring a reference if the device is already being destroyed. If the refcount is 0, we do not schedule the work.
--- include/net/addrconf.h | 5 +++++ net/ipv6/mcast.c | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 12 deletions(-)
include/net/addrconf.h +5 -0
@@ -440,6 +440,11 @@ static inline void in6_dev_hold(struct inet6_dev *idev)refcount_inc (&idev->refcnt); } +static inline bool in6_dev_hold_safe (struct inet6_dev *idev) +{ +return refcount_inc_not_zero (&idev->refcnt); +} +/* called with rcu_read_lock held */ static inline bool ip6_ignore_linkdown (const struct net_device *dev) {
net/ipv6/mcast.c +28 -12
@@ -1080,8 +1080,10 @@ static void mld_gq_start_work(struct inet6_dev *idev)mc_assert_locked (idev); idev->mc_gq_running =1 ; -if (!mod_delayed_work (mld_wq, &idev->mc_gq_work, tv +2 )) -in6_dev_hold (idev); +if (in6_dev_hold_safe (idev)) { +if (mod_delayed_work (mld_wq, &idev->mc_gq_work, tv +2 )) +in6_dev_put (idev); + } }static void mld_gq_stop_work (struct inet6_dev *idev)
@@ -1099,8 +1101,10 @@ static void mld_ifc_start_work(struct inet6_dev *idev, unsigned long delay)mc_assert_locked (idev); -if (!mod_delayed_work (mld_wq, &idev->mc_ifc_work, tv +2 )) -in6_dev_hold (idev); +if (in6_dev_hold_safe (idev)) { +if (mod_delayed_work (mld_wq, &idev->mc_ifc_work, tv +2 )) +in6_dev_put (idev); + } }static void mld_ifc_stop_work (struct inet6_dev *idev)
@@ -1118,8 +1122,10 @@ static void mld_dad_start_work(struct inet6_dev *idev, unsigned long delay)mc_assert_locked (idev); -if (!mod_delayed_work (mld_wq, &idev->mc_dad_work, tv +2 )) -in6_dev_hold (idev); +if (in6_dev_hold_safe (idev)) { +if (mod_delayed_work (mld_wq, &idev->mc_dad_work, tv +2 )) +in6_dev_put (idev); + } }static void mld_dad_stop_work (struct inet6_dev *idev)
@@ -1405,18 +1411,23 @@ static void mld_process_v2(struct inet6_dev *idev, struct mld2_query *mld,void igmp6_event_query (struct sk_buff *skb) {struct inet6_dev *idev =__in6_dev_get (skb->dev); +bool put = false;if (!idev || idev->dead) goto out;spin_lock_bh (&idev->mc_query_lock); -if (skb_queue_len (&idev->mc_query_queue) <MLD_MAX_SKBS ) { +if (skb_queue_len (&idev->mc_query_queue) <MLD_MAX_SKBS && +in6_dev_hold_safe (idev)) {__skb_queue_tail (&idev->mc_query_queue, skb); -if (!mod_delayed_work (mld_wq, &idev->mc_query_work,0 )) -in6_dev_hold (idev); +if (mod_delayed_work (mld_wq, &idev->mc_query_work,0 )) + put = true; skb =NULL ; }spin_unlock_bh (&idev->mc_query_lock); + +if (put) +in6_dev_put (idev); out:kfree_skb (skb); }
@@ -1573,18 +1584,23 @@ static void mld_query_work(struct work_struct *work)void igmp6_event_report (struct sk_buff *skb) {struct inet6_dev *idev =__in6_dev_get (skb->dev); +bool put = false;if (!idev || idev->dead) goto out;spin_lock_bh (&idev->mc_report_lock); -if (skb_queue_len (&idev->mc_report_queue) <MLD_MAX_SKBS ) { +if (skb_queue_len (&idev->mc_report_queue) <MLD_MAX_SKBS && +in6_dev_hold_safe (idev)) {__skb_queue_tail (&idev->mc_report_queue, skb); -if (!mod_delayed_work (mld_wq, &idev->mc_report_work,0 )) -in6_dev_hold (idev); +if (mod_delayed_work (mld_wq, &idev->mc_report_work,0 )) + put = true; skb =NULL ; }spin_unlock_bh (&idev->mc_report_lock); + +if (put) +in6_dev_put (idev); out:kfree_skb (skb); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1076/1611 ipv4: igmp: annotate data-races around im->users
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuyang Huang <[email protected]>
[ Upstream commit 061c0aa740d5d3847cd600a74c66a165bee1fbe0 ]
/proc/net/igmp walks IPv4 multicast memberships under RCU and prints im->users without holding RTNL, while multicast join and leave paths update the field while holding RTNL. Annotate this intentional lockless snapshot with READ_ONCE() and the matching writers with WRITE_ONCE().
Stable-dep-of: 3546deaa0c30 ("ipv4: igmp: Fix potential memory leaks in igmp_mod_timer() and igmp_stop_timer()")
--- net/ipv4/igmp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
net/ipv4/igmp.c +7 -4
@@ -1531,7 +1531,7 @@ static void ____ip_mc_inc_group(struct in_device *in_dev, __be32 addr, }if (im) { - im->users++; +WRITE_ONCE (im->users, im->users +1 );ip_mc_add_src (in_dev, &addr, mode,0 ,NULL ,0 ); goto out; }
@@ -1540,7 +1540,7 @@ static void ____ip_mc_inc_group(struct in_device *in_dev, __be32 addr,if (!im) goto out; - im->users =1 ; +WRITE_ONCE (im->users,1 ); im->interface = in_dev;in_dev_hold (in_dev); im->multiaddr = addr;
@@ -1774,7 +1774,10 @@ void __ip_mc_dec_group(struct in_device *in_dev, __be32 addr, gfp_t gfp) (i =rtnl_dereference (*ip)) !=NULL ; ip = &i->next_rcu) {if (i->multiaddr == addr) { -if (--i->users ==0 ) { +int new_users = i->users -1 ; + +WRITE_ONCE (i->users, new_users); +if (new_users ==0 ) {ip_mc_hash_remove (in_dev, i); *ip = i->next_rcu; in_dev->mc_count--;
@@ -2968,7 +2971,7 @@ static int igmp_mc_seq_show(struct seq_file *seq, void *v) delta = im->timer.expires - jiffies;seq_printf (seq,"\t\t\t\t%08X %5d %d:%08lX\t\t%d\n" , - im->multiaddr, im->users, + im->multiaddr,READ_ONCE (im->users), im->tm_running, im->tm_running ?jiffies_delta_to_clock_t (delta) :0 , im->reporter);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1077/1611 ipv4: igmp: annotate data-races around timer-related fields
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuyang Huang <[email protected]>
[ Upstream commit 3289d17b7a1321e103b8aec4ad82675c03c4764f ]
/proc/net/igmp walks the multicast list locklessly under RCU and reads timer-related fields (im->tm_running, im->reporter, im->timer.expires) to print the timer state of multicast memberships. Concurrently, these fields are modified under im->lock spinlock in timer management paths (igmp_stop_timer(), igmp_start_timer(), and igmp_timer_expire()). Fix this intentional lockless snapshot by annotating the lockless reads with READ_ONCE() and the updates with WRITE_ONCE().
Stable-dep-of: 3546deaa0c30 ("ipv4: igmp: Fix potential memory leaks in igmp_mod_timer() and igmp_stop_timer()")
--- net/ipv4/igmp.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
net/ipv4/igmp.c +13 -11
@@ -207,8 +207,8 @@ static void igmp_stop_timer(struct ip_mc_list *im)spin_lock_bh (&im->lock);if (timer_delete (&im->timer))refcount_dec (&im->refcnt); - im->tm_running =0 ; - im->reporter =0 ; +WRITE_ONCE (im->tm_running,0 ); +WRITE_ONCE (im->reporter,0 ); im->unsolicit_count =0 ;spin_unlock_bh (&im->lock); }
@@ -218,7 +218,7 @@ static void igmp_start_timer(struct ip_mc_list *im, int max_delay) {int tv =get_random_u32_below (max_delay); - im->tm_running =1 ; +WRITE_ONCE (im->tm_running,1 );if (refcount_inc_not_zero (&im->refcnt)) {if (mod_timer (&im->timer, jiffies + tv +2 ))ip_ma_put (im);
@@ -258,7 +258,7 @@ static void igmp_mod_timer(struct ip_mc_list *im, int max_delay)if (timer_delete (&im->timer)) {if ((long )(im->timer.expires-jiffies) < max_delay) {add_timer (&im->timer); - im->tm_running =1 ; +WRITE_ONCE (im->tm_running,1 );spin_unlock_bh (&im->lock);return ; }
@@ -848,12 +848,12 @@ static void igmp_timer_expire(struct timer_list *t)struct in_device *in_dev = im->interface;spin_lock (&im->lock); - im->tm_running =0 ; +WRITE_ONCE (im->tm_running,0 );if (im->unsolicit_count && --im->unsolicit_count)igmp_start_timer (im,unsolicited_report_interval (in_dev)); - im->reporter =1 ; +WRITE_ONCE (im->reporter,1 );spin_unlock (&im->lock);if (IGMP_V1_SEEN (in_dev))
@@ -1315,7 +1315,7 @@ static void __igmp_group_dropped(struct ip_mc_list *im, gfp_t gfp) !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) return; - reporter = im->reporter; + reporter =READ_ONCE (im->reporter);igmp_stop_timer (im);if (!in_dev->dead) {
@@ -2953,6 +2953,7 @@ static int igmp_mc_seq_show(struct seq_file *seq, void *v)struct ip_mc_list *im = v;struct igmp_mc_iter_state *state =igmp_mc_seq_private (seq);char *querier; +int tm_running;long delta;#ifdef CONFIG_IP_MULTICAST
@@ -2968,13 +2969,14 @@ static int igmp_mc_seq_show(struct seq_file *seq, void *v) state->dev->ifindex, state->dev->name, state->in_dev->mc_count, querier); } - delta = im->timer.expires - jiffies; + tm_running =READ_ONCE (im->tm_running); + delta =READ_ONCE (im->timer.expires) - jiffies;seq_printf (seq,"\t\t\t\t%08X %5d %d:%08lX\t\t%d\n" , im->multiaddr,READ_ONCE (im->users), - im->tm_running, - im->tm_running ?jiffies_delta_to_clock_t (delta) :0 , - im->reporter); + tm_running, + tm_running ?jiffies_delta_to_clock_t (delta) :0 , +READ_ONCE (im->reporter)); }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1078/1611 ipv4: igmp: Fix potential memory leaks in igmp_mod_timer() and igmp_stop_timer()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 3546deaa0c30a14c7cdb5dc8f2432cb428f0cd36 ]
When a timer is deleted and not re-armed in igmp_mod_timer(), or stopped in igmp_stop_timer(), the code currently decrements the reference counter of the multicast list entry @im using refcount_dec(&im->refcnt).
However, both functions can be called from the RCU reader path:
- igmp_mod_timer() via igmp_heard_query() -> for_each_pmc_rcu()
- igmp_stop_timer() via igmp_rcv() -> igmp_heard_report()
If the group im was concurrently removed from the list by ip_mc_dec_group(), its reference count might have already been decremented to 1.
In this case, timer_delete() succeeds, and refcount_dec() decrements the refcount from 1 to 0. Since refcount_dec() does not free the object when it hits 0 (unlike ip_ma_put()), the im structure is leaked.
Fix this by using ip_ma_put(im) instead of refcount_dec(&im->refcnt), and deferring the put until after the spinlock is released.
--- net/ipv4/igmp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/ipv4/igmp.c +12 -2
@@ -204,13 +204,18 @@ static void ip_sf_list_clear_all(struct ip_sf_list *psf)static void igmp_stop_timer (struct ip_mc_list *im) { +bool put = false; +spin_lock_bh (&im->lock);if (timer_delete (&im->timer)) -refcount_dec (&im->refcnt); + put = true;WRITE_ONCE (im->tm_running,0 );WRITE_ONCE (im->reporter,0 ); im->unsolicit_count =0 ;spin_unlock_bh (&im->lock); + +if (put) +ip_ma_put (im); }/* It must be called with locked im->lock */
@@ -253,6 +258,8 @@ static void igmp_ifc_start_timer(struct in_device *in_dev, int delay)static void igmp_mod_timer (struct ip_mc_list *im,int max_delay) { +bool put = false; +spin_lock_bh (&im->lock); im->unsolicit_count =0 ;if (timer_delete (&im->timer)) {
@@ -262,10 +269,13 @@ static void igmp_mod_timer(struct ip_mc_list *im, int max_delay)spin_unlock_bh (&im->lock);return ; } -refcount_dec (&im->refcnt); + put = true; }igmp_start_timer (im, max_delay);spin_unlock_bh (&im->lock); + +if (put) +ip_ma_put (im); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1079/1611 netfilter: nft_lookup: fix catchall element handling with inverted lookups
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tamaki Yanagawa <[email protected]>
[ Upstream commit e6107a4c74b54cb33e3bce162a63048ae5a6b198 ]
nft_lookup_eval() decides whether a lookup matched (found) from the direct set lookup and priv->invert before falling back to the catchall element used by interval sets (e.g. nft_set_rbtree) for the open-ended default range. Since found is never recomputed after ext is replaced by the catchall lookup, inverted lookups (NFT_LOOKUP_F_INV, "!= @set") can wrongly match or wrongly skip the catchall element, producing the wrong verdict. Fold the catchall lookup into ext before computing found, matching the order already used by nft_objref_map_eval().
--- net/netfilter/nft_lookup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/netfilter/nft_lookup.c +5 -5
@@ -103,13 +103,13 @@ void nft_lookup_eval(const struct nft_expr *expr,bool found; ext =nft_set_do_lookup (net, set, ®s->data[priv->sreg]); +if (!ext) + ext =nft_set_catchall_lookup (net, set); + found = !!ext ^ priv->invert;if (!found) { - ext =nft_set_catchall_lookup (net, set); -if (!ext) { - regs->verdict.code =NFT_BREAK ; -return ; - } + regs->verdict.code =NFT_BREAK ; +return ; }if (ext) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1080/1611 ipvs: pass parsed transport offset to state handlers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yizhou Zhao <[email protected]>
[ Upstream commit bae7ce7bafb59e42dc0e0e2999fdd9d1cffe3866 ]
IPVS callers already parse the packet into struct ip_vs_iphdr before updating connection state. For IPv6 this records the real transport-header offset after extension headers in iph.len.
Pass this parsed transport offset through ip_vs_set_state() and the protocol state_transition() callback so protocol handlers can use the same packet context as scheduling and NAT handling. This patch only changes the common callback plumbing and adapts the protocol callback signatures; TCP and SCTP start using the value in follow-up patches.
Stable-dep-of: 2500fa3958b1 ("ipvs: use parsed transport offset in TCP state lookup")
--- include/net/ip_vs.h | 3 ++- net/netfilter/ipvs/ip_vs_core.c | 10 +++++----- net/netfilter/ipvs/ip_vs_proto_sctp.c | 3 ++- net/netfilter/ipvs/ip_vs_proto_tcp.c | 3 ++- net/netfilter/ipvs/ip_vs_proto_udp.c | 3 ++- 5 files changed, 13 insertions(+), 9 deletions(-)
include/net/ip_vs.h +2 -1
@@ -516,7 +516,8 @@ struct ip_vs_protocol {void (*state_transition)(struct ip_vs_conn *cp,int direction,const struct sk_buff *skb, -struct ip_vs_proto_data *pd); +struct ip_vs_proto_data *pd, +unsigned int iph_len);int (*register_app)(struct netns_ipvs *ipvs,struct ip_vs_app *inc);
net/netfilter/ipvs/ip_vs_core.c +5 -5
@@ -220,10 +220,10 @@ ip_vs_conn_stats(struct ip_vs_conn *cp, struct ip_vs_service *svc)static inline void ip_vs_set_state (struct ip_vs_conn *cp,int direction,const struct sk_buff *skb, -struct ip_vs_proto_data *pd) +struct ip_vs_proto_data *pd,unsigned int iph_len) {if (likely (pd->pp->state_transition)) - pd->pp->state_transition (cp, direction, skb, pd); + pd->pp->state_transition (cp, direction, skb, pd, iph_len); } static inline int
@@ -625,7 +625,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,ip_vs_in_stats (cp, skb);/* set state */ -ip_vs_set_state (cp,IP_VS_DIR_INPUT , skb, pd); +ip_vs_set_state (cp,IP_VS_DIR_INPUT , skb, pd, iph->len);/* transmit the first SYN packet */ ret = cp->packet_xmit (skb, cp, pd->pp, iph);
@@ -1306,7 +1306,7 @@ handle_response(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd, after_nat:ip_vs_out_stats (cp, skb); -ip_vs_set_state (cp,IP_VS_DIR_OUTPUT , skb, pd); +ip_vs_set_state (cp,IP_VS_DIR_OUTPUT , skb, pd, iph->len); skb->ipvs_property =1 ;if (!(cp->flags &IP_VS_CONN_F_NFCT ))ip_vs_notrack (skb);
@@ -2055,7 +2055,7 @@ ip_vs_in_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *stateIP_VS_DBG_PKT (11 , af, pp, skb, iph.off,"Incoming packet" );ip_vs_in_stats (cp, skb); -ip_vs_set_state (cp,IP_VS_DIR_INPUT , skb, pd); +ip_vs_set_state (cp,IP_VS_DIR_INPUT , skb, pd, iph.len);if (cp->packet_xmit) ret = cp->packet_xmit (skb, cp, pp, &iph);/* do not touch skb anymore */
net/netfilter/ipvs/ip_vs_proto_sctp.c +2 -1
@@ -468,7 +468,8 @@ set_sctp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp,static void sctp_state_transition (struct ip_vs_conn *cp,int direction, -const struct sk_buff *skb,struct ip_vs_proto_data *pd) +const struct sk_buff *skb,struct ip_vs_proto_data *pd, +unsigned int iph_len) {spin_lock_bh (&cp->lock);set_sctp_state (pd, cp, direction, skb);
net/netfilter/ipvs/ip_vs_proto_tcp.c +2 -1
@@ -580,7 +580,8 @@ set_tcp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp,static void tcp_state_transition (struct ip_vs_conn *cp,int direction,const struct sk_buff *skb, -struct ip_vs_proto_data *pd) +struct ip_vs_proto_data *pd, +unsigned int iph_len) {struct tcphdr _tcph, *th;
net/netfilter/ipvs/ip_vs_proto_udp.c +2 -1
@@ -445,7 +445,8 @@ static const char * udp_state_name(int state)static void udp_state_transition (struct ip_vs_conn *cp,int direction,const struct sk_buff *skb, -struct ip_vs_proto_data *pd) +struct ip_vs_proto_data *pd, +unsigned int iph_len) {if (unlikely (!pd)) {pr_err ("UDP no ns data\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1081/1611 ipvs: use parsed transport offset in TCP state lookup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yizhou Zhao <[email protected]>
[ Upstream commit 2500fa3958b1ba51c2b065e39db1b04dfa7e23a2 ]
TCP state handling reparses the skb to find the TCP header. For IPv6 it uses sizeof(struct ipv6hdr), while the surrounding IPVS code already parsed the packet with ip_vs_fill_iph_skb() and has the real transport-header offset in iph.len.
This makes TCP state handling look at the wrong bytes when an IPv6 packet carries extension headers. Use the parsed transport offset passed down from ip_vs_set_state() when reading the TCP header.
For IPv4 and for IPv6 packets without extension headers, the passed offset matches the previous value.
--- net/netfilter/ipvs/ip_vs_proto_tcp.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
net/netfilter/ipvs/ip_vs_proto_tcp.c +1 -7
@@ -585,13 +585,7 @@ tcp_state_transition(struct ip_vs_conn *cp, int direction, {struct tcphdr _tcph, *th; -#ifdef CONFIG_IP_VS_IPV6 -int ihl = cp->af ==AF_INET ?ip_hdrlen (skb) :sizeof (struct ipv6hdr ); -#else -int ihl =ip_hdrlen (skb); -#endif - - th =skb_header_pointer (skb, ihl,sizeof (_tcph), &_tcph); + th =skb_header_pointer (skb, iph_len,sizeof (_tcph), &_tcph);if (th ==NULL )return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1082/1611 ipvs: fix PMTU for GUE/GRE tunnel ICMP errors
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yizhou Zhao <[email protected]>
[ Upstream commit 6b335af0d0d1ff44ac579d106953bf19299e5233 ]
When an ICMP Fragmentation Needed error is received for a tunneled IPVS connection, ip_vs_in_icmp() recomputes the MTU that the original packet can use by subtracting the tunnel overhead from the reported next-hop MTU.
The current code always subtracts sizeof(struct iphdr), which is only the IPIP overhead. For GUE and GRE tunnels, ipvs_udp_decap() and ipvs_gre_decap() already compute the additional tunnel header length, but that value is scoped to the decapsulation block and is lost before the ICMP_FRAG_NEEDED handling. As a result, the ICMP error sent back to the client advertises an MTU that is too large, so PMTUD can fail to converge for GUE/GRE-tunneled real servers.
With a reported next-hop MTU of 1400, a GUE tunnel currently returns 1380 to the client. The correct value is 1368:
1400 - sizeof(struct iphdr) - sizeof(struct udphdr) - sizeof(struct guehdr)
Hoist the tunnel header length into the main ip_vs_in_icmp() scope and subtract sizeof(struct iphdr) + ulen in the Fragmentation Needed path. The IPIP path keeps ulen as 0, so its existing 1400 - 20 = 1380 result is unchanged.
Stable-dep-of: 3f7a535ff0fa ("ipvs: ensure inner headers in ICMP errors are in headroom")
--- net/netfilter/ipvs/ip_vs_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/ipvs/ip_vs_core.c +3 -3
@@ -1589,6 +1589,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,bool tunnel, new_cp = false;union nf_inet_addr *raddr;char *outer_proto ="IPIP" ; +int ulen =0 ; *related =1 ;
@@ -1653,7 +1654,6 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,/* Error for our tunnel must arrive at LOCAL_IN */ (skb_rtable(skb)->rt_flags & RTCF_LOCAL)) {__u8 iproto; -int ulen;/* Non-first fragment has no UDP/GRE header */ if (unlikely (cih->frag_off &htons (IP_OFFSET )))
@@ -1758,8 +1758,8 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,if (dest_dst) mtu =dst_mtu (dest_dst->dst_cache); } -if (mtu >68 +sizeof (struct iphdr )) - mtu -=sizeof (struct iphdr ); +if (mtu >68 +sizeof (struct iphdr ) + ulen) + mtu -=sizeof (struct iphdr ) + ulen; info =htonl (mtu); }/* Strip outer IP, ICMP and IPIP/UDP/GRE, go to IP header of
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1083/1611 ipvs: ensure inner headers in ICMP errors are in headroom
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit 3f7a535ff0fa627a0132803e4c2f903ceffcbc1c ]
Sashiko points out that after stripping the outer headers with pskb_pull() we should ensure the inner IP headers in ICMP errors from tunnels are present in the skb headroom for functions like ipv4_update_pmtu(), icmp_send() and IP_VS_DBG().
Also, add more checks for the length of the inner headers.
--- net/netfilter/ipvs/ip_vs_core.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
net/netfilter/ipvs/ip_vs_core.c +15 -6
@@ -1589,6 +1589,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,bool tunnel, new_cp = false;union nf_inet_addr *raddr;char *outer_proto ="IPIP" ; +unsigned int hlen_ipip;int ulen =0 ; *related =1 ;
@@ -1626,9 +1627,10 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,/* Now find the contained IP header */ offset +=sizeof (_icmph); cih =skb_header_pointer (skb, offset,sizeof (_ciph), &_ciph); -if (cih ==NULL ) +if (!(cih && cih->version ==4 && cih->ihl >=5 ))return NF_ACCEPT ;/* The packet looks wrong, ignore */ raddr = (union nf_inet_addr *)&cih->daddr; + hlen_ipip = cih->ihl *4 ;/* Special case for errors for IPIP/UDP/GRE tunnel packets */ tunnel = false;
@@ -1644,9 +1646,9 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,/* Only for known tunnel */ if (!dest || dest->tun_type !=IP_VS_CONN_F_TUNNEL_TYPE_IPIP )return NF_ACCEPT ; - offset += cih->ihl *4 ; + offset += hlen_ipip; cih =skb_header_pointer (skb, offset,sizeof (_ciph), &_ciph); -if (cih ==NULL ) +if (!(cih && cih->version ==4 && cih->ihl >=5 ))return NF_ACCEPT ;/* The packet looks wrong, ignore */ tunnel = true; } else if ((cih->protocol == IPPROTO_UDP || /* Can be UDP encap */
@@ -1658,7 +1660,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,/* Non-first fragment has no UDP/GRE header */ if (unlikely (cih->frag_off &htons (IP_OFFSET )))return NF_ACCEPT ; - offset2 = offset + cih->ihl *4 ; + offset2 = offset + hlen_ipip;if (cih->protocol ==IPPROTO_UDP ) { ulen =ipvs_udp_decap (ipvs, skb, offset2,AF_INET , raddr, &iproto);
@@ -1727,6 +1729,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related, }if (tunnel) { +unsigned int hlen_orig = cih->ihl *4 ;__be32 info = ic->un.gateway;__u8 type = ic->type;__u8 code = ic->code;
@@ -1743,6 +1746,9 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related, goto ignore_tunnel; offset2 -= ihl +sizeof (_icmph);skb_reset_network_header (skb); +/* Ensure the IP header is present in headroom */ +if (!pskb_may_pull (skb, hlen_ipip)) + goto ignore_tunnel;IP_VS_DBG (12 ,"ICMP for %s %pI4->%pI4: mtu=%u\n" , outer_proto, &ip_hdr (skb)->saddr, &ip_hdr (skb)->daddr, mtu);
@@ -1758,8 +1764,8 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,if (dest_dst) mtu =dst_mtu (dest_dst->dst_cache); } -if (mtu >68 +sizeof (struct iphdr ) + ulen) - mtu -=sizeof (struct iphdr ) + ulen; +if (mtu >68 + hlen_ipip + ulen) + mtu -= hlen_ipip + ulen; info =htonl (mtu); }/* Strip outer IP, ICMP and IPIP/UDP/GRE, go to IP header of
@@ -1768,6 +1774,9 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,if (pskb_pull (skb, offset2) ==NULL ) goto ignore_tunnel;skb_reset_network_header (skb); +/* Ensure the IP header is present in headroom */ +if (!pskb_may_pull (skb, hlen_orig)) + goto ignore_tunnel;IP_VS_DBG (12 ,"Sending ICMP for %pI4->%pI4: t=%u, c=%u, i=%u\n" , &ip_hdr (skb)->saddr, &ip_hdr (skb)->daddr, type, code,ntohl (info));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1084/1611 s390/zcrypt: Remove the empty file
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rongguang Wei <[email protected]>
[ Upstream commit 575f87b9d4882b0d621192fdd754d7e09dbd5789 ]
The files has no real user because CEX2 and CEX3 device drivers are removed, also remove these empty files.
--- drivers/s390/crypto/zcrypt_cex2a.c | 0 drivers/s390/crypto/zcrypt_cex2a.h | 0 drivers/s390/crypto/zcrypt_cex2c.c | 0 drivers/s390/crypto/zcrypt_cex2c.h | 0 4 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 drivers/s390/crypto/zcrypt_cex2a.c delete mode 100644 drivers/s390/crypto/zcrypt_cex2a.h delete mode 100644 drivers/s390/crypto/zcrypt_cex2c.c delete mode 100644 drivers/s390/crypto/zcrypt_cex2c.h
drivers/s390/crypto/zcrypt_cex2a.c deleted +0 -0
drivers/s390/crypto/zcrypt_cex2a.h deleted +0 -0
drivers/s390/crypto/zcrypt_cex2c.c deleted +0 -0
drivers/s390/crypto/zcrypt_cex2c.h deleted +0 -0
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1085/1611 cifs: validate DFS referral string offsets
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 027a84ac6b50c12ef767c15abfc58aa865820e9e ]
parse_dfs_referrals() validates that the response header and referral array fit in the received buffer, but each referral also contains string offsets supplied by the server.
Those offsets are used to compute the DfsPath and NetworkAddress string pointers without checking whether they still point inside the response buffer. A malformed referral can therefore make the computed pointer exceed the end of the buffer. The resulting negative max_len is then passed to cifs_strndup_from_utf16(), and the non-Unicode path forwards it to kstrndup() as a size_t, allowing strnlen() to read out of bounds.
Validate each string offset before deriving the string pointer.
--- fs/smb/client/misc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/smb/client/misc.c +8 -0
@@ -1032,6 +1032,10 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size, node->ref_flag =le16_to_cpu (ref->ReferralEntryFlags);/* copy DfsPath */ +if (le16_to_cpu (ref->DfsPathOffset) > data_end - (char *)ref) { + rc = -EINVAL ; + goto parse_DFS_referrals_exit; + } temp = (char *)ref +le16_to_cpu (ref->DfsPathOffset); max_len = data_end - temp; node->path_name = cifs_strndup_from_utf16(temp, max_len,
@@ -1042,6 +1046,10 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size, }/* copy link target UNC */ +if (le16_to_cpu (ref->NetworkAddressOffset) > data_end - (char *)ref) { + rc = -EINVAL ; + goto parse_DFS_referrals_exit; + } temp = (char *)ref +le16_to_cpu (ref->NetworkAddressOffset); max_len = data_end - temp; node->node_name = cifs_strndup_from_utf16(temp, max_len,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1086/1611 SUNRPC: release lower rpc_clnt if killed waiting for XPRT_LOCKED
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 29bacb096d43bd04062f6655e50ceeed27fe6d2f ]
xs_tcp_tls_setup_socket() creates a temporary "lower" rpc_clnt with rpc_create() to drive the inner TLS handshake, then waits for XPRT_LOCKED on its xprt with TASK_KILLABLE so a stuck handshake can be aborted by signal. When the wait is interrupted, the function jumps to out_unlock without releasing lower_clnt. The success path and the out_close error path both call rpc_shutdown_client(lower_clnt); only the killed-wait path skips it, leaking the clnt and its underlying xprt.
Call rpc_shutdown_client() on this path before joining out_unlock. xprt_release_write() is not needed here because XPRT_LOCKED was never acquired.
--- net/sunrpc/xprtsock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/sunrpc/xprtsock.c +4 -1
@@ -2733,8 +2733,11 @@ static void xs_tcp_tls_setup_socket(struct work_struct *work) lower_xprt =rcu_dereference (lower_clnt->cl_xprt);rcu_read_unlock (); -if (wait_on_bit_lock (&lower_xprt->state,XPRT_LOCKED ,TASK_KILLABLE )) +if (wait_on_bit_lock (&lower_xprt->state,XPRT_LOCKED ,TASK_KILLABLE )) { +/* XPRT_LOCKED was never acquired. */ +rpc_shutdown_client (lower_clnt); goto out_unlock; + } status =xs_tls_handshake_sync (lower_xprt, &upper_xprt->xprtsec);if (status) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1087/1611 SUNRPC: pin upper rpc_clnt across the TLS connect_worker
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 46bc86c833956219bbfd246c1ffd832a479c5199 ]
The TLS connect path has a use-after-free: nothing pins the upper rpc_clnt across the delayed connect_worker. xs_connect() stores task->tk_client in sock_xprt::clnt as a raw pointer and queues the worker; for TLS-secured transports that worker is xs_tcp_tls_setup_socket(), which reads several fields out of the saved pointer (cl_timeout, cl_program, cl_prog, cl_vers, cl_cred, cl_stats) to construct the args for the inner handshake rpc_clnt.
The xprt does not reference the rpc_clnt; the rpc_clnt references the xprt. xs_destroy() does cancel the connect_worker, but it runs only when the xprt's refcount drops to zero, which cannot happen until the rpc_clnt releases its cl_xprt reference in rpc_free_client_work(). When a TLS handshake fails fatally (for example, an mTLS mount whose client cert does not match the server), the connecting task is woken with -EACCES and exits, the mount caller invokes rpc_shutdown_client(), and the upper rpc_clnt is freed before the queued connect_worker fires. xs_tcp_tls_setup_socket() then dereferences the freed clnt, producing the refcount_t underflow Michael Nemanov reported.
Take a reference on the upper rpc_clnt in xs_connect() for TLS transports via a new rpc_hold_client() helper, and drop it in the connect_worker's exit path with rpc_release_client(). The xprt_lock_connect() / xprt_unlock_connect() pairing already serialises xs_connect() with xs_tcp_tls_setup_socket(), so the take and release are balanced one-for-one.
The non-TLS connect worker (xs_tcp_setup_socket) never reads sock_xprt::clnt, so leave that path alone and avoid the clnt-holds-xprt-holds-clnt cycle that would otherwise prevent xprt destruction.
--- include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 19 +++++++++++++++++-- net/sunrpc/xprtsock.c | 11 ++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-)
include/linux/sunrpc/clnt.h +1 -0
@@ -190,6 +190,7 @@ int rpc_switch_client_transport(struct rpc_clnt *, const struct rpc_timeout *); void rpc_shutdown_client(struct rpc_clnt *); +void rpc_hold_client (struct rpc_clnt *);void rpc_release_client (struct rpc_clnt *);void rpc_task_release_transport (struct rpc_task *);void rpc_task_release_client (struct rpc_task *);
net/sunrpc/clnt.c +17 -2
@@ -1026,8 +1026,23 @@ rpc_free_auth(struct rpc_clnt *clnt)return NULL ; } -/* -* Release reference to the RPC client +/** +* rpc_hold_client - acquire a reference on an rpc_clnt +* @clnt: rpc_clnt to pin +* +* Pairs with rpc_release_client(). +*/ +void rpc_hold_client (struct rpc_clnt *clnt) +{ +refcount_inc (&clnt->cl_count); +} + +/** +* rpc_release_client - release a reference on an rpc_clnt +* @clnt: rpc_clnt to release +* +* Pairs with rpc_hold_client(). The rpc_clnt's resources are +* freed once its reference count drops to zero. */ void rpc_release_client (struct rpc_clnt *clnt)
net/sunrpc/xprtsock.c +10 -1
@@ -2760,6 +2760,7 @@ static void xs_tcp_tls_setup_socket(struct work_struct *work) out_unlock:current_restore_flags (pflags,PF_MEMALLOC ); upper_transport->clnt =NULL ; +rpc_release_client (upper_clnt);xprt_unlock_connect (upper_xprt, upper_transport);return ;
@@ -2807,7 +2808,15 @@ static void xs_connect(struct rpc_xprt *xprt, struct rpc_task *task) }else dprintk ("RPC: xs_connect scheduled xprt %p\n" , xprt); - transport->clnt = task->tk_client; +/* +* Only the TLS connect_worker reads transport->clnt; pinning +* the upper rpc_clnt unconditionally would form a cycle with +* cl_xprt and prevent xprt destruction. +*/ +if (xprt->xprtsec.policy !=RPC_XPRTSEC_NONE ) { +rpc_hold_client (task->tk_client); + transport->clnt = task->tk_client; + }queue_delayed_work (xprtiod_workqueue, &transport->connect_worker, delay);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1088/1611 dm era: fix NULL pointer dereference in metadata_open()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cao Guanghui <[email protected]>
[ Upstream commit 9ae672606c17891d90b282e3490b817620549599 ]
metadata_open() returns NULL when kzalloc_obj() fails, but the caller era_ctr() only checks IS_ERR(md). Since IS_ERR(NULL) returns false, the NULL pointer is treated as a valid result and later assigned to era->md, leading to a NULL pointer dereference when the metadata is accessed.
Fix this by returning ERR_PTR(-ENOMEM) on allocation failure, consistent with dm-cache-metadata.c, dm-thin-metadata.c, and dm-clone-metadata.c which all use ERR_PTR(-ENOMEM) for the same pattern.
--- drivers/md/dm-era-target.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/md/dm-era-target.c +4 -2
@@ -810,8 +810,10 @@ static struct era_metadata *metadata_open(struct block_device *bdev,int r;struct era_metadata *md =kzalloc (sizeof (*md),GFP_KERNEL ); -if (!md) -return NULL ; +if (!md) { +DMERR ("could not allocate metadata struct" ); +return ERR_PTR (-ENOMEM ); + } md->bdev = bdev; md->block_size = block_size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1089/1611 regulator: core: regulator_lock_two() should test for EDEADLK not EDEADLOCK
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Tabi <[email protected]>
[ Upstream commit d38f8bd771c4999b797d7074b348cf201414bd34 ]
Compare against -EDEADLK, which is what ww_mutex_lock() actually returns and what every other deadlock check in this file already uses.
Function regulator_lock_two() acquires two regulators via regulator_lock_nested() -> ww_mutex_lock(). On contention, ww_mutex_lock() returns -EDEADLK, which is the caller's signal to drop the lock it holds and retry the acquisition in the canonical order.
However, regulator_lock_two() tests the return value against -EDEADLOCK rather than -EDEADLK. On most architectures, EDEADLK and EDEADLOCK are the same value, so the comparison happens to be correct and the bug is invisible. But on MIPS, SPARC, and PowerPC, those two errors have different values. The test is wrong: a genuine -EDEADLK backoff no longer matches -EDEADLOCK, so instead of unlocking and retrying, the code falls into WARN_ON(ret) and returns with only one of the two regulators locked.
In practice, this is a bug only on MIPS, because the regulator core is not built or used on the other two platforms.
In general, EDEADLK is preferred over EDEADLOCK for new code.
--- drivers/regulator/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/core.c +2 -2
@@ -232,7 +232,7 @@ static void regulator_lock_two(struct regulator_dev *rdev1, ret =regulator_lock_nested (rdev1, ww_ctx);WARN_ON (ret); ret =regulator_lock_nested (rdev2, ww_ctx); -if (ret != -EDEADLOCK ) { +if (ret != -EDEADLK ) {WARN_ON (ret); goto exit; }
@@ -248,7 +248,7 @@ static void regulator_lock_two(struct regulator_dev *rdev1,swap (held, contended); ret =regulator_lock_nested (contended, ww_ctx); -if (ret != -EDEADLOCK ) { +if (ret != -EDEADLK ) {WARN_ON (ret);break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1090/1611 selftests/net: fix EVP_MD_CTX leak in tcp_mmap
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Yan <[email protected]>
[ Upstream commit f4ef35efbb49527293309f668ea73ec5de9b8e7a ]
In tcp_mmap.c, both child_thread() and main() allocate an EVP_MD_CTX via EVP_MD_CTX_new() when integrity checking is enabled, but neither function releases the context. child_thread() misses the free in its common cleanup block, and main() returns without freeing the context.
This results in a SHA256 context leak on every run that uses the ‑i (integrity) option. Add the missing EVP_MD_CTX_free() calls to the appropriate cleanup paths to fix the leak.
--- tools/testing/selftests/net/tcp_mmap.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/net/tcp_mmap.c +4 -0
@@ -313,6 +313,8 @@ void *child_thread(void *arg) tcp_info_get_rcv_mss(fd)); } error: +if (ctx) +EVP_MD_CTX_free (ctx);munmap (buffer, buffer_sz);close (fd);if (zflg)
@@ -606,6 +608,8 @@ int main(int argc, char *argv[])EVP_DigestFinal_ex (ctx, digest, &digest_len);send (fd, digest, (size_t )SHA256_DIGEST_LENGTH ,0 ); } +if (ctx) +EVP_MD_CTX_free (ctx);close (fd);munmap (buffer, buffer_sz);return 0 ;
Signature · 1 line
2.53.0