6.6.8-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 1/166 r8152: add vendor/device ID pair for ASUS USB-C2500
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kelly Kane <[email protected]>
[ Upstream commit 7037d95a047cd89b1f680eed253c6ab586bef1ed ]
The ASUS USB-C2500 is an RTL8156 based 2.5G Ethernet controller.
Add the vendor and product ID values to the driver. This makes Ethernet work with the adapter.
--- drivers/net/usb/r8152.c | 1 + include/linux/usb/r8152.h | 1 + 2 files changed, 2 insertions(+)
drivers/net/usb/r8152.c +1 -0
@@ -10016,6 +10016,7 @@ static const struct usb_device_id rtl8152_table[] = { { USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff) }, { USB_DEVICE(VENDOR_ID_TPLINK, 0x0601) }, { USB_DEVICE(VENDOR_ID_DLINK, 0xb301) }, + { USB_DEVICE(VENDOR_ID_ASUS, 0x1976) }, {} };
include/linux/usb/r8152.h +1 -0
@@ -30,6 +30,7 @@#define VENDOR_ID_NVIDIA 0x0955#define VENDOR_ID_TPLINK 0x2357#define VENDOR_ID_DLINK 0x2001 +#define VENDOR_ID_ASUS 0x0b05#if IS_REACHABLE (CONFIG_USB_RTL8152 )extern u8 rtl8152_get_version (struct usb_interface *intf);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 10/166 net/mlx5e: Tidy up IPsec NAT-T SA discovery
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit c2bf84f1d1a1595dcc45fe867f0e02b331993fee ]
IPsec NAT-T packets are UDP encapsulated packets over ESP normal ones. In case they arrive to RX, the SPI and ESP are located in inner header, while the check was performed on outer header instead.
That wrong check caused to the situation where received rekeying request was missed and caused to rekey timeout, which "compensated" this failure by completing rekeying.
--- .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 22 ++++++++++++++----- include/linux/mlx5/mlx5_ifc.h | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c +16 -6
@@ -974,13 +974,22 @@ static void setup_fte_esp(struct mlx5_flow_spec *spec)MLX5_SET (fte_match_param, spec->match_value, outer_headers.ip_protocol,IPPROTO_ESP ); } -static void setup_fte_spi (struct mlx5_flow_spec *spec,u32 spi) +static void setup_fte_spi (struct mlx5_flow_spec *spec,u32 spi,bool encap) {/* SPI number */ spec->match_criteria_enable |=MLX5_MATCH_MISC_PARAMETERS ; -MLX5_SET_TO_ONES (fte_match_param, spec->match_criteria, misc_parameters.outer_esp_spi); -MLX5_SET (fte_match_param, spec->match_value, misc_parameters.outer_esp_spi, spi); +if (encap) { +MLX5_SET_TO_ONES (fte_match_param, spec->match_criteria, + misc_parameters.inner_esp_spi); +MLX5_SET (fte_match_param, spec->match_value, + misc_parameters.inner_esp_spi, spi); + }else { +MLX5_SET_TO_ONES (fte_match_param, spec->match_criteria, + misc_parameters.outer_esp_spi); +MLX5_SET (fte_match_param, spec->match_value, + misc_parameters.outer_esp_spi, spi); + } }static void setup_fte_no_frags (struct mlx5_flow_spec *spec)
@@ -1339,8 +1348,9 @@ static int rx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)else setup_fte_addr6 (spec, attrs->saddr.a6, attrs->daddr.a6); -setup_fte_spi (spec, attrs->spi); -setup_fte_esp (spec); +setup_fte_spi (spec, attrs->spi, attrs->encap); +if (!attrs->encap) +setup_fte_esp (spec);setup_fte_no_frags (spec);setup_fte_upper_proto_match (spec, &attrs->upspec);
@@ -1443,7 +1453,7 @@ static int tx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)switch (attrs->type) {case XFRM_DEV_OFFLOAD_CRYPTO : -setup_fte_spi (spec, attrs->spi); +setup_fte_spi (spec, attrs->spi, false);setup_fte_esp (spec);setup_fte_reg_a (spec);break ;
include/linux/mlx5/mlx5_ifc.h +1 -1
@@ -620,7 +620,7 @@ struct mlx5_ifc_fte_match_set_misc_bits {u8 reserved_at_140[0x8 ];u8 bth_dst_qp[0x18 ]; -u8 reserved_at_160[0x20 ]; +u8 inner_esp_spi[0x20 ];u8 outer_esp_spi[0x20 ];u8 reserved_at_1a0[0x60 ]; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 11/166 net/mlx5e: Reduce eswitch mode_lock protection context
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jianbo Liu <[email protected]>
[ Upstream commit baac8351f74c543896b8fd40138b7ad9365587a3 ]
Currently eswitch mode_lock is so heavy, for example, it's locked during the whole process of the mode change, which may need to hold other locks. As the mode_lock is also used by IPSec to block mode and encap change now, it is easy to cause lock dependency.
Since some of protections are also done by devlink lock, the eswitch mode_lock is not needed at those places, and thus the possibility of lockdep issue is reduced.
--- .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 9 +++-- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 35 ++++++++++------- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 2 + .../mellanox/mlx5/core/eswitch_offloads.c | 38 +++++++++++-------- 4 files changed, 52 insertions(+), 32 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c +6 -3
@@ -1834,8 +1834,11 @@ static int mlx5e_ipsec_block_tc_offload(struct mlx5_core_dev *mdev)struct mlx5_eswitch *esw = mdev->priv.eswitch;int err =0 ; -if (esw) -down_write (&esw->mode_lock); +if (esw) { + err =mlx5_esw_lock (esw); +if (err) +return err; + }if (mdev->num_block_ipsec) { err = -EBUSY ;
@@ -1846,7 +1849,7 @@ static int mlx5e_ipsec_block_tc_offload(struct mlx5_core_dev *mdev) unlock:if (esw) -up_write (&esw->mode_lock); +mlx5_esw_unlock (esw);return err; }
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +22 -13
@@ -1463,7 +1463,7 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int num_vfs) {int err; -lockdep_assert_held (&esw->mode_lock); +devl_assert_locked (priv_to_devlink (esw->dev));if (!MLX5_CAP_ESW_FLOWTABLE_FDB (esw->dev, ft_support)) {esw_warn (esw->dev,"FDB is not supported, aborting ...\n" );
@@ -1531,7 +1531,6 @@ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs)if (toggle_lag)mlx5_lag_disable_change (esw->dev); -down_write (&esw->mode_lock);if (!mlx5_esw_is_fdb_created (esw)) { ret =mlx5_eswitch_enable_locked (esw, num_vfs); }else {
@@ -1554,8 +1553,6 @@ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs) } } -up_write (&esw->mode_lock); -if (toggle_lag)mlx5_lag_enable_change (esw->dev);
@@ -1569,12 +1566,11 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw, bool clear_vf)return ;devl_assert_locked (priv_to_devlink (esw->dev)); -down_write (&esw->mode_lock);/* If driver is unloaded, this function is called twice by remove_one() * and mlx5_unload(). Prevent the second call. */ if (!esw->esw_funcs.num_vfs && !esw->esw_funcs.num_ec_vfs && !clear_vf) - goto unlock; +return ; esw_info(esw->dev, "Unload vfs: mode(%s), nvfs(%d), necvfs(%d), active vports(%d)\n", esw->mode == MLX5_ESWITCH_LEGACY ? "LEGACY" : "OFFLOADS",
@@ -1603,9 +1599,6 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw, bool clear_vf) esw->esw_funcs.num_vfs =0 ; else esw->esw_funcs.num_ec_vfs = 0; - -unlock: -up_write (&esw->mode_lock); }/* Free resources for corresponding eswitch mode. It is called by devlink
@@ -1647,10 +1640,8 @@ void mlx5_eswitch_disable(struct mlx5_eswitch *esw)devl_assert_locked (priv_to_devlink (esw->dev));mlx5_lag_disable_change (esw->dev); -down_write (&esw->mode_lock);mlx5_eswitch_disable_locked (esw); esw->mode =MLX5_ESWITCH_LEGACY ; -up_write (&esw->mode_lock);mlx5_lag_enable_change (esw->dev); }
@@ -2254,8 +2245,13 @@ bool mlx5_esw_hold(struct mlx5_core_dev *mdev)if (!mlx5_esw_allowed (esw))return true; -if (down_read_trylock (&esw->mode_lock) !=0 ) +if (down_read_trylock (&esw->mode_lock) !=0 ) { +if (esw->eswitch_operation_in_progress) { +up_read (&esw->mode_lock); +return false; + }return true; + }return false; }
@@ -2312,7 +2308,8 @@ int mlx5_esw_try_lock(struct mlx5_eswitch *esw)if (down_write_trylock (&esw->mode_lock) ==0 )return -EINVAL ; -if (atomic64_read (&esw->user_count) >0 ) { +if (esw->eswitch_operation_in_progress || +atomic64_read (&esw->user_count) >0 ) {up_write (&esw->mode_lock);return -EBUSY ; }
@@ -2320,6 +2317,18 @@ int mlx5_esw_try_lock(struct mlx5_eswitch *esw)return esw->mode; } +int mlx5_esw_lock (struct mlx5_eswitch *esw) +{ +down_write (&esw->mode_lock); + +if (esw->eswitch_operation_in_progress) { +up_write (&esw->mode_lock); +return -EBUSY ; + } + +return 0 ; +} +/** * mlx5_esw_unlock() - Release write lock on esw mode lock * @esw: eswitch device.
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -0
@@ -383,6 +383,7 @@ struct mlx5_eswitch {struct xarray paired;struct mlx5_devcom_comp_dev *devcom;u16 enabled_ipsec_vf_count; +bool eswitch_operation_in_progress; };void esw_offloads_disable (struct mlx5_eswitch *esw);
@@ -827,6 +828,7 @@ void mlx5_esw_release(struct mlx5_core_dev *dev);void mlx5_esw_get (struct mlx5_core_dev *dev);void mlx5_esw_put (struct mlx5_core_dev *dev);int mlx5_esw_try_lock (struct mlx5_eswitch *esw); +int mlx5_esw_lock (struct mlx5_eswitch *esw);void mlx5_esw_unlock (struct mlx5_eswitch *esw);void esw_vport_change_handle_locked (struct mlx5_vport *vport);
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +22 -16
@@ -3733,13 +3733,16 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode, goto unlock; } + esw->eswitch_operation_in_progress = true; +up_write (&esw->mode_lock); +mlx5_eswitch_disable_locked (esw);if (mode ==DEVLINK_ESWITCH_MODE_SWITCHDEV ) {if (mlx5_devlink_trap_get_num_active (esw->dev)) {NL_SET_ERR_MSG_MOD (extack,"Can't change mode while devlink traps are active" ); err = -EOPNOTSUPP ; - goto unlock; + goto skip; } err =esw_offloads_start (esw, extack); }else if (mode ==DEVLINK_ESWITCH_MODE_LEGACY ) {
@@ -3749,6 +3752,9 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode, err = -EINVAL ; } +skip: +down_write (&esw->mode_lock); + esw->eswitch_operation_in_progress = false; unlock:mlx5_esw_unlock (esw); enable_lag:
@@ -3759,16 +3765,12 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,int mlx5_devlink_eswitch_mode_get (struct devlink *devlink,u16 *mode) {struct mlx5_eswitch *esw; -int err; esw =mlx5_devlink_eswitch_get (devlink);if (IS_ERR (esw))return PTR_ERR (esw); -down_read (&esw->mode_lock); - err =esw_mode_to_devlink (esw->mode, mode); -up_read (&esw->mode_lock); -return err; +return esw_mode_to_devlink (esw->mode, mode); } static int mlx5_esw_vports_inline_set(struct mlx5_eswitch *esw, u8 mlx5_mode,
@@ -3862,11 +3864,15 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode,if (err) goto out; + esw->eswitch_operation_in_progress = true; +up_write (&esw->mode_lock); + err =mlx5_esw_vports_inline_set (esw, mlx5_mode, extack); -if (err) - goto out; +if (!err) + esw->offloads.inline_mode = mlx5_mode; - esw->offloads.inline_mode = mlx5_mode; +down_write (&esw->mode_lock); + esw->eswitch_operation_in_progress = false;up_write (&esw->mode_lock);return 0 ;
@@ -3878,16 +3884,12 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode,int mlx5_devlink_eswitch_inline_mode_get (struct devlink *devlink,u8 *mode) {struct mlx5_eswitch *esw; -int err; esw =mlx5_devlink_eswitch_get (devlink);if (IS_ERR (esw))return PTR_ERR (esw); -down_read (&esw->mode_lock); - err =esw_inline_mode_to_devlink (esw->offloads.inline_mode, mode); -up_read (&esw->mode_lock); -return err; +return esw_inline_mode_to_devlink (esw->offloads.inline_mode, mode); }bool mlx5_eswitch_block_encap (struct mlx5_core_dev *dev)
@@ -3969,6 +3971,9 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, goto unlock; } + esw->eswitch_operation_in_progress = true; +up_write (&esw->mode_lock); +esw_destroy_offloads_fdb_tables (esw); esw->offloads.encap = encap;
@@ -3982,6 +3987,9 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, (void )esw_create_offloads_fdb_tables (esw); } +down_write (&esw->mode_lock); + esw->eswitch_operation_in_progress = false; + unlock:up_write (&esw->mode_lock);return err;
@@ -3996,9 +4004,7 @@ int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,if (IS_ERR (esw))return PTR_ERR (esw); -down_read (&esw->mode_lock); *encap = esw->offloads.encap; -up_read (&esw->mode_lock);return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 12/166 net/mlx5e: Check the number of elements before walk TC rhashtable
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jianbo Liu <[email protected]>
[ Upstream commit 4e25b661f484df54b6751b65f9ea2434a3b67539 ]
After IPSec TX tables are destroyed, the flow rules in TC rhashtable, which have the destination to IPSec, are restored to the original one, the uplink.
However, when the device is in switchdev mode and unload driver with IPSec rules configured, TC rhashtable cleanup is done before IPSec cleanup, which means tc_ht->tbl is already freed when walking TC rhashtable, in order to restore the destination. So add the checking before walking to avoid unexpected behavior.
--- drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c +1 -1
@@ -152,7 +152,7 @@ void mlx5_esw_ipsec_restore_dest_uplink(struct mlx5_core_dev *mdev)xa_for_each (&esw->offloads.vport_reps, i, rep) { rpriv = rep->rep_data[REP_ETH ].priv; -if (!rpriv || !rpriv->netdev) +if (!rpriv || !rpriv->netdev || !atomic_read (&rpriv->tc_ht.nelems))continue ;rhashtable_walk_enter (&rpriv->tc_ht, &iter);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 13/166 RDMA/mlx5: Send events from IB driver about device affiliation state
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 0d293714ac32650bfb669ceadf7cc2fad8161401 ]
Send blocking events from IB driver whenever the device is done being affiliated or if it is removed from an affiliation.
This is useful since now the EN driver can register to those event and know when a device is affiliated or not.
Stable-dep-of: 762a55a54eec ("net/mlx5e: Disable IPsec offload support if not FW steering")
--- drivers/infiniband/hw/mlx5/main.c | 17 +++++++++++++++++ drivers/net/ethernet/mellanox/mlx5/core/main.c | 6 ++++++ include/linux/mlx5/device.h | 2 ++ include/linux/mlx5/driver.h | 2 ++ 4 files changed, 27 insertions(+)
drivers/infiniband/hw/mlx5/main.c +17 -0
@@ -24,6 +24,7 @@#include <linux/mlx5/vport.h> #include <linux/mlx5/fs.h> #include <linux/mlx5/eswitch.h> +#include <linux/mlx5/driver.h> #include <linux/list.h> #include <rdma/ib_smi.h> #include <rdma/ib_umem_odp.h>
@@ -3175,6 +3176,13 @@ static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev,lockdep_assert_held (&mlx5_ib_multiport_mutex); +mlx5_core_mp_event_replay (ibdev->mdev, +MLX5_DRIVER_EVENT_AFFILIATION_REMOVED , +NULL ); +mlx5_core_mp_event_replay (mpi->mdev, +MLX5_DRIVER_EVENT_AFFILIATION_REMOVED , +NULL ); +mlx5_ib_cleanup_cong_debugfs (ibdev, port_num);spin_lock (&port->mp.mpi_lock);
@@ -3226,6 +3234,7 @@ static bool mlx5_ib_bind_slave_port(struct mlx5_ib_dev *ibdev, struct mlx5_ib_multiport_info *mpi) {u32 port_num =mlx5_core_native_port_num (mpi->mdev) -1 ; +u64 key;int err;lockdep_assert_held (&mlx5_ib_multiport_mutex);
@@ -3254,6 +3263,14 @@ static bool mlx5_ib_bind_slave_port(struct mlx5_ib_dev *ibdev,mlx5_ib_init_cong_debugfs (ibdev, port_num); + key = ibdev->ib_dev.index; +mlx5_core_mp_event_replay (mpi->mdev, +MLX5_DRIVER_EVENT_AFFILIATION_DONE , + &key); +mlx5_core_mp_event_replay (ibdev->mdev, +MLX5_DRIVER_EVENT_AFFILIATION_DONE , + &key); +return true; unbind:
drivers/net/ethernet/mellanox/mlx5/core/main.c +6 -0
@@ -361,6 +361,12 @@ void mlx5_core_uplink_netdev_event_replay(struct mlx5_core_dev *dev) }EXPORT_SYMBOL (mlx5_core_uplink_netdev_event_replay); +void mlx5_core_mp_event_replay (struct mlx5_core_dev *dev,u32 event,void *data) +{ +mlx5_blocking_notifier_call_chain (dev, event, data); +} +EXPORT_SYMBOL (mlx5_core_mp_event_replay); +int mlx5_core_get_caps_mode (struct mlx5_core_dev *dev,enum mlx5_cap_type cap_type,enum mlx5_cap_mode cap_mode) {
include/linux/mlx5/device.h +2 -0
@@ -366,6 +366,8 @@ enum mlx5_driver_event {MLX5_DRIVER_EVENT_UPLINK_NETDEV ,MLX5_DRIVER_EVENT_MACSEC_SA_ADDED ,MLX5_DRIVER_EVENT_MACSEC_SA_DELETED , +MLX5_DRIVER_EVENT_AFFILIATION_DONE , + MLX5_DRIVER_EVENT_AFFILIATION_REMOVED, }; enum {
include/linux/mlx5/driver.h +2 -0
@@ -1027,6 +1027,8 @@ bool mlx5_cmd_is_down(struct mlx5_core_dev *dev);void mlx5_core_uplink_netdev_set (struct mlx5_core_dev *mdev,struct net_device *netdev);void mlx5_core_uplink_netdev_event_replay (struct mlx5_core_dev *mdev); +void mlx5_core_mp_event_replay (struct mlx5_core_dev *dev,u32 event,void *data); +void mlx5_health_cleanup (struct mlx5_core_dev *dev);int mlx5_health_init (struct mlx5_core_dev *dev);void mlx5_start_health_poll (struct mlx5_core_dev *dev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 14/166 net/mlx5e: Disable IPsec offload support if not FW steering
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mi <[email protected]>
[ Upstream commit 762a55a54eec4217e4cec9265ab6e5d4c11b61bd ]
IPsec FDB offload can only work with FW steering as of now, disable the cap upon non FW steering.
And since the IPSec cap is dynamic now based on steering mode. Cleanup the resources if they exist instead of checking the IPsec cap again.
--- .../mellanox/mlx5/core/en_accel/ipsec.c | 26 ++++++++----------- .../mlx5/core/en_accel/ipsec_offload.c | 8 +++++- 2 files changed, 18 insertions(+), 16 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +11 -15
@@ -929,9 +929,11 @@ void mlx5e_ipsec_cleanup(struct mlx5e_priv *priv)return ;mlx5e_accel_ipsec_fs_cleanup (ipsec); -if (mlx5_ipsec_device_caps (priv->mdev) &MLX5_IPSEC_CAP_TUNNEL ) +if (ipsec->netevent_nb.notifier_call) {unregister_netevent_notifier (&ipsec->netevent_nb); -if (mlx5_ipsec_device_caps (priv->mdev) &MLX5_IPSEC_CAP_PACKET_OFFLOAD ) + ipsec->netevent_nb.notifier_call =NULL ; + } +if (ipsec->aso)mlx5e_ipsec_aso_cleanup (ipsec);destroy_workqueue (ipsec->wq);kfree (ipsec);
@@ -1040,6 +1042,12 @@ static int mlx5e_xfrm_validate_policy(struct mlx5_core_dev *mdev, } } +if (x->xdo.type ==XFRM_DEV_OFFLOAD_PACKET && + !(mlx5_ipsec_device_caps (mdev) &MLX5_IPSEC_CAP_PACKET_OFFLOAD )) { +NL_SET_ERR_MSG_MOD (extack,"Packet offload is not supported" ); +return -EINVAL ; + } +return 0 ; }
@@ -1135,14 +1143,6 @@ static const struct xfrmdev_ops mlx5e_ipsec_xfrmdev_ops = { .xdo_dev_state_free = mlx5e_xfrm_free_state, .xdo_dev_offload_ok = mlx5e_ipsec_offload_ok, .xdo_dev_state_advance_esn = mlx5e_xfrm_advance_esn_state, -}; - -static const struct xfrmdev_ops mlx5e_ipsec_packet_xfrmdev_ops = { - .xdo_dev_state_add = mlx5e_xfrm_add_state, - .xdo_dev_state_delete = mlx5e_xfrm_del_state, - .xdo_dev_state_free = mlx5e_xfrm_free_state, - .xdo_dev_offload_ok = mlx5e_ipsec_offload_ok, - .xdo_dev_state_advance_esn = mlx5e_xfrm_advance_esn_state, .xdo_dev_state_update_curlft = mlx5e_xfrm_update_curlft, .xdo_dev_policy_add = mlx5e_xfrm_add_policy,
@@ -1160,11 +1160,7 @@ void mlx5e_ipsec_build_netdev(struct mlx5e_priv *priv)mlx5_core_info (mdev,"mlx5e: IPSec ESP acceleration enabled\n" ); -if (mlx5_ipsec_device_caps (mdev) &MLX5_IPSEC_CAP_PACKET_OFFLOAD ) - netdev->xfrmdev_ops = &mlx5e_ipsec_packet_xfrmdev_ops; -else - netdev->xfrmdev_ops = &mlx5e_ipsec_xfrmdev_ops; - + netdev->xfrmdev_ops = &mlx5e_ipsec_xfrmdev_ops; netdev->features |=NETIF_F_HW_ESP ; netdev->hw_enc_features |=NETIF_F_HW_ESP ;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c +7 -1
@@ -5,6 +5,8 @@#include "en.h" #include "ipsec.h" #include "lib/crypto.h" +#include "fs_core.h" +#include "eswitch.h" enum {MLX5_IPSEC_ASO_REMOVE_FLOW_PKT_CNT_OFFSET ,
@@ -37,7 +39,10 @@ u32 mlx5_ipsec_device_caps(struct mlx5_core_dev *mdev) MLX5_CAP_ETH(mdev, insert_trailer) && MLX5_CAP_ETH(mdev, swp)) caps |=MLX5_IPSEC_CAP_CRYPTO ; - if (MLX5_CAP_IPSEC(mdev, ipsec_full_offload)) { + if (MLX5_CAP_IPSEC(mdev, ipsec_full_offload) && + (mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_DMFS || + (mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_SMFS && + is_mdev_legacy_mode(mdev)))) { if (MLX5_CAP_FLOWTABLE_NIC_TX(mdev, reformat_add_esp_trasport) && MLX5_CAP_FLOWTABLE_NIC_RX(mdev,
@@ -558,6 +563,7 @@ void mlx5e_ipsec_aso_cleanup(struct mlx5e_ipsec *ipsec)dma_unmap_single (pdev, aso->dma_addr,sizeof (aso->ctx),DMA_BIDIRECTIONAL );kfree (aso); + ipsec->aso =NULL ; } static void mlx5e_ipsec_aso_copy(struct mlx5_wqe_aso_ctrl_seg *ctrl,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 15/166 net/mlx5e: Fix possible deadlock on mlx5e_tx_timeout_work
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Moshe Shemesh <[email protected]>
[ Upstream commit eab0da38912ebdad922ed0388209f7eb0a5163cd ]
Due to the cited patch, devlink health commands take devlink lock and this may result in deadlock for mlx5e_tx_reporter as it takes local state_lock before calling devlink health report and on the other hand devlink health commands such as diagnose for same reporter take local state_lock after taking devlink lock (see kernel log below).
To fix it, remove local state_lock from mlx5e_tx_timeout_work() before calling devlink_health_report() and take care to cancel the work before any call to close channels, which may free the SQs that should be handled by the work. Before cancel_work_sync(), use current_work() to check we are not calling it from within the work, as mlx5e_tx_timeout_work() itself may close the channels and reopen as part of recovery flow.
While removing state_lock from mlx5e_tx_timeout_work() keep rtnl_lock to ensure no change in netdev->real_num_tx_queues, but use rtnl_trylock() and a flag to avoid deadlock by calling cancel_work_sync() before closing the channels while holding rtnl_lock too.
Kernel log:
======================================================
WARNING: possible circular locking dependency detected 6.0.0-rc3_for_upstream_debug_2022_08_30_13_10 #1 Not tainted
------------------------------------------------------
kworker/u16:2/65 is trying to acquire lock:ffff888122f6c2f8 (&devlink->lock_key#2){+.+.}-{3:3}, at: devlink_health_report+0x2f1/0x7e0
but task is already holding lock:ffff888121d20be0 (&priv->state_lock){+.+.}-{3:3}, at: mlx5e_tx_timeout_work+0x70/0x280 [mlx5_core]
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (&priv->state_lock){+.+.}-{3:3}:
__mutex_lock+0x12c/0x14b0
mlx5e_rx_reporter_diagnose+0x71/0x700 [mlx5_core]
devlink_nl_cmd_health_reporter_diagnose_doit+0x212/0xa50
genl_family_rcv_msg_doit+0x1e9/0x2f0
genl_rcv_msg+0x2e9/0x530
netlink_rcv_skb+0x11d/0x340
genl_rcv+0x24/0x40
netlink_unicast+0x438/0x710
netlink_sendmsg+0x788/0xc40
sock_sendmsg+0xb0/0xe0
__sys_sendto+0x1c1/0x290
__x64_sys_sendto+0xdd/0x1b0
do_syscall_64+0x3d/0x90
entry_SYSCALL_64_after_hwframe+0x46/0xb0-> #0 (&devlink->lock_key#2){+.+.}-{3:3}:
__lock_acquire+0x2c8a/0x6200
lock_acquire+0x1c1/0x550
__mutex_lock+0x12c/0x14b0
devlink_health_report+0x2f1/0x7e0
mlx5e_health_report+0xc9/0xd7 [mlx5_core]
mlx5e_reporter_tx_timeout+0x2ab/0x3d0 [mlx5_core]
mlx5e_tx_timeout_work+0x1c1/0x280 [mlx5_core]
process_one_work+0x7c2/0x1340
worker_thread+0x59d/0xec0
kthread+0x28f/0x330
ret_from_fork+0x1f/0x30other info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&priv->state_lock);
lock(&devlink->lock_key#2);
lock(&priv->state_lock); lock(&devlink->lock_key#2);
*** DEADLOCK ***
4 locks held by kworker/u16:2/65:
#0: ffff88811a55b138 ((wq_completion)mlx5e#2){+.+.}-{0:0}, at: process_one_work+0x6e2/0x1340 #1: ffff888101de7db8 ((work_completion)(&priv->tx_timeout_work)){+.+.}-{0:0}, at: process_one_work+0x70f/0x1340 #2: ffffffff84ce8328 (rtnl_mutex){+.+.}-{3:3}, at: mlx5e_tx_timeout_work+0x53/0x280 [mlx5_core] #3: ffff888121d20be0 (&priv->state_lock){+.+.}-{3:3}, at: mlx5e_tx_timeout_work+0x70/0x280 [mlx5_core]
stack backtrace: CPU: 1 PID: 65 Comm: kworker/u16:2 Not tainted 6.0.0-rc3_for_upstream_debug_2022_08_30_13_10 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 Workqueue: mlx5e mlx5e_tx_timeout_work [mlx5_core] Call Trace: <TASK> dump_stack_lvl+0x57/0x7d check_noncircular+0x278/0x300 ? print_circular_bug+0x460/0x460 ? find_held_lock+0x2d/0x110 ? __stack_depot_save+0x24c/0x520 ? alloc_chain_hlocks+0x228/0x700 __lock_acquire+0x2c8a/0x6200 ? register_lock_class+0x1860/0x1860 ? kasan_save_stack+0x1e/0x40 ? kasan_set_free_info+0x20/0x30 ? ____kasan_slab_free+0x11d/0x1b0 ? kfree+0x1ba/0x520 ? devlink_health_do_dump.part.0+0x171/0x3a0 ? devlink_health_report+0x3d5/0x7e0 lock_acquire+0x1c1/0x550 ? devlink_health_report+0x2f1/0x7e0 ? lockdep_hardirqs_on_prepare+0x400/0x400 ? find_held_lock+0x2d/0x110 __mutex_lock+0x12c/0x14b0 ? devlink_health_report+0x2f1/0x7e0 ? devlink_health_report+0x2f1/0x7e0 ? mutex_lock_io_nested+0x1320/0x1320 ? trace_hardirqs_on+0x2d/0x100 ? bit_wait_io_timeout+0x170/0x170 ? devlink_health_do_dump.part.0+0x171/0x3a0 ? kfree+0x1ba/0x520 ? devlink_health_do_dump.part.0+0x171/0x3a0 devlink_health_report+0x2f1/0x7e0 mlx5e_health_report+0xc9/0xd7 [mlx5_core] mlx5e_reporter_tx_timeout+0x2ab/0x3d0 [mlx5_core] ? lockdep_hardirqs_on_prepare+0x400/0x400 ? mlx5e_reporter_tx_err_cqe+0x1b0/0x1b0 [mlx5_core] ? mlx5e_tx_reporter_timeout_dump+0x70/0x70 [mlx5_core] ? mlx5e_tx_reporter_dump_sq+0x320/0x320 [mlx5_core] ? mlx5e_tx_timeout_work+0x70/0x280 [mlx5_core] ? mutex_lock_io_nested+0x1320/0x1320 ? process_one_work+0x70f/0x1340 ? lockdep_hardirqs_on_prepare+0x400/0x400 ? lock_downgrade+0x6e0/0x6e0 mlx5e_tx_timeout_work+0x1c1/0x280 [mlx5_core] process_one_work+0x7c2/0x1340 ? lockdep_hardirqs_on_prepare+0x400/0x400 ? pwq_dec_nr_in_flight+0x230/0x230 ? rwlock_bug.part.0+0x90/0x90 worker_thread+0x59d/0xec0 ? process_one_work+0x1340/0x1340 kthread+0x28f/0x330 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x1f/0x30 </TASK>
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + .../net/ethernet/mellanox/mlx5/core/en_main.c | 27 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -0
@@ -818,6 +818,7 @@ enum {MLX5E_STATE_DESTROYING ,MLX5E_STATE_XDP_TX_ENABLED ,MLX5E_STATE_XDP_ACTIVE , + MLX5E_STATE_CHANNELS_ACTIVE, }; struct mlx5e_modify_sq_param {
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +24 -3
@@ -2668,6 +2668,7 @@ void mlx5e_close_channels(struct mlx5e_channels *chs) {int i; +ASSERT_RTNL ();if (chs->ptp) {mlx5e_ptp_close (chs->ptp); chs->ptp =NULL ;
@@ -2945,17 +2946,29 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)if (mlx5e_is_vport_rep (priv))mlx5e_rep_activate_channels (priv); +set_bit (MLX5E_STATE_CHANNELS_ACTIVE , &priv->state); +mlx5e_wait_channels_min_rx_wqes (&priv->channels);if (priv->rx_res)mlx5e_rx_res_channels_activate (priv->rx_res, &priv->channels); } +static void mlx5e_cancel_tx_timeout_work (struct mlx5e_priv *priv) +{ +WARN_ON_ONCE (test_bit (MLX5E_STATE_CHANNELS_ACTIVE , &priv->state)); +if (current_work () != &priv->tx_timeout_work) +cancel_work_sync (&priv->tx_timeout_work); +} +void mlx5e_deactivate_priv_channels (struct mlx5e_priv *priv) {if (priv->rx_res)mlx5e_rx_res_channels_deactivate (priv->rx_res); +clear_bit (MLX5E_STATE_CHANNELS_ACTIVE , &priv->state); +mlx5e_cancel_tx_timeout_work (priv); +if (mlx5e_is_vport_rep (priv))mlx5e_rep_deactivate_channels (priv);
@@ -4734,8 +4747,17 @@ static void mlx5e_tx_timeout_work(struct work_struct *work)struct net_device *netdev = priv->netdev;int i; -rtnl_lock (); -mutex_lock (&priv->state_lock); +/* Take rtnl_lock to ensure no change in netdev->real_num_tx_queues +* through this flow. However, channel closing flows have to wait for +* this work to finish while holding rtnl lock too. So either get the +* lock or find that channels are being closed for other reason and +* this work is not relevant anymore. +*/ +while (!rtnl_trylock ()) { +if (!test_bit (MLX5E_STATE_CHANNELS_ACTIVE , &priv->state)) +return ; +msleep (20 ); + }if (!test_bit (MLX5E_STATE_OPENED , &priv->state)) goto unlock;
@@ -4754,7 +4776,6 @@ static void mlx5e_tx_timeout_work(struct work_struct *work) } unlock: -mutex_unlock (&priv->state_lock);rtnl_unlock (); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 16/166 net/mlx5e: TC, Dont offload post action rule if not supported
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mi <[email protected]>
[ Upstream commit ccbe33003b109f14c4dde2a4fca9c2a50c423601 ]
If post action is not supported, eg. ignore_flow_level is not supported, don't offload post action rule. Otherwise, will hit panic [1].
Fix it by checking if post action table is valid or not.
[1]
[445537.863880] BUG: unable to handle page fault for address: ffffffffffffffb1 [445537.864617] #PF: supervisor read access in kernel mode [445537.865244] #PF: error_code(0x0000) - not-present page [445537.865860] PGD 70683a067 P4D 70683a067 PUD 70683c067 PMD 0 [445537.866497] Oops: 0000 [#1] PREEMPT SMP NOPTI [445537.867077] CPU: 19 PID: 248742 Comm: tc Kdump: loaded Tainted: G O 6.5.0+ #1 [445537.867888] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 [445537.868834] RIP: 0010:mlx5e_tc_post_act_add+0x51/0x130 [mlx5_core] [445537.869635] Code: c0 0d 00 00 e8 20 96 c6 d3 48 85 c0 0f 84 e5 00 00 00 c7 83 b0 01 00 00 00 00 00 00 49 89 c5 31 c0 31 d2 66 89 83 b4 01 00 00 <49> 8b 44 24 10 83 23 df 83 8b d8 01 00 00 04 48 89 83 c0 01 00 00 [445537.871318] RSP: 0018:ffffb98741cef428 EFLAGS: 00010246 [445537.871962] RAX: 0000000000000000 RBX: ffff8df341167000 RCX: 0000000000000001 [445537.872704] RDX: 0000000000000000 RSI: ffffffff954844e1 RDI: ffffffff9546e9cb [445537.873430] RBP: ffffb98741cef448 R08: 0000000000000020 R09: 0000000000000246 [445537.874160] R10: 0000000000000000 R11: ffffffff943f73ff R12: ffffffffffffffa1 [445537.874893] R13: ffff8df36d336c20 R14: ffffffffffffffa1 R15: ffff8df341167000 [445537.875628] FS: 00007fcd6564f800(0000) GS:ffff8dfa9ea00000(0000) knlGS:0000000000000000 [445537.876425] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [445537.877090] CR2: ffffffffffffffb1 CR3: 00000003b5884001 CR4: 0000000000770ee0 [445537.877832] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [445537.878564] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [445537.879300] PKRU: 55555554 [445537.879797] Call Trace: [445537.880263] <TASK> [445537.880713] ? show_regs+0x6e/0x80 [445537.881232] ? __die+0x29/0x70 [445537.881731] ? page_fault_oops+0x85/0x160 [445537.882276] ? search_exception_tables+0x65/0x70 [445537.882852] ? kernelmode_fixup_or_oops+0xa2/0x120 [445537.883432] ? __bad_area_nosemaphore+0x18b/0x250 [445537.884019] ? bad_area_nosemaphore+0x16/0x20 [445537.884566] ? do_kern_addr_fault+0x8b/0xa0 [445537.885105] ? exc_page_fault+0xf5/0x1c0 [445537.885623] ? asm_exc_page_fault+0x2b/0x30 [445537.886149] ? __kmem_cache_alloc_node+0x1df/0x2a0 [445537.886717] ? mlx5e_tc_post_act_add+0x51/0x130 [mlx5_core] [445537.887431] ? mlx5e_tc_post_act_add+0x30/0x130 [mlx5_core] [445537.888172] alloc_flow_post_acts+0xfb/0x1c0 [mlx5_core] [445537.888849] parse_tc_actions+0x582/0x5c0 [mlx5_core] [445537.889505] parse_tc_fdb_actions+0xd7/0x1f0 [mlx5_core] [445537.890175] __mlx5e_add_fdb_flow+0x1ab/0x2b0 [mlx5_core] [445537.890843] mlx5e_add_fdb_flow+0x56/0x120 [mlx5_core] [445537.891491] ? debug_smp_processor_id+0x1b/0x30 [445537.892037] mlx5e_tc_add_flow+0x79/0x90 [mlx5_core] [445537.892676] mlx5e_configure_flower+0x305/0x450 [mlx5_core] [445537.893341] mlx5e_rep_setup_tc_cls_flower+0x3d/0x80 [mlx5_core] [445537.894037] mlx5e_rep_setup_tc_cb+0x5c/0xa0 [mlx5_core] [445537.894693] tc_setup_cb_add+0xdc/0x220 [445537.895177] fl_hw_replace_filter+0x15f/0x220 [cls_flower] [445537.895767] fl_change+0xe87/0x1190 [cls_flower] [445537.896302] tc_new_tfilter+0x484/0xa50
--- .../mellanox/mlx5/core/en/tc/post_act.c | 6 +++++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 25 ++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c +6 -0
@@ -83,6 +83,9 @@ mlx5e_tc_post_act_offload(struct mlx5e_post_act *post_act,struct mlx5_flow_spec *spec;int err; +if (IS_ERR (post_act)) +return PTR_ERR (post_act); + spec =kvzalloc (sizeof (*spec),GFP_KERNEL );if (!spec)return -ENOMEM ;
@@ -111,6 +114,9 @@ mlx5e_tc_post_act_add(struct mlx5e_post_act *post_act, struct mlx5_flow_attr *postruct mlx5e_post_act_handle *handle;int err; +if (IS_ERR (post_act)) +return ERR_CAST (post_act); + handle =kzalloc (sizeof (*handle),GFP_KERNEL );if (!handle)return ERR_PTR (-ENOMEM );
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +21 -4
@@ -444,6 +444,9 @@ mlx5e_tc_add_flow_meter(struct mlx5e_priv *priv,struct mlx5e_flow_meter_handle *meter;enum mlx5e_post_meter_type type; +if (IS_ERR (post_act)) +return PTR_ERR (post_act); + meter =mlx5e_tc_meter_replace (priv->mdev, &attr->meter_attr.params);if (IS_ERR (meter)) {mlx5_core_err (priv->mdev,"Failed to get flow meter\n" );
@@ -3736,6 +3739,20 @@ alloc_flow_post_acts(struct mlx5e_tc_flow *flow, struct netlink_ext_ack *extack)return err; } +static int +set_branch_dest_ft (struct mlx5e_priv *priv,struct mlx5_flow_attr *attr) +{ +struct mlx5e_post_act *post_act =get_post_action (priv); + +if (IS_ERR (post_act)) +return PTR_ERR (post_act); + + attr->action |=MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; + attr->dest_ft =mlx5e_tc_post_act_get_ft (post_act); + +return 0 ; +} + static int alloc_branch_attr(struct mlx5e_tc_flow *flow, struct mlx5e_tc_act_branch_ctrl *cond,
@@ -3759,8 +3776,8 @@ alloc_branch_attr(struct mlx5e_tc_flow *flow,break ;case FLOW_ACTION_ACCEPT :case FLOW_ACTION_PIPE : - attr->action |=MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; - attr->dest_ft =mlx5e_tc_post_act_get_ft (get_post_action (flow->priv)); +if (set_branch_dest_ft (flow->priv, attr)) + goto out_err;break ;case FLOW_ACTION_JUMP :if (*jump_count) {
@@ -3769,8 +3786,8 @@ alloc_branch_attr(struct mlx5e_tc_flow *flow, goto out_err; } *jump_count = cond->extval; - attr->action |=MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; - attr->dest_ft =mlx5e_tc_post_act_get_ft (get_post_action (flow->priv)); +if (set_branch_dest_ft (flow->priv, attr)) + goto out_err;break ;default : err = -EOPNOTSUPP ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 17/166 net/mlx5: Nack sync reset request when HotPlug is enabled
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Moshe Shemesh <[email protected]>
[ Upstream commit 3d7a3f2612d75de5f371a681038b089ded6667eb ]
Current sync reset flow is not supported when PCIe bridge connected directly to mlx5 device has HotPlug interrupt enabled and can be triggered on link state change event. Return nack on reset request in such case.
--- .../ethernet/mellanox/mlx5/core/fw_reset.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +29 -0
@@ -325,6 +325,29 @@ static void mlx5_fw_live_patch_event(struct work_struct *work)mlx5_core_err (dev,"Failed to reload FW tracer\n" ); } +#if IS_ENABLED (CONFIG_HOTPLUG_PCI_PCIE ) +static int mlx5_check_hotplug_interrupt (struct mlx5_core_dev *dev) +{ +struct pci_dev *bridge = dev->pdev->bus->self; +u16 reg16; +int err; + +if (!bridge) +return -EOPNOTSUPP ; + + err =pcie_capability_read_word (bridge,PCI_EXP_SLTCTL , ®16); +if (err) +return err; + +if ((reg16 &PCI_EXP_SLTCTL_HPIE ) && (reg16 &PCI_EXP_SLTCTL_DLLSCE )) { +mlx5_core_warn (dev,"FW reset is not supported as HotPlug is enabled\n" ); +return -EOPNOTSUPP ; + } + +return 0 ; +} +#endif +static int mlx5_check_dev_ids (struct mlx5_core_dev *dev,u16 dev_id) {struct pci_bus *bridge_bus = dev->pdev->bus;
@@ -357,6 +380,12 @@ static bool mlx5_is_reset_now_capable(struct mlx5_core_dev *dev)return false; } +#if IS_ENABLED (CONFIG_HOTPLUG_PCI_PCIE ) + err =mlx5_check_hotplug_interrupt (dev); +if (err) +return false; +#endif + err =pci_read_config_word (dev->pdev,PCI_DEVICE_ID , &dev_id);if (err)return false;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 18/166 net/mlx5e: Check netdev pointer before checking its net ns
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gavin Li <[email protected]>
[ Upstream commit 7aaf975238c47b710fcc4eca0da1e7902a53abe2 ]
Previously, when comparing the net namespaces, the case where the netdev doesn't exist wasn't taken into account, and therefore can cause a crash. In such a case, the comparing function should return false, as there is no netdev->net to compare the devlink->net to.
Furthermore, this will result in an attempt to enter switchdev mode without a netdev to fail, and which is the desired result as there is no meaning in switchdev mode without a net device.
--- .../mellanox/mlx5/core/eswitch_offloads.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +10 -6
@@ -3653,14 +3653,18 @@ static int esw_inline_mode_to_devlink(u8 mlx5_mode, u8 *mode)static bool esw_offloads_devlink_ns_eq_netdev_ns (struct devlink *devlink) { +struct mlx5_core_dev *dev =devlink_priv (devlink);struct net *devl_net, *netdev_net; -struct mlx5_eswitch *esw; - - esw =mlx5_devlink_eswitch_nocheck_get (devlink); - netdev_net =dev_net (esw->dev->mlx5e_res.uplink_netdev); - devl_net =devlink_net (devlink); +bool ret = false; -return net_eq (devl_net, netdev_net); +mutex_lock (&dev->mlx5e_res.uplink_netdev_lock); +if (dev->mlx5e_res.uplink_netdev) { + netdev_net =dev_net (dev->mlx5e_res.uplink_netdev); + devl_net =devlink_net (devlink); + ret =net_eq (devl_net, netdev_net); + } +mutex_unlock (&dev->mlx5e_res.uplink_netdev_lock); +return ret; }int mlx5_eswitch_block_mode (struct mlx5_core_dev *dev)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 19/166 net/mlx5: Fix a NULL vs IS_ERR() check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit ca4ef28d0ad831d2521fa2b16952f37fd9324ca3 ]
The mlx5_esw_offloads_devlink_port() function returns error pointers, not NULL.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 -1
@@ -1503,7 +1503,7 @@ mlx5e_vport_vf_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) dl_port =mlx5_esw_offloads_devlink_port (dev->priv.eswitch, rpriv->rep->vport); -if (dl_port) { +if (!IS_ERR (dl_port)) {SET_NETDEV_DEVLINK_PORT (netdev, dl_port);mlx5e_rep_vnic_reporter_create (priv, dl_port); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 2/166 ext4: fix warning in ext4_dio_write_end_io()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit 619f75dae2cf117b1d07f27b046b9ffb071c4685 ]
The syzbot has reported that it can hit the warning in ext4_dio_write_end_io() because i_size < i_disksize. Indeed the reproducer creates a race between DIO IO completion and truncate expanding the file and thus ext4_dio_write_end_io() sees an inconsistent inode state where i_disksize is already updated but i_size is not updated yet. Since we are careful when setting up DIO write and consider it extending (and thus performing the IO synchronously with i_rwsem held exclusively) whenever it goes past either of i_size or i_disksize, we can use the same test during IO completion without risking entering ext4_handle_inode_extension() without i_rwsem held. This way we make it obvious both i_size and i_disksize are large enough when we report DIO completion without relying on unreliable WARN_ON.
--- fs/ext4/file.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
fs/ext4/file.c +8 -6
@@ -349,9 +349,10 @@ static void ext4_inode_extension_cleanup(struct inode *inode, ssize_t count)return ; }/* -* If i_disksize got extended due to writeback of delalloc blocks while -* the DIO was running we could fail to cleanup the orphan list in -* ext4_handle_inode_extension(). Do it now. +* If i_disksize got extended either due to writeback of delalloc +* blocks or extending truncate while the DIO was running we could fail +* to cleanup the orphan list in ext4_handle_inode_extension(). Do it +* now. */ if (!list_empty (&EXT4_I (inode)->i_orphan) && inode->i_nlink) {handle_t *handle =ext4_journal_start (inode,EXT4_HT_INODE ,2 );
@@ -386,10 +387,11 @@ static int ext4_dio_write_end_io(struct kiocb *iocb, ssize_t size,* blocks. But the code in ext4_iomap_alloc() is careful to use * zeroed/unwritten extents if this is possible; thus we won't leave * uninitialized blocks in a file even if we didn't succeed in writing -* as much as we intended. +* as much as we intended. Also we can race with truncate or write +* expanding the file so we have to be a bit careful here. */ -WARN_ON_ONCE (i_size_read (inode) <READ_ONCE (EXT4_I (inode)->i_disksize)); -if (pos + size <=READ_ONCE (EXT4_I (inode)->i_disksize)) +if (pos + size <=READ_ONCE (EXT4_I (inode)->i_disksize) && + pos + size <=i_size_read (inode))return size;return ext4_handle_inode_extension (inode, pos, size); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 20/166 net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej Żenczykowski <[email protected]>
[ Upstream commit bd4a816752bab609dd6d65ae021387beb9e2ddbd ]
Lorenzo points out that we effectively clear all unknown flags from PIO when copying them to userspace in the netlink RTM_NEWPREFIX notification.
We could fix this one at a time as new flags are defined, or in one fell swoop - I choose the latter.
We could either define 6 new reserved flags (reserved1..6) and handle them individually (and rename them as new flags are defined), or we could simply copy the entire unmodified byte over - I choose the latter.
This unfortunately requires some anonymous union/struct magic, so we add a static assert on the struct size for a little extra safety.
--- include/net/addrconf.h | 12 ++++++++++-- include/net/if_inet6.h | 4 ---- net/ipv6/addrconf.c | 6 +----- 3 files changed, 11 insertions(+), 11 deletions(-)
include/net/addrconf.h +10 -2
@@ -31,17 +31,22 @@ struct prefix_info {__u8 length;__u8 prefix_len; +union __packed { +__u8 flags; +struct __packed {#if defined(__BIG_ENDIAN_BITFIELD) - __u8 onlink : 1, +__u8 onlink :1 , autoconf :1 , reserved :6 ;#elif defined(__LITTLE_ENDIAN_BITFIELD) - __u8 reserved : 6, +__u8 reserved :6 , autoconf :1 , onlink :1 ;#else #error "Please fix <asm/byteorder.h>"#endif + }; + };__be32 valid;__be32 prefered;__be32 reserved2;
@@ -49,6 +54,9 @@ struct prefix_info {struct in6_addr prefix; }; +/* rfc4861 4.6.2: IPv6 PIO is 32 bytes in size */ +static_assert (sizeof (struct prefix_info ) ==32 ); +#include <linux/ipv6.h> #include <linux/netdevice.h> #include <net/if_inet6.h>
include/net/if_inet6.h +0 -4
@@ -22,10 +22,6 @@#define IF_RS_SENT 0x10#define IF_READY 0x80000000 -/* prefix flags */ -#define IF_PREFIX_ONLINK 0x01 -#define IF_PREFIX_AUTOCONF 0x02 -enum {INET6_IFADDR_STATE_PREDAD ,INET6_IFADDR_STATE_DAD ,
net/ipv6/addrconf.c +1 -5
@@ -6137,11 +6137,7 @@ static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev, pmsg->prefix_len = pinfo->prefix_len; pmsg->prefix_type = pinfo->type; pmsg->prefix_pad3 =0 ; - pmsg->prefix_flags =0 ; -if (pinfo->onlink) - pmsg->prefix_flags |=IF_PREFIX_ONLINK ; -if (pinfo->autoconf) - pmsg->prefix_flags |=IF_PREFIX_AUTOCONF ; + pmsg->prefix_flags = pinfo->flags;if (nla_put (skb,PREFIX_ADDRESS ,sizeof (pinfo->prefix), &pinfo->prefix)) goto nla_put_failure;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 3/166 ksmbd: fix memory leak in smb2_lock()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <[email protected]>
[ Upstream commit 8f1752723019db900fb60a5b9d0dfd3a2bdea36c ]
In smb2_lock(), if setup_async_work() executes successfully, work->cancel_argv will bind the argv that generated by kmalloc(). And release_async_work() is called in ksmbd_conn_try_dequeue_request() or smb2_lock() to release argv.
However, when setup_async_work function fails, work->cancel_argv has not been bound to the argv, resulting in the previously allocated argv not being released. Call kfree() to fix it.
--- fs/smb/server/smb2pdu.c | 1 + 1 file changed, 1 insertion(+)
fs/smb/server/smb2pdu.c +1 -0
@@ -7074,6 +7074,7 @@ int smb2_lock(struct ksmbd_work *work) smb2_remove_blocked_lock, argv);if (rc) { +kfree (argv); err = -ENOMEM ; goto out; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 4/166 efi/x86: Avoid physical KASLR on older Dell systems
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
[ Upstream commit 50d7cdf7a9b1ab6f4f74a69c84e974d5dc0c1bf1 ]
River reports boot hangs with v6.6 and v6.7, and the bisect points to commit
a1b87d54f4e4 ("x86/efistub: Avoid legacy decompressor when doing EFI boot")
which moves the memory allocation and kernel decompression from the legacy decompressor (which executes *after* ExitBootServices()) to the EFI stub, using boot services for allocating the memory. The memory allocation succeeds but the subsequent call to decompress_kernel() never returns, resulting in a failed boot and a hanging system.
As it turns out, this issue only occurs when physical address randomization (KASLR) is enabled, and given that this is a feature we can live without (virtual KASLR is much more important), let's disable the physical part of KASLR when booting on AMI UEFI firmware claiming to implement revision v2.0 of the specification (which was released in 2006), as this is the version these systems advertise.
--- drivers/firmware/efi/libstub/x86-stub.c | 31 +++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-)
drivers/firmware/efi/libstub/x86-stub.c +24 -7
@@ -307,17 +307,20 @@ static void setup_unaccepted_memory(void)efi_err ("Memory acceptance protocol failed\n" ); } +static efi_char16_t *efistub_fw_vendor (void ) +{ +unsigned long vendor =efi_table_attr (efi_system_table, fw_vendor); + +return (efi_char16_t *)vendor; +} +static const efi_char16_t apple[] =L"Apple" ;static void setup_quirks (struct boot_params *boot_params) { -efi_char16_t *fw_vendor = (efi_char16_t *)(unsigned long ) -efi_table_attr (efi_system_table, fw_vendor); - -if (!memcmp (fw_vendor, apple,sizeof (apple))) { -if (IS_ENABLED (CONFIG_APPLE_PROPERTIES )) -retrieve_apple_device_properties (boot_params); - } +if (IS_ENABLED (CONFIG_APPLE_PROPERTIES ) && + !memcmp (efistub_fw_vendor (), apple,sizeof (apple))) +retrieve_apple_device_properties (boot_params); }/*
@@ -799,11 +802,25 @@ static efi_status_t efi_decompress_kernel(unsigned long *kernel_entry)if (IS_ENABLED (CONFIG_RANDOMIZE_BASE ) && !efi_nokaslr) {u64 range =KERNEL_IMAGE_SIZE -LOAD_PHYSICAL_ADDR - kernel_total_size; +static const efi_char16_t ami[] =L"American Megatrends" ;efi_get_seed (seed,sizeof (seed)); virt_addr += (range * seed[1 ]) >>32 ; virt_addr &= ~(CONFIG_PHYSICAL_ALIGN -1 ); + +/* +* Older Dell systems with AMI UEFI firmware v2.0 may hang +* while decompressing the kernel if physical address +* randomization is enabled. +* +* https://bugzilla.kernel.org/show_bug.cgi?id=218173 +*/ +if (efi_system_table->hdr.revision <=EFI_2_00_SYSTEM_TABLE_REVISION && + !memcmp (efistub_fw_vendor (), ami,sizeof (ami))) { +efi_debug ("AMI firmware v2.0 or older detected - disabling physical KASLR\n" ); + seed[0 ] =0 ; + } } status = efi_random_alloc(alloc_size, CONFIG_PHYSICAL_ALIGN, &addr,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 5/166 afs: Fix refcount underflow from error handling race
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 52bf9f6c09fca8c74388cd41cc24e5d1bff812a9 ]
If an AFS cell that has an unreachable (eg. ENETUNREACH) server listed (VL server or fileserver), an asynchronous probe to one of its addresses may fail immediately because sendmsg() returns an error. When this happens, a refcount underflow can happen if certain events hit a very small window.
The way this occurs is:
(1) There are two levels of "call" object, the afs_call and the rxrpc_call. Each of them can be transitioned to a "completed" state in the event of success or failure.
(2) Asynchronous afs_calls are self-referential whilst they are active to prevent them from evaporating when they're not being processed. This reference is disposed of when the afs_call is completed.
Note that an afs_call may only be completed once; once completed completing it again will do nothing.
(3) When a call transmission is made, the app-side rxrpc code queues a Tx buffer for the rxrpc I/O thread to transmit. The I/O thread invokes sendmsg() to transmit it - and in the case of failure, it transitions the rxrpc_call to the completed state.
(4) When an rxrpc_call is completed, the app layer is notified. In this case, the app is kafs and it schedules a work item to process events pertaining to an afs_call.
(5) When the afs_call event processor is run, it goes down through the RPC-specific handler to afs_extract_data() to retrieve data from rxrpc
- and, in this case, it picks up the error from the rxrpc_call and returns it.
The error is then propagated to the afs_call and that is completed too. At this point the self-reference is released.
(6) If the rxrpc I/O thread manages to complete the rxrpc_call within the window between rxrpc_send_data() queuing the request packet and checking for call completion on the way out, then rxrpc_kernel_send_data() will return the error from sendmsg() to the app.
(7) Then afs_make_call() will see an error and will jump to the error handling path which will attempt to clean up the afs_call.
(8) The problem comes when the error handling path in afs_make_call() tries to unconditionally drop an async afs_call's self-reference. This self-reference, however, may already have been dropped by afs_extract_data() completing the afs_call
(9) The refcount underflows when we return to afs_do_probe_vlserver() and that tries to drop its reference on the afs_call.
Fix this by making afs_make_call() attempt to complete the afs_call rather than unconditionally putting it. That way, if afs_extract_data() manages to complete the call first, afs_make_call() won't do anything.
The bug can be forced by making do_udp_sendmsg() return -ENETUNREACH and sticking an msleep() in rxrpc_send_data() after the 'success:' label to widen the race window.
The error message looks something like:
refcount_t: underflow; use-after-free.
WARNING: CPU: 3 PID: 720 at lib/refcount.c:28 refcount_warn_saturate+0xba/0x110
...
RIP: 0010:refcount_warn_saturate+0xba/0x110
...
afs_put_call+0x1dc/0x1f0 [kafs]
afs_fs_get_capabilities+0x8b/0xe0 [kafs]
afs_fs_probe_fileserver+0x188/0x1e0 [kafs]
afs_lookup_server+0x3bf/0x3f0 [kafs]
afs_alloc_server_list+0x130/0x2e0 [kafs]
afs_create_volume+0x162/0x400 [kafs]
afs_get_tree+0x266/0x410 [kafs]
vfs_get_tree+0x25/0xc0
fc_mount+0xe/0x40
afs_d_automount+0x1b3/0x390 [kafs]
__traverse_mounts+0x8f/0x210
step_into+0x340/0x760
path_openat+0x13a/0x1260
do_filp_open+0xaf/0x160
do_sys_openat2+0xaf/0x170or something like:
refcount_t: underflow; use-after-free.
...
RIP: 0010:refcount_warn_saturate+0x99/0xda
...
afs_put_call+0x4a/0x175
afs_send_vl_probes+0x108/0x172
afs_select_vlserver+0xd6/0x311
afs_do_cell_detect_alias+0x5e/0x1e9
afs_cell_detect_alias+0x44/0x92
afs_validate_fc+0x9d/0x134
afs_get_tree+0x20/0x2e6
vfs_get_tree+0x1d/0xc9
fc_mount+0xe/0x33
afs_d_automount+0x48/0x9d
__traverse_mounts+0xe0/0x166
step_into+0x140/0x274
open_last_lookups+0x1c1/0x1df
path_openat+0x138/0x1c3
do_filp_open+0x55/0xb4
do_sys_openat2+0x6c/0xb6--- fs/afs/rxrpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/rxrpc.c +1 -1
@@ -424,7 +424,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)if (call->async) {if (cancel_work_sync (&call->async_work))afs_put_call (call); -afs_put_call (call); +afs_set_call_complete (call, ret,0 ); } ac->error = ret;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 6/166 HID: lenovo: Restrict detection of patched firmware only to USB cptkbd
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Khvainitski <[email protected]>
[ Upstream commit 43527a0094c10dfbf0d5a2e7979395a38de3ff65 ]
Commit 46a0a2c96f0f ("HID: lenovo: Detect quirk-free fw on cptkbd and stop applying workaround") introduced a regression for ThinkPad TrackPoint Keyboard II which has similar quirks to cptkbd (so it uses the same workarounds) but slightly different so that there are false-positives during detecting well-behaving firmware. This commit restricts detecting well-behaving firmware to the only model which known to have one and have stable enough quirks to not cause false-positives.
--- drivers/hid/hid-lenovo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hid/hid-lenovo.c +2 -1
@@ -692,7 +692,8 @@ static int lenovo_event_cptkbd(struct hid_device *hdev,* so set middlebutton_state to 3 * to never apply workaround anymore */ -if (cptkbd_data->middlebutton_state ==1 && +if (hdev->product ==USB_DEVICE_ID_LENOVO_CUSBKBD && + cptkbd_data->middlebutton_state ==1 && usage->type ==EV_REL && (usage->code ==REL_X || usage->code ==REL_Y )) { cptkbd_data->middlebutton_state =3 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 7/166 net/mlx5e: Honor user choice of IPsec replay window size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit a5e400a985df8041ed4659ed1462aa9134318130 ]
Users can configure IPsec replay window size, but mlx5 driver didn't honor their choice and set always 32bits. Fix assignment logic to configure right size from the beginning.
--- .../mellanox/mlx5/core/en_accel/ipsec.c | 21 +++++++++++++++++++ .../mlx5/core/en_accel/ipsec_offload.c | 2 +- include/linux/mlx5/mlx5_ifc.h | 7 +++++++ 3 files changed, 29 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +21 -0
@@ -335,6 +335,27 @@ void mlx5e_ipsec_build_accel_xfrm_attrs(struct mlx5e_ipsec_sa_entry *sa_entry, attrs->replay_esn.esn = sa_entry->esn_state.esn; attrs->replay_esn.esn_msb = sa_entry->esn_state.esn_msb; attrs->replay_esn.overlap = sa_entry->esn_state.overlap; +switch (x->replay_esn->replay_window) { +case 32 : + attrs->replay_esn.replay_window = +MLX5_IPSEC_ASO_REPLAY_WIN_32BIT ; +break ; +case 64 : + attrs->replay_esn.replay_window = +MLX5_IPSEC_ASO_REPLAY_WIN_64BIT ; +break ; +case 128 : + attrs->replay_esn.replay_window = +MLX5_IPSEC_ASO_REPLAY_WIN_128BIT ; +break ; +case 256 : + attrs->replay_esn.replay_window = +MLX5_IPSEC_ASO_REPLAY_WIN_256BIT ; +break ; +default : +WARN_ON (true); +return ; + } } attrs->dir = x->xso.dir;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c +1 -1
@@ -94,7 +94,7 @@ static void mlx5e_ipsec_packet_setup(void *obj, u32 pdn,if (attrs->dir ==XFRM_DEV_OFFLOAD_IN ) {MLX5_SET (ipsec_aso, aso_ctx, window_sz, - attrs->replay_esn.replay_window /64 ); + attrs->replay_esn.replay_window);MLX5_SET (ipsec_aso, aso_ctx, mode,MLX5_IPSEC_ASO_REPLAY_PROTECTION ); }
include/linux/mlx5/mlx5_ifc.h +7 -0
@@ -11936,6 +11936,13 @@ enum { MLX5_IPSEC_ASO_INC_SN = 0x2, }; +enum { +MLX5_IPSEC_ASO_REPLAY_WIN_32BIT =0x0 , +MLX5_IPSEC_ASO_REPLAY_WIN_64BIT =0x1 , +MLX5_IPSEC_ASO_REPLAY_WIN_128BIT =0x2 , +MLX5_IPSEC_ASO_REPLAY_WIN_256BIT =0x3 , +}; +struct mlx5_ifc_ipsec_aso_bits {u8 valid[0x1 ];u8 reserved_at_201[0x1 ];
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 8/166 net/mlx5e: Ensure that IPsec sequence packet number starts from 1
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 3d42c8cc67a8fcbff0181f9ed6d03d353edcee07 ]
According to RFC4303, section "3.3.3. Sequence Number Generation", the first packet sent using a given SA will contain a sequence number of 1.
However if user didn't set seq/oseq, the HW used zero as first sequence packet number. Such misconfiguration causes to drop of first packet if replay window protection was enabled in SA.
To fix it, set sequence number to be at least 1.
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +8 -1
@@ -121,7 +121,14 @@ static bool mlx5e_ipsec_update_esn_state(struct mlx5e_ipsec_sa_entry *sa_entry)if (x->xso.type ==XFRM_DEV_OFFLOAD_CRYPTO ) esn_msb =xfrm_replay_seqhi (x,htonl (seq_bottom)); - sa_entry->esn_state.esn = esn; +if (sa_entry->esn_state.esn_msb) + sa_entry->esn_state.esn = esn; +else +/* According to RFC4303, section "3.3.3. Sequence Number Generation", +* the first packet sent using a given SA will contain a sequence +* number of 1. +*/ + sa_entry->esn_state.esn =max_t (u32, esn,1 ); sa_entry->esn_state.esn_msb = esn_msb;if (unlikely (overlap && seq_bottom <MLX5E_IPSEC_ESN_SCOPE_MID )) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 9/166 net/mlx5e: Unify esw and normal IPsec status table creation/destruction
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 94af50c0a9bb961fe93cf0fdd14eb0883da86721 ]
Change normal IPsec flow to use the same creation/destruction functions for status flow table as that of ESW, which first of all refines the code to have less code duplication.
And more importantly, the ESW status table handles IPsec syndrome checks at steering by HW, which is more efficient than the previous behaviour we had where it was copied to WQE meta data and checked by the driver.
--- .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 187 +++++++++++++----- .../mellanox/mlx5/core/esw/ipsec_fs.c | 152 -------------- .../mellanox/mlx5/core/esw/ipsec_fs.h | 15 -- 3 files changed, 141 insertions(+), 213 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c +141 -46
@@ -128,63 +128,166 @@ static struct mlx5_flow_table *ipsec_ft_create(struct mlx5_flow_namespace *ns,return mlx5_create_auto_grouped_flow_table (ns, &ft_attr); } -static int ipsec_status_rule (struct mlx5_core_dev *mdev, -struct mlx5e_ipsec_rx *rx, -struct mlx5_flow_destination *dest) +static void ipsec_rx_status_drop_destroy (struct mlx5e_ipsec *ipsec, +struct mlx5e_ipsec_rx *rx) { -u8 action[MLX5_UN_SZ_BYTES (set_add_copy_action_in_auto)] = {}; +mlx5_del_flow_rules (rx->status_drop.rule); +mlx5_destroy_flow_group (rx->status_drop.group); +mlx5_fc_destroy (ipsec->mdev, rx->status_drop_cnt); +} + +static void ipsec_rx_status_pass_destroy (struct mlx5e_ipsec *ipsec, +struct mlx5e_ipsec_rx *rx) +{ +mlx5_del_flow_rules (rx->status.rule); + +if (rx != ipsec->rx_esw) +return ; + +#ifdef CONFIG_MLX5_ESWITCH +mlx5_chains_put_table (esw_chains (ipsec->mdev->priv.eswitch),0 ,1 ,0 ); +#endif +} + +static int ipsec_rx_status_drop_create (struct mlx5e_ipsec *ipsec, +struct mlx5e_ipsec_rx *rx) +{ +int inlen =MLX5_ST_SZ_BYTES (create_flow_group_in); +struct mlx5_flow_table *ft = rx->ft.status; +struct mlx5_core_dev *mdev = ipsec->mdev; +struct mlx5_flow_destination dest = {};struct mlx5_flow_act flow_act = {}; -struct mlx5_modify_hdr *modify_hdr; -struct mlx5_flow_handle *fte; +struct mlx5_flow_handle *rule; +struct mlx5_fc *flow_counter;struct mlx5_flow_spec *spec; -int err; +struct mlx5_flow_group *g; +u32 *flow_group_in; +int err =0 ; + flow_group_in =kvzalloc (inlen,GFP_KERNEL ); spec =kvzalloc (sizeof (*spec),GFP_KERNEL ); -if (!spec) -return -ENOMEM ; +if (!flow_group_in || !spec) { + err = -ENOMEM ; + goto err_out; + } -/* Action to copy 7 bit ipsec_syndrome to regB[24:30] */ -MLX5_SET (copy_action_in, action, action_type,MLX5_ACTION_TYPE_COPY ); -MLX5_SET (copy_action_in, action, src_field,MLX5_ACTION_IN_FIELD_IPSEC_SYNDROME ); -MLX5_SET (copy_action_in, action, src_offset,0 ); -MLX5_SET (copy_action_in, action, length,7 ); -MLX5_SET (copy_action_in, action, dst_field,MLX5_ACTION_IN_FIELD_METADATA_REG_B ); -MLX5_SET (copy_action_in, action, dst_offset,24 ); +MLX5_SET (create_flow_group_in, flow_group_in, start_flow_index, ft->max_fte -1 ); +MLX5_SET (create_flow_group_in, flow_group_in, end_flow_index, ft->max_fte -1 ); + g =mlx5_create_flow_group (ft, flow_group_in); +if (IS_ERR (g)) { + err =PTR_ERR (g); +mlx5_core_err (mdev, +"Failed to add ipsec rx status drop flow group, err=%d\n" , err); + goto err_out; + } - modify_hdr =mlx5_modify_header_alloc (mdev,MLX5_FLOW_NAMESPACE_KERNEL , -1 , action); + flow_counter =mlx5_fc_create (mdev, false); +if (IS_ERR (flow_counter)) { + err =PTR_ERR (flow_counter); +mlx5_core_err (mdev, +"Failed to add ipsec rx status drop rule counter, err=%d\n" , err); + goto err_cnt; + } -if (IS_ERR (modify_hdr)) { - err =PTR_ERR (modify_hdr); + flow_act.action =MLX5_FLOW_CONTEXT_ACTION_DROP |MLX5_FLOW_CONTEXT_ACTION_COUNT ; + dest.type =MLX5_FLOW_DESTINATION_TYPE_COUNTER ; + dest.counter_id =mlx5_fc_id (flow_counter); +if (rx == ipsec->rx_esw) + spec->flow_context.flow_source =MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK ; + rule =mlx5_add_flow_rules (ft, spec, &flow_act, &dest,1 ); +if (IS_ERR (rule)) { + err =PTR_ERR (rule);mlx5_core_err (mdev, -"fail to alloc ipsec copy modify_header_id err=%d\n" , err); - goto out_spec; +"Failed to add ipsec rx status drop rule, err=%d\n" , err); + goto err_rule; } -/* create fte */ - flow_act.action =MLX5_FLOW_CONTEXT_ACTION_MOD_HDR | -MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | + rx->status_drop.group = g; + rx->status_drop.rule = rule; + rx->status_drop_cnt = flow_counter; + +kvfree (flow_group_in); +kvfree (spec); +return 0 ; + +err_rule: +mlx5_fc_destroy (mdev, flow_counter); +err_cnt: +mlx5_destroy_flow_group (g); +err_out: +kvfree (flow_group_in); +kvfree (spec); +return err; +} + +static int ipsec_rx_status_pass_create (struct mlx5e_ipsec *ipsec, +struct mlx5e_ipsec_rx *rx, +struct mlx5_flow_destination *dest) +{ +struct mlx5_flow_act flow_act = {}; +struct mlx5_flow_handle *rule; +struct mlx5_flow_spec *spec; +int err; + + spec =kvzalloc (sizeof (*spec),GFP_KERNEL ); +if (!spec) +return -ENOMEM ; + +MLX5_SET_TO_ONES (fte_match_param, spec->match_criteria, + misc_parameters_2.ipsec_syndrome); +MLX5_SET (fte_match_param, spec->match_value, + misc_parameters_2.ipsec_syndrome,0 ); +if (rx == ipsec->rx_esw) + spec->flow_context.flow_source =MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK ; + spec->match_criteria_enable =MLX5_MATCH_MISC_PARAMETERS_2 ; + flow_act.flags =FLOW_ACT_NO_APPEND ; + flow_act.action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |MLX5_FLOW_CONTEXT_ACTION_COUNT ; - flow_act.modify_hdr = modify_hdr; - fte =mlx5_add_flow_rules (rx->ft.status, spec, &flow_act, dest,2 ); -if (IS_ERR (fte)) { - err =PTR_ERR (fte); -mlx5_core_err (mdev,"fail to add ipsec rx err copy rule err=%d\n" , err); - goto out; + rule =mlx5_add_flow_rules (rx->ft.status, spec, &flow_act, dest,2 ); +if (IS_ERR (rule)) { + err =PTR_ERR (rule); +mlx5_core_warn (ipsec->mdev, +"Failed to add ipsec rx status pass rule, err=%d\n" , err); + goto err_rule; } + rx->status.rule = rule;kvfree (spec); - rx->status.rule = fte; - rx->status.modify_hdr = modify_hdr;return 0 ; -out: -mlx5_modify_header_dealloc (mdev, modify_hdr); -out_spec: +err_rule:kvfree (spec);return err; } +static void mlx5_ipsec_rx_status_destroy (struct mlx5e_ipsec *ipsec, +struct mlx5e_ipsec_rx *rx) +{ +ipsec_rx_status_pass_destroy (ipsec, rx); +ipsec_rx_status_drop_destroy (ipsec, rx); +} + +static int mlx5_ipsec_rx_status_create (struct mlx5e_ipsec *ipsec, +struct mlx5e_ipsec_rx *rx, +struct mlx5_flow_destination *dest) +{ +int err; + + err =ipsec_rx_status_drop_create (ipsec, rx); +if (err) +return err; + + err =ipsec_rx_status_pass_create (ipsec, rx, dest); +if (err) + goto err_pass_create; + +return 0 ; + +err_pass_create: +ipsec_rx_status_drop_destroy (ipsec, rx); +return err; +} + static int ipsec_miss_create(struct mlx5_core_dev *mdev, struct mlx5_flow_table *ft, struct mlx5e_ipsec_miss *miss,
@@ -256,12 +359,7 @@ static void rx_destroy(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,mlx5_destroy_flow_table (rx->ft.sa);if (rx->allow_tunnel_mode)mlx5_eswitch_unblock_encap (mdev); -if (rx == ipsec->rx_esw) { -mlx5_esw_ipsec_rx_status_destroy (ipsec, rx); - }else { -mlx5_del_flow_rules (rx->status.rule); -mlx5_modify_header_dealloc (mdev, rx->status.modify_hdr); - } +mlx5_ipsec_rx_status_destroy (ipsec, rx);mlx5_destroy_flow_table (rx->ft.status);mlx5_ipsec_fs_roce_rx_destroy (ipsec->roce, family);
@@ -351,10 +449,7 @@ static int rx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec, dest[1 ].type =MLX5_FLOW_DESTINATION_TYPE_COUNTER ; dest[1 ].counter_id =mlx5_fc_id (rx->fc->cnt); -if (rx == ipsec->rx_esw) - err =mlx5_esw_ipsec_rx_status_create (ipsec, rx, dest); -else - err =ipsec_status_rule (mdev, rx, dest); + err =mlx5_ipsec_rx_status_create (ipsec, rx, dest);if (err) goto err_add;
drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c +0 -152
158 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.h +0 -15
@@ -8,11 +8,6 @@ struct mlx5e_ipsec;struct mlx5e_ipsec_sa_entry ;#ifdef CONFIG_MLX5_ESWITCH -void mlx5_esw_ipsec_rx_status_destroy (struct mlx5e_ipsec *ipsec, -struct mlx5e_ipsec_rx *rx); -int mlx5_esw_ipsec_rx_status_create (struct mlx5e_ipsec *ipsec, -struct mlx5e_ipsec_rx *rx, -struct mlx5_flow_destination *dest);void mlx5_esw_ipsec_rx_create_attr_set (struct mlx5e_ipsec *ipsec,struct mlx5e_ipsec_rx_create_attr *attr); int mlx5_esw_ipsec_rx_status_pass_dest_get(struct mlx5e_ipsec *ipsec,
@@ -26,16 +21,6 @@ void mlx5_esw_ipsec_tx_create_attr_set(struct mlx5e_ipsec *ipsec, struct mlx5e_ipsec_tx_create_attr *attr);void mlx5_esw_ipsec_restore_dest_uplink (struct mlx5_core_dev *mdev);#else -static inline void mlx5_esw_ipsec_rx_status_destroy (struct mlx5e_ipsec *ipsec, -struct mlx5e_ipsec_rx *rx) {} - -static inline int mlx5_esw_ipsec_rx_status_create (struct mlx5e_ipsec *ipsec, -struct mlx5e_ipsec_rx *rx, -struct mlx5_flow_destination *dest) -{ -return -EINVAL ; -} -static inline void mlx5_esw_ipsec_rx_create_attr_set (struct mlx5e_ipsec *ipsec,struct mlx5e_ipsec_rx_create_attr *attr) {}
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainercover 6.6.8-rc1 review
This is the start of the stable review cycle for the 6.6.8 release. There are 166 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 20 Dec 2023 13:50:31 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.8-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.6.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 6.6.8-rc1
Patrisious Haddad <[email protected]>
RDMA/mlx5: Change the key being sent for MPV device affiliation
Fangrui Song <[email protected]>
x86/speculation, objtool: Use absolute relocations for annotations
Steven Rostedt (Google) <[email protected]>
ring-buffer: Have rb_time_cmpxchg() set the msb counter too
Steven Rostedt (Google) <[email protected]>
ring-buffer: Do not try to put back write_stamp
Steven Rostedt (Google) <[email protected]>
ring-buffer: Fix a race in rb_time_cmpxchg() for 32 bit archs
Steven Rostedt (Google) <[email protected]>
ring-buffer: Fix writing to the buffer with max_data_size
Steven Rostedt (Google) <[email protected]>
ring-buffer: Have saved event hold the entire event
Steven Rostedt (Google) <[email protected]>
ring-buffer: Do not update before stamp when switching sub-buffers
Steven Rostedt (Google) <[email protected]>
tracing: Update snapshot buffer on resize if it is allocated
Steven Rostedt (Google) <[email protected]>
ring-buffer: Fix memory leak of free page
Paulo Alcantara <[email protected]>
smb: client: fix OOB in smb2_query_reparse_point()
Paulo Alcantara <[email protected]>
smb: client: fix NULL deref in asn1_ber_decoder()
Paulo Alcantara <[email protected]>
smb: client: fix potential OOBs in smb2_parse_contexts()
Paulo Alcantara <[email protected]>
smb: client: fix OOB in receive_encrypted_standard()
Ville Syrjälä <[email protected]>
drm/i915: Fix remapped stride with CCS on ADL+
Ville Syrjälä <[email protected]>
drm/i915: Fix intel_atomic_setup_scalers() plane_state handling
Ville Syrjälä <[email protected]>
drm/i915: Fix ADL+ tiled plane stride when the POT stride is smaller than the original
Mario Limonciello <[email protected]>
drm/amd/display: Disable PSR-SU on Parade 0803 TCON again
Mario Limonciello <[email protected]>
drm/amd/display: Restore guard against default backlight value < 1 nit
Jani Nikula <[email protected]>
drm/edid: also call add modes in EDID connector update fallback
Christian König <[email protected]>
drm/amdgpu: fix tear down order in amdgpu_vm_pt_free
Boris Burkov <[email protected]>
btrfs: don't clear qgroup reserved bit in release_folio
Boris Burkov <[email protected]>
btrfs: fix qgroup_free_reserved_data int overflow
Boris Burkov <[email protected]>
btrfs: free qgroup reserve when ORDERED_IOERR is set
Ignat Korchagin <[email protected]>
kexec: drop dependency on ARCH_SUPPORTS_KEXEC from CRASH_DUMP
David Stevens <[email protected]>
mm/shmem: fix race in shmem_undo_range w/THP
Yu Zhao <[email protected]>
mm/mglru: reclaim offlined memcgs harder
Yu Zhao <[email protected]>
mm/mglru: respect min_ttl_ms with memcgs
Yu Zhao <[email protected]>
mm/mglru: try to stop at high watermarks
Yu Zhao <[email protected]>
mm/mglru: fix underprotected page cache
Frank Li <[email protected]>
dmaengine: fsl-edma: fix DMA channel leak in eDMAv4
Amelie Delaunay <[email protected]>
dmaengine: stm32-dma: avoid bitfield overflow assertion
Stuart Lee <[email protected]>
drm/mediatek: Fix access violation in mtk_drm_crtc_dma_dev_get
Alex Deucher <[email protected]>
drm/amdgpu/sdma5.2: add begin/end_use ring callbacks
Florent Revest <[email protected]>
team: Fix use-after-free when an option instance allocation fails
James Houghton <[email protected]>
arm64: mm: Always make sw-dirty PTEs hw-dirty in pte_modify
John Hubbard <[email protected]>
Revert "selftests: error out if kernel header files are not yet built"
Baokun Li <[email protected]>
ext4: prevent the normalized size from exceeding EXT_MAX_BLOCKS
Krzysztof Kozlowski <[email protected]>
soundwire: stream: fix NULL pointer dereference for multi_link
Dan Williams <[email protected]>
cxl/hdm: Fix dpa translation locking
Josef Bacik <[email protected]>
btrfs: do not allow non subvolume root targets for snapshot
Mark Rutland <[email protected]>
perf: Fix perf_event_validate_size() lockdep splat
Denis Benato <[email protected]>
HID: hid-asus: add const to read-only outgoing usb buffer
Masahiro Yamada <[email protected]>
arm64: add dependency between vmlinuz.efi and Image
Paulo Alcantara <[email protected]>
smb: client: set correct file type from NFS reparse points
Paulo Alcantara <[email protected]>
smb: client: introduce ->parse_reparse_point()
Paulo Alcantara <[email protected]>
smb: client: implement ->query_reparse_point() for SMB1
Lech Perczak <[email protected]>
net: usb: qmi_wwan: claim interface 4 for ZTE MF290
Steven Rostedt (Google) <[email protected]>
eventfs: Do not allow NULL parent to eventfs_start_creating()
Linus Torvalds <[email protected]>
asm-generic: qspinlock: fix queued_spin_value_unlocked() implementation
Heiko Carstens <[email protected]>
scripts/checkstack.pl: match all stack sizes for s390
Nguyen Dinh Phi <[email protected]>
nfc: virtual_ncidev: Add variable to check if ndev is running
Aoba K <[email protected]>
HID: multitouch: Add quirk for HONOR GLO-GXXX touchpad
Denis Benato <[email protected]>
HID: hid-asus: reset the backlight brightness level on resume
Li Nan <[email protected]>
nbd: pass nbd_sock to nbd_read_reply() instead of index
Oliver Neukum <[email protected]>
HID: add ALWAYS_POLL quirk for Apple kb
Brett Raye <[email protected]>
HID: glorious: fix Glorious Model I HID report
Yihong Cao <[email protected]>
HID: apple: add Jamesdonkey and A3R to non-apple keyboards list
Hamish Martin <[email protected]>
HID: mcp2221: Allow IO to start during probe
Hamish Martin <[email protected]>
HID: mcp2221: Set driver data before I2C adapter add
Andy Shevchenko <[email protected]>
platform/x86: intel_telemetry: Fix kernel doc descriptions
Bibo Mao <[email protected]>
LoongArch: Implement constant timer shutdown interface
Huacai Chen <[email protected]>
LoongArch: Mark {dmw,tlb}_virt_to_page() exports as non-GPL
Huacai Chen <[email protected]>
LoongArch: Silence the boot warning about 'nokaslr'
WANG Rui <[email protected]>
LoongArch: Record pc instead of offset in la_abs relocation
Masahiro Yamada <[email protected]>
LoongArch: Add dependency between vmlinuz.efi and vmlinux.efi
Eduard Zingerman <[email protected]>
selftests/bpf: fix bpf_loop_bench for new callback verification scheme
Hannes Reinecke <[email protected]>
nvme: catch errors from nvme_configure_metadata()
Mark O'Donovan <[email protected]>
nvme-auth: set explanation code for failure2 msgs
Li Nan <[email protected]>
nbd: fix null-ptr-dereference while accessing 'nbd->config'
Li Nan <[email protected]>
nbd: factor out a helper to get nbd_config without holding 'config_lock'
Li Nan <[email protected]>
nbd: fold nbd config initialization into nbd_alloc_config()
Coly Li <[email protected]>
bcache: avoid NULL checking to c->root in run_cache_set()
Coly Li <[email protected]>
bcache: add code comments for bch_btree_node_get() and __bch_btree_node_alloc()
Colin Ian King <[email protected]>
bcache: remove redundant assignment to variable cur_idx
Coly Li <[email protected]>
bcache: avoid oversize memory allocation by small stripe_size
Ming Lei <[email protected]>
blk-cgroup: bypass blkcg_deactivate_policy after destroying
Ming Lei <[email protected]>
blk-throttle: fix lockdep warning of "cgroup_mutex or RCU read lock required!"
David Howells <[email protected]>
rxrpc: Fix some minor issues with bundle tracing
Jean Delvare <[email protected]>
stmmac: dwmac-loongson: Add architecture dependency
Oliver Neukum <[email protected]>
usb: aqc111: check packet for fixup for true limit
Saurabh Sengar <[email protected]>
x86/hyperv: Fix the detection of E820_TYPE_PRAM in a Gen2 VM
David Hildenbrand <[email protected]>
selftests/mm: cow: print ksft header before printing anything else
Tvrtko Ursulin <[email protected]>
drm/i915: Use internal class when counting engine resets
Tvrtko Ursulin <[email protected]>
drm/i915/selftests: Fix engine reset count storage for multi-tile
Andrzej Kacprowski <[email protected]>
accel/ivpu/37xx: Fix interrupt_clear_with_0 WA initialization
Stanislaw Gruszka <[email protected]>
accel/ivpu: Print information about used workarounds
Jason-JH.Lin <[email protected]>
drm/mediatek: Add spinlock for setting vblank event in atomic_begin
Michael Walle <[email protected]>
drm/mediatek: fix kernel oops if no crtc is found
Johan Hovold <[email protected]>
PCI: vmd: Fix potential deadlock when enabling ASPM
Namjae Jeon <[email protected]>
ksmbd: fix wrong name of SMB2_CREATE_ALLOCATION_SIZE
Johan Hovold <[email protected]>
PCI/ASPM: Add pci_enable_link_state_locked()
Jiaxun Yang <[email protected]>
PCI: loongson: Limit MRRS to 256
Bjorn Helgaas <[email protected]>
Revert "PCI: acpiphp: Reassign resources on bridge if necessary"
Gergo Koteles <[email protected]>
ALSA: hda/tas2781: reset the amp before component_add
Gergo Koteles <[email protected]>
ALSA: hda/tas2781: call cleanup functions only once
Gergo Koteles <[email protected]>
ALSA: hda/tas2781: handle missing EFI calibration data
Gergo Koteles <[email protected]>
ALSA: hda/tas2781: leave hda_component in usable state
Hartmut Knaack <[email protected]>
ALSA: hda/realtek: Apply mute LED quirk for HP15-db
Kai Vehmanen <[email protected]>
ALSA: hda/hdmi: add force-connect quirks for ASUSTeK Z170 variants
Kai Vehmanen <[email protected]>
ALSA: hda/hdmi: add force-connect quirk for NUC5CPYB
Al Viro <[email protected]>
io_uring/cmd: fix breakage in SOCKET_URING_OP_SIOC* implementation
Hangyu Hua <[email protected]>
fuse: dax: set fc->dax to NULL in fuse_dax_conn_free()
Amir Goldstein <[email protected]>
fuse: disable FOPEN_PARALLEL_DIRECT_WRITES with FUSE_DIRECT_IO_ALLOW_MMAP
Krister Johansen <[email protected]>
fuse: share lookup state between submount and its parent
Tyler Fanelli <[email protected]>
fuse: Rename DIRECT_IO_RELAX to DIRECT_IO_ALLOW_MMAP
Sebastian Parschauer <[email protected]>
HID: Add quirk for Labtec/ODDOR/aikeec handbrake
Mario Limonciello <[email protected]>
HID: i2c-hid: Add IDEA5002 to i2c_hid_acpi_blacklist[]
Jens Axboe <[email protected]>
cred: get rid of CONFIG_DEBUG_CREDENTIALS
Jens Axboe <[email protected]>
cred: switch to using atomic_long_t
Igor Russkikh <[email protected]>
net: atlantic: fix double free in ring reinit logic
Hyunwoo Kim <[email protected]>
appletalk: Fix Use-After-Free in atalk_ioctl
Andrew Halaney <[email protected]>
net: stmmac: Handle disabled MDIO busses from devicetree
Sneh Shah <[email protected]>
net: stmmac: dwmac-qcom-ethqos: Fix drops in 10M SGMII RX
Ioana Ciornei <[email protected]>
dpaa2-switch: do not ask for MDB, VLAN and FDB replay
Ioana Ciornei <[email protected]>
dpaa2-switch: fix size of the dma_unmap
Nikolay Kuratov <[email protected]>
vsock/virtio: Fix unsigned integer wrap around in virtio_transport_has_space()
Yusong Gao <[email protected]>
sign-file: Fix incorrect return values check
Yanteng Si <[email protected]>
stmmac: dwmac-loongson: Make sure MDIO is initialized before use
David Arinzon <[email protected]>
net: ena: Fix XDP redirection error
David Arinzon <[email protected]>
net: ena: Fix DMA syncing in XDP path when SWIOTLB is on
David Arinzon <[email protected]>
net: ena: Fix xdp drops handling due to multibuf packets
David Arinzon <[email protected]>
net: ena: Destroy correct number of xdp queues upon failure
Dong Chenchen <[email protected]>
net: Remove acked SYN flag from packet in the transmit queue correctly
Dinghao Liu <[email protected]>
qed: Fix a potential use-after-free in qed_cxt_tables_alloc
Slawomir Laba <[email protected]>
iavf: Fix iavf_shutdown to call iavf_remove instead iavf_close
Piotr Gardocki <[email protected]>
iavf: Handle ntuple on/off based on new state machines for flow director
Piotr Gardocki <[email protected]>
iavf: Introduce new state machines for flow director
Hyunwoo Kim <[email protected]>
net/rose: Fix Use-After-Free in rose_ioctl
Hyunwoo Kim <[email protected]>
atm: Fix Use-After-Free in do_vcc_ioctl
Hariprasad Kelam <[email protected]>
octeontx2-af: Fix pause frame configuration
Hariprasad Kelam <[email protected]>
octeontx2-af: Update RSS algorithm index
Hariprasad Kelam <[email protected]>
octeontx2-pf: Fix promisc mcam entry action
Shinas Rasheed <[email protected]>
octeon_ep: explicitly test for firmware ready value
Vlad Buslov <[email protected]>
net/sched: act_ct: Take per-cb reference to tcf_ct_flow_table
Zhipeng Lu <[email protected]>
octeontx2-af: fix a use-after-free in rvu_nix_register_reporters
Radu Bulie <[email protected]>
net: fec: correct queue selection
Chengfeng Ye <[email protected]>
atm: solos-pci: Fix potential deadlock on &tx_queue_lock
Chengfeng Ye <[email protected]>
atm: solos-pci: Fix potential deadlock on &cli_queue_lock
Michael Chan <[email protected]>
bnxt_en: Fix HWTSTAMP_FILTER_ALL packet timestamp logic
Kalesh AP <[email protected]>
bnxt_en: Fix wrong return value check in bnxt_close_nic()
Sreekanth Reddy <[email protected]>
bnxt_en: Fix skb recycling logic in bnxt_deliver_skb()
Somnath Kotur <[email protected]>
bnxt_en: Clear resource reservation during resume
Stefan Wahren <[email protected]>
qca_spi: Fix reset behavior
Stefan Wahren <[email protected]>
qca_debug: Fix ethtool -G iface tx behavior
Stefan Wahren <[email protected]>
qca_debug: Prevent crash on TX ring changes
Maciej Żenczykowski <[email protected]>
net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX
Dan Carpenter <[email protected]>
net/mlx5: Fix a NULL vs IS_ERR() check
Gavin Li <[email protected]>
net/mlx5e: Check netdev pointer before checking its net ns
Moshe Shemesh <[email protected]>
net/mlx5: Nack sync reset request when HotPlug is enabled
Chris Mi <[email protected]>
net/mlx5e: TC, Don't offload post action rule if not supported
Moshe Shemesh <[email protected]>
net/mlx5e: Fix possible deadlock on mlx5e_tx_timeout_work
Chris Mi <[email protected]>
net/mlx5e: Disable IPsec offload support if not FW steering
Patrisious Haddad <[email protected]>
RDMA/mlx5: Send events from IB driver about device affiliation state
Jianbo Liu <[email protected]>
net/mlx5e: Check the number of elements before walk TC rhashtable
Jianbo Liu <[email protected]>
net/mlx5e: Reduce eswitch mode_lock protection context
Leon Romanovsky <[email protected]>
net/mlx5e: Tidy up IPsec NAT-T SA discovery
Patrisious Haddad <[email protected]>
net/mlx5e: Unify esw and normal IPsec status table creation/destruction
Leon Romanovsky <[email protected]>
net/mlx5e: Ensure that IPsec sequence packet number starts from 1
Leon Romanovsky <[email protected]>
net/mlx5e: Honor user choice of IPsec replay window size
Mikhail Khvainitski <[email protected]>
HID: lenovo: Restrict detection of patched firmware only to USB cptkbd
David Howells <[email protected]>
afs: Fix refcount underflow from error handling race
Ard Biesheuvel <[email protected]>
efi/x86: Avoid physical KASLR on older Dell systems
Zizhi Wo <[email protected]>
ksmbd: fix memory leak in smb2_lock()
Jan Kara <[email protected]>
ext4: fix warning in ext4_dio_write_end_io()
Kelly Kane <[email protected]>
r8152: add vendor/device ID pair for ASUS USB-C2500
-------------
Diffstat:
Makefile | 4 +- arch/arm64/Makefile | 2 +- arch/arm64/include/asm/pgtable.h | 6 + arch/loongarch/Makefile | 2 + arch/loongarch/include/asm/asmmacro.h | 3 +- arch/loongarch/include/asm/setup.h | 2 +- arch/loongarch/kernel/relocate.c | 10 +- arch/loongarch/kernel/time.c | 27 +-- arch/loongarch/mm/pgtable.c | 4 +- arch/powerpc/configs/skiroot_defconfig | 1 - arch/riscv/Kconfig | 4 +- arch/riscv/kernel/crash_core.c | 4 +- arch/s390/configs/debug_defconfig | 1 - arch/x86/hyperv/hv_init.c | 25 ++- arch/x86/include/asm/alternative.h | 4 +- arch/x86/include/asm/nospec-branch.h | 4 +- block/blk-cgroup.c | 13 ++ block/blk-throttle.c | 2 + drivers/accel/ivpu/ivpu_drv.h | 5 + drivers/accel/ivpu/ivpu_hw_37xx.c | 17 +- drivers/accel/ivpu/ivpu_hw_40xx.c | 4 + drivers/atm/solos-pci.c | 8 +- drivers/block/nbd.c | 117 ++++++---- drivers/cxl/core/hdm.c | 3 +- drivers/cxl/core/port.c | 4 +- drivers/dma/fsl-edma-common.c | 1 + drivers/dma/stm32-dma.c | 8 +- drivers/firmware/efi/libstub/x86-stub.c | 31 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 3 +- drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 28 +++ .../dc/link/protocols/link_edp_panel_control.c | 4 +- .../drm/amd/display/modules/power/power_helpers.c | 2 + drivers/gpu/drm/drm_edid.c | 3 +- drivers/gpu/drm/i915/display/intel_fb.c | 19 +- drivers/gpu/drm/i915/display/skl_scaler.c | 2 +- drivers/gpu/drm/i915/gt/intel_reset.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 5 +- drivers/gpu/drm/i915/i915_gpu_error.h | 12 +- drivers/gpu/drm/i915/selftests/igt_live_test.c | 9 +- drivers/gpu/drm/i915/selftests/igt_live_test.h | 3 +- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 14 +- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 +- drivers/hid/hid-apple.c | 2 + drivers/hid/hid-asus.c | 27 ++- drivers/hid/hid-glorious.c | 16 +- drivers/hid/hid-ids.h | 12 +- drivers/hid/hid-lenovo.c | 3 +- drivers/hid/hid-mcp2221.c | 4 +- drivers/hid/hid-multitouch.c | 5 + drivers/hid/hid-quirks.c | 2 + drivers/hid/i2c-hid/i2c-hid-acpi.c | 5 + drivers/infiniband/hw/mlx5/main.c | 17 ++ drivers/md/bcache/bcache.h | 1 + drivers/md/bcache/btree.c | 7 + drivers/md/bcache/super.c | 4 +- drivers/md/bcache/writeback.c | 2 +- drivers/net/ethernet/amazon/ena/ena_eth_com.c | 3 - drivers/net/ethernet/amazon/ena/ena_netdev.c | 53 +++-- drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 5 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 38 +++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 10 +- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 11 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 19 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 5 +- .../ethernet/freescale/dpaa2/dpaa2-switch-flower.c | 7 +- .../net/ethernet/freescale/dpaa2/dpaa2-switch.c | 11 +- drivers/net/ethernet/freescale/fec_main.c | 27 +-- drivers/net/ethernet/intel/iavf/iavf.h | 1 + drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 27 ++- drivers/net/ethernet/intel/iavf/iavf_fdir.h | 15 +- drivers/net/ethernet/intel/iavf/iavf_main.c | 179 ++++++++++----- drivers/net/ethernet/intel/iavf/iavf_virtchnl.c | 71 +++++- .../net/ethernet/marvell/octeon_ep/octep_main.c | 3 +- drivers/net/ethernet/marvell/octeontx2/af/rpm.c | 11 +- .../ethernet/marvell/octeontx2/af/rvu_devlink.c | 5 +- .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 55 ++++- .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 25 ++- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + .../ethernet/mellanox/mlx5/core/en/tc/post_act.c | 6 + .../ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 56 +++-- .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 222 +++++++++++++----- .../mellanox/mlx5/core/en_accel/ipsec_offload.c | 10 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 27 ++- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 25 ++- .../net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c | 154 +------------ .../net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.h | 15 -- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 35 +-- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 2 + .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 56 +++-- drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 29 +++ drivers/net/ethernet/mellanox/mlx5/core/main.c | 6 + drivers/net/ethernet/qlogic/qed/qed_cxt.c | 1 + drivers/net/ethernet/qualcomm/qca_debug.c | 17 +- drivers/net/ethernet/qualcomm/qca_spi.c | 20 +- drivers/net/ethernet/stmicro/stmmac/Kconfig | 2 +- .../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 14 +- .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 10 + drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 6 +- drivers/net/team/team.c | 4 +- drivers/net/usb/aqc111.c | 8 +- drivers/net/usb/qmi_wwan.c | 1 + drivers/net/usb/r8152.c | 1 + drivers/nfc/virtual_ncidev.c | 7 +- drivers/nvme/host/auth.c | 2 + drivers/nvme/host/core.c | 19 +- drivers/pci/controller/pci-loongson.c | 46 +++- drivers/pci/controller/vmd.c | 2 +- drivers/pci/hotplug/acpiphp_glue.c | 9 +- drivers/pci/pcie/aspm.c | 53 +++-- drivers/platform/x86/intel/telemetry/core.c | 4 +- drivers/soundwire/stream.c | 7 +- fs/afs/rxrpc.c | 2 +- fs/btrfs/delalloc-space.c | 2 +- fs/btrfs/extent_io.c | 3 +- fs/btrfs/file.c | 2 +- fs/btrfs/inode.c | 16 +- fs/btrfs/ioctl.c | 9 + fs/btrfs/ordered-data.c | 11 +- fs/btrfs/qgroup.c | 25 ++- fs/btrfs/qgroup.h | 4 +- fs/ext4/file.c | 14 +- fs/ext4/mballoc.c | 4 + fs/fuse/dax.c | 1 + fs/fuse/file.c | 8 +- fs/fuse/fuse_i.h | 19 +- fs/fuse/inode.c | 81 ++++++- fs/nfsd/auth.c | 4 - fs/nfsd/nfssvc.c | 1 - fs/nfsd/vfs.c | 9 +- fs/open.c | 3 - fs/smb/client/cached_dir.c | 17 +- fs/smb/client/cifsglob.h | 14 +- fs/smb/client/cifspdu.h | 4 +- fs/smb/client/cifsproto.h | 11 +- fs/smb/client/cifssmb.c | 191 +++++++--------- fs/smb/client/inode.c | 74 ++++-- fs/smb/client/readdir.c | 6 +- fs/smb/client/smb1ops.c | 73 ++---- fs/smb/client/smb2inode.c | 2 +- fs/smb/client/smb2misc.c | 26 +-- fs/smb/client/smb2ops.c | 176 ++++++++------- fs/smb/client/smb2pdu.c | 95 ++++---- fs/smb/client/smb2proto.h | 12 +- fs/smb/common/smb2pdu.h | 2 +- fs/smb/server/smb2pdu.c | 1 + fs/tracefs/inode.c | 13 +- include/asm-generic/qspinlock.h | 2 +- include/linux/cred.h | 58 +---- include/linux/mlx5/device.h | 2 + include/linux/mlx5/driver.h | 2 + include/linux/mlx5/mlx5_ifc.h | 9 +- include/linux/mm_inline.h | 23 +- include/linux/mmzone.h | 34 +-- include/linux/objtool.h | 10 +- include/linux/pci.h | 3 + include/linux/usb/r8152.h | 1 + include/net/addrconf.h | 12 +- include/net/if_inet6.h | 4 - include/net/netfilter/nf_flow_table.h | 10 + include/uapi/linux/fuse.h | 10 +- io_uring/uring_cmd.c | 2 +- kernel/Kconfig.kexec | 1 - kernel/cred.c | 248 +++------------------ kernel/events/core.c | 10 + kernel/exit.c | 3 - kernel/trace/ring_buffer.c | 58 ++--- kernel/trace/trace.c | 4 +- lib/Kconfig.debug | 15 -- mm/shmem.c | 19 +- mm/vmscan.c | 92 +++++--- mm/workingset.c | 6 +- net/appletalk/ddp.c | 9 +- net/atm/ioctl.c | 7 +- net/ipv4/tcp_output.c | 6 + net/ipv6/addrconf.c | 6 +- net/rose/af_rose.c | 4 +- net/rxrpc/conn_client.c | 7 +- net/sched/act_ct.c | 34 ++- net/sunrpc/auth.c | 3 - net/vmw_vsock/virtio_transport_common.c | 2 +- scripts/checkstack.pl | 3 +- scripts/sign-file.c | 12 +- security/selinux/hooks.c | 6 - sound/pci/hda/patch_hdmi.c | 3 + sound/pci/hda/patch_realtek.c | 1 + sound/pci/hda/tas2781_hda_i2c.c | 21 +- tools/objtool/noreturns.h | 1 - tools/testing/selftests/Makefile | 21 +- tools/testing/selftests/bpf/config.x86_64 | 1 - tools/testing/selftests/bpf/progs/bpf_loop_bench.c | 13 +- tools/testing/selftests/hid/config.common | 1 - tools/testing/selftests/lib.mk | 40 +--- tools/testing/selftests/mm/cow.c | 3 +- 194 files changed, 2164 insertions(+), 1607 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 22/166 qca_debug: Fix ethtool -G iface tx behavior
6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wahren <[email protected]>
[ Upstream commit 96a7e861d9e04d07febd3011c30cd84cd141d81f ]
After calling ethtool -g it was not possible to adjust the TX ring size again:
# ethtool -g eth1 Ring parameters for eth1: Pre-set maximums: RX: 4 RX Mini: n/a RX Jumbo: n/a TX: 10 Current hardware settings: RX: 4 RX Mini: n/a RX Jumbo: n/a TX: 10 # ethtool -G eth1 tx 8 netlink error: Invalid argument
The reason for this is that the readonly setting rx_pending get initialized and after that the range check in qcaspi_set_ringparam() fails regardless of the provided parameter. So fix this by accepting the exposed RX defaults. Instead of adding another magic number better use a new define here.
--- drivers/net/ethernet/qualcomm/qca_debug.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/qualcomm/qca_debug.c +5 -3
@@ -30,6 +30,8 @@#define QCASPI_MAX_REGS 0x20 +#define QCASPI_RX_MAX_FRAMES 4 +static const u16 qcaspi_spi_regs[] = {SPI_REG_BFR_SIZE ,SPI_REG_WRBUF_SPC_AVA ,
@@ -252,9 +254,9 @@ qcaspi_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring, {struct qcaspi *qca =netdev_priv (dev); - ring->rx_max_pending =4 ; + ring->rx_max_pending =QCASPI_RX_MAX_FRAMES ; ring->tx_max_pending =TX_RING_MAX_LEN ; - ring->rx_pending =4 ; + ring->rx_pending =QCASPI_RX_MAX_FRAMES ; ring->tx_pending = qca->txr.count; }
@@ -265,7 +267,7 @@ qcaspi_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring, {struct qcaspi *qca =netdev_priv (dev); -if ((ring->rx_pending) || +if (ring->rx_pending !=QCASPI_RX_MAX_FRAMES || (ring->rx_mini_pending) || (ring->rx_jumbo_pending))return -EINVAL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 31/166 octeontx2-af: fix a use-after-free in rvu_nix_register_reporters
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhipeng Lu <[email protected]>
[ Upstream commit 28a7cb045ab700de5554193a1642917602787784 ]
The rvu_dl will be freed in rvu_nix_health_reporters_destroy(rvu_dl) after the create_workqueue fails, and after that free, the rvu_dl will be translate back through the following call chain:
rvu_nix_health_reporters_destroy
|-> rvu_nix_health_reporters_create
|-> rvu_health_reporters_create
|-> rvu_register_dl (label err_dl_health)Finally. in the err_dl_health label, rvu_dl being freed again in rvu_health_reporters_destroy(rvu) by rvu_nix_health_reporters_destroy. In the second calls of rvu_nix_health_reporters_destroy, however, it uses rvu_dl->rvu_nix_health_reporter, which is already freed at the end of rvu_nix_health_reporters_destroy in the first call.
So this patch prevents the first destroy by instantly returning -ENONMEN when create_workqueue fails. In addition, since the failure of create_workqueue is the only entrence of label err, it has been integrated into the error-handling path of create_workqueue.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +1 -4
@@ -642,7 +642,7 @@ static int rvu_nix_register_reporters(struct rvu_devlink *rvu_dl) rvu_dl->devlink_wq =create_workqueue ("rvu_devlink_wq" );if (!rvu_dl->devlink_wq) - goto err; +return -ENOMEM ;INIT_WORK (&rvu_reporters->intr_work, rvu_nix_intr_work);INIT_WORK (&rvu_reporters->gen_work, rvu_nix_gen_work);
@@ -650,9 +650,6 @@ static int rvu_nix_register_reporters(struct rvu_devlink *rvu_dl)INIT_WORK (&rvu_reporters->ras_work, rvu_nix_ras_work);return 0 ; -err: -rvu_nix_health_reporters_destroy (rvu_dl); -return -ENOMEM ; }static int rvu_nix_health_reporters_create (struct rvu_devlink *rvu_dl)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 32/166 net/sched: act_ct: Take per-cb reference to tcf_ct_flow_table
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlad Buslov <[email protected]>
[ Upstream commit 125f1c7f26ffcdbf96177abe75b70c1a6ceb17bc ]
The referenced change added custom cleanup code to act_ct to delete any callbacks registered on the parent block when deleting the tcf_ct_flow_table instance. However, the underlying issue is that the drivers don't obtain the reference to the tcf_ct_flow_table instance when registering callbacks which means that not only driver callbacks may still be on the table when deleting it but also that the driver can still have pointers to its internal nf_flowtable and can use it concurrently which results either warning in netfilter[0] or use-after-free.
Fix the issue by taking a reference to the underlying struct tcf_ct_flow_table instance when registering the callback and release the reference when unregistering. Expose new API required for such reference counting by adding two new callbacks to nf_flowtable_type and implementing them for act_ct flowtable_ct type. This fixes the issue by extending the lifetime of nf_flowtable until all users have unregistered.
[0]:
[106170.938634] ------------[ cut here ]------------ [106170.939111] WARNING: CPU: 21 PID: 3688 at include/net/netfilter/nf_flow_table.h:262 mlx5_tc_ct_del_ft_cb+0x267/0x2b0 [mlx5_core] [106170.940108] Modules linked in: act_ct nf_flow_table act_mirred act_skbedit act_tunnel_key vxlan cls_matchall nfnetlink_cttimeout act_gact cls_flower sch_ingress mlx5_vdpa vringh vhost_iotlb vdpa bonding openvswitch nsh rpcrdma rdma_ucm ib_iser libiscsi scsi_transport_iscsi ib_umad rdma_cm ib_ipoib iw_cm ib_cm mlx5_ib ib_uverbs ib_core xt_MASQUERADE nf_conntrack_netlink nfnetlink iptable_nat xt_addrtype xt_conntrack nf_nat br_netfilter rpcsec_gss_krb5 auth_rpcgss oid_regis try overlay mlx5_core [106170.943496] CPU: 21 PID: 3688 Comm: kworker/u48:0 Not tainted 6.6.0-rc7_for_upstream_min_debug_2023_11_01_13_02 #1 [106170.944361] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 [106170.945292] Workqueue: mlx5e mlx5e_rep_neigh_update [mlx5_core] [106170.945846] RIP: 0010:mlx5_tc_ct_del_ft_cb+0x267/0x2b0 [mlx5_core] [106170.946413] Code: 89 ef 48 83 05 71 a4 14 00 01 e8 f4 06 04 e1 48 83 05 6c a4 14 00 01 48 83 c4 28 5b 5d 41 5c 41 5d c3 48 83 05 d1 8b 14 00 01 <0f> 0b 48 83 05 d7 8b 14 00 01 e9 96 fe ff ff 48 83 05 a2 90 14 00 [106170.947924] RSP: 0018:ffff88813ff0fcb8 EFLAGS: 00010202 [106170.948397] RAX: 0000000000000000 RBX: ffff88811eabac40 RCX: ffff88811eabad48 [106170.949040] RDX: ffff88811eab8000 RSI: ffffffffa02cd560 RDI: 0000000000000000 [106170.949679] RBP: ffff88811eab8000 R08: 0000000000000001 R09: ffffffffa0229700 [106170.950317] R10: ffff888103538fc0 R11: 0000000000000001 R12: ffff88811eabad58 [106170.950969] R13: ffff888110c01c00 R14: ffff888106b40000 R15: 0000000000000000 [106170.951616] FS: 0000000000000000(0000) GS:ffff88885fd40000(0000) knlGS:0000000000000000 [106170.952329] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [106170.952834] CR2: 00007f1cefd28cb0 CR3: 000000012181b006 CR4: 0000000000370ea0 [106170.953482] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [106170.954121] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [106170.954766] Call Trace: [106170.955057] <TASK> [106170.955315] ? __warn+0x79/0x120 [106170.955648] ? mlx5_tc_ct_del_ft_cb+0x267/0x2b0 [mlx5_core] [106170.956172] ? report_bug+0x17c/0x190 [106170.956537] ? handle_bug+0x3c/0x60 [106170.956891] ? exc_invalid_op+0x14/0x70 [106170.957264] ? asm_exc_invalid_op+0x16/0x20 [106170.957666] ? mlx5_del_flow_rules+0x10/0x310 [mlx5_core] [106170.958172] ? mlx5_tc_ct_block_flow_offload_add+0x1240/0x1240 [mlx5_core] [106170.958788] ? mlx5_tc_ct_del_ft_cb+0x267/0x2b0 [mlx5_core] [106170.959339] ? mlx5_tc_ct_del_ft_cb+0xc6/0x2b0 [mlx5_core] [106170.959854] ? mapping_remove+0x154/0x1d0 [mlx5_core] [106170.960342] ? mlx5e_tc_action_miss_mapping_put+0x4f/0x80 [mlx5_core] [106170.960927] mlx5_tc_ct_delete_flow+0x76/0xc0 [mlx5_core] [106170.961441] mlx5_free_flow_attr_actions+0x13b/0x220 [mlx5_core] [106170.962001] mlx5e_tc_del_fdb_flow+0x22c/0x3b0 [mlx5_core] [106170.962524] mlx5e_tc_del_flow+0x95/0x3c0 [mlx5_core] [106170.963034] mlx5e_flow_put+0x73/0xe0 [mlx5_core] [106170.963506] mlx5e_put_flow_list+0x38/0x70 [mlx5_core] [106170.964002] mlx5e_rep_update_flows+0xec/0x290 [mlx5_core] [106170.964525] mlx5e_rep_neigh_update+0x1da/0x310 [mlx5_core] [106170.965056] process_one_work+0x13a/0x2c0 [106170.965443] worker_thread+0x2e5/0x3f0 [106170.965808] ? rescuer_thread+0x410/0x410 [106170.966192] kthread+0xc6/0xf0 [106170.966515] ? kthread_complete_and_exit+0x20/0x20 [106170.966970] ret_from_fork+0x2d/0x50 [106170.967332] ? kthread_complete_and_exit+0x20/0x20 [106170.967774] ret_from_fork_asm+0x11/0x20 [106170.970466] </TASK> [106170.970726] ---[ end trace 0000000000000000 ]---
--- include/net/netfilter/nf_flow_table.h | 10 ++++++++ net/sched/act_ct.c | 34 ++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 6 deletions(-)
include/net/netfilter/nf_flow_table.h +10 -0
@@ -62,6 +62,8 @@ struct nf_flowtable_type {enum flow_offload_tuple_dir dir, struct nf_flow_rule *flow_rule);void (*free)(struct nf_flowtable *ft); +void (*get)(struct nf_flowtable *ft); +void (*put)(struct nf_flowtable *ft);nf_hookfn *hook;struct module *owner; };
@@ -240,6 +242,11 @@ nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table, }list_add_tail (&block_cb->list, &block->cb_list); +up_write (&flow_table->flow_block_lock); + +if (flow_table->type->get) + flow_table->type->get (flow_table); +return 0 ; unlock:up_write (&flow_table->flow_block_lock);
@@ -262,6 +269,9 @@ nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table,WARN_ON (true); }up_write (&flow_table->flow_block_lock); + +if (flow_table->type->put) + flow_table->type->put (flow_table); } void flow_offload_route_init(struct flow_offload *flow,
net/sched/act_ct.c +28 -6
@@ -286,9 +286,31 @@ static bool tcf_ct_flow_is_outdated(const struct flow_offload *flow) !test_bit (NF_FLOW_HW_ESTABLISHED , &flow->flags); } +static void tcf_ct_flow_table_get_ref (struct tcf_ct_flow_table *ct_ft); + +static void tcf_ct_nf_get (struct nf_flowtable *ft) +{ +struct tcf_ct_flow_table *ct_ft = + container_of(ft, struct tcf_ct_flow_table, nf_ft); + +tcf_ct_flow_table_get_ref (ct_ft); +} + +static void tcf_ct_flow_table_put (struct tcf_ct_flow_table *ct_ft); + +static void tcf_ct_nf_put (struct nf_flowtable *ft) +{ +struct tcf_ct_flow_table *ct_ft = + container_of(ft, struct tcf_ct_flow_table, nf_ft); + +tcf_ct_flow_table_put (ct_ft); +} +static struct nf_flowtable_type flowtable_ct = { .gc = tcf_ct_flow_is_outdated, .action = tcf_ct_flow_table_fill_actions, + .get = tcf_ct_nf_get, + .put = tcf_ct_nf_put, .owner =THIS_MODULE , };
@@ -337,9 +359,13 @@ static int tcf_ct_flow_table_get(struct net *net, struct tcf_ct_params *params)return err; } +static void tcf_ct_flow_table_get_ref (struct tcf_ct_flow_table *ct_ft) +{ +refcount_inc (&ct_ft->ref); +} +static void tcf_ct_flow_table_cleanup_work (struct work_struct *work) { -struct flow_block_cb *block_cb, *tmp_cb;struct tcf_ct_flow_table *ct_ft;struct flow_block *block;
@@ -347,13 +373,9 @@ static void tcf_ct_flow_table_cleanup_work(struct work_struct *work) rwork);nf_flow_table_free (&ct_ft->nf_ft); -/* Remove any remaining callbacks before cleanup */ block = &ct_ft->nf_ft.flow_block;down_write (&ct_ft->nf_ft.flow_block_lock); -list_for_each_entry_safe (block_cb, tmp_cb, &block->cb_list, list) { -list_del (&block_cb->list); -flow_block_cb_free (block_cb); - } +WARN_ON (!list_empty (&block->cb_list));up_write (&ct_ft->nf_ft.flow_block_lock);kfree (ct_ft);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 33/166 octeon_ep: explicitly test for firmware ready value
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shinas Rasheed <[email protected]>
[ Upstream commit 284f717622417cb267e344a9174f8e5698d1e3c1 ]
The firmware ready value is 1, and get firmware ready status function should explicitly test for that value. The firmware ready value read will be 2 after driver load, and on unbind till firmware rewrites the firmware ready back to 0, the value seen by driver will be 2, which should be regarded as not ready.
--- drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +2 -1
@@ -1076,7 +1076,8 @@ static bool get_fw_ready_status(struct pci_dev *pdev)pci_read_config_byte (pdev, (pos +8 ), &status);dev_info (&pdev->dev,"Firmware ready status = %u\n" , status); -return status; +#define FW_STATUS_READY 1ULL +return status ==FW_STATUS_READY ; }return false; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 34/166 octeontx2-pf: Fix promisc mcam entry action
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hariprasad Kelam <[email protected]>
[ Upstream commit dbda436824ded8ef6a05bb82cd9baa8d42377a49 ]
Current implementation is such that, promisc mcam entry action is set as multicast even when there are no trusted VFs. multicast action causes the hardware to copy packet data, which reduces the performance.
This patch fixes this issue by setting the promisc mcam entry action to unicast instead of multicast when there are no trusted VFs. The same change is made for the 'allmulti' mcam entry action.
--- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +22 -3
@@ -1650,6 +1650,21 @@ static void otx2_free_hw_resources(struct otx2_nic *pf)mutex_unlock (&mbox->lock); } +static bool otx2_promisc_use_mce_list (struct otx2_nic *pfvf) +{ +int vf; + +/* The AF driver will determine whether to allow the VF netdev or not */ +if (is_otx2_vf (pfvf->pcifunc)) +return true; + +/* check if there are any trusted VFs associated with the PF netdev */ +for (vf =0 ; vf <pci_num_vf (pfvf->pdev); vf++) +if (pfvf->vf_configs[vf].trusted) +return true; +return false; +} +static void otx2_do_set_rx_mode (struct otx2_nic *pf) {struct net_device *netdev = pf->netdev;
@@ -1682,7 +1697,8 @@ static void otx2_do_set_rx_mode(struct otx2_nic *pf)if (netdev->flags & (IFF_ALLMULTI |IFF_MULTICAST )) req->mode |=NIX_RX_MODE_ALLMULTI ; - req->mode |=NIX_RX_MODE_USE_MCE ; +if (otx2_promisc_use_mce_list (pf)) + req->mode |=NIX_RX_MODE_USE_MCE ;otx2_sync_mbox_msg (&pf->mbox);mutex_unlock (&pf->mbox.lock);
@@ -2691,11 +2707,14 @@ static int otx2_ndo_set_vf_trust(struct net_device *netdev, int vf, pf->vf_configs[vf].trusted = enable; rc =otx2_set_vf_permissions (pf, vf,OTX2_TRUSTED_VF ); -if (rc) +if (rc) { pf->vf_configs[vf].trusted = !enable; -else + }else {netdev_info (pf->netdev,"VF %d is %strusted\n" , vf, enable ?"" :"not " ); +otx2_set_rx_mode (netdev); + } +return rc; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 35/166 octeontx2-af: Update RSS algorithm index
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hariprasad Kelam <[email protected]>
[ Upstream commit 570ba37898ecd9069beb58bf0b6cf84daba6e0fe ]
The RSS flow algorithm is not set up correctly for promiscuous or all multi MCAM entries. This has an impact on flow distribution.
This patch fixes the issue by updating flow algorithm index in above mentioned MCAM entries.
--- .../ethernet/marvell/octeontx2/af/rvu_npc.c | 55 +++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +44 -11
@@ -671,6 +671,7 @@ void rvu_npc_install_promisc_entry(struct rvu *rvu, u16 pcifunc,int blkaddr, ucast_idx, index;struct nix_rx_action action = {0 };u64 relaxed_mask; +u8 flow_key_alg;if (!hw->cap.nix_rx_multicast &&is_cgx_vf (rvu, pcifunc))return ;
@@ -701,6 +702,8 @@ void rvu_npc_install_promisc_entry(struct rvu *rvu, u16 pcifunc, action.op =NIX_RX_ACTIONOP_UCAST ; } + flow_key_alg = action.flow_key_alg; +/* RX_ACTION set to MCAST for CGX PF's */ if (hw->cap.nix_rx_multicast && pfvf->use_mce_list &&is_pf_cgxmapped (rvu,rvu_get_pf (pcifunc))) {
@@ -740,7 +743,7 @@ void rvu_npc_install_promisc_entry(struct rvu *rvu, u16 pcifunc, req.vf = pcifunc; req.index = action.index; req.match_id = action.match_id; - req.flow_key_alg = action.flow_key_alg; + req.flow_key_alg = flow_key_alg;rvu_mbox_handler_npc_install_flow (rvu, &req, &rsp); }
@@ -854,6 +857,7 @@ void rvu_npc_install_allmulti_entry(struct rvu *rvu, u16 pcifunc, int nixlf,u8 mac_addr[ETH_ALEN ] = {0 };struct nix_rx_action action = {0 };struct rvu_pfvf *pfvf; +u8 flow_key_alg;u16 vf_func;/* Only CGX PF/VF can add allmulticast entry */
@@ -888,6 +892,7 @@ void rvu_npc_install_allmulti_entry(struct rvu *rvu, u16 pcifunc, int nixlf, *(u64 *)&action =npc_get_mcam_action (rvu, mcam, blkaddr, ucast_idx); + flow_key_alg = action.flow_key_alg;if (action.op !=NIX_RX_ACTIONOP_RSS ) { *(u64 *)&action =0 ; action.op =NIX_RX_ACTIONOP_UCAST ;
@@ -924,7 +929,7 @@ void rvu_npc_install_allmulti_entry(struct rvu *rvu, u16 pcifunc, int nixlf, req.vf = pcifunc | vf_func; req.index = action.index; req.match_id = action.match_id; - req.flow_key_alg = action.flow_key_alg; + req.flow_key_alg = flow_key_alg;rvu_mbox_handler_npc_install_flow (rvu, &req, &rsp); }
@@ -990,11 +995,38 @@ static void npc_update_vf_flow_entry(struct rvu *rvu, struct npc_mcam *mcam,mutex_unlock (&mcam->lock); } +static void npc_update_rx_action_with_alg_idx (struct rvu *rvu,struct nix_rx_action action, +struct rvu_pfvf *pfvf,int mcam_index,int blkaddr, +int alg_idx) + +{ +struct npc_mcam *mcam = &rvu->hw->mcam; +struct rvu_hwinfo *hw = rvu->hw; +int bank, op_rss; + +if (!is_mcam_entry_enabled (rvu, mcam, blkaddr, mcam_index)) +return ; + + op_rss = (!hw->cap.nix_rx_multicast || !pfvf->use_mce_list); + + bank =npc_get_bank (mcam, mcam_index); + mcam_index &= (mcam->banksize -1 ); + +/* If Rx action is MCAST update only RSS algorithm index */ +if (!op_rss) { + *(u64 *)&action =rvu_read64 (rvu, blkaddr, +NPC_AF_MCAMEX_BANKX_ACTION (mcam_index, bank)); + + action.flow_key_alg = alg_idx; + } +rvu_write64 (rvu, blkaddr, +NPC_AF_MCAMEX_BANKX_ACTION (mcam_index, bank), *(u64 *)&action); +} +void rvu_npc_update_flowkey_alg_idx (struct rvu *rvu,u16 pcifunc,int nixlf,int group,int alg_idx,int mcam_index) {struct npc_mcam *mcam = &rvu->hw->mcam; -struct rvu_hwinfo *hw = rvu->hw;struct nix_rx_action action;int blkaddr, index, bank;struct rvu_pfvf *pfvf;
@@ -1050,15 +1082,16 @@ void rvu_npc_update_flowkey_alg_idx(struct rvu *rvu, u16 pcifunc, int nixlf,/* If PF's promiscuous entry is enabled, * Set RSS action for that entry as well */ -if ((!hw->cap.nix_rx_multicast || !pfvf->use_mce_list) && -is_mcam_entry_enabled (rvu, mcam, blkaddr, index)) { - bank =npc_get_bank (mcam, index); - index &= (mcam->banksize -1 ); +npc_update_rx_action_with_alg_idx (rvu, action, pfvf, index, blkaddr, + alg_idx); -rvu_write64 (rvu, blkaddr, -NPC_AF_MCAMEX_BANKX_ACTION (index, bank), - *(u64 *)&action); - } + index =npc_get_nixlf_mcam_index (mcam, pcifunc, + nixlf,NIXLF_ALLMULTI_ENTRY ); +/* If PF's allmulti entry is enabled, +* Set RSS action for that entry as well +*/ +npc_update_rx_action_with_alg_idx (rvu, action, pfvf, index, blkaddr, + alg_idx); } void npc_enadis_default_mce_entry(struct rvu *rvu, u16 pcifunc,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 36/166 octeontx2-af: Fix pause frame configuration
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hariprasad Kelam <[email protected]>
[ Upstream commit e307b5a845c5951dabafc48d00b6424ee64716c4 ]
The current implementation's default Pause Forward setting is causing unnecessary network traffic. This patch disables Pause Forward to address this issue.
--- drivers/net/ethernet/marvell/octeontx2/af/rpm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rpm.c +7 -4
@@ -373,6 +373,11 @@ void rpm_lmac_pause_frm_config(void *rpmd, int lmac_id, bool enable) cfg |=RPMX_MTI_MAC100X_COMMAND_CONFIG_TX_P_DISABLE ;rpm_write (rpm, lmac_id,RPMX_MTI_MAC100X_COMMAND_CONFIG , cfg); +/* Disable forward pause to driver */ + cfg =rpm_read (rpm, lmac_id,RPMX_MTI_MAC100X_COMMAND_CONFIG ); + cfg &= ~RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_FWD ; +rpm_write (rpm, lmac_id,RPMX_MTI_MAC100X_COMMAND_CONFIG , cfg); +/* Enable channel mask for all LMACS */ if (is_dev_rpm2 (rpm))rpm_write (rpm, lmac_id,RPM2_CMR_CHAN_MSK_OR ,0xffff );
@@ -616,12 +621,10 @@ int rpm_lmac_pfc_config(void *rpmd, int lmac_id, u8 tx_pause, u8 rx_pause, u16 pif (rx_pause) { cfg &= ~(RPMX_MTI_MAC100X_COMMAND_CONFIG_RX_P_DISABLE | -RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE | -RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_FWD ); +RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE ); }else { cfg |= (RPMX_MTI_MAC100X_COMMAND_CONFIG_RX_P_DISABLE | -RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE | -RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_FWD ); +RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE ); }if (tx_pause) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 37/166 atm: Fix Use-After-Free in do_vcc_ioctl
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
[ Upstream commit 24e90b9e34f9e039f56b5f25f6e6eb92cdd8f4b3 ]
Because do_vcc_ioctl() accesses sk->sk_receive_queue without holding a sk->sk_receive_queue.lock, it can cause a race with vcc_recvmsg().
A use-after-free for skb occurs with the following flow.
``` do_vcc_ioctl() -> skb_peek() vcc_recvmsg() -> skb_recv_datagram() -> skb_free_datagram() ```
Add sk->sk_receive_queue.lock to do_vcc_ioctl() to fix this issue.
--- net/atm/ioctl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/atm/ioctl.c +5 -2
@@ -73,14 +73,17 @@ static int do_vcc_ioctl(struct socket *sock, unsigned int cmd,case SIOCINQ : {struct sk_buff *skb; +int amount;if (sock->state !=SS_CONNECTED ) { error = -EINVAL ; goto done; } +spin_lock_irq (&sk->sk_receive_queue.lock); skb =skb_peek (&sk->sk_receive_queue); - error =put_user (skb ? skb->len :0 , - (int __user *)argp) ? -EFAULT :0 ; + amount = skb ? skb->len :0 ; +spin_unlock_irq (&sk->sk_receive_queue.lock); + error =put_user (amount, (int __user *)argp) ? -EFAULT :0 ; goto done; }case ATM_SETSC :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 38/166 net/rose: Fix Use-After-Free in rose_ioctl
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
[ Upstream commit 810c38a369a0a0ce625b5c12169abce1dd9ccd53 ]
Because rose_ioctl() accesses sk->sk_receive_queue without holding a sk->sk_receive_queue.lock, it can cause a race with rose_accept().
A use-after-free for skb occurs with the following flow.
``` rose_ioctl() -> skb_peek() rose_accept() -> skb_dequeue() -> kfree_skb() ```
Add sk->sk_receive_queue.lock to rose_ioctl() to fix this issue.
--- net/rose/af_rose.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/rose/af_rose.c +3 -1
@@ -1315,9 +1315,11 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)case TIOCINQ : {struct sk_buff *skb;long amount =0L ; -/* These two are safe on a single CPU system as only user tasks fiddle here */ + +spin_lock_irq (&sk->sk_receive_queue.lock);if ((skb =skb_peek (&sk->sk_receive_queue)) !=NULL ) amount = skb->len; +spin_unlock_irq (&sk->sk_receive_queue.lock);return put_user (amount, (unsigned int __user *) argp); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 39/166 iavf: Introduce new state machines for flow director
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Piotr Gardocki <[email protected]>
[ Upstream commit 3a0b5a2929fdeda63fc921c2dbed237059acf732 ]
New states introduced:
IAVF_FDIR_FLTR_DIS_REQUEST
IAVF_FDIR_FLTR_DIS_PENDING
IAVF_FDIR_FLTR_INACTIVE
Current FDIR state machines (SM) are not adequate to handle a few scenarios in the link DOWN/UP event, reset event and ntuple-feature.
For example, when VF link goes DOWN and comes back UP administratively, the expectation is that previously installed filters should also be restored. But with current SM, filters are not restored.
So with new SM, during link DOWN filters are marked as INACTIVE in the iavf list but removed from PF. After link UP, SM will transition from INACTIVE to ADD_REQUEST to restore the filter.
Similarly, with VF reset, filters will be removed from the PF, but marked as INACTIVE in the iavf list. Filters will be restored after reset completion.
Steps to reproduce:
-------------------
1. Create a VF. Here VF is enp8s0.
2. Assign IP addresses to VF and link partner and ping continuously from remote. Here remote IP is 1.1.1.1.
3. Check default RX Queue of traffic.
ethtool -S enp8s0 | grep -E "rx-[[:digit:]]+\.packets"
4. Add filter - change default RX Queue (to 15 here)
ethtool -U ens8s0 flow-type ip4 src-ip 1.1.1.1 action 15 loc 5
5. Ensure filter gets added and traffic is received on RX queue 15 now.
Link event testing:
-------------------
6. Bring VF link down and up. If traffic flows to configured queue 15, test is success, otherwise it is a failure.
Reset event testing:
--------------------
7. Reset the VF. If traffic flows to configured queue 15, test is success, otherwise it is a failure.
--- drivers/net/ethernet/intel/iavf/iavf.h | 1 + .../net/ethernet/intel/iavf/iavf_ethtool.c | 27 ++++--- drivers/net/ethernet/intel/iavf/iavf_fdir.h | 15 +++- drivers/net/ethernet/intel/iavf/iavf_main.c | 48 ++++++++++--- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 71 +++++++++++++++++-- 5 files changed, 139 insertions(+), 23 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +1 -0
@@ -303,6 +303,7 @@ struct iavf_adapter {#define IAVF_FLAG_QUEUES_DISABLED BIT(17)#define IAVF_FLAG_SETUP_NETDEV_FEATURES BIT(18)#define IAVF_FLAG_REINIT_MSIX_NEEDED BIT(20) +#define IAVF_FLAG_FDIR_ENABLED BIT(21)/* duplicates for common code */ #define IAVF_FLAG_DCB_ENABLED 0/* flags for admin queue service task */
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +18 -9
@@ -1063,7 +1063,7 @@ iavf_get_ethtool_fdir_entry(struct iavf_adapter *adapter,struct iavf_fdir_fltr *rule =NULL ;int ret =0 ; -if (!FDIR_FLTR_SUPPORT (adapter)) +if (!(adapter->flags &IAVF_FLAG_FDIR_ENABLED ))return -EOPNOTSUPP ;spin_lock_bh (&adapter->fdir_fltr_lock);
@@ -1205,7 +1205,7 @@ iavf_get_fdir_fltr_ids(struct iavf_adapter *adapter, struct ethtool_rxnfc *cmd,unsigned int cnt =0 ;int val =0 ; -if (!FDIR_FLTR_SUPPORT (adapter)) +if (!(adapter->flags &IAVF_FLAG_FDIR_ENABLED ))return -EOPNOTSUPP ; cmd->data =IAVF_MAX_FDIR_FILTERS ;
@@ -1397,7 +1397,7 @@ static int iavf_add_fdir_ethtool(struct iavf_adapter *adapter, struct ethtool_rxint count =50 ;int err; -if (!FDIR_FLTR_SUPPORT (adapter)) +if (!(adapter->flags &IAVF_FLAG_FDIR_ENABLED ))return -EOPNOTSUPP ;if (fsp->flow_type &FLOW_MAC_EXT )
@@ -1438,12 +1438,16 @@ static int iavf_add_fdir_ethtool(struct iavf_adapter *adapter, struct ethtool_rxspin_lock_bh (&adapter->fdir_fltr_lock);iavf_fdir_list_add_fltr (adapter, fltr); adapter->fdir_active_fltr++; - fltr->state =IAVF_FDIR_FLTR_ADD_REQUEST ; - adapter->aq_required |=IAVF_FLAG_AQ_ADD_FDIR_FILTER ; +if (adapter->link_up) { + fltr->state =IAVF_FDIR_FLTR_ADD_REQUEST ; + adapter->aq_required |=IAVF_FLAG_AQ_ADD_FDIR_FILTER ; + }else { + fltr->state =IAVF_FDIR_FLTR_INACTIVE ; + }spin_unlock_bh (&adapter->fdir_fltr_lock); -mod_delayed_work (adapter->wq, &adapter->watchdog_task,0 ); - +if (adapter->link_up) +mod_delayed_work (adapter->wq, &adapter->watchdog_task,0 ); ret:if (err && fltr)kfree (fltr);
@@ -1465,7 +1469,7 @@ static int iavf_del_fdir_ethtool(struct iavf_adapter *adapter, struct ethtool_rxstruct iavf_fdir_fltr *fltr =NULL ;int err =0 ; -if (!FDIR_FLTR_SUPPORT (adapter)) +if (!(adapter->flags &IAVF_FLAG_FDIR_ENABLED ))return -EOPNOTSUPP ;spin_lock_bh (&adapter->fdir_fltr_lock);
@@ -1474,6 +1478,11 @@ static int iavf_del_fdir_ethtool(struct iavf_adapter *adapter, struct ethtool_rxif (fltr->state ==IAVF_FDIR_FLTR_ACTIVE ) { fltr->state =IAVF_FDIR_FLTR_DEL_REQUEST ; adapter->aq_required |=IAVF_FLAG_AQ_DEL_FDIR_FILTER ; + }else if (fltr->state ==IAVF_FDIR_FLTR_INACTIVE ) { +list_del (&fltr->list); +kfree (fltr); + adapter->fdir_active_fltr--; + fltr =NULL ; }else { err = -EBUSY ; }
@@ -1782,7 +1791,7 @@ static int iavf_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd, ret =0 ;break ;case ETHTOOL_GRXCLSRLCNT : -if (!FDIR_FLTR_SUPPORT (adapter)) +if (!(adapter->flags &IAVF_FLAG_FDIR_ENABLED ))break ;spin_lock_bh (&adapter->fdir_fltr_lock); cmd->rule_cnt = adapter->fdir_active_fltr;
drivers/net/ethernet/intel/iavf/iavf_fdir.h +14 -1
@@ -6,12 +6,25 @@struct iavf_adapter ; -/* State of Flow Director filter */ +/* State of Flow Director filter +* +* *_REQUEST states are used to mark filter to be sent to PF driver to perform +* an action (either add or delete filter). *_PENDING states are an indication +* that request was sent to PF and the driver is waiting for response. +* +* Both DELETE and DISABLE states are being used to delete a filter in PF. +* The difference is that after a successful response filter in DEL_PENDING +* state is being deleted from VF driver as well and filter in DIS_PENDING state +* is being changed to INACTIVE state. +*/ enum iavf_fdir_fltr_state_t {IAVF_FDIR_FLTR_ADD_REQUEST ,/* User requests to add filter */ IAVF_FDIR_FLTR_ADD_PENDING ,/* Filter pending add by the PF */ IAVF_FDIR_FLTR_DEL_REQUEST ,/* User requests to delete filter */ IAVF_FDIR_FLTR_DEL_PENDING ,/* Filter pending delete by the PF */ +IAVF_FDIR_FLTR_DIS_REQUEST ,/* Filter scheduled to be disabled */ +IAVF_FDIR_FLTR_DIS_PENDING ,/* Filter pending disable by the PF */ +IAVF_FDIR_FLTR_INACTIVE ,/* Filter inactive on link down */ IAVF_FDIR_FLTR_ACTIVE ,/* Filter is active */ };
drivers/net/ethernet/intel/iavf/iavf_main.c +39 -9
71 lines not on this page · raw message
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +67 -4
118 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 40/166 iavf: Handle ntuple on/off based on new state machines for flow director
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Piotr Gardocki <[email protected]>
[ Upstream commit 09d23b8918f9ab0f8114f6b94f2faf8bde3fb52a ]
ntuple-filter feature on/off:
Default is on. If turned off, the filters will be removed from both PF and iavf list. The removal is irrespective of current filter state.
Steps to reproduce:
-------------------
1. Ensure ntuple is on.
ethtool -K enp8s0 ntuple-filters on
2. Create a filter to receive the traffic into non-default rx-queue like 15 and ensure traffic is flowing into queue into 15.
Now, turn off ntuple. Traffic should not flow to configured queue 15. It should flow to default RX queue.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 59 +++++++++++++++++++++ 1 file changed, 59 insertions(+)
drivers/net/ethernet/intel/iavf/iavf_main.c +59 -0
@@ -4409,6 +4409,49 @@ static int iavf_change_mtu(struct net_device *netdev, int new_mtu)return ret; } +/** +* iavf_disable_fdir - disable Flow Director and clear existing filters +* @adapter: board private structure +**/ +static void iavf_disable_fdir (struct iavf_adapter *adapter) +{ +struct iavf_fdir_fltr *fdir, *fdirtmp; +bool del_filters = false; + + adapter->flags &= ~IAVF_FLAG_FDIR_ENABLED ; + +/* remove all Flow Director filters */ +spin_lock_bh (&adapter->fdir_fltr_lock); +list_for_each_entry_safe (fdir, fdirtmp, &adapter->fdir_list_head, + list) { +if (fdir->state ==IAVF_FDIR_FLTR_ADD_REQUEST || + fdir->state ==IAVF_FDIR_FLTR_INACTIVE ) { +/* Delete filters not registered in PF */ +list_del (&fdir->list); +kfree (fdir); + adapter->fdir_active_fltr--; + }else if (fdir->state ==IAVF_FDIR_FLTR_ADD_PENDING || + fdir->state ==IAVF_FDIR_FLTR_DIS_REQUEST || + fdir->state ==IAVF_FDIR_FLTR_ACTIVE ) { +/* Filters registered in PF, schedule their deletion */ + fdir->state =IAVF_FDIR_FLTR_DEL_REQUEST ; + del_filters = true; + }else if (fdir->state ==IAVF_FDIR_FLTR_DIS_PENDING ) { +/* Request to delete filter already sent to PF, change +* state to DEL_PENDING to delete filter after PF's +* response, not set as INACTIVE +*/ + fdir->state =IAVF_FDIR_FLTR_DEL_PENDING ; + } + } +spin_unlock_bh (&adapter->fdir_fltr_lock); + +if (del_filters) { + adapter->aq_required |=IAVF_FLAG_AQ_DEL_FDIR_FILTER ; +mod_delayed_work (adapter->wq, &adapter->watchdog_task,0 ); + } +} +#define NETIF_VLAN_OFFLOAD_FEATURES (NETIF_F_HW_VLAN_CTAG_RX | \ NETIF_F_HW_VLAN_CTAG_TX | \ NETIF_F_HW_VLAN_STAG_RX | \
@@ -4431,6 +4474,13 @@ static int iavf_set_features(struct net_device *netdev,iavf_set_vlan_offload_features (adapter, netdev->features, features); +if ((netdev->features &NETIF_F_NTUPLE ) ^ (features &NETIF_F_NTUPLE )) { +if (features &NETIF_F_NTUPLE ) + adapter->flags |=IAVF_FLAG_FDIR_ENABLED ; +else +iavf_disable_fdir (adapter); + } +return 0 ; }
@@ -4726,6 +4776,9 @@ static netdev_features_t iavf_fix_features(struct net_device *netdev, {struct iavf_adapter *adapter =netdev_priv (netdev); +if (!FDIR_FLTR_SUPPORT (adapter)) + features &= ~NETIF_F_NTUPLE ; +return iavf_fix_netdev_vlan_features (adapter, features); }
@@ -4843,6 +4896,12 @@ int iavf_process_config(struct iavf_adapter *adapter)if (vfres->vf_cap_flags &VIRTCHNL_VF_OFFLOAD_VLAN ) netdev->features |=NETIF_F_HW_VLAN_CTAG_FILTER ; +if (FDIR_FLTR_SUPPORT (adapter)) { + netdev->hw_features |=NETIF_F_NTUPLE ; + netdev->features |=NETIF_F_NTUPLE ; + adapter->flags |=IAVF_FLAG_FDIR_ENABLED ; + } + netdev->priv_flags |=IFF_UNICAST_FLT ;/* Do not turn on offloads when they are requested to be turned off.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 23/166 qca_spi: Fix reset behavior
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wahren <[email protected]>
[ Upstream commit 1057812d146dd658c9a9a96d869c2551150207b5 ]
In case of a reset triggered by the QCA7000 itself, the behavior of the qca_spi driver was not quite correct:
- in case of a pending RX frame decoding the drop counter must be incremented and decoding state machine reseted
- also the reset counter must always be incremented regardless of sync state
--- drivers/net/ethernet/qualcomm/qca_spi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/qualcomm/qca_spi.c +7 -1
@@ -620,11 +620,17 @@ qcaspi_spi_thread(void *data)if (intr_cause &SPI_INT_CPU_ON ) {qcaspi_qca7k_sync (qca,QCASPI_EVENT_CPUON ); +/* Frame decoding in progress */ +if (qca->frm_handle.state != qca->frm_handle.init) + qca->net_dev->stats.rx_dropped++; + +qcafrm_fsm_init_spi (&qca->frm_handle); + qca->stats.device_reset++; +/* not synced. */ if (qca->sync !=QCASPI_SYNC_READY )continue ; - qca->stats.device_reset++;netif_wake_queue (qca->net_dev);netif_carrier_on (qca->net_dev); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 41/166 iavf: Fix iavf_shutdown to call iavf_remove instead iavf_close
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slawomir Laba <[email protected]>
[ Upstream commit 7ae42ef308ed0f6250b36f43e4eeb182ebbe6215 ]
Make the flow for pci shutdown be the same to the pci remove.
iavf_shutdown was implementing an incomplete version of iavf_remove. It misses several calls to the kernel like iavf_free_misc_irq, iavf_reset_interrupt_capability, iounmap that might break the system on reboot or hibernation.
Implement the call of iavf_remove directly in iavf_shutdown to close this gap.
Fixes below error messages (dmesg) during shutdown stress tests -
[685814.900917] ice 0000:88:00.0: MAC 02:d0:5f:82:43:5d does not exist for VF 0 [685814.900928] ice 0000:88:00.0: MAC 33:33:00:00:00:01 does not exist for
VF 0
Reproduction:
1. Create one VF interface:
echo 1 > /sys/class/net/<interface_name>/device/sriov_numvfs
2. Run live dmesg on the host:
dmesg -wH
3. On SUT, script below steps into vf_namespace_assignment.sh
<#!/bin/sh> // Remove <>. Git removes # line
if=<VF name> (edit this per VF name)
loop=0
while true; do
echo test round $loop
let loop++
ip netns add ns$loop
ip link set dev $if up
ip link set dev $if netns ns$loop
ip netns exec ns$loop ip link set dev $if up
ip netns exec ns$loop ip link set dev $if netns 1
ip netns delete ns$loop
done
4. Run the script for at least 1000 iterations on SUT:
./vf_namespace_assignment.sh
Expected result:
No errors in dmesg.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 72 ++++++--------------- 1 file changed, 21 insertions(+), 51 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +21 -51
@@ -277,27 +277,6 @@ void iavf_free_virt_mem(struct iavf_hw *hw, struct iavf_virt_mem *mem)kfree (mem->va); } -/** -* iavf_lock_timeout - try to lock mutex but give up after timeout -* @lock: mutex that should be locked -* @msecs: timeout in msecs -* -* Returns 0 on success, negative on failure -**/ -static int iavf_lock_timeout (struct mutex *lock,unsigned int msecs) -{ -unsigned int wait, delay =10 ; - -for (wait =0 ; wait < msecs; wait += delay) { -if (mutex_trylock (lock)) -return 0 ; - -msleep (delay); - } - -return -1 ; -} -/** * iavf_schedule_reset - Set the flags and schedule a reset event * @adapter: board private structure
@@ -4925,34 +4904,6 @@ int iavf_process_config(struct iavf_adapter *adapter)return 0 ; } -/** -* iavf_shutdown - Shutdown the device in preparation for a reboot -* @pdev: pci device structure -**/ -static void iavf_shutdown (struct pci_dev *pdev) -{ -struct iavf_adapter *adapter =iavf_pdev_to_adapter (pdev); -struct net_device *netdev = adapter->netdev; - -netif_device_detach (netdev); - -if (netif_running (netdev)) -iavf_close (netdev); - -if (iavf_lock_timeout (&adapter->crit_lock,5000 )) -dev_warn (&adapter->pdev->dev,"%s: failed to acquire crit_lock\n" , __func__); -/* Prevent the watchdog from running. */ -iavf_change_state (adapter, __IAVF_REMOVE); - adapter->aq_required =0 ; -mutex_unlock (&adapter->crit_lock); - -#ifdef CONFIG_PM -pci_save_state (pdev); - -#endif -pci_disable_device (pdev); -} -/** * iavf_probe - Device Initialization Routine * @pdev: PCI device information struct
@@ -5166,17 +5117,22 @@ static int __maybe_unused iavf_resume(struct device *dev_d)**/ static void iavf_remove (struct pci_dev *pdev) { -struct iavf_adapter *adapter =iavf_pdev_to_adapter (pdev);struct iavf_fdir_fltr *fdir, *fdirtmp;struct iavf_vlan_filter *vlf, *vlftmp;struct iavf_cloud_filter *cf, *cftmp;struct iavf_adv_rss *rss, *rsstmp;struct iavf_mac_filter *f, *ftmp; +struct iavf_adapter *adapter;struct net_device *netdev;struct iavf_hw *hw;int err; - netdev = adapter->netdev; +/* Don't proceed with remove if netdev is already freed */ + netdev =pci_get_drvdata (pdev); +if (!netdev) +return ; + + adapter =iavf_pdev_to_adapter (pdev); hw = &adapter->hw;if (test_and_set_bit (__IAVF_IN_REMOVE_TASK, &adapter->crit_section))
@@ -5304,11 +5260,25 @@ static void iavf_remove(struct pci_dev *pdev)destroy_workqueue (adapter->wq); +pci_set_drvdata (pdev,NULL ); +free_netdev (netdev);pci_disable_device (pdev); } +/** +* iavf_shutdown - Shutdown the device in preparation for a reboot +* @pdev: pci device structure +**/ +static void iavf_shutdown (struct pci_dev *pdev) +{ +iavf_remove (pdev); + +if (system_state ==SYSTEM_POWER_OFF ) +pci_set_power_state (pdev, PCI_D3hot); +} + static SIMPLE_DEV_PM_OPS(iavf_pm_ops, iavf_suspend, iavf_resume);static struct pci_driver iavf_driver = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 42/166 qed: Fix a potential use-after-free in qed_cxt_tables_alloc
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dinghao Liu <[email protected]>
[ Upstream commit b65d52ac9c085c0c52dee012a210d4e2f352611b ]
qed_ilt_shadow_alloc() will call qed_ilt_shadow_free() to free p_hwfn->p_cxt_mngr->ilt_shadow on error. However, qed_cxt_tables_alloc() accesses the freed pointer on failure of qed_ilt_shadow_alloc() through calling qed_cxt_mngr_free(), which may lead to use-after-free. Fix this issue by setting p_mngr->ilt_shadow to NULL in qed_ilt_shadow_free().
--- drivers/net/ethernet/qlogic/qed/qed_cxt.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/qlogic/qed/qed_cxt.c +1 -0
@@ -933,6 +933,7 @@ static void qed_ilt_shadow_free(struct qed_hwfn *p_hwfn) p_dma->virt_addr =NULL ; }kfree (p_mngr->ilt_shadow); + p_mngr->ilt_shadow =NULL ; } static int qed_ilt_blk_alloc(struct qed_hwfn *p_hwfn,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 43/166 net: Remove acked SYN flag from packet in the transmit queue correctly
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dong Chenchen <[email protected]>
[ Upstream commit f99cd56230f56c8b6b33713c5be4da5d6766be1f ]
syzkaller report:
kernel BUG at net/core/skbuff.c:3452!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.7.0-rc4-00009-gbee0e7762ad2-dirty #135 RIP: 0010:skb_copy_and_csum_bits (net/core/skbuff.c:3452) Call Trace: icmp_glue_bits (net/ipv4/icmp.c:357) __ip_append_data.isra.0 (net/ipv4/ip_output.c:1165) ip_append_data (net/ipv4/ip_output.c:1362 net/ipv4/ip_output.c:1341) icmp_push_reply (net/ipv4/icmp.c:370) __icmp_send (./include/net/route.h:252 net/ipv4/icmp.c:772) ip_fragment.constprop.0 (./include/linux/skbuff.h:1234 net/ipv4/ip_output.c:592 net/ipv4/ip_output.c:577) __ip_finish_output (net/ipv4/ip_output.c:311 net/ipv4/ip_output.c:295) ip_output (net/ipv4/ip_output.c:427) __ip_queue_xmit (net/ipv4/ip_output.c:535) __tcp_transmit_skb (net/ipv4/tcp_output.c:1462) __tcp_retransmit_skb (net/ipv4/tcp_output.c:3387) tcp_retransmit_skb (net/ipv4/tcp_output.c:3404) tcp_retransmit_timer (net/ipv4/tcp_timer.c:604) tcp_write_timer (./include/linux/spinlock.h:391 net/ipv4/tcp_timer.c:716)
The panic issue was trigered by tcp simultaneous initiation. The initiation process is as follows:
TCP A TCP B
1. CLOSED CLOSED
2. SYN-SENT --> <SEQ=100><CTL=SYN> ...
3. SYN-RECEIVED <-- <SEQ=300><CTL=SYN> <-- SYN-SENT
4. ... <SEQ=100><CTL=SYN> --> SYN-RECEIVED
5. SYN-RECEIVED --> <SEQ=100><ACK=301><CTL=SYN,ACK> ...
// TCP B: not send challenge ack for ack limit or packet loss // TCP A: close
tcp_close
tcp_send_fin
if (!tskb && tcp_under_memory_pressure(sk))
tskb = skb_rb_last(&sk->tcp_rtx_queue); //pick SYN_ACK packet
TCP_SKB_CB(tskb)->tcp_flags |= TCPHDR_FIN; // set FIN flag 6. FIN_WAIT_1 --> <SEQ=100><ACK=301><END_SEQ=102><CTL=SYN,FIN,ACK> ...
// TCP B: send challenge ack to SYN_FIN_ACK
7. ... <SEQ=301><ACK=101><CTL=ACK> <-- SYN-RECEIVED //challenge ack
// TCP A: <SND.UNA=101>
8. FIN_WAIT_1 --> <SEQ=101><ACK=301><END_SEQ=102><CTL=SYN,FIN,ACK> ... // retransmit panic
__tcp_retransmit_skb //skb->len=0 tcp_trim_head len = tp->snd_una - TCP_SKB_CB(skb)->seq // len=101-100 __pskb_trim_head skb->data_len -= len // skb->len=-1, wrap around ... ... ip_fragment icmp_glue_bits //BUG_ON
If we use tcp_trim_head() to remove acked SYN from packet that contains data or other flags, skb->len will be incorrectly decremented. We can remove SYN flag that has been acked from rtx_queue earlier than tcp_trim_head(), which can fix the problem mentioned above.
--- net/ipv4/tcp_output.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ipv4/tcp_output.c +6 -0
@@ -3263,7 +3263,13 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs)if (skb_still_in_host_queue (sk, skb))return -EBUSY ; +start:if (before (TCP_SKB_CB (skb)->seq, tp->snd_una)) { +if (unlikely (TCP_SKB_CB (skb)->tcp_flags &TCPHDR_SYN )) { +TCP_SKB_CB (skb)->tcp_flags &= ~TCPHDR_SYN ; +TCP_SKB_CB (skb)->seq++; + goto start; + }if (unlikely (before (TCP_SKB_CB (skb)->end_seq, tp->snd_una))) {WARN_ON_ONCE (1 );return -EINVAL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 44/166 net: ena: Destroy correct number of xdp queues upon failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Arinzon <[email protected]>
[ Upstream commit 41db6f99b5489a0d2ef26afe816ef0c6118d1d47 ]
The ena_setup_and_create_all_xdp_queues() function freed all the resources upon failure, after creating only xdp_num_queues queues, instead of freeing just the created ones.
In this patch, the only resources that are freed, are the ones allocated right before the failure occurs.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +7 -6
@@ -74,6 +74,8 @@ static void ena_unmap_tx_buff(struct ena_ring *tx_ring, struct ena_tx_buffer *tx_info);static int ena_create_io_tx_queues_in_range (struct ena_adapter *adapter,int first_index,int count); +static void ena_free_all_io_tx_resources_in_range (struct ena_adapter *adapter, +int first_index,int count);/* Increase a stat by cnt while holding syncp seqlock on 32bit machines */ static void ena_increase_stat(u64 *statp, u64 cnt,
@@ -457,23 +459,22 @@ static void ena_init_all_xdp_queues(struct ena_adapter *adapter)static int ena_setup_and_create_all_xdp_queues (struct ena_adapter *adapter) { +u32 xdp_first_ring = adapter->xdp_first_ring; +u32 xdp_num_queues = adapter->xdp_num_queues;int rc =0 ; - rc =ena_setup_tx_resources_in_range (adapter, adapter->xdp_first_ring, - adapter->xdp_num_queues); + rc =ena_setup_tx_resources_in_range (adapter, xdp_first_ring, xdp_num_queues);if (rc) goto setup_err; - rc =ena_create_io_tx_queues_in_range (adapter, - adapter->xdp_first_ring, - adapter->xdp_num_queues); + rc =ena_create_io_tx_queues_in_range (adapter, xdp_first_ring, xdp_num_queues);if (rc) goto create_err;return 0 ; create_err: -ena_free_all_io_tx_resources (adapter); +ena_free_all_io_tx_resources_in_range (adapter, xdp_first_ring, xdp_num_queues); setup_err:return rc; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 45/166 net: ena: Fix xdp drops handling due to multibuf packets
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Arinzon <[email protected]>
[ Upstream commit 505b1a88d311ff6f8c44a34f94e3be21745cce6f ]
Current xdp code drops packets larger than ENA_XDP_MAX_MTU. This is an incorrect condition since the problem is not the size of the packet, rather the number of buffers it contains.
This commit:
1. Identifies and drops XDP multi-buffer packets at the beginning of the function.
2. Increases the xdp drop statistic when this drop occurs.
3. Adds a one-time print that such drops are happening to give better indication to the user.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +10 -7
@@ -1672,20 +1672,23 @@ static void ena_set_rx_hash(struct ena_ring *rx_ring, } } -static int ena_xdp_handle_buff (struct ena_ring *rx_ring,struct xdp_buff *xdp) +static int ena_xdp_handle_buff (struct ena_ring *rx_ring,struct xdp_buff *xdp,u16 num_descs) {struct ena_rx_buffer *rx_info;int ret; +/* XDP multi-buffer packets not supported */ +if (unlikely (num_descs >1 )) { +netdev_err_once (rx_ring->adapter->netdev, +"xdp: dropped unsupported multi-buffer packets\n" ); +ena_increase_stat (&rx_ring->rx_stats.xdp_drop,1 , &rx_ring->syncp); +return ENA_XDP_DROP ; + } + rx_info = &rx_ring->rx_buffer_info[rx_ring->ena_bufs[0 ].req_id];xdp_prepare_buff (xdp,page_address (rx_info->page), rx_info->buf_offset, rx_ring->ena_bufs[0 ].len, false); -/* If for some reason we received a bigger packet than -* we expect, then we simply drop it -*/ -if (unlikely (rx_ring->ena_bufs[0 ].len >ENA_XDP_MAX_MTU )) -return ENA_XDP_DROP ; ret =ena_xdp_execute (rx_ring, xdp);
@@ -1754,7 +1757,7 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi, ena_rx_ctx.l4_proto, ena_rx_ctx.hash);if (ena_xdp_present_ring (rx_ring)) - xdp_verdict =ena_xdp_handle_buff (rx_ring, &xdp); + xdp_verdict =ena_xdp_handle_buff (rx_ring, &xdp, ena_rx_ctx.descs);/* allocate skb and fill it */ if (xdp_verdict ==ENA_XDP_PASS )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 46/166 net: ena: Fix DMA syncing in XDP path when SWIOTLB is on
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Arinzon <[email protected]>
[ Upstream commit d760117060cf2e90b5c59c5492cab179a4dbce01 ]
This patch fixes two issues:
Issue 1
-------
Description
``````````` Current code does not call dma_sync_single_for_cpu() to sync data from the device side memory to the CPU side memory before the XDP code path uses the CPU side data. This causes the XDP code path to read the unset garbage data in the CPU side memory, resulting in incorrect handling of the packet by XDP. Solution ````````
1. Add a call to dma_sync_single_for_cpu() before the XDP code starts to use the data in the CPU side memory.
2. The XDP code verdict can be XDP_PASS, in which case there is a fallback to the non-XDP code, which also calls dma_sync_single_for_cpu().
To avoid calling dma_sync_single_for_cpu() twice:
2.1. Put the dma_sync_single_for_cpu() in the code in such a place where
it happens before XDP and non-XDP code.
2.2. Remove the calls to dma_sync_single_for_cpu() in the non-XDP code
for the first buffer only (rx_copybreak and non-rx_copybreak cases), since the new call that was added covers these cases. The call to dma_sync_single_for_cpu() for the second buffer and on stays because only the first buffer is handled by the newly added dma_sync_single_for_cpu(). And there is no need for special handling of the second buffer and on for the XDP path since currently the driver supports only single buffer packets.
Issue 2
-------
Description
```````````
In case the XDP code forwarded the packet (ENA_XDP_FORWARDED),
ena_unmap_rx_buff_attrs() is called with attrs set to 0.
This means that before unmapping the buffer, the internal function
dma_unmap_page_attrs() will also call dma_sync_single_for_cpu() on
the whole buffer (not only on the data part of it).
This sync is both wasteful (since a sync was already explicitly
called before) and also causes a bug, which will be explained
using the below diagram.
The following diagram shows the flow of events causing the bug.
The order of events is (1)-(4) as shown in the diagram.
CPU side memory area
(3)convert_to_xdp_frame() initializes the
headroom with xdpf metadata
||
\/
___________________________________
| |
0 | V 4K
---------------------------------------------------------------------
| xdpf->data | other xdpf | < data > | tailroom ||...|
| | fields | | GARBAGE || |
---------------------------------------------------------------------
/\ /\
|| ||
(4)ena_unmap_rx_buff_attrs() calls (2)dma_sync_single_for_cpu()
dma_sync_single_for_cpu() on the copies data from device
whole buffer page, overwriting side to CPU side memory
the xdpf->data with GARBAGE. ||
0 4K
---------------------------------------------------------------------
| headroom | < data > | tailroom ||...|
| GARBAGE | | GARBAGE || |
---------------------------------------------------------------------
Device side memory area /\
||
(1) device writes RX packet data
After the call to ena_unmap_rx_buff_attrs() in (4), the xdpf->data
becomes corrupted, and so when it is later accessed in
ena_clean_xdp_irq()->xdp_return_frame(), it causes a page fault,
crashing the kernel.
Solution
````````Explicitly tell ena_unmap_rx_buff_attrs() not to call dma_sync_single_for_cpu() by passing it the ENA_DMA_ATTR_SKIP_CPU_SYNC flag.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 23 ++++++++------------ 1 file changed, 9 insertions(+), 14 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +9 -14
@@ -1493,11 +1493,6 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,if (unlikely (!skb))return NULL ; -/* sync this buffer for CPU use */ -dma_sync_single_for_cpu (rx_ring->dev, -dma_unmap_addr (&rx_info->ena_buf, paddr) + pkt_offset, - len, -DMA_FROM_DEVICE );skb_copy_to_linear_data (skb, buf_addr + buf_offset, len); dma_sync_single_for_device(rx_ring->dev, dma_unmap_addr(&rx_info->ena_buf, paddr) + pkt_offset,
@@ -1516,17 +1511,10 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring, buf_len =SKB_DATA_ALIGN (len + buf_offset + tailroom); - pre_reuse_paddr =dma_unmap_addr (&rx_info->ena_buf, paddr); -/* If XDP isn't loaded try to reuse part of the RX buffer */ reuse_rx_buf_page = !is_xdp_loaded &&ena_try_rx_buf_page_reuse (rx_info, buf_len, len, pkt_offset); -dma_sync_single_for_cpu (rx_ring->dev, - pre_reuse_paddr + pkt_offset, - len, -DMA_FROM_DEVICE ); -if (!reuse_rx_buf_page)ena_unmap_rx_buff_attrs (rx_ring, rx_info,DMA_ATTR_SKIP_CPU_SYNC );
@@ -1723,6 +1711,7 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,int xdp_flags =0 ;int total_len =0 ;int xdp_verdict; +u8 pkt_offset;int rc =0 ;int i;
@@ -1749,13 +1738,19 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,/* First descriptor might have an offset set by the device */ rx_info = &rx_ring->rx_buffer_info[rx_ring->ena_bufs[0 ].req_id]; - rx_info->buf_offset += ena_rx_ctx.pkt_offset; + pkt_offset = ena_rx_ctx.pkt_offset; + rx_info->buf_offset += pkt_offset;netif_dbg (rx_ring->adapter, rx_status, rx_ring->netdev,"rx_poll: q %d got packet from ena. descs #: %d l3 proto %d l4 proto %d hash: %x\n" , rx_ring->qid, ena_rx_ctx.descs, ena_rx_ctx.l3_proto, ena_rx_ctx.l4_proto, ena_rx_ctx.hash); +dma_sync_single_for_cpu (rx_ring->dev, +dma_unmap_addr (&rx_info->ena_buf, paddr) + pkt_offset, + rx_ring->ena_bufs[0 ].len, +DMA_FROM_DEVICE ); +if (ena_xdp_present_ring (rx_ring)) xdp_verdict =ena_xdp_handle_buff (rx_ring, &xdp, ena_rx_ctx.descs);
@@ -1781,7 +1776,7 @@ static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,if (xdp_verdict &ENA_XDP_FORWARDED ) {ena_unmap_rx_buff_attrs (rx_ring, &rx_ring->rx_buffer_info[req_id], -0 ); +DMA_ATTR_SKIP_CPU_SYNC ); rx_ring->rx_buffer_info[req_id].page =NULL ; } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 47/166 net: ena: Fix XDP redirection error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Arinzon <[email protected]>
[ Upstream commit 4ab138ca0a340e6d6e7a6a9bd5004bd8f83127ca ]
When sending TX packets, the meta descriptor can be all zeroes as no meta information is required (as in XDP).
This patch removes the validity check, as when disable_meta_caching is enabled, such TX packets will be dropped otherwise.
--- drivers/net/ethernet/amazon/ena/ena_eth_com.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/ethernet/amazon/ena/ena_eth_com.c +0 -3
@@ -328,9 +328,6 @@ static int ena_com_create_and_store_tx_meta_desc(struct ena_com_io_sq *io_sq,* compare it to the stored version, just create the meta */ if (io_sq->disable_meta_caching) { -if (unlikely (!ena_tx_ctx->meta_valid)) -return -EINVAL ; - *have_meta = true;return ena_com_create_meta (io_sq, ena_meta); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 48/166 stmmac: dwmac-loongson: Make sure MDIO is initialized before use
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yanteng Si <[email protected]>
[ Upstream commit e87d3a1370ce9f04770d789bcf7cce44865d2e8d ]
Generic code will use mdio. If it is not initialized before use, the kernel will Oops.
--- .../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +6 -8
@@ -68,17 +68,15 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_idif (!plat)return -ENOMEM ; + plat->mdio_bus_data =devm_kzalloc (&pdev->dev, +sizeof (*plat->mdio_bus_data), +GFP_KERNEL ); +if (!plat->mdio_bus_data) +return -ENOMEM ; + plat->mdio_node =of_get_child_by_name (np,"mdio" );if (plat->mdio_node) {dev_info (&pdev->dev,"Found MDIO subnode\n" ); - - plat->mdio_bus_data =devm_kzalloc (&pdev->dev, -sizeof (*plat->mdio_bus_data), -GFP_KERNEL ); -if (!plat->mdio_bus_data) { - ret = -ENOMEM ; - goto err_put_node; - } plat->mdio_bus_data->needs_reset = true; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 49/166 sign-file: Fix incorrect return values check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yusong Gao <[email protected]>
[ Upstream commit 829649443e78d85db0cff0c37cadb28fbb1a5f6f ]
There are some wrong return values check in sign-file when call OpenSSL API. The ERR() check cond is wrong because of the program only check the return value is < 0 which ignored the return val is 0. For example:
1. CMS_final() return 1 for success or 0 for failure.
2. i2d_CMS_bio_stream() returns 1 for success or 0 for failure.
3. i2d_TYPEbio() return 1 for success and 0 for failure.
4. BIO_free() return 1 for success and 0 for failure.
--- scripts/sign-file.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
scripts/sign-file.c +6 -6
@@ -322,7 +322,7 @@ int main(int argc, char **argv)CMS_NOSMIMECAP | use_keyid | use_signed_attrs), "CMS_add1_signer"); -ERR (CMS_final (cms, bm,NULL ,CMS_NOCERTS |CMS_BINARY ) <0 , +ERR (CMS_final (cms, bm,NULL ,CMS_NOCERTS |CMS_BINARY ) !=1 ,"CMS_final" );#else
@@ -341,10 +341,10 @@ int main(int argc, char **argv) b =BIO_new_file (sig_file_name,"wb" );ERR (!b,"%s" , sig_file_name);#ifndef USE_PKCS7 -ERR (i2d_CMS_bio_stream (b, cms,NULL ,0 ) <0 , +ERR (i2d_CMS_bio_stream (b, cms,NULL ,0 ) !=1 ,"%s" , sig_file_name);#else -ERR (i2d_PKCS7_bio (b, pkcs7) <0 , +ERR (i2d_PKCS7_bio (b, pkcs7) !=1 ,"%s" , sig_file_name);#endif BIO_free (b);
@@ -374,9 +374,9 @@ int main(int argc, char **argv)if (!raw_sig) {#ifndef USE_PKCS7 -ERR (i2d_CMS_bio_stream (bd, cms,NULL ,0 ) <0 ,"%s" , dest_name); +ERR (i2d_CMS_bio_stream (bd, cms,NULL ,0 ) !=1 ,"%s" , dest_name);#else -ERR (i2d_PKCS7_bio (bd, pkcs7) <0 ,"%s" , dest_name); +ERR (i2d_PKCS7_bio (bd, pkcs7) !=1 ,"%s" , dest_name);#endif }else {BIO *b;
@@ -396,7 +396,7 @@ int main(int argc, char **argv)ERR (BIO_write (bd, &sig_info,sizeof (sig_info)) <0 ,"%s" , dest_name);ERR (BIO_write (bd, magic_number,sizeof (magic_number) -1 ) <0 ,"%s" , dest_name); -ERR (BIO_free (bd) <0 ,"%s" , dest_name); +ERR (BIO_free (bd) !=1 ,"%s" , dest_name);/* Finally, if we're signing in place, replace the original. */ if (replace_orig)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 50/166 vsock/virtio: Fix unsigned integer wrap around in virtio_transport_has_space()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Kuratov <[email protected]>
[ Upstream commit 60316d7f10b17a7ebb1ead0642fee8710e1560e0 ]
We need to do signed arithmetic if we expect condition if (bytes < 0) to be possible
Found by Linux Verification Center (linuxtesting.org) with SVACE
--- net/vmw_vsock/virtio_transport_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/vmw_vsock/virtio_transport_common.c +1 -1
@@ -679,7 +679,7 @@ static s64 virtio_transport_has_space(struct vsock_sock *vsk)struct virtio_vsock_sock *vvs = vsk->trans;s64 bytes; - bytes = vvs->peer_buf_alloc - (vvs->tx_cnt - vvs->peer_fwd_cnt); + bytes = (s64 )vvs->peer_buf_alloc - (vvs->tx_cnt - vvs->peer_fwd_cnt);if (bytes <0 ) bytes =0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 24/166 bnxt_en: Clear resource reservation during resume
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Somnath Kotur <[email protected]>
[ Upstream commit 9ef7c58f5abe41e6d91f37f28fe2d851ffedd92a ]
We are issuing HWRM_FUNC_RESET cmd to reset the device including all reserved resources, but not clearing the reservations within the driver struct. As a result, when the driver re-initializes as part of resume, it believes that there is no need to do any resource reservation and goes ahead and tries to allocate rings which will eventually fail beyond a certain number pre-reserved by the firmware.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -0
@@ -13897,6 +13897,8 @@ static int bnxt_resume(struct device *device)if (rc) goto resume_exit; +bnxt_clear_reservations (bp, true); +if (bnxt_hwrm_func_drv_rgtr (bp,NULL ,0 , false)) { rc = -ENODEV ; goto resume_exit;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 51/166 dpaa2-switch: fix size of the dma_unmap
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ioana Ciornei <[email protected]>
[ Upstream commit 2aad7d4189a923b24efa8ea6ad09059882b1bfe4 ]
The size of the DMA unmap was wrongly put as a sizeof of a pointer. Change the value of the DMA unmap to be the actual macro used for the allocation and the DMA map.
--- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c +4 -3
@@ -139,7 +139,8 @@ int dpaa2_switch_acl_entry_add(struct dpaa2_switch_filter_block *filter_block, err =dpsw_acl_add_entry (ethsw->mc_io,0 , ethsw->dpsw_handle, filter_block->acl_id, acl_entry_cfg); -dma_unmap_single (dev, acl_entry_cfg->key_iova,sizeof (cmd_buff), +dma_unmap_single (dev, acl_entry_cfg->key_iova, +DPAA2_ETHSW_PORT_ACL_CMD_BUF_SIZE ,DMA_TO_DEVICE );if (err) {dev_err (dev,"dpsw_acl_add_entry() failed %d\n" , err);
@@ -181,8 +182,8 @@ dpaa2_switch_acl_entry_remove(struct dpaa2_switch_filter_block *block, err =dpsw_acl_remove_entry (ethsw->mc_io,0 , ethsw->dpsw_handle, block->acl_id, acl_entry_cfg); -dma_unmap_single (dev, acl_entry_cfg->key_iova,sizeof (cmd_buff), -DMA_TO_DEVICE ); +dma_unmap_single (dev, acl_entry_cfg->key_iova, +DPAA2_ETHSW_PORT_ACL_CMD_BUF_SIZE ,DMA_TO_DEVICE );if (err) {dev_err (dev,"dpsw_acl_remove_entry() failed %d\n" , err);kfree (cmd_buff);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 25/166 bnxt_en: Fix skb recycling logic in bnxt_deliver_skb()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sreekanth Reddy <[email protected]>
[ Upstream commit aded5d1feb08e48d544845d3594d70c4d5fe6e54 ]
Receive SKBs can go through the VF-rep path or the normal path. skb_mark_for_recycle() is only called for the normal path. Fix it to do it for both paths to fix possible stalled page pool shutdown errors.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -1
@@ -1749,13 +1749,14 @@ static void bnxt_tpa_agg(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,static void bnxt_deliver_skb (struct bnxt *bp,struct bnxt_napi *bnapi,struct sk_buff *skb) { +skb_mark_for_recycle (skb); +if (skb->dev != bp->dev) {/* this packet belongs to a vf-rep */ bnxt_vf_rep_rx (bp, skb);return ; }skb_record_rx_queue (skb, bnapi->index); -skb_mark_for_recycle (skb);napi_gro_receive (&bnapi->napi, skb); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 26/166 bnxt_en: Fix wrong return value check in bnxt_close_nic()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kalesh AP <[email protected]>
[ Upstream commit bd6781c18cb5b5e5d8c5873fa9a51668e89ec76e ]
The wait_event_interruptible_timeout() function returns 0 if the timeout elapsed, -ERESTARTSYS if it was interrupted by a signal, and the remaining jiffies otherwise if the condition evaluated to true before the timeout elapsed.
Driver should have checked for zero return value instead of a positive value.
MChan: Print a warning for -ERESTARTSYS. The close operation will proceed anyway when wait_event_interruptible_timeout() returns for any reason. Since we do the close no matter what, we should not return this error code to the caller. Change bnxt_close_nic() to a void function and remove all error handling from some of the callers.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 +++++++------ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +- .../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 11 ++--------- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 19 ++++--------------- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 5 ++--- 5 files changed, 16 insertions(+), 34 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +7 -6
@@ -10704,10 +10704,8 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init,bnxt_free_mem (bp, irq_re_init); } -int bnxt_close_nic (struct bnxt *bp,bool irq_re_init,bool link_re_init) +void bnxt_close_nic (struct bnxt *bp,bool irq_re_init,bool link_re_init) { -int rc =0 ; -if (test_bit (BNXT_STATE_IN_FW_RESET , &bp->state)) {/* If we get here, it means firmware reset is in progress * while we are trying to close. We can safely proceed with
@@ -10722,15 +10720,18 @@ int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)#ifdef CONFIG_BNXT_SRIOV if (bp->sriov_cfg) { +int rc; + rc =wait_event_interruptible_timeout (bp->sriov_cfg_wait, !bp->sriov_cfg,BNXT_SRIOV_CFG_WAIT_TMO ); -if (rc) -netdev_warn (bp->dev,"timeout waiting for SRIOV config operation to complete!\n" ); +if (!rc) +netdev_warn (bp->dev,"timeout waiting for SRIOV config operation to complete, proceeding to close!\n" ); +else if (rc <0 ) +netdev_warn (bp->dev,"SRIOV config operation interrupted, proceeding to close!\n" ); }#endif __bnxt_close_nic (bp, irq_re_init, link_re_init); -return rc; }static int bnxt_close (struct net_device *dev)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -1
@@ -2362,7 +2362,7 @@ int bnxt_open_nic(struct bnxt *, bool, bool);int bnxt_half_open_nic (struct bnxt *bp);void bnxt_half_close_nic (struct bnxt *bp);void bnxt_reenable_sriov (struct bnxt *bp); -int bnxt_close_nic (struct bnxt *,bool ,bool ); +void bnxt_close_nic (struct bnxt *,bool ,bool );void bnxt_get_ring_err_stats (struct bnxt *bp,struct bnxt_total_ring_err_stats *stats); int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words,
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +2 -9
@@ -478,15 +478,8 @@ static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change,return -ENODEV ; }bnxt_ulp_stop (bp); -if (netif_running (bp->dev)) { - rc =bnxt_close_nic (bp, true, true); -if (rc) { -NL_SET_ERR_MSG_MOD (extack,"Failed to close" ); -dev_close (bp->dev); -rtnl_unlock (); -break ; - } - } +if (netif_running (bp->dev)) +bnxt_close_nic (bp, true, true);bnxt_vf_reps_free (bp); rc =bnxt_hwrm_func_drv_unrgtr (bp);if (rc) {
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +4 -15
@@ -164,9 +164,8 @@ static int bnxt_set_coalesce(struct net_device *dev, reset_coalesce:if (test_bit (BNXT_STATE_OPEN , &bp->state)) {if (update_stats) { - rc =bnxt_close_nic (bp, true, false); -if (!rc) - rc =bnxt_open_nic (bp, true, false); +bnxt_close_nic (bp, true, false); + rc =bnxt_open_nic (bp, true, false); }else { rc =bnxt_hwrm_set_coal (bp); }
@@ -955,12 +954,7 @@ static int bnxt_set_channels(struct net_device *dev,* before PF unload */ } - rc =bnxt_close_nic (bp, true, false); -if (rc) { -netdev_err (bp->dev,"Set channel failure rc :%x\n" , - rc); -return rc; - } +bnxt_close_nic (bp, true, false); }if (sh) {
@@ -3737,12 +3731,7 @@ static void bnxt_self_test(struct net_device *dev, struct ethtool_test *etest,bnxt_run_fw_tests (bp, test_mask, &test_results); }else {bnxt_ulp_stop (bp); - rc =bnxt_close_nic (bp, true, false); -if (rc) { - etest->flags |=ETH_TEST_FL_FAILED ; -bnxt_ulp_start (bp, rc); -return ; - } +bnxt_close_nic (bp, true, false);bnxt_run_fw_tests (bp, test_mask, &test_results); buf[BNXT_MACLPBK_TEST_IDX ] =1 ;
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +2 -3
@@ -521,9 +521,8 @@ static int bnxt_hwrm_ptp_cfg(struct bnxt *bp)if (netif_running (bp->dev)) {if (ptp->rx_filter ==HWTSTAMP_FILTER_ALL ) { - rc =bnxt_close_nic (bp, false, false); -if (!rc) - rc =bnxt_open_nic (bp, false, false); +bnxt_close_nic (bp, false, false); + rc =bnxt_open_nic (bp, false, false); }else {bnxt_ptp_cfg_tstamp_filters (bp); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 27/166 bnxt_en: Fix HWTSTAMP_FILTER_ALL packet timestamp logic
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Chan <[email protected]>
[ Upstream commit c13e268c0768659cdaae4bfe2fb24860bcc8ddb4 ]
When the chip is configured to timestamp all receive packets, the timestamp in the RX completion is only valid if the metadata present flag is not set for packets received on the wire. In addition, internal loopback packets will never have a valid timestamp and the timestamp field will always be zero. We must exclude any 0 value in the timestamp field because there is no way to determine if it is a loopback packet or not.
Add a new function bnxt_rx_ts_valid() to check for all timestamp valid conditions.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 20 +++++++++++++++++--- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 8 +++++++- 2 files changed, 24 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +17 -3
@@ -1760,6 +1760,21 @@ static void bnxt_deliver_skb(struct bnxt *bp, struct bnxt_napi *bnapi,napi_gro_receive (&bnapi->napi, skb); } +static bool bnxt_rx_ts_valid (struct bnxt *bp,u32 flags, +struct rx_cmp_ext *rxcmp1,u32 *cmpl_ts) +{ +u32 ts =le32_to_cpu (rxcmp1->rx_cmp_timestamp); + +if (BNXT_PTP_RX_TS_VALID (flags)) + goto ts_valid; +if (!bp->ptp_all_rx_tstamp || !ts || !BNXT_ALL_RX_TS_VALID (flags)) +return false; + +ts_valid: + *cmpl_ts = ts; +return true; +} +/* returns the following: * 1 - 1 packet successfully received * 0 - successful TPA_START, packet not completed yet
@@ -1785,6 +1800,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,struct sk_buff *skb;struct xdp_buff xdp;u32 flags, misc; +u32 cmpl_ts;void *data;int rc =0 ;
@@ -2007,10 +2023,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, } } -if (unlikely ((flags &RX_CMP_FLAGS_ITYPES_MASK ) == -RX_CMP_FLAGS_ITYPE_PTP_W_TS ) || bp->ptp_all_rx_tstamp) { +if (bnxt_rx_ts_valid (bp, flags, rxcmp1, &cmpl_ts)) {if (bp->flags &BNXT_FLAG_CHIP_P5 ) { -u32 cmpl_ts =le32_to_cpu (rxcmp1->rx_cmp_timestamp);u64 ns, ts;if (!bnxt_get_rx_ts_p5 (bp, &ts, cmpl_ts)) {
drivers/net/ethernet/broadcom/bnxt/bnxt.h +7 -1
@@ -161,7 +161,7 @@ struct rx_cmp {#define RX_CMP_FLAGS_ERROR (1 << 6)#define RX_CMP_FLAGS_PLACEMENT (7 << 7)#define RX_CMP_FLAGS_RSS_VALID (1 << 10) -#define RX_CMP_FLAGS_UNUSED (1 << 11) +#define RX_CMP_FLAGS_PKT_METADATA_PRESENT (1 << 11)#define RX_CMP_FLAGS_ITYPES_SHIFT 12#define RX_CMP_FLAGS_ITYPES_MASK 0xf000#define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12)
@@ -188,6 +188,12 @@ struct rx_cmp {__le32 rx_cmp_rss_hash; }; +#define BNXT_PTP_RX_TS_VALID (flags) \ + (((flags) & RX_CMP_FLAGS_ITYPES_MASK) == RX_CMP_FLAGS_ITYPE_PTP_W_TS) + +#define BNXT_ALL_RX_TS_VALID (flags) \ + !((flags) & RX_CMP_FLAGS_PKT_METADATA_PRESENT) +#define RX_CMP_HASH_VALID (rxcmp) \ ((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 28/166 atm: solos-pci: Fix potential deadlock on &cli_queue_lock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
[ Upstream commit d5dba32b8f6cb39be708b726044ba30dbc088b30 ]
As &card->cli_queue_lock is acquired under softirq context along the following call chain from solos_bh(), other acquisition of the same lock inside process context should disable at least bh to avoid double lock.
<deadlock #1>console_show()
--> spin_lock(&card->cli_queue_lock)
<interrupt>
--> solos_bh()
--> spin_lock(&card->cli_queue_lock)
This flaw was found by an experimental static analysis tool I am developing for irq-related deadlock.
To prevent the potential deadlock, the patch uses spin_lock_bh() on the card->cli_queue_lock under process context code consistently to prevent the possible deadlock scenario.
--- drivers/atm/solos-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/atm/solos-pci.c +2 -2
@@ -449,9 +449,9 @@ static ssize_t console_show(struct device *dev, struct device_attribute *attr,struct sk_buff *skb;unsigned int len; -spin_lock (&card->cli_queue_lock); +spin_lock_bh (&card->cli_queue_lock); skb =skb_dequeue (&card->cli_queue[SOLOS_CHAN (atmdev)]); -spin_unlock (&card->cli_queue_lock); +spin_unlock_bh (&card->cli_queue_lock);if (skb ==NULL )return sprintf (buf,"No data.\n" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 29/166 atm: solos-pci: Fix potential deadlock on &tx_queue_lock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
[ Upstream commit 15319a4e8ee4b098118591c6ccbd17237f841613 ]
As &card->tx_queue_lock is acquired under softirq context along the following call chain from solos_bh(), other acquisition of the same lock inside process context should disable at least bh to avoid double lock.
<deadlock #2>pclose()
--> spin_lock(&card->tx_queue_lock)
<interrupt>
--> solos_bh()
--> fpga_tx()
--> spin_lock(&card->tx_queue_lock)
This flaw was found by an experimental static analysis tool I am developing for irq-related deadlock.
To prevent the potential deadlock, the patch uses spin_lock_bh() on &card->tx_queue_lock under process context code consistently to prevent the possible deadlock scenario.
--- drivers/atm/solos-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/atm/solos-pci.c +2 -2
@@ -956,14 +956,14 @@ static void pclose(struct atm_vcc *vcc)struct pkt_hdr *header;/* Remove any yet-to-be-transmitted packets from the pending queue */ -spin_lock (&card->tx_queue_lock); +spin_lock_bh (&card->tx_queue_lock); skb_queue_walk_safe(&card->tx_queue[port], skb, tmpskb) {if (SKB_CB (skb)->vcc == vcc) {skb_unlink (skb, &card->tx_queue[port]);solos_pop (vcc, skb); } } -spin_unlock (&card->tx_queue_lock); +spin_unlock_bh (&card->tx_queue_lock); skb =alloc_skb (sizeof (*header),GFP_KERNEL );if (!skb) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 30/166 net: fec: correct queue selection
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Radu Bulie <[email protected]>
[ Upstream commit 9fc95fe95c3e2a63ced8eeca4b256518ab204b63 ]
The old implementation extracted VLAN TCI info from the payload before the VLAN tag has been pushed in the payload.
Another problem was that the VLAN TCI was extracted even if the packet did not have VLAN protocol header.
This resulted in invalid VLAN TCI and as a consequence a random queue was computed.
This patch fixes the above issues and use the VLAN TCI from the skb if it is present or VLAN TCI from payload if present. If no VLAN header is present queue 0 is selected.
--- drivers/net/ethernet/freescale/fec_main.c | 27 +++++++++-------------- 1 file changed, 11 insertions(+), 16 deletions(-)
drivers/net/ethernet/freescale/fec_main.c +11 -16
@@ -3710,31 +3710,26 @@ static int fec_set_features(struct net_device *netdev,return 0 ; } -static u16 fec_enet_get_raw_vlan_tci (struct sk_buff *skb) -{ -struct vlan_ethhdr *vhdr; -unsigned short vlan_TCI =0 ; - -if (skb->protocol ==htons (ETH_P_ALL )) { - vhdr = (struct vlan_ethhdr *)(skb->data); - vlan_TCI =ntohs (vhdr->h_vlan_TCI); - } - -return vlan_TCI; -} -static u16 fec_enet_select_queue (struct net_device *ndev,struct sk_buff *skb,struct net_device *sb_dev) {struct fec_enet_private *fep =netdev_priv (ndev); -u16 vlan_tag; +u16 vlan_tag =0 ;if (!(fep->quirks &FEC_QUIRK_HAS_AVB ))return netdev_pick_tx (ndev, skb,NULL ); - vlan_tag =fec_enet_get_raw_vlan_tci (skb); -if (!vlan_tag) +/* VLAN is present in the payload.*/ +if (eth_type_vlan (skb->protocol)) { +struct vlan_ethhdr *vhdr =skb_vlan_eth_hdr (skb); + + vlan_tag =ntohs (vhdr->h_vlan_TCI); +/* VLAN is present in the skb but not yet pushed in the payload.*/ + }else if (skb_vlan_tag_present (skb)) { + vlan_tag = skb->vlan_tci; + }else {return vlan_tag; + }return fec_enet_vlan_pri_to_queue[vlan_tag >>13 ]; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 21/166 qca_debug: Prevent crash on TX ring changes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wahren <[email protected]>
[ Upstream commit f4e6064c97c050bd9904925ff7d53d0c9954fc7b ]
The qca_spi driver stop and restart the SPI kernel thread (via ndo_stop & ndo_open) in case of TX ring changes. This is a big issue because it allows userspace to prevent restart of the SPI kernel thread (via signals). A subsequent change of TX ring wrongly assume a valid spi_thread pointer which result in a crash.
So prevent this by stopping the network traffic handling and temporary park the SPI thread.
--- drivers/net/ethernet/qualcomm/qca_debug.c | 9 ++++----- drivers/net/ethernet/qualcomm/qca_spi.c | 12 ++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-)
drivers/net/ethernet/qualcomm/qca_debug.c +4 -5
@@ -263,7 +263,6 @@ qcaspi_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring,struct kernel_ethtool_ringparam *kernel_ring, struct netlink_ext_ack *extack) { - const struct net_device_ops *ops = dev->netdev_ops; struct qcaspi *qca = netdev_priv(dev); if ((ring->rx_pending) ||
@@ -271,14 +270,14 @@ qcaspi_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring, (ring->rx_jumbo_pending))return -EINVAL ; -if (netif_running (dev)) - ops->ndo_stop (dev); +if (qca->spi_thread) +kthread_park (qca->spi_thread); qca->txr.count =max_t (u32, ring->tx_pending,TX_RING_MIN_LEN ); qca->txr.count =min_t (u16, qca->txr.count,TX_RING_MAX_LEN ); -if (netif_running (dev)) - ops->ndo_open (dev); +if (qca->spi_thread) +kthread_unpark (qca->spi_thread);return 0 ; }
drivers/net/ethernet/qualcomm/qca_spi.c +12 -0
@@ -580,6 +580,18 @@ qcaspi_spi_thread(void *data)netdev_info (qca->net_dev,"SPI thread created\n" );while (!kthread_should_stop ()) {set_current_state (TASK_INTERRUPTIBLE ); +if (kthread_should_park ()) { +netif_tx_disable (qca->net_dev); +netif_carrier_off (qca->net_dev); +qcaspi_flush_tx_ring (qca); +kthread_parkme (); +if (qca->sync ==QCASPI_SYNC_READY ) { +netif_carrier_on (qca->net_dev); +netif_wake_queue (qca->net_dev); + } +continue ; + } +if ((qca->intr_req == qca->intr_svc) && !qca->txr.skb[qca->txr.head])schedule ();
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 53/166 net: stmmac: dwmac-qcom-ethqos: Fix drops in 10M SGMII RX
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sneh Shah <[email protected]>
[ Upstream commit 981d947bcd382c3950a593690e0e13d194d65b1c ]
In 10M SGMII mode all the packets are being dropped due to wrong Rx clock. SGMII 10MBPS mode needs RX clock divider programmed to avoid drops in Rx. Update configure SGMII function with Rx clk divider programming.
--- .../net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +10 -0
@@ -34,6 +34,7 @@#define RGMII_CONFIG_LOOPBACK_EN BIT(2)#define RGMII_CONFIG_PROG_SWAP BIT(1)#define RGMII_CONFIG_DDR_MODE BIT(0) +#define RGMII_CONFIG_SGMII_CLK_DVDR GENMASK(18, 10)/* SDCC_HC_REG_DLL_CONFIG fields */ #define SDCC_DLL_CONFIG_DLL_RST BIT(30)
@@ -78,6 +79,8 @@#define ETHQOS_MAC_CTRL_SPEED_MODE BIT(14)#define ETHQOS_MAC_CTRL_PORT_SEL BIT(15) +#define SGMII_10M_RX_CLK_DVDR 0x31 +struct ethqos_emac_por {unsigned int offset;unsigned int value;
@@ -598,6 +601,9 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos)return 0 ; } +/* On interface toggle MAC registers gets reset. +* Configure MAC block for SGMII on ethernet phy link up +*/ static int ethqos_configure_sgmii (struct qcom_ethqos *ethqos) {int val;
@@ -617,6 +623,10 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos)case SPEED_10 : val |=ETHQOS_MAC_CTRL_PORT_SEL ; val &= ~ETHQOS_MAC_CTRL_SPEED_MODE ; +rgmii_updatel (ethqos,RGMII_CONFIG_SGMII_CLK_DVDR , +FIELD_PREP (RGMII_CONFIG_SGMII_CLK_DVDR , +SGMII_10M_RX_CLK_DVDR ), +RGMII_IO_MACRO_CONFIG );break ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 62/166 fuse: share lookup state between submount and its parent
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krister Johansen <[email protected]>
commit c4d361f66ac91db8fc65061a9671682f61f4ca9d upstream.
Fuse submounts do not perform a lookup for the nodeid that they inherit from their parent. Instead, the code decrements the nlookup on the submount's fuse_inode when it is instantiated, and no forget is performed when a submount root is evicted.
Trouble arises when the submount's parent is evicted despite the submount itself being in use. In this author's case, the submount was in a container and deatched from the initial mount namespace via a MNT_DEATCH operation. When memory pressure triggered the shrinker, the inode from the parent was evicted, which triggered enough forgets to render the submount's nodeid invalid.
Since submounts should still function, even if their parent goes away, solve this problem by sharing refcounted state between the parent and its submount. When all of the references on this shared state reach zero, it's safe to forget the final lookup of the fuse nodeid.
--- fs/fuse/fuse_i.h | 15 +++++++++++ fs/fuse/inode.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 87 insertions(+), 3 deletions(-)
fs/fuse/fuse_i.h +15 -0
@@ -63,6 +63,19 @@ struct fuse_forget_link {struct fuse_forget_link *next; }; +/* Submount lookup tracking */ +struct fuse_submount_lookup { +/** Refcount */ +refcount_t count; + +/** Unique ID, which identifies the inode between userspace +* and kernel */ +u64 nodeid; + +/** The request used for sending the FORGET message */ +struct fuse_forget_link *forget; +}; +/** FUSE inode */ struct fuse_inode {/** Inode data */
@@ -158,6 +171,8 @@ struct fuse_inode {*/ struct fuse_inode_dax *dax;#endif +/** Submount specific lookup tracking */ +struct fuse_submount_lookup *submount_lookup; };/** FUSE inode state bits */
fs/fuse/inode.c +72 -3
143 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 63/166 fuse: disable FOPEN_PARALLEL_DIRECT_WRITES with FUSE_DIRECT_IO_ALLOW_MMAP
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
commit 3f29f1c336c0e8a4bec52f1e5217f88835553e5b upstream.
The new fuse init flag FUSE_DIRECT_IO_ALLOW_MMAP breaks assumptions made by FOPEN_PARALLEL_DIRECT_WRITES and causes test generic/095 to hit BUG_ON(fi->writectr < 0) assertions in fuse_set_nowrite():
generic/095 5s ...
kernel BUG at fs/fuse/dir.c:1756!
...
? fuse_set_nowrite+0x3d/0xdd ? do_raw_spin_unlock+0x88/0x8f ? _raw_spin_unlock+0x2d/0x43 ? fuse_range_is_writeback+0x71/0x84 fuse_sync_writes+0xf/0x19 fuse_direct_io+0x167/0x5bd fuse_direct_write_iter+0xf0/0x146
Auto disable FOPEN_PARALLEL_DIRECT_WRITES when server negotiated FUSE_DIRECT_IO_ALLOW_MMAP.
--- fs/fuse/file.c | 2 ++ 1 file changed, 2 insertions(+)
fs/fuse/file.c +2 -0
@@ -1574,6 +1574,7 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from)ssize_t res;bool exclusive_lock = !(ff->open_flags &FOPEN_PARALLEL_DIRECT_WRITES ) || +get_fuse_conn (inode)->direct_io_allow_mmap || iocb->ki_flags &IOCB_APPEND ||fuse_direct_write_extending_i_size (iocb, from);
@@ -1581,6 +1582,7 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from)* Take exclusive lock if * - Parallel direct writes are disabled - a user space decision * - Parallel direct writes are enabled and i_size is being extended. +* - Shared mmap on direct_io file is supported (FUSE_DIRECT_IO_ALLOW_MMAP). * This might not be needed at all, but needs further investigation. */ if (exclusive_lock)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 64/166 fuse: dax: set fc->dax to NULL in fuse_dax_conn_free()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hangyu Hua <[email protected]>
commit 7f8ed28d1401320bcb02dda81b3c23ab2dc5a6d8 upstream.
fuse_dax_conn_free() will be called when fuse_fill_super_common() fails after fuse_dax_conn_alloc(). Then deactivate_locked_super() in virtio_fs_get_tree() will call virtio_kill_sb() to release the discarded superblock. This will call fuse_dax_conn_free() again in fuse_conn_put(), resulting in a possible double free.
--- fs/fuse/dax.c | 1 + 1 file changed, 1 insertion(+)
fs/fuse/dax.c +1 -0
@@ -1222,6 +1222,7 @@ void fuse_dax_conn_free(struct fuse_connif (fc->dax) {fuse_free_dax_mem_ranges (&fc->dax->free_ranges);kfree (fc->dax); + fc->dax =NULL ; } }
Greg Kroah-Hartman
maintainerPATCH 65/166 io_uring/cmd: fix breakage in SOCKET_URING_OP_SIOC* implementation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 1ba0e9d69b2000e95267c888cbfa91d823388d47 upstream.
In 8e9fad0e70b7 "io_uring: Add io_uring command support for sockets"
you've got an include of asm-generic/ioctls.h done in io_uring/uring_cmd.c. That had been done for the sake of this chunk -
+ ret = prot->ioctl(sk, SIOCINQ, &arg);
+ if (ret)
+ return ret;
+ return arg;
+ case SOCKET_URING_OP_SIOCOUTQ:
+ ret = prot->ioctl(sk, SIOCOUTQ, &arg);
SIOC{IN,OUT}Q are defined to symbols (FIONREAD and TIOCOUTQ) that come from ioctls.h, all right, but the values vary by the architecture.
FIONREAD is
0x467F on mips 0x4004667F on alpha, powerpc and sparc 0x8004667F on sh and xtensa 0x541B everywhere else TIOCOUTQ is 0x7472 on mips 0x40047473 on alpha, powerpc and sparc 0x80047473 on sh and xtensa 0x5411 everywhere else
->ioctl() expects the same values it would've gotten from userland; all places where we compare with SIOC{IN,OUT}Q are using asm/ioctls.h, so they pick the correct values. io_uring_cmd_sock(), OTOH, ends up passing the default ones.
--- io_uring/uring_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/uring_cmd.c +1 -1
@@ -7,7 +7,7 @@#include <linux/nospec.h> #include <uapi/linux/io_uring.h> -#include <uapi/asm-generic/ioctls.h> +#include <asm/ioctls.h> #include "io_uring.h" #include "rsrc.h"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 66/166 ALSA: hda/hdmi: add force-connect quirk for NUC5CPYB
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai Vehmanen <[email protected]>
commit 3b1ff57e24a7bcd2e2a8426dd2013a80d1fa96eb upstream.
Add one more older NUC model that requires quirk to force all pins to be connected. The display codec pins are not registered properly without the force-connect quirk. The codec will report only one pin as having external connectivity, but i915 finds all three connectors on the system, so the two drivers are not in sync.
Issue found with DRM igt-gpu-tools test kms_hdmi_inject@inject-audio.
--- sound/pci/hda/patch_hdmi.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_hdmi.c +1 -0
@@ -1994,6 +1994,7 @@ static const struct snd_pci_quirk force_SND_PCI_QUIRK (0x103c ,0x8711 ,"HP" ,1 ),SND_PCI_QUIRK (0x103c ,0x8715 ,"HP" ,1 ),SND_PCI_QUIRK (0x1462 ,0xec94 ,"MS-7C94" ,1 ), +SND_PCI_QUIRK (0x8086 ,0x2060 ,"Intel NUC5CPYB" ,1 ), SND_PCI_QUIRK(0x8086, 0x2081, "Intel NUC 10", 1), {} };
Greg Kroah-Hartman
maintainerPATCH 67/166 ALSA: hda/hdmi: add force-connect quirks for ASUSTeK Z170 variants
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai Vehmanen <[email protected]>
commit 924f5ca2975b2993ee81a7ecc3c809943a70f334 upstream.
On ASUSTeK Z170M PLUS and Z170 PRO GAMING systems, the display codec pins are not registered properly without the force-connect quirk. The codec will report only one pin as having external connectivity, but i915 finds all three connectors on the system, so the two drivers are not in sync.
Issue found with DRM igt-gpu-tools test kms_hdmi_inject@inject-audio.
--- sound/pci/hda/patch_hdmi.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/patch_hdmi.c +2 -0
@@ -1993,6 +1993,8 @@ static const struct snd_pci_quirk force_SND_PCI_QUIRK (0x103c ,0x871a ,"HP" ,1 ),SND_PCI_QUIRK (0x103c ,0x8711 ,"HP" ,1 ),SND_PCI_QUIRK (0x103c ,0x8715 ,"HP" ,1 ), +SND_PCI_QUIRK (0x1043 ,0x86ae ,"ASUS" ,1 ),/* Z170 PRO */ +SND_PCI_QUIRK (0x1043 ,0x86c7 ,"ASUS" ,1 ),/* Z170M PLUS */ SND_PCI_QUIRK (0x1462 ,0xec94 ,"MS-7C94" ,1 ),SND_PCI_QUIRK (0x8086 ,0x2060 ,"Intel NUC5CPYB" ,1 ), SND_PCI_QUIRK(0x8086, 0x2081, "Intel NUC 10", 1),
Greg Kroah-Hartman
maintainerPATCH 68/166 ALSA: hda/realtek: Apply mute LED quirk for HP15-db
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hartmut Knaack <[email protected]>
commit 9b726bf6ae11add6a7a52883a21f90ff9cbca916 upstream.
The HP laptop 15-db0403ng uses the ALC236 codec and controls the mute LED using COEF 0x07 index 1.
Sound card subsystem: Hewlett-Packard Company Device [103c:84ae]
Use the existing quirk for this model.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9705,6 +9705,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x83b9 ,"HP Spectre x360" ,ALC269_FIXUP_HP_MUTE_LED_MIC3 ),SND_PCI_QUIRK (0x103c ,0x841c ,"HP Pavilion 15-CK0xx" ,ALC269_FIXUP_HP_MUTE_LED_MIC3 ),SND_PCI_QUIRK (0x103c ,0x8497 ,"HP Envy x360" ,ALC269_FIXUP_HP_MUTE_LED_MIC3 ), +SND_PCI_QUIRK (0x103c ,0x84ae ,"HP 15-db0403ng" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ),SND_PCI_QUIRK (0x103c ,0x84da ,"HP OMEN dc0019-ur" ,ALC295_FIXUP_HP_OMEN ),SND_PCI_QUIRK (0x103c ,0x84e7 ,"HP Pavilion 15" ,ALC269_FIXUP_HP_MUTE_LED_MIC3 ), SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360),
Greg Kroah-Hartman
maintainerPATCH 69/166 ALSA: hda/tas2781: leave hda_component in usable state
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gergo Koteles <[email protected]>
commit 75a25d31b80770485641ad2789a854955f5c1e40 upstream.
Unloading then loading the module causes a NULL ponter dereference.
The hda_unbind zeroes the hda_component, later the hda_bind tries to dereference the codec field.
The hda_component is only initialized once by tas2781_generic_fixup.
Set only previously modified fields to NULL.
BUG: kernel NULL pointer dereference, address: 0000000000000322 Call Trace: <TASK> ? __die+0x23/0x70 ? page_fault_oops+0x171/0x4e0 ? exc_page_fault+0x7f/0x180 ? asm_exc_page_fault+0x26/0x30 ? tas2781_hda_bind+0x59/0x140 [snd_hda_scodec_tas2781_i2c] component_bind_all+0xf3/0x240 try_to_bring_up_aggregate_device+0x1c3/0x270 __component_add+0xbc/0x1a0 tas2781_hda_i2c_probe+0x289/0x3a0 [snd_hda_scodec_tas2781_i2c] i2c_device_probe+0x136/0x2e0
--- sound/pci/hda/tas2781_hda_i2c.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
sound/pci/hda/tas2781_hda_i2c.c +6 -2
@@ -612,9 +612,13 @@ static void tas2781_hda_unbind(struct device *dev, {struct tasdevice_priv *tas_priv =dev_get_drvdata (dev);struct hda_component *comps = master_data; + comps = &comps[tas_priv->index]; -if (comps[tas_priv->index].dev == dev) -memset (&comps[tas_priv->index],0 ,sizeof (*comps)); +if (comps->dev == dev) { + comps->dev =NULL ; +memset (comps->name,0 ,sizeof (comps->name)); + comps->playback_hook =NULL ; + }tasdevice_config_info_remove (tas_priv);tasdevice_dsp_remove (tas_priv);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 70/166 ALSA: hda/tas2781: handle missing EFI calibration data
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gergo Koteles <[email protected]>
commit 33071422714a4c9587753b0ccc130ca59323bf42 upstream.
The code does not properly check whether the calibration variable is available in the EFI. If it is not available, it causes a NULL pointer dereference.
Check the return value of the first get_variable call also.
BUG: kernel NULL pointer dereference, address: 0000000000000000 Call Trace: <TASK> ? __die+0x23/0x70 ? page_fault_oops+0x171/0x4e0 ? srso_alias_return_thunk+0x5/0x7f ? schedule+0x5e/0xd0 ? exc_page_fault+0x7f/0x180 ? asm_exc_page_fault+0x26/0x30 ? crc32_body+0x2c/0x120 ? tas2781_save_calibration+0xe4/0x220 [snd_hda_scodec_tas2781_i2c] tasdev_fw_ready+0x1af/0x280 [snd_hda_scodec_tas2781_i2c] request_firmware_work_func+0x59/0xa0
--- sound/pci/hda/tas2781_hda_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/hda/tas2781_hda_i2c.c +2 -2
@@ -455,9 +455,9 @@ static int tas2781_save_calibration(stru status = efi.get_variable (efi_name, &efi_guid, &attr, &tas_priv->cali_data.total_sz, tas_priv->cali_data.data); -if (status !=EFI_SUCCESS ) -return -EINVAL ; } +if (status !=EFI_SUCCESS ) +return -EINVAL ; tmp_val = (unsigned int *)tas_priv->cali_data.data;
Greg Kroah-Hartman
maintainerPATCH 71/166 ALSA: hda/tas2781: call cleanup functions only once
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gergo Koteles <[email protected]>
commit 6c6fa2641402e8e753262fb61ed9a15a7cb225ad upstream.
If the module can load the RCA but not the firmware binary, it will call the cleanup functions. Then unloading the module causes general protection fault due to double free.
Do not call the cleanup functions in tasdev_fw_ready.
general protection fault, probably for non-canonical address 0x6f2b8a2bff4c8fec: 0000 [#1] PREEMPT SMP NOPTI Call Trace: <TASK> ? die_addr+0x36/0x90 ? exc_general_protection+0x1c5/0x430 ? asm_exc_general_protection+0x26/0x30 ? tasdevice_config_info_remove+0x6d/0xd0 [snd_soc_tas2781_fmwlib] tas2781_hda_unbind+0xaa/0x100 [snd_hda_scodec_tas2781_i2c] component_unbind+0x2e/0x50 component_unbind_all+0x92/0xa0 component_del+0xa8/0x140 tas2781_hda_remove.isra.0+0x32/0x60 [snd_hda_scodec_tas2781_i2c] i2c_device_remove+0x26/0xb0
--- sound/pci/hda/tas2781_hda_i2c.c | 5 ----- 1 file changed, 5 deletions(-)
sound/pci/hda/tas2781_hda_i2c.c +0 -5
@@ -550,11 +550,6 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)tas2781_save_calibration (tas_priv); out: -if (tas_priv->fw_state ==TASDEVICE_DSP_FW_FAIL ) { -/*If DSP FW fail, kcontrol won't be created */ -tasdevice_config_info_remove (tas_priv); -tasdevice_dsp_remove (tas_priv); - }mutex_unlock (&tas_priv->codec_lock);if (fmw)release_firmware (fmw);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 54/166 net: stmmac: Handle disabled MDIO busses from devicetree
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Halaney <[email protected]>
[ Upstream commit e23c0d21ce9234fbc31ece35663ababbb83f9347 ]
Many hardware configurations have the MDIO bus disabled, and are instead using some other MDIO bus to talk to the MAC's phy.
of_mdiobus_register() returns -ENODEV in this case. Let's handle it gracefully instead of failing to probe the MAC.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +5 -1
@@ -591,7 +591,11 @@ int stmmac_mdio_register(struct net_device *ndev) new_bus->parent = priv->device; err =of_mdiobus_register (new_bus, mdio_node); -if (err !=0 ) { +if (err == -ENODEV ) { + err =0 ; +dev_info (dev,"MDIO bus is disabled\n" ); + goto bus_register_fail; + }else if (err) {dev_err_probe (dev, err,"Cannot register the MDIO bus\n" ); goto bus_register_fail; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 72/166 ALSA: hda/tas2781: reset the amp before component_add
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gergo Koteles <[email protected]>
commit 315deab289924c83ab1ded50022e8db95d6e428b upstream.
Calling component_add starts loading the firmware, the callback function writes the program to the amplifiers. If the module resets the amplifiers after component_add, it happens that one of the amplifiers does not work because the reset and program writing are interleaving.
Call tas2781_reset before component_add to ensure reliable initialization.
--- sound/pci/hda/tas2781_hda_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/hda/tas2781_hda_i2c.c +2 -2
@@ -674,14 +674,14 @@ static int tas2781_hda_i2c_probe(struct i2c_client *clt)pm_runtime_put_autosuspend (tas_priv->dev); +tas2781_reset (tas_priv); + ret =component_add (tas_priv->dev, &tas2781_hda_comp_ops);if (ret) {dev_err (tas_priv->dev,"Register component failed: %d\n" , ret);pm_runtime_disable (tas_priv->dev); - goto err; } -tas2781_reset (tas_priv); err:if (ret)tas2781_hda_remove (&clt->dev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 73/166 Revert "PCI: acpiphp: Reassign resources on bridge if necessary"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Helgaas <[email protected]>
commit 5df12742b7e3aae2594a30a9d14d5d6e9e7699f4 upstream.
This reverts commit 40613da52b13fb21c5566f10b287e0ca8c12c4e9 and the subsequent fix to it:
cc22522fd55e ("PCI: acpiphp: Use pci_assign_unassigned_bridge_resources() only for non-root bus")
40613da52b13 fixed a problem where hot-adding a device with large BARs failed if the bridge windows programmed by firmware were not large enough.
cc22522fd55e ("PCI: acpiphp: Use pci_assign_unassigned_bridge_resources() only for non-root bus") fixed a problem with 40613da52b13: an ACPI hot-add of a device on a PCI root bus (common in the virt world) or firmware sending ACPI Bus Check to non-existent Root Ports (e.g., on Dell Inspiron 7352/0W6WV0) caused a NULL pointer dereference and suspend/resume hangs.
Unfortunately the combination of 40613da52b13 and cc22522fd55e caused other problems:
- Fiona reported that hot-add of SCSI disks in QEMU virtual machine fails sometimes.
- Dongli reported a similar problem with hot-add of SCSI disks.
- Jonathan reported a console freeze during boot on bare metal due to an error in radeon GPU initialization.
Revert both patches to avoid adding these problems. This means we will again see the problems with hot-adding devices with large BARs and the NULL pointer dereferences and suspend/resume issues that 40613da52b13 and cc22522fd55e were intended to fix.
--- drivers/pci/hotplug/acpiphp_glue.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +3 -6
@@ -512,15 +512,12 @@ static void enable_slot(struct acpiphp_sif (pass && dev->subordinate) {check_hotplug_bridge (slot, dev);pcibios_resource_survey_bus (dev->subordinate); -if (pci_is_root_bus (bus)) -__pci_bus_size_bridges (dev->subordinate, &add_list); +__pci_bus_size_bridges (dev->subordinate, + &add_list); } } } -if (pci_is_root_bus (bus)) -__pci_bus_assign_resources (bus, &add_list,NULL ); -else -pci_assign_unassigned_bridge_resources (bus->self); +__pci_bus_assign_resources (bus, &add_list,NULL ); }acpiphp_sanitize_bus (bus);
Greg Kroah-Hartman
maintainerPATCH 74/166 PCI: loongson: Limit MRRS to 256
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaxun Yang <[email protected]>
commit ef61a0405742a9f7f6051bc6fd2f017d87d07911 upstream.
This is a partial revert of 8b3517f88ff2 ("PCI: loongson: Prevent LS7A MRRS increases") for MIPS-based Loongson.
Some MIPS Loongson systems don't support arbitrary Max_Read_Request_Size (MRRS) settings. 8b3517f88ff2 ("PCI: loongson: Prevent LS7A MRRS increases") worked around that by (1) assuming that firmware configured MRRS to the maximum supported value and (2) preventing the PCI core from increasing MRRS.
Unfortunately, some firmware doesn't set that maximum MRRS correctly, which results in devices not being initialized correctly. One symptom, from the Debian report below, is this:
ata4.00: exception Emask 0x0 SAct 0x20000000 SErr 0x0 action 0x6 frozen ata4.00: failed command: WRITE FPDMA QUEUED
ata4.00: cmd 61/20:e8:00:f0:e1/00:00:00:00:00/40 tag 29 ncq dma 16384 out
res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
ata4.00: status: { DRDY }
ata4: hard resetting link
Limit MRRS to 256 because MIPS Loongson with higher MRRS support is considered rare.
This must be done at device enablement stage because the MRRS setting may get lost if PCI_COMMAND_MASTER on the parent bridge is cleared, and we are only sure parent bridge is enabled at this point.
--- drivers/pci/controller/pci-loongson.c | 46 ++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-)
drivers/pci/controller/pci-loongson.c +41 -5
@@ -80,13 +80,49 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LODECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_LOONGSON ,DEV_LS7A_LPC , system_bus_quirk); +/* +* Some Loongson PCIe ports have hardware limitations on their Maximum Read +* Request Size. They can't handle anything larger than this. Sane +* firmware will set proper MRRS at boot, so we only need no_inc_mrrs for +* bridges. However, some MIPS Loongson firmware doesn't set MRRS properly, +* so we have to enforce maximum safe MRRS, which is 256 bytes. +*/ +#ifdef CONFIG_MIPS +static void loongson_set_min_mrrs_quirk (struct pci_dev *pdev) +{ +struct pci_bus *bus = pdev->bus; +struct pci_dev *bridge; +static const struct pci_device_id bridge_devids[] = { + {PCI_VDEVICE (LOONGSON ,DEV_LS2K_PCIE_PORT0 ) }, + {PCI_VDEVICE (LOONGSON ,DEV_LS7A_PCIE_PORT0 ) }, + {PCI_VDEVICE (LOONGSON ,DEV_LS7A_PCIE_PORT1 ) }, + {PCI_VDEVICE (LOONGSON ,DEV_LS7A_PCIE_PORT2 ) }, + {PCI_VDEVICE (LOONGSON ,DEV_LS7A_PCIE_PORT3 ) }, + {PCI_VDEVICE (LOONGSON ,DEV_LS7A_PCIE_PORT4 ) }, + {PCI_VDEVICE (LOONGSON ,DEV_LS7A_PCIE_PORT5 ) }, + {PCI_VDEVICE (LOONGSON ,DEV_LS7A_PCIE_PORT6 ) }, + {0 , }, + }; + +/* look for the matching bridge */ +while (!pci_is_root_bus (bus)) { + bridge = bus->self; + bus = bus->parent; + +if (pci_match_id (bridge_devids, bridge)) { +if (pcie_get_readrq (pdev) >256 ) { +pci_info (pdev,"limiting MRRS to 256\n" ); +pcie_set_readrq (pdev,256 ); + } +break ; + } + } +} +DECLARE_PCI_FIXUP_ENABLE (PCI_ANY_ID ,PCI_ANY_ID , loongson_set_min_mrrs_quirk); +#endif +static void loongson_mrrs_quirk (struct pci_dev *pdev) { -/* -* Some Loongson PCIe ports have h/w limitations of maximum read -* request size. They can't handle anything larger than this. So -* force this limit on any devices attached under these ports. -*/ struct pci_host_bridge *bridge =pci_find_host_bridge (pdev->bus); bridge->no_inc_mrrs =1 ;
Greg Kroah-Hartman
maintainerPATCH 75/166 PCI/ASPM: Add pci_enable_link_state_locked()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 718ab8226636a1a3a7d281f5d6a7ad7c925efe5a upstream.
Add pci_enable_link_state_locked() for enabling link states that can be used in contexts where a pci_bus_sem read lock is already held (e.g. from pci_walk_bus()).
This helper will be used to fix a couple of potential deadlocks where the current helper is called with the lock already held, hence the CC stable tag.
--- drivers/pci/pcie/aspm.c | 53 ++++++++++++++++++++++++++++++++++++------------ include/linux/pci.h | 3 ++ 2 files changed, 43 insertions(+), 13 deletions(-)
drivers/pci/pcie/aspm.c +40 -13
@@ -1102,17 +1102,7 @@ int pci_disable_link_state(struct pci_de }EXPORT_SYMBOL (pci_disable_link_state); -/** -* pci_enable_link_state - Clear and set the default device link state so that -* the link may be allowed to enter the specified states. Note that if the -* BIOS didn't grant ASPM control to the OS, this does nothing because we can't -* touch the LNKCTL register. Also note that this does not enable states -* disabled by pci_disable_link_state(). Return 0 or a negative errno. -* -* @pdev: PCI device -* @state: Mask of ASPM link states to enable -*/ -int pci_enable_link_state (struct pci_dev *pdev,int state) +static int __pci_enable_link_state (struct pci_dev *pdev,int state,bool locked) {struct pcie_link_state *link =pcie_aspm_get_link (pdev);
@@ -1129,7 +1119,8 @@ int pci_enable_link_state(struct pci_devreturn -EPERM ; } -down_read (&pci_bus_sem); +if (!locked) +down_read (&pci_bus_sem);mutex_lock (&aspm_lock); link->aspm_default =0 ;if (state &PCIE_LINK_STATE_L0S )
@@ -1150,12 +1141,48 @@ int pci_enable_link_state(struct pci_dev link->clkpm_default = (state &PCIE_LINK_STATE_CLKPM ) ?1 :0 ;pcie_set_clkpm (link,policy_to_clkpm_state (link));mutex_unlock (&aspm_lock); -up_read (&pci_bus_sem); +if (!locked) +up_read (&pci_bus_sem);return 0 ; } + +/** +* pci_enable_link_state - Clear and set the default device link state so that +* the link may be allowed to enter the specified states. Note that if the +* BIOS didn't grant ASPM control to the OS, this does nothing because we can't +* touch the LNKCTL register. Also note that this does not enable states +* disabled by pci_disable_link_state(). Return 0 or a negative errno. +* +* @pdev: PCI device +* @state: Mask of ASPM link states to enable +*/ +int pci_enable_link_state (struct pci_dev *pdev,int state) +{ +return __pci_enable_link_state (pdev, state, false); +}EXPORT_SYMBOL (pci_enable_link_state); +/** +* pci_enable_link_state_locked - Clear and set the default device link state +* so that the link may be allowed to enter the specified states. Note that if +* the BIOS didn't grant ASPM control to the OS, this does nothing because we +* can't touch the LNKCTL register. Also note that this does not enable states +* disabled by pci_disable_link_state(). Return 0 or a negative errno. +* +* @pdev: PCI device +* @state: Mask of ASPM link states to enable +* +* Context: Caller holds pci_bus_sem read lock. +*/ +int pci_enable_link_state_locked (struct pci_dev *pdev,int state) +{ +lockdep_assert_held_read (&pci_bus_sem); + +return __pci_enable_link_state (pdev, state, true); +} +EXPORT_SYMBOL (pci_enable_link_state_locked); +static int pcie_aspm_set_policy (const char *val,const struct kernel_param *kp) {
include/linux/pci.h +3 -0
@@ -1803,6 +1803,7 @@ extern bool pcie_ports_native;int pci_disable_link_state (struct pci_dev *pdev,int state);int pci_disable_link_state_locked (struct pci_dev *pdev,int state);int pci_enable_link_state (struct pci_dev *pdev,int state); +int pci_enable_link_state_locked (struct pci_dev *pdev,int state);void pcie_no_aspm (void );bool pcie_aspm_support_enabled (void );bool pcie_aspm_enabled (struct pci_dev *pdev);
@@ -1813,6 +1814,8 @@ static inline int pci_disable_link_state {return 0 ; }static inline int pci_enable_link_state (struct pci_dev *pdev,int state) {return 0 ; } +static inline int pci_enable_link_state_locked (struct pci_dev *pdev,int state) +{return 0 ; }static inline void pcie_no_aspm (void ) { }static inline bool pcie_aspm_support_enabled (void ) {return false; }static inline bool pcie_aspm_enabled (struct pci_dev *pdev) {return false; }
Greg Kroah-Hartman
maintainerPATCH 76/166 ksmbd: fix wrong name of SMB2_CREATE_ALLOCATION_SIZE
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit 13736654481198e519059d4a2e2e3b20fa9fdb3e upstream.
MS confirm that "AISi" name of SMB2_CREATE_ALLOCATION_SIZE in MS-SMB2 specification is a typo. cifs/ksmbd have been using this wrong name from MS-SMB2. It should be "AlSi". Also It will cause problem when running smb2.create.open test in smbtorture against ksmbd.
--- fs/smb/common/smb2pdu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/common/smb2pdu.h +1 -1
@@ -1120,7 +1120,7 @@ struct smb2_change_notify_rsp {#define SMB2_CREATE_SD_BUFFER "SecD"/* security descriptor */ #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC" -#define SMB2_CREATE_ALLOCATION_SIZE "AISi" +#define SMB2_CREATE_ALLOCATION_SIZE "AlSi"#define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"#define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"#define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
Greg Kroah-Hartman
maintainerPATCH 77/166 PCI: vmd: Fix potential deadlock when enabling ASPM
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 49de0dc87965079a8e2803ee4b39f9d946259423 upstream.
The vmd_pm_enable_quirk() helper is called from pci_walk_bus() during probe to enable ASPM for controllers with VMD_FEAT_BIOS_PM_QUIRK set.
Since pci_walk_bus() already holds a pci_bus_sem read lock, use pci_enable_link_state_locked() to enable link states in order to avoid a potential deadlock (e.g. in case someone takes a write lock before reacquiring the read lock).
[bhelgaas: add "potential" in subject since the deadlock has only been reported by lockdep, include helper name in commit log]
--- drivers/pci/controller/vmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/vmd.c +1 -1
@@ -751,7 +751,7 @@ static int vmd_pm_enable_quirk(struct pci_dev *pdev, void *userdata)if (!(features &VMD_FEAT_BIOS_PM_QUIRK ))return 0 ; -pci_enable_link_state (pdev,PCIE_LINK_STATE_ALL ); +pci_enable_link_state_locked (pdev,PCIE_LINK_STATE_ALL ); pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_LTR );if (!pos)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 78/166 drm/mediatek: fix kernel oops if no crtc is found
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Walle <[email protected]>
[ Upstream commit 4662817aed5a9d6c695658d0105d8ff4b84ac6cb ]
drm_crtc_from_index(0) might return NULL if there are no CRTCs registered at all which will lead to a kernel oops in mtk_drm_crtc_dma_dev_get(). Add the missing return value check.
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +4 -1
@@ -421,6 +421,7 @@ static int mtk_drm_kms_init(struct drm_device *drm)struct mtk_drm_private *private = drm->dev_private;struct mtk_drm_private *priv_n;struct device *dma_dev =NULL ; +struct drm_crtc *crtc;int ret, i, j;if (drm_firmware_drivers_only ())
@@ -495,7 +496,9 @@ static int mtk_drm_kms_init(struct drm_device *drm) }/* Use OVL device for all DMA memory allocations */ - dma_dev =mtk_drm_crtc_dma_dev_get (drm_crtc_from_index (drm,0 )); + crtc =drm_crtc_from_index (drm,0 ); +if (crtc) + dma_dev =mtk_drm_crtc_dma_dev_get (crtc);if (!dma_dev) { ret = -ENODEV ;dev_err (drm->dev,"Need at least one OVL device\n" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 79/166 drm/mediatek: Add spinlock for setting vblank event in atomic_begin
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason-JH.Lin <[email protected]>
[ Upstream commit fe4c5f662097978b6c91c23a13c24ed92339a180 ]
Add spinlock protection to avoid race condition on vblank event between mtk_drm_crtc_atomic_begin() and mtk_drm_finish_page_flip().
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +5 -0
@@ -747,6 +747,7 @@ static void mtk_drm_crtc_atomic_begin(struct drm_crtc *crtc, crtc);struct mtk_crtc_state *mtk_crtc_state =to_mtk_crtc_state (crtc_state);struct mtk_drm_crtc *mtk_crtc =to_mtk_crtc (crtc); +unsigned long flags;if (mtk_crtc->event && mtk_crtc_state->base.event)DRM_ERROR ("new event while there is still a pending event\n" );
@@ -754,7 +755,11 @@ static void mtk_drm_crtc_atomic_begin(struct drm_crtc *crtc,if (mtk_crtc_state->base.event) { mtk_crtc_state->base.event->pipe =drm_crtc_index (crtc);WARN_ON (drm_crtc_vblank_get (crtc) !=0 ); + +spin_lock_irqsave (&crtc->dev->event_lock, flags); mtk_crtc->event = mtk_crtc_state->base.event; +spin_unlock_irqrestore (&crtc->dev->event_lock, flags); + mtk_crtc_state->base.event =NULL ; } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 80/166 accel/ivpu: Print information about used workarounds
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislaw Gruszka <[email protected]>
[ Upstream commit eefa13a69053a09f20b2d1c00dda59be9c98cfe9 ]
Use ivpu_dbg(MISC) to print information about workarounds.
Stable-dep-of: 35c49cfc8b70 ("accel/ivpu/37xx: Fix interrupt_clear_with_0 WA initialization")
--- drivers/accel/ivpu/ivpu_drv.h | 5 +++++ drivers/accel/ivpu/ivpu_hw_37xx.c | 5 +++++ drivers/accel/ivpu/ivpu_hw_40xx.c | 4 ++++ 3 files changed, 14 insertions(+)
drivers/accel/ivpu/ivpu_drv.h +5 -0
@@ -76,6 +76,11 @@#define IVPU_WA (wa_name) (vdev->wa.wa_name) +#define IVPU_PRINT_WA (wa_name) do { \ + if (IVPU_WA(wa_name)) \ + ivpu_dbg(vdev, MISC, "Using WA: " #wa_name "\n"); \ +} while (0) +struct ivpu_wa_table {bool punit_disabled;bool clear_runtime_mem;
drivers/accel/ivpu/ivpu_hw_37xx.c +5 -0
@@ -104,6 +104,11 @@ static void ivpu_hw_wa_init(struct ivpu_device *vdev)if (ivpu_device_id (vdev) ==PCI_DEVICE_ID_MTL &&ivpu_revision (vdev) <4 ) vdev->wa.interrupt_clear_with_0 = true; + +IVPU_PRINT_WA (punit_disabled); +IVPU_PRINT_WA (clear_runtime_mem); +IVPU_PRINT_WA (d3hot_after_power_off); +IVPU_PRINT_WA (interrupt_clear_with_0); }static void ivpu_hw_timeouts_init (struct ivpu_device *vdev)
drivers/accel/ivpu/ivpu_hw_40xx.c +4 -0
@@ -125,6 +125,10 @@ static void ivpu_hw_wa_init(struct ivpu_device *vdev)if (ivpu_hw_gen (vdev) ==IVPU_HW_40XX ) vdev->wa.disable_clock_relinquish = true; + +IVPU_PRINT_WA (punit_disabled); +IVPU_PRINT_WA (clear_runtime_mem); +IVPU_PRINT_WA (disable_clock_relinquish); }static void ivpu_hw_timeouts_init (struct ivpu_device *vdev)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 81/166 accel/ivpu/37xx: Fix interrupt_clear_with_0 WA initialization
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrzej Kacprowski <[email protected]>
[ Upstream commit 35c49cfc8b702eda7a0d3f05497b16f81b69e289 ]
Using PCI Device ID/Revision to initialize the interrupt_clear_with_0 workaround is problematic - there are many pre-production steppings with different behavior, even with the same PCI ID/Revision
Instead of checking for PCI Device ID/Revision, check the VPU buttress interrupt status register behavior - if this register is not zero after writing 1s it means there register is RW instead of RW1C and we need to enable the interrupt_clear_with_0 workaround.
--- drivers/accel/ivpu/ivpu_hw_37xx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/accel/ivpu/ivpu_hw_37xx.c +9 -3
@@ -53,10 +53,12 @@#define ICB_0_1_IRQ_MASK ((((u64)ICB_1_IRQ_MASK) << 32) | ICB_0_IRQ_MASK) -#define BUTTRESS_IRQ_MASK ((REG_FLD(VPU_37XX_BUTTRESS_INTERRUPT_STAT, FREQ_CHANGE)) | \ - (REG_FLD(VPU_37XX_BUTTRESS_INTERRUPT_STAT, ATS_ERR)) | \ +#define BUTTRESS_IRQ_MASK ((REG_FLD(VPU_37XX_BUTTRESS_INTERRUPT_STAT, ATS_ERR)) | \ (REG_FLD(VPU_37XX_BUTTRESS_INTERRUPT_STAT, UFI_ERR))) +#define BUTTRESS_ALL_IRQ_MASK (BUTTRESS_IRQ_MASK | \ + (REG_FLD(VPU_37XX_BUTTRESS_INTERRUPT_STAT, FREQ_CHANGE))) +#define BUTTRESS_IRQ_ENABLE_MASK ((u32)~BUTTRESS_IRQ_MASK)#define BUTTRESS_IRQ_DISABLE_MASK ((u32)-1)
@@ -102,8 +104,12 @@ static void ivpu_hw_wa_init(struct ivpu_device *vdev) vdev->wa.clear_runtime_mem = false; vdev->wa.d3hot_after_power_off = true; -if (ivpu_device_id (vdev) ==PCI_DEVICE_ID_MTL &&ivpu_revision (vdev) <4 ) +REGB_WR32 (VPU_37XX_BUTTRESS_INTERRUPT_STAT ,BUTTRESS_ALL_IRQ_MASK ); +if (REGB_RD32 (VPU_37XX_BUTTRESS_INTERRUPT_STAT ) ==BUTTRESS_ALL_IRQ_MASK ) { +/* Writing 1s does not clear the interrupt status register */ vdev->wa.interrupt_clear_with_0 = true; +REGB_WR32 (VPU_37XX_BUTTRESS_INTERRUPT_STAT ,0x0 ); + }IVPU_PRINT_WA (punit_disabled);IVPU_PRINT_WA (clear_runtime_mem);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 55/166 appletalk: Fix Use-After-Free in atalk_ioctl
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
[ Upstream commit 189ff16722ee36ced4d2a2469d4ab65a8fee4198 ]
Because atalk_ioctl() accesses sk->sk_receive_queue without holding a sk->sk_receive_queue.lock, it can cause a race with atalk_recvmsg().
A use-after-free for skb occurs with the following flow.
``` atalk_ioctl() -> skb_peek() atalk_recvmsg() -> skb_recv_datagram() -> skb_free_datagram() ```
Add sk->sk_receive_queue.lock to atalk_ioctl() to fix this issue.
--- net/appletalk/ddp.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
net/appletalk/ddp.c +4 -5
@@ -1811,15 +1811,14 @@ static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)break ; }case TIOCINQ : { -/* -* These two are safe on a single CPU system as only -* user tasks fiddle here -*/ -struct sk_buff *skb =skb_peek (&sk->sk_receive_queue); +struct sk_buff *skb;long amount =0 ; +spin_lock_irq (&sk->sk_receive_queue.lock); + skb =skb_peek (&sk->sk_receive_queue);if (skb) amount = skb->len -sizeof (struct ddpehdr ); +spin_unlock_irq (&sk->sk_receive_queue.lock); rc =put_user (amount, (int __user *)argp);break ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 82/166 drm/i915/selftests: Fix engine reset count storage for multi-tile
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tvrtko Ursulin <[email protected]>
[ Upstream commit 7c7c863bf89c5f76d8c7fda177a81559b61dc15b ]
Engine->id namespace is per-tile so struct igt_live_test->reset_engine[] needs to be two-dimensional so engine reset counts from all tiles can be stored with no aliasing. With aliasing, if we had a real multi-tile platform, the reset counts would be incorrect for same engine instance on different tiles.
--- drivers/gpu/drm/i915/selftests/igt_live_test.c | 9 +++++---- drivers/gpu/drm/i915/selftests/igt_live_test.h | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/selftests/igt_live_test.c +5 -4
@@ -37,8 +37,9 @@ int igt_live_test_begin(struct igt_live_test *t, }for_each_engine (engine, gt, id) - t->reset_engine[id] = -i915_reset_engine_count (&i915->gpu_error, engine); + t->reset_engine[i][id] = +i915_reset_engine_count (&i915->gpu_error, + engine); } t->reset_global =i915_reset_count (&i915->gpu_error);
@@ -66,14 +67,14 @@ int igt_live_test_end(struct igt_live_test *t)for_each_gt (gt, i915, i) {for_each_engine (engine, gt, id) { -if (t->reset_engine[id] == +if (t->reset_engine[i][id] ==i915_reset_engine_count (&i915->gpu_error, engine))continue ;gt_err (gt,"%s(%s): engine '%s' was reset %d times!\n" , t->func, t->name, engine->name,i915_reset_engine_count (&i915->gpu_error, engine) - - t->reset_engine[id]); + t->reset_engine[i][id]);return -EIO ; } }
drivers/gpu/drm/i915/selftests/igt_live_test.h +2 -1
@@ -7,6 +7,7 @@#ifndef IGT_LIVE_TEST_H #define IGT_LIVE_TEST_H +#include "gt/intel_gt_defines.h" /* for I915_MAX_GT */ #include "gt/intel_engine.h" /* for I915_NUM_ENGINES */ struct drm_i915_private ;
@@ -17,7 +18,7 @@ struct igt_live_test {const char *name;unsigned int reset_global; -unsigned int reset_engine[I915_NUM_ENGINES ]; +unsigned int reset_engine[I915_MAX_GT ][I915_NUM_ENGINES ]; };/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 83/166 drm/i915: Use internal class when counting engine resets
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tvrtko Ursulin <[email protected]>
[ Upstream commit 1f721a93a528268fa97875cff515d1fcb69f4f44 ]
Commit 503579448db9 ("drm/i915/gsc: Mark internal GSC engine with reserved uabi class")
made the GSC0 engine not have a valid uabi class and so broke the engine
reset counting, which in turn was made class based in cb823ed9915b ("drm/i915/gt: Use intel_gt as the primary object for handling resets").
Despite the title and commit text of the latter is not mentioning it (and has left the storage array incorrectly sized), tracking by class, despite it adding aliasing in hypthotetical multi-tile systems, is handy for virtual engines which for instance do not have a valid engine->id.
Therefore we keep that but just change it to use the internal class which is always valid. We also add a helper to increment the count, which aligns with the existing getter.
What was broken without this fix were out of bounds reads every time a reset would happen on the GSC0 engine, or during selftests when storing and cross-checking the counts in igt_live_test_begin and igt_live_test_end.
--- drivers/gpu/drm/i915/gt/intel_reset.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 5 +++-- drivers/gpu/drm/i915/i915_gpu_error.h | 12 ++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/gt/intel_reset.c +1 -1
@@ -1297,7 +1297,7 @@ int __intel_engine_reset_bh(struct intel_engine_cs *engine, const char *msg)if (msg)drm_notice (&engine->i915->drm,"Resetting %s for %s\n" , engine->name, msg); -atomic_inc (&engine->i915->gpu_error.reset_engine_count[engine->uabi_class]); +i915_increase_reset_engine_count (&engine->i915->gpu_error, engine); ret =intel_gt_reset_engine (engine);if (ret) {
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +3 -2
@@ -4774,7 +4774,8 @@ static void capture_error_state(struct intel_guc *guc,if (match) {intel_engine_set_hung_context (e, ce); engine_mask |= e->mask; -atomic_inc (&i915->gpu_error.reset_engine_count[e->uabi_class]); +i915_increase_reset_engine_count (&i915->gpu_error, + e); } }
@@ -4786,7 +4787,7 @@ static void capture_error_state(struct intel_guc *guc, }else {intel_engine_set_hung_context (ce->engine, ce); engine_mask = ce->engine->mask; -atomic_inc (&i915->gpu_error.reset_engine_count[ce->engine->uabi_class]); +i915_increase_reset_engine_count (&i915->gpu_error, ce->engine); }with_intel_runtime_pm (&i915->runtime_pm, wakeref)
drivers/gpu/drm/i915/i915_gpu_error.h +10 -2
@@ -16,6 +16,7 @@#include "display/intel_display_device.h" #include "gt/intel_engine.h" +#include "gt/intel_engine_types.h" #include "gt/intel_gt_types.h" #include "gt/uc/intel_uc_fw.h"
@@ -232,7 +233,7 @@ struct i915_gpu_error {atomic_t reset_count;/** Number of times an engine has been reset */ -atomic_t reset_engine_count[I915_NUM_ENGINES ]; +atomic_t reset_engine_count[MAX_ENGINE_CLASS ]; };struct drm_i915_error_state_buf {
@@ -255,7 +256,14 @@ static inline u32 i915_reset_count(struct i915_gpu_error *error)static inline u32 i915_reset_engine_count (struct i915_gpu_error *error,const struct intel_engine_cs *engine) { -return atomic_read (&error->reset_engine_count[engine->uabi_class]); +return atomic_read (&error->reset_engine_count[engine->class]); +} + +static inline void +i915_increase_reset_engine_count (struct i915_gpu_error *error, +const struct intel_engine_cs *engine) +{ +atomic_inc (&error->reset_engine_count[engine->class]); }#define CORE_DUMP_FLAG_NONE 0x0
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 56/166 net: atlantic: fix double free in ring reinit logic
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Russkikh <[email protected]>
[ Upstream commit 7bb26ea74aa86fdf894b7dbd8c5712c5b4187da7 ]
Driver has a logic leak in ring data allocation/free, where double free may happen in aq_ring_free if system is under stress and driver init/deinit is happening.
The probability is higher to get this during suspend/resume cycle.
Verification was done simulating same conditions with
stress -m 2000 --vm-bytes 20M --vm-hang 10 --backoff 1000 while true; do sudo ifconfig enp1s0 down; sudo ifconfig enp1s0 up; done
Fixed by explicitly clearing pointers to NULL on deallocation
--- drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +4 -1
@@ -938,11 +938,14 @@ void aq_ring_free(struct aq_ring_s *self)return ;kfree (self->buff_ring); + self->buff_ring =NULL ; -if (self->dx_ring) +if (self->dx_ring) {dma_free_coherent (aq_nic_get_dev (self->aq_nic), self->size * self->dx_size, self->dx_ring, self->dx_ring_pa); + self->dx_ring =NULL ; + } }unsigned int aq_ring_fill_stats_data (struct aq_ring_s *self,u64 *data)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 57/166 cred: switch to using atomic_long_t
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit f8fa5d76925991976b3e7076f9d1052515ec1fca upstream.
There are multiple ways to grab references to credentials, and the only protection we have against overflowing it is the memory required to do so.
With memory sizes only moving in one direction, let's bump the reference count to 64-bit and move it outside the realm of feasibly overflowing.
--- include/linux/cred.h | 8 +++--- kernel/cred.c | 64 +++++++++++++++++++++++++-------------------------- 2 files changed, 36 insertions(+), 36 deletions(-)
include/linux/cred.h +4 -4
@@ -108,7 +108,7 @@ static inline int groups_search(const st* same context as task->real_cred. */ struct cred { -atomic_t usage; +atomic_long_t usage;#ifdef CONFIG_DEBUG_CREDENTIALS atomic_t subscribers;/* number of processes subscribed */ void *put_addr;
@@ -227,7 +227,7 @@ static inline bool cap_ambient_invariant*/ static inline struct cred *get_new_cred (struct cred *cred) { -atomic_inc (&cred->usage); +atomic_long_inc (&cred->usage);return cred; }
@@ -259,7 +259,7 @@ static inline const struct cred *get_crestruct cred *nonconst_cred = (struct cred *) cred;if (!cred)return NULL ; -if (!atomic_inc_not_zero (&nonconst_cred->usage)) +if (!atomic_long_inc_not_zero (&nonconst_cred->usage))return NULL ;validate_creds (cred); nonconst_cred->non_rcu =0 ;
@@ -283,7 +283,7 @@ static inline void put_cred(const structif (cred) {validate_creds (cred); -if (atomic_dec_and_test (&(cred)->usage)) +if (atomic_long_dec_and_test (&(cred)->usage))__put_cred (cred); } }
kernel/cred.c +32 -32
167 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 58/166 cred: get rid of CONFIG_DEBUG_CREDENTIALS
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit ae1914174a63a558113e80d24ccac2773f9f7b2b upstream.
This code is rarely (never?) enabled by distros, and it hasn't caught anything in decades. Let's kill off this legacy debug code.
--- arch/powerpc/configs/skiroot_defconfig | 1 arch/s390/configs/debug_defconfig | 1 fs/nfsd/auth.c | 4 fs/nfsd/nfssvc.c | 1 fs/nfsd/vfs.c | 9 - fs/open.c | 3 include/linux/cred.h | 50 ------ kernel/cred.c | 232 ++---------------------------- kernel/exit.c | 3 lib/Kconfig.debug | 15 - net/sunrpc/auth.c | 3 security/selinux/hooks.c | 6 tools/objtool/noreturns.h | 1 tools/testing/selftests/bpf/config.x86_64 | 1 tools/testing/selftests/hid/config.common | 1 15 files changed, 18 insertions(+), 313 deletions(-)
arch/powerpc/configs/skiroot_defconfig +0 -1
@@ -301,7 +301,6 @@ CONFIG_WQ_WATCHDOG=y CONFIG_DEBUG_SG=y CONFIG_DEBUG_NOTIFIERS=y CONFIG_BUG_ON_DATA_CORRUPTION=y -CONFIG_DEBUG_CREDENTIALS=y # CONFIG_FTRACE is not set CONFIG_XMON=y # CONFIG_RUNTIME_TESTING_MENU is not set
arch/s390/configs/debug_defconfig +0 -1
@@ -834,7 +834,6 @@ CONFIG_DEBUG_IRQFLAGS=y CONFIG_DEBUG_LIST=y CONFIG_DEBUG_SG=y CONFIG_DEBUG_NOTIFIERS=y -CONFIG_DEBUG_CREDENTIALS=y CONFIG_RCU_TORTURE_TEST=m CONFIG_RCU_REF_SCALE_TEST=m CONFIG_RCU_CPU_STALL_TIMEOUT=300
fs/nfsd/auth.c +0 -4
@@ -26,8 +26,6 @@ int nfsd_setuser(struct svc_rqst *rqstp,int i;int flags =nfsexp_flags (rqstp, exp); -validate_process_creds (); -/* discard any old override before preparing the new set */ revert_creds (get_cred (current_real_cred ())); new =prepare_creds ();
@@ -81,10 +79,8 @@ int nfsd_setuser(struct svc_rqst *rqstp,else new->cap_effective =cap_raise_nfsd_set (new->cap_effective, new->cap_permitted); -validate_process_creds ();put_cred (override_creds (new));put_cred (new); -validate_process_creds ();return 0 ; oom:
fs/nfsd/nfssvc.c +0 -1
@@ -962,7 +962,6 @@ nfsd(void *vrqstp) rqstp->rq_server->sv_maxconn = nn->max_connections;svc_recv (rqstp); -validate_process_creds (); }atomic_dec (&nfsdstats.th_cnt);
fs/nfsd/vfs.c +1 -8
@@ -884,7 +884,6 @@ nfsd_open(struct svc_rqst *rqstp, structint host_err;bool retried = false; -validate_process_creds ();/* * If we get here, then the client has already done an "open", * and (hopefully) checked permission - so allow OWNER_OVERRIDE
@@ -909,7 +908,6 @@ retry: } err =nfserrno (host_err); } -validate_process_creds ();return err; }
@@ -926,12 +924,7 @@ int nfsd_open_verified(struct svc_rqst *rqstp, struct svc_fh *fhp, int may_flags, struct file **filp) { - int err; - -validate_process_creds (); - err =__nfsd_open (rqstp, fhp,S_IFREG , may_flags, filp); -validate_process_creds (); -return err; + return __nfsd_open(rqstp, fhp, S_IFREG, may_flags, filp); }/*
fs/open.c +0 -3
@@ -1069,8 +1069,6 @@ struct file *dentry_open(const struct paint error;struct file *f; -validate_creds (cred); -/* We must always pass in a valid mount pointer. */ BUG_ON (!path->mnt);
@@ -1109,7 +1107,6 @@ struct file *dentry_create(const structstruct file *f;int error; -validate_creds (cred); f =alloc_empty_file (flags, cred);if (IS_ERR (f))return f;
include/linux/cred.h +0 -50
80 lines not on this page · raw message
kernel/cred.c +17 -215
379 lines not on this page · raw message
kernel/exit.c +0 -3
@@ -824,8 +824,6 @@ void __noreturn do_exit(long code)ptrace_event (PTRACE_EVENT_EXIT , code);user_events_exit (tsk); -validate_creds_for_do_exit (tsk); -io_uring_files_cancel ();exit_signals (tsk);/* sets PF_EXITING */
@@ -912,7 +910,6 @@ void __noreturn do_exit(long code)if (tsk->task_frag.page)put_page (tsk->task_frag.page); -validate_creds_for_do_exit (tsk);exit_task_stack_account (tsk);check_stack_usage ();
lib/Kconfig.debug +0 -15
@@ -1730,21 +1730,6 @@ config DEBUG_MAPLE_TREE endmenu -config DEBUG_CREDENTIALS - bool "Debug credential management" - depends on DEBUG_KERNEL - help - Enable this to turn on some debug checking for credential - management. The additional code keeps track of the number of - pointers from task_structs to any given cred struct, and checks to - see that this number never exceeds the usage count of the cred - struct. - - Furthermore, if SELinux is enabled, this also checks that the - security pointer in the cred struct is never seen to be invalid. - - If unsure, say N. - source "kernel/rcu/Kconfig.debug" config DEBUG_WQ_FORCE_RR_CPU
net/sunrpc/auth.c +0 -3
@@ -40,9 +40,6 @@ static unsigned long number_cred_unused;static struct cred machine_cred = { .usage =ATOMIC_INIT (1 ), -#ifdef CONFIG_DEBUG_CREDENTIALS - .magic =CRED_MAGIC , -#endif };/*
security/selinux/hooks.c +0 -6
@@ -1660,8 +1660,6 @@ static int inode_has_perm(const struct cstruct inode_security_struct *isec;u32 sid; -validate_creds (cred); -if (unlikely (IS_PRIVATE (inode)))return 0 ;
@@ -3056,8 +3054,6 @@ static int selinux_inode_follow_link(strstruct inode_security_struct *isec;u32 sid; -validate_creds (cred); - ad.type =LSM_AUDIT_DATA_DENTRY ; ad.u.dentry = dentry; sid =cred_sid (cred);
@@ -3101,8 +3097,6 @@ static int selinux_inode_permission(struif (!mask)return 0 ; -validate_creds (cred); -if (unlikely (IS_PRIVATE (inode)))return 0 ;
tools/objtool/noreturns.h +0 -1
@@ -6,7 +6,6 @@* * Yes, this is unfortunate. A better solution is in the works. */ -NORETURN(__invalid_creds) NORETURN(__kunit_abort) NORETURN(__module_put_and_kthread_exit) NORETURN(__reiserfs_panic)
tools/testing/selftests/bpf/config.x86_64 +0 -1
@@ -50,7 +50,6 @@ CONFIG_CRYPTO_SEQIV=y CONFIG_CRYPTO_XXHASH=y CONFIG_DCB=y CONFIG_DEBUG_ATOMIC_SLEEP=y -CONFIG_DEBUG_CREDENTIALS=y CONFIG_DEBUG_INFO_BTF=y CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y CONFIG_DEBUG_MEMORY_INIT=y
tools/testing/selftests/hid/config.common +0 -1
@@ -46,7 +46,6 @@ CONFIG_CRYPTO_SEQIV=y CONFIG_CRYPTO_XXHASH=y CONFIG_DCB=y CONFIG_DEBUG_ATOMIC_SLEEP=y -CONFIG_DEBUG_CREDENTIALS=y CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y CONFIG_DEBUG_MEMORY_INIT=y CONFIG_DEFAULT_FQ_CODEL=y
Greg Kroah-Hartman
maintainerPATCH 59/166 HID: i2c-hid: Add IDEA5002 to i2c_hid_acpi_blacklist[]
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit a9f68ffe1170ca4bc17ab29067d806a354a026e0 upstream.
Users have reported problems with recent Lenovo laptops that contain an IDEA5002 I2C HID device. Reports include fans turning on and running even at idle and spurious wakeups from suspend.
Presumably in the Windows ecosystem there is an application that uses the HID device. Maybe that puts it into a lower power state so it doesn't cause spurious events.
This device doesn't serve any functional purpose in Linux as nothing interacts with it so blacklist it from being probed. This will prevent the GPIO driver from setting up the GPIO and the spurious interrupts and wake events will not occur.
--- drivers/hid/i2c-hid/i2c-hid-acpi.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hid/i2c-hid/i2c-hid-acpi.c +5 -0
@@ -40,6 +40,11 @@ static const struct acpi_device_id i2c_h* ICN8505 controller, has a _CID of PNP0C50 but is not HID compatible. */ { "CHPN0001" }, +/* +* The IDEA5002 ACPI device causes high interrupt usage and spurious +* wakeups from suspend. +*/ + { "IDEA5002" }, { } };
Greg Kroah-Hartman
maintainerPATCH 60/166 HID: Add quirk for Labtec/ODDOR/aikeec handbrake
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Parschauer <[email protected]>
commit 31e52523267faab5ed8569b9d5c22c9a2283872f upstream.
This device needs ALWAYS_POLL quirk, otherwise it keeps reconnecting indefinitely. It is a handbrake for sim racing detected as joystick. Reported and tested by GitHub user N0th1ngM4tt3rs.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-quirks.c | 1 + 2 files changed, 2 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -744,6 +744,7 @@#define USB_VENDOR_ID_LABTEC 0x1020#define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006 +#define USB_DEVICE_ID_LABTEC_ODDOR_HANDBRAKE 0x8888#define USB_VENDOR_ID_LCPOWER 0x1241#define USB_DEVICE_ID_LCPOWER_LC1000 0xf767
drivers/hid/hid-quirks.c +1 -0
@@ -120,6 +120,7 @@ static const struct hid_device_id hid_qu { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M406XE), HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2), HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_PENSKETCH_T609A), HID_QUIRK_MULTI_INPUT }, + { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_ODDOR_HANDBRAKE), HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_OPTICAL_USB_MOUSE_600E), HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_608D), HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_6019), HID_QUIRK_ALWAYS_POLL },
Greg Kroah-Hartman
maintainerPATCH 61/166 fuse: Rename DIRECT_IO_RELAX to DIRECT_IO_ALLOW_MMAP
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tyler Fanelli <[email protected]>
commit c55e0a55b165202f18cbc4a20650d2e1becd5507 upstream.
Although DIRECT_IO_RELAX's initial usage is to allow shared mmap, its description indicates a purpose of reducing memory footprint. This may imply that it could be further used to relax other DIRECT_IO operations in the future.
Replace it with a flag DIRECT_IO_ALLOW_MMAP which does only one thing, allow shared mmap of DIRECT_IO files while still bypassing the cache on regular reads and writes.
[Miklos] Also Keep DIRECT_IO_RELAX definition for backward compatibility.
--- fs/fuse/file.c | 6 +++--- fs/fuse/fuse_i.h | 4 ++-- fs/fuse/inode.c | 6 +++--- include/uapi/linux/fuse.h | 10 ++++++---- 4 files changed, 14 insertions(+), 12 deletions(-)
fs/fuse/file.c +3 -3
@@ -1448,7 +1448,7 @@ ssize_t fuse_direct_io(struct fuse_io_prif (!ia)return -ENOMEM ; -if (fopen_direct_io && fc->direct_io_relax) { +if (fopen_direct_io && fc->direct_io_allow_mmap) { res =filemap_write_and_wait_range (mapping, pos, pos + count -1 );if (res) {fuse_io_free (ia);
@@ -2466,9 +2466,9 @@ static int fuse_file_mmap(struct file *fif (ff->open_flags &FOPEN_DIRECT_IO ) {/* Can't provide the coherency needed for MAP_SHARED -* if FUSE_DIRECT_IO_RELAX isn't set. +* if FUSE_DIRECT_IO_ALLOW_MMAP isn't set. */ -if ((vma->vm_flags &VM_MAYSHARE ) && !fc->direct_io_relax) +if ((vma->vm_flags &VM_MAYSHARE ) && !fc->direct_io_allow_mmap)return -ENODEV ;invalidate_inode_pages2 (file->f_mapping);
fs/fuse/fuse_i.h +2 -2
@@ -797,8 +797,8 @@ struct fuse_conn {/* Is tmpfile not implemented by fs? */ unsigned int no_tmpfile:1; -/* relax restrictions in FOPEN_DIRECT_IO mode */ - unsigned int direct_io_relax:1; +/* Relax restrictions to allow shared mmap in FOPEN_DIRECT_IO mode */ + unsigned int direct_io_allow_mmap:1;/* Is statx not implemented by fs? */ unsigned int no_statx:1;
fs/fuse/inode.c +3 -3
@@ -1232,8 +1232,8 @@ static void process_init_reply(struct fu fc->init_security =1 ;if (flags &FUSE_CREATE_SUPP_GROUP ) fc->create_supp_group =1 ; -if (flags &FUSE_DIRECT_IO_RELAX ) - fc->direct_io_relax =1 ; +if (flags &FUSE_DIRECT_IO_ALLOW_MMAP ) + fc->direct_io_allow_mmap =1 ; }else { ra_pages = fc->max_read /PAGE_SIZE ; fc->no_lock =1 ;
@@ -1280,7 +1280,7 @@ void fuse_send_init(struct fuse_mount *fFUSE_NO_OPENDIR_SUPPORT |FUSE_EXPLICIT_INVAL_DATA |FUSE_HANDLE_KILLPRIV_V2 |FUSE_SETXATTR_EXT |FUSE_INIT_EXT |FUSE_SECURITY_CTX |FUSE_CREATE_SUPP_GROUP | -FUSE_HAS_EXPIRE_ONLY |FUSE_DIRECT_IO_RELAX ; +FUSE_HAS_EXPIRE_ONLY |FUSE_DIRECT_IO_ALLOW_MMAP ;#ifdef CONFIG_FUSE_DAX if (fm->fc->dax) flags |=FUSE_MAP_ALIGNMENT ;
include/uapi/linux/fuse.h +6 -4
@@ -209,7 +209,7 @@* - add FUSE_HAS_EXPIRE_ONLY * * 7.39 -* - add FUSE_DIRECT_IO_RELAX +* - add FUSE_DIRECT_IO_ALLOW_MMAP * - add FUSE_STATX and related structures */
@@ -409,8 +409,7 @@ struct fuse_file_lock {* FUSE_CREATE_SUPP_GROUP: add supplementary group info to create, mkdir, * symlink and mknod (single group that matches parent) * FUSE_HAS_EXPIRE_ONLY: kernel supports expiry-only entry invalidation -* FUSE_DIRECT_IO_RELAX: relax restrictions in FOPEN_DIRECT_IO mode, for now -* allow shared mmap +* FUSE_DIRECT_IO_ALLOW_MMAP: allow shared mmap in FOPEN_DIRECT_IO mode. */ #define FUSE_ASYNC_READ (1 << 0)#define FUSE_POSIX_LOCKS (1 << 1)
@@ -449,7 +448,10 @@ struct fuse_file_lock {#define FUSE_HAS_INODE_DAX (1ULL << 33)#define FUSE_CREATE_SUPP_GROUP (1ULL << 34)#define FUSE_HAS_EXPIRE_ONLY (1ULL << 35) -#define FUSE_DIRECT_IO_RELAX (1ULL << 36) +#define FUSE_DIRECT_IO_ALLOW_MMAP (1ULL << 36) + +/* Obsolete alias for FUSE_DIRECT_IO_ALLOW_MMAP */ +#define FUSE_DIRECT_IO_RELAX FUSE_DIRECT_IO_ALLOW_MMAP/** * CUSE INIT request/reply flags
Greg Kroah-Hartman
maintainerPATCH 52/166 dpaa2-switch: do not ask for MDB, VLAN and FDB replay
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ioana Ciornei <[email protected]>
[ Upstream commit f24a49a375f65e8e75ee1b19d806f46dbaae57fd ]
Starting with commit 4e51bf44a03a ("net: bridge: move the switchdev object replay helpers to "push" mode") the switchdev_bridge_port_offload() helper was extended with the intention to provide switchdev drivers easy access to object addition and deletion replays. This works by calling the replay helpers with non-NULL notifier blocks.
In the same commit, the dpaa2-switch driver was updated so that it passes valid notifier blocks to the helper. At that moment, no regression was identified through testing.
In the meantime, the blamed commit changed the behavior in terms of which ports get hit by the replay. Before this commit, only the initial port which identified itself as offloaded through switchdev_bridge_port_offload() got a replay of all port objects and FDBs. After this, the newly joining port will trigger a replay of objects on all bridge ports and on the bridge itself.
This behavior leads to errors in dpaa2_switch_port_vlans_add() when a VLAN gets installed on the same interface multiple times.
The intended mechanism to address this is to pass a non-NULL ctx to the switchdev_bridge_port_offload() helper and then check it against the port's private structure. But since the driver does not have any use for the replayed port objects and FDBs until it gains support for LAG offload, it's better to fix the issue by reverting the dpaa2-switch driver to not ask for replay. The pointers will be added back when we are prepared to ignore replays on unrelated ports.
--- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +2 -9
@@ -1998,9 +1998,6 @@ static int dpaa2_switch_port_attr_set_event(struct net_device *netdev,return notifier_from_errno (err); } -static struct notifier_block dpaa2_switch_port_switchdev_nb; -static struct notifier_block dpaa2_switch_port_switchdev_blocking_nb; -static int dpaa2_switch_port_bridge_join (struct net_device *netdev,struct net_device *upper_dev,struct netlink_ext_ack *extack)
@@ -2043,9 +2040,7 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev, goto err_egress_flood; err =switchdev_bridge_port_offload (netdev, netdev,NULL , - &dpaa2_switch_port_switchdev_nb, - &dpaa2_switch_port_switchdev_blocking_nb, - false, extack); +NULL ,NULL , false, extack);if (err) goto err_switchdev_offload;
@@ -2079,9 +2074,7 @@ static int dpaa2_switch_port_restore_rxvlan(struct net_device *vdev, int vid, vostatic void dpaa2_switch_port_pre_bridge_leave (struct net_device *netdev) { -switchdev_bridge_port_unoffload (netdev,NULL , - &dpaa2_switch_port_switchdev_nb, - &dpaa2_switch_port_switchdev_blocking_nb); +switchdev_bridge_port_unoffload (netdev,NULL ,NULL ,NULL ); }static int dpaa2_switch_port_bridge_leave (struct net_device *netdev)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 85/166 x86/hyperv: Fix the detection of E820_TYPE_PRAM in a Gen2 VM
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saurabh Sengar <[email protected]>
[ Upstream commit 7e8037b099c0bbe8f2109dc452dbcab8d400fc53 ]
A Gen2 VM doesn't support legacy PCI/PCIe, so both raw_pci_ops and raw_pci_ext_ops are NULL, and pci_subsys_init() -> pcibios_init() doesn't call pcibios_resource_survey() -> e820__reserve_resources_late(); as a result, any emulated persistent memory of E820_TYPE_PRAM (12) via the kernel parameter memmap=nn[KMG]!ss is not added into iomem_resource and hence can't be detected by register_e820_pmem().
Fix this by directly calling e820__reserve_resources_late() in hv_pci_init(), which is called from arch_initcall(pci_arch_init).
It's ok to move a Gen2 VM's e820__reserve_resources_late() from subsys_initcall(pci_subsys_init) to arch_initcall(pci_arch_init) because the code in-between doesn't depend on the E820 resources. e820__reserve_resources_late() depends on e820__reserve_resources(), which has been called earlier from setup_arch().
For a Gen-2 VM, the new hv_pci_init() also adds any memory of E820_TYPE_PMEM (7) into iomem_resource, and acpi_nfit_register_region() -> acpi_nfit_insert_resource() -> region_intersects() returns REGION_INTERSECTS, so the memory of E820_TYPE_PMEM won't get added twice.
Changed the local variable "int gen2vm" to "bool gen2vm".
Message-ID: <[email protected]>
--- arch/x86/hyperv/hv_init.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
arch/x86/hyperv/hv_init.c +21 -4
@@ -15,6 +15,7 @@#include <linux/io.h> #include <asm/apic.h> #include <asm/desc.h> +#include <asm/e820/api.h> #include <asm/sev.h> #include <asm/ibt.h> #include <asm/hypervisor.h>
@@ -286,15 +287,31 @@ static int hv_cpu_die(unsigned int cpu)static int __init hv_pci_init (void ) { -int gen2vm =efi_enabled (EFI_BOOT ); +bool gen2vm =efi_enabled (EFI_BOOT );/* -* For Generation-2 VM, we exit from pci_arch_init() by returning 0. -* The purpose is to suppress the harmless warning: +* A Generation-2 VM doesn't support legacy PCI/PCIe, so both +* raw_pci_ops and raw_pci_ext_ops are NULL, and pci_subsys_init() -> +* pcibios_init() doesn't call pcibios_resource_survey() -> +* e820__reserve_resources_late(); as a result, any emulated persistent +* memory of E820_TYPE_PRAM (12) via the kernel parameter +* memmap=nn[KMG]!ss is not added into iomem_resource and hence can't be +* detected by register_e820_pmem(). Fix this by directly calling +* e820__reserve_resources_late() here: e820__reserve_resources_late() +* depends on e820__reserve_resources(), which has been called earlier +* from setup_arch(). Note: e820__reserve_resources_late() also adds +* any memory of E820_TYPE_PMEM (7) into iomem_resource, and +* acpi_nfit_register_region() -> acpi_nfit_insert_resource() -> +* region_intersects() returns REGION_INTERSECTS, so the memory of +* E820_TYPE_PMEM won't get added twice. +* +* We return 0 here so that pci_arch_init() won't print the warning: * "PCI: Fatal: No config space access function found" */ -if (gen2vm) +if (gen2vm) { +e820__reserve_resources_late ();return 0 ; + }/* For Generation-1 VM, we'll proceed in pci_arch_init(). */ return 1 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 94/166 bcache: avoid NULL checking to c->root in run_cache_set()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Coly Li <[email protected]>
[ Upstream commit 3eba5e0b2422aec3c9e79822029599961fdcab97 ]
In run_cache_set() after c->root returned from bch_btree_node_get(), it is checked by IS_ERR_OR_NULL(). Indeed it is unncessary to check NULL because bch_btree_node_get() will not return NULL pointer to caller.
This patch replaces IS_ERR_OR_NULL() by IS_ERR() for the above reason.
--- drivers/md/bcache/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/super.c +1 -1
@@ -2017,7 +2017,7 @@ static int run_cache_set(struct cache_set *c) c->root =bch_btree_node_get (c,NULL , k, j->btree_level, true,NULL ); -if (IS_ERR_OR_NULL (c->root)) +if (IS_ERR (c->root)) goto err;list_del_init (&c->root->list);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 95/166 nbd: fold nbd config initialization into nbd_alloc_config()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Nan <[email protected]>
[ Upstream commit 1b59860540a4018e8071dc18d4893ec389506b7d ]
There are no functional changes, make the code cleaner and prepare to fix null-ptr-dereference while accessing 'nbd->config'.
--- drivers/block/nbd.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-)
drivers/block/nbd.c +19 -22
@@ -1530,17 +1530,20 @@ static int nbd_ioctl(struct block_device *bdev, blk_mode_t mode,return error; } -static struct nbd_config *nbd_alloc_config (void ) +static int nbd_alloc_and_init_config (struct nbd_device *nbd) {struct nbd_config *config; +if (WARN_ON (nbd->config)) +return -EINVAL ; +if (!try_module_get (THIS_MODULE )) -return ERR_PTR (-ENODEV ); +return -ENODEV ; config =kzalloc (sizeof (struct nbd_config ),GFP_NOFS );if (!config) {module_put (THIS_MODULE ); -return ERR_PTR (-ENOMEM ); +return -ENOMEM ; }atomic_set (&config->recv_threads,0 );
@@ -1548,7 +1551,10 @@ static struct nbd_config *nbd_alloc_config(void)init_waitqueue_head (&config->conn_wait); config->blksize_bits =NBD_DEF_BLKSIZE_BITS ;atomic_set (&config->live_connections,0 ); -return config; + nbd->config = config; +refcount_set (&nbd->config_refs,1 ); + +return 0 ; }static int nbd_open (struct gendisk *disk,blk_mode_t mode)
@@ -1567,21 +1573,17 @@ static int nbd_open(struct gendisk *disk, blk_mode_t mode) goto out; }if (!refcount_inc_not_zero (&nbd->config_refs)) { -struct nbd_config *config; -mutex_lock (&nbd->config_lock);if (refcount_inc_not_zero (&nbd->config_refs)) {mutex_unlock (&nbd->config_lock); goto out; } - config =nbd_alloc_config (); -if (IS_ERR (config)) { - ret =PTR_ERR (config); + ret =nbd_alloc_and_init_config (nbd); +if (ret) {mutex_unlock (&nbd->config_lock); goto out; } - nbd->config = config; -refcount_set (&nbd->config_refs,1 ); +refcount_inc (&nbd->refs);mutex_unlock (&nbd->config_lock);if (max_part)
@@ -1990,22 +1992,17 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)pr_err ("nbd%d already in use\n" , index);return -EBUSY ; } -if (WARN_ON (nbd->config)) { -mutex_unlock (&nbd->config_lock); -nbd_put (nbd); -return -EINVAL ; - } - config =nbd_alloc_config (); -if (IS_ERR (config)) { + + ret =nbd_alloc_and_init_config (nbd); +if (ret) {mutex_unlock (&nbd->config_lock);nbd_put (nbd);pr_err ("couldn't allocate config\n" ); -return PTR_ERR (config); +return ret; } - nbd->config = config; -refcount_set (&nbd->config_refs,1 ); -set_bit (NBD_RT_BOUND , &config->runtime_flags); + config = nbd->config; +set_bit (NBD_RT_BOUND , &config->runtime_flags); ret =nbd_genl_size_set (info, nbd);if (ret) goto out;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 96/166 nbd: factor out a helper to get nbd_config without holding config_lock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Nan <[email protected]>
[ Upstream commit 3123ac77923341774ca3ad1196ad20bb0732bf70 ]
There are no functional changes, just to make code cleaner and prepare to fix null-ptr-dereference while accessing 'nbd->config'.
--- drivers/block/nbd.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
drivers/block/nbd.c +19 -8
@@ -395,6 +395,14 @@ static u32 req_to_nbd_cmd_type(struct request *req) } } +static struct nbd_config *nbd_get_config_unlocked (struct nbd_device *nbd) +{ +if (refcount_inc_not_zero (&nbd->config_refs)) +return nbd->config; + +return NULL ; +} +static enum blk_eh_timer_return nbd_xmit_timeout (struct request *req) {struct nbd_cmd *cmd =blk_mq_rq_to_pdu (req);
@@ -409,13 +417,13 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req)return BLK_EH_DONE ; } -if (!refcount_inc_not_zero (&nbd->config_refs)) { + config =nbd_get_config_unlocked (nbd); +if (!config) { cmd->status =BLK_STS_TIMEOUT ;__clear_bit (NBD_CMD_INFLIGHT , &cmd->flags);mutex_unlock (&cmd->lock); goto done; } - config = nbd->config;if (config->num_connections >1 || (config->num_connections ==1 && nbd->tag_set.timeout)) {
@@ -977,12 +985,12 @@ static int nbd_handle_cmd(struct nbd_cmd *cmd, int index)struct nbd_sock *nsock;int ret; -if (!refcount_inc_not_zero (&nbd->config_refs)) { + config =nbd_get_config_unlocked (nbd); +if (!config) {dev_err_ratelimited (disk_to_dev (nbd->disk),"Socks array is empty\n" );return -EINVAL ; } - config = nbd->config;if (index >= config->num_connections) { dev_err_ratelimited(disk_to_dev(nbd->disk),
@@ -1560,6 +1568,7 @@ static int nbd_alloc_and_init_config(struct nbd_device *nbd)static int nbd_open (struct gendisk *disk,blk_mode_t mode) {struct nbd_device *nbd; +struct nbd_config *config;int ret =0 ;mutex_lock (&nbd_index_mutex);
@@ -1572,7 +1581,9 @@ static int nbd_open(struct gendisk *disk, blk_mode_t mode) ret = -ENXIO ; goto out; } -if (!refcount_inc_not_zero (&nbd->config_refs)) { + + config =nbd_get_config_unlocked (nbd); +if (!config) {mutex_lock (&nbd->config_lock);if (refcount_inc_not_zero (&nbd->config_refs)) {mutex_unlock (&nbd->config_lock);
@@ -1588,7 +1599,7 @@ static int nbd_open(struct gendisk *disk, blk_mode_t mode)mutex_unlock (&nbd->config_lock);if (max_part)set_bit (GD_NEED_PART_SCAN , &disk->state); - }else if (nbd_disconnected (nbd->config)) { + }else if (nbd_disconnected (config)) {if (max_part)set_bit (GD_NEED_PART_SCAN , &disk->state); }
@@ -2205,7 +2216,8 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) }mutex_unlock (&nbd_index_mutex); -if (!refcount_inc_not_zero (&nbd->config_refs)) { + config =nbd_get_config_unlocked (nbd); +if (!config) {dev_err (nbd_to_dev (nbd),"not configured, cannot reconfigure\n" );nbd_put (nbd);
@@ -2213,7 +2225,6 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) }mutex_lock (&nbd->config_lock); - config = nbd->config;if (!test_bit (NBD_RT_BOUND , &config->runtime_flags) || !nbd->pid) { dev_err(nbd_to_dev(nbd),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 97/166 nbd: fix null-ptr-dereference while accessing nbd->config
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Nan <[email protected]>
[ Upstream commit c2da049f419417808466c529999170f5c3ef7d3d ]
Memory reordering may occur in nbd_genl_connect(), causing config_refs to be set to 1 while nbd->config is still empty. Opening nbd at this time will cause null-ptr-dereference.
T1 T2
nbd_open
nbd_get_config_unlocked
nbd_genl_connect
nbd_alloc_and_init_config
//memory reordered
refcount_set(&nbd->config_refs, 1) // 2
nbd->config
->null point
nbd->config = config // 1Fix it by adding smp barrier to guarantee the execution sequence.
--- drivers/block/nbd.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/block/nbd.c +17 -1
@@ -397,8 +397,16 @@ static u32 req_to_nbd_cmd_type(struct request *req)static struct nbd_config *nbd_get_config_unlocked (struct nbd_device *nbd) { -if (refcount_inc_not_zero (&nbd->config_refs)) +if (refcount_inc_not_zero (&nbd->config_refs)) { +/* +* Add smp_mb__after_atomic to ensure that reading nbd->config_refs +* and reading nbd->config is ordered. The pair is the barrier in +* nbd_alloc_and_init_config(), avoid nbd->config_refs is set +* before nbd->config. +*/ +smp_mb__after_atomic ();return nbd->config; + }return NULL ; }
@@ -1559,7 +1567,15 @@ static int nbd_alloc_and_init_config(struct nbd_device *nbd)init_waitqueue_head (&config->conn_wait); config->blksize_bits =NBD_DEF_BLKSIZE_BITS ;atomic_set (&config->live_connections,0 ); + nbd->config = config; +/* +* Order refcount_set(&nbd->config_refs, 1) and nbd->config assignment, +* its pair is the barrier in nbd_get_config_unlocked(). +* So nbd_get_config_unlocked() won't see nbd->config as null after +* refcount_inc_not_zero() succeed. +*/ +smp_mb__before_atomic ();refcount_set (&nbd->config_refs,1 );return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 98/166 nvme-auth: set explanation code for failure2 msgs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark O'Donovan <[email protected]>
[ Upstream commit 38ce1570e2c46e7e9af983aa337edd7e43723aa2 ]
Some error cases were not setting an auth-failure-reason-code-explanation. This means an AUTH_Failure2 message will be sent with an explanation value of 0 which is a reserved value.
--- drivers/nvme/host/auth.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/auth.c +2 -0
@@ -840,6 +840,8 @@ static void nvme_queue_auth_work(struct } fail2: +if (chap->status ==0 ) + chap->status =NVME_AUTH_DHCHAP_FAILURE_FAILED ;dev_dbg (ctrl->device,"%s: qid %d send failure2, status %x\n" , __func__, chap->qid, chap->status); tl =nvme_auth_set_dhchap_failure2_data (ctrl, chap);
Greg Kroah-Hartman
maintainerPATCH 99/166 nvme: catch errors from nvme_configure_metadata()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
[ Upstream commit cd9aed606088d36a7ffff3e808db4e76b1854285 ]
nvme_configure_metadata() is issuing I/O, so we might incur an I/O error which will cause the connection to be reset.
But in that case any further probing will race with reset and cause UAF errors.
So return a status from nvme_configure_metadata() and abort probing if there was an I/O error.
--- drivers/nvme/host/core.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/nvme/host/core.c +13 -6
@@ -1813,16 +1813,18 @@ static int nvme_init_ms(struct nvme_ns *ns, struct nvme_id_ns *id)return ret; } -static void nvme_configure_metadata (struct nvme_ns *ns,struct nvme_id_ns *id) +static int nvme_configure_metadata (struct nvme_ns *ns,struct nvme_id_ns *id) {struct nvme_ctrl *ctrl = ns->ctrl; +int ret; -if (nvme_init_ms (ns, id)) -return ; + ret =nvme_init_ms (ns, id); +if (ret) +return ret; ns->features &= ~(NVME_NS_METADATA_SUPPORTED |NVME_NS_EXT_LBAS );if (!ns->ms || !(ctrl->ops->flags &NVME_F_METADATA_SUPPORTED )) -return ; +return 0 ;if (ctrl->ops->flags &NVME_F_FABRICS ) {/*
@@ -1831,7 +1833,7 @@ static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)* remap the separate metadata buffer from the block layer. */ if (WARN_ON_ONCE (!(id->flbas &NVME_NS_FLBAS_META_EXT ))) -return ; +return 0 ; ns->features |=NVME_NS_EXT_LBAS ;
@@ -1858,6 +1860,7 @@ static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)else ns->features |=NVME_NS_METADATA_SUPPORTED ; } +return 0 ; } static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
@@ -2038,7 +2041,11 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, ns->lba_shift = id->lbaf[lbaf].ds;nvme_set_queue_limits (ns->ctrl, ns->queue); -nvme_configure_metadata (ns, id); + ret =nvme_configure_metadata (ns, id); +if (ret <0 ) { +blk_mq_unfreeze_queue (ns->disk->queue); + goto out; + }nvme_set_chunk_sectors (ns, id);nvme_update_disk_info (ns->disk, ns, id);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 100/166 selftests/bpf: fix bpf_loop_bench for new callback verification scheme
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
[ Upstream commit f40bfd1679446b22d321e64a1fa98b7d07d2be08 ]
This is a preparatory change. A follow-up patch "bpf: verify callbacks as if they are called unknown number of times" changes logic for callbacks handling. While previously callbacks were verified as a single function call, new scheme takes into account that callbacks could be executed unknown number of times.
This has dire implications for bpf_loop_bench:
SEC("fentry/" SYS_PREFIX "sys_getpgid")
int benchmark(void *ctx)
{
for (int i = 0; i < 1000; i++) {
bpf_loop(nr_loops, empty_callback, NULL, 0);
__sync_add_and_fetch(&hits, nr_loops);
}
return 0;
}W/o callbacks change verifier sees it as a 1000 calls to empty_callback(). However, with callbacks change things become exponential:
- i=0: state exploring empty_callback is scheduled with i=0 (a);
- i=1: state exploring empty_callback is scheduled with i=1;
...
- i=999: state exploring empty_callback is scheduled with i=999;
- state (a) is popped from stack;
- i=1: state exploring empty_callback is scheduled with i=1;
...
Avoid this issue by rewriting outer loop as bpf_loop(). Unfortunately, this adds a function call to a loop at runtime, which negatively affects performance:
throughput latency
before: 149.919 ± 0.168 M ops/s, 6.670 ns/op
after : 137.040 ± 0.187 M ops/s, 7.297 ns/op
--- tools/testing/selftests/bpf/progs/bpf_loop_bench.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
tools/testing/selftests/bpf/progs/bpf_loop_bench.c +8 -5
@@ -15,13 +15,16 @@ static int empty_callback(__u32 index, void *data)return 0 ; } +static int outer_loop (__u32 index,void *data) +{ +bpf_loop (nr_loops, empty_callback,NULL ,0 ); +__sync_add_and_fetch (&hits, nr_loops); +return 0 ; +} + SEC("fentry/" SYS_PREFIX "sys_getpgid")int benchmark (void *ctx) { -for (int i =0 ; i <1000 ; i++) { -bpf_loop (nr_loops, empty_callback,NULL ,0 ); - -__sync_add_and_fetch (&hits, nr_loops); - } +bpf_loop (1000 , outer_loop,NULL ,0 );return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 101/166 LoongArch: Add dependency between vmlinuz.efi and vmlinux.efi
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit d3ec75bc635cb0cb8185b63293d33a3d1b942d22 ]
A common issue in Makefile is a race in parallel building.
You need to be careful to prevent multiple threads from writing to the same file simultaneously.
Commit 3939f3345050 ("ARM: 8418/1: add boot image dependencies to not generate invalid images") addressed such a bad scenario.
A similar symptom occurs with the following command:
$ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
[ snip ]
SORTTAB vmlinux
OBJCOPY arch/loongarch/boot/vmlinux.efi
OBJCOPY arch/loongarch/boot/vmlinux.efi
PAD arch/loongarch/boot/vmlinux.bin
GZIP arch/loongarch/boot/vmlinuz
OBJCOPY arch/loongarch/boot/vmlinuz.o
LD arch/loongarch/boot/vmlinuz.efi.elf
OBJCOPY arch/loongarch/boot/vmlinuz.efiThe log "OBJCOPY arch/loongarch/boot/vmlinux.efi" is displayed twice.
It indicates that two threads simultaneously enter arch/loongarch/boot/ and write to arch/loongarch/boot/vmlinux.efi.
It occasionally leads to a build failure:
$ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
[ snip ]
SORTTAB vmlinux
OBJCOPY arch/loongarch/boot/vmlinux.efi
PAD arch/loongarch/boot/vmlinux.bin
truncate: Invalid number: ‘arch/loongarch/boot/vmlinux.bin’
make[2]: *** [drivers/firmware/efi/libstub/Makefile.zboot:13:
arch/loongarch/boot/vmlinux.bin] Error 1
make[2]: *** Deleting file 'arch/loongarch/boot/vmlinux.bin'
make[1]: *** [arch/loongarch/Makefile:146: vmlinuz.efi] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:234: __sub-make] Error 2vmlinuz.efi depends on vmlinux.efi, but such a dependency is not specified in arch/loongarch/Makefile.
--- arch/loongarch/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/loongarch/Makefile +2 -0
@@ -142,6 +142,8 @@ vdso_install: all: $(notdir $(KBUILD_IMAGE)) +vmlinuz.efi: vmlinux.efi + vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 102/166 LoongArch: Record pc instead of offset in la_abs relocation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: WANG Rui <[email protected]>
[ Upstream commit aa0cbc1b506b090c3a775b547c693ada108cc0d7 ]
To clarify, the previous version functioned flawlessly. However, it's worth noting that the LLVM's LoongArch backend currently lacks support for cross-section label calculations. With this patch, we enable the use of clang to compile relocatable kernels.
--- arch/loongarch/include/asm/asmmacro.h | 3 +-- arch/loongarch/include/asm/setup.h | 2 +- arch/loongarch/kernel/relocate.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-)
arch/loongarch/include/asm/asmmacro.h +1 -2
@@ -609,8 +609,7 @@ lu32i.d \reg, 0 lu52i.d \reg, \reg, 0 .pushsection ".la_abs", "aw", %progbits - 768: - .dword 768b-766b + .dword 766b .dword \sym .popsection#endif
arch/loongarch/include/asm/setup.h +1 -1
@@ -25,7 +25,7 @@ extern void set_merr_handler(unsigned long offset, void *addr, unsigned long len#ifdef CONFIG_RELOCATABLE struct rela_la_abs { -long offset; +long pc;long symvalue; };
arch/loongarch/kernel/relocate.c +1 -1
@@ -52,7 +52,7 @@ static inline void __init relocate_absolute(long random_offset)for (p = begin; (void *)p < end; p++) {long v = p->symvalue;uint32_t lu12iw, ori, lu32id, lu52id; -union loongarch_instruction *insn = (void *)p - p->offset; +union loongarch_instruction *insn = (void *)p->pc; lu12iw = (v >>12 ) &0xfffff ; ori = v &0xfff ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 103/166 LoongArch: Silence the boot warning about nokaslr
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
[ Upstream commit 902d75cdf0cf0a3fb58550089ee519abf12566f5 ]
The kernel parameter 'nokaslr' is handled before start_kernel(), so we don't need early_param() to mark it technically. But it can cause a boot warning as follows:
Unknown kernel command line parameters "nokaslr", will be passed to user space.
When we use 'init=/bin/bash', 'nokaslr' which passed to user space will even cause a kernel panic. So we use early_param() to mark 'nokaslr', simply print a notice and silence the boot warning (also fix a potential panic). This logic is similar to RISC-V.
--- arch/loongarch/kernel/relocate.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/loongarch/kernel/relocate.c +8 -0
@@ -102,6 +102,14 @@ static inline __init unsigned long get_random_boot(void)return hash; } +static int __init nokaslr (char *p) +{ +pr_info ("KASLR is disabled.\n" ); + +return 0 ;/* Print a notice and silence the boot warning */ +} +early_param ("nokaslr" , nokaslr); +static inline __init bool kaslr_disabled (void ) {char *str;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 86/166 usb: aqc111: check packet for fixup for true limit
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit ccab434e674ca95d483788b1895a70c21b7f016a ]
If a device sends a packet that is inbetween 0 and sizeof(u64) the value passed to skb_trim() as length will wrap around ending up as some very large value.
The driver will then proceed to parse the header located at that position, which will either oops or process some random value.
The fix is to check against sizeof(u64) rather than 0, which the driver currently does. The issue exists since the introduction of the driver.
--- drivers/net/usb/aqc111.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/usb/aqc111.c +4 -4
@@ -1079,17 +1079,17 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb)u16 pkt_count =0 ;u64 desc_hdr =0 ;u16 vlan_tag =0 ; -u32 skb_len =0 ; +u32 skb_len;if (!skb) goto err; -if (skb->len ==0 ) + skb_len = skb->len; +if (skb_len <sizeof (desc_hdr)) goto err; - skb_len = skb->len;/* RX Descriptor Header */ -skb_trim (skb, skb->len -sizeof (desc_hdr)); +skb_trim (skb, skb_len -sizeof (desc_hdr)); desc_hdr =le64_to_cpup ((u64 *)skb_tail_pointer (skb));/* Check these packets */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 104/166 LoongArch: Mark {dmw,tlb}_virt_to_page() exports as non-GPL
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
[ Upstream commit 19d86a496233731882aea7ec24505ce6641b1c0c ]
Mark {dmw,tlb}_virt_to_page() exports as non-GPL, in order to let out-of-tree modules (e.g. OpenZFS) be built without errors. Otherwise we get:
ERROR: modpost: GPL-incompatible module zfs.ko uses GPL-only symbol 'dmw_virt_to_page'
ERROR: modpost: GPL-incompatible module zfs.ko uses GPL-only symbol 'tlb_virt_to_page'
--- arch/loongarch/mm/pgtable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/loongarch/mm/pgtable.c +2 -2
@@ -13,13 +13,13 @@ struct page *dmw_virt_to_page(unsigned long kaddr) {return pfn_to_page (virt_to_pfn (kaddr)); } -EXPORT_SYMBOL_GPL (dmw_virt_to_page); +EXPORT_SYMBOL (dmw_virt_to_page);struct page *tlb_virt_to_page (unsigned long kaddr) {return pfn_to_page (pte_pfn (*virt_to_kpte (kaddr))); } -EXPORT_SYMBOL_GPL (tlb_virt_to_page); +EXPORT_SYMBOL (tlb_virt_to_page);pgd_t *pgd_alloc (struct mm_struct *mm) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 105/166 LoongArch: Implement constant timer shutdown interface
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bibo Mao <[email protected]>
[ Upstream commit d43f37b73468c172bc89ac4824a1511b411f0778 ]
When a cpu is hot-unplugged, it is put in idle state and the function arch_cpu_idle_dead() is called. The timer interrupt for this processor should be disabled, otherwise there will be pending timer interrupt for the unplugged cpu, so that vcpu is prevented from giving up scheduling when system is running in vm mode.
This patch implements the timer shutdown interface so that the constant timer will be properly disabled when a CPU is hot-unplugged.
--- arch/loongarch/kernel/time.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
arch/loongarch/kernel/time.c +9 -14
@@ -58,14 +58,16 @@ static int constant_set_state_oneshot(struct clock_event_device *evt)return 0 ; } -static int constant_set_state_oneshot_stopped (struct clock_event_device *evt) +static int constant_set_state_periodic (struct clock_event_device *evt) { +unsigned long period;unsigned long timer_config;raw_spin_lock (&state_lock); - timer_config =csr_read64 (LOONGARCH_CSR_TCFG ); - timer_config &= ~CSR_TCFG_EN ; + period = const_clock_freq /HZ ; + timer_config = period &CSR_TCFG_VAL ; + timer_config |= (CSR_TCFG_PERIOD |CSR_TCFG_EN );csr_write64 (timer_config,LOONGARCH_CSR_TCFG );raw_spin_unlock (&state_lock);
@@ -73,16 +75,14 @@ static int constant_set_state_oneshot_stopped(struct clock_event_device *evt)return 0 ; } -static int constant_set_state_periodic (struct clock_event_device *evt) +static int constant_set_state_shutdown (struct clock_event_device *evt) { -unsigned long period;unsigned long timer_config;raw_spin_lock (&state_lock); - period = const_clock_freq /HZ ; - timer_config = period &CSR_TCFG_VAL ; - timer_config |= (CSR_TCFG_PERIOD |CSR_TCFG_EN ); + timer_config =csr_read64 (LOONGARCH_CSR_TCFG ); + timer_config &= ~CSR_TCFG_EN ;csr_write64 (timer_config,LOONGARCH_CSR_TCFG );raw_spin_unlock (&state_lock);
@@ -90,11 +90,6 @@ static int constant_set_state_periodic(struct clock_event_device *evt)return 0 ; } -static int constant_set_state_shutdown (struct clock_event_device *evt) -{ -return 0 ; -} -static int constant_timer_next_event (unsigned long delta,struct clock_event_device *evt) {unsigned long timer_config;
@@ -161,7 +156,7 @@ int constant_clockevent_init(void) cd->rating =320 ; cd->cpumask =cpumask_of (cpu); cd->set_state_oneshot = constant_set_state_oneshot; - cd->set_state_oneshot_stopped = constant_set_state_oneshot_stopped; + cd->set_state_oneshot_stopped = constant_set_state_shutdown; cd->set_state_periodic = constant_set_state_periodic; cd->set_state_shutdown = constant_set_state_shutdown; cd->set_next_event = constant_timer_next_event;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 106/166 platform/x86: intel_telemetry: Fix kernel doc descriptions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit a6584711e64d9d12ab79a450ec3628fd35e4f476 ]
LKP found issues with a kernel doc in the driver:
core.c:116: warning: Function parameter or member 'ioss_evtconfig' not described in 'telemetry_update_events' core.c:188: warning: Function parameter or member 'ioss_evtconfig' not described in 'telemetry_get_eventconfig'
It looks like it were copy'n'paste typos when these descriptions had been introduced. Fix the typos.
--- drivers/platform/x86/intel/telemetry/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/intel/telemetry/core.c +2 -2
@@ -102,7 +102,7 @@ static const struct telemetry_core_ops telm_defpltops = {/** * telemetry_update_events() - Update telemetry Configuration * @pss_evtconfig: PSS related config. No change if num_evts = 0. -* @pss_evtconfig: IOSS related config. No change if num_evts = 0. +* @ioss_evtconfig: IOSS related config. No change if num_evts = 0. * * This API updates the IOSS & PSS Telemetry configuration. Old config * is overwritten. Call telemetry_reset_events when logging is over
@@ -176,7 +176,7 @@ EXPORT_SYMBOL_GPL(telemetry_reset_events);/** * telemetry_get_eventconfig() - Returns the pss and ioss events enabled * @pss_evtconfig: Pointer to PSS related configuration. -* @pss_evtconfig: Pointer to IOSS related configuration. +* @ioss_evtconfig: Pointer to IOSS related configuration. * @pss_len: Number of u32 elements allocated for pss_evtconfig array * @ioss_len: Number of u32 elements allocated for ioss_evtconfig array *
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 107/166 HID: mcp2221: Set driver data before I2C adapter add
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hamish Martin <[email protected]>
[ Upstream commit f2d4a5834638bbc967371b9168c0b481519f7c5e ]
The process of adding an I2C adapter can invoke I2C accesses on that new adapter (see i2c_detect()).
Ensure we have set the adapter's driver data to avoid null pointer dereferences in the xfer functions during the adapter add.
This has been noted in the past and the same fix proposed but not completed. See:
https://lore.kernel.org/lkml/[email protected]/
--- drivers/hid/hid-mcp2221.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-mcp2221.c +1 -1
@@ -1157,12 +1157,12 @@ static int mcp2221_probe(struct hid_device *hdev,snprintf (mcp->adapter.name,sizeof (mcp->adapter.name),"MCP2221 usb-i2c bridge" ); +i2c_set_adapdata (&mcp->adapter, mcp); ret =devm_i2c_add_adapter (&hdev->dev, &mcp->adapter);if (ret) {hid_err (hdev,"can't add usb-i2c adapter: %d\n" , ret);return ret; } -i2c_set_adapdata (&mcp->adapter, mcp);#if IS_REACHABLE (CONFIG_GPIOLIB )/* Setup GPIO chip */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 108/166 HID: mcp2221: Allow IO to start during probe
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hamish Martin <[email protected]>
[ Upstream commit 73ce9f1f2741a38f5d27393e627702ae2c46e6f2 ]
During the probe we add an I2C adapter and as soon as we add that adapter it may be used for a transfer (e.g via the code in i2cdetect()). Those transfers are not able to complete and time out. This is because the HID raw_event callback (mcp2221_raw_event) will not be invoked until the HID device's 'driver_input_lock' is marked up at the completion of the probe in hid_device_probe(). This starves the driver of the responses it is waiting for.
In order to allow the I2C transfers to complete while we are still in the probe, start the IO once we have completed init of the HID device.
This issue seems to have been seen before and a patch was submitted but it seems it was never accepted. See:
https://lore.kernel.org/all/[email protected]/
--- drivers/hid/hid-mcp2221.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/hid-mcp2221.c +2 -0
@@ -1142,6 +1142,8 @@ static int mcp2221_probe(struct hid_device *hdev,if (ret)return ret; +hid_device_io_start (hdev); +/* Set I2C bus clock diviser */ if (i2c_clk_freq >400 ) i2c_clk_freq =400 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 109/166 HID: apple: add Jamesdonkey and A3R to non-apple keyboards list
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yihong Cao <[email protected]>
[ Upstream commit 113f736655e4f20633e107d731dd5bd097d5938c ]
Jamesdonkey A3R keyboard is identified as "Jamesdonkey A3R" in wired mode, "A3R-U" in wireless mode and "A3R" in bluetooth mode. Adding them to non-apple keyboards fixes function key.
--- drivers/hid/hid-apple.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/hid-apple.c +2 -0
@@ -345,6 +345,8 @@ static const struct apple_non_apple_keyboard non_apple_keyboards[] = { { "AONE" }, { "GANSS" }, { "Hailuck" }, + { "Jamesdonkey" }, + { "A3R" }, };static bool apple_is_non_apple_keyboard (struct hid_device *hdev)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 110/166 HID: glorious: fix Glorious Model I HID report
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brett Raye <[email protected]>
[ Upstream commit a5e913c25b6b2b6ae02acef6d9400645ac03dfdf ]
The Glorious Model I mouse has a buggy HID report descriptor for its keyboard endpoint (used for programmable buttons). For report ID 2, there is a mismatch between Logical Minimum and Usage Minimum in the array that reports keycodes.
The offending portion of the descriptor: (from hid-decode)
0x95, 0x05, // Report Count (5) 30 0x75, 0x08, // Report Size (8) 32 0x15, 0x00, // Logical Minimum (0) 34 0x25, 0x65, // Logical Maximum (101) 36 0x05, 0x07, // Usage Page (Keyboard) 38 0x19, 0x01, // Usage Minimum (1) 40 0x29, 0x65, // Usage Maximum (101) 42 0x81, 0x00, // Input (Data,Arr,Abs) 44
This bug shifts all programmed keycodes up by 1. Importantly, this causes "empty" array indexes of 0x00 to be interpreted as 0x01, ErrorRollOver. The presence of ErrorRollOver causes the system to ignore all keypresses from the endpoint and breaks the ability to use the programmable buttons.
Setting byte 41 to 0x00 fixes this, and causes keycodes to be interpreted correctly.
Also, USB_VENDOR_ID_GLORIOUS is changed to USB_VENDOR_ID_SINOWEALTH, and a new ID for Laview Technology is added. Glorious seems to be white-labeling controller boards or mice from these vendors. There isn't a single canonical vendor ID for Glorious products.
--- drivers/hid/hid-glorious.c | 16 ++++++++++++++-- drivers/hid/hid-ids.h | 11 +++++++---- 2 files changed, 21 insertions(+), 6 deletions(-)
drivers/hid/hid-glorious.c +14 -2
@@ -21,6 +21,10 @@ MODULE_DESCRIPTION("HID driver for Glori* Glorious Model O and O- specify the const flag in the consumer input * report descriptor, which leads to inputs being ignored. Fix this * by patching the descriptor. +* +* Glorious Model I incorrectly specifes the Usage Minimum for its +* keyboard HID report, causing keycodes to be misinterpreted. +* Fix this by setting Usage Minimum to 0 in that report. */ static __u8 *glorious_report_fixup (struct hid_device *hdev,__u8 *rdesc,unsigned int *rsize)
@@ -32,6 +36,10 @@ static __u8 *glorious_report_fixup(struc rdesc[85 ] = rdesc[113 ] = rdesc[141 ] = \HID_MAIN_ITEM_VARIABLE |HID_MAIN_ITEM_RELATIVE ; } +if (*rsize ==156 && rdesc[41 ] ==1 ) { +hid_info (hdev,"patching Glorious Model I keyboard report descriptor\n" ); + rdesc[41 ] =0 ; + }return rdesc; }
@@ -44,6 +52,8 @@ static void glorious_update_name(struct model ="Model O" ;break ;case USB_DEVICE_ID_GLORIOUS_MODEL_D : model ="Model D" ;break ; +case USB_DEVICE_ID_GLORIOUS_MODEL_I : + model ="Model I" ;break ; }snprintf (hdev->name,sizeof (hdev->name),"%s %s" ,"Glorious" , model);
@@ -66,10 +76,12 @@ static int glorious_probe(struct hid_dev }static const struct hid_device_id glorious_devices[] = { - {HID_USB_DEVICE (USB_VENDOR_ID_GLORIOUS , + {HID_USB_DEVICE (USB_VENDOR_ID_SINOWEALTH ,USB_DEVICE_ID_GLORIOUS_MODEL_O ) }, - {HID_USB_DEVICE (USB_VENDOR_ID_GLORIOUS , + {HID_USB_DEVICE (USB_VENDOR_ID_SINOWEALTH ,USB_DEVICE_ID_GLORIOUS_MODEL_D ) }, + {HID_USB_DEVICE (USB_VENDOR_ID_LAVIEW , +USB_DEVICE_ID_GLORIOUS_MODEL_I ) }, { } };MODULE_DEVICE_TABLE (hid, glorious_devices);
drivers/hid/hid-ids.h +7 -4
@@ -511,10 +511,6 @@#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A 0x010a#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100 0xe100 -#define USB_VENDOR_ID_GLORIOUS 0x258a -#define USB_DEVICE_ID_GLORIOUS_MODEL_D 0x0033 -#define USB_DEVICE_ID_GLORIOUS_MODEL_O 0x0036 -#define I2C_VENDOR_ID_GOODIX 0x27c6#define I2C_DEVICE_ID_GOODIX_01F0 0x01f0
@@ -746,6 +742,9 @@#define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006#define USB_DEVICE_ID_LABTEC_ODDOR_HANDBRAKE 0x8888 +#define USB_VENDOR_ID_LAVIEW 0x22D4 +#define USB_DEVICE_ID_GLORIOUS_MODEL_I 0x1503 +#define USB_VENDOR_ID_LCPOWER 0x1241#define USB_DEVICE_ID_LCPOWER_LC1000 0xf767
@@ -1160,6 +1159,10 @@#define USB_VENDOR_ID_SIGMATEL 0x066F#define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780 +#define USB_VENDOR_ID_SINOWEALTH 0x258a +#define USB_DEVICE_ID_GLORIOUS_MODEL_D 0x0033 +#define USB_DEVICE_ID_GLORIOUS_MODEL_O 0x0036 +#define USB_VENDOR_ID_SIS_TOUCH 0x0457#define USB_DEVICE_ID_SIS9200_TOUCH 0x9200#define USB_DEVICE_ID_SIS817_TOUCH 0x0817
Greg Kroah-Hartman
maintainerPATCH 111/166 HID: add ALWAYS_POLL quirk for Apple kb
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit c55092187d9ad7b2f8f5a8645286fa03997d442f ]
These devices disconnect if suspended without remote wakeup. They can operate with the standard driver.
--- drivers/hid/hid-quirks.c | 1 + 1 file changed, 1 insertion(+)
drivers/hid/hid-quirks.c +1 -0
@@ -33,6 +33,7 @@ static const struct hid_device_id hid_quirks[] = { { HID_USB_DEVICE(USB_VENDOR_ID_AKAI, USB_DEVICE_ID_AKAI_MPKMINI2), HID_QUIRK_NO_INIT_REPORTS }, { HID_USB_DEVICE(USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD), HID_QUIRK_BADPAD }, { HID_USB_DEVICE(USB_VENDOR_ID_AMI, USB_DEVICE_ID_AMI_VIRT_KEYBOARD_AND_MOUSE), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI), HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM), HID_QUIRK_NOGET }, { HID_USB_DEVICE(USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC), HID_QUIRK_NOGET }, { HID_USB_DEVICE(USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM), HID_QUIRK_NOGET },
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 112/166 nbd: pass nbd_sock to nbd_read_reply() instead of index
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Nan <[email protected]>
[ Upstream commit 98c598afc22d4e43c2ad91860b65996d0c099a5d ]
If a socket is processing ioctl 'NBD_SET_SOCK', config->socks might be krealloc in nbd_add_socket(), and a garbage request is received now, a UAF may occurs.
T1
nbd_ioctl
__nbd_ioctl
nbd_add_socket
blk_mq_freeze_queue
T2
recv_work
nbd_read_reply
sock_xmit
krealloc config->socks
def config->socksPass nbd_sock to nbd_read_reply(). And introduce a new function sock_xmit_recv(), which differs from sock_xmit only in the way it get socket.
==================================================================
BUG: KASAN: use-after-free in sock_xmit+0x525/0x550 Read of size 8 at addr ffff8880188ec428 by task kworker/u12:1/18779 Workqueue: knbd4-recv recv_work Call Trace: __dump_stack dump_stack+0xbe/0xfd print_address_description.constprop.0+0x19/0x170 __kasan_report.cold+0x6c/0x84 kasan_report+0x3a/0x50 sock_xmit+0x525/0x550 nbd_read_reply+0xfe/0x2c0 recv_work+0x1c2/0x750 process_one_work+0x6b6/0xf10 worker_thread+0xdd/0xd80 kthread+0x30a/0x410 ret_from_fork+0x22/0x30 Allocated by task 18784: kasan_save_stack+0x1b/0x40 kasan_set_track set_alloc_info __kasan_kmalloc __kasan_kmalloc.constprop.0+0xf0/0x130 slab_post_alloc_hook slab_alloc_node slab_alloc __kmalloc_track_caller+0x157/0x550 __do_krealloc krealloc+0x37/0xb0 nbd_add_socket +0x2d3/0x880 __nbd_ioctl nbd_ioctl+0x584/0x8e0 __blkdev_driver_ioctl blkdev_ioctl+0x2a0/0x6e0 block_ioctl+0xee/0x130 vfs_ioctl __do_sys_ioctl __se_sys_ioctl+0x138/0x190 do_syscall_64+0x33/0x40 entry_SYSCALL_64_after_hwframe+0x61/0xc6 Freed by task 18784: kasan_save_stack+0x1b/0x40 kasan_set_track+0x1c/0x30 kasan_set_free_info+0x20/0x40 __kasan_slab_free.part.0+0x13f/0x1b0 slab_free_hook slab_free_freelist_hook slab_free kfree+0xcb/0x6c0 krealloc+0x56/0xb0 nbd_add_socket+0x2d3/0x880 __nbd_ioctl nbd_ioctl+0x584/0x8e0 __blkdev_driver_ioctl blkdev_ioctl+0x2a0/0x6e0 block_ioctl+0xee/0x130 vfs_ioctl __do_sys_ioctl __se_sys_ioctl+0x138/0x190 do_syscall_64+0x33/0x40 entry_SYSCALL_64_after_hwframe+0x61/0xc6
--- drivers/block/nbd.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-)
drivers/block/nbd.c +22 -13
@@ -67,6 +67,7 @@ struct nbd_sock {struct recv_thread_args {struct work_struct work;struct nbd_device *nbd; +struct nbd_sock *nsock;int index; };
@@ -505,15 +506,9 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req)return BLK_EH_DONE ; } -/* -* Send or receive packet. Return a positive value on success and -* negtive value on failue, and never return 0. -*/ -static int sock_xmit (struct nbd_device *nbd,int index,int send, -struct iov_iter *iter,int msg_flags,int *sent) +static int __sock_xmit (struct nbd_device *nbd,struct socket *sock,int send, +struct iov_iter *iter,int msg_flags,int *sent) { -struct nbd_config *config = nbd->config; -struct socket *sock = config->socks[index]->sock;int result;struct msghdr msg;unsigned int noreclaim_flag;
@@ -556,6 +551,19 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send,return result; } +/* +* Send or receive packet. Return a positive value on success and +* negtive value on failure, and never return 0. +*/ +static int sock_xmit (struct nbd_device *nbd,int index,int send, +struct iov_iter *iter,int msg_flags,int *sent) +{ +struct nbd_config *config = nbd->config; +struct socket *sock = config->socks[index]->sock; + +return __sock_xmit (nbd, sock, send, iter, msg_flags, sent); +} +/* * Different settings for sk->sk_sndtimeo can result in different return values * if there is a signal pending when we enter sendmsg, because reasons?
@@ -712,7 +720,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)return 0 ; } -static int nbd_read_reply (struct nbd_device *nbd,int index, +static int nbd_read_reply (struct nbd_device *nbd,struct socket *sock,struct nbd_reply *reply) {struct kvec iov = {.iov_base = reply, .iov_len =sizeof (*reply)};
@@ -721,7 +729,7 @@ static int nbd_read_reply(struct nbd_device *nbd, int index, reply->magic =0 ;iov_iter_kvec (&to,ITER_DEST , &iov,1 ,sizeof (*reply)); - result =sock_xmit (nbd, index,0 , &to,MSG_WAITALL ,NULL ); + result =__sock_xmit (nbd, sock,0 , &to,MSG_WAITALL ,NULL );if (result <0 ) {if (!nbd_disconnected (nbd->config)) dev_err(disk_to_dev(nbd->disk),
@@ -845,14 +853,14 @@ static void recv_work(struct work_struct *work)struct nbd_device *nbd = args->nbd;struct nbd_config *config = nbd->config;struct request_queue *q = nbd->disk->queue; -struct nbd_sock *nsock; +struct nbd_sock *nsock = args->nsock;struct nbd_cmd *cmd;struct request *rq;while (1 ) {struct nbd_reply reply; -if (nbd_read_reply (nbd, args->index, &reply)) +if (nbd_read_reply (nbd, nsock->sock, &reply))break ;/*
@@ -887,7 +895,6 @@ static void recv_work(struct work_struct *work)percpu_ref_put (&q->q_usage_counter); } - nsock = config->socks[args->index];mutex_lock (&nsock->tx_lock);nbd_mark_nsock_dead (nbd, nsock,1 );mutex_unlock (&nsock->tx_lock);
@@ -1231,6 +1238,7 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)INIT_WORK (&args->work, recv_work); args->index = i; args->nbd = nbd; + args->nsock = nsock; nsock->cookie++;mutex_unlock (&nsock->tx_lock);sockfd_put (old);
@@ -1413,6 +1421,7 @@ static int nbd_start_device(struct nbd_device *nbd)refcount_inc (&nbd->config_refs);INIT_WORK (&args->work, recv_work); args->nbd = nbd; + args->nsock = config->socks[i]; args->index = i;queue_work (nbd->recv_workq, &args->work); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 113/166 HID: hid-asus: reset the backlight brightness level on resume
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Benato <[email protected]>
[ Upstream commit 546edbd26cff7ae990e480a59150e801a06f77b1 ]
Some devices managed by this driver automatically set brightness to 0 before entering a suspended state and reset it back to a default brightness level after the resume:
this has the effect of having the kernel report wrong brightness status after a sleep, and on some devices (like the Asus RC71L) that brightness is the intensity of LEDs directly facing the user.
Fix the above issue by setting back brightness to the level it had before entering a sleep state.
--- drivers/hid/hid-asus.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/hid/hid-asus.c +19 -0
@@ -1000,6 +1000,24 @@ static int asus_start_multitouch(struct hid_device *hdev)return 0 ; } +static int __maybe_unused asus_resume (struct hid_device *hdev) { +struct asus_drvdata *drvdata =hid_get_drvdata (hdev); +int ret =0 ; + +if (drvdata->kbd_backlight) { +const u8 buf[] = {FEATURE_KBD_REPORT_ID ,0xba ,0xc5 ,0xc4 , + drvdata->kbd_backlight->cdev.brightness }; + ret =asus_kbd_set_report (hdev, buf,sizeof (buf)); +if (ret <0 ) { +hid_err (hdev,"Asus failed to set keyboard backlight: %d\n" , ret); + goto asus_resume_err; + } + } + +asus_resume_err: +return ret; +} +static int __maybe_unused asus_reset_resume (struct hid_device *hdev) {struct asus_drvdata *drvdata =hid_get_drvdata (hdev);
@@ -1294,6 +1312,7 @@ static struct hid_driver asus_driver = { .input_configured = asus_input_configured, #ifdef CONFIG_PM .reset_resume = asus_reset_resume, + .resume = asus_resume, #endif .event = asus_event, .raw_event = asus_raw_event
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 87/166 stmmac: dwmac-loongson: Add architecture dependency
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean Delvare <[email protected]>
[ Upstream commit 7fbd5fc2b35a8f559a6b380dfa9bcd964a758186 ]
Only present the DWMAC_LOONGSON option on architectures where it can actually be used.
This follows the same logic as the DWMAC_INTEL option.
--- drivers/net/ethernet/stmicro/stmmac/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/Kconfig +1 -1
@@ -269,7 +269,7 @@ config DWMAC_INTEL config DWMAC_LOONGSON tristate "Loongson PCI DWMAC support" default MACH_LOONGSON64 - depends on STMMAC_ETH && PCI + depends on (MACH_LOONGSON64 || COMPILE_TEST) && STMMAC_ETH && PCI depends on COMMON_CLK help This selects the LOONGSON PCI bus support for the stmmac driver,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 114/166 HID: multitouch: Add quirk for HONOR GLO-GXXX touchpad
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aoba K <[email protected]>
[ Upstream commit 9ffccb691adb854e7b7f3ee57fbbda12ff70533f ]
Honor MagicBook 13 2023 has a touchpad which do not switch to the multitouch mode until the input mode feature is written by the host. The touchpad do report the input mode at touchpad(3), while itself working under mouse mode. As a workaround, it is possible to call MT_QUIRE_FORCE_GET_FEATURE to force set feature in mt_set_input_mode for such device.
The touchpad reports as BLTP7853, which cannot retrive any useful manufacture information on the internel by this string at present. As the serial number of the laptop is GLO-G52, while DMI info reports the laptop serial number as GLO-GXXX, this workaround should applied to all models which has the GLO-GXXX.
--- drivers/hid/hid-multitouch.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hid/hid-multitouch.c +5 -0
@@ -2048,6 +2048,11 @@ static const struct hid_device_id mt_devices[] = { MT_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) }, +/* HONOR GLO-GXXX panel */ + { .driver_data = MT_CLS_VTL, +HID_DEVICE (BUS_I2C ,HID_GROUP_MULTITOUCH_WIN_8 , + 0x347d, 0x7853) }, + /* Ilitek dual touch panel */ { .driver_data = MT_CLS_NSMU, MT_USB_DEVICE(USB_VENDOR_ID_ILITEK,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 115/166 nfc: virtual_ncidev: Add variable to check if ndev is running
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Dinh Phi <[email protected]>
[ Upstream commit 84d2db91f14a32dc856a5972e3f0907089093c7a ]
syzbot reported an memory leak that happens when an skb is add to send_buff after virtual nci closed.
This patch adds a variable to track if the ndev is running before handling new skb in send function.
--- drivers/nfc/virtual_ncidev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/nfc/virtual_ncidev.c +6 -1
@@ -26,10 +26,14 @@ struct virtual_nci_dev {struct mutex mtx;struct sk_buff *send_buff;struct wait_queue_head wq; +bool running; };static int virtual_nci_open (struct nci_dev *ndev) { +struct virtual_nci_dev *vdev =nci_get_drvdata (ndev); + + vdev->running = true;return 0 ; }
@@ -40,6 +44,7 @@ static int virtual_nci_close(struct nci_dev *ndev)mutex_lock (&vdev->mtx);kfree_skb (vdev->send_buff); vdev->send_buff =NULL ; + vdev->running = false;mutex_unlock (&vdev->mtx);return 0 ;
@@ -50,7 +55,7 @@ static int virtual_nci_send(struct nci_dev *ndev, struct sk_buff *skb)struct virtual_nci_dev *vdev =nci_get_drvdata (ndev);mutex_lock (&vdev->mtx); -if (vdev->send_buff) { +if (vdev->send_buff || !vdev->running) {mutex_unlock (&vdev->mtx);kfree_skb (skb);return -1 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 88/166 rxrpc: Fix some minor issues with bundle tracing
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 0c3bd086d12d185650d095a906662593ec607bd0 ]
Fix some superficial issues with the tracing of rxrpc_bundle structs, including:
(1) Set the debug_id when the bundle is allocated rather than when it is set up so that the "NEW" trace line displays the correct bundle ID.
(2) Show the refcount when emitting the "FREE" traceline.
--- net/rxrpc/conn_client.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/rxrpc/conn_client.c +4 -3
@@ -73,6 +73,7 @@ static void rxrpc_destroy_client_conn_ids(struct rxrpc_local *local)static struct rxrpc_bundle *rxrpc_alloc_bundle (struct rxrpc_call *call,gfp_t gfp) { +static atomic_t rxrpc_bundle_id;struct rxrpc_bundle *bundle; bundle =kzalloc (sizeof (*bundle), gfp);
@@ -85,6 +86,7 @@ static struct rxrpc_bundle *rxrpc_alloc_bundle(struct rxrpc_call *call, bundle->upgrade =test_bit (RXRPC_CALL_UPGRADE , &call->flags); bundle->service_id = call->dest_srx.srx_service; bundle->security_level = call->security_level; + bundle->debug_id =atomic_inc_return (&rxrpc_bundle_id);refcount_set (&bundle->ref,1 );atomic_set (&bundle->active,1 );INIT_LIST_HEAD (&bundle->waiting_calls);
@@ -105,7 +107,8 @@ struct rxrpc_bundle *rxrpc_get_bundle(struct rxrpc_bundle *bundle,static void rxrpc_free_bundle (struct rxrpc_bundle *bundle) { -trace_rxrpc_bundle (bundle->debug_id,1 , rxrpc_bundle_free); +trace_rxrpc_bundle (bundle->debug_id,refcount_read (&bundle->ref), + rxrpc_bundle_free);rxrpc_put_peer (bundle->peer, rxrpc_peer_put_bundle);key_put (bundle->key);kfree (bundle);
@@ -239,7 +242,6 @@ static bool rxrpc_may_reuse_conn(struct rxrpc_connection *conn)*/ int rxrpc_look_up_bundle (struct rxrpc_call *call,gfp_t gfp) { -static atomic_t rxrpc_bundle_id;struct rxrpc_bundle *bundle, *candidate;struct rxrpc_local *local = call->local;struct rb_node *p, **pp, *parent;
@@ -306,7 +308,6 @@ int rxrpc_look_up_bundle(struct rxrpc_call *call, gfp_t gfp) }_debug ("new bundle" ); - candidate->debug_id =atomic_inc_return (&rxrpc_bundle_id);rb_link_node (&candidate->local_node, parent, pp);rb_insert_color (&candidate->local_node, &local->client_bundles); call->bundle =rxrpc_get_bundle (candidate, rxrpc_bundle_get_client_call);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 89/166 blk-throttle: fix lockdep warning of "cgroup_mutex or RCU read lock required!"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
[ Upstream commit 27b13e209ddca5979847a1b57890e0372c1edcee ]
Inside blkg_for_each_descendant_pre(), both css_for_each_descendant_pre() and blkg_lookup() requires RCU read lock, and either cgroup_assert_mutex_or_rcu_locked() or rcu_read_lock_held() is called.
Fix the warning by adding rcu read lock.
--- block/blk-throttle.c | 2 ++ 1 file changed, 2 insertions(+)
block/blk-throttle.c +2 -0
@@ -1320,6 +1320,7 @@ static void tg_conf_updated(struct throtl_grp *tg, bool global)tg_bps_limit (tg,READ ),tg_bps_limit (tg,WRITE ), tg_iops_limit(tg, READ), tg_iops_limit(tg, WRITE)); +rcu_read_lock ();/* * Update has_rules[] flags for the updated tg's subtree. A tg is * considered to have rules if either the tg itself or any of its
@@ -1347,6 +1348,7 @@ static void tg_conf_updated(struct throtl_grp *tg, bool global) this_tg->latency_target =max (this_tg->latency_target, parent_tg->latency_target); } +rcu_read_unlock ();/* * We're already holding queue_lock and know @tg is valid. Let's
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 90/166 blk-cgroup: bypass blkcg_deactivate_policy after destroying
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
[ Upstream commit e63a57303599b17290cd8bc48e6f20b24289a8bc ]
blkcg_deactivate_policy() can be called after blkg_destroy_all() returns, and it isn't necessary since blkg_destroy_all has covered policy deactivation.
--- block/blk-cgroup.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
block/blk-cgroup.c +13 -0
@@ -577,6 +577,7 @@ static void blkg_destroy_all(struct gendisk *disk)struct request_queue *q = disk->queue;struct blkcg_gq *blkg, *n;int count =BLKG_DESTROY_BATCH_SIZE ; +int i; restart:spin_lock_irq (&q->queue_lock);
@@ -602,6 +603,18 @@ static void blkg_destroy_all(struct gendisk *disk) } } +/* +* Mark policy deactivated since policy offline has been done, and +* the free is scheduled, so future blkcg_deactivate_policy() can +* be bypassed +*/ +for (i =0 ; i <BLKCG_MAX_POLS ; i++) { +struct blkcg_policy *pol = blkcg_policy[i]; + +if (pol) +__clear_bit (pol->plid, q->blkcg_pols); + } + q->root_blkg =NULL ;spin_unlock_irq (&q->queue_lock); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 91/166 bcache: avoid oversize memory allocation by small stripe_size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Coly Li <[email protected]>
[ Upstream commit baf8fb7e0e5ec54ea0839f0c534f2cdcd79bea9c ]
Arraies bcache->stripe_sectors_dirty and bcache->full_dirty_stripes are used for dirty data writeback, their sizes are decided by backing device capacity and stripe size. Larger backing device capacity or smaller stripe size make these two arraies occupies more dynamic memory space.
Currently bcache->stripe_size is directly inherited from queue->limits.io_opt of underlying storage device. For normal hard drives, its limits.io_opt is 0, and bcache sets the corresponding stripe_size to 1TB (1<<31 sectors), it works fine 10+ years. But for devices do declare value for queue->limits.io_opt, small stripe_size (comparing to 1TB) becomes an issue for oversize memory allocations of bcache->stripe_sectors_dirty and bcache->full_dirty_stripes, while the capacity of hard drives gets much larger in recent decade.
For example a raid5 array assembled by three 20TB hardrives, the raid device capacity is 40TB with typical 512KB limits.io_opt. After the math calculation in bcache code, these two arraies will occupy 400MB dynamic memory. Even worse Andrea Tomassetti reports that a 4KB limits.io_opt is declared on a new 2TB hard drive, then these two arraies request 2GB and 512MB dynamic memory from kzalloc(). The result is that bcache device always fails to initialize on his system.
To avoid the oversize memory allocation, bcache->stripe_size should not directly inherited by queue->limits.io_opt from the underlying device. This patch defines BCH_MIN_STRIPE_SZ (4MB) as minimal bcache stripe size and set bcache device's stripe size against the declared limits.io_opt value from the underlying storage device,
- If the declared limits.io_opt > BCH_MIN_STRIPE_SZ, bcache device will set its stripe size directly by this limits.io_opt value.
- If the declared limits.io_opt < BCH_MIN_STRIPE_SZ, bcache device will set its stripe size by a value multiplying limits.io_opt and euqal or large than BCH_MIN_STRIPE_SZ.
Then the minimal stripe size of a bcache device will always be >= 4MB. For a 40TB raid5 device with 512KB limits.io_opt, memory occupied by bcache->stripe_sectors_dirty and bcache->full_dirty_stripes will be 50MB in total. For a 2TB hard drive with 4KB limits.io_opt, memory occupied by these two arraies will be 2.5MB in total.
Such mount of memory allocated for bcache->stripe_sectors_dirty and bcache->full_dirty_stripes is reasonable for most of storage devices.
--- drivers/md/bcache/bcache.h | 1 + drivers/md/bcache/super.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/md/bcache/bcache.h +1 -0
@@ -265,6 +265,7 @@ struct bcache_device {#define BCACHE_DEV_WB_RUNNING 3#define BCACHE_DEV_RATE_DW_RUNNING 4int nr_stripes; +#define BCH_MIN_STRIPE_SZ ((4 << 20) >> SECTOR_SHIFT)unsigned int stripe_size;atomic_t *stripe_sectors_dirty;unsigned long *full_dirty_stripes;
drivers/md/bcache/super.c +2 -0
@@ -905,6 +905,8 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,if (!d->stripe_size) d->stripe_size =1 <<31 ; +else if (d->stripe_size <BCH_MIN_STRIPE_SZ ) + d->stripe_size =roundup (BCH_MIN_STRIPE_SZ , d->stripe_size); n =DIV_ROUND_UP_ULL (sectors, d->stripe_size);if (!n || n > max_stripes) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 92/166 bcache: remove redundant assignment to variable cur_idx
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
[ Upstream commit be93825f0e6428c2d3f03a6e4d447dc48d33d7ff ]
Variable cur_idx is being initialized with a value that is never read, it is being re-assigned later in a while-loop. Remove the redundant assignment. Cleans up clang scan build warning:
drivers/md/bcache/writeback.c:916:2: warning: Value stored to 'cur_idx' is never read [deadcode.DeadStores]
--- drivers/md/bcache/writeback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/writeback.c +1 -1
@@ -913,7 +913,7 @@ static int bch_dirty_init_thread(void *arg)int cur_idx, prev_idx, skip_nr; k = p =NULL ; - cur_idx = prev_idx =0 ; + prev_idx =0 ;bch_btree_iter_init (&c->root->keys, &iter,NULL ); k =bch_btree_iter_next_filter (&iter, &c->root->keys, bch_ptr_bad);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 93/166 bcache: add code comments for bch_btree_node_get() and __bch_btree_node_alloc()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Coly Li <[email protected]>
[ Upstream commit 31f5b956a197d4ec25c8a07cb3a2ab69d0c0b82f ]
This patch adds code comments to bch_btree_node_get() and __bch_btree_node_alloc() that NULL pointer will not be returned and it is unnecessary to check NULL pointer by the callers of these routines.
--- drivers/md/bcache/btree.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/md/bcache/btree.c +7 -0
@@ -995,6 +995,9 @@ static struct btree *mca_alloc(struct cache_set *c, struct btree_op *op,* * The btree node will have either a read or a write lock held, depending on * level and op->lock. +* +* Note: Only error code or btree pointer will be returned, it is unncessary +* for callers to check NULL pointer. */ struct btree *bch_btree_node_get(struct cache_set *c, struct btree_op *op, struct bkey *k, int level, bool write,
@@ -1106,6 +1109,10 @@ static void btree_node_free(struct btree *b)mutex_unlock (&b->c->bucket_lock); } +/* +* Only error code or btree pointer will be returned, it is unncessary for +* callers to check NULL pointer. +*/ struct btree *__bch_btree_node_alloc (struct cache_set *c,struct btree_op *op,int level,bool wait,struct btree *parent)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 84/166 selftests/mm: cow: print ksft header before printing anything else
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
[ Upstream commit a6fcd57cf2df409d35e9225b8dbad6f937b28df0 ]
Doing a ksft_print_msg() before the ksft_print_header() seems to confuse the ksft framework in a strange way: running the test on the cmdline results in the expected output.
But piping the output somewhere else, results in some odd output, whereby we repeatedly get the same info printed:
# [INFO] detected THP size: 2048 KiB
# [INFO] detected hugetlb page size: 2048 KiB
# [INFO] detected hugetlb page size: 1048576 KiB
# [INFO] huge zeropage is enabled
TAP version 13
1..190
# [INFO] Anonymous memory tests in private mappings # [RUN] Basic COW after fork() ... with base page # [INFO] detected THP size: 2048 KiB
# [INFO] detected hugetlb page size: 2048 KiB
# [INFO] detected hugetlb page size: 1048576 KiB
# [INFO] huge zeropage is enabled
TAP version 13
1..190
# [INFO] Anonymous memory tests in private mappings # [RUN] Basic COW after fork() ... with base page ok 1 No leak from parent into child
# [RUN] Basic COW after fork() ... with swapped out base page # [INFO] detected THP size: 2048 KiB
# [INFO] detected hugetlb page size: 2048 KiB
# [INFO] detected hugetlb page size: 1048576 KiB
# [INFO] huge zeropage is enabled
Doing the ksft_print_header() first seems to resolve that and gives us the output we expect:
TAP version 13
# [INFO] detected THP size: 2048 KiB
# [INFO] detected hugetlb page size: 2048 KiB
# [INFO] detected hugetlb page size: 1048576 KiB
# [INFO] huge zeropage is enabled
1..190
# [INFO] Anonymous memory tests in private mappings # [RUN] Basic COW after fork() ... with base page ok 1 No leak from parent into child
# [RUN] Basic COW after fork() ... with swapped out base page ok 2 No leak from parent into child
# [RUN] Basic COW after fork() ... with THP
ok 3 No leak from parent into child
# [RUN] Basic COW after fork() ... with swapped-out THP ok 4 No leak from parent into child
# [RUN] Basic COW after fork() ... with PTE-mapped THP ok 5 No leak from parent into child
--- tools/testing/selftests/mm/cow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/mm/cow.c +2 -1
@@ -1680,6 +1680,8 @@ int main(int argc, char **argv) {int err; +ksft_print_header (); + pagesize =getpagesize (); thpsize =read_pmd_pagesize ();if (thpsize)
@@ -1689,7 +1691,6 @@ int main(int argc, char **argv) ARRAY_SIZE(hugetlbsizes));detect_huge_zeropage (); -ksft_print_header ();ksft_set_plan (ARRAY_SIZE (anon_test_cases) *tests_per_anon_test_case () +ARRAY_SIZE (anon_thp_test_cases) *tests_per_anon_thp_test_case () +ARRAY_SIZE (non_anon_test_cases) *tests_per_non_anon_test_case ());
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 117/166 asm-generic: qspinlock: fix queued_spin_value_unlocked() implementation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
[ Upstream commit 125b0bb95dd6bec81b806b997a4ccb026eeecf8f ]
We really don't want to do atomic_read() or anything like that, since we already have the value, not the lock. The whole point of this is that we've loaded the lock from memory, and we want to check whether the value we loaded was a locked one or not.
The main use of this is the lockref code, which loads both the lock and the reference count in one atomic operation, and then works on that combined value. With the atomic_read(), the compiler would pointlessly spill the value to the stack, in order to then be able to read it back "atomically".
This is the qspinlock version of commit c6f4a9002252 ("asm-generic:
ticket-lock: Optimize arch_spin_value_unlocked()") which fixed this same bug for ticket locks.
--- include/asm-generic/qspinlock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/qspinlock.h +1 -1
@@ -70,7 +70,7 @@ static __always_inline int queued_spin_is_locked(struct qspinlock *lock)*/ static __always_inline int queued_spin_value_unlocked(struct qspinlock lock) { -return !atomic_read (&lock.val); +return !lock.val.counter; }/**
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 126/166 btrfs: do not allow non subvolume root targets for snapshot
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit a8892fd71933126ebae3d60aec5918d4dceaae76 upstream.
Our btrfs subvolume snapshot <source> <destination> utility enforces that <source> is the root of the subvolume, however this isn't enforced in the kernel. Update the kernel to also enforce this limitation to avoid problems with other users of this ioctl that don't have the appropriate checks in place.
--- fs/btrfs/ioctl.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/btrfs/ioctl.c +9 -0
@@ -1290,6 +1290,15 @@ static noinline int __btrfs_ioctl_snap_c* are limited to own subvolumes only */ ret = -EPERM ; + }else if (btrfs_ino (BTRFS_I (src_inode)) !=BTRFS_FIRST_FREE_OBJECTID ) { +/* +* Snapshots must be made with the src_inode referring +* to the subvolume inode, otherwise the permission +* checking above is useless because we may have +* permission on a lower directory but not the subvol +* itself. +*/ + ret = -EINVAL ; }else { ret = btrfs_mksnapshot(&file->f_path, idmap, name, namelen,
Greg Kroah-Hartman
maintainerPATCH 127/166 cxl/hdm: Fix dpa translation locking
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
commit 6f5c4eca48ffe18307b4e1d375817691c9005c87 upstream.
The helper, cxl_dpa_resource_start(), snapshots the dpa-address of an endpoint-decoder after acquiring the cxl_dpa_rwsem. However, it is sufficient to assert that cxl_dpa_rwsem is held rather than acquire it in the helper. Otherwise, it triggers multiple lockdep reports:
1/ Tracing callbacks are in an atomic context that can not acquire sleeping locks:
BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1525
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1288, name: bash
preempt_count: 2, expected: 0
RCU nest depth: 0, expected: 0
[..]
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS edk2-20230524-3.fc38 05/24/2023
Call Trace:
<TASK>
dump_stack_lvl+0x71/0x90
__might_resched+0x1b2/0x2c0
down_read+0x1a/0x190
cxl_dpa_resource_start+0x15/0x50 [cxl_core]
cxl_trace_hpa+0x122/0x300 [cxl_core]
trace_event_raw_event_cxl_poison+0x1c9/0x2d0 [cxl_core]2/ The rwsem is already held in the inject poison path:
WARNING: possible recursive locking detected
6.7.0-rc2+ #12 Tainted: G W OE N
--------------------------------------------
bash/1288 is trying to acquire lock:
ffffffffc05f73d0 (cxl_dpa_rwsem){++++}-{3:3}, at: cxl_dpa_resource_start+0x15/0x50 [cxl_core]
but task is already holding lock:
ffffffffc05f73d0 (cxl_dpa_rwsem){++++}-{3:3}, at: cxl_inject_poison+0x7d/0x1e0 [cxl_core]
[..]
Call Trace:
<TASK>
dump_stack_lvl+0x71/0x90
__might_resched+0x1b2/0x2c0
down_read+0x1a/0x190
cxl_dpa_resource_start+0x15/0x50 [cxl_core]
cxl_trace_hpa+0x122/0x300 [cxl_core]
trace_event_raw_event_cxl_poison+0x1c9/0x2d0 [cxl_core]
__traceiter_cxl_poison+0x5c/0x80 [cxl_core]
cxl_inject_poison+0x1bc/0x1e0 [cxl_core]This appears to have been an issue since the initial implementation and uncovered by the new cxl-poison.sh test [1]. That test is now passing with these changes.
--- drivers/cxl/core/hdm.c | 3 +-- drivers/cxl/core/port.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/cxl/core/hdm.c +1 -2
@@ -373,10 +373,9 @@ resource_size_t cxl_dpa_resource_start(s {resource_size_t base =-1 ; -down_read (&cxl_dpa_rwsem); +lockdep_assert_held (&cxl_dpa_rwsem);if (cxled->dpa_res) base = cxled->dpa_res->start; -up_read (&cxl_dpa_rwsem);return base; }
drivers/cxl/core/port.c +2 -2
@@ -219,9 +219,9 @@ static ssize_t dpa_resource_show(struct char *buf) {struct cxl_endpoint_decoder *cxled =to_cxl_endpoint_decoder (dev); -u64 base =cxl_dpa_resource_start (cxled); -return sysfs_emit (buf,"%#llx\n" , base); +guard (rwsem_read)(&cxl_dpa_rwsem); +return sysfs_emit (buf,"%#llx\n" , (u64 )cxl_dpa_resource_start (cxled)); }static DEVICE_ATTR_RO (dpa_resource);
Greg Kroah-Hartman
maintainerPATCH 128/166 soundwire: stream: fix NULL pointer dereference for multi_link
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit e199bf52ffda8f98f129728d57244a9cd9ad5623 upstream.
If bus is marked as multi_link, but number of masters in the stream is not higher than bus->hw_sync_min_links (bus->multi_link && m_rt_count >= bus->hw_sync_min_links), bank switching should not happen. The first part of do_bank_switch() code properly takes these conditions into account, but second part (sdw_ml_sync_bank_switch()) relies purely on bus->multi_link property. This is not balanced and leads to NULL pointer dereference:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 ... Call trace: wait_for_completion_timeout+0x124/0x1f0 do_bank_switch+0x370/0x6f8 sdw_prepare_stream+0x2d0/0x438 qcom_snd_sdw_prepare+0xa0/0x118 sm8450_snd_prepare+0x128/0x148 snd_soc_link_prepare+0x5c/0xe8 __soc_pcm_prepare+0x28/0x1ec dpcm_be_dai_prepare+0x1e0/0x2c0 dpcm_fe_dai_prepare+0x108/0x28c snd_pcm_do_prepare+0x44/0x68 snd_pcm_action_single+0x54/0xc0 snd_pcm_action_nonatomic+0xe4/0xec snd_pcm_prepare+0xc4/0x114 snd_pcm_common_ioctl+0x1154/0x1cc0 snd_pcm_ioctl+0x54/0x74
--- drivers/soundwire/stream.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/soundwire/stream.c +4 -3
@@ -742,14 +742,15 @@ error_1:* sdw_ml_sync_bank_switch: Multilink register bank switch * * @bus: SDW bus instance +* @multi_link: whether this is a multi-link stream with hardware-based sync * * Caller function should free the buffers on error */ -static int sdw_ml_sync_bank_switch (struct sdw_bus *bus) +static int sdw_ml_sync_bank_switch (struct sdw_bus *bus,bool multi_link) {unsigned long time_left; -if (!bus->multi_link) +if (!multi_link)return 0 ;/* Wait for completion of transfer */
@@ -847,7 +848,7 @@ static int do_bank_switch(struct sdw_str bus->bank_switch_timeout =DEFAULT_BANK_SWITCH_TIMEOUT ;/* Check if bank switch was successful */ - ret =sdw_ml_sync_bank_switch (bus); + ret =sdw_ml_sync_bank_switch (bus, multi_link);if (ret <0 ) {dev_err (bus->dev,"multi link bank switch failed: %d\n" , ret);
Greg Kroah-Hartman
maintainerPATCH 129/166 ext4: prevent the normalized size from exceeding EXT_MAX_BLOCKS
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 2dcf5fde6dffb312a4bfb8ef940cea2d1f402e32 upstream.
For files with logical blocks close to EXT_MAX_BLOCKS, the file size predicted in ext4_mb_normalize_request() may exceed EXT_MAX_BLOCKS. This can cause some blocks to be preallocated that will not be used. And after [Fixes], the following issue may be triggered:
=========================================================
kernel BUG at fs/ext4/mballoc.c:4653!
Internal error: Oops - BUG: 00000000f2000800 [#1] SMP CPU: 1 PID: 2357 Comm: xfs_io 6.7.0-rc2-00195-g0f5cc96c367f Hardware name: linux,dummy-virt (DT) pc : ext4_mb_use_inode_pa+0x148/0x208 lr : ext4_mb_use_inode_pa+0x98/0x208 Call trace: ext4_mb_use_inode_pa+0x148/0x208 ext4_mb_new_inode_pa+0x240/0x4a8 ext4_mb_use_best_found+0x1d4/0x208 ext4_mb_try_best_found+0xc8/0x110 ext4_mb_regular_allocator+0x11c/0xf48 ext4_mb_new_blocks+0x790/0xaa8 ext4_ext_map_blocks+0x7cc/0xd20 ext4_map_blocks+0x170/0x600 ext4_iomap_begin+0x1c0/0x348 =========================================================
Here is a calculation when adjusting ac_b_ex in ext4_mb_new_inode_pa():
ex.fe_logical = orig_goal_end - EXT4_C2B(sbi, ex.fe_len); if (ac->ac_o_ex.fe_logical >= ex.fe_logical) goto adjust_bex;
The problem is that when orig_goal_end is subtracted from ac_b_ex.fe_len it is still greater than EXT_MAX_BLOCKS, which causes ex.fe_logical to overflow to a very small value, which ultimately triggers a BUG_ON in ext4_mb_new_inode_pa() because pa->pa_free < len.
The last logical block of an actual write request does not exceed EXT_MAX_BLOCKS, so in ext4_mb_normalize_request() also avoids normalizing the last logical block to exceed EXT_MAX_BLOCKS to avoid the above issue.
The test case in [Link] can reproduce the above issue with 64k block size.
--- fs/ext4/mballoc.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ext4/mballoc.c +4 -0
@@ -4489,6 +4489,10 @@ ext4_mb_normalize_request(struct ext4_al start =max (start,rounddown (ac->ac_o_ex.fe_logical, (ext4_lblk_t )EXT4_BLOCKS_PER_GROUP (ac->ac_sb))); +/* avoid unnecessary preallocation that may trigger assertions */ +if (start + size >EXT_MAX_BLOCKS ) + size =EXT_MAX_BLOCKS - start; +/* don't cover already allocated blocks in selected range */ if (ar->pleft && start <= ar->lleft) { size -= ar->lleft +1 - start;
Greg Kroah-Hartman
maintainerPATCH 130/166 Revert "selftests: error out if kernel header files are not yet built"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Hubbard <[email protected]>
commit 43e8832fed08438e2a27afed9bac21acd0ceffe5 upstream.
This reverts commit 9fc96c7c19df ("selftests: error out if kernel header files are not yet built").
It turns out that requiring the kernel headers to be built as a prerequisite to building selftests, does not work in many cases. For example, Peter Zijlstra writes:
"My biggest beef with the whole thing is that I simply do not want to use 'make headers', it doesn't work for me.
I have a ton of output directories and I don't care to build tools into the output dirs, in fact some of them flat out refuse to work that way (bpf comes to mind)." [1]
Therefore, stop erroring out on the selftests build. Additional patches will be required in order to change over to not requiring the kernel headers.
[1] https://lore.kernel.org/[email protected]
--- tools/testing/selftests/Makefile | 21 -------------------- tools/testing/selftests/lib.mk | 40 ++------------------------------------- 2 files changed, 4 insertions(+), 57 deletions(-)
tools/testing/selftests/Makefile +1 -20
@@ -152,12 +152,10 @@ ifneq ($(KBUILD_OUTPUT),) abs_objtree := $(realpath $(abs_objtree)) BUILD := $(abs_objtree)/kselftest KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include - KHDR_DIR := ${abs_objtree}/usr/include else BUILD := $(CURDIR) abs_srctree := $(shell cd $(top_srcdir) && pwd) KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include - KHDR_DIR := ${abs_srctree}/usr/include DEFAULT_INSTALL_HDR_PATH := 1 endif
@@ -171,7 +169,7 @@ export KHDR_INCLUDES # all isn't the first target in the file. .DEFAULT_GOAL := all -all: kernel_header_files +all: @ret=1; \ for TARGET in $(TARGETS); do \ BUILD_TARGET=$$BUILD/$$TARGET; \
@@ -182,23 +180,6 @@ all: kernel_header_files ret=$$((ret * $$?)); \ done; exit $$ret; -kernel_header_files: - @ls $(KHDR_DIR)/linux/*.h >/dev/null 2>/dev/null; \ - if [ $$? -ne 0 ]; then \ - RED='\033[1;31m'; \ - NOCOLOR='\033[0m'; \ - echo; \ - echo -e "$${RED}error$${NOCOLOR}: missing kernel header files."; \ - echo "Please run this and try again:"; \ - echo; \ - echo " cd $(top_srcdir)"; \ - echo " make headers"; \ - echo; \ - exit 1; \ - fi - -.PHONY: kernel_header_files - run_tests: all @for TARGET in $(TARGETS); do \ BUILD_TARGET=$$BUILD/$$TARGET; \
tools/testing/selftests/lib.mk +3 -37
@@ -44,26 +44,10 @@ endif selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST)))) top_srcdir = $(selfdir)/../../.. -ifeq ("$(origin O)", "command line") - KBUILD_OUTPUT := $(O) +ifeq ($(KHDR_INCLUDES),) +KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include endif -ifneq ($(KBUILD_OUTPUT),) - # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot - # expand a shell special character '~'. We use a somewhat tedious way here. - abs_objtree := $(shell cd $(top_srcdir) && mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd) - $(if $(abs_objtree),, \ - $(error failed to create output directory "$(KBUILD_OUTPUT)")) - # $(realpath ...) resolves symlinks - abs_objtree := $(realpath $(abs_objtree)) - KHDR_DIR := ${abs_objtree}/usr/include -else - abs_srctree := $(shell cd $(top_srcdir) && pwd) - KHDR_DIR := ${abs_srctree}/usr/include -endif - -KHDR_INCLUDES := -isystem $(KHDR_DIR) - # The following are built by lib.mk common compile rules. # TEST_CUSTOM_PROGS should be used by tests that require # custom build rule and prevent common build rule use.
@@ -74,25 +58,7 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) -all: kernel_header_files $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) \ - $(TEST_GEN_FILES) - -kernel_header_files: - @ls $(KHDR_DIR)/linux/*.h >/dev/null 2>/dev/null; \ - if [ $$? -ne 0 ]; then \ - RED='\033[1;31m'; \ - NOCOLOR='\033[0m'; \ - echo; \ - echo -e "$${RED}error$${NOCOLOR}: missing kernel header files."; \ - echo "Please run this and try again:"; \ - echo; \ - echo " cd $(top_srcdir)"; \ - echo " make headers"; \ - echo; \ - exit 1; \ - fi - -.PHONY: kernel_header_files +all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) define RUN_TESTS BASE_DIR="$(selfdir)"; \
Greg Kroah-Hartman
maintainerPATCH 131/166 arm64: mm: Always make sw-dirty PTEs hw-dirty in pte_modify
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Houghton <[email protected]>
commit 3c0696076aad60a2f04c019761921954579e1b0e upstream.
It is currently possible for a userspace application to enter an infinite page fault loop when using HugeTLB pages implemented with contiguous PTEs when HAFDBS is not available. This happens because:
1. The kernel may sometimes write PTEs that are sw-dirty but hw-clean (PTE_DIRTY | PTE_RDONLY | PTE_WRITE).
2. If, during a write, the CPU uses a sw-dirty, hw-clean PTE in handling the memory access on a system without HAFDBS, we will get a page fault.
3. HugeTLB will check if it needs to update the dirty bits on the PTE. For contiguous PTEs, it will check to see if the pgprot bits need updating. In this case, HugeTLB wants to write a sequence of sw-dirty, hw-dirty PTEs, but it finds that all the PTEs it is about to overwrite are all pte_dirty() (pte_sw_dirty() => pte_dirty()), so it thinks no update is necessary.
We can get the kernel to write a sw-dirty, hw-clean PTE with the following steps (showing the relevant VMA flags and pgprot bits):
i. Create a valid, writable contiguous PTE.
VMA vmflags: VM_SHARED | VM_READ | VM_WRITE
VMA pgprot bits: PTE_RDONLY | PTE_WRITE
PTE pgprot bits: PTE_DIRTY | PTE_WRITE
ii. mprotect the VMA to PROT_NONE.
VMA vmflags: VM_SHARED
VMA pgprot bits: PTE_RDONLY
PTE pgprot bits: PTE_DIRTY | PTE_RDONLY
iii. mprotect the VMA back to PROT_READ | PROT_WRITE.
VMA vmflags: VM_SHARED | VM_READ | VM_WRITE
VMA pgprot bits: PTE_RDONLY | PTE_WRITE PTE pgprot bits: PTE_DIRTY | PTE_WRITE | PTE_RDONLY
Make it impossible to create a writeable sw-dirty, hw-clean PTE with pte_modify(). Such a PTE should be impossible to create, and there may be places that assume that pte_dirty() implies pte_hw_dirty().
--- arch/arm64/include/asm/pgtable.h | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/include/asm/pgtable.h +6 -0
@@ -826,6 +826,12 @@ static inline pte_t pte_modify(pte_t pte pte =set_pte_bit (pte,__pgprot (PTE_DIRTY ));pte_val (pte) = (pte_val (pte) & ~mask) | (pgprot_val (newprot) & mask); +/* +* If we end up clearing hw dirtiness for a sw-dirty PTE, set hardware +* dirtiness again. +*/ +if (pte_sw_dirty (pte)) + pte =pte_mkdirty (pte);return pte; }
Greg Kroah-Hartman
maintainerPATCH 132/166 team: Fix use-after-free when an option instance allocation fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florent Revest <[email protected]>
commit c12296bbecc488623b7d1932080e394d08f3226b upstream.
In __team_options_register, team_options are allocated and appended to the team's option_list.
If one option instance allocation fails, the "inst_rollback" cleanup path frees the previously allocated options but doesn't remove them from the team's option_list.
This leaves dangling pointers that can be dereferenced later by other parts of the team driver that iterate over options.
This patch fixes the cleanup path to remove the dangling pointers from the list.
As far as I can tell, this uaf doesn't have much security implications since it would be fairly hard to exploit (an attacker would need to make the allocation of that specific small object fail) but it's still nice to fix.
--- drivers/net/team/team.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/team/team.c +3 -1
@@ -281,8 +281,10 @@ static int __team_options_register(strucreturn 0 ; inst_rollback: -for (i--; i >=0 ; i--) +for (i--; i >=0 ; i--) {__team_option_inst_del_option (team, dst_opts[i]); +list_del (&dst_opts[i]->list); + } i = option_count; alloc_rollback:
Greg Kroah-Hartman
maintainerPATCH 133/166 drm/amdgpu/sdma5.2: add begin/end_use ring callbacks
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit ab4750332dbe535243def5dcebc24ca00c1f98ac upstream.
Add begin/end_use ring callbacks to disallow GFXOFF when SDMA work is submitted and allow it again afterward.
This should avoid corner cases where GFXOFF is erroneously entered when SDMA is still active. For now just allow/disallow GFXOFF in the begin and end helpers until we root cause the issue. This should not impact power as SDMA usage is pretty minimal and GFXOSS should not be active when SDMA is active anyway, this just makes it explicit.
v2: move everything into sdma5.2 code. No reason for this to be generic at this point.
v3: Add comments in new code
--- drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +28 -0
@@ -1651,6 +1651,32 @@ static void sdma_v5_2_get_clockgating_st *flags |=AMD_CG_SUPPORT_SDMA_LS ; } +static void sdma_v5_2_ring_begin_use (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; + +/* SDMA 5.2.3 (RMB) FW doesn't seem to properly +* disallow GFXOFF in some cases leading to +* hangs in SDMA. Disallow GFXOFF while SDMA is active. +* We can probably just limit this to 5.2.3, +* but it shouldn't hurt for other parts since +* this GFXOFF will be disallowed anyway when SDMA is +* active, this just makes it explicit. +*/ +amdgpu_gfx_off_ctrl (adev, false); +} + +static void sdma_v5_2_ring_end_use (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; + +/* SDMA 5.2.3 (RMB) FW doesn't seem to properly +* disallow GFXOFF in some cases leading to +* hangs in SDMA. Allow GFXOFF when SDMA is complete. +*/ +amdgpu_gfx_off_ctrl (adev, true); +} +const struct amd_ip_funcs sdma_v5_2_ip_funcs = { .name ="sdma_v5_2" , .early_init = sdma_v5_2_early_init,
@@ -1698,6 +1724,8 @@ static const struct amdgpu_ring_funcs sd .test_ib = sdma_v5_2_ring_test_ib, .insert_nop = sdma_v5_2_ring_insert_nop, .pad_ib = sdma_v5_2_ring_pad_ib, + .begin_use = sdma_v5_2_ring_begin_use, + .end_use = sdma_v5_2_ring_end_use, .emit_wreg = sdma_v5_2_ring_emit_wreg, .emit_reg_wait = sdma_v5_2_ring_emit_reg_wait, .emit_reg_write_reg_wait = sdma_v5_2_ring_emit_reg_write_reg_wait,
Greg Kroah-Hartman
maintainerPATCH 134/166 drm/mediatek: Fix access violation in mtk_drm_crtc_dma_dev_get
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stuart Lee <[email protected]>
commit b6961d187fcd138981b8707dac87b9fcdbfe75d1 upstream.
Add error handling to check NULL input inmtk_drm_crtc_dma_dev_get function.
While display path is not configured correctly, none of crtc is established. So the caller of mtk_drm_crtc_dma_dev_get may pass input parameter *crtc as NULL, Which may cause coredump when we try to get the container of NULL pointer.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +8 -1
@@ -885,7 +885,14 @@ static int mtk_drm_crtc_init_comp_planesstruct device *mtk_drm_crtc_dma_dev_get (struct drm_crtc *crtc) { -struct mtk_drm_crtc *mtk_crtc =to_mtk_crtc (crtc); +struct mtk_drm_crtc *mtk_crtc =NULL ; + +if (!crtc) +return NULL ; + + mtk_crtc =to_mtk_crtc (crtc); +if (!mtk_crtc) +return NULL ;return mtk_crtc->dma_dev; }
Greg Kroah-Hartman
maintainerPATCH 135/166 dmaengine: stm32-dma: avoid bitfield overflow assertion
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amelie Delaunay <[email protected]>
commit 54bed6bafa0f38daf9697af50e3aff5ff1354fe1 upstream.
stm32_dma_get_burst() returns a negative error for invalid input, which
gets turned into a large u32 value in stm32_dma_prep_dma_memcpy() that
in turn triggers an assertion because it does not fit into a two-bit field:drivers/dma/stm32-dma.c: In function 'stm32_dma_prep_dma_memcpy':include/linux/compiler_types.h:354:38: error: call to '__compiletime_assert_282' declared with attribute error: FIELD_PREP: value too large for the field
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:335:4: note: in definition of macro '__compiletime_assert'
prefix ## suffix(); \
^~~~~~
include/linux/compiler_types.h:354:2: note: in expansion of macro '_compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:68:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
^~~~~~~~~~~~~~~~
include/linux/bitfield.h:114:3: note: in expansion of macro '__BF_FIELD_CHECK'
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
^~~~~~~~~~~~~~~~ drivers/dma/stm32-dma.c:1237:4: note: in expansion of macro 'FIELD_PREP'
FIELD_PREP(STM32_DMA_SCR_PBURST_MASK, dma_burst) | ^~~~~~~~~~
As an easy workaround, assume the error can happen, so try to handle this by failing stm32_dma_prep_dma_memcpy() before the assertion. It replicates what is done in stm32_dma_set_xfer_param() where stm32_dma_get_burst() is also used.
--- drivers/dma/stm32-dma.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/dma/stm32-dma.c +6 -2
@@ -1249,8 +1249,8 @@ static struct dma_async_tx_descriptor *senum dma_slave_buswidth max_width;struct stm32_dma_desc *desc;size_t xfer_count, offset; -u32 num_sgs, best_burst, dma_burst, threshold; -int i; +u32 num_sgs, best_burst, threshold; +int dma_burst, i; num_sgs =DIV_ROUND_UP (len,STM32_DMA_ALIGNED_MAX_DATA_ITEMS ); desc =kzalloc (struct_size (desc, sg_req, num_sgs),GFP_NOWAIT );
@@ -1268,6 +1268,10 @@ static struct dma_async_tx_descriptor *s best_burst =stm32_dma_get_best_burst (len,STM32_DMA_MAX_BURST , threshold, max_width); dma_burst =stm32_dma_get_burst (chan, best_burst); +if (dma_burst <0 ) { +kfree (desc); +return NULL ; + }stm32_dma_clear_reg (&desc->sg_req[i].chan_reg); desc->sg_req[i].chan_reg.dma_scr =
Greg Kroah-Hartman
maintainerPATCH 118/166 eventfs: Do not allow NULL parent to eventfs_start_creating()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit fc4561226feaad5fcdcb55646c348d77b8ee69c5 ]
The eventfs directory is dynamically created via the meta data supplied by the existing trace events. All files and directories in eventfs has a parent. Do not allow NULL to be passed into eventfs_start_creating() as the parent because that should never happen. Warn if it does.
--- fs/tracefs/inode.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
fs/tracefs/inode.c +4 -9
@@ -509,20 +509,15 @@ struct dentry *eventfs_start_creating(const char *name, struct dentry *parent)struct dentry *dentry;int error; +/* Must always have a parent. */ +if (WARN_ON_ONCE (!parent)) +return ERR_PTR (-EINVAL ); + error =simple_pin_fs (&trace_fs_type, &tracefs_mount, &tracefs_mount_count);if (error)return ERR_PTR (error); -/* -* If the parent is not specified, we create it in the root. -* We need the root dentry to do this, which is in the super -* block. A pointer to that is in the struct vfsmount that we -* have around. -*/ -if (!parent) - parent = tracefs_mount->mnt_root; -if (unlikely (IS_DEADDIR (parent->d_inode))) dentry =ERR_PTR (-ENOENT );else
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 136/166 dmaengine: fsl-edma: fix DMA channel leak in eDMAv4
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit 4ee632c82d2dbb9e2dcc816890ef182a151cbd99 upstream.
Allocate channel count consistently increases due to a missing source ID (srcid) cleanup in the fsl_edma_free_chan_resources() function at imx93 eDMAv4.
Reset 'srcid' at fsl_edma_free_chan_resources().
--- drivers/dma/fsl-edma-common.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/fsl-edma-common.c +1 -0
@@ -828,6 +828,7 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan)dma_pool_destroy (fsl_chan->tcd_pool); fsl_chan->tcd_pool =NULL ; fsl_chan->is_sw = false; + fsl_chan->srcid =0 ; }void fsl_edma_cleanup_vchan (struct dma_device *dmadev)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 137/166 mm/mglru: fix underprotected page cache
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Zhao <[email protected]>
commit 081488051d28d32569ebb7c7a23572778b2e7d57 upstream.
Unmapped folios accessed through file descriptors can be underprotected. Those folios are added to the oldest generation based on:
1. The fact that they are less costly to reclaim (no need to walk the rmap and flush the TLB) and have less impact on performance (don't cause major PFs and can be non-blocking if needed again).
2. The observation that they are likely to be single-use. E.g., for client use cases like Android, its apps parse configuration files and store the data in heap (anon); for server use cases like MySQL, it reads from InnoDB files and holds the cached data for tables in buffer pools (anon).
However, the oldest generation can be very short lived, and if so, it doesn't provide the PID controller with enough time to respond to a surge of refaults. (Note that the PID controller uses weighted refaults and those from evicted generations only take a half of the whole weight.) In other words, for a short lived generation, the moving average smooths out the spike quickly.
To fix the problem:
1. For folios that are already on LRU, if they can be beyond the tracking range of tiers, i.e., five accesses through file descriptors, move them to the second oldest generation to give them more time to age. (Note that tiers are used by the PID controller to statistically determine whether folios accessed multiple times through file descriptors are worth protecting.)
2. When adding unmapped folios to LRU, adjust the placement of them so that they are not too close to the tail. The effect of this is similar to the above.
On Android, launching 55 apps sequentially:
Before After Change workingset_refault_anon 25641024 25598972 0% workingset_refault_file 115016834 106178438 -8%
--- include/linux/mm_inline.h | 23 ++++++++++++++--------- mm/vmscan.c | 2 +- mm/workingset.c | 6 +++--- 3 files changed, 18 insertions(+), 13 deletions(-)
include/linux/mm_inline.h +14 -9
@@ -231,22 +231,27 @@ static inline bool lru_gen_add_folio(strif (folio_test_unevictable (folio) || !lrugen->enabled)return false;/* -* There are three common cases for this page: -* 1. If it's hot, e.g., freshly faulted in or previously hot and -* migrated, add it to the youngest generation. -* 2. If it's cold but can't be evicted immediately, i.e., an anon page -* not in swapcache or a dirty page pending writeback, add it to the -* second oldest generation. -* 3. Everything else (clean, cold) is added to the oldest generation. +* There are four common cases for this page: +* 1. If it's hot, i.e., freshly faulted in, add it to the youngest +* generation, and it's protected over the rest below. +* 2. If it can't be evicted immediately, i.e., a dirty page pending +* writeback, add it to the second youngest generation. +* 3. If it should be evicted first, e.g., cold and clean from +* folio_rotate_reclaimable(), add it to the oldest generation. +* 4. Everything else falls between 2 & 3 above and is added to the +* second oldest generation if it's considered inactive, or the +* oldest generation otherwise. See lru_gen_is_active(). */ if (folio_test_active (folio)) seq = lrugen->max_seq;else if ((type ==LRU_GEN_ANON && !folio_test_swapcache (folio)) || (folio_test_reclaim (folio) && (folio_test_dirty (folio) ||folio_test_writeback (folio)))) - seq = lrugen->min_seq[type] +1 ; -else + seq = lrugen->max_seq -1 ; +else if (reclaiming || lrugen->min_seq[type] +MIN_NR_GENS >= lrugen->max_seq) seq = lrugen->min_seq[type]; +else + seq = lrugen->min_seq[type] +1 ; gen =lru_gen_from_seq (seq); flags = (gen +1UL ) <<LRU_GEN_PGOFF ;
mm/vmscan.c +1 -1
@@ -4933,7 +4933,7 @@ static bool sort_folio(struct lruvec *lr }/* protected */ -if (tier > tier_idx) { +if (tier > tier_idx || refs ==BIT (LRU_REFS_WIDTH )) {int hist =lru_hist_from_seq (lrugen->min_seq[type]); gen =folio_inc_gen (lruvec, folio, false);
mm/workingset.c +3 -3
@@ -313,10 +313,10 @@ static void lru_gen_refault(struct folio* 1. For pages accessed through page tables, hotter pages pushed out * hot pages which refaulted immediately. * 2. For pages accessed multiple times through file descriptors, -* numbers of accesses might have been out of the range. +* they would have been protected by sort_folio(). */ -if (lru_gen_in_fault () || refs ==BIT (LRU_REFS_WIDTH )) { -folio_set_workingset (folio); +if (lru_gen_in_fault () || refs >=BIT (LRU_REFS_WIDTH ) -1 ) { +set_mask_bits (&folio->flags,0 ,LRU_REFS_MASK |BIT (PG_workingset));mod_lruvec_state (lruvec,WORKINGSET_RESTORE_BASE + type, delta); } unlock:
Greg Kroah-Hartman
maintainerPATCH 138/166 mm/mglru: try to stop at high watermarks
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Zhao <[email protected]>
commit 5095a2b23987d3c3c47dd16b3d4080e2733b8bb9 upstream.
The initial MGLRU patchset didn't include the memcg LRU support, and it relied on should_abort_scan(), added by commit f76c83378851 ("mm:
multi-gen LRU: optimize multiple memcgs"), to "backoff to avoid overshooting their aggregate reclaim target by too much".
Later on when the memcg LRU was added, should_abort_scan() was deemed unnecessary, and the test results [1] showed no side effects after it was removed by commit a579086c99ed ("mm: multi-gen LRU: remove eviction fairness safeguard").
However, that test used memory.reclaim, which sets nr_to_reclaim to SWAP_CLUSTER_MAX. So it can overshoot only by SWAP_CLUSTER_MAX-1 pages, i.e., from nr_reclaimed=nr_to_reclaim-1 to nr_reclaimed=nr_to_reclaim+SWAP_CLUSTER_MAX-1. Compared with the batch size kswapd sets to nr_to_reclaim, SWAP_CLUSTER_MAX is tiny. Therefore that test isn't able to reproduce the worst case scenario, i.e., kswapd overshooting GBs on large systems and "consuming 100% CPU" (see the Closes tag).
Bring back a simplified version of should_abort_scan() on top of the memcg LRU, so that kswapd stops when all eligible zones are above their respective high watermarks plus a small delta to lower the chance of KSWAPD_HIGH_WMARK_HIT_QUICKLY. Note that this only applies to order-0 reclaim, meaning compaction-induced reclaim can still run wild (which is a different problem).
On Android, launching 55 apps sequentially:
Before After Change pgpgin 838377172 802955040 -4% pgpgout 38037080 34336300 -10%
[1] https://lore.kernel.org/[email protected]/
--- mm/vmscan.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)
mm/vmscan.c +28 -8
@@ -5341,20 +5341,41 @@ static long get_nr_to_scan(struct lruvecreturn try_to_inc_max_seq (lruvec, max_seq, sc, can_swap, false) ?-1 :0 ; } -static unsigned long get_nr_to_reclaim (struct scan_control *sc) +static bool should_abort_scan (struct lruvec *lruvec,struct scan_control *sc) { +int i; +enum zone_watermarks mark; +/* don't abort memcg reclaim to ensure fairness */ if (!root_reclaim (sc)) -return -1 ; +return false; + +if (sc->nr_reclaimed >=max (sc->nr_to_reclaim,compact_gap (sc->order))) +return true; + +/* check the order to exclude compaction-induced reclaim */ +if (!current_is_kswapd () || sc->order) +return false; + + mark = sysctl_numa_balancing_mode &NUMA_BALANCING_MEMORY_TIERING ? +WMARK_PROMO :WMARK_HIGH ; + +for (i =0 ; i <= sc->reclaim_idx; i++) { +struct zone *zone =lruvec_pgdat (lruvec)->node_zones + i; +unsigned long size =wmark_pages (zone, mark) +MIN_LRU_BATCH ; + +if (managed_zone (zone) && !zone_watermark_ok (zone,0 , size, sc->reclaim_idx,0 )) +return false; + } -return max (sc->nr_to_reclaim,compact_gap (sc->order)); +/* kswapd should abort if all eligible zones are safe */ +return true; }static bool try_to_shrink_lruvec (struct lruvec *lruvec,struct scan_control *sc) {long nr_to_scan;unsigned long scanned =0 ; -unsigned long nr_to_reclaim =get_nr_to_reclaim (sc);int swappiness =get_swappiness (lruvec, sc);/* clean file folios are more likely to exist */
@@ -5376,7 +5397,7 @@ static bool try_to_shrink_lruvec(structif (scanned >= nr_to_scan)break ; -if (sc->nr_reclaimed >= nr_to_reclaim) +if (should_abort_scan (lruvec, sc))break ;cond_resched ();
@@ -5437,7 +5458,6 @@ static void shrink_many(struct pglist_dastruct lru_gen_folio *lrugen;struct mem_cgroup *memcg;const struct hlist_nulls_node *pos; -unsigned long nr_to_reclaim =get_nr_to_reclaim (sc); bin = first_bin =get_random_u32_below (MEMCG_NR_BINS ); restart:
@@ -5470,7 +5490,7 @@ restart:rcu_read_lock (); -if (sc->nr_reclaimed >= nr_to_reclaim) +if (should_abort_scan (lruvec, sc))break ; }
@@ -5481,7 +5501,7 @@ restart:mem_cgroup_put (memcg); -if (sc->nr_reclaimed >= nr_to_reclaim) +if (!is_a_nulls (pos))return ;/* restart if raced with lru_gen_rotate_memcg() */
Greg Kroah-Hartman
maintainerPATCH 139/166 mm/mglru: respect min_ttl_ms with memcgs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Zhao <[email protected]>
commit 8aa420617918d12d1f5d55030a503c9418e73c2c upstream.
While investigating kswapd "consuming 100% CPU" [1] (also see "mm/mglru:
try to stop at high watermarks"), it was discovered that the memcg LRU can breach the thrashing protection imposed by min_ttl_ms.
Before the memcg LRU:
kswapd()
shrink_node_memcgs()
mem_cgroup_iter()
inc_max_seq() // always hit a different memcg
lru_gen_age_node()
mem_cgroup_iter()
check the timestamp of the oldest generation
After the memcg LRU:
kswapd()
shrink_many()
restart:
iterate the memcg LRU:
inc_max_seq() // occasionally hit the same memcg if raced with lru_gen_rotate_memcg():
goto restart
lru_gen_age_node()
mem_cgroup_iter()
check the timestamp of the oldest generation
Specifically, when the restart happens in shrink_many(), it needs to stick with the (memcg LRU) generation it began with. In other words, it should neither re-read memcg_lru->seq nor age an lruvec of a different generation. Otherwise it can hit the same memcg multiple times without giving lru_gen_age_node() a chance to check the timestamp of that memcg's oldest generation (against min_ttl_ms).
[1] https://lore.kernel.org/CAK8fFZ4DY+GtBA40Pm7Nn5xCHy+51w3sfxPqkqpqakSXYyX+Wg@mail.gmail.com/
--- include/linux/mmzone.h | 30 +++++++++++++++++------------- mm/vmscan.c | 30 ++++++++++++++++-------------- 2 files changed, 33 insertions(+), 27 deletions(-)
include/linux/mmzone.h +17 -13
@@ -505,33 +505,37 @@ void lru_gen_look_around(struct page_vma* the old generation, is incremented when all its bins become empty. * * There are four operations: -* 1. MEMCG_LRU_HEAD, which moves an memcg to the head of a random bin in its +* 1. MEMCG_LRU_HEAD, which moves a memcg to the head of a random bin in its * current generation (old or young) and updates its "seg" to "head"; -* 2. MEMCG_LRU_TAIL, which moves an memcg to the tail of a random bin in its +* 2. MEMCG_LRU_TAIL, which moves a memcg to the tail of a random bin in its * current generation (old or young) and updates its "seg" to "tail"; -* 3. MEMCG_LRU_OLD, which moves an memcg to the head of a random bin in the old +* 3. MEMCG_LRU_OLD, which moves a memcg to the head of a random bin in the old * generation, updates its "gen" to "old" and resets its "seg" to "default"; -* 4. MEMCG_LRU_YOUNG, which moves an memcg to the tail of a random bin in the +* 4. MEMCG_LRU_YOUNG, which moves a memcg to the tail of a random bin in the * young generation, updates its "gen" to "young" and resets its "seg" to * "default". * * The events that trigger the above operations are: * 1. Exceeding the soft limit, which triggers MEMCG_LRU_HEAD; -* 2. The first attempt to reclaim an memcg below low, which triggers +* 2. The first attempt to reclaim a memcg below low, which triggers * MEMCG_LRU_TAIL; -* 3. The first attempt to reclaim an memcg below reclaimable size threshold, +* 3. The first attempt to reclaim a memcg below reclaimable size threshold, * which triggers MEMCG_LRU_TAIL; -* 4. The second attempt to reclaim an memcg below reclaimable size threshold, +* 4. The second attempt to reclaim a memcg below reclaimable size threshold, * which triggers MEMCG_LRU_YOUNG; -* 5. Attempting to reclaim an memcg below min, which triggers MEMCG_LRU_YOUNG; +* 5. Attempting to reclaim a memcg below min, which triggers MEMCG_LRU_YOUNG; * 6. Finishing the aging on the eviction path, which triggers MEMCG_LRU_YOUNG; -* 7. Offlining an memcg, which triggers MEMCG_LRU_OLD. +* 7. Offlining a memcg, which triggers MEMCG_LRU_OLD. * -* Note that memcg LRU only applies to global reclaim, and the round-robin -* incrementing of their max_seq counters ensures the eventual fairness to all -* eligible memcgs. For memcg reclaim, it still relies on mem_cgroup_iter(). +* Notes: +* 1. Memcg LRU only applies to global reclaim, and the round-robin incrementing +* of their max_seq counters ensures the eventual fairness to all eligible +* memcgs. For memcg reclaim, it still relies on mem_cgroup_iter(). +* 2. There are only two valid generations: old (seq) and young (seq+1). +* MEMCG_NR_GENS is set to three so that when reading the generation counter +* locklessly, a stale value (seq-1) does not wraparound to young. */ -#define MEMCG_NR_GENS 2 +#define MEMCG_NR_GENS 3#define MEMCG_NR_BINS 8struct lru_gen_memcg {
mm/vmscan.c +16 -14
@@ -4790,6 +4790,9 @@ static void lru_gen_rotate_memcg(structelse VM_WARN_ON_ONCE (true); +WRITE_ONCE (lruvec->lrugen.seg, seg); +WRITE_ONCE (lruvec->lrugen.gen, new); +hlist_nulls_del_rcu (&lruvec->lrugen.list);if (op ==MEMCG_LRU_HEAD || op ==MEMCG_LRU_OLD )
@@ -4800,9 +4803,6 @@ static void lru_gen_rotate_memcg(struct pgdat->memcg_lru.nr_memcgs[old]--; pgdat->memcg_lru.nr_memcgs[new]++; - lruvec->lrugen.gen = new; -WRITE_ONCE (lruvec->lrugen.seg, seg); -if (!pgdat->memcg_lru.nr_memcgs[old] && old ==get_memcg_gen (pgdat->memcg_lru.seq))WRITE_ONCE (pgdat->memcg_lru.seq, pgdat->memcg_lru.seq +1 );
@@ -4825,11 +4825,11 @@ void lru_gen_online_memcg(struct mem_cgr gen =get_memcg_gen (pgdat->memcg_lru.seq); + lruvec->lrugen.gen = gen; +hlist_nulls_add_tail_rcu (&lruvec->lrugen.list, &pgdat->memcg_lru.fifo[gen][bin]); pgdat->memcg_lru.nr_memcgs[gen]++; - lruvec->lrugen.gen = gen; -spin_unlock_irq (&pgdat->memcg_lru.lock); } }
@@ -5328,7 +5328,7 @@ static long get_nr_to_scan(struct lruvecDEFINE_MAX_SEQ (lruvec);if (mem_cgroup_below_min (sc->target_mem_cgroup, memcg)) -return 0 ; +return -1 ;if (!should_run_aging (lruvec, max_seq, sc, can_swap, &nr_to_scan))return nr_to_scan;
@@ -5403,7 +5403,7 @@ static bool try_to_shrink_lruvec(structcond_resched (); } -/* whether try_to_inc_max_seq() was successful */ +/* whether this lruvec should be rotated */ return nr_to_scan <0 ; }
@@ -5457,13 +5457,13 @@ static void shrink_many(struct pglist_dastruct lruvec *lruvec;struct lru_gen_folio *lrugen;struct mem_cgroup *memcg; -const struct hlist_nulls_node *pos; +struct hlist_nulls_node *pos; + gen =get_memcg_gen (READ_ONCE (pgdat->memcg_lru.seq)); bin = first_bin =get_random_u32_below (MEMCG_NR_BINS ); restart: op =0 ; memcg =NULL ; - gen =get_memcg_gen (READ_ONCE (pgdat->memcg_lru.seq));rcu_read_lock ();
@@ -5474,6 +5474,10 @@ restart: }mem_cgroup_put (memcg); + memcg =NULL ; + +if (gen !=READ_ONCE (lrugen->gen)) +continue ; lruvec = container_of(lrugen, struct lruvec, lrugen); memcg =lruvec_memcg (lruvec);
@@ -5558,16 +5562,14 @@ static void set_initial_priority(structif (sc->priority !=DEF_PRIORITY || sc->nr_to_reclaim <MIN_LRU_BATCH )return ;/* -* Determine the initial priority based on ((total / MEMCG_NR_GENS) >> -* priority) * reclaimed_to_scanned_ratio = nr_to_reclaim, where the -* estimated reclaimed_to_scanned_ratio = inactive / total. +* Determine the initial priority based on +* (total >> priority) * reclaimed_to_scanned_ratio = nr_to_reclaim, +* where reclaimed_to_scanned_ratio = inactive / total. */ reclaimable =node_page_state (pgdat,NR_INACTIVE_FILE );if (get_swappiness (lruvec, sc)) reclaimable +=node_page_state (pgdat,NR_INACTIVE_ANON ); - reclaimable /=MEMCG_NR_GENS ; -/* round down reclaimable and round up sc->nr_to_reclaim */ priority =fls_long (reclaimable) -1 -fls_long (sc->nr_to_reclaim -1 );
Greg Kroah-Hartman
maintainerPATCH 140/166 mm/mglru: reclaim offlined memcgs harder
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Zhao <[email protected]>
commit 4376807bf2d5371c3e00080c972be568c3f8a7d1 upstream.
In the effort to reduce zombie memcgs [1], it was discovered that the memcg LRU doesn't apply enough pressure on offlined memcgs. Specifically, instead of rotating them to the tail of the current generation (MEMCG_LRU_TAIL) for a second attempt, it moves them to the next generation (MEMCG_LRU_YOUNG) after the first attempt.
Not applying enough pressure on offlined memcgs can cause them to build up, and this can be particularly harmful to memory-constrained systems.
On Pixel 8 Pro, launching apps for 50 cycles:
Before After Change Zombie memcgs 45 35 -22%
[1] https://lore.kernel.org/CABdmKX2M6koq4Q0Cmp_-=wbP0Qa190HdEGGaHfxNS05gAkUtPA@mail.gmail.com/
--- include/linux/mmzone.h | 8 ++++---- mm/vmscan.c | 24 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-)
include/linux/mmzone.h +4 -4
@@ -519,10 +519,10 @@ void lru_gen_look_around(struct page_vma* 1. Exceeding the soft limit, which triggers MEMCG_LRU_HEAD; * 2. The first attempt to reclaim a memcg below low, which triggers * MEMCG_LRU_TAIL; -* 3. The first attempt to reclaim a memcg below reclaimable size threshold, -* which triggers MEMCG_LRU_TAIL; -* 4. The second attempt to reclaim a memcg below reclaimable size threshold, -* which triggers MEMCG_LRU_YOUNG; +* 3. The first attempt to reclaim a memcg offlined or below reclaimable size +* threshold, which triggers MEMCG_LRU_TAIL; +* 4. The second attempt to reclaim a memcg offlined or below reclaimable size +* threshold, which triggers MEMCG_LRU_YOUNG; * 5. Attempting to reclaim a memcg below min, which triggers MEMCG_LRU_YOUNG; * 6. Finishing the aging on the eviction path, which triggers MEMCG_LRU_YOUNG; * 7. Offlining a memcg, which triggers MEMCG_LRU_OLD.
mm/vmscan.c +16 -8
@@ -5291,7 +5291,12 @@ static bool should_run_aging(struct lruv }/* try to scrape all its memory if this memcg was deleted */ - *nr_to_scan =mem_cgroup_online (memcg) ? (total >> sc->priority) : total; +if (!mem_cgroup_online (memcg)) { + *nr_to_scan = total; +return false; + } + + *nr_to_scan = total >> sc->priority;/* * The aging tries to be lazy to reduce the overhead, while the eviction
@@ -5412,14 +5417,9 @@ static int shrink_one(struct lruvec *lrubool success;unsigned long scanned = sc->nr_scanned;unsigned long reclaimed = sc->nr_reclaimed; -int seg =lru_gen_memcg_seg (lruvec);struct mem_cgroup *memcg =lruvec_memcg (lruvec);struct pglist_data *pgdat =lruvec_pgdat (lruvec); -/* see the comment on MEMCG_NR_GENS */ -if (!lruvec_is_sizable (lruvec, sc)) -return seg !=MEMCG_LRU_TAIL ?MEMCG_LRU_TAIL :MEMCG_LRU_YOUNG ; -mem_cgroup_calculate_protection (NULL , memcg);if (mem_cgroup_below_min (NULL , memcg))
@@ -5427,7 +5427,7 @@ static int shrink_one(struct lruvec *lruif (mem_cgroup_below_low (NULL , memcg)) {/* see the comment on MEMCG_NR_GENS */ -if (seg !=MEMCG_LRU_TAIL ) +if (lru_gen_memcg_seg (lruvec) !=MEMCG_LRU_TAIL )return MEMCG_LRU_TAIL ;memcg_memory_event (memcg,MEMCG_LOW );
@@ -5443,7 +5443,15 @@ static int shrink_one(struct lruvec *lruflush_reclaim_state (sc); -return success ?MEMCG_LRU_YOUNG :0 ; +if (success &&mem_cgroup_online (memcg)) +return MEMCG_LRU_YOUNG ; + +if (!success &&lruvec_is_sizable (lruvec, sc)) +return 0 ; + +/* one retry if offlined or too small */ +return lru_gen_memcg_seg (lruvec) !=MEMCG_LRU_TAIL ? +MEMCG_LRU_TAIL :MEMCG_LRU_YOUNG ; }#ifdef CONFIG_MEMCG
Greg Kroah-Hartman
maintainerPATCH 141/166 mm/shmem: fix race in shmem_undo_range w/THP
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Stevens <[email protected]>
commit 55ac8bbe358bdd2f3c044c12f249fd22d48fe015 upstream.
Split folios during the second loop of shmem_undo_range. It's not sufficient to only split folios when dealing with partial pages, since it's possible for a THP to be faulted in after that point. Calling truncate_inode_folio in that situation can result in throwing away data outside of the range being targeted.
--- mm/shmem.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
mm/shmem.c +18 -1
@@ -1098,7 +1098,24 @@ whole_folios: }VM_BUG_ON_FOLIO (folio_test_writeback (folio), folio); -truncate_inode_folio (mapping, folio); + +if (!folio_test_large (folio)) { +truncate_inode_folio (mapping, folio); + }else if (truncate_inode_partial_folio (folio, lstart, lend)) { +/* +* If we split a page, reset the loop so +* that we pick up the new sub pages. +* Otherwise the THP was entirely +* dropped or the target range was +* zeroed, so just continue the loop as +* is. +*/ +if (!folio_test_large (folio)) { +folio_unlock (folio); + index = start; +break ; + } + } }folio_unlock (folio); }
Greg Kroah-Hartman
maintainerPATCH 142/166 kexec: drop dependency on ARCH_SUPPORTS_KEXEC from CRASH_DUMP
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ignat Korchagin <[email protected]>
commit c41bd2514184d75db087fe4c1221237fb7922875 upstream.
In commit f8ff23429c62 ("kernel/Kconfig.kexec: drop select of KEXEC for CRASH_DUMP") we tried to fix a config regression, where CONFIG_CRASH_DUMP required CONFIG_KEXEC.
However, it was not enough at least for arm64 platforms. While further testing the patch with our arm64 config I noticed that CONFIG_CRASH_DUMP is unavailable in menuconfig. This is because CONFIG_CRASH_DUMP still depends on the new CONFIG_ARCH_SUPPORTS_KEXEC introduced in commit 91506f7e5d21 ("arm64/kexec: refactor for kernel/Kconfig.kexec") and on arm64 CONFIG_ARCH_SUPPORTS_KEXEC requires CONFIG_PM_SLEEP_SMP=y, which in turn requires either CONFIG_SUSPEND=y or CONFIG_HIBERNATION=y neither of which are set in our config.
Given that we already established that CONFIG_KEXEC (which is a switch for kexec system call itself) is not required for CONFIG_CRASH_DUMP drop CONFIG_ARCH_SUPPORTS_KEXEC dependency as well. The arm64 kernel builds just fine with CONFIG_CRASH_DUMP=y and with both CONFIG_KEXEC=n and CONFIG_KEXEC_FILE=n after f8ff23429c62 ("kernel/Kconfig.kexec: drop select of KEXEC for CRASH_DUMP") and this patch are applied given that the necessary shared bits are included via CONFIG_KEXEC_CORE dependency.
--- arch/riscv/Kconfig | 4 ++-- arch/riscv/kernel/crash_core.c | 4 +++- kernel/Kconfig.kexec | 1 - 3 files changed, 5 insertions(+), 4 deletions(-)
arch/riscv/Kconfig +2 -2
@@ -669,7 +669,7 @@ config RISCV_BOOT_SPINWAIT If unsure what to do here, say N. config ARCH_SUPPORTS_KEXEC - def_bool MMU + def_bool y config ARCH_SELECTS_KEXEC def_bool y
@@ -677,7 +677,7 @@ config ARCH_SELECTS_KEXEC select HOTPLUG_CPU if SMP config ARCH_SUPPORTS_KEXEC_FILE - def_bool 64BIT && MMU + def_bool 64BIT config ARCH_SELECTS_KEXEC_FILE def_bool y
arch/riscv/kernel/crash_core.c +3 -1
@@ -5,18 +5,20 @@void arch_crash_save_vmcoreinfo (void ) { -VMCOREINFO_NUMBER (VA_BITS );VMCOREINFO_NUMBER (phys_ram_base);vmcoreinfo_append_str ("NUMBER(PAGE_OFFSET)=0x%lx\n" ,PAGE_OFFSET );vmcoreinfo_append_str ("NUMBER(VMALLOC_START)=0x%lx\n" ,VMALLOC_START );vmcoreinfo_append_str ("NUMBER(VMALLOC_END)=0x%lx\n" ,VMALLOC_END ); +#ifdef CONFIG_MMU +VMCOREINFO_NUMBER (VA_BITS );vmcoreinfo_append_str ("NUMBER(VMEMMAP_START)=0x%lx\n" ,VMEMMAP_START );vmcoreinfo_append_str ("NUMBER(VMEMMAP_END)=0x%lx\n" ,VMEMMAP_END );#ifdef CONFIG_64BIT vmcoreinfo_append_str ("NUMBER(MODULES_VADDR)=0x%lx\n" ,MODULES_VADDR );vmcoreinfo_append_str ("NUMBER(MODULES_END)=0x%lx\n" ,MODULES_END );#endif +#endif vmcoreinfo_append_str ("NUMBER(KERNEL_LINK_ADDR)=0x%lx\n" ,KERNEL_LINK_ADDR );vmcoreinfo_append_str ("NUMBER(va_kernel_pa_offset)=0x%lx\n" , kernel_map.va_kernel_pa_offset);
kernel/Kconfig.kexec +0 -1
@@ -94,7 +94,6 @@ config KEXEC_JUMP config CRASH_DUMP bool "kernel crash dumps" depends on ARCH_SUPPORTS_CRASH_DUMP - depends on ARCH_SUPPORTS_KEXEC select CRASH_CORE select KEXEC_CORE help
Greg Kroah-Hartman
maintainerPATCH 143/166 btrfs: free qgroup reserve when ORDERED_IOERR is set
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Burkov <[email protected]>
commit f63e1164b90b385cd832ff0fdfcfa76c3cc15436 upstream.
An ordered extent completing is a critical moment in qgroup reserve handling, as the ownership of the reservation is handed off from the ordered extent to the delayed ref. In the happy path we release (unlock) but do not free (decrement counter) the reservation, and the delayed ref drives the free. However, on an error, we don't create a delayed ref, since there is no ref to add. Therefore, free on the error path.
--- fs/btrfs/ordered-data.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/btrfs/ordered-data.c +3 -1
@@ -603,7 +603,9 @@ void btrfs_remove_ordered_extent(struct release = entry->disk_num_bytes; else release = entry->num_bytes; -btrfs_delalloc_release_metadata (btrfs_inode, release, false); +btrfs_delalloc_release_metadata (btrfs_inode, release, +test_bit (BTRFS_ORDERED_IOERR , + &entry->flags)); } percpu_counter_add_batch(&fs_info->ordered_bytes, -entry->num_bytes,
Greg Kroah-Hartman
maintainerPATCH 144/166 btrfs: fix qgroup_free_reserved_data int overflow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Burkov <[email protected]>
commit 9e65bfca24cf1d77e4a5c7a170db5867377b3fe7 upstream.
The reserved data counter and input parameter is a u64, but we inadvertently accumulate it in an int. Overflowing that int results in freeing the wrong amount of data and breaking reserve accounting.
Unfortunately, this overflow rot spreads from there, as the qgroup release/free functions rely on returning an int to take advantage of negative values for error codes.
Therefore, the full fix is to return the "released" or "freed" amount by a u64 argument and to return 0 or negative error code via the return value.
Most of the call sites simply ignore the return value, though some of them handle the error and count the returned bytes. Change all of them accordingly.
--- fs/btrfs/delalloc-space.c | 2 +- fs/btrfs/file.c | 2 +- fs/btrfs/inode.c | 16 ++++++++-------- fs/btrfs/ordered-data.c | 7 ++++--- fs/btrfs/qgroup.c | 25 +++++++++++++++---------- fs/btrfs/qgroup.h | 4 ++-- 6 files changed, 31 insertions(+), 25 deletions(-)
fs/btrfs/delalloc-space.c +1 -1
@@ -199,7 +199,7 @@ void btrfs_free_reserved_data_space(stru start =round_down (start, fs_info->sectorsize);btrfs_free_reserved_data_space_noquota (fs_info, len); -btrfs_qgroup_free_data (inode, reserved, start, len); +btrfs_qgroup_free_data (inode, reserved, start, len,NULL ); }/*
fs/btrfs/file.c +1 -1
@@ -3187,7 +3187,7 @@ static long btrfs_fallocate(struct file qgroup_reserved -= range->len; }else if (qgroup_reserved >0 ) {btrfs_qgroup_free_data (BTRFS_I (inode), data_reserved, - range->start, range->len); + range->start, range->len,NULL ); qgroup_reserved -= range->len; }list_del (&range->list);
fs/btrfs/inode.c +8 -8
@@ -687,7 +687,7 @@ out:* And at reserve time, it's always aligned to page size, so * just free one page here. */ -btrfs_qgroup_free_data (inode,NULL ,0 ,PAGE_SIZE ); +btrfs_qgroup_free_data (inode,NULL ,0 ,PAGE_SIZE ,NULL );btrfs_free_path (path);btrfs_end_transaction (trans);return ret;
@@ -5129,7 +5129,7 @@ static void evict_inode_truncate_pages(s*/ if (state_flags &EXTENT_DELALLOC )btrfs_qgroup_free_data (BTRFS_I (inode),NULL , start, - end - start +1 ); + end - start +1 ,NULL ); clear_extent_bit(io_tree, start, end, EXTENT_CLEAR_ALL_BITS | EXTENT_DO_ACCOUNTING,
@@ -8051,7 +8051,7 @@ next:* reserved data space. * Since the IO will never happen for this page. */ -btrfs_qgroup_free_data (inode,NULL , cur, range_end +1 - cur); +btrfs_qgroup_free_data (inode,NULL , cur, range_end +1 - cur,NULL );if (!inode_evicting) { clear_extent_bit(tree, cur, range_end, EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_UPTODATE |
@@ -9481,7 +9481,7 @@ static struct btrfs_trans_handle *insertstruct btrfs_path *path;u64 start = ins->objectid;u64 len = ins->offset; -int qgroup_released; +u64 qgroup_released =0 ;int ret;memset (&stack_fi,0 ,sizeof (stack_fi));
@@ -9494,9 +9494,9 @@ static struct btrfs_trans_handle *insertbtrfs_set_stack_file_extent_compression (&stack_fi,BTRFS_COMPRESS_NONE );/* Encryption and other encoding is reserved and all 0 */ - qgroup_released =btrfs_qgroup_release_data (inode, file_offset, len); -if (qgroup_released <0 ) -return ERR_PTR (qgroup_released); + ret =btrfs_qgroup_release_data (inode, file_offset, len, &qgroup_released); +if (ret <0 ) +return ERR_PTR (ret);if (trans) { ret = insert_reserved_file_extent(trans, inode,
@@ -10391,7 +10391,7 @@ out_delalloc_release:btrfs_delalloc_release_metadata (inode, disk_num_bytes, ret <0 ); out_qgroup_free_data:if (ret <0 ) -btrfs_qgroup_free_data (inode, data_reserved, start, num_bytes); +btrfs_qgroup_free_data (inode, data_reserved, start, num_bytes,NULL ); out_free_data_space:/* * If btrfs_reserve_extent() succeeded, then we already decremented
fs/btrfs/ordered-data.c +4 -3
@@ -153,11 +153,12 @@ static struct btrfs_ordered_extent *allo {struct btrfs_ordered_extent *entry;int ret; +u64 qgroup_rsv =0 ;if (flags & ((1 <<BTRFS_ORDERED_NOCOW ) | (1 <<BTRFS_ORDERED_PREALLOC ))) {/* For nocow write, we can release the qgroup rsv right now */ - ret =btrfs_qgroup_free_data (inode,NULL , file_offset, num_bytes); + ret =btrfs_qgroup_free_data (inode,NULL , file_offset, num_bytes, &qgroup_rsv);if (ret <0 )return ERR_PTR (ret); }else {
@@ -165,7 +166,7 @@ static struct btrfs_ordered_extent *allo* The ordered extent has reserved qgroup space, release now * and pass the reserved number for qgroup_record to free. */ - ret =btrfs_qgroup_release_data (inode, file_offset, num_bytes); + ret =btrfs_qgroup_release_data (inode, file_offset, num_bytes, &qgroup_rsv);if (ret <0 )return ERR_PTR (ret); }
@@ -183,7 +184,7 @@ static struct btrfs_ordered_extent *allo entry->inode =igrab (&inode->vfs_inode); entry->compress_type = compress_type; entry->truncated_len = (u64)-1 ; - entry->qgroup_rsv = ret; + entry->qgroup_rsv = qgroup_rsv; entry->flags = flags;refcount_set (&entry->refs,1 );init_waitqueue_head (&entry->wait);
fs/btrfs/qgroup.c +15 -10
@@ -3855,13 +3855,14 @@ int btrfs_qgroup_reserve_data(struct btr/* Free ranges specified by @reserved, normally in error path */ static int qgroup_free_reserved_data (struct btrfs_inode *inode, -struct extent_changeset *reserved,u64 start,u64 len) +struct extent_changeset *reserved, +u64 start,u64 len,u64 *freed_ret) {struct btrfs_root *root = inode->root;struct ulist_node *unode;struct ulist_iterator uiter;struct extent_changeset changeset; -int freed =0 ; +u64 freed =0 ;int ret;extent_changeset_init (&changeset);
@@ -3902,7 +3903,9 @@ static int qgroup_free_reserved_data(str }btrfs_qgroup_free_refroot (root->fs_info, root->root_key.objectid, freed,BTRFS_QGROUP_RSV_DATA ); - ret = freed; +if (freed_ret) + *freed_ret = freed; + ret =0 ; out:extent_changeset_release (&changeset);return ret;
@@ -3910,7 +3913,7 @@ out:static int __btrfs_qgroup_release_data (struct btrfs_inode *inode,struct extent_changeset *reserved,u64 start,u64 len, -int free) +u64 *released,int free) {struct extent_changeset changeset;int trace_op =QGROUP_RELEASE ;
@@ -3922,7 +3925,7 @@ static int __btrfs_qgroup_release_data(s/* In release case, we shouldn't have @reserved */ WARN_ON (!free && reserved);if (free && reserved) -return qgroup_free_reserved_data (inode, reserved, start, len); +return qgroup_free_reserved_data (inode, reserved, start, len, released);extent_changeset_init (&changeset); ret =clear_record_extent_bits (&inode->io_tree, start, start + len -1 ,EXTENT_QGROUP_RESERVED , &changeset);
@@ -3937,7 +3940,8 @@ static int __btrfs_qgroup_release_data(sbtrfs_qgroup_free_refroot (inode->root->fs_info, inode->root->root_key.objectid, changeset.bytes_changed,BTRFS_QGROUP_RSV_DATA ); - ret = changeset.bytes_changed; +if (released) + *released = changeset.bytes_changed; out:extent_changeset_release (&changeset);return ret;
@@ -3956,9 +3960,10 @@ out:* NOTE: This function may sleep for memory allocation. */ int btrfs_qgroup_free_data (struct btrfs_inode *inode, -struct extent_changeset *reserved,u64 start,u64 len) +struct extent_changeset *reserved, +u64 start,u64 len,u64 *freed) { -return __btrfs_qgroup_release_data (inode, reserved, start, len,1 ); +return __btrfs_qgroup_release_data (inode, reserved, start, len, freed,1 ); }/*
@@ -3976,9 +3981,9 @@ int btrfs_qgroup_free_data(struct btrfs_* * NOTE: This function may sleep for memory allocation. */ -int btrfs_qgroup_release_data (struct btrfs_inode *inode,u64 start,u64 len) +int btrfs_qgroup_release_data (struct btrfs_inode *inode,u64 start,u64 len,u64 *released) { -return __btrfs_qgroup_release_data (inode,NULL , start, len,0 ); +return __btrfs_qgroup_release_data (inode,NULL , start, len, released,0 ); } static void add_root_meta_rsv(struct btrfs_root *root, int num_bytes,
fs/btrfs/qgroup.h +2 -2
@@ -363,10 +363,10 @@ int btrfs_verify_qgroup_counts(struct bt/* New io_tree based accurate qgroup reserve API */ int btrfs_qgroup_reserve_data (struct btrfs_inode *inode,struct extent_changeset **reserved,u64 start,u64 len); -int btrfs_qgroup_release_data (struct btrfs_inode *inode,u64 start,u64 len); +int btrfs_qgroup_release_data (struct btrfs_inode *inode,u64 start,u64 len,u64 *released);int btrfs_qgroup_free_data (struct btrfs_inode *inode,struct extent_changeset *reserved,u64 start, -u64 len); +u64 len,u64 *freed);int btrfs_qgroup_reserve_meta (struct btrfs_root *root,int num_bytes,enum btrfs_qgroup_rsv_type type,bool enforce); int __btrfs_qgroup_reserve_meta(struct btrfs_root *root, int num_bytes,
Greg Kroah-Hartman
maintainerPATCH 145/166 btrfs: dont clear qgroup reserved bit in release_folio
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Burkov <[email protected]>
commit a86805504b88f636a6458520d85afdf0634e3c6b upstream.
The EXTENT_QGROUP_RESERVED bit is used to "lock" regions of the file for duplicate reservations. That is two writes to that range in one transaction shouldn't create two reservations, as the reservation will only be freed once when the write finally goes down. Therefore, it is never OK to clear that bit without freeing the associated qgroup reserve. At this point, we don't want to be freeing the reserve, so mask off the bit.
--- fs/btrfs/extent_io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/extent_io.c +2 -1
@@ -2303,7 +2303,8 @@ static int try_release_extent_state(stru ret =0 ; }else {u32 clear_bits = ~(EXTENT_LOCKED |EXTENT_NODATASUM | -EXTENT_DELALLOC_NEW |EXTENT_CTLBITS ); +EXTENT_DELALLOC_NEW |EXTENT_CTLBITS | +EXTENT_QGROUP_RESERVED );/* * At this point we can safely clear everything except the