6.0.10-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 169/314 mlxsw: Avoid warnings when not offloaded FDB entry with IPv6 is removed
In reply to Greg Kroah-HartmanFrom: Amit Cohen <[email protected]>
[ Upstream commit 30f5312d2c722107364f266cfa98ef4f0857c1fb ]
FDB entries that perform VXLAN encapsulation with an IPv6 underlay hold a reference on a resource - the KVDL entry where the IPv6 underlay destination IP is stored. For that, the driver maintains two hash tables:
1. Maps IPv6 to KVDL index
2. Maps {MAC, FID index} to IPv6 address
When a FDB entry is removed, the second table is used to find the relevant IPv6 address and the first table is used to remove the reference count and free the index if is not used anymore.
In order for a packet to be forwarded to a single remote VTEP, FDB entries need to be configured at both the bridge and VXLAN devices' FDB tables. Both entries are squashed into one {MAC, VLAN/VNI} -> IP entry in the hardware. Therefore, in case one entry is removed, the entry will be removed from the hardware and the remaining entry will be unmarked with 'offload' flag since it is not offloaded anymore.
For example, the two FDB entries should be added to allow packets to be forwarded via vx10:
$ bridge fdb add dev vx10 aa:bb:cc:dd:ee:ff self static dst 2001:db8:5::1 $ bridge fdb add dev vx10 aa:bb:cc:dd:ee:ff master static vlan 10
When one entry will be removed, the second one will not be offloaded anymore. When the first entry (in VXLAN FDB) will be removed / will not be offloaded anymore, the two mappings in IPv6 hash tables will be removed.
In case that the second entry is removed before the first one, unexpected warnings[1][2] will be shown in user space as a result of removing the first entry. The issue is that not offloaded entry is removed, the driver tries to search the relevant entries in the hash tables, does not find them and therefore warns.
Do not handle removing of not offloaded VXLAN FDB entries, as they were already removed when the offload flag was removed.
[1]:
WARNING: CPU: 1 PID: 239 at drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c:914 mlxsw_sp_nve_ipv6_addr_map_del+0x6b/0x80 [mlxsw_spectrum] ... Hardware name: Mellanox Technologies Ltd. Mellanox switch/Mellanox switch, BIOS 4.6.5 05/21/2015 Workqueue: mlxsw_core_ordered mlxsw_sp_switchdev_vxlan_fdb_event_work [mlxsw_spectrum] RIP: 0010:mlxsw_sp_nve_ipv6_addr_map_del+0x6b/0x80 [mlxsw_spectrum] ... Call Trace: <TASK> mlxsw_sp_port_fdb_tunnel_uc_op+0x6cf/0x7b0 [mlxsw_spectrum] mlxsw_sp_switchdev_vxlan_fdb_event_work+0x17c/0x420 [mlxsw_spectrum] ? finish_task_switch.isra.0+0x8c/0x290 process_one_work+0x1cd/0x390 worker_thread+0x48/0x3c0 ? process_one_work+0x390/0x390 kthread+0xe0/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x1f/0x30 </TASK>
[2]:
WARNING: CPU: 0 PID: 239 at drivers/net/ethernet/mellanox/mlxsw/spectrum.c:3035 mlxsw_sp_ipv6_addr_put+0x142/0x220 [mlxsw_spectrum] ... Hardware name: Mellanox Technologies Ltd. Mellanox switch/Mellanox switch, BIOS 4.6.5 05/21/2015 Workqueue: mlxsw_core_ordered mlxsw_sp_switchdev_vxlan_fdb_event_work [mlxsw_spectrum] RIP: 0010:mlxsw_sp_ipv6_addr_put+0x142/0x220 [mlxsw_spectrum] ... Call Trace: <TASK> ? mlxsw_sp_port_fdb_tun_uc_op6_sfd_write+0x5c1/0x610 [mlxsw_spectrum] mlxsw_sp_port_fdb_tunnel_uc_op+0x6ec/0x7b0 [mlxsw_spectrum] mlxsw_sp_switchdev_vxlan_fdb_event_work+0x17c/0x420 [mlxsw_spectrum] ? finish_task_switch.isra.0+0x8c/0x290 process_one_work+0x1cd/0x390 worker_thread+0x48/0x3c0 ? process_one_work+0x390/0x390 kthread+0xe0/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x1f/0x30 </TASK>
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +2 -0
@@ -3470,6 +3470,8 @@ mlxsw_sp_switchdev_vxlan_fdb_del(struct mlxsw_sp *mlxsw_sp,u16 vid; vxlan_fdb_info = &switchdev_work->vxlan_fdb_info; +if (!vxlan_fdb_info->offloaded) +return ; bridge_device =mlxsw_sp_bridge_device_find (mlxsw_sp->bridge, br_dev);if (!bridge_device)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 170/314 net: ionic: Fix error handling in ionic_init_module()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 280c0f7cd0aa4d190619b18243110e052a90775c ]
A problem about ionic create debugfs failed is triggered with the following log given:
[ 415.799514] debugfs: Directory 'ionic' with parent '/' already present!
The reason is that ionic_init_module() returns ionic_bus_register_driver() directly without checking its return value, if ionic_bus_register_driver() failed, it returns without destroy the newly created debugfs, resulting the debugfs of ionic can never be created later.
ionic_init_module()
ionic_debugfs_create() # create debugfs directory ionic_bus_register_driver()
pci_register_driver()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without destroy debugfs directory
Fix by removing debugfs when ionic_bus_register_driver() returns error.
--- drivers/net/ethernet/pensando/ionic/ionic_main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_main.c +7 -1
@@ -687,8 +687,14 @@ int ionic_port_reset(struct ionic *ionic)static int __init ionic_init_module (void ) { +int ret; +ionic_debugfs_create (); -return ionic_bus_register_driver (); + ret =ionic_bus_register_driver (); +if (ret) +ionic_debugfs_destroy (); + +return ret; } static void __exit ionic_cleanup_module(void)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 171/314 kcm: close race conditions on sk_receive_queue
In reply to Greg Kroah-HartmanFrom: Cong Wang <[email protected]>
[ Upstream commit 5121197ecc5db58c07da95eb1ff82b98b121a221 ]
sk->sk_receive_queue is protected by skb queue lock, but for KCM sockets its RX path takes mux->rx_lock to protect more than just skb queue. However, kcm_recvmsg() still only grabs the skb queue lock, so race conditions still exist.
We can teach kcm_recvmsg() to grab mux->rx_lock too but this would introduce a potential performance regression as struct kcm_mux can be shared by multiple KCM sockets.
So we have to enforce skb queue lock in requeue_rx_msgs() and handle skb peek case carefully in kcm_wait_data(). Fortunately, skb_recv_datagram() already handles it nicely and is widely used by other sockets, we can just switch to skb_recv_datagram() after getting rid of the unnecessary sock lock in kcm_recvmsg() and kcm_splice_read(). Side note: SOCK_DONE is not used by KCM sockets, so it is safe to get rid of this check too.
I ran the original syzbot reproducer for 30 min without seeing any issue.
--- net/kcm/kcmsock.c | 58 +++++------------------------------------------ 1 file changed, 6 insertions(+), 52 deletions(-)
net/kcm/kcmsock.c +6 -52
@@ -222,7 +222,7 @@ static void requeue_rx_msgs(struct kcm_mux *mux, struct sk_buff_head *head)struct sk_buff *skb;struct kcm_sock *kcm; -while ((skb =__skb_dequeue (head))) { +while ((skb =skb_dequeue (head))) {/* Reset destructor to avoid calling kcm_rcv_ready */ skb->destructor = sock_rfree;skb_orphan (skb);
@@ -1085,53 +1085,17 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)return err; } -static struct sk_buff *kcm_wait_data (struct sock *sk,int flags, -long timeo,int *err) -{ -struct sk_buff *skb; - -while (!(skb =skb_peek (&sk->sk_receive_queue))) { -if (sk->sk_err) { - *err =sock_error (sk); -return NULL ; - } - -if (sock_flag (sk,SOCK_DONE )) -return NULL ; - -if ((flags &MSG_DONTWAIT ) || !timeo) { - *err = -EAGAIN ; -return NULL ; - } - -sk_wait_data (sk, &timeo,NULL ); - -/* Handle signals */ -if (signal_pending (current)) { - *err =sock_intr_errno (timeo); -return NULL ; - } - } - -return skb; -} -static int kcm_recvmsg (struct socket *sock,struct msghdr *msg,size_t len,int flags) {struct sock *sk = sock->sk;struct kcm_sock *kcm =kcm_sk (sk);int err =0 ; -long timeo;struct strp_msg *stm;int copied =0 ;struct sk_buff *skb; - timeo =sock_rcvtimeo (sk, flags &MSG_DONTWAIT ); - -lock_sock (sk); - - skb =kcm_wait_data (sk, flags, timeo, &err); + skb =skb_recv_datagram (sk, flags, &err);if (!skb) goto out;
@@ -1162,14 +1126,11 @@ static int kcm_recvmsg(struct socket *sock, struct msghdr *msg,/* Finished with message */ msg->msg_flags |=MSG_EOR ;KCM_STATS_INCR (kcm->stats.rx_msgs); -skb_unlink (skb, &sk->sk_receive_queue); -kfree_skb (skb); } } out: -release_sock (sk); - +skb_free_datagram (sk, skb);return copied ? : err; }
@@ -1179,7 +1140,6 @@ static ssize_t kcm_splice_read(struct socket *sock, loff_t *ppos, {struct sock *sk = sock->sk;struct kcm_sock *kcm =kcm_sk (sk); -long timeo;struct strp_msg *stm;int err =0 ;ssize_t copied;
@@ -1187,11 +1147,7 @@ static ssize_t kcm_splice_read(struct socket *sock, loff_t *ppos,/* Only support splice for SOCKSEQPACKET */ - timeo =sock_rcvtimeo (sk, flags &MSG_DONTWAIT ); - -lock_sock (sk); - - skb =kcm_wait_data (sk, flags, timeo, &err); + skb =skb_recv_datagram (sk, flags, &err);if (!skb) goto err_out;
@@ -1219,13 +1175,11 @@ static ssize_t kcm_splice_read(struct socket *sock, loff_t *ppos,* finish reading the message. */ -release_sock (sk); - +skb_free_datagram (sk, skb);return copied; err_out: -release_sock (sk); - +skb_free_datagram (sk, skb);return err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 172/314 net: ena: Fix error handling in ena_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit d349e9be5a2c2d7588a2c4e4bfa0bb3dc1226769 ]
The ena_init() won't destroy workqueue created by create_singlethread_workqueue() when pci_register_driver() failed. Call destroy_workqueue() when pci_register_driver() failed to prevent the resource leak.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +7 -1
@@ -4545,13 +4545,19 @@ static struct pci_driver ena_pci_driver = {static int __init ena_init (void ) { +int ret; + ena_wq =create_singlethread_workqueue (DRV_MODULE_NAME );if (!ena_wq) {pr_err ("Failed to create workqueue\n" );return -ENOMEM ; } -return pci_register_driver (&ena_pci_driver); + ret =pci_register_driver (&ena_pci_driver); +if (ret) +destroy_workqueue (ena_wq); + +return ret; } static void __exit ena_cleanup(void)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 173/314 net: hns3: fix incorrect hw rss hash type of rx packet
In reply to Greg Kroah-HartmanFrom: Jian Shen <[email protected]>
[ Upstream commit a56cad694767ebdb7d80f27ffc239db46fff64de ]
Currently, the HNS3 driver reports the rss hash type of each packet based on the rss hash tuples set. It always reports PKT_HASH_TYPE_L4, without checking the type of current packet. It's incorrect.
Fixes it by reporting it base on the packet type.
--- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 - .../hns3/hns3_common/hclge_comm_rss.c | 20 --- .../hns3/hns3_common/hclge_comm_rss.h | 2 - .../net/ethernet/hisilicon/hns3/hns3_enet.c | 163 ++++++++++-------- .../net/ethernet/hisilicon/hns3/hns3_enet.h | 1 + .../hisilicon/hns3/hns3pf/hclge_main.c | 1 - 6 files changed, 94 insertions(+), 94 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hnae3.h +0 -1
@@ -790,7 +790,6 @@ struct hnae3_knic_private_info {const struct hnae3_dcb_ops *dcb_ops;u16 int_rl_setting; -enum pkt_hash_types rss_type;void __iomem *io_base; };
drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_rss.c +0 -20
@@ -191,23 +191,6 @@ u32 hclge_comm_get_rss_key_size(struct hnae3_handle *handle)return HCLGE_COMM_RSS_KEY_SIZE ; } -void hclge_comm_get_rss_type (struct hnae3_handle *nic, -struct hclge_comm_rss_tuple_cfg *rss_tuple_sets) -{ -if (rss_tuple_sets->ipv4_tcp_en || - rss_tuple_sets->ipv4_udp_en || - rss_tuple_sets->ipv4_sctp_en || - rss_tuple_sets->ipv6_tcp_en || - rss_tuple_sets->ipv6_udp_en || - rss_tuple_sets->ipv6_sctp_en) - nic->kinfo.rss_type =PKT_HASH_TYPE_L4 ; -else if (rss_tuple_sets->ipv4_fragment_en || - rss_tuple_sets->ipv6_fragment_en) - nic->kinfo.rss_type =PKT_HASH_TYPE_L3 ; -else - nic->kinfo.rss_type =PKT_HASH_TYPE_NONE ; -} -int hclge_comm_parse_rss_hfunc (struct hclge_comm_rss_cfg *rss_cfg,const u8 hfunc,u8 *hash_algo) {
@@ -344,9 +327,6 @@ int hclge_comm_set_rss_input_tuple(struct hnae3_handle *nic, req->ipv6_sctp_en = rss_cfg->rss_tuple_sets.ipv6_sctp_en; req->ipv6_fragment_en = rss_cfg->rss_tuple_sets.ipv6_fragment_en; -if (is_pf) -hclge_comm_get_rss_type (nic, &rss_cfg->rss_tuple_sets); - ret =hclge_comm_cmd_send (hw, &desc,1 );if (ret) dev_err(&hw->cmq.csq.pdev->dev,
drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_rss.h +0 -2
@@ -95,8 +95,6 @@ struct hclge_comm_rss_tc_mode_cmd { };u32 hclge_comm_get_rss_key_size (struct hnae3_handle *handle); -void hclge_comm_get_rss_type (struct hnae3_handle *nic, -struct hclge_comm_rss_tuple_cfg *rss_tuple_sets);void hclge_comm_rss_indir_init_cfg (struct hnae3_ae_dev *ae_dev,struct hclge_comm_rss_cfg *rss_cfg); int hclge_comm_get_rss_tuple(struct hclge_comm_rss_cfg *rss_cfg, int flow_type,
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +93 -70
212 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +1 -0
@@ -404,6 +404,7 @@ struct hns3_rx_ptype { u32 ip_summed : 2; u32 l3_type : 4; u32 valid : 1; + u32 hash_type: 3; };struct ring_stats {
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +0 -1
@@ -4662,7 +4662,6 @@ static int hclge_set_rss_tuple(struct hnae3_handle *handle,return ret; } -hclge_comm_get_rss_type (&vport->nic, &hdev->rss_cfg.rss_tuple_sets);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 174/314 net: hns3: fix return value check bug of rx copybreak
In reply to Greg Kroah-HartmanFrom: Jie Wang <[email protected]>
[ Upstream commit 29df7c695ed67a8fa32bb7805bad8fe2a76c1f88 ]
The refactoring of rx copybreak modifies the original return logic, which will make this feature unavailable. So this patch fixes the return logic of rx copybreak.
--- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +2 -2
@@ -3736,8 +3736,8 @@ static void hns3_nic_reuse_page(struct sk_buff *skb, int i, desc_cb->reuse_flag =1 ; }else if (frag_size <= ring->rx_copybreak) { ret =hns3_handle_rx_copybreak (skb, i, ring, pull_len, desc_cb); -if (ret) - goto out; +if (!ret) +return ; } out:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 175/314 net: hns3: fix setting incorrect phy link ksettings for firmware in resetting process
In reply to Greg Kroah-HartmanFrom: Guangbin Huang <[email protected]>
[ Upstream commit 510d7b6ae842e59ee00d57e5f07ac15131b6d899 ]
Currently, if driver is in phy-imp(phy controlled by imp firmware) mode, as driver did not update phy link ksettings after initialization process or not update advertising when getting phy link ksettings from firmware, it may set incorrect phy link ksettings for firmware in resetting process. So fix it.
--- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +7 -3
@@ -3246,6 +3246,7 @@ static int hclge_update_tp_port_info(struct hclge_dev *hdev) hdev->hw.mac.autoneg = cmd.base.autoneg; hdev->hw.mac.speed = cmd.base.speed; hdev->hw.mac.duplex = cmd.base.duplex; +linkmode_copy (hdev->hw.mac.advertising, cmd.link_modes.advertising);return 0 ; }
@@ -11373,9 +11374,12 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)if (ret) goto err_msi_irq_uninit; -if (hdev->hw.mac.media_type ==HNAE3_MEDIA_TYPE_COPPER && - !hnae3_dev_phy_imp_supported (hdev)) { - ret =hclge_mac_mdio_config (hdev); +if (hdev->hw.mac.media_type ==HNAE3_MEDIA_TYPE_COPPER ) { +if (hnae3_dev_phy_imp_supported (hdev)) + ret =hclge_update_tp_port_info (hdev); +else + ret =hclge_mac_mdio_config (hdev); +if (ret) goto err_msi_irq_uninit; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 176/314 bridge: switchdev: Fix memory leaks when changing VLAN protocol
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit 9d45921ee4cb364910097e7d1b7558559c2f9fd2 ]
The bridge driver can offload VLANs to the underlying hardware either via switchdev or the 8021q driver. When the former is used, the VLAN is marked in the bridge driver with the 'BR_VLFLAG_ADDED_BY_SWITCHDEV' private flag.
To avoid the memory leaks mentioned in the cited commit, the bridge driver will try to delete a VLAN via the 8021q driver if the VLAN is not marked with the previously mentioned flag.
When the VLAN protocol of the bridge changes, switchdev drivers are notified via the 'SWITCHDEV_ATTR_ID_BRIDGE_VLAN_PROTOCOL' attribute, but the 8021q driver is also called to add the existing VLANs with the new protocol and delete them with the old protocol.
In case the VLANs were offloaded via switchdev, the above behavior is both redundant and buggy. Redundant because the VLANs are already programmed in hardware and drivers that support VLAN protocol change (currently only mlx5) change the protocol upon the switchdev attribute notification. Buggy because the 8021q driver is called despite these VLANs being marked with 'BR_VLFLAG_ADDED_BY_SWITCHDEV'. This leads to memory leaks [1] when the VLANs are deleted.
Fix by not calling the 8021q driver for VLANs that were already programmed via switchdev.
[1]
unreferenced object 0xffff8881f6771200 (size 256):
comm "ip", pid 446855, jiffies 4298238841 (age 55.240s) hex dump (first 32 bytes):
00 00 7f 0e 83 88 ff ff 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000012819ac>] vlan_vid_add+0x437/0x750
[<00000000f2281fad>] __br_vlan_set_proto+0x289/0x920
[<000000000632b56f>] br_changelink+0x3d6/0x13f0
[<0000000089d25f04>] __rtnl_newlink+0x8ae/0x14c0
[<00000000f6276baf>] rtnl_newlink+0x5f/0x90
[<00000000746dc902>] rtnetlink_rcv_msg+0x336/0xa00
[<000000001c2241c0>] netlink_rcv_skb+0x11d/0x340
[<0000000010588814>] netlink_unicast+0x438/0x710
[<00000000e1a4cd5c>] netlink_sendmsg+0x788/0xc40
[<00000000e8992d4e>] sock_sendmsg+0xb0/0xe0
[<00000000621b8f91>] ____sys_sendmsg+0x4ff/0x6d0
[<000000000ea26996>] ___sys_sendmsg+0x12e/0x1b0
[<00000000684f7e25>] __sys_sendmsg+0xab/0x130
[<000000004538b104>] do_syscall_64+0x3d/0x90
[<0000000091ed9678>] entry_SYSCALL_64_after_hwframe+0x46/0xb0--- net/bridge/br_vlan.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
net/bridge/br_vlan.c +14 -3
@@ -959,6 +959,8 @@ int __br_vlan_set_proto(struct net_bridge *br, __be16 proto,list_for_each_entry (p, &br->port_list, list) { vg =nbp_vlan_group (p);list_for_each_entry (vlan, &vg->vlan_list, vlist) { +if (vlan->priv_flags &BR_VLFLAG_ADDED_BY_SWITCHDEV ) +continue ; err =vlan_vid_add (p->dev, proto, vlan->vid);if (err) goto err_filt;
@@ -973,8 +975,11 @@ int __br_vlan_set_proto(struct net_bridge *br, __be16 proto,/* Delete VLANs for the old proto from the device filter. */ list_for_each_entry (p, &br->port_list, list) { vg =nbp_vlan_group (p); -list_for_each_entry (vlan, &vg->vlan_list, vlist) +list_for_each_entry (vlan, &vg->vlan_list, vlist) { +if (vlan->priv_flags &BR_VLFLAG_ADDED_BY_SWITCHDEV ) +continue ;vlan_vid_del (p->dev, oldproto, vlan->vid); + } }return 0 ;
@@ -983,13 +988,19 @@ int __br_vlan_set_proto(struct net_bridge *br, __be16 proto, attr.u.vlan_protocol =ntohs (oldproto);switchdev_port_attr_set (br->dev, &attr,NULL ); -list_for_each_entry_continue_reverse (vlan, &vg->vlan_list, vlist) +list_for_each_entry_continue_reverse (vlan, &vg->vlan_list, vlist) { +if (vlan->priv_flags &BR_VLFLAG_ADDED_BY_SWITCHDEV ) +continue ;vlan_vid_del (p->dev, proto, vlan->vid); + }list_for_each_entry_continue_reverse (p, &br->port_list, list) { vg =nbp_vlan_group (p); -list_for_each_entry (vlan, &vg->vlan_list, vlist) +list_for_each_entry (vlan, &vg->vlan_list, vlist) { +if (vlan->priv_flags &BR_VLFLAG_ADDED_BY_SWITCHDEV ) +continue ;vlan_vid_del (p->dev, proto, vlan->vid); + } }return err;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 177/314 drbd: use after free in drbd_create_device()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit a7a1598189228b5007369a9622ccdf587be0730f ]
The drbd_destroy_connection() frees the "connection" so use the _safe() iterator to prevent a use after free.
--- drivers/block/drbd/drbd_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/drbd/drbd_main.c +2 -2
@@ -2672,7 +2672,7 @@ static int init_submitter(struct drbd_device *device)enum drbd_ret_code drbd_create_device (struct drbd_config_context *adm_ctx,unsigned int minor) {struct drbd_resource *resource = adm_ctx->resource; -struct drbd_connection *connection; +struct drbd_connection *connection, *n;struct drbd_device *device;struct drbd_peer_device *peer_device, *tmp_peer_device;struct gendisk *disk;
@@ -2789,7 +2789,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsigreturn NO_ERROR ; out_idr_remove_from_resource: -for_each_connection (connection, resource) { +for_each_connection_safe (connection, n, resource) { peer_device =idr_remove (&connection->peer_devices, vnr);if (peer_device)kref_put (&connection->kref, drbd_destroy_connection);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 178/314 platform/x86/intel: pmc: Dont unconditionally attach Intel PMC when virtualized
In reply to Greg Kroah-HartmanFrom: Roger Pau Monné <[email protected]>
[ Upstream commit 2dbfb3f33350e1e868d3d7ed4c176d8777150878 ]
The current logic in the Intel PMC driver will forcefully attach it when detecting any CPU on the intel_pmc_core_platform_ids array, even if the matching ACPI device is not present.
There's no checking in pmc_core_probe() to assert that the PMC device is present, and hence on virtualized environments the PMC device probes successfully, even if the underlying registers are not present. Before commit 21ae43570940 ("platform/x86: intel_pmc_core: Substitute PCI with CPUID enumeration") the driver would check for the presence of a specific PCI device, and that prevented the driver from attaching when running virtualized.
Fix by only forcefully attaching the PMC device when not running virtualized. Note that virtualized platforms can still get the device to load if the appropriate ACPI device is present on the tables provided to the VM.
Make an exception for the Xen initial domain, which does have full hardware access, and hence can attach to the PMC if present.
--- drivers/platform/x86/intel/pmc/pltdrv.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/platform/x86/intel/pmc/pltdrv.c +9 -0
@@ -18,6 +18,8 @@#include <asm/cpu_device_id.h> #include <asm/intel-family.h> +#include <xen/xen.h> +static void intel_pmc_core_release (struct device *dev) {kfree (dev);
@@ -53,6 +55,13 @@ static int __init pmc_core_platform_init(void)if (acpi_dev_present ("INT33A1" ,NULL ,-1 ))return -ENODEV ; +/* +* Skip forcefully attaching the device for VMs. Make an exception for +* Xen dom0, which does have full hardware access. +*/ +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR ) && !xen_initial_domain ()) +return -ENODEV ; +if (!x86_match_cpu (intel_pmc_core_platform_ids))return -ENODEV ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 179/314 platform/surface: aggregator: Do not check for repeated unsequenced packets
In reply to Greg Kroah-HartmanFrom: Maximilian Luz <[email protected]>
[ Upstream commit d9a477f643eb3de71fbea5ae6103b800ceb8f547 ]
Currently, we check any received packet whether we have already seen it previously, regardless of the packet type (sequenced / unsequenced). We do this by checking the sequence number. This assumes that sequence numbers are valid for both sequenced and unsequenced packets. However, this assumption appears to be incorrect.
On some devices, the sequence number field of unsequenced packets (in particular HID input events on the Surface Pro 9) is always zero. As a result, the current retransmission check kicks in and discards all but the first unsequenced packet, breaking (among other things) keyboard and touchpad input.
Note that we have, so far, only seen packets being retransmitted in sequenced communication. In particular, this happens when there is an ACK timeout, causing the EC (or us) to re-send the packet waiting for an ACK. Arguably, retransmission / duplication of unsequenced packets should not be an issue as there is no logical condition (such as an ACK timeout) to determine when a packet should be sent again.
Therefore, remove the retransmission check for unsequenced packets entirely to resolve the issue.
--- .../surface/aggregator/ssh_packet_layer.c | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
drivers/platform/surface/aggregator/ssh_packet_layer.c +20 -4
@@ -1596,16 +1596,32 @@ static void ssh_ptl_timeout_reap(struct work_struct *work)ssh_ptl_tx_wakeup_packet (ptl); } -static bool ssh_ptl_rx_retransmit_check (struct ssh_ptl *ptl,u8 seq) +static bool ssh_ptl_rx_retransmit_check (struct ssh_ptl *ptl,const struct ssh_frame *frame) {int i; +/* +* Ignore unsequenced packets. On some devices (notably Surface Pro 9), +* unsequenced events will always be sent with SEQ=0x00. Attempting to +* detect retransmission would thus just block all events. +* +* While sequence numbers would also allow detection of retransmitted +* packets in unsequenced communication, they have only ever been used +* to cover edge-cases in sequenced transmission. In particular, the +* only instance of packets being retransmitted (that we are aware of) +* is due to an ACK timeout. As this does not happen in unsequenced +* communication, skip the retransmission check for those packets +* entirely. +*/ +if (frame->type ==SSH_FRAME_TYPE_DATA_NSQ ) +return false; +/* * Check if SEQ has been seen recently (i.e. packet was * re-transmitted and we should ignore it). */ for (i =0 ; i <ARRAY_SIZE (ptl->rx.blocked.seqs); i++) { -if (likely (ptl->rx.blocked.seqs[i] != seq)) +if (likely (ptl->rx.blocked.seqs[i] != frame->seq))continue ;ptl_dbg (ptl,"ptl: ignoring repeated data packet\n" );
@@ -1613,7 +1629,7 @@ static bool ssh_ptl_rx_retransmit_check(struct ssh_ptl *ptl, u8 seq) }/* Update list of blocked sequence IDs. */ - ptl->rx.blocked.seqs[ptl->rx.blocked.offset] = seq; + ptl->rx.blocked.seqs[ptl->rx.blocked.offset] = frame->seq; ptl->rx.blocked.offset = (ptl->rx.blocked.offset +1 ) %ARRAY_SIZE (ptl->rx.blocked.seqs);
@@ -1624,7 +1640,7 @@ static void ssh_ptl_rx_dataframe(struct ssh_ptl *ptl, const struct ssh_frame *frame, const struct ssam_span *payload) { - if (ssh_ptl_rx_retransmit_check(ptl, frame->seq)) + if (ssh_ptl_rx_retransmit_check(ptl, frame)) return; ptl->ops.data_received (ptl, payload);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 180/314 netfs: Fix missing xas_retry() calls in xarray iteration
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 7e043a80b5dae5c2d2cf84031501de7827fd6c00 ]
netfslib has a number of places in which it performs iteration of an xarray whilst being under the RCU read lock. It *should* call xas_retry() as the first thing inside of the loop and do "continue" if it returns true in case the xarray walker passed out a special value indicating that the walk needs to be redone from the root[*].
Fix this by adding the missing retry checks.
[*] I wonder if this should be done inside xas_find(), xas_next_node() and
suchlike, but I'm told that's not an simple change to effect.
This can cause an oops like that below. Note the faulting address - this is an internal value (|0x2) returned from xarray.
BUG: kernel NULL pointer dereference, address: 0000000000000402 ... RIP: 0010:netfs_rreq_unlock+0xef/0x380 [netfs] ... Call Trace: netfs_rreq_assess+0xa6/0x240 [netfs] netfs_readpage+0x173/0x3b0 [netfs] ? init_wait_var_entry+0x50/0x50 filemap_read_page+0x33/0xf0 filemap_get_pages+0x2f2/0x3f0 filemap_read+0xaa/0x320 ? do_filp_open+0xb2/0x150 ? rmqueue+0x3be/0xe10 ceph_read_iter+0x1fe/0x680 [ceph] ? new_sync_read+0x115/0x1a0 new_sync_read+0x115/0x1a0 vfs_read+0xf3/0x180 ksys_read+0x5f/0xe0 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae
Changes:
========
ver #2)
- Changed an unsigned int to a size_t to reduce the likelihood of an overflow as per Willy's suggestion.
- Added an additional patch to fix the maths.
--- fs/netfs/buffered_read.c | 9 +++++++-- fs/netfs/io.c | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-)
fs/netfs/buffered_read.c +7 -2
@@ -46,10 +46,15 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq)rcu_read_lock ();xas_for_each (&xas, folio, last_page) { -unsigned int pgpos = (folio_index (folio) - start_page) *PAGE_SIZE ; -unsigned int pgend = pgpos +folio_size (folio); +unsigned int pgpos, pgend;bool pg_failed = false; +if (xas_retry (&xas, folio)) +continue ; + + pgpos = (folio_index (folio) - start_page) *PAGE_SIZE ; + pgend = pgpos +folio_size (folio); +for (;;) {if (!subreq) { pg_failed = true;
fs/netfs/io.c +3 -0
@@ -121,6 +121,9 @@ static void netfs_rreq_unmark_after_write(struct netfs_io_request *rreq,XA_STATE (xas, &rreq->mapping->i_pages, subreq->start /PAGE_SIZE );xas_for_each (&xas, folio, (subreq->start + subreq->len -1 ) /PAGE_SIZE ) { +if (xas_retry (&xas, folio)) +continue ; +/* We might have multiple writes from the same huge * folio, but we mustn't unlock a folio more than once. */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 181/314 netfs: Fix dodgy maths
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 5e51c627c5acbcf82bb552e17533a79d2a6a2600 ]
Fix the dodgy maths in netfs_rreq_unlock_folios(). start_page could be inside the folio, in which case the calculation of pgpos will be come up with a negative number (though for the moment rreq->start is rounded down earlier and folios would have to get merged whilst locked)
Alter how this works to just frame the tracking in terms of absolute file positions, rather than offsets from the start of the I/O request. This simplifies the maths and makes it easier to follow.
Fix the issue by using folio_pos() and folio_size() to calculate the end position of the page.
--- fs/netfs/buffered_read.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
fs/netfs/buffered_read.c +9 -8
@@ -17,9 +17,9 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq) {struct netfs_io_subrequest *subreq;struct folio *folio; -unsigned int iopos, account =0 ;pgoff_t start_page = rreq->start /PAGE_SIZE ;pgoff_t last_page = ((rreq->start + rreq->len) /PAGE_SIZE ) -1 ; +size_t account =0 ;bool subreq_failed = false;XA_STATE (xas, &rreq->mapping->i_pages, start_page);
@@ -39,23 +39,23 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq)*/ subreq =list_first_entry (&rreq->subrequests, struct netfs_io_subrequest, rreq_link); - iopos =0 ; subreq_failed = (subreq->error <0 );trace_netfs_rreq (rreq, netfs_rreq_trace_unlock);rcu_read_lock ();xas_for_each (&xas, folio, last_page) { -unsigned int pgpos, pgend; +loff_t pg_end;bool pg_failed = false;if (xas_retry (&xas, folio))continue ; - pgpos = (folio_index (folio) - start_page) *PAGE_SIZE ; - pgend = pgpos +folio_size (folio); + pg_end =folio_pos (folio) +folio_size (folio) -1 ;for (;;) { +loff_t sreq_end; +if (!subreq) { pg_failed = true;break ;
@@ -63,11 +63,11 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq)if (test_bit (NETFS_SREQ_COPY_TO_CACHE , &subreq->flags))folio_start_fscache (folio); pg_failed |= subreq_failed; -if (pgend < iopos + subreq->len) + sreq_end = subreq->start + subreq->len -1 ; +if (pg_end < sreq_end)break ; account += subreq->transferred; - iopos += subreq->len;if (!list_is_last (&subreq->rreq_link, &rreq->subrequests)) { subreq =list_next_entry (subreq, rreq_link); subreq_failed = (subreq->error <0 );
@@ -75,7 +75,8 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq) subreq =NULL ; subreq_failed = false; } -if (pgend == iopos) + +if (pg_end == sreq_end)break ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 182/314 cifs: add check for returning value of SMB2_close_init
In reply to Greg Kroah-HartmanFrom: Anastasia Belova <[email protected]>
[ Upstream commit d520de6cb42e88a1d008b54f935caf9fc05951da ]
If the returning value of SMB2_close_init is an error-value, exit the function.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/cifs/smb2ops.c | 2 ++ 1 file changed, 2 insertions(+)
fs/cifs/smb2ops.c +2 -0
@@ -1133,6 +1133,8 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, rqst[2 ].rq_nvec =1 ; rc =SMB2_close_init (tcon, server, &rqst[2 ],COMPOUND_FID ,COMPOUND_FID , false); +if (rc) + goto sea_exit;smb2_set_related (&rqst[2 ]); rc = compound_send_recv(xid, ses, server,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 183/314 net: ag71xx: call phylink_disconnect_phy if ag71xx_hw_enable() fail in ag71xx_open()
In reply to Greg Kroah-HartmanFrom: Liu Jian <[email protected]>
[ Upstream commit c9b895c6878bdb6789dc1d7af60fd10f4a9f1937 ]
If ag71xx_hw_enable() fails, call phylink_disconnect_phy() to clean up. And if phylink_of_phy_connect() fails, nothing needs to be done. Compile tested only.
--- drivers/net/ethernet/atheros/ag71xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/atheros/ag71xx.c +2 -1
@@ -1427,7 +1427,7 @@ static int ag71xx_open(struct net_device *ndev)if (ret) {netif_err (ag, link, ndev,"phylink_of_phy_connect filed with err: %i\n" , ret); - goto err; +return ret; } max_frame_len =ag71xx_max_frame_len (ndev->mtu);
@@ -1448,6 +1448,7 @@ static int ag71xx_open(struct net_device *ndev) err:ag71xx_rings_cleanup (ag); +phylink_disconnect_phy (ag->phylink);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 184/314 net/x25: Fix skb leak in x25_lapb_receive_frame()
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
[ Upstream commit 2929cceb2fcf0ded7182562e4888afafece82cce ]
x25_lapb_receive_frame() using skb_copy() to get a private copy of skb, the new skb should be freed in the undersized/fragmented skb error handling path. Otherwise there is a memory leak.
--- net/x25/x25_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/x25/x25_dev.c +1 -1
@@ -117,7 +117,7 @@ int x25_lapb_receive_frame(struct sk_buff *skb, struct net_device *dev,if (!pskb_may_pull (skb,1 )) {x25_neigh_put (nb); -return 0 ; + goto drop; }switch (skb->data[0 ]) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 185/314 net: dsa: dont leak tagger-owned storage on switch driver unbind
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 4e0c19fcb8b5323716140fa82b79aa9f60e60407 ]
In the initial commit dc452a471dba ("net: dsa: introduce tagger-owned storage for private and shared data"), we had a call to tag_ops->disconnect(dst) issued from dsa_tree_free(), which is called at tree teardown time.
There were problems with connecting to a switch tree as a whole, so this got reworked to connecting to individual switches within the tree. In this process, tag_ops->disconnect(ds) was made to be called only from switch.c (cross-chip notifiers emitted as a result of dynamic tag proto changes), but the normal driver teardown code path wasn't replaced with anything.
Solve this problem by adding a function that does the opposite of dsa_switch_setup_tag_protocol(), which is called from the equivalent spot in dsa_switch_teardown(). The positioning here also ensures that we won't have any use-after-free in tagging protocol (*rcv) ops, since the teardown sequence is as follows:
dsa_tree_teardown
-> dsa_tree_teardown_master
-> dsa_master_teardown
-> unsets master->dsa_ptr, making no further packets match the
ETH_P_XDSA packet type handler
-> dsa_tree_teardown_ports
-> dsa_port_teardown
-> dsa_slave_destroy
-> unregisters DSA net devices, there is even a synchronize_net()
in unregister_netdevice_many()
-> dsa_tree_teardown_switches
-> dsa_switch_teardown
-> dsa_switch_teardown_tag_protocol
-> finally frees the tagger-owned storage--- net/dsa/dsa2.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/dsa/dsa2.c +10 -0
@@ -850,6 +850,14 @@ static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds)return err; } +static void dsa_switch_teardown_tag_protocol (struct dsa_switch *ds) +{ +const struct dsa_device_ops *tag_ops = ds->dst->tag_ops; + +if (tag_ops->disconnect) + tag_ops->disconnect (ds); +} +static int dsa_switch_setup (struct dsa_switch *ds) {struct dsa_devlink_priv *dl_priv;
@@ -953,6 +961,8 @@ static void dsa_switch_teardown(struct dsa_switch *ds) ds->slave_mii_bus =NULL ; } +dsa_switch_teardown_tag_protocol (ds); +if (ds->ops->teardown) ds->ops->teardown (ds);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 186/314 nvmet: fix a memory leak in nvmet_auth_set_key
In reply to Greg Kroah-HartmanFrom: Sagi Grimberg <[email protected]>
[ Upstream commit 0a52566279b4ee65ecd2503d7b7342851f84755c ]
When changing dhchap secrets we need to release the old secrets as well.
kmemleak complaint:
--
unreferenced object 0xffff8c7f44ed8180 (size 64):
comm "check", pid 7304, jiffies 4295686133 (age 72034.246s) hex dump (first 32 bytes):
44 48 48 43 2d 31 3a 30 30 3a 4c 64 4c 4f 64 71 DHHC-1:00:LdLOdq
79 56 69 67 77 48 55 32 6d 5a 59 4c 7a 35 59 38 yVigwHU2mZYLz5Y8
backtrace:
[<00000000b6fc5071>] kstrdup+0x2e/0x60
[<00000000f0f4633f>] 0xffffffffc0e07ee6
[<0000000053006c05>] 0xffffffffc0dff783
[<00000000419ae922>] configfs_write_iter+0xb1/0x120
[<000000008183c424>] vfs_write+0x2be/0x3c0
[<000000009005a2a5>] ksys_write+0x5f/0xe0
[<00000000cd495c89>] do_syscall_64+0x38/0x90
[<00000000f2a84ac5>] entry_SYSCALL_64_after_hwframe+0x63/0xcd--- drivers/nvme/target/auth.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/target/auth.c +2 -0
@@ -45,9 +45,11 @@ int nvmet_auth_set_key(struct nvmet_host *host, const char *secret,if (!dhchap_secret)return -ENOMEM ;if (set_ctrl) { +kfree (host->dhchap_ctrl_secret); host->dhchap_ctrl_secret =strim (dhchap_secret); host->dhchap_ctrl_key_hash = key_hash; }else { +kfree (host->dhchap_secret); host->dhchap_secret =strim (dhchap_secret); host->dhchap_key_hash = key_hash; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 187/314 cifs: Fix wrong return value checking when GETFLAGS
In reply to Greg Kroah-HartmanFrom: Zhang Xiaoxu <[email protected]>
[ Upstream commit 92bbd67a55fee50743b42825d1c016e7fd5c79f9 ]
The return value of CIFSGetExtAttr is negative, should be checked with -EOPNOTSUPP rather than EOPNOTSUPP.
--- fs/cifs/ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/cifs/ioctl.c +2 -2
@@ -343,7 +343,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) rc =put_user (ExtAttrBits &FS_FL_USER_VISIBLE , (int __user *)arg); -if (rc !=EOPNOTSUPP ) +if (rc != -EOPNOTSUPP ) break; }#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
@@ -373,7 +373,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)* pSMBFile->fid.netfid, * extAttrBits, * &ExtAttrMask); -* if (rc != EOPNOTSUPP) +* if (rc != -EOPNOTSUPP) * break; */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 188/314 net: lan966x: Fix potential null-ptr-deref in lan966x_stats_init()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit ba86af3733aece88dbcee0dfebf7e2dcfefb2be4 ]
lan966x_stats_init() calls create_singlethread_workqueue() and not checked the ret value, which may return NULL. And a null-ptr-deref may happen:
lan966x_stats_init()
create_singlethread_workqueue() # failed, lan966x->stats_queue is NULL
queue_delayed_work()
queue_delayed_work_on()
__queue_delayed_work() # warning here, but continue
__queue_work() # access wq->flags, null-ptr-derefCheck the ret value and return -ENOMEM if it is NULL.
--- drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c +3 -0
@@ -716,6 +716,9 @@ int lan966x_stats_init(struct lan966x *lan966x)snprintf (queue_name,sizeof (queue_name),"%s-stats" ,dev_name (lan966x->dev)); lan966x->stats_queue =create_singlethread_workqueue (queue_name); +if (!lan966x->stats_queue) +return -ENOMEM ; +INIT_DELAYED_WORK (&lan966x->stats_work, lan966x_check_stats_work);queue_delayed_work (lan966x->stats_queue, &lan966x->stats_work,LAN966X_STATS_CHECK_DELAY );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 189/314 net: microchip: sparx5: Fix potential null-ptr-deref in sparx_stats_init() and sparx5_start()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 639f5d006e36bb303f525d9479448c412b720c39 ]
sparx_stats_init() calls create_singlethread_workqueue() and not checked the ret value, which may return NULL. And a null-ptr-deref may happen:
sparx_stats_init()
create_singlethread_workqueue() # failed, sparx5->stats_queue is NULL
queue_delayed_work()
queue_delayed_work_on()
__queue_delayed_work() # warning here, but continue
__queue_work() # access wq->flags, null-ptr-derefCheck the ret value and return -ENOMEM if it is NULL. So as sparx5_start().
--- drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c | 3 +++ drivers/net/ethernet/microchip/sparx5/sparx5_main.c | 3 +++ 2 files changed, 6 insertions(+)
drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c +3 -0
@@ -1253,6 +1253,9 @@ int sparx_stats_init(struct sparx5 *sparx5)snprintf (queue_name,sizeof (queue_name),"%s-stats" ,dev_name (sparx5->dev)); sparx5->stats_queue =create_singlethread_workqueue (queue_name); +if (!sparx5->stats_queue) +return -ENOMEM ; +INIT_DELAYED_WORK (&sparx5->stats_work, sparx5_check_stats_work);queue_delayed_work (sparx5->stats_queue, &sparx5->stats_work,SPX5_STATS_CHECK_DELAY );
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +3 -0
@@ -657,6 +657,9 @@ static int sparx5_start(struct sparx5 *sparx5)snprintf (queue_name,sizeof (queue_name),"%s-mact" ,dev_name (sparx5->dev)); sparx5->mact_queue =create_singlethread_workqueue (queue_name); +if (!sparx5->mact_queue) +return -ENOMEM ; +INIT_DELAYED_WORK (&sparx5->mact_work, sparx5_mact_pull_work);queue_delayed_work (sparx5->mact_queue, &sparx5->mact_work,SPX5_MACT_PULL_DELAY );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 190/314 net: thunderbolt: Fix error handling in tbnet_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit f524b7289bbb0c8ffaa2ba3c34c146e43da54fb2 ]
A problem about insmod thunderbolt-net failed is triggered with following log given while lsmod does not show thunderbolt_net:
insmod: ERROR: could not insert module thunderbolt-net.ko: File exists
The reason is that tbnet_init() returns tb_register_service_driver() directly without checking its return value, if tb_register_service_driver() failed, it returns without removing property directory, resulting the property directory can never be created later.
tbnet_init()
tb_register_property_dir() # register property directory tb_register_service_driver()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without remove property directory
Fix by remove property directory when tb_register_service_driver() returns error.
--- drivers/net/thunderbolt.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/net/thunderbolt.c +14 -5
@@ -1379,12 +1379,21 @@ static int __init tbnet_init(void) TBNET_MATCH_FRAGS_ID | TBNET_64K_FRAMES); ret =tb_register_property_dir ("network" , tbnet_dir); -if (ret) { -tb_property_free_dir (tbnet_dir); -return ret; - } +if (ret) + goto err_free_dir; + + ret =tb_register_service_driver (&tbnet_driver); +if (ret) + goto err_unregister; -return tb_register_service_driver (&tbnet_driver); +return 0 ; + +err_unregister: +tb_unregister_property_dir ("network" , tbnet_dir); +err_free_dir: +tb_property_free_dir (tbnet_dir); + +return ret; }module_init (tbnet_init);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 191/314 s390: avoid using global register for current_stack_pointer
In reply to Greg Kroah-HartmanFrom: Vasily Gorbik <[email protected]>
[ Upstream commit e3c11025bcd2142a61abe5806b2f86a0e78118df ]
Commit 30de14b1884b ("s390: current_stack_pointer shouldn't be a function") made current_stack_pointer a global register variable like on many other architectures. Unfortunately on s390 it uncovers old gcc bug which is fixed only since gcc-9.1 [gcc commit 3ad7fed1cc87 ("S/390: Fix PR89775. Stackpointer save/restore instructions removed")] and backported to gcc-8.4 and later. Due to this bug gcc versions prior to 8.4 generate broken code which leads to stack corruptions.
Current minimal gcc version required to build the kernel is declared as 5.1. It is not possible to fix all old gcc versions, so work around this problem by avoiding using global register variable for current_stack_pointer.
--- arch/s390/include/asm/processor.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/s390/include/asm/processor.h +10 -1
@@ -202,7 +202,16 @@ unsigned long __get_wchan(struct task_struct *p);/* Has task runtime instrumentation enabled ? */ #define is_ri_task (tsk) (!!(tsk)->thread.ri_cb) -registerunsigned long current_stack_pointer asm("r15" ); +/* avoid using global register due to gcc bug in versions < 8.4 */ +#define current_stack_pointer (__current_stack_pointer()) + +static __always_inline unsigned long __current_stack_pointer (void ) +{ +unsigned long sp; + + asmvolatile ("lgr %0,15" :"=d" (sp)); +return sp; +}static __always_inline unsigned short stap (void ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 192/314 cifs: add check for returning value of SMB2_set_info_init
In reply to Greg Kroah-HartmanFrom: Anastasia Belova <[email protected]>
[ Upstream commit a51e5d293dd1c2e7bf6f7be788466cd9b5d280fb ]
If the returning value of SMB2_set_info_init is an error-value, exit the function.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/cifs/smb2ops.c | 2 ++ 1 file changed, 2 insertions(+)
fs/cifs/smb2ops.c +2 -0
@@ -1123,6 +1123,8 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,COMPOUND_FID , current->tgid,FILE_FULL_EA_INFORMATION , SMB2_O_INFO_FILE, 0, data, size); +if (rc) + goto sea_exit;smb2_set_next_command (tcon, &rqst[1 ]);smb2_set_related (&rqst[1 ]);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 193/314 netdevsim: Fix memory leak of nsim_dev->fa_cookie
In reply to Greg Kroah-HartmanFrom: Wang Yufen <[email protected]>
[ Upstream commit 064bc7312bd09a48798418663090be0c776183db ]
kmemleak reports this issue:
unreferenced object 0xffff8881bac872d0 (size 8):
comm "sh", pid 58603, jiffies 4481524462 (age 68.065s) hex dump (first 8 bytes):
04 00 00 00 de ad be ef ........
backtrace:
[<00000000c80b8577>] __kmalloc+0x49/0x150
[<000000005292b8c6>] nsim_dev_trap_fa_cookie_write+0xc1/0x210 [netdevsim]
[<0000000093d78e77>] full_proxy_write+0xf3/0x180
[<000000005a662c16>] vfs_write+0x1c5/0xaf0
[<000000007aabf84a>] ksys_write+0xed/0x1c0
[<000000005f1d2e47>] do_syscall_64+0x3b/0x90
[<000000006001c6ec>] entry_SYSCALL_64_after_hwframe+0x63/0xcdThe issue occurs in the following scenarios:
nsim_dev_trap_fa_cookie_write()
kmalloc() fa_cookie
nsim_dev->fa_cookie = fa_cookie
..nsim_drv_remove()
The fa_cookie allocked in nsim_dev_trap_fa_cookie_write() is not freed. To fix, add kfree(nsim_dev->fa_cookie) to nsim_drv_remove().
--- drivers/net/netdevsim/dev.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/netdevsim/dev.c +1 -0
@@ -1675,6 +1675,7 @@ void nsim_drv_remove(struct nsim_bus_dev *nsim_bus_dev) ARRAY_SIZE(nsim_devlink_params));devl_resources_unregister (devlink);kfree (nsim_dev->vfconfigs); +kfree (nsim_dev->fa_cookie);devl_unlock (devlink);devlink_free (devlink);dev_set_drvdata (&nsim_bus_dev->dev,NULL );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 194/314 block: make dma_alignment a stacking queue_limit
In reply to Greg Kroah-HartmanFrom: Keith Busch <[email protected]>
[ Upstream commit c964d62f5cab7b43dd0534f22a96eab386c6ec5d ]
Device mappers had always been getting the default 511 dma mask, but the underlying device might have a larger alignment requirement. Since this value is used to determine alloweable direct-io alignment, this needs to be a stackable limit.
Stable-dep-of: 86e4d3e8d183 ("dm-crypt: provide dma_alignment limit in io_hints")
--- block/blk-core.c | 1 - block/blk-settings.c | 8 +++++--- include/linux/blkdev.h | 15 ++++++++------- 3 files changed, 13 insertions(+), 11 deletions(-)
block/blk-core.c +0 -1
@@ -426,7 +426,6 @@ struct request_queue *blk_alloc_queue(int node_id, bool alloc_srcu) PERCPU_REF_INIT_ATOMIC, GFP_KERNEL)) goto fail_stats; -blk_queue_dma_alignment (q,511 );blk_set_default_limits (&q->limits); q->nr_requests =BLKDEV_DEFAULT_RQ ;
block/blk-settings.c +5 -3
@@ -57,6 +57,7 @@ void blk_set_default_limits(struct queue_limits *lim) lim->misaligned =0 ; lim->zoned =BLK_ZONED_NONE ; lim->zone_write_granularity =0 ; + lim->dma_alignment =511 ; }EXPORT_SYMBOL (blk_set_default_limits);
@@ -600,6 +601,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->io_min =max (t->io_min, b->io_min); t->io_opt =lcm_not_zero (t->io_opt, b->io_opt); + t->dma_alignment =max (t->dma_alignment, b->dma_alignment);/* Set non-power-of-2 compatible chunk_sectors boundary */ if (b->chunk_sectors)
@@ -773,7 +775,7 @@ EXPORT_SYMBOL(blk_queue_virt_boundary);**/ void blk_queue_dma_alignment (struct request_queue *q,int mask) { - q->dma_alignment = mask; + q->limits.dma_alignment = mask; }EXPORT_SYMBOL (blk_queue_dma_alignment);
@@ -795,8 +797,8 @@ void blk_queue_update_dma_alignment(struct request_queue *q, int mask) {BUG_ON (mask >PAGE_SIZE ); -if (mask > q->dma_alignment) - q->dma_alignment = mask; +if (mask > q->limits.dma_alignment) + q->limits.dma_alignment = mask; }EXPORT_SYMBOL (blk_queue_update_dma_alignment);
include/linux/blkdev.h +8 -7
@@ -311,6 +311,13 @@ struct queue_limits {unsigned char discard_misaligned;unsigned char raid_partial_stripes_expensive;enum blk_zoned_model zoned; + +/* +* Drivers that set dma_alignment to less than 511 must be prepared to +* handle individual bvec's that are not a multiple of a SECTOR_SIZE +* due to possible offsets. +*/ +unsigned int dma_alignment; }; typedef int (*report_zones_cb)(struct blk_zone *zone, unsigned int idx,
@@ -456,12 +463,6 @@ struct request_queue {unsigned long nr_requests;/* Max # of requests */ unsigned int dma_pad_mask; -/* -* Drivers that set dma_alignment to less than 511 must be prepared to -* handle individual bvec's that are not a multiple of a SECTOR_SIZE -* due to possible offsets. -*/ -unsigned int dma_alignment;#ifdef CONFIG_BLK_INLINE_ENCRYPTION struct blk_crypto_profile *crypto_profile;
@@ -1311,7 +1312,7 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)static inline int queue_dma_alignment (const struct request_queue *q) { -return q ? q->dma_alignment :511 ; +return q ? q->limits.dma_alignment :511 ; }static inline unsigned int bdev_dma_alignment (struct block_device *bdev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 195/314 dm-crypt: provide dma_alignment limit in io_hints
In reply to Greg Kroah-HartmanFrom: Keith Busch <[email protected]>
[ Upstream commit 86e4d3e8d1838ca88fb9267e669c36f6c8f7c6cd ]
This device mapper needs bio vectors to be sized and memory aligned to the logical block size. Set the minimum required queue limit accordingly.
--- drivers/md/dm-crypt.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/dm-crypt.c +1 -0
@@ -3630,6 +3630,7 @@ static void crypt_io_hints(struct dm_target *ti, struct queue_limits *limits) limits->physical_block_size =max_t (unsigned, limits->physical_block_size, cc->sector_size); limits->io_min =max_t (unsigned, limits->io_min, cc->sector_size); + limits->dma_alignment = limits->logical_block_size -1 ; }static struct target_type crypt_target = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 196/314 ftrace: Fix the possible incorrect kernel message
In reply to Greg Kroah-HartmanFrom: Wang Wensheng <[email protected]>
commit 08948caebe93482db1adfd2154eba124f66d161d upstream.
If the number of mcount entries is an integer multiple of ENTRIES_PER_PAGE, the page count showing on the console would be wrong.
--- kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
@@ -7394,7 +7394,7 @@ void __init ftrace_init(void) }pr_info ("ftrace: allocating %ld entries in %ld pages\n" , - count, count /ENTRIES_PER_PAGE +1 ); + count,DIV_ROUND_UP (count,ENTRIES_PER_PAGE )); ret = ftrace_process_locs(NULL, __start_mcount_loc,
Greg Kroah-Hartman
maintainerPATCH 197/314 ftrace: Optimize the allocation for mcount entries
In reply to Greg Kroah-HartmanFrom: Wang Wensheng <[email protected]>
commit bcea02b096333dc74af987cb9685a4dbdd820840 upstream.
If we can't allocate this size, try something smaller with half of the size. Its order should be decreased by one instead of divided by two.
--- kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
@@ -3193,7 +3193,7 @@ static int ftrace_allocate_records(struc/* if we can't allocate this size, try something smaller */ if (!order)return -ENOMEM ; - order >>=1 ; + order--; goto again; }
Greg Kroah-Hartman
maintainerPATCH 198/314 ftrace: Fix null pointer dereference in ftrace_add_mod()
In reply to Greg Kroah-HartmanFrom: Xiu Jianfeng <[email protected]>
commit 19ba6c8af9382c4c05dc6a0a79af3013b9a35cd0 upstream.
The @ftrace_mod is allocated by kzalloc(), so both the members {prev,next} of @ftrace_mode->list are NULL, it's not a valid state to call list_del(). If kstrdup() for @ftrace_mod->{func|module} fails, it goes to @out_free tag and calls free_ftrace_mod() to destroy @ftrace_mod, then list_del() will write prev->next and next->prev, where null pointer dereference happens.
BUG: kernel NULL pointer dereference, address: 0000000000000008 Oops: 0002 [#1] PREEMPT SMP NOPTI Call Trace: <TASK> ftrace_mod_callback+0x20d/0x220 ? do_filp_open+0xd9/0x140 ftrace_process_regex.isra.51+0xbf/0x130 ftrace_regex_write.isra.52.part.53+0x6e/0x90 vfs_write+0xee/0x3a0 ? __audit_filter_op+0xb1/0x100 ? auditd_test_task+0x38/0x50 ksys_write+0xa5/0xe0 do_syscall_64+0x3a/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd Kernel panic - not syncing: Fatal exception
So call INIT_LIST_HEAD() to initialize the list member to fix this issue.
--- kernel/trace/ftrace.c | 1 + 1 file changed, 1 insertion(+)
kernel/trace/ftrace.c +1 -0
@@ -1289,6 +1289,7 @@ static int ftrace_add_mod(struct trace_aif (!ftrace_mod)return -ENOMEM ; +INIT_LIST_HEAD (&ftrace_mod->list); ftrace_mod->func =kstrdup (func,GFP_KERNEL ); ftrace_mod->module =kstrdup (module,GFP_KERNEL ); ftrace_mod->enable = enable;
Greg Kroah-Hartman
maintainerPATCH 199/314 ring_buffer: Do not deactivate non-existant pages
In reply to Greg Kroah-HartmanFrom: Daniil Tatianin <[email protected]>
commit 56f4ca0a79a9f1af98f26c54b9b89ba1f9bcc6bd upstream.
rb_head_page_deactivate() expects cpu_buffer to contain a valid list of ->pages, so verify that the list is actually present before calling it.
Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.
--- kernel/trace/ring_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/ring_buffer.c +2 -2
@@ -1769,9 +1769,9 @@ static void rb_free_cpu_buffer(struct rifree_buffer_page (cpu_buffer->reader_page); -rb_head_page_deactivate (cpu_buffer); -if (head) { +rb_head_page_deactivate (cpu_buffer); +list_for_each_entry_safe (bpage, tmp, head, list) {list_del_init (&bpage->list);free_buffer_page (bpage);
Greg Kroah-Hartman
maintainerPATCH 200/314 tracing: Fix memory leak in tracing_read_pipe()
In reply to Greg Kroah-HartmanFrom: Wang Yufen <[email protected]>
commit 649e72070cbbb8600eb823833e4748f5a0815116 upstream.
kmemleak reports this issue:
unreferenced object 0xffff888105a18900 (size 128):
comm "test_progs", pid 18933, jiffies 4336275356 (age 22801.766s) hex dump (first 32 bytes):
25 73 00 90 81 88 ff ff 26 05 00 00 42 01 58 04 %s......&...B.X.
03 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000560143a1>] __kmalloc_node_track_caller+0x4a/0x140
[<000000006af00822>] krealloc+0x8d/0xf0
[<00000000c309be6a>] trace_iter_expand_format+0x99/0x150
[<000000005a53bdb6>] trace_check_vprintf+0x1e0/0x11d0
[<0000000065629d9d>] trace_event_printf+0xb6/0xf0
[<000000009a690dc7>] trace_raw_output_bpf_trace_printk+0x89/0xc0
[<00000000d22db172>] print_trace_line+0x73c/0x1480
[<00000000cdba76ba>] tracing_read_pipe+0x45c/0x9f0
[<0000000015b58459>] vfs_read+0x17b/0x7c0
[<000000004aeee8ed>] ksys_read+0xed/0x1c0
[<0000000063d3d898>] do_syscall_64+0x3b/0x90
[<00000000a06dda7f>] entry_SYSCALL_64_after_hwframe+0x63/0xcditer->fmt alloced in
tracing_read_pipe() -> .. ->trace_iter_expand_format(), but not
freed, to fix, add free in tracing_release_pipe()
--- kernel/trace/trace.c | 1 + 1 file changed, 1 insertion(+)
kernel/trace/trace.c +1 -0
@@ -6657,6 +6657,7 @@ static int tracing_release_pipe(struct imutex_unlock (&trace_types_lock);free_cpumask_var (iter->started); +kfree (iter->fmt);mutex_destroy (&iter->mutex);kfree (iter);
Greg Kroah-Hartman
maintainerPATCH 201/314 tracing/ring-buffer: Have polling block on watermark
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
commit 42fb0a1e84ff525ebe560e2baf9451ab69127e2b upstream.
Currently the way polling works on the ring buffer is broken. It will return immediately if there's any data in the ring buffer whereas a read will block until the watermark (defined by the tracefs buffer_percent file) is hit.
That is, a select() or poll() will return as if there's data available, but then the following read will block. This is broken for the way select()s and poll()s are supposed to work.
Have the polling on the ring buffer also block the same way reads and splice does on the ring buffer.
--- include/linux/ring_buffer.h | 2 - kernel/trace/ring_buffer.c | 55 ++++++++++++++++++++++++++++---------------- kernel/trace/trace.c | 2 - 3 files changed, 38 insertions(+), 21 deletions(-)
include/linux/ring_buffer.h +1 -1
@@ -100,7 +100,7 @@ __ring_buffer_alloc(unsigned long size,int ring_buffer_wait (struct trace_buffer *buffer,int cpu,int full);__poll_t ring_buffer_poll_wait (struct trace_buffer *buffer,int cpu, -struct file *filp,poll_table *poll_table); +struct file *filp,poll_table *poll_table,int full);void ring_buffer_wake_waiters (struct trace_buffer *buffer,int cpu);#define RING_BUFFER_ALL_CPUS -1
kernel/trace/ring_buffer.c +36 -19
118 lines not on this page · raw message
kernel/trace/trace.c +1 -1
@@ -6682,7 +6682,7 @@ trace_poll(struct trace_iterator *iter,return EPOLLIN |EPOLLRDNORM ; else return ring_buffer_poll_wait(iter->array_buffer->buffer, iter->cpu_file, - filp, poll_table); + filp, poll_table, iter->tr->buffer_percent); } static __poll_t
Greg Kroah-Hartman
maintainerPATCH 202/314 tracing: Fix memory leak in test_gen_synth_cmd() and test_empty_synth_event()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
commit a4527fef9afe5c903c718d0cd24609fe9c754250 upstream.
test_gen_synth_cmd() only free buf in fail path, hence buf will leak when there is no failure. Add kfree(buf) to prevent the memleak. The same reason and solution in test_empty_synth_event().
unreferenced object 0xffff8881127de000 (size 2048):
comm "modprobe", pid 247, jiffies 4294972316 (age 78.756s) hex dump (first 32 bytes):
20 67 65 6e 5f 73 79 6e 74 68 5f 74 65 73 74 20 gen_synth_test
20 70 69 64 5f 74 20 6e 65 78 74 5f 70 69 64 5f pid_t next_pid_
backtrace:
[<000000004254801a>] kmalloc_trace+0x26/0x100
[<0000000039eb1cf5>] 0xffffffffa00083cd
[<000000000e8c3bc8>] 0xffffffffa00086ba
[<00000000c293d1ea>] do_one_initcall+0xdb/0x480
[<00000000aa189e6d>] do_init_module+0x1cf/0x680
[<00000000d513222b>] load_module+0x6a50/0x70a0
[<000000001fd4d529>] __do_sys_finit_module+0x12f/0x1c0
[<00000000b36c4c0f>] do_syscall_64+0x3f/0x90
[<00000000bbf20cf3>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
unreferenced object 0xffff8881127df000 (size 2048):
comm "modprobe", pid 247, jiffies 4294972324 (age 78.728s)
hex dump (first 32 bytes):
20 65 6d 70 74 79 5f 73 79 6e 74 68 5f 74 65 73 empty_synth_tes
74 20 20 70 69 64 5f 74 20 6e 65 78 74 5f 70 69 t pid_t next_pi
backtrace:
[<000000004254801a>] kmalloc_trace+0x26/0x100
[<00000000d4db9a3d>] 0xffffffffa0008071
[<00000000c31354a5>] 0xffffffffa00086ce
[<00000000c293d1ea>] do_one_initcall+0xdb/0x480
[<00000000aa189e6d>] do_init_module+0x1cf/0x680
[<00000000d513222b>] load_module+0x6a50/0x70a0
[<000000001fd4d529>] __do_sys_finit_module+0x12f/0x1c0
[<00000000b36c4c0f>] do_syscall_64+0x3f/0x90
[<00000000bbf20cf3>] entry_SYSCALL_64_after_hwframe+0x63/0xcd--- kernel/trace/synth_event_gen_test.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
kernel/trace/synth_event_gen_test.c +6 -10
@@ -120,15 +120,13 @@ static int __init test_gen_synth_cmd(voi/* Now generate a gen_synth_test event */ ret =synth_event_trace_array (gen_synth_test, vals,ARRAY_SIZE (vals)); - out: + free: +kfree (buf);return ret; delete:/* We got an error after creating the event, delete it */ synth_event_delete ("gen_synth_test" ); - free: -kfree (buf); - - goto out; + goto free; }/*
@@ -227,15 +225,13 @@ static int __init test_empty_synth_event/* Now trace an empty_synth_test event */ ret =synth_event_trace_array (empty_synth_test, vals,ARRAY_SIZE (vals)); - out: + free: +kfree (buf);return ret; delete:/* We got an error after creating the event, delete it */ synth_event_delete ("empty_synth_test" ); - free: -kfree (buf); - - goto out; + goto free; }static struct synth_field_desc create_synth_test_fields[] = {
Greg Kroah-Hartman
maintainerPATCH 203/314 tracing: Fix wild-memory-access in register_synth_event()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
commit 1b5f1c34d3f5a664a57a5a7557a50e4e3cc2505c upstream.
In register_synth_event(), if set_synth_event_print_fmt() failed, then both trace_remove_event_call() and unregister_trace_event() will be called, which means the trace_event_call will call __unregister_trace_event() twice. As the result, the second unregister will causes the wild-memory-access.
register_synth_event
set_synth_event_print_fmt failed
trace_remove_event_call
event_remove
if call->event.funcs then
__unregister_trace_event (first call)
unregister_trace_event
__unregister_trace_event (second call)
Fix the bug by avoiding to call the second __unregister_trace_event() by checking if the first one is called.
general protection fault, probably for non-canonical address 0xfbd59c0000000024: 0000 [#1] SMP KASAN PTI KASAN: maybe wild-memory-access in range [0xdead000000000120-0xdead000000000127] CPU: 0 PID: 3807 Comm: modprobe Not tainted 6.1.0-rc1-00186-g76f33a7eedb4 #299 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 RIP: 0010:unregister_trace_event+0x6e/0x280 Code: 00 fc ff df 4c 89 ea 48 c1 ea 03 80 3c 02 00 0f 85 0e 02 00 00 48 b8 00 00 00 00 00 fc ff df 4c 8b 63 08 4c 89 e2 48 c1 ea 03 <80> 3c 02 00 0f 85 e2 01 00 00 49 89 2c 24 48 85 ed 74 28 e8 7a 9b RSP: 0018:ffff88810413f370 EFLAGS: 00010a06 RAX: dffffc0000000000 RBX: ffff888105d050b0 RCX: 0000000000000000 RDX: 1bd5a00000000024 RSI: ffff888119e276e0 RDI: ffffffff835a8b20 RBP: dead000000000100 R08: 0000000000000000 R09: fffffbfff0913481 R10: ffffffff8489a407 R11: fffffbfff0913480 R12: dead000000000122 R13: ffff888105d050b8 R14: 0000000000000000 R15: ffff888105d05028 FS: 00007f7823e8d540(0000) GS:ffff888119e00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f7823e7ebec CR3: 000000010a058002 CR4: 0000000000330ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> __create_synth_event+0x1e37/0x1eb0 create_or_delete_synth_event+0x110/0x250 synth_event_run_command+0x2f/0x110 test_gen_synth_cmd+0x170/0x2eb [synth_event_gen_test] synth_event_gen_test_init+0x76/0x9bc [synth_event_gen_test] do_one_initcall+0xdb/0x480 do_init_module+0x1cf/0x680 load_module+0x6a50/0x70a0 __do_sys_finit_module+0x12f/0x1c0 do_syscall_64+0x3f/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd
--- kernel/trace/trace_events_synth.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/trace/trace_events_synth.c +2 -3
@@ -828,10 +828,9 @@ static int register_synth_event(struct s } ret =set_synth_event_print_fmt (call); -if (ret <0 ) { +/* unregister_trace_event() will be called inside */ +if (ret <0 )trace_remove_event_call (call); - goto err; - } out:return ret; err:
Greg Kroah-Hartman
maintainerPATCH 204/314 tracing: Fix race where eprobes can be called before the event
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
commit 94eedf3dded5fb472ce97bfaf3ac1c6c29c35d26 upstream.
The flag that tells the event to call its triggers after reading the event is set for eprobes after the eprobe is enabled. This leads to a race where the eprobe may be triggered at the beginning of the event where the record information is NULL. The eprobe then dereferences the NULL record causing a NULL kernel pointer bug.
Test for a NULL record to keep this from happening.
--- kernel/trace/trace_eprobe.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/trace/trace_eprobe.c +3 -0
@@ -560,6 +560,9 @@ static void eprobe_trigger_func(struct e {struct eprobe_data *edata = data->private_data; +if (unlikely (!rec)) +return ; +__eprobe_trace_func (edata, rec); }
Greg Kroah-Hartman
maintainerPATCH 205/314 tracing: kprobe: Fix potential null-ptr-deref on trace_event_file in kprobe_event_gen_test_exit()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
commit e0d75267f59d7084e0468bd68beeb1bf9c71d7c0 upstream.
When trace_get_event_file() failed, gen_kretprobe_test will be assigned as the error code. If module kprobe_event_gen_test is removed now, the null pointer dereference will happen in kprobe_event_gen_test_exit(). Check if gen_kprobe_test or gen_kretprobe_test is error code or NULL before dereference them.
BUG: kernel NULL pointer dereference, address: 0000000000000012 PGD 0 P4D 0 Oops: 0000 [#1] SMP PTI CPU: 3 PID: 2210 Comm: modprobe Not tainted 6.1.0-rc1-00171-g2159299a3b74-dirty #217 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 RIP: 0010:kprobe_event_gen_test_exit+0x1c/0xb5 [kprobe_event_gen_test] Code: Unable to access opcode bytes at 0xffffffff9ffffff2. RSP: 0018:ffffc900015bfeb8 EFLAGS: 00010246 RAX: ffffffffffffffea RBX: ffffffffa0002080 RCX: 0000000000000000 RDX: ffffffffa0001054 RSI: ffffffffa0001064 RDI: ffffffffdfc6349c RBP: ffffffffa0000000 R08: 0000000000000004 R09: 00000000001e95c0 R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000800 R13: ffffffffa0002420 R14: 0000000000000000 R15: 0000000000000000 FS: 00007f56b75be540(0000) GS:ffff88813bc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffff9ffffff2 CR3: 000000010874a006 CR4: 0000000000330ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> __x64_sys_delete_module+0x206/0x380 ? lockdep_hardirqs_on_prepare+0xd8/0x190 ? syscall_enter_from_user_mode+0x1c/0x50 do_syscall_64+0x3f/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd
--- kernel/trace/kprobe_event_gen_test.c | 44 ++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 16 deletions(-)
kernel/trace/kprobe_event_gen_test.c +28 -16
@@ -73,6 +73,10 @@ static struct trace_event_file *gen_kret#define KPROBE_GEN_TEST_ARG3 NULL#endif +static bool trace_event_file_is_valid (struct trace_event_file *input) +{ +return input && !IS_ERR (input); +}/* * Test to make sure we can create a kprobe event, then add more
@@ -217,10 +221,12 @@ static int __init kprobe_event_gen_test_ ret =test_gen_kretprobe_cmd ();if (ret) { -WARN_ON (trace_array_set_clr_event (gen_kretprobe_test->tr, -"kprobes" , -"gen_kretprobe_test" , false)); -trace_put_event_file (gen_kretprobe_test); +if (trace_event_file_is_valid (gen_kretprobe_test)) { +WARN_ON (trace_array_set_clr_event (gen_kretprobe_test->tr, +"kprobes" , +"gen_kretprobe_test" , false)); +trace_put_event_file (gen_kretprobe_test); + }WARN_ON (kprobe_event_delete ("gen_kretprobe_test" )); }
@@ -229,24 +235,30 @@ static int __init kprobe_event_gen_test_ static void __exit kprobe_event_gen_test_exit(void) { -/* Disable the event or you can't remove it */ -WARN_ON (trace_array_set_clr_event (gen_kprobe_test->tr, -"kprobes" , -"gen_kprobe_test" , false)); +if (trace_event_file_is_valid (gen_kprobe_test)) { +/* Disable the event or you can't remove it */ +WARN_ON (trace_array_set_clr_event (gen_kprobe_test->tr, +"kprobes" , +"gen_kprobe_test" , false)); + +/* Now give the file and instance back */ +trace_put_event_file (gen_kprobe_test); + } -/* Now give the file and instance back */ -trace_put_event_file (gen_kprobe_test);/* Now unregister and free the event */ WARN_ON (kprobe_event_delete ("gen_kprobe_test" )); -/* Disable the event or you can't remove it */ -WARN_ON (trace_array_set_clr_event (gen_kretprobe_test->tr, -"kprobes" , -"gen_kretprobe_test" , false)); +if (trace_event_file_is_valid (gen_kretprobe_test)) { +/* Disable the event or you can't remove it */ +WARN_ON (trace_array_set_clr_event (gen_kretprobe_test->tr, +"kprobes" , +"gen_kretprobe_test" , false)); + +/* Now give the file and instance back */ +trace_put_event_file (gen_kretprobe_test); + } -/* Now give the file and instance back */ -trace_put_event_file (gen_kretprobe_test);/* Now unregister and free the event */ WARN_ON (kprobe_event_delete ("gen_kretprobe_test" ));
Greg Kroah-Hartman
maintainerPATCH 206/314 tracing: kprobe: Fix potential null-ptr-deref on trace_array in kprobe_event_gen_test_exit()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
commit 22ea4ca9631eb137e64e5ab899e9c89cb6670959 upstream.
When test_gen_kprobe_cmd() failed after kprobe_event_gen_cmd_end(), it will goto delete, which will call kprobe_event_delete() and release the corresponding resource. However, the trace_array in gen_kretprobe_test will point to the invalid resource. Set gen_kretprobe_test to NULL after called kprobe_event_delete() to prevent null-ptr-deref.
BUG: kernel NULL pointer dereference, address: 0000000000000070 PGD 0 P4D 0 Oops: 0000 [#1] SMP PTI CPU: 0 PID: 246 Comm: modprobe Tainted: G W 6.1.0-rc1-00174-g9522dc5c87da-dirty #248 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 RIP: 0010:__ftrace_set_clr_event_nolock+0x53/0x1b0 Code: e8 82 26 fc ff 49 8b 1e c7 44 24 0c ea ff ff ff 49 39 de 0f 84 3c 01 00 00 c7 44 24 18 00 00 00 00 e8 61 26 fc ff 48 8b 6b 10 <44> 8b 65 70 4c 8b 6d 18 41 f7 c4 00 02 00 00 75 2f RSP: 0018:ffffc9000159fe00 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffff88810971d268 RCX: 0000000000000000 RDX: ffff8881080be600 RSI: ffffffff811b48ff RDI: ffff88810971d058 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000001 R10: ffffc9000159fe58 R11: 0000000000000001 R12: ffffffffa0001064 R13: ffffffffa000106c R14: ffff88810971d238 R15: 0000000000000000 FS: 00007f89eeff6540(0000) GS:ffff88813b600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000070 CR3: 000000010599e004 CR4: 0000000000330ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> __ftrace_set_clr_event+0x3e/0x60 trace_array_set_clr_event+0x35/0x50 ? 0xffffffffa0000000 kprobe_event_gen_test_exit+0xcd/0x10b [kprobe_event_gen_test] __x64_sys_delete_module+0x206/0x380 ? lockdep_hardirqs_on_prepare+0xd8/0x190 ? syscall_enter_from_user_mode+0x1c/0x50 do_syscall_64+0x3f/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f89eeb061b7
--- kernel/trace/kprobe_event_gen_test.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/trace/kprobe_event_gen_test.c +4 -0
@@ -143,6 +143,8 @@ static int __init test_gen_kprobe_cmd(vokfree (buf);return ret; delete: +if (trace_event_file_is_valid (gen_kprobe_test)) + gen_kprobe_test =NULL ;/* We got an error after creating the event, delete it */ ret =kprobe_event_delete ("gen_kprobe_test" ); goto out;
@@ -206,6 +208,8 @@ static int __init test_gen_kretprobe_cmdkfree (buf);return ret; delete: +if (trace_event_file_is_valid (gen_kretprobe_test)) + gen_kretprobe_test =NULL ;/* We got an error after creating the event, delete it */ ret =kprobe_event_delete ("gen_kretprobe_test" ); goto out;
Greg Kroah-Hartman
maintainerPATCH 207/314 rethook: fix a potential memleak in rethook_alloc()
In reply to Greg Kroah-HartmanFrom: Yi Yang <[email protected]>
commit 0a1ebe35cb3b7aa1f4b26b37e2a0b9ae68dc4ffb upstream.
In rethook_alloc(), the variable rh is not freed or passed out if handler is NULL, which could lead to a memleak, fix it.
--- kernel/trace/rethook.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/rethook.c +3 -1
@@ -83,8 +83,10 @@ struct rethook *rethook_alloc(void *data {struct rethook *rh =kzalloc (sizeof (struct rethook ),GFP_KERNEL ); -if (!rh || !handler) +if (!rh || !handler) { +kfree (rh);return NULL ; + } rh->data = data; rh->handler = handler;
Greg Kroah-Hartman
maintainerPATCH 208/314 platform/x86/amd: pmc: Remove more CONFIG_DEBUG_FS checks
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
commit a5b5fb0fc47ddc7d1ed6a0365197639a01bc1f3a upstream.
commit b37fe34c8309 ("platform/x86/amd: pmc: remove CONFIG_DEBUG_FS checks") removed most CONFIG_DEBUG_FS checks, but there were some left that were reported to cause compile test failures.
Remove the remaining checks, and also the unnecessary CONFIG_SUSPEND used in the same place.
--- drivers/platform/x86/amd/pmc.c | 2 -- 1 file changed, 2 deletions(-)
drivers/platform/x86/amd/pmc.c +0 -2
@@ -274,7 +274,6 @@ static const struct file_operations amd_ .release = amd_pmc_stb_debugfs_release_v2, }; -#if defined(CONFIG_SUSPEND ) || defined(CONFIG_DEBUG_FS )static int amd_pmc_setup_smu_logging (struct amd_pmc_dev *dev) {if (dev->cpu_id ==AMD_CPU_ID_PCO ) {
@@ -349,7 +348,6 @@ static int get_metrics_table(struct amd_memcpy_fromio (table, pdev->smu_virt_addr,sizeof (struct smu_metrics ));return 0 ; } -#endif /* CONFIG_SUSPEND || CONFIG_DEBUG_FS */ #ifdef CONFIG_SUSPEND static void amd_pmc_validate_deepest (struct amd_pmc_dev *pdev)
Greg Kroah-Hartman
maintainerPATCH 209/314 platform/x86/amd: pmc: Add new ACPI ID AMDI0009
In reply to Greg Kroah-HartmanFrom: Shyam Sundar S K <[email protected]>
commit 6412518f5cb953cbd84b6746db9741bfc92be40a upstream.
Add new a new ACPI ID AMDI0009 used by upcoming AMD platform to the pmc supported list of devices.
--- drivers/platform/x86/amd/pmc.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/x86/amd/pmc.c +1 -0
@@ -918,6 +918,7 @@ static const struct acpi_device_id amd_p {"AMDI0006", 0}, {"AMDI0007", 0}, {"AMDI0008", 0}, + {"AMDI0009", 0}, {"AMD0004", 0}, {"AMD0005", 0}, { }
Greg Kroah-Hartman
maintainerPATCH 210/314 drm/amd/pm: enable runpm support over BACO for SMU13.0.7
In reply to Greg Kroah-HartmanFrom: Evan Quan <[email protected]>
commit df7c013efc1a0da8861099802b2d6ab2aacaeb1b upstream.
Enable SMU13.0.7 runpm support.
--- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +28 -2
@@ -122,6 +122,7 @@ static struct cmn2asic_msg_mapping smu_v13_0_7_message_map[SMU_MSG_MAX_COUNT] =MSG_MAP (PrepareMp1ForUnload, PPSMC_MSG_PrepareMp1ForUnload,0 ),MSG_MAP (SetMGpuFanBoostLimitRpm, PPSMC_MSG_SetMGpuFanBoostLimitRpm,0 ),MSG_MAP (DFCstateControl, PPSMC_MSG_SetExternalClientDfCstateAllow,0 ), + MSG_MAP(ArmD3, PPSMC_MSG_ArmD3, 0), }; static struct cmn2asic_mapping smu_v13_0_7_clk_map[SMU_CLK_COUNT] = {
@@ -1578,6 +1579,31 @@ static int smu_v13_0_7_set_mp1_state(struct smu_context *smu,return ret; } +static int smu_v13_0_7_baco_enter (struct smu_context *smu) +{ +struct smu_baco_context *smu_baco = &smu->smu_baco; +struct amdgpu_device *adev = smu->adev; + +if (adev->in_runpm &&smu_cmn_is_audio_func_enabled (adev)) +return smu_v13_0_baco_set_armd3_sequence (smu, + smu_baco->maco_support ?BACO_SEQ_BAMACO :BACO_SEQ_BACO ); +else +return smu_v13_0_baco_enter (smu); +} + +static int smu_v13_0_7_baco_exit (struct smu_context *smu) +{ +struct amdgpu_device *adev = smu->adev; + +if (adev->in_runpm &&smu_cmn_is_audio_func_enabled (adev)) { +/* Wait for PMFW handling for the Dstate change */ +usleep_range (10000 ,11000 ); +return smu_v13_0_baco_set_armd3_sequence (smu,BACO_SEQ_ULPS ); + }else { +return smu_v13_0_baco_exit (smu); + } +} +static bool smu_v13_0_7_is_mode1_reset_supported (struct smu_context *smu) {struct amdgpu_device *adev = smu->adev;
@@ -1655,8 +1681,8 @@ static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { .baco_is_support = smu_v13_0_baco_is_support, .baco_get_state = smu_v13_0_baco_get_state, .baco_set_state = smu_v13_0_baco_set_state, - .baco_enter = smu_v13_0_baco_enter, - .baco_exit = smu_v13_0_baco_exit, + .baco_enter = smu_v13_0_7_baco_enter, + .baco_exit = smu_v13_0_7_baco_exit, .mode1_reset_is_support = smu_v13_0_7_is_mode1_reset_supported, .mode1_reset = smu_v13_0_mode1_reset, .set_mp1_state = smu_v13_0_7_set_mp1_state,
Signature · 1 line
2.38.1
Greg Kroah-Hartman
maintainerPATCH 211/314 drm/amd/pm: enable runpm support over BACO for SMU13.0.0
In reply to Greg Kroah-HartmanFrom: Evan Quan <[email protected]>
commit 8652da45d09abe1b3174dbb80dc5176b8c3fa08e upstream.
Enable SMU13.0.0 runpm support.
--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 8 +++++ drivers/gpu/drm/amd/pm/swsmu/inc/smu_v11_0.h | 10 ------ drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 11 +----- drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 - drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 9 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 30 +++++++++++++++++-- 6 files changed, 50 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +8 -0
@@ -1372,6 +1372,14 @@ enum smu_cmn2asic_mapping_type { CMN2ASIC_MAPPING_WORKLOAD, }; +enum smu_baco_seq { +BACO_SEQ_BACO =0 , +BACO_SEQ_MSR , +BACO_SEQ_BAMACO , +BACO_SEQ_ULPS , +BACO_SEQ_COUNT , +}; +#define MSG_MAP (msg, index, valid_in_vf) \ [SMU_MSG_##msg] = {1, (index), (valid_in_vf)}
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v11_0.h +1 -9
@@ -147,14 +147,6 @@ struct smu_11_5_power_context {uint32_t max_fast_ppt_limit; }; -enum smu_v11_0_baco_seq { -BACO_SEQ_BACO =0 , -BACO_SEQ_MSR , -BACO_SEQ_BAMACO , -BACO_SEQ_ULPS , -BACO_SEQ_COUNT , -}; -#if defined(SWSMU_CODE_LAYER_L2 ) || defined(SWSMU_CODE_LAYER_L3 )int smu_v11_0_init_microcode (struct smu_context *smu);
@@ -257,7 +249,7 @@ int smu_v11_0_baco_enter(struct smu_contint smu_v11_0_baco_exit (struct smu_context *smu);int smu_v11_0_baco_set_armd3_sequence (struct smu_context *smu, -enum smu_v11_0_baco_seq baco_seq); +enum smu_baco_seq baco_seq);int smu_v11_0_mode1_reset (struct smu_context *smu);
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +3 -8
@@ -123,14 +123,6 @@ struct smu_13_0_power_context {enum smu_13_0_power_state power_state; }; -enum smu_v13_0_baco_seq { -BACO_SEQ_BACO =0 , -BACO_SEQ_MSR , -BACO_SEQ_BAMACO , -BACO_SEQ_ULPS , -BACO_SEQ_COUNT , -}; -#if defined(SWSMU_CODE_LAYER_L2 ) || defined(SWSMU_CODE_LAYER_L3 )int smu_v13_0_init_microcode (struct smu_context *smu);
@@ -217,6 +209,9 @@ int smu_v13_0_set_azalia_d3_pme(struct sint smu_v13_0_get_max_sustainable_clocks_by_dc (struct smu_context *smu,struct pp_smu_nv_clock_table *max_clocks); +int smu_v13_0_baco_set_armd3_sequence (struct smu_context *smu, +enum smu_baco_seq baco_seq); +bool smu_v13_0_baco_is_support (struct smu_context *smu);enum smu_baco_state smu_v13_0_baco_get_state (struct smu_context *smu);
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +1 -1
@@ -1576,7 +1576,7 @@ int smu_v11_0_set_azalia_d3_pme(struct s }int smu_v11_0_baco_set_armd3_sequence (struct smu_context *smu, -enum smu_v11_0_baco_seq baco_seq) +enum smu_baco_seq baco_seq) {return smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_ArmD3, baco_seq,NULL ); }
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +9 -0
@@ -2219,6 +2219,15 @@ int smu_v13_0_gfx_ulv_control(struct smureturn ret; } +int smu_v13_0_baco_set_armd3_sequence (struct smu_context *smu, +enum smu_baco_seq baco_seq) +{ +return smu_cmn_send_smc_msg_with_param (smu, + SMU_MSG_ArmD3, + baco_seq, +NULL ); +} +bool smu_v13_0_baco_is_support (struct smu_context *smu) {struct smu_baco_context *smu_baco = &smu->smu_baco;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +28 -2
@@ -120,6 +120,7 @@ static struct cmn2asic_msg_mapping smu_vMSG_MAP (Mode1Reset, PPSMC_MSG_Mode1Reset,0 ),MSG_MAP (PrepareMp1ForUnload, PPSMC_MSG_PrepareMp1ForUnload,0 ),MSG_MAP (DFCstateControl, PPSMC_MSG_SetExternalClientDfCstateAllow,0 ), + MSG_MAP(ArmD3, PPSMC_MSG_ArmD3, 0), }; static struct cmn2asic_mapping smu_v13_0_0_clk_map[SMU_CLK_COUNT] = {
@@ -1566,6 +1567,31 @@ static int smu_v13_0_0_set_power_profile NULL); } +static int smu_v13_0_0_baco_enter (struct smu_context *smu) +{ +struct smu_baco_context *smu_baco = &smu->smu_baco; +struct amdgpu_device *adev = smu->adev; + +if (adev->in_runpm &&smu_cmn_is_audio_func_enabled (adev)) +return smu_v13_0_baco_set_armd3_sequence (smu, + smu_baco->maco_support ?BACO_SEQ_BAMACO :BACO_SEQ_BACO ); +else +return smu_v13_0_baco_enter (smu); +} + +static int smu_v13_0_0_baco_exit (struct smu_context *smu) +{ +struct amdgpu_device *adev = smu->adev; + +if (adev->in_runpm &&smu_cmn_is_audio_func_enabled (adev)) { +/* Wait for PMFW handling for the Dstate change */ +usleep_range (10000 ,11000 ); +return smu_v13_0_baco_set_armd3_sequence (smu,BACO_SEQ_ULPS ); + }else { +return smu_v13_0_baco_exit (smu); + } +} +static bool smu_v13_0_0_is_mode1_reset_supported (struct smu_context *smu) {struct amdgpu_device *adev = smu->adev;
@@ -1827,8 +1853,8 @@ static const struct pptable_funcs smu_v1 .baco_is_support = smu_v13_0_baco_is_support, .baco_get_state = smu_v13_0_baco_get_state, .baco_set_state = smu_v13_0_baco_set_state, - .baco_enter = smu_v13_0_baco_enter, - .baco_exit = smu_v13_0_baco_exit, + .baco_enter = smu_v13_0_0_baco_enter, + .baco_exit = smu_v13_0_0_baco_exit, .mode1_reset_is_support = smu_v13_0_0_is_mode1_reset_supported, .mode1_reset = smu_v13_0_mode1_reset, .set_mp1_state = smu_v13_0_0_set_mp1_state,
Greg Kroah-Hartman
maintainerPATCH 212/314 drm/amd/pm: fix SMU13 runpm hang due to unintentional workaround
In reply to Greg Kroah-HartmanFrom: Evan Quan <[email protected]>
commit 4b14841c9a820e484bc8c4c3f5a6fed1bc528cbc upstream.
The workaround designed for some specific ASICs is wrongly applied to SMU13 ASICs. That leads to some runpm hang.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +11 -12
@@ -1131,22 +1131,21 @@ static int smu_smc_hw_setup(struct smu_cuint64_t features_supported;int ret =0 ; -if (adev->in_suspend &&smu_is_dpm_running (smu)) { -dev_info (adev->dev,"dpm has been enabled\n" ); -/* this is needed specifically */ -switch (adev->ip_versions[MP1_HWIP ][0 ]) { -case IP_VERSION (11 ,0 ,7 ): -case IP_VERSION (11 ,0 ,11 ): -case IP_VERSION (11 ,5 ,0 ): -case IP_VERSION (11 ,0 ,12 ): +switch (adev->ip_versions[MP1_HWIP ][0 ]) { +case IP_VERSION (11 ,0 ,7 ): +case IP_VERSION (11 ,0 ,11 ): +case IP_VERSION (11 ,5 ,0 ): +case IP_VERSION (11 ,0 ,12 ): +if (adev->in_suspend &&smu_is_dpm_running (smu)) { +dev_info (adev->dev,"dpm has been enabled\n" ); ret =smu_system_features_control (smu, true);if (ret)dev_err (adev->dev,"Failed system features control!\n" ); -break ; -default : -break ; +return ret; } -return ret; +break ; +default : +break ; } ret =smu_init_display_count (smu,0 );
Greg Kroah-Hartman
maintainerPATCH 213/314 drm/display: Dont assume dual mode adaptors support i2c sub-addressing
In reply to Greg Kroah-HartmanFrom: Simon Rettberg <[email protected]>
commit 5954acbacbd1946b96ce8ee799d309cb0cd3cb9d upstream.
Current dual mode adaptor ("DP++") detection code assumes that all adaptors support i2c sub-addressing for read operations from the DP-HDMI adaptor ID buffer. It has been observed that multiple adaptors do not in fact support this, and always return data starting at register 0. On affected adaptors, the code fails to read the proper registers that would identify the device as a type 2 adaptor, and handles those as type 1, limiting the TMDS clock to 165MHz, even if the according register would announce a higher TMDS clock. Fix this by always reading the ID buffer starting from offset 0, and discarding any bytes before the actual offset of interest.
We tried finding authoritative documentation on whether or not this is allowed behaviour, but since all the official VESA docs are paywalled, the best we could come up with was the spec sheet for Texas Instruments' SNx5DP149 chip family.[1] It explicitly mentions that sub-addressing is supported for register writes, but *not* for reads (See NOTE in section 8.5.3). Unless TI openly decided to violate the VESA spec, one could take that as a hint that sub-addressing is in fact not mandated by VESA.
The other two adaptors affected used the PS8409(A) and the LT8611, according to the data returned from their ID buffers.
[1] https://www.ti.com/lit/ds/symlink/sn75dp149.pdf
--- drivers/gpu/drm/display/drm_dp_dual_mode_helper.c | 51 ++++++++++++---------- 1 file changed, 29 insertions(+), 22 deletions(-)
drivers/gpu/drm/display/drm_dp_dual_mode_helper.c +29 -22
@@ -63,23 +63,45 @@ssize_t drm_dp_dual_mode_read (struct i2c_adapter *adapter,u8 offset,void *buffer,size_t size) { +u8 zero =0 ; +char *tmpbuf =NULL ; +/* +* As sub-addressing is not supported by all adaptors, +* always explicitly read from the start and discard +* any bytes that come before the requested offset. +* This way, no matter whether the adaptor supports it +* or not, we'll end up reading the proper data. +*/ struct i2c_msg msgs[] = { { .addr =DP_DUAL_MODE_SLAVE_ADDRESS , .flags =0 , .len =1 , - .buf = &offset, + .buf = &zero, }, { .addr =DP_DUAL_MODE_SLAVE_ADDRESS , .flags =I2C_M_RD , - .len = size, + .len = size + offset, .buf = buffer, }, };int ret; +if (offset) { + tmpbuf =kmalloc (size + offset,GFP_KERNEL ); +if (!tmpbuf) +return -ENOMEM ; + + msgs[1 ].buf = tmpbuf; + } + ret =i2c_transfer (adapter, msgs,ARRAY_SIZE (msgs)); +if (tmpbuf) +memcpy (buffer, tmpbuf + offset, size); + +kfree (tmpbuf); +if (ret <0 )return ret;if (ret !=ARRAY_SIZE (msgs))
@@ -208,18 +230,6 @@ enum drm_dp_dual_mode_type drm_dp_dual_mif (ret)return DRM_DP_DUAL_MODE_UNKNOWN ; -/* -* Sigh. Some (maybe all?) type 1 adaptors are broken and ack -* the offset but ignore it, and instead they just always return -* data from the start of the HDMI ID buffer. So for a broken -* type 1 HDMI adaptor a single byte read will always give us -* 0x44, and for a type 1 DVI adaptor it should give 0x00 -* (assuming it implements any registers). Fortunately neither -* of those values will match the type 2 signature of the -* DP_DUAL_MODE_ADAPTOR_ID register so we can proceed with -* the type 2 adaptor detection safely even in the presence -* of broken type 1 adaptors. -*/ ret =drm_dp_dual_mode_read (adapter,DP_DUAL_MODE_ADAPTOR_ID , &adaptor_id,sizeof (adaptor_id));drm_dbg_kms (dev,"DP dual mode adaptor ID: %02x (err %zd)\n" , adaptor_id, ret);
@@ -233,11 +243,10 @@ enum drm_dp_dual_mode_type drm_dp_dual_mreturn DRM_DP_DUAL_MODE_TYPE2_DVI ; }/* -* If neither a proper type 1 ID nor a broken type 1 adaptor -* as described above, assume type 1, but let the user know -* that we may have misdetected the type. +* If not a proper type 1 ID, still assume type 1, but let +* the user know that we may have misdetected the type. */ -if (!is_type1_adaptor (adaptor_id) && adaptor_id != hdmi_id[0 ]) +if (!is_type1_adaptor (adaptor_id))drm_err (dev,"Unexpected DP dual mode adaptor ID %02x\n" , adaptor_id); }
@@ -343,10 +352,8 @@ EXPORT_SYMBOL(drm_dp_dual_mode_get_tmds_* @enable: enable (as opposed to disable) the TMDS output buffers * * Set the state of the TMDS output buffers in the adaptor. For -* type2 this is set via the DP_DUAL_MODE_TMDS_OEN register. As -* some type 1 adaptors have problems with registers (see comments -* in drm_dp_dual_mode_detect()) we avoid touching the register, -* making this function a no-op on type 1 adaptors. +* type2 this is set via the DP_DUAL_MODE_TMDS_OEN register. +* Type1 adaptors do not support any register writes. * * Returns: * 0 on success, negative error code on failure
Greg Kroah-Hartman
maintainerPATCH 214/314 drm/amd/display: Fix invalid DPIA AUX reply causing system hang
In reply to Greg Kroah-HartmanFrom: Stylon Wang <[email protected]>
commit 8d8494c3467d366eb0f7c8198dab80be8bdc47d2 upstream.
[Why]
Some DPIA AUX replies have incorrect data length from original request. This could lead to overwriting of destination buffer if reply length is larger, which could cause invalid access to stack since many destination buffers are declared as local variables.
[How]
Check for invalid length from DPIA AUX replies and trigger a retry if reply length is not the same as original request. A DRM_WARN() dmesg log is also produced.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 20 ++++++++++++++++++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 6 ------ 2 files changed, 20 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +20 -0
@@ -146,6 +146,14 @@ MODULE_FIRMWARE(FIRMWARE_NAVI12_DMCU);/* Number of bytes in PSP footer for firmware. */ #define PSP_FOOTER_BYTES 0x100 +/* +* DMUB Async to Sync Mechanism Status +*/ +#define DMUB_ASYNC_TO_SYNC_ACCESS_FAIL 1 +#define DMUB_ASYNC_TO_SYNC_ACCESS_TIMEOUT 2 +#define DMUB_ASYNC_TO_SYNC_ACCESS_SUCCESS 3 +#define DMUB_ASYNC_TO_SYNC_ACCESS_INVALID 4 +/** * DOC: overview *
@@ -10149,6 +10157,8 @@ static int amdgpu_dm_set_dmub_async_sync *operation_result =AUX_RET_ERROR_TIMEOUT ; }else if (status_type ==DMUB_ASYNC_TO_SYNC_ACCESS_FAIL ) { *operation_result =AUX_RET_ERROR_ENGINE_ACQUIRE ; + }else if (status_type ==DMUB_ASYNC_TO_SYNC_ACCESS_INVALID ) { + *operation_result =AUX_RET_ERROR_INVALID_REPLY ; }else { *operation_result =AUX_RET_ERROR_UNKNOWN ; }
@@ -10196,6 +10206,16 @@ int amdgpu_dm_process_dmub_aux_transfer_ payload->reply[0 ] = adev->dm.dmub_notify->aux_reply.command;if (!payload->write && adev->dm.dmub_notify->aux_reply.length && payload->reply[0 ] ==AUX_TRANSACTION_REPLY_AUX_ACK ) { + +if (payload->length != adev->dm.dmub_notify->aux_reply.length) { +DRM_WARN ("invalid read from DPIA AUX %x(%d) got length %d!\n" , + payload->address, payload->length, + adev->dm.dmub_notify->aux_reply.length); +return amdgpu_dm_set_dmub_async_sync_status (is_cmd_aux, ctx, +DMUB_ASYNC_TO_SYNC_ACCESS_INVALID , + (uint32_t *)operation_result); + } +memcpy (payload->data, adev->dm.dmub_notify->aux_reply.data, adev->dm.dmub_notify->aux_reply.length); }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +0 -6
@@ -51,12 +51,6 @@#define AMDGPU_DMUB_NOTIFICATION_MAX 5/* -* DMUB Async to Sync Mechanism Status -*/ -#define DMUB_ASYNC_TO_SYNC_ACCESS_FAIL 1 -#define DMUB_ASYNC_TO_SYNC_ACCESS_TIMEOUT 2 -#define DMUB_ASYNC_TO_SYNC_ACCESS_SUCCESS 3 -/* #include "include/amdgpu_dal_power_if.h" #include "amdgpu_dm_irq.h" */
Greg Kroah-Hartman
maintainerPATCH 215/314 drm/amd/display: Add HUBP surface flip interrupt handler
In reply to Greg Kroah-HartmanFrom: Rodrigo Siqueira <[email protected]>
commit 7af87fc1ba136143314c870059b8f60180247cbd upstream.
On IGT, there is a test named amd_hotplug, and when the subtest basic is executed on DCN31, we get the following error:
[drm] *ERROR* [CRTC:71:crtc-0] flip_done timed out [drm] *ERROR* flip_done timed out
[drm] *ERROR* [CRTC:71:crtc-0] commit wait timed out [drm] *ERROR* flip_done timed out
[drm] *ERROR* [CONNECTOR:88:DP-1] commit wait timed out [drm] *ERROR* flip_done timed out
[drm] *ERROR* [PLANE:59:plane-3] commit wait timed out
After enable the page flip log with the below command:
echo -n 'format "[PFLIP]" +p' > /sys/kernel/debug/dynamic_debug/control
It is possible to see that the flip was submitted, but DC never replied back, which generates time-out issues. This is an indication that the HUBP surface flip is missing. This commit fixes this issue by adding hubp1_set_flip_int to DCN31.
--- drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hubp.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hubp.c +1 -0
@@ -87,6 +87,7 @@ static struct hubp_funcs dcn31_hubp_func .hubp_init = hubp3_init, .set_unbounded_requesting = hubp31_set_unbounded_requesting, .hubp_soft_reset = hubp31_soft_reset, + .hubp_set_flip_int = hubp1_set_flip_int, .hubp_in_blank = hubp1_in_blank, .program_extended_blank = hubp31_program_extended_blank, };
Greg Kroah-Hartman
maintainerPATCH 216/314 drm/amd/display: Fix access timeout to DPIA AUX at boot time
In reply to Greg Kroah-HartmanFrom: Stylon Wang <[email protected]>
commit 0d502ef8898b3983eef9e40f50dfe100a0de5d93 upstream.
[Why]
Since introduction of patch "Query DPIA HPD status.", link detection at boot could be accessing DPIA AUX, which will not succeed until DMUB outbox messaging is enabled and results in below dmesg logs:
[ 160.840227] [drm:amdgpu_dm_process_dmub_aux_transfer_sync [amdgpu]] *ERROR* wait_for_completion_timeout timeout!
[How]
Enable DMUB outbox messaging before link detection at boot time.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +6 -6
@@ -1645,12 +1645,6 @@ static int amdgpu_dm_init(struct amdgpu_ } } -if (amdgpu_dm_initialize_drm_device (adev)) { -DRM_ERROR ( -"amdgpu: failed to initialize sw for display support.\n" ); - goto error; - } -/* Enable outbox notification only after IRQ handlers are registered and DMUB is alive. * It is expected that DMUB will resend any pending notifications at this point, for * example HPD from DPIA.
@@ -1658,6 +1652,12 @@ static int amdgpu_dm_init(struct amdgpu_if (dc_is_dmub_outbox_supported (adev->dm.dc))dc_enable_dmub_outbox (adev->dm.dc); +if (amdgpu_dm_initialize_drm_device (adev)) { +DRM_ERROR ( +"amdgpu: failed to initialize sw for display support.\n" ); + goto error; + } +/* create fake encoders for MST */ dm_dp_create_fake_mst_encoders (adev);
Greg Kroah-Hartman
maintainerPATCH 217/314 drm/amd/display: Support parsing VRAM info v3.0 from VBIOS
In reply to Greg Kroah-HartmanFrom: George Shen <[email protected]>
commit 7e952a18eb978a3e51fc1704b752378be66226b2 upstream.
[Why]
For DCN3.2 and DCN3.21, VBIOS has switch to using v3.0 of the VRAM info struct. We should read and override the VRAM info in driver with values provided by VBIOS to support memory downbin cases.
--- drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +30 -0
@@ -2392,6 +2392,26 @@ static enum bp_result get_vram_info_v25(return result; } +static enum bp_result get_vram_info_v30 ( +struct bios_parser *bp, +struct dc_vram_info *info) +{ +struct atom_vram_info_header_v3_0 *info_v30; +enum bp_result result =BP_RESULT_OK ; + + info_v30 = GET_IMAGE(struct atom_vram_info_header_v3_0, +DATA_TABLES (vram_info)); + +if (info_v30 ==NULL ) +return BP_RESULT_BADBIOSTABLE ; + + info->num_chans = info_v30->channel_num; + info->dram_channel_width_bytes = (1 << info_v30->channel_width) /8 ; + +return result; +} + +/* * get_integrated_info_v11 *
@@ -3022,6 +3042,16 @@ static enum bp_result bios_parser_get_vrbreak ;default :break ; + } +break ; + +case 3 : +switch (revision.minor) { +case 0 : + result =get_vram_info_v30 (bp, info); +break ; +default : +break ; }break ;
Greg Kroah-Hartman
maintainerPATCH 218/314 drm/amd/display: Fix optc2_configure warning on dcn314
In reply to Greg Kroah-HartmanFrom: Roman Li <[email protected]>
commit e7e4f77c991c9abf90924929a9d55f90b0bb78de upstream.
[Why]
dcn314 uses optc2_configure_crc() that wraps optc1_configure_crc() + set additional registers not applicable to dcn314.
It's not critical but when used leads to warning like:
WARNING: drivers/gpu/drm/amd/amdgpu/../display/dc/dc_helper.c
Call Trace: <TASK> generic_reg_set_ex+0x6d/0xe0 [amdgpu] optc2_configure_crc+0x60/0x80 [amdgpu] dc_stream_configure_crc+0x129/0x150 [amdgpu] amdgpu_dm_crtc_configure_crc_source+0x5d/0xe0 [amdgpu]
[How]
Use optc1_configure_crc() directly
--- drivers/gpu/drm/amd/display/dc/dcn314/dcn314_optc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_optc.c +1 -1
@@ -237,7 +237,7 @@ static struct timing_generator_funcs dcn .clear_optc_underflow = optc1_clear_optc_underflow, .setup_global_swap_lock = NULL, .get_crc = optc1_get_crc, - .configure_crc = optc2_configure_crc, + .configure_crc = optc1_configure_crc, .set_dsc_config = optc3_set_dsc_config, .get_dsc_status = optc2_get_dsc_status, .set_dwb_source = NULL,
Greg Kroah-Hartman
maintainerPATCH 219/314 drm/amd/display: dont enable DRM CRTC degamma property for DCE
In reply to Greg Kroah-HartmanFrom: Melissa Wen <[email protected]>
commit 0e444a4de6b38c4593a07e4cfb5bf54c40cc79b6 upstream.
DM maps DRM CRTC degamma to DPP (pre-blending) degamma block, but DCE doesn't support programmable degamma curve anywhere. Currently, a custom degamma is accepted by DM but just ignored by DCE driver and degamma correction isn't actually applied. There is no way to map custom degamma in DCE, therefore, DRM CRTC degamma property shouldn't be enabled for DCE drivers.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c +8 -2
@@ -412,7 +412,7 @@ int amdgpu_dm_crtc_init(struct amdgpu_di {struct amdgpu_crtc *acrtc =NULL ;struct drm_plane *cursor_plane; - +bool is_dcn;int res = -ENOMEM ; cursor_plane =kzalloc (sizeof (*cursor_plane),GFP_KERNEL );
@@ -450,8 +450,14 @@ int amdgpu_dm_crtc_init(struct amdgpu_di acrtc->otg_inst =-1 ; dm->adev->mode_info.crtcs[crtc_index] = acrtc; -drm_crtc_enable_color_mgmt (&acrtc->base,MAX_COLOR_LUT_ENTRIES , + +/* Don't enable DRM CRTC degamma property for DCE since it doesn't +* support programmable degamma anywhere. +*/ + is_dcn = dm->adev->dm.dc->caps.color.dpp.dcn_arch; +drm_crtc_enable_color_mgmt (&acrtc->base, is_dcn ?MAX_COLOR_LUT_ENTRIES :0 , true,MAX_COLOR_LUT_ENTRIES ); +drm_mode_crtc_set_gamma_size (&acrtc->base,MAX_COLOR_LEGACY_LUT_ENTRIES );return 0 ;
Greg Kroah-Hartman
maintainerPATCH 220/314 drm/amd/display: Fix prefetch calculations for dcn32
In reply to Greg Kroah-HartmanFrom: Dillon Varone <[email protected]>
commit 246e667079e8d0fc85f842bceca8c5a3c5da5905 upstream.
[Description]
Prefetch calculation loop was not exiting until utilizing all of vstartup if it failed once. Locals need to be reset on each iteration of the loop.
--- drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c +2 -0
@@ -718,6 +718,8 @@ static void DISPCLKDPPCLKDCFCLKDeepSleep do { MaxTotalRDBandwidth = 0; + DestinationLineTimesForPrefetchLessThan2 = false; + VRatioPrefetchMoreThanMax = false; #ifdef __DML_VBA_DEBUG__ dml_print("DML::%s: Start loop: VStartup = %d\n", __func__, mode_lib->vba.VStartupLines); #endif
Greg Kroah-Hartman
maintainerPATCH 221/314 ALSA: usb-audio: Drop snd_BUG_ON() from snd_usbmidi_output_open()
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit ad72c3c3f6eb81d2cb189ec71e888316adada5df upstream.
snd_usbmidi_output_open() has a check of the NULL port with snd_BUG_ON(). snd_BUG_ON() was used as this shouldn't have happened, but in reality, the NULL port may be seen when the device gives an invalid endpoint setup at the descriptor, hence the driver skips the allocation. That is, the check itself is valid and snd_BUG_ON() should be dropped from there. Otherwise it's confusing as if it were a real bug, as recently syzbot stumbled on it.
--- sound/usb/midi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
sound/usb/midi.c +1 -3
@@ -1133,10 +1133,8 @@ static int snd_usbmidi_output_open(struc port = &umidi->endpoints[i].out->ports[j];break ; } -if (!port) { -snd_BUG (); +if (!port)return -ENXIO ; - } substream->runtime->private_data = port; port->state =STATE_UNKNOWN ;
Greg Kroah-Hartman
maintainerPATCH 222/314 ALSA: hda/realtek: fix speakers for Samsung Galaxy Book Pro
In reply to Greg Kroah-HartmanFrom: Emil Flink <[email protected]>
commit b18a456330e1c1ca207b57b45872f10336741388 upstream.
The Samsung Galaxy Book Pro seems to have the same issue as a few other Samsung laptops, detailed in kernel bug report 207423. Sound from headphone jack works, but not the built-in speakers.
alsa-info: http://alsa-project.org/db/?f=b40ba609dc6ae28dc84ad404a0d8a4bbcd8bea6d
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9446,6 +9446,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x144d ,0xc176 ,"Samsung Notebook 9 Pro (NP930MBE-K04US)" ,ALC298_FIXUP_SAMSUNG_AMP ),SND_PCI_QUIRK (0x144d ,0xc189 ,"Samsung Galaxy Flex Book (NT950QCG-X716)" ,ALC298_FIXUP_SAMSUNG_AMP ),SND_PCI_QUIRK (0x144d ,0xc18a ,"Samsung Galaxy Book Ion (NP930XCJ-K01US)" ,ALC298_FIXUP_SAMSUNG_AMP ), +SND_PCI_QUIRK (0x144d ,0xc1a3 ,"Samsung Galaxy Book Pro (NP935XDB-KC1SE)" ,ALC298_FIXUP_SAMSUNG_AMP ),SND_PCI_QUIRK (0x144d ,0xc740 ,"Samsung Ativ book 8 (NP870Z5G)" ,ALC269_FIXUP_ATIV_BOOK_8 ),SND_PCI_QUIRK (0x144d ,0xc812 ,"Samsung Notebook Pen S (NT950SBE-X58)" ,ALC298_FIXUP_SAMSUNG_AMP ), SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_AMP),
Greg Kroah-Hartman
maintainerPATCH 223/314 ALSA: hda/realtek: Fix the speaker output on Samsung Galaxy Book Pro 360
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 1abfd71ee8f3ed99c5d0df5d9843a360541d6808 upstream.
Samsung Galaxy Book Pro 360 (13" 2021 NP930QBD-ke1US) with codec SSID 144d:c1a6 requires the same workaround for enabling the speaker amp like other Samsung models with ALC298 codec.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9447,6 +9447,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x144d ,0xc189 ,"Samsung Galaxy Flex Book (NT950QCG-X716)" ,ALC298_FIXUP_SAMSUNG_AMP ),SND_PCI_QUIRK (0x144d ,0xc18a ,"Samsung Galaxy Book Ion (NP930XCJ-K01US)" ,ALC298_FIXUP_SAMSUNG_AMP ),SND_PCI_QUIRK (0x144d ,0xc1a3 ,"Samsung Galaxy Book Pro (NP935XDB-KC1SE)" ,ALC298_FIXUP_SAMSUNG_AMP ), +SND_PCI_QUIRK (0x144d ,0xc1a6 ,"Samsung Galaxy Book Pro 360 (NP930QBD)" ,ALC298_FIXUP_SAMSUNG_AMP ),SND_PCI_QUIRK (0x144d ,0xc740 ,"Samsung Ativ book 8 (NP870Z5G)" ,ALC269_FIXUP_ATIV_BOOK_8 ),SND_PCI_QUIRK (0x144d ,0xc812 ,"Samsung Notebook Pen S (NT950SBE-X58)" ,ALC298_FIXUP_SAMSUNG_AMP ), SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_AMP),
Greg Kroah-Hartman
maintainerPATCH 224/314 Revert "usb: dwc3: disable USB core PHY management"
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 5c294de36e7fb3e0cba0c4e1ef9a5f57bc080d0f upstream.
This reverts commit 6000b8d900cd5f52fbcd0776d0cc396e88c8c2ea.
The offending commit disabled the USB core PHY management as the dwc3 already manages the PHYs in question.
Unfortunately some platforms have started relying on having USB core also controlling the PHY and this is specifically currently needed on some Exynos platforms for PHY calibration or connected device may fail to enumerate.
The PHY calibration was previously handled in the dwc3 driver, but to work around some issues related to how the dwc3 driver interacts with xhci (e.g. using multiple drivers) this was moved to USB core by commits 34c7ed72f4f0 ("usb: core: phy: add support for PHY calibration") and a0a465569b45 ("usb: dwc3: remove generic PHY calibrate() calls").
The same PHY obviously should not be controlled from two different places, which for example do no agree on the PHY mode or power state during suspend, but as the offending patch was backported to stable, let's revert it for now.
--- drivers/usb/dwc3/host.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/usb/dwc3/host.c +0 -10
@@ -11,13 +11,8 @@#include <linux/of.h> #include <linux/platform_device.h> -#include "../host/xhci-plat.h" #include "core.h" -static const struct xhci_plat_priv dwc3_xhci_plat_priv = { - .quirks =XHCI_SKIP_PHY_INIT , -}; -static void dwc3_host_fill_xhci_irq_res (struct dwc3 *dwc,int irq,char *name) {
@@ -97,11 +92,6 @@ int dwc3_host_init(struct dwc3 *dwc) goto err; } - ret =platform_device_add_data (xhci, &dwc3_xhci_plat_priv, -sizeof (dwc3_xhci_plat_priv)); -if (ret) - goto err; -memset (props,0 ,sizeof (struct property_entry ) *ARRAY_SIZE (props));if (dwc->usb3_lpm_capable)
Greg Kroah-Hartman
maintainerPATCH 225/314 usb: dwc3: Do not get extcon device when usb-role-switch is used
In reply to Greg Kroah-HartmanFrom: Janne Grunau <[email protected]>
commit d68cc25b7c7fb3034c5a5b5f350a0b858c6d5a45 upstream.
The change breaks device tree based platforms with PHY device and use usb-role-switch instead of an extcon switch. extcon_find_edev_by_node() will return EPROBE_DEFER if it can not find a device so probing without an extcon device will be deferred indefinitely. Fix this by explicitly checking for usb-role-switch.
At least the out-of-tree USB3 support on Apple silicon based platforms using dwc3 with tipd USB Type-C and PD controller is affected by this issue.
--- drivers/usb/dwc3/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/usb/dwc3/core.c +10 -0
@@ -1711,6 +1711,16 @@ static struct extcon_dev *dwc3_get_extcoreturn extcon_get_extcon_dev (name);/* +* Check explicitly if "usb-role-switch" is used since +* extcon_find_edev_by_node() can not be used to check the absence of +* an extcon device. In the absence of an device it will always return +* EPROBE_DEFER. +*/ +if (IS_ENABLED (CONFIG_USB_ROLE_SWITCH ) && +device_property_read_bool (dev,"usb-role-switch" )) +return NULL ; + +/* * Try to get an extcon device from the USB PHY controller's "port" * node. Check if it has the "port" node first, to avoid printing the * error message from underlying code, as it's a valid case: extcon
Greg Kroah-Hartman
maintainerPATCH 226/314 io_uring: update res mask in io_poll_check_events
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
commit b98186aee22fa593bc8c6b2c5d839c2ee518bc8c upstream.
When io_poll_check_events() collides with someone attempting to queue a task work, it'll spin for one more time. However, it'll continue to use the mask from the first iteration instead of updating it. For example, if the first wake up was a EPOLLIN and the second EPOLLOUT, the userspace will not get EPOLLOUT in time.
Clear the mask for all subsequent iterations to force vfs_poll().
--- io_uring/poll.c | 3 +++ 1 file changed, 3 insertions(+)
io_uring/poll.c +3 -0
@@ -256,6 +256,9 @@ static int io_poll_check_events(struct ireturn ret; } +/* force the next iteration to vfs_poll() */ + req->cqe.res =0 ; +/* * Release all references, retry if someone tried to restart * task_work while we were executing it.
Greg Kroah-Hartman
maintainerPATCH 227/314 nvme-pci: add NVME_QUIRK_BOGUS_NID for Micron Nitro
In reply to Greg Kroah-HartmanFrom: Bean Huo <[email protected]>
commit d5ceb4d1c50786d21de3d4b06c3f43109ec56dd8 upstream.
Added a quirk to fix Micron Nitro NVMe reporting duplicate NGUIDs.
--- drivers/nvme/host/pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/pci.c +2 -0
@@ -3488,6 +3488,8 @@ static const struct pci_device_id nvme_i NVME_QUIRK_IGNORE_DEV_SUBNQN, }, { PCI_DEVICE(0x1344, 0x5407), /* Micron Technology Inc NVMe SSD */ .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN }, + { PCI_DEVICE(0x1344, 0x6001), /* Micron Nitro NVMe */ + .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x1c5c, 0x1504), /* SK Hynix PC400 */ .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, { PCI_DEVICE(0x1c5c, 0x174a), /* SK Hynix P31 SSD */
Greg Kroah-Hartman
maintainerPATCH 228/314 nvme-pci: add NVME_QUIRK_BOGUS_NID for Netac NV7000
In reply to Greg Kroah-HartmanFrom: Tiago Dias Ferreira <[email protected]>
commit 8d6e38f636ac063e8062a21e7616f7d9bf0df5d8 upstream.
Added a quirk to fix the Netac NV7000 SSD reporting duplicate NGUIDs.
--- drivers/nvme/host/pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/pci.c +2 -0
@@ -3520,6 +3520,8 @@ static const struct pci_device_id nvme_i .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, { PCI_DEVICE(0x2646, 0x501E), /* KINGSTON OM3PGP4xxxxQ OS21011 NVMe SSD */ .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, + { PCI_DEVICE(0x1f40, 0x5236), /* Netac Technologies Co. NV7000 NVMe SSD */ + .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x1e4B, 0x1001), /* MAXIO MAP1001 */ .driver_data = NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x1e4B, 0x1002), /* MAXIO MAP1002 */
Greg Kroah-Hartman
maintainerPATCH 229/314 slimbus: qcom-ngd: Fix build error when CONFIG_SLIM_QCOM_NGD_CTRL=y && CONFIG_QCOM_RPROC_COMMON=m
In reply to Greg Kroah-HartmanFrom: Zheng Bin <[email protected]>
commit e54fad8044db18cc400df8d01bfb86cada08b7cb upstream.
If CONFIG_SLIM_QCOM_NGD_CTRL=y, CONFIG_QCOM_RPROC_COMMON=m, COMPILE_TEST=y, bulding fails:
drivers/slimbus/qcom-ngd-ctrl.o: In function `qcom_slim_ngd_ctrl_probe':
qcom-ngd-ctrl.c:(.text+0x330): undefined reference to qcom_register_ssr_notifier' qcom-ngd-ctrl.c:(.text+0x5fc): undefined reference to qcom_unregister_ssr_notifier' drivers/slimbus/qcom-ngd-ctrl.o: In function `qcom_slim_ngd_remove':
qcom-ngd-ctrl.c:(.text+0x90c): undefined reference to `qcom_unregister_ssr_notifier'
Make SLIM_QCOM_NGD_CTRL depends on QCOM_RPROC_COMMON || (COMPILE_TEST && !QCOM_RPROC_COMMON) to fix this.
--- drivers/slimbus/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/slimbus/Kconfig +1 -1
@@ -23,7 +23,7 @@ config SLIM_QCOM_CTRL config SLIM_QCOM_NGD_CTRL tristate "Qualcomm SLIMbus Satellite Non-Generic Device Component" depends on HAS_IOMEM && DMA_ENGINE && NET && QCOM_RPROC_COMMON - depends on ARCH_QCOM || COMPILE_TEST + depends on ARCH_QCOM || (COMPILE_TEST && !QCOM_RPROC_COMMON) select QCOM_QMI_HELPERS select QCOM_PDR_HELPERS help
Greg Kroah-Hartman
maintainerPATCH 230/314 slimbus: stream: correct presence rate frequencies
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit b9c1939627f8185dec8ba6d741e9573a4c7a5834 upstream.
Correct few frequencies in presence rate table - multiplied by 10 (110250 instead of 11025 Hz).
--- drivers/slimbus/stream.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/slimbus/stream.c +4 -4
@@ -67,10 +67,10 @@ static const int slim_presence_rate_tabl384000 ,768000 ,0 ,/* Reserved */ -110250 , -220500 , -441000 , -882000 , +11025 , +22050 , +44100 , +88200 ,176400 ,352800 , 705600,
Greg Kroah-Hartman
maintainerPATCH 231/314 speakup: fix a segfault caused by switching consoles
In reply to Greg Kroah-HartmanFrom: Mushahid Hussain <[email protected]>
commit 0fc801f8018000c8e64a275a20cb1da7c54e46df upstream.
This patch fixes a segfault by adding a null check on synth in speakup_con_update(). The segfault can be reproduced as follows:
- Login into a text console
- Load speakup and speakup_soft modules
- Remove speakup_soft
- Switch to a graphics console
This is caused by lack of a null check on synth in speakup_con_update().
Here's the sequence that causes the segfault:
- When we remove the speakup_soft, synth_release() sets the synth to null.
- After that, when we change the virtual console to graphics console, vt_notifier_call() is fired, which then calls speakup_con_update().
- Inside speakup_con_update() there's no null check on synth, so it calls synth_printf().
- Inside synth_printf(), synth_buffer_add() and synth_start(), both access synth, when it is null and causing a segfault.
Therefore adding a null check on synth solves the issue.
--- drivers/accessibility/speakup/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accessibility/speakup/main.c +1 -1
@@ -1778,7 +1778,7 @@ static void speakup_con_update(struct vc {unsigned long flags; -if (!speakup_console[vc->vc_num] || spk_parked) +if (!speakup_console[vc->vc_num] || spk_parked || !synth)return ;if (!spin_trylock_irqsave (&speakup_info.spinlock, flags))/* Speakup output, discard */
Greg Kroah-Hartman
maintainerPATCH 232/314 speakup: replace utils u_char with unsigned char
In reply to Greg Kroah-HartmanFrom: Đoàn Trần Công Danh <[email protected]>
commit 92ca969ff8815f3feef2645199bd39bf594e5eeb upstream.
drivers/accessibility/speakup/utils.h will be used to compile host tool to generate metadata.
"u_char" is a non-standard type, which is defined to "unsigned char" on glibc but not defined by some libc, e.g. musl.
Let's replace "u_char" with "unsigned char"
--- drivers/accessibility/speakup/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accessibility/speakup/utils.h +1 -1
@@ -54,7 +54,7 @@ static inline int oops(const char *msg,static inline struct st_key *hash_name (char *name) { -u_char *pn = (u_char *)name; +unsigned char *pn = (unsigned char *)name;int hash =0 ;while (*pn) {
Greg Kroah-Hartman
maintainerPATCH 233/314 USB: bcma: Make GPIO explicitly optional
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
commit cd136706b4f925aa5d316642543babac90d45910 upstream.
What the code does is to not check the return value from devm_gpiod_get() and then avoid using an erroneous GPIO descriptor with IS_ERR_OR_NULL().
This will miss real errors from the GPIO core that should not be ignored, such as probe deferral.
Instead request the GPIO as explicitly optional, which means that if it doesn't exist, the descriptor returned will be NULL.
Then we can add error handling and also avoid just doing this on the device tree path, and simplify the site where the optional GPIO descriptor is used.
There were some problems with cleaning up this GPIO descriptor use in the past, but this is the proper way to deal with it.
--- drivers/usb/host/bcma-hcd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/usb/host/bcma-hcd.c +6 -4
@@ -285,7 +285,7 @@ static void bcma_hci_platform_power_gpio {struct bcma_hcd_device *usb_dev =bcma_get_drvdata (dev); -if (IS_ERR_OR_NULL (usb_dev->gpio_desc)) +if (!usb_dev->gpio_desc)return ;gpiod_set_value (usb_dev->gpio_desc, val);
@@ -406,9 +406,11 @@ static int bcma_hcd_probe(struct bcma_dereturn -ENOMEM ; usb_dev->core = core; -if (core->dev.of_node) - usb_dev->gpio_desc =devm_gpiod_get (&core->dev,"vcc" , -GPIOD_OUT_HIGH ); + usb_dev->gpio_desc =devm_gpiod_get_optional (&core->dev,"vcc" , +GPIOD_OUT_HIGH ); +if (IS_ERR (usb_dev->gpio_desc)) +return dev_err_probe (&core->dev,PTR_ERR (usb_dev->gpio_desc), +"error obtaining VCC GPIO" );switch (core->id.id) {case BCMA_CORE_USB20_HOST :
Greg Kroah-Hartman
maintainerPATCH 234/314 USB: serial: option: add Sierra Wireless EM9191
In reply to Greg Kroah-HartmanFrom: Benoît Monin <[email protected]>
commit df3414b0a245f43476061fddd78cee7d6cff797f upstream.
Add support for the AT and diag ports, similar to other qualcomm SDX55 modems. In QDL mode, the modem uses a different device ID and support is provided by qcserial in commit 11c52d250b34 ("USB: serial: qcserial:
add EM9191 QDL support").
T: Bus=08 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 3 Spd=5000 MxCh= 0 D: Ver= 3.20 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 1 P: Vendor=1199 ProdID=90d3 Rev=00.06 S: Manufacturer=Sierra Wireless, Incorporated S: Product=Sierra Wireless EM9191 S: SerialNumber=xxxxxxxxxxxxxxxx C: #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=896mA I: If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim I: If#=0x1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim I: If#=0x3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none) I: If#=0x4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=(none)
--- drivers/usb/serial/option.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/serial/option.c +5 -0
@@ -581,6 +581,9 @@ static void option_instat_callback(struc#define OPPO_VENDOR_ID 0x22d9#define OPPO_PRODUCT_R11 0x276c +/* Sierra Wireless products */ +#define SIERRA_VENDOR_ID 0x1199 +#define SIERRA_PRODUCT_EM9191 0x90d3/* Device flags */
@@ -2176,6 +2179,8 @@ static const struct usb_device_id option { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1405, 0xff) }, /* GosunCn GM500 MBIM */ { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1406, 0xff) }, /* GosunCn GM500 ECM/NCM */ { USB_DEVICE_AND_INTERFACE_INFO(OPPO_VENDOR_ID, OPPO_PRODUCT_R11, 0xff, 0xff, 0x30) }, + { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0xff, 0x30) }, + { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0, 0) }, { } /* Terminating entry */ };MODULE_DEVICE_TABLE (usb, option_ids);
Greg Kroah-Hartman
maintainerPATCH 235/314 USB: serial: option: remove old LARA-R6 PID
In reply to Greg Kroah-HartmanFrom: Davide Tronchin <[email protected]>
commit 2ec106b96afc19698ff934323b633c0729d4c7f8 upstream.
Remove the UBLOX_PRODUCT_R6XX 0x90fa association since LARA-R6 00B final product uses a new USB composition with different PID. 0x90fa PID used only by LARA-R6 internal prototypes.
Move 0x90fa PID directly in the option_ids array since used by other Qualcomm based modem vendors as pointed out in:
https://lore.kernel.org/all/[email protected]
--- drivers/usb/serial/option.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/serial/option.c +1 -2
@@ -240,7 +240,6 @@ static void option_instat_callback(struc#define QUECTEL_PRODUCT_UC15 0x9090/* These u-blox products use Qualcomm's vendor ID */ #define UBLOX_PRODUCT_R410M 0x90b2 -#define UBLOX_PRODUCT_R6XX 0x90fa/* These Yuga products use Qualcomm's vendor ID */ #define YUGA_PRODUCT_CLM920_NC5 0x9625
@@ -1127,7 +1126,7 @@ static const struct usb_device_id option/* u-blox products using Qualcomm vendor ID */ { USB_DEVICE(QUALCOMM_VENDOR_ID, UBLOX_PRODUCT_R410M), .driver_info = RSVD(1) | RSVD(3) }, - { USB_DEVICE(QUALCOMM_VENDOR_ID, UBLOX_PRODUCT_R6XX), + { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x90fa), .driver_info = RSVD(3) },/* Quectel products using Quectel vendor ID */ { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21, 0xff, 0xff, 0xff),
Greg Kroah-Hartman
maintainerPATCH 236/314 USB: serial: option: add u-blox LARA-R6 00B modem
In reply to Greg Kroah-HartmanFrom: Davide Tronchin <[email protected]>
commit d9e37a5c4d80ea25a7171ab8557a449115554e76 upstream.
The official LARA-R6 (00B) modem uses 0x908b PID. LARA-R6 00B does not implement a QMI interface on port 4, the reservation (RSVD(4)) has been added to meet other companies that implement QMI on that interface.
LARA-R6 00B USB composition exposes the following interfaces:
If 0: Diagnostic
If 1: AT parser
If 2: AT parser
If 3: AT parser/alternative functions
--- drivers/usb/serial/option.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/option.c +2 -0
@@ -1126,6 +1126,8 @@ static const struct usb_device_id option/* u-blox products using Qualcomm vendor ID */ { USB_DEVICE(QUALCOMM_VENDOR_ID, UBLOX_PRODUCT_R410M), .driver_info = RSVD(1) | RSVD(3) }, + { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x908b), /* u-blox LARA-R6 00B */ + .driver_info = RSVD(4) }, { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x90fa), .driver_info = RSVD(3) },/* Quectel products using Quectel vendor ID */
Greg Kroah-Hartman
maintainerPATCH 237/314 USB: serial: option: add u-blox LARA-L6 modem
In reply to Greg Kroah-HartmanFrom: Davide Tronchin <[email protected]>
commit c1547f12df8b8e9ca2686accee43213ecd117efe upstream.
Add LARA-L6 PIDs for three different USB compositions.
LARA-L6 module can be configured (by AT interface) in three different USB modes:
* Default mode (Vendor ID: 0x1546 Product ID: 0x1341) with 4 serial interfaces
* RmNet mode (Vendor ID: 0x1546 Product ID: 0x1342) with 4 serial interfaces and 1 RmNet virtual network interface
* CDC-ECM mode (Vendor ID: 0x1546 Product ID: 0x1343) with 4 serial interface and 1 CDC-ECM virtual network interface
In default mode LARA-L6 exposes the following interfaces:
If 0: Diagnostic
If 1: AT parser
If 2: AT parser
If 3: AT parser/alternative functions
In RmNet mode LARA-L6 exposes the following interfaces:
If 0: Diagnostic
If 1: AT parser
If 2: AT parser
If 3: AT parset/alternative functions
If 4: RMNET interface
In CDC-ECM mode LARA-L6 exposes the following interfaces:
If 0: Diagnostic
If 1: AT parser
If 2: AT parser
If 3: AT parset/alternative functions
If 4: CDC-ECM interface
--- drivers/usb/serial/option.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/serial/option.c +8 -0
@@ -162,6 +162,8 @@ static void option_instat_callback(struc#define NOVATELWIRELESS_PRODUCT_G2 0xA010#define NOVATELWIRELESS_PRODUCT_MC551 0xB001 +#define UBLOX_VENDOR_ID 0x1546 +/* AMOI PRODUCTS */ #define AMOI_VENDOR_ID 0x1614#define AMOI_PRODUCT_H01 0x0800
@@ -1130,6 +1132,12 @@ static const struct usb_device_id option .driver_info = RSVD(4) }, { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x90fa), .driver_info = RSVD(3) }, +/* u-blox products */ + { USB_DEVICE(UBLOX_VENDOR_ID, 0x1341) }, /* u-blox LARA-L6 */ + { USB_DEVICE(UBLOX_VENDOR_ID, 0x1342), /* u-blox LARA-L6 (RMNET) */ + .driver_info = RSVD(4) }, + { USB_DEVICE(UBLOX_VENDOR_ID, 0x1343), /* u-blox LARA-L6 (ECM) */ + .driver_info = RSVD(4) },/* Quectel products using Quectel vendor ID */ { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21, 0xff, 0xff, 0xff), .driver_info = NUMEP2 },
Greg Kroah-Hartman
maintainerPATCH 238/314 USB: serial: option: add Fibocom FM160 0x0111 composition
In reply to Greg Kroah-HartmanFrom: Reinhard Speyerer <[email protected]>
commit 148f4b32b4504d8a32cf82049b7b9499a4b299ab upstream.
Add support for the following Fibocom FM160 composition:
0x0111: MBIM + MODEM + DIAG + AT
T: Bus=01 Lev=02 Prnt=125 Port=01 Cnt=02 Dev#= 93 Spd=480 MxCh= 0 D: Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=2cb7 ProdID=0111 Rev= 5.04 S: Manufacturer=Fibocom S: Product=Fibocom FM160 Modem_SN:12345678 S: SerialNumber=12345678 C:* #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA A: FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=0e Prot=00 I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0e Prot=00 Driver=cdc_mbim E: Ad=81(I) Atr=03(Int.) MxPS= 64 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim I:* If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim E: Ad=8e(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=0f(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=86(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/usb/serial/option.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/option.c +1 -0
@@ -2179,6 +2179,7 @@ static const struct usb_device_id option { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x010a, 0xff) }, /* Fibocom MA510 (ECM mode) */ { USB_DEVICE_AND_INTERFACE_INFO(0x2cb7, 0x010b, 0xff, 0xff, 0x30) }, /* Fibocom FG150 Diag */ { USB_DEVICE_AND_INTERFACE_INFO(0x2cb7, 0x010b, 0xff, 0, 0) }, /* Fibocom FG150 AT */ + { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0111, 0xff) }, /* Fibocom FM160 (MBIM mode) */ { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x01a0, 0xff) }, /* Fibocom NL668-AM/NL652-EU (laptop MBIM) */ { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x01a2, 0xff) }, /* Fibocom FM101-GL (laptop MBIM) */ { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x01a4, 0xff), /* Fibocom FM101-GL (laptop MBIM) */
Greg Kroah-Hartman
maintainerPATCH 239/314 usb: add NO_LPM quirk for Realforce 87U Keyboard
In reply to Greg Kroah-HartmanFrom: Nicolas Dumazet <[email protected]>
commit 181135bb20dcb184edd89817831b888eb8132741 upstream.
Before adding this quirk, this (mechanical keyboard) device would not be recognized, logging:
new full-speed USB device number 56 using xhci_hcd unable to read config index 0 descriptor/start: -32 chopping to 0 config(s)
It would take dozens of plugging/unpuggling cycles for the keyboard to be recognized. Keyboard seems to simply work after applying this quirk.
This issue had been reported by users in two places already ([1], [2]) but nobody tried upstreaming a patch yet. After testing I believe their suggested fix (DELAY_INIT + NO_LPM + DEVICE_QUALIFIER) was probably a little overkill. I assume this particular combination was tested because it had been previously suggested in [3], but only NO_LPM seems sufficient for this device.
[1]: https://qiita.com/float168/items/fed43d540c8e2201b543
[2]: https://blog.kostic.dev/posts/making-the-realforce-87ub-work-with-usb30-on-Ubuntu/
[3]: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1678477
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -362,6 +362,9 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x0781, 0x5583), .driver_info = USB_QUIRK_NO_LPM }, { USB_DEVICE(0x0781, 0x5591), .driver_info = USB_QUIRK_NO_LPM }, + /* Realforce 87U Keyboard */ + { USB_DEVICE(0x0853, 0x011b), .driver_info = USB_QUIRK_NO_LPM }, + /* M-Systems Flash Disk Pioneers */ { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
Greg Kroah-Hartman
maintainerPATCH 240/314 usb: chipidea: fix deadlock in ci_otg_del_timer
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
commit 7a58b8d6021426b796eebfae80983374d9a80a75 upstream.
There is a deadlock in ci_otg_del_timer(), the process is shown below:
(thread 1) | (thread 2) ci_otg_del_timer() | ci_otg_hrtimer_func() ... | spin_lock_irqsave() //(1) | ... ... | hrtimer_cancel() | spin_lock_irqsave() //(2)
(block forever)
We hold ci->lock in position (1) and use hrtimer_cancel() to wait ci_otg_hrtimer_func() to stop, but ci_otg_hrtimer_func() also need ci->lock in position (2). As a result, the hrtimer_cancel() in ci_otg_del_timer() will be blocked forever.
This patch extracts hrtimer_cancel() from the protection of spin_lock_irqsave() in order that the ci_otg_hrtimer_func() could obtain the ci->lock.
What`s more, there will be no race happen. Because the "next_timer" is always under the protection of spin_lock_irqsave() and we only check whether "next_timer" equals to NUM_OTG_FSM_TIMERS in the following code.
--- drivers/usb/chipidea/otg_fsm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/chipidea/otg_fsm.c +2 -0
@@ -256,8 +256,10 @@ static void ci_otg_del_timer(struct ci_h ci->enabled_otg_timer_bits &= ~(1 << t);if (ci->next_otg_timer == t) {if (ci->enabled_otg_timer_bits ==0 ) { +spin_unlock_irqrestore (&ci->lock, flags);/* No enabled timers after delete it */ hrtimer_cancel (&ci->otg_fsm_hrtimer); +spin_lock_irqsave (&ci->lock, flags); ci->next_otg_timer =NUM_OTG_FSM_TIMERS ; }else {/* Find the next timer */
Greg Kroah-Hartman
maintainerPATCH 241/314 usb: cdns3: host: fix endless superspeed hub port reset
In reply to Greg Kroah-HartmanFrom: Li Jun <[email protected]>
commit 9d5333c931347005352d5b8beaa43528c94cfc9c upstream.
When usb 3.0 hub connect with one USB 2.0 device and NO USB 3.0 device, some usb hub reports endless port reset message.
[ 190.324169] usb 2-1: new SuperSpeed USB device number 88 using xhci-hcd [ 190.352834] hub 2-1:1.0: USB hub found [ 190.356995] hub 2-1:1.0: 4 ports detected [ 190.700056] usb 2-1: USB disconnect, device number 88 [ 192.472139] usb 2-1: new SuperSpeed USB device number 89 using xhci-hcd [ 192.500820] hub 2-1:1.0: USB hub found [ 192.504977] hub 2-1:1.0: 4 ports detected [ 192.852066] usb 2-1: USB disconnect, device number 89
The reason is the runtime pm state of USB2.0 port is active and USB 3.0 port is suspend, so parent device is active state.
cat /sys/bus/platform/devices/5b110000.usb/5b130000.usb/xhci-hcd.1.auto/usb2/power/runtime_status
suspended
cat /sys/bus/platform/devices/5b110000.usb/5b130000.usb/xhci-hcd.1.auto/usb1/power/runtime_status
active
cat /sys/bus/platform/devices/5b110000.usb/5b130000.usb/xhci-hcd.1.auto/power/runtime_status
active
cat /sys/bus/platform/devices/5b110000.usb/5b130000.usb/power/runtime_status
active
So xhci_cdns3_suspend_quirk() have not called. U3 configure is not applied.
move U3 configure into host start. Reinit again in resume function in case controller power lost during suspend.
--- drivers/usb/cdns3/host.c | 56 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-)
drivers/usb/cdns3/host.c +28 -28
@@ -24,11 +24,37 @@#define CFG_RXDET_P3_EN BIT(15)#define LPM_2_STB_SWITCH_EN BIT(25) -static int xhci_cdns3_suspend_quirk (struct usb_hcd *hcd); +static void xhci_cdns3_plat_start (struct usb_hcd *hcd) +{ +struct xhci_hcd *xhci =hcd_to_xhci (hcd); +u32 value; + +/* set usbcmd.EU3S */ + value =readl (&xhci->op_regs->command); + value |=CMD_PM_INDEX ; +writel (value, &xhci->op_regs->command); + +if (hcd->regs) { + value =readl (hcd->regs +XECP_AUX_CTRL_REG1 ); + value |=CFG_RXDET_P3_EN ; +writel (value, hcd->regs +XECP_AUX_CTRL_REG1 ); + + value =readl (hcd->regs +XECP_PORT_CAP_REG ); + value |=LPM_2_STB_SWITCH_EN ; +writel (value, hcd->regs +XECP_PORT_CAP_REG ); + } +} + +static int xhci_cdns3_resume_quirk (struct usb_hcd *hcd) +{ +xhci_cdns3_plat_start (hcd); +return 0 ; +}static const struct xhci_plat_priv xhci_plat_cdns3_xhci = { .quirks =XHCI_SKIP_PHY_INIT |XHCI_AVOID_BEI , - .suspend_quirk = xhci_cdns3_suspend_quirk, + .plat_start = xhci_cdns3_plat_start, + .resume_quirk = xhci_cdns3_resume_quirk, };static int __cdns_host_init (struct cdns *cdns)
@@ -90,32 +116,6 @@ err1:return ret; } -static int xhci_cdns3_suspend_quirk (struct usb_hcd *hcd) -{ -struct xhci_hcd *xhci =hcd_to_xhci (hcd); -u32 value; - -if (pm_runtime_status_suspended (hcd->self.controller)) -return 0 ; - -/* set usbcmd.EU3S */ - value =readl (&xhci->op_regs->command); - value |=CMD_PM_INDEX ; -writel (value, &xhci->op_regs->command); - -if (hcd->regs) { - value =readl (hcd->regs +XECP_AUX_CTRL_REG1 ); - value |=CFG_RXDET_P3_EN ; -writel (value, hcd->regs +XECP_AUX_CTRL_REG1 ); - - value =readl (hcd->regs +XECP_PORT_CAP_REG ); - value |=LPM_2_STB_SWITCH_EN ; -writel (value, hcd->regs +XECP_PORT_CAP_REG ); - } - -return 0 ; -} -static void cdns_host_exit (struct cdns *cdns) {kfree (cdns->xhci_plat_data);
Greg Kroah-Hartman
maintainerPATCH 242/314 usb: typec: mux: Enter safe mode only when pins need to be reconfigured
In reply to Greg Kroah-HartmanFrom: Rajat Khandelwal <[email protected]>
commit 40bf8f162d0f95e0716e479d7db41443d931765c upstream.
There is no point to enter safe mode during DP/TBT configuration if the DP/TBT was already configured in mux. This is because safe mode is only applicable when there is a need to reconfigure the pins in order to avoid damage within/to port partner.
In some chrome systems, IOM/mux is already configured before OS comes up. Thus, when driver is probed, it blindly enters safe mode due to PD negotiations but only after gfx driver lowers dp_phy_ownership, will the IOM complete safe mode and send an ack to PMC.
Since, that never happens, we see IPC timeout.
Hence, allow safe mode only when pin reconfiguration is not required, which makes sense.
--- drivers/usb/typec/mux/intel_pmc_mux.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/usb/typec/mux/intel_pmc_mux.c +13 -2
@@ -369,13 +369,24 @@ pmc_usb_mux_usb4(struct pmc_usb_port *poreturn pmc_usb_command (port, (void *)&req,sizeof (req)); } -static int pmc_usb_mux_safe_state (struct pmc_usb_port *port) +static int pmc_usb_mux_safe_state (struct pmc_usb_port *port, +struct typec_mux_state *state) {u8 msg;if (IOM_PORT_ACTIVITY_IS (port->iom_status,SAFE_MODE ))return 0 ; +if ((IOM_PORT_ACTIVITY_IS (port->iom_status,DP ) || +IOM_PORT_ACTIVITY_IS (port->iom_status,DP_MFD )) && + state->alt && state->alt->svid ==USB_TYPEC_DP_SID ) +return 0 ; + +if ((IOM_PORT_ACTIVITY_IS (port->iom_status,TBT ) || +IOM_PORT_ACTIVITY_IS (port->iom_status,ALT_MODE_TBT_USB )) && + state->alt && state->alt->svid ==USB_TYPEC_TBT_SID ) +return 0 ; + msg =PMC_USB_SAFE_MODE ; msg |= port->usb3_port <<PMC_USB_MSG_USB3_PORT_SHIFT ;
@@ -443,7 +454,7 @@ pmc_usb_mux_set(struct typec_mux_dev *mureturn 0 ;if (state->mode ==TYPEC_STATE_SAFE ) -return pmc_usb_mux_safe_state (port); +return pmc_usb_mux_safe_state (port, state);if (state->mode ==TYPEC_STATE_USB )return pmc_usb_connect (port, port->role);
Greg Kroah-Hartman
maintainerPATCH 243/314 usb: typec: tipd: Prevent uninitialized event{1,2} in IRQ handler
In reply to Greg Kroah-HartmanFrom: Sven Peter <[email protected]>
commit 6d8fc203b28ff8f6115fbe5eaf584de8b824f4fa upstream.
If reading TPS_REG_INT_EVENT1/2 fails in the interrupt handler event1 and event2 may be uninitialized when they are used to determine IRQ_HANDLED vs. IRQ_NONE in the error path.
--- drivers/usb/typec/tipd/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/typec/tipd/core.c +3 -3
@@ -474,7 +474,7 @@ static void tps6598x_handle_plug_event(sstatic irqreturn_t cd321x_interrupt (int irq,void *data) {struct tps6598x *tps = data; -u64 event; +u64 event =0 ;u32 status;int ret;
@@ -519,8 +519,8 @@ err_unlock:static irqreturn_t tps6598x_interrupt (int irq,void *data) {struct tps6598x *tps = data; -u64 event1; -u64 event2; +u64 event1 =0 ; +u64 event2 =0 ;u32 status;int ret;
Greg Kroah-Hartman
maintainerPATCH 244/314 iio: accel: bma400: Ensure VDDIO is enable defore reading the chip ID.
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit 57572cacd36e6d4be7722d7770d23f4430219827 upstream.
The regulator enables were after the check on the chip variant, which was very unlikely to return a correct value when not powered. Presumably all the device anyone is testing on have a regulator that is already powered up when this code runs for reasons beyond the scope of this driver. Move the read call down a few lines.
--- drivers/iio/accel/bma400_core.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/iio/accel/bma400_core.c +12 -12
@@ -737,18 +737,6 @@ static int bma400_init(struct bma400_datunsigned int val;int ret; -/* Try to read chip_id register. It must return 0x90. */ - ret =regmap_read (data->regmap,BMA400_CHIP_ID_REG , &val); -if (ret) { -dev_err (data->dev,"Failed to read chip id register\n" ); -return ret; - } - -if (val !=BMA400_ID_REG_VAL ) { -dev_err (data->dev,"Chip ID mismatch\n" ); -return -ENODEV ; - } - data->regulators[BMA400_VDD_REGULATOR ].supply ="vdd" ; data->regulators[BMA400_VDDIO_REGULATOR ].supply ="vddio" ; ret = devm_regulator_bulk_get(data->dev,
@@ -774,6 +762,18 @@ static int bma400_init(struct bma400_datif (ret)return ret; +/* Try to read chip_id register. It must return 0x90. */ + ret =regmap_read (data->regmap,BMA400_CHIP_ID_REG , &val); +if (ret) { +dev_err (data->dev,"Failed to read chip id register\n" ); +return ret; + } + +if (val !=BMA400_ID_REG_VAL ) { +dev_err (data->dev,"Chip ID mismatch\n" ); +return -ENODEV ; + } + ret =bma400_get_power_mode (data);if (ret) {dev_err (data->dev,"Failed to get the initial power-mode\n" );
Greg Kroah-Hartman
maintainerPATCH 245/314 iio: adc: at91_adc: fix possible memory leak in at91_adc_allocate_trigger()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
commit 65f20301607d07ee279b0804d11a05a62a6c1a1c upstream.
If iio_trigger_register() returns error, it should call iio_trigger_free() to give up the reference that hold in iio_trigger_alloc(), so that it can call iio_trig_release() to free memory when the refcount hit to 0.
--- drivers/iio/adc/at91_adc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/at91_adc.c +3 -1
@@ -634,8 +634,10 @@ static struct iio_trigger *at91_adc_allo trig->ops = &at91_adc_trigger_ops; ret =iio_trigger_register (trig); -if (ret) +if (ret) { +iio_trigger_free (trig);return NULL ; + }return trig; }
Greg Kroah-Hartman
maintainerPATCH 246/314 iio: trigger: sysfs: fix possible memory leak in iio_sysfs_trig_init()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
commit efa17e90e1711bdb084e3954fa44afb6647331c0 upstream.
dev_set_name() allocates memory for name, it need be freed when device_add() fails, call put_device() to give up the reference that hold in device_initialize(), so that it can be freed in kobject_cleanup() when the refcount hit to 0.
Fault injection test can trigger this:
unreferenced object 0xffff8e8340a7b4c0 (size 32):
comm "modprobe", pid 243, jiffies 4294678145 (age 48.845s) hex dump (first 32 bytes):
69 69 6f 5f 73 79 73 66 73 5f 74 72 69 67 67 65 iio_sysfs_trigge
72 00 a7 40 83 8e ff ff 00 86 13 c4 f6 ee ff ff r..@............
backtrace:
[<0000000074999de8>] __kmem_cache_alloc_node+0x1e9/0x360
[<00000000497fd30b>] __kmalloc_node_track_caller+0x44/0x1a0
[<000000003636c520>] kstrdup+0x2d/0x60
[<0000000032f84da2>] kobject_set_name_vargs+0x1e/0x90
[<0000000092efe493>] dev_set_name+0x4e/0x70--- drivers/iio/trigger/iio-trig-sysfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/trigger/iio-trig-sysfs.c +5 -1
@@ -203,9 +203,13 @@ static int iio_sysfs_trigger_remove(intstatic int __init iio_sysfs_trig_init (void ) { +int ret;device_initialize (&iio_sysfs_trig_dev);dev_set_name (&iio_sysfs_trig_dev,"iio_sysfs_trigger" ); -return device_add (&iio_sysfs_trig_dev); + ret =device_add (&iio_sysfs_trig_dev); +if (ret) +put_device (&iio_sysfs_trig_dev); +return ret; }module_init (iio_sysfs_trig_init);
Greg Kroah-Hartman
maintainerPATCH 247/314 iio: adc: mp2629: fix wrong comparison of channel
In reply to Greg Kroah-HartmanFrom: Saravanan Sekar <[email protected]>
commit 1eb20332a082fa801fb89c347c5e62de916a4001 upstream.
Input voltage channel enum is compared against iio address instead of the channel.
--- drivers/iio/adc/mp2629_adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/mp2629_adc.c +1 -1
@@ -74,7 +74,7 @@ static int mp2629_read_raw(struct iio_deif (ret)return ret; -if (chan->address ==MP2629_INPUT_VOLT ) +if (chan->channel ==MP2629_INPUT_VOLT ) rval &=GENMASK (6 ,0 ); *val = rval;return IIO_VAL_INT ;
Greg Kroah-Hartman
maintainerPATCH 248/314 iio: adc: mp2629: fix potential array out of bound access
In reply to Greg Kroah-HartmanFrom: Saravanan Sekar <[email protected]>
commit ca1547ab15f48dc81624183ae17a2fd1bad06dfc upstream.
Add sentinel at end of maps to avoid potential array out of bound access in iio core.
--- drivers/iio/adc/mp2629_adc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/mp2629_adc.c +2 -1
@@ -57,7 +57,8 @@ static struct iio_map mp2629_adc_maps[]MP2629_MAP (SYSTEM_VOLT ,"system-volt" ),MP2629_MAP (INPUT_VOLT ,"input-volt" ),MP2629_MAP (BATT_CURRENT ,"batt-current" ), -MP2629_MAP (INPUT_CURRENT ,"input-current" ) + MP2629_MAP(INPUT_CURRENT, "input-current"), + { } }; static int mp2629_read_raw(struct iio_dev *indio_dev,
Greg Kroah-Hartman
maintainerPATCH 249/314 iio: pressure: ms5611: fixed value compensation bug
In reply to Greg Kroah-HartmanFrom: Mitja Spes <[email protected]>
commit 17f442e7e47579d3881fc4d47354eaef09302e6f upstream.
When using multiple instances of this driver the compensation PROM was overwritten by the last initialized sensor. Now each sensor has own PROM storage.
--- drivers/iio/pressure/ms5611.h | 12 ++------ drivers/iio/pressure/ms5611_core.c | 51 +++++++++++++++++++------------------ 2 files changed, 31 insertions(+), 32 deletions(-)
drivers/iio/pressure/ms5611.h +4 -8
@@ -25,13 +25,6 @@ enum { MS5607, }; -struct ms5611_chip_info { -u16 prom[MS5611_PROM_WORDS_NB ]; - -int (*temp_and_pressure_compensate)(struct ms5611_chip_info *chip_info, -s32 *temp,s32 *pressure); -}; -/* * OverSampling Rate descriptor. * Warning: cmd MUST be kept aligned on a word boundary (see
@@ -50,12 +43,15 @@ struct ms5611_state {const struct ms5611_osr *pressure_osr;const struct ms5611_osr *temp_osr; +u16 prom[MS5611_PROM_WORDS_NB ]; +int (*reset)(struct ms5611_state *st);int (*read_prom_word)(struct ms5611_state *st,int index,u16 *word);int (*read_adc_temp_and_pressure)(struct ms5611_state *st,s32 *temp,s32 *pressure); -struct ms5611_chip_info *chip_info; +int (*compensate_temp_and_pressure)(struct ms5611_state *st,s32 *temp, +s32 *pressure);struct regulator *vdd; };
drivers/iio/pressure/ms5611_core.c +27 -24
101 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 250/314 iio: pressure: ms5611: changed hardcoded SPI speed to value limited
In reply to Greg Kroah-HartmanFrom: Mitja Spes <[email protected]>
commit 741cec30cc52058d1c10d415f3b98319887e4f73 upstream.
Don't hardcode the ms5611 SPI speed, limit it instead.
--- drivers/iio/pressure/ms5611_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/pressure/ms5611_spi.c +1 -1
@@ -91,7 +91,7 @@ static int ms5611_spi_probe(struct spi_dspi_set_drvdata (spi, indio_dev); spi->mode =SPI_MODE_0 ; - spi->max_speed_hz =20000000 ; + spi->max_speed_hz =min (spi->max_speed_hz,20000000U ); spi->bits_per_word =8 ; ret =spi_setup (spi);if (ret <0 )
Greg Kroah-Hartman
maintainerPATCH 251/314 dm bufio: Fix missing decrement of no_sleep_enabled if dm_bufio_client_create failed
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 0dfc1f4ceae86a0d09d880ab87625c86c61ed33c upstream.
The 'no_sleep_enabled' should be decreased in error handling path in dm_bufio_client_create() when the DM_BUFIO_CLIENT_NO_SLEEP flag is set, otherwise static_branch_unlikely() will always return true even if no dm_bufio_client instances have DM_BUFIO_CLIENT_NO_SLEEP flag set.
--- drivers/md/dm-bufio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/dm-bufio.c +2 -0
@@ -1858,6 +1858,8 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsigndm_io_client_destroy (c->dm_io); bad_dm_io:mutex_destroy (&c->lock); +if (c->no_sleep) +static_branch_dec (&no_sleep_enabled);kfree (c); bad_client:return ERR_PTR (r);
Signature · 1 line
2.38.1
Greg Kroah-Hartman
maintainerPATCH 252/314 dm ioctl: fix misbehavior if list_versions races with module loading
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit 4fe1ec995483737f3d2a14c3fe1d8fe634972979 upstream.
__list_versions will first estimate the required space using the "dm_target_iterate(list_version_get_needed, &needed)" call and then will fill the space using the "dm_target_iterate(list_version_get_info, &iter_info)" call. Each of these calls locks the targets using the "down_read(&_lock)" and "up_read(&_lock)" calls, however between the first and second "dm_target_iterate" there is no lock held and the target modules can be loaded at this point, so the second "dm_target_iterate" call may need more space than what was the first "dm_target_iterate" returned.
The code tries to handle this overflow (see the beginning of list_version_get_info), however this handling is incorrect.
The code sets "param->data_size = param->data_start + needed" and "iter_info.end = (char *)vers+len" - "needed" is the size returned by the first dm_target_iterate call; "len" is the size of the buffer allocated by userspace.
"len" may be greater than "needed"; in this case, the code will write up to "len" bytes into the buffer, however param->data_size is set to "needed", so it may write data past the param->data_size value. The ioctl interface copies only up to param->data_size into userspace, thus part of the result will be truncated.
Fix this bug by setting "iter_info.end = (char *)vers + needed;" - this guarantees that the second "dm_target_iterate" call will write only up to the "needed" buffer and it will exit with "DM_BUFFER_FULL_FLAG" if it overflows the "needed" space - in this case, userspace will allocate a larger buffer and retry.
Note that there is also a bug in list_version_get_needed - we need to add "strlen(tt->name) + 1" to the needed size, not "strlen(tt->name)".
--- drivers/md/dm-ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-ioctl.c +2 -2
@@ -655,7 +655,7 @@ static void list_version_get_needed(strusize_t *needed = needed_param; *needed +=sizeof (struct dm_target_versions ); - *needed +=strlen (tt->name); + *needed +=strlen (tt->name) +1 ; *needed +=ALIGN_MASK ; }
@@ -720,7 +720,7 @@ static int __list_versions(struct dm_ioc iter_info.old_vers =NULL ; iter_info.vers = vers; iter_info.flags =0 ; - iter_info.end = (char *)vers+len; + iter_info.end = (char *)vers + needed;/* * Now loop through filling out the names & versions.
Greg Kroah-Hartman
maintainerPATCH 253/314 serial: 8250: Fall back to non-DMA Rx if IIR_RDI occurs
In reply to Greg Kroah-HartmanFrom: Ilpo Järvinen <[email protected]>
commit a931237cbea256aff13bb403da13a97b2d1605d9 upstream.
DW UART sometimes triggers IIR_RDI during DMA Rx when IIR_RX_TIMEOUT should have been triggered instead. Since IIR_RDI has higher priority than IIR_RX_TIMEOUT, this causes the Rx to hang into interrupt loop. The problem seems to occur at least with some combinations of small-sized transfers (I've reproduced the problem on Elkhart Lake PSE UARTs).
If there's already an on-going Rx DMA and IIR_RDI triggers, fall graciously back to non-DMA Rx. That is, behave as if IIR_RX_TIMEOUT had occurred.
8250_omap already considers IIR_RDI similar to this change so its nothing unheard of.
--- drivers/tty/serial/8250/8250_port.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/8250/8250_port.c +4 -0
@@ -1892,6 +1892,10 @@ EXPORT_SYMBOL_GPL(serial8250_modem_statustatic bool handle_rx_dma (struct uart_8250_port *up,unsigned int iir) {switch (iir &0x3f ) { +case UART_IIR_RDI : +if (!up->dma->rx_running) +break ; + fallthrough;case UART_IIR_RX_TIMEOUT :serial8250_rx_dma_flush (up); fallthrough;
Greg Kroah-Hartman
maintainerPATCH 254/314 serial: 8250: Flush DMA Rx on RLSI
In reply to Greg Kroah-HartmanFrom: Ilpo Järvinen <[email protected]>
commit 1980860e0c8299316cddaf0992dd9e1258ec9d88 upstream.
Returning true from handle_rx_dma() without flushing DMA first creates a data ordering hazard. If DMA Rx has handled any character at the point when RLSI occurs, the non-DMA path handles any pending characters jumping them ahead of those characters that are pending under DMA.
--- drivers/tty/serial/8250/8250_port.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/serial/8250/8250_port.c +1 -2
@@ -1896,10 +1896,9 @@ static bool handle_rx_dma(struct uart_82if (!up->dma->rx_running)break ; fallthrough; +case UART_IIR_RLSI :case UART_IIR_RX_TIMEOUT :serial8250_rx_dma_flush (up); - fallthrough; -case UART_IIR_RLSI :return true; }return up->dma->rx_dma (up);
Greg Kroah-Hartman
maintainerPATCH 255/314 serial: 8250_lpss: Configure DMA also w/o DMA filter
In reply to Greg Kroah-HartmanFrom: Ilpo Järvinen <[email protected]>
commit 1bfcbe5805d0cfc83c3544dcd01e0a282c1f6790 upstream.
If the platform doesn't use DMA device filter (as is the case with Elkhart Lake), whole lpss8250_dma_setup() setup is skipped. This results in skipping also *_maxburst setup which is undesirable. Refactor lpss8250_dma_setup() to configure DMA even if filter is not setup.
--- drivers/tty/serial/8250/8250_lpss.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_lpss.c +11 -4
@@ -277,8 +277,13 @@ static int lpss8250_dma_setup(struct lpsstruct dw_dma_slave *rx_param, *tx_param;struct device *dev = port->port.dev; -if (!lpss->dma_param.dma_dev) +if (!lpss->dma_param.dma_dev) { + dma = port->dma; +if (dma) + goto out_configuration_only; +return 0 ; + } rx_param =devm_kzalloc (dev,sizeof (*rx_param),GFP_KERNEL );if (!rx_param)
@@ -289,16 +294,18 @@ static int lpss8250_dma_setup(struct lpsreturn -ENOMEM ; *rx_param = lpss->dma_param; - dma->rxconf.src_maxburst = lpss->dma_maxburst; - *tx_param = lpss->dma_param; - dma->txconf.dst_maxburst = lpss->dma_maxburst; dma->fn = lpss8250_dma_filter; dma->rx_param = rx_param; dma->tx_param = tx_param; port->dma = dma; + +out_configuration_only: + dma->rxconf.src_maxburst = lpss->dma_maxburst; + dma->txconf.dst_maxburst = lpss->dma_maxburst; +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 256/314 serial: 8250_lpss: Use 16B DMA burst with Elkhart Lake
In reply to Greg Kroah-HartmanFrom: Ilpo Järvinen <[email protected]>
commit 7090abd6ad0610a144523ce4ffcb8560909bf2a8 upstream.
Configure DMA to use 16B burst size with Elkhart Lake. This makes the bus use more efficient and works around an issue which occurs with the previously used 1B.
The fix was initially developed by Srikanth Thokala and Aman Kumar. This together with the previous config change is the cleaned up version of the original fix.
--- drivers/tty/serial/8250/8250_lpss.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/8250/8250_lpss.c +2 -0
@@ -174,6 +174,8 @@ static int ehl_serial_setup(struct lpss8*/ up->dma = dma; + lpss->dma_maxburst =16 ; + port->set_termios = dw8250_do_set_termios;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 257/314 io_uring: fix tw losing poll events
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
commit 539bcb57da2f58886d7d5c17134236b0ec9cd15d upstream.
We may never try to process a poll wake and its mask if there was multiple wake ups racing for queueing up a tw. Force io_poll_check_events() to update the mask by vfs_poll().
--- io_uring/poll.c | 7 +++++++ 1 file changed, 7 insertions(+)
io_uring/poll.c +7 -0
@@ -226,6 +226,13 @@ static int io_poll_check_events(struct ireturn IOU_POLL_DONE ;if (v &IO_POLL_CANCEL_FLAG )return -ECANCELED ; +/* +* cqe.res contains only events of the first wake up +* and all others are be lost. Redo vfs_poll() to get +* up to date state. +*/ +if ((v &IO_POLL_REF_MASK ) !=1 ) + req->cqe.res =0 ;/* the mask was stashed in __io_poll_execute */ if (!req->cqe.res) {
Greg Kroah-Hartman
maintainerPATCH 258/314 io_uring: fix multishot accept request leaks
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
commit 91482864768a874c4290ef93b84a78f4f1dac51b upstream.
Having REQ_F_POLLED set doesn't guarantee that the request is executed as a multishot from the polling path. Fortunately for us, if the code thinks it's multishot issue when it's not, it can only ask to skip completion so leaking the request. Use issue_flags to mark multipoll issues.
--- include/linux/io_uring.h | 3 +++ io_uring/io_uring.c | 2 +- io_uring/io_uring.h | 4 ++-- io_uring/net.c | 7 ++----- 4 files changed, 8 insertions(+), 8 deletions(-)
include/linux/io_uring.h +3 -0
@@ -15,6 +15,9 @@ enum io_uring_cmd_flags {IO_URING_F_SQE128 =4 ,IO_URING_F_CQE32 =8 ,IO_URING_F_IOPOLL =16 , + +/* the request is executed from poll, it should not be freed */ + IO_URING_F_MULTISHOT = 32, }; struct io_uring_cmd {
io_uring/io_uring.c +1 -1
@@ -1618,7 +1618,7 @@ int io_poll_issue(struct io_kiocb *req,io_tw_lock (req->ctx, locked);if (unlikely (req->task->flags &PF_EXITING ))return -EFAULT ; -return io_issue_sqe (req,IO_URING_F_NONBLOCK ); +return io_issue_sqe (req,IO_URING_F_NONBLOCK |IO_URING_F_MULTISHOT ); }struct io_wq_work *io_wq_free_work (struct io_wq_work *work)
io_uring/io_uring.h +2 -2
@@ -17,8 +17,8 @@ enum {IOU_ISSUE_SKIP_COMPLETE = -EIOCBQUEUED ,/* -* Intended only when both REQ_F_POLLED and REQ_F_APOLL_MULTISHOT -* are set to indicate to the poll runner that multishot should be +* Intended only when both IO_URING_F_MULTISHOT is passed +* to indicate to the poll runner that multishot should be * removed and the result is set on req->cqe.res. */ IOU_STOP_MULTISHOT = -ECANCELED,
io_uring/net.c +2 -5
@@ -1168,8 +1168,7 @@ retry:* return EAGAIN to arm the poll infra since it * has already been done */ -if ((req->flags &IO_APOLL_MULTI_POLLED ) == -IO_APOLL_MULTI_POLLED ) +if (issue_flags &IO_URING_F_MULTISHOT ) ret =IOU_ISSUE_SKIP_COMPLETE ;return ret; }
@@ -1194,9 +1193,7 @@ retry: goto retry;io_req_set_res (req, ret,0 ); -if (req->flags &REQ_F_POLLED ) -return IOU_STOP_MULTISHOT ; -return IOU_OK ; +return (issue_flags &IO_URING_F_MULTISHOT ) ?IOU_STOP_MULTISHOT :IOU_OK ; }int io_socket_prep (struct io_kiocb *req,const struct io_uring_sqe *sqe)
Greg Kroah-Hartman
maintainerPATCH 259/314 io_uring: fix multishot recv request leaks
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
commit 100d6b17c06ee4c2b42fdddf0fe4ab77c86eb77e upstream.
Having REQ_F_POLLED set doesn't guarantee that the request is executed as a multishot from the polling path. Fortunately for us, if the code thinks it's multishot issue when it's not, it can only ask to skip completion so leaking the request. Use issue_flags to mark multipoll issues.
--- io_uring/net.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
io_uring/net.c +7 -9
@@ -66,8 +66,6 @@ struct io_sr_msg {struct io_kiocb *notif; }; -#define IO_APOLL_MULTI_POLLED (REQ_F_APOLL_MULTISHOT | REQ_F_POLLED) -int io_shutdown_prep (struct io_kiocb *req,const struct io_uring_sqe *sqe) { struct io_shutdown *shutdown = io_kiocb_to_cmd(req, struct io_shutdown);
@@ -558,7 +556,8 @@ static inline void io_recv_prep_retry(st* again (for multishot). */ static inline bool io_recv_finish (struct io_kiocb *req,int *ret, -unsigned int cflags,bool mshot_finished) +unsigned int cflags,bool mshot_finished, +unsigned issue_flags) {if (!(req->flags &REQ_F_APOLL_MULTISHOT )) {io_req_set_res (req, *ret, cflags);
@@ -581,7 +580,7 @@ static inline bool io_recv_finish(structio_req_set_res (req, *ret, cflags); -if (req->flags &REQ_F_POLLED ) +if (issue_flags &IO_URING_F_MULTISHOT ) *ret =IOU_STOP_MULTISHOT ;else *ret =IOU_OK ;
@@ -740,8 +739,7 @@ retry_multishot:if (ret < min_ret) {if (ret == -EAGAIN && force_nonblock) { ret =io_setup_async_msg (req, kmsg, issue_flags); -if (ret == -EAGAIN && (req->flags &IO_APOLL_MULTI_POLLED ) == -IO_APOLL_MULTI_POLLED ) { +if (ret == -EAGAIN && (issue_flags &IO_URING_F_MULTISHOT )) {io_kbuf_recycle (req, issue_flags);return IOU_ISSUE_SKIP_COMPLETE ; }
@@ -770,7 +768,7 @@ retry_multishot:if (kmsg->msg.msg_inq) cflags |=IORING_CQE_F_SOCK_NONEMPTY ; -if (!io_recv_finish (req, &ret, cflags, mshot_finished)) +if (!io_recv_finish (req, &ret, cflags, mshot_finished, issue_flags)) goto retry_multishot;if (mshot_finished) {
@@ -836,7 +834,7 @@ retry_multishot: ret =sock_recvmsg (sock, &msg, flags);if (ret < min_ret) {if (ret == -EAGAIN && force_nonblock) { -if ((req->flags &IO_APOLL_MULTI_POLLED ) ==IO_APOLL_MULTI_POLLED ) { +if (issue_flags &IO_URING_F_MULTISHOT ) {io_kbuf_recycle (req, issue_flags);return IOU_ISSUE_SKIP_COMPLETE ; }
@@ -869,7 +867,7 @@ out_free:if (msg.msg_inq) cflags |=IORING_CQE_F_SOCK_NONEMPTY ; -if (!io_recv_finish (req, &ret, cflags, ret <=0 )) +if (!io_recv_finish (req, &ret, cflags, ret <=0 , issue_flags)) goto retry_multishot;return ret;
Greg Kroah-Hartman
maintainerPATCH 260/314 io_uring: disallow self-propelled ring polling
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
commit 7fdbc5f014c3f71bc44673a2d6c5bb2d12d45f25 upstream.
When we post a CQE we wake all ring pollers as it normally should be. However, if a CQE was generated by a multishot poll request targeting its own ring, it'll wake that request up, which will make it to post a new CQE, which will wake the request and so on until it exhausts all CQ entries.
Don't allow multishot polling io_uring files but downgrade them to oneshots, which was always stated as a correct behaviour that the userspace should check for.
--- io_uring/poll.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/poll.c +2 -0
@@ -244,6 +244,8 @@ static int io_poll_check_events(struct icontinue ;if (req->apoll_events &EPOLLONESHOT )return IOU_POLL_DONE ; +if (io_is_uring_fops (req->file)) +return IOU_POLL_DONE ;/* multishot, just fill a CQE and proceed */ if (!(req->flags &REQ_F_APOLL_MULTISHOT )) {
Greg Kroah-Hartman
maintainerPATCH 261/314 ceph: avoid putting the realm twice when decoding snaps fails
In reply to Greg Kroah-HartmanFrom: Xiubo Li <[email protected]>
commit 51884d153f7ec85e18d607b2467820a90e0f4359 upstream.
When decoding the snaps fails it maybe leaving the 'first_realm' and 'realm' pointing to the same snaprealm memory. And then it'll put it twice and could cause random use-after-free, BUG_ON, etc issues.
--- fs/ceph/snap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/snap.c +2 -1
@@ -763,7 +763,7 @@ int ceph_update_snap_trace(struct ceph_mstruct ceph_mds_snap_realm *ri;/* encoded */ __le64 *snaps;/* encoded */ __le64 *prior_parent_snaps;/* encoded */ -struct ceph_snap_realm *realm =NULL ; +struct ceph_snap_realm *realm;struct ceph_snap_realm *first_realm =NULL ;struct ceph_snap_realm *realm_to_rebuild =NULL ;int rebuild_snapcs;
@@ -774,6 +774,7 @@ int ceph_update_snap_trace(struct ceph_mdout ("%s deletion=%d\n" , __func__, deletion); more: + realm =NULL ; rebuild_snapcs =0 ;ceph_decode_need (&p, e,sizeof (*ri), bad); ri = p;
Greg Kroah-Hartman
maintainerPATCH 262/314 Input: iforce - invert valid length check when fetching device IDs
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
commit b8ebf250997c5fb253582f42bfe98673801ebebd upstream.
syzbot is reporting uninitialized value at iforce_init_device() [1], for commit 6ac0aec6b0a6 ("Input: iforce - allow callers supply data buffer when fetching device IDs") is checking that valid length is shorter than bytes to read. Since iforce_get_id_packet() stores valid length when returning 0, the caller needs to check that valid length is longer than or equals to bytes to read.
--- drivers/input/joystick/iforce/iforce-main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/input/joystick/iforce/iforce-main.c +4 -4
@@ -273,22 +273,22 @@ int iforce_init_device(struct device *pa* Get device info. */ -if (!iforce_get_id_packet (iforce,'M' , buf, &len) || len <3 ) +if (!iforce_get_id_packet (iforce,'M' , buf, &len) && len >=3 ) input_dev->id.vendor =get_unaligned_le16 (buf +1 );else dev_warn (&iforce->dev->dev,"Device does not respond to id packet M\n" ); -if (!iforce_get_id_packet (iforce,'P' , buf, &len) || len <3 ) +if (!iforce_get_id_packet (iforce,'P' , buf, &len) && len >=3 ) input_dev->id.product =get_unaligned_le16 (buf +1 );else dev_warn (&iforce->dev->dev,"Device does not respond to id packet P\n" ); -if (!iforce_get_id_packet (iforce,'B' , buf, &len) || len <3 ) +if (!iforce_get_id_packet (iforce,'B' , buf, &len) && len >=3 ) iforce->device_memory.end =get_unaligned_le16 (buf +1 );else dev_warn (&iforce->dev->dev,"Device does not respond to id packet B\n" ); -if (!iforce_get_id_packet (iforce,'N' , buf, &len) || len <2 ) +if (!iforce_get_id_packet (iforce,'N' , buf, &len) && len >=2 ) ff_effects = buf[1 ];else dev_warn (&iforce->dev->dev,"Device does not respond to id packet N\n" );
Greg Kroah-Hartman
maintainerPATCH 263/314 maccess: Fix writing offset in case of fault in strncpy_from_kernel_nofault()
In reply to Greg Kroah-HartmanFrom: Alban Crequy <[email protected]>
commit 8678ea06852cd1f819b870c773d43df888d15d46 upstream.
If a page fault occurs while copying the first byte, this function resets one byte before dst.
As a consequence, an address could be modified and leaded to kernel crashes if case the modified address was accessed later.
--- mm/maccess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/maccess.c +1 -1
@@ -97,7 +97,7 @@ long strncpy_from_kernel_nofault(char *dreturn src - unsafe_addr; Efault:pagefault_enable (); - dst[-1 ] ='\0' ; + dst[0 ] ='\0' ;return -EFAULT ; }
Greg Kroah-Hartman
maintainerPATCH 264/314 net: phy: marvell: add sleep time after enabling the loopback bit
In reply to Greg Kroah-HartmanFrom: Aminuddin Jamaluddin <[email protected]>
commit 18c532e44939caa17f1fa380f7ac50dbc0718dbb upstream.
Sleep time is added to ensure the phy to be ready after loopback bit was set. This to prevent the phy loopback test from failing.
--- drivers/net/phy/marvell.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/net/phy/marvell.c +9 -7
@@ -2015,14 +2015,16 @@ static int m88e1510_loopback(struct phy_if (err <0 )return err; -/* FIXME: Based on trial and error test, it seem 1G need to have -* delay between soft reset and loopback enablement. -*/ -if (phydev->speed ==SPEED_1000 ) -msleep (1000 ); + err =phy_modify (phydev,MII_BMCR ,BMCR_LOOPBACK , +BMCR_LOOPBACK ); -return phy_modify (phydev,MII_BMCR ,BMCR_LOOPBACK , -BMCR_LOOPBACK ); +if (!err) { +/* It takes some time for PHY device to switch +* into/out-of loopback mode. +*/ +msleep (1000 ); + } +return err; }else { err =phy_modify (phydev,MII_BMCR ,BMCR_LOOPBACK ,0 );if (err <0 )
Greg Kroah-Hartman
maintainerPATCH 265/314 scsi: zfcp: Fix double free of FSF request when qdio send fails
In reply to Greg Kroah-HartmanFrom: Benjamin Block <[email protected]>
commit 0954256e970ecf371b03a6c9af2cf91b9c4085ff upstream.
We used to use the wrong type of integer in 'zfcp_fsf_req_send()' to cache the FSF request ID when sending a new FSF request. This is used in case the sending fails and we need to remove the request from our internal hash table again (so we don't keep an invalid reference and use it when we free the request again).
In 'zfcp_fsf_req_send()' we used to cache the ID as 'int' (signed and 32 bit wide), but the rest of the zfcp code (and the firmware specification) handles the ID as 'unsigned long'/'u64' (unsigned and 64 bit wide [s390x ELF ABI]). For one this has the obvious problem that when the ID grows past 32 bit (this can happen reasonably fast) it is truncated to 32 bit when storing it in the cache variable and so doesn't match the original ID anymore. The second less obvious problem is that even when the original ID has not yet grown past 32 bit, as soon as the 32nd bit is set in the original ID (0x80000000 = 2'147'483'648) we will have a mismatch when we cast it back to 'unsigned long'. As the cached variable is of a signed type, the compiler will choose a sign-extending instruction to load the 32 bit variable into a 64 bit register (e.g.: 'lgf %r11,188(%r15)'). So once we pass the cached variable into 'zfcp_reqlist_find_rm()' to remove the request again all the leading zeros will be flipped to ones to extend the sign and won't match the original ID anymore (this has been observed in practice).
If we can't successfully remove the request from the hash table again after 'zfcp_qdio_send()' fails (this happens regularly when zfcp cannot notify the adapter about new work because the adapter is already gone during e.g. a ChpID toggle) we will end up with a double free. We unconditionally free the request in the calling function when 'zfcp_fsf_req_send()' fails, but because the request is still in the hash table we end up with a stale memory reference, and once the zfcp adapter is either reset during recovery or shutdown we end up freeing the same memory twice.
The resulting stack traces vary depending on the kernel and have no direct correlation to the place where the bug occurs. Here are three examples that have been seen in practice:
list_del corruption. next->prev should be 00000001b9d13800, but was 00000000dead4ead. (next=00000001bd131a00)
------------[ cut here ]------------
kernel BUG at lib/list_debug.c:62!
monitor event: 0040 ilc:2 [#1] PREEMPT SMP
Modules linked in: ...
CPU: 9 PID: 1617 Comm: zfcperp0.0.1740 Kdump: loaded
Hardware name: ...
Krnl PSW : 0704d00180000000 00000003cbeea1f8 (__list_del_entry_valid+0x98/0x140)
R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:1 PM:0 RI:0 EA:3
Krnl GPRS: 00000000916d12f1 0000000080000000 000000000000006d 00000003cb665cd6
0000000000000001 0000000000000000 0000000000000000 00000000d28d21e8
00000000d3844000 00000380099efd28 00000001bd131a00 00000001b9d13800
00000000d3290100 0000000000000000 00000003cbeea1f4 00000380099efc70
Krnl Code: 00000003cbeea1e8: c020004f68a7 larl %r2,00000003cc8d7336
00000003cbeea1ee: c0e50027fd65 brasl %r14,00000003cc3e9cb8
#00000003cbeea1f4: af000000 mc 0,0
>00000003cbeea1f8: c02000920440 larl %r2,00000003cd12aa78
00000003cbeea1fe: c0e500289c25 brasl %r14,00000003cc3fda48
00000003cbeea204: b9040043 lgr %r4,%r3
00000003cbeea208: b9040051 lgr %r5,%r1
00000003cbeea20c: b9040032 lgr %r3,%r2
Call Trace:
[<00000003cbeea1f8>] __list_del_entry_valid+0x98/0x140
([<00000003cbeea1f4>] __list_del_entry_valid+0x94/0x140)
[<000003ff7ff502fe>] zfcp_fsf_req_dismiss_all+0xde/0x150 [zfcp]
[<000003ff7ff49cd0>] zfcp_erp_strategy_do_action+0x160/0x280 [zfcp]
[<000003ff7ff4a22e>] zfcp_erp_strategy+0x21e/0xca0 [zfcp]
[<000003ff7ff4ad34>] zfcp_erp_thread+0x84/0x1a0 [zfcp]
[<00000003cb5eece8>] kthread+0x138/0x150
[<00000003cb557f3c>] __ret_from_fork+0x3c/0x60
[<00000003cc4172ea>] ret_from_fork+0xa/0x40
INFO: lockdep is turned off.
Last Breaking-Event-Address:
[<00000003cc3e9d04>] _printk+0x4c/0x58
Kernel panic - not syncing: Fatal exception: panic_on_oopsor:
Unable to handle kernel pointer dereference in virtual kernel address space
Failing address: 6b6b6b6b6b6b6000 TEID: 6b6b6b6b6b6b6803
Fault in home space mode while using kernel ASCE.
AS:0000000063b10007 R3:0000000000000024
Oops: 0038 ilc:3 [#1] SMP
Modules linked in: ...
CPU: 10 PID: 0 Comm: swapper/10 Kdump: loaded
Hardware name: ...
Krnl PSW : 0404d00180000000 000003ff7febaf8e (zfcp_fsf_reqid_check+0x86/0x158 [zfcp])
R:0 T:1 IO:0 EX:0 Key:0 M:1 W:0 P:0 AS:3 CC:1 PM:0 RI:0 EA:3
Krnl GPRS: 5a6f1cfa89c49ac3 00000000aff2c4c8 6b6b6b6b6b6b6b6b 00000000000002a8
0000000000000000 0000000000000055 0000000000000000 00000000a8515800
0700000000000000 00000000a6e14500 00000000aff2c000 000000008003c44c
000000008093c700 0000000000000010 00000380009ebba8 00000380009ebb48
Krnl Code: 000003ff7febaf7e: a7f4003d brc 15,000003ff7febaff8
000003ff7febaf82: e32020000004 lg %r2,0(%r2)
#000003ff7febaf88: ec2100388064 cgrj %r2,%r1,8,000003ff7febaff8
>000003ff7febaf8e: e3b020100020 cg %r11,16(%r2)
000003ff7febaf94: a774fff7 brc 7,000003ff7febaf82
000003ff7febaf98: ec280030007c cgij %r2,0,8,000003ff7febaff8
000003ff7febaf9e: e31020080004 lg %r1,8(%r2)
000003ff7febafa4: e33020000004 lg %r3,0(%r2)
Call Trace:
[<000003ff7febaf8e>] zfcp_fsf_reqid_check+0x86/0x158 [zfcp]
[<000003ff7febbdbc>] zfcp_qdio_int_resp+0x6c/0x170 [zfcp]
[<000003ff7febbf90>] zfcp_qdio_irq_tasklet+0xd0/0x108 [zfcp]
[<0000000061d90a04>] tasklet_action_common.constprop.0+0xdc/0x128
[<000000006292f300>] __do_softirq+0x130/0x3c0
[<0000000061d906c6>] irq_exit_rcu+0xfe/0x118
[<000000006291e818>] do_io_irq+0xc8/0x168
[<000000006292d516>] io_int_handler+0xd6/0x110
[<000000006292d596>] psw_idle_exit+0x0/0xa
([<0000000061d3be50>] arch_cpu_idle+0x40/0xd0)
[<000000006292ceea>] default_idle_call+0x52/0xf8
[<0000000061de4fa4>] do_idle+0xd4/0x168
[<0000000061de51fe>] cpu_startup_entry+0x36/0x40
[<0000000061d4faac>] smp_start_secondary+0x12c/0x138
[<000000006292d88e>] restart_int_handler+0x6e/0x90
Last Breaking-Event-Address:
[<000003ff7febaf94>] zfcp_fsf_reqid_check+0x8c/0x158 [zfcp]
Kernel panic - not syncing: Fatal exception in interruptor:
Unable to handle kernel pointer dereference in virtual kernel address space
Failing address: 523b05d3ae76a000 TEID: 523b05d3ae76a803
Fault in home space mode while using kernel ASCE.
AS:0000000077c40007 R3:0000000000000024
Oops: 0038 ilc:3 [#1] SMP
Modules linked in: ...
CPU: 3 PID: 453 Comm: kworker/3:1H Kdump: loaded
Hardware name: ...
Workqueue: kblockd blk_mq_run_work_fn
Krnl PSW : 0404d00180000000 0000000076fc0312 (__kmalloc+0xd2/0x398)
R:0 T:1 IO:0 EX:0 Key:0 M:1 W:0 P:0 AS:3 CC:1 PM:0 RI:0 EA:3
Krnl GPRS: ffffffffffffffff 523b05d3ae76abf6 0000000000000000 0000000000092a20
0000000000000002 00000007e49b5cc0 00000007eda8f000 0000000000092a20
00000007eda8f000 00000003b02856b9 00000000000000a8 523b05d3ae76abf6
00000007dd662000 00000007eda8f000 0000000076fc02b2 000003e0037637a0
Krnl Code: 0000000076fc0302: c004000000d4 brcl 0,76fc04aa
0000000076fc0308: b904001b lgr %r1,%r11
#0000000076fc030c: e3106020001a algf %r1,32(%r6)
>0000000076fc0312: e31010000082 xg %r1,0(%r1)
0000000076fc0318: b9040001 lgr %r0,%r1
0000000076fc031c: e30061700082 xg %r0,368(%r6)
0000000076fc0322: ec59000100d9 aghik %r5,%r9,1
0000000076fc0328: e34003b80004 lg %r4,952
Call Trace:
[<0000000076fc0312>] __kmalloc+0xd2/0x398
[<0000000076f318f2>] mempool_alloc+0x72/0x1f8
[<000003ff8027c5f8>] zfcp_fsf_req_create.isra.7+0x40/0x268 [zfcp]
[<000003ff8027f1bc>] zfcp_fsf_fcp_cmnd+0xac/0x3f0 [zfcp]
[<000003ff80280f1a>] zfcp_scsi_queuecommand+0x122/0x1d0 [zfcp]
[<000003ff800b4218>] scsi_queue_rq+0x778/0xa10 [scsi_mod]
[<00000000771782a0>] __blk_mq_try_issue_directly+0x130/0x208
[<000000007717a124>] blk_mq_request_issue_directly+0x4c/0xa8
[<000003ff801302e2>] dm_mq_queue_rq+0x2ea/0x468 [dm_mod]
[<0000000077178c12>] blk_mq_dispatch_rq_list+0x33a/0x818
[<000000007717f064>] __blk_mq_do_dispatch_sched+0x284/0x2f0
[<000000007717f44c>] __blk_mq_sched_dispatch_requests+0x1c4/0x218
[<000000007717fa7a>] blk_mq_sched_dispatch_requests+0x52/0x90
[<0000000077176d74>] __blk_mq_run_hw_queue+0x9c/0xc0
[<0000000076da6d74>] process_one_work+0x274/0x4d0
[<0000000076da7018>] worker_thread+0x48/0x560
[<0000000076daef18>] kthread+0x140/0x160
[<000000007751d144>] ret_from_fork+0x28/0x30
Last Breaking-Event-Address:
[<0000000076fc0474>] __kmalloc+0x234/0x398
Kernel panic - not syncing: Fatal exception: panic_on_oopsTo fix this, simply change the type of the cache variable to 'unsigned long', like the rest of zfcp and also the argument for 'zfcp_reqlist_find_rm()'. This prevents truncation and wrong sign extension and so can successfully remove the request from the hash table.
--- drivers/s390/scsi/zfcp_fsf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/scsi/zfcp_fsf.c +1 -1
@@ -884,7 +884,7 @@ static int zfcp_fsf_req_send(struct zfcpconst bool is_srb =zfcp_fsf_req_is_status_read_buffer (req);struct zfcp_adapter *adapter = req->adapter;struct zfcp_qdio *qdio = adapter->qdio; -int req_id = req->req_id; +unsigned long req_id = req->req_id;zfcp_reqlist_add (adapter->req_list, req);
Greg Kroah-Hartman
maintainerPATCH 266/314 iommu/vt-d: Preset Access bit for IOVA in FL non-leaf paging entries
In reply to Greg Kroah-HartmanFrom: Tina Zhang <[email protected]>
commit 242b0aaeabbe2efbef1b9d42a8e56627e800964c upstream.
The A/D bits are preseted for IOVA over first level(FL) usage for both kernel DMA (i.e, domain typs is IOMMU_DOMAIN_DMA) and user space DMA usage (i.e., domain type is IOMMU_DOMAIN_UNMANAGED).
Presetting A bit in FL requires to preset the bit in every related paging entries, including the non-leaf ones. Otherwise, hardware may treat this as an error. For example, in a case of ECAP_REG.SMPWC==0, DMA faults might occur with below DMAR fault messages (wrapped for line length) dumped.
DMAR: DRHD: handling fault status reg 2
DMAR: [DMA Read NO_PASID] Request device [aa:00.0] fault addr 0x10c3a6000
[fault reason 0x90]
SM: A/D bit update needed in first-level entry when set up in no snoop
--- drivers/iommu/intel/iommu.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/iommu/intel/iommu.c +3 -5
@@ -954,11 +954,9 @@ static struct dma_pte *pfn_to_dma_pte(stdomain_flush_cache (domain, tmp_page,VTD_PAGE_SIZE ); pteval = ((uint64_t )virt_to_dma_pfn (tmp_page) <<VTD_PAGE_SHIFT ) |DMA_PTE_READ |DMA_PTE_WRITE ; -if (domain_use_first_level (domain)) { - pteval |=DMA_FL_PTE_XD |DMA_FL_PTE_US ; -if (iommu_is_dma_domain (&domain->domain)) - pteval |=DMA_FL_PTE_ACCESS ; - } +if (domain_use_first_level (domain)) + pteval |=DMA_FL_PTE_XD |DMA_FL_PTE_US |DMA_FL_PTE_ACCESS ; +if (cmpxchg64 (&pte->val,0ULL , pteval))/* Someone else set it while we were thinking; use theirs. */ free_pgtable_page (tmp_page);
Greg Kroah-Hartman
maintainerPATCH 267/314 iommu/vt-d: Set SRE bit only when hardware has SRS cap
In reply to Greg Kroah-HartmanFrom: Tina Zhang <[email protected]>
commit 7fc961cf7ffcb130c4e93ee9a5628134f9de700a upstream.
SRS cap is the hardware cap telling if the hardware IOMMU can support requests seeking supervisor privilege or not. SRE bit in scalable-mode PASID table entry is treated as Reserved(0) for implementation not supporting SRS cap.
Checking SRS cap before setting SRE bit can avoid the non-recoverable fault of "Non-zero reserved field set in PASID Table Entry" caused by setting SRE bit while there is no SRS cap support. The fault messages look like below:
DMAR: DRHD: handling fault status reg 2
DMAR: [DMA Read NO_PASID] Request device [00:0d.0] fault addr 0x1154e1000
[fault reason 0x5a]
SM: Non-zero reserved field set in PASID Table Entry
--- drivers/iommu/intel/pasid.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iommu/intel/pasid.c +3 -2
@@ -652,7 +652,7 @@ int intel_pasid_setup_second_level(struc* Since it is a second level only translation setup, we should * set SRE bit as well (addresses are expected to be GPAs). */ -if (pasid !=PASID_RID2PASID ) +if (pasid !=PASID_RID2PASID &&ecap_srs (iommu->ecap))pasid_set_sre (pte);pasid_set_present (pte);spin_unlock (&iommu->lock);
@@ -695,7 +695,8 @@ int intel_pasid_setup_pass_through(struc* We should set SRE bit as well since the addresses are expected * to be GPAs. */ -pasid_set_sre (pte); +if (ecap_srs (iommu->ecap)) +pasid_set_sre (pte);pasid_set_present (pte);spin_unlock (&iommu->lock);
Greg Kroah-Hartman
maintainerPATCH 268/314 firmware: coreboot: Register bus in module init
In reply to Greg Kroah-HartmanFrom: Brian Norris <[email protected]>
commit 65946690ed8d972fdb91a74ee75ac0f0f0d68321 upstream.
The coreboot_table driver registers a coreboot bus while probing a "coreboot_table" device representing the coreboot table memory region. Probing this device (i.e., registering the bus) is a dependency for the module_init() functions of any driver for this bus (e.g., memconsole-coreboot.c / memconsole_driver_init()).
With synchronous probe, this dependency works OK, as the link order in the Makefile ensures coreboot_table_driver_init() (and thus, coreboot_table_probe()) completes before a coreboot device driver tries to add itself to the bus.
With asynchronous probe, however, coreboot_table_probe() may race with memconsole_driver_init(), and so we're liable to hit one of these two:
1. coreboot_driver_register() eventually hits "[...] the bus was not initialized.", and the memconsole driver fails to register; or
2. coreboot_driver_register() gets past #1, but still races with bus_register() and hits some other undefined/crashing behavior (e.g., in driver_find() [1])
We can resolve this by registering the bus in our initcall, and only deferring "device" work (scanning the coreboot memory region and creating sub-devices) to probe().
[1] Example failure, using 'driver_async_probe=*' kernel command line:
[ 0.114217] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010 ... [ 0.114307] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.1.0-rc1 #63 [ 0.114316] Hardware name: Google Scarlet (DT) ... [ 0.114488] Call trace: [ 0.114494] _raw_spin_lock+0x34/0x60 [ 0.114502] kset_find_obj+0x28/0x84 [ 0.114511] driver_find+0x30/0x50 [ 0.114520] driver_register+0x64/0x10c [ 0.114528] coreboot_driver_register+0x30/0x3c [ 0.114540] memconsole_driver_init+0x24/0x30 [ 0.114550] do_one_initcall+0x154/0x2e0 [ 0.114560] do_initcall_level+0x134/0x160 [ 0.114571] do_initcalls+0x60/0xa0 [ 0.114579] do_basic_setup+0x28/0x34 [ 0.114588] kernel_init_freeable+0xf8/0x150 [ 0.114596] kernel_init+0x2c/0x12c [ 0.114607] ret_from_fork+0x10/0x20 [ 0.114624] Code: 5280002b 1100054a b900092a f9800011 (885ffc01) [ 0.114631] ---[ end trace 0000000000000000 ]---
--- drivers/firmware/google/coreboot_table.c | 37 ++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-)
drivers/firmware/google/coreboot_table.c +29 -8
@@ -149,12 +149,8 @@ static int coreboot_table_probe(struct pif (!ptr)return -ENOMEM ; - ret =bus_register (&coreboot_bus_type); -if (!ret) { - ret =coreboot_table_populate (dev, ptr); -if (ret) -bus_unregister (&coreboot_bus_type); - } + ret =coreboot_table_populate (dev, ptr); +memunmap (ptr);return ret;
@@ -169,7 +165,6 @@ static int __cb_dev_unregister(struct destatic int coreboot_table_remove (struct platform_device *pdev) {bus_for_each_dev (&coreboot_bus_type,NULL ,NULL , __cb_dev_unregister); -bus_unregister (&coreboot_bus_type);return 0 ; }
@@ -199,6 +194,32 @@ static struct platform_driver coreboot_t .of_match_table = of_match_ptr(coreboot_of_match), }, }; -module_platform_driver (coreboot_table_driver); + +static int __init coreboot_table_driver_init (void ) +{ +int ret; + + ret =bus_register (&coreboot_bus_type); +if (ret) +return ret; + + ret =platform_driver_register (&coreboot_table_driver); +if (ret) { +bus_unregister (&coreboot_bus_type); +return ret; + } + +return 0 ; +} + +static void __exit coreboot_table_driver_exit(void) +{ +platform_driver_unregister (&coreboot_table_driver); +bus_unregister (&coreboot_bus_type); +} + +module_init (coreboot_table_driver_init); +module_exit (coreboot_table_driver_exit); +MODULE_AUTHOR ("Google, Inc." );MODULE_LICENSE ("GPL" );
Greg Kroah-Hartman
maintainerPATCH 269/314 mmc: core: properly select voltage range without power cycle
In reply to Greg Kroah-HartmanFrom: Yann Gautier <[email protected]>
commit 39a72dbfe188291b156dd6523511e3d5761ce775 upstream.
In mmc_select_voltage(), if there is no full power cycle, the voltage range selected at the end of the function will be on a single range (e.g. 3.3V/3.4V). To keep a range around the selected voltage (3.2V/3.4V), the mask shift should be reduced by 1.
This issue was triggered by using a specific SD-card (Verbatim Premium 16GB UHS-1) on an STM32MP157C-DK2 board. This board cannot do UHS modes and there is no power cycle. And the card was failing to switch to high-speed mode. When adding the range 3.2V/3.3V for this card with the proposed shift change, the card can switch to high-speed mode.
--- drivers/mmc/core/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mmc/core/core.c +7 -1
@@ -1134,7 +1134,13 @@ u32 mmc_select_voltage(struct mmc_host *mmc_power_cycle (host, ocr); }else { bit =fls (ocr) -1 ; - ocr &=3 << bit; +/* +* The bit variable represents the highest voltage bit set in +* the OCR register. +* To keep a range of 2 values (e.g. 3.2V/3.3V and 3.3V/3.4V), +* we must shift the mask '3' with (bit - 1). +*/ + ocr &=3 << (bit -1 );if (bit != host->ios.vdd)dev_warn (mmc_dev (host),"exceeding card's volts\n" ); }
Greg Kroah-Hartman
maintainerPATCH 270/314 mmc: sdhci-pci-o2micro: fix card detect fail issue caused by CD# debounce timeout
In reply to Greg Kroah-HartmanFrom: Chevron Li <[email protected]>
commit 096cc0cddf58232bded309336961784f1d1c85f8 upstream.
The SD card is recognized failed sometimes when resume from suspend. Because CD# debounce time too long then card present report wrong. Finally, card is recognized failed.
--- drivers/mmc/host/sdhci-pci-o2micro.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mmc/host/sdhci-pci-o2micro.c +7 -0
@@ -32,6 +32,7 @@#define O2_SD_CAPS 0xE0#define O2_SD_ADMA1 0xE2#define O2_SD_ADMA2 0xE7 +#define O2_SD_MISC_CTRL2 0xF0#define O2_SD_INF_MOD 0xF1#define O2_SD_MISC_CTRL4 0xFC#define O2_SD_MISC_CTRL 0x1C0
@@ -874,6 +875,12 @@ static int sdhci_pci_o2_probe(struct sdh/* Set Tuning Windows to 5 */ pci_write_config_byte (chip->pdev,O2_SD_TUNING_CTRL ,0x55 ); +//Adjust 1st and 2nd CD debounce time +pci_read_config_dword (chip->pdev,O2_SD_MISC_CTRL2 , &scratch_32); + scratch_32 &=0xFFE7FFFF ; + scratch_32 |=0x00180000 ; +pci_write_config_dword (chip->pdev,O2_SD_MISC_CTRL2 , scratch_32); +pci_write_config_dword (chip->pdev,O2_SD_DETECT_SETTING ,1 );/* Lock WP */ ret =pci_read_config_byte (chip->pdev,O2_SD_LOCK_WP , &scratch);
Greg Kroah-Hartman
maintainerPATCH 271/314 mmc: sdhci-pci: Fix possible memory leak caused by missing pci_dev_put()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
commit 222cfa0118aa68687ace74aab8fdf77ce8fbd7e6 upstream.
pci_get_device() will increase the reference count for the returned pci_dev. We need to use pci_dev_put() to decrease the reference count before amd_probe() returns. There is no problem for the 'smbus_dev == NULL' branch because pci_dev_put() can also handle the NULL input parameter case.
--- drivers/mmc/host/sdhci-pci-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mmc/host/sdhci-pci-core.c +2 -0
@@ -1728,6 +1728,8 @@ static int amd_probe(struct sdhci_pci_ch } } +pci_dev_put (smbus_dev); +if (gen ==AMD_CHIPSET_BEFORE_ML || gen ==AMD_CHIPSET_CZ ) chip->quirks2 |=SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD ;
Greg Kroah-Hartman
maintainerPATCH 272/314 docs: update mediator contact information in CoC doc
In reply to Greg Kroah-HartmanFrom: Shuah Khan <[email protected]>
commit 5fddf8962b429b8303c4a654291ecb6e61a7d747 upstream.
Update mediator contact information in CoC interpretation document.
--- Documentation/process/code-of-conduct-interpretation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/process/code-of-conduct-interpretation.rst +1 -1
@@ -51,7 +51,7 @@ the Technical Advisory Board (TAB) or ot uncertain how to handle situations that come up. It will not be considered a violation report unless you want it to be. If you are uncertain about approaching the TAB or any other maintainers, please -reach out to our conflict mediator, Joanna Lee <[email protected]>. +reach out to our conflict mediator, Joanna Lee <[email protected]>. In the end, "be kind to each other" is really what the end goal is for everybody. We know everyone is human and we all fail at times, but the
Greg Kroah-Hartman
maintainerPATCH 273/314 docs/driver-api/miscellaneous: Remove kernel-doc of serial_core.c
In reply to Greg Kroah-HartmanFrom: Akira Yokosawa <[email protected]>
commit 3ec17cb325ac731c2211e13f7eaa4b812694e218 upstream.
Since merge of tty-6.0-rc1, "make htmldocs" with Sphinx >=3.1 emits a bunch of warnings indicating duplicate kernel-doc comments from drivers/tty/serial/serial_core.c.
This is due to the kernel-doc directive for serial_core.c in serial/drivers.rst added in the merge. It conflicts with an existing kernel-doc directive in miscellaneous.rst.
Remove the latter directive and resolve the duplicates.
--- Documentation/driver-api/miscellaneous.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Documentation/driver-api/miscellaneous.rst +2 -3
@@ -16,12 +16,11 @@ Parallel Port Devices 16x50 UART Driver ================= -.. kernel-doc:: drivers/tty/serial/serial_core.c - :export: - .. kernel-doc:: drivers/tty/serial/8250/8250_core.c :export: +See serial/driver.rst for related APIs. + Pulse-Width Modulation (PWM) ============================
Signature · 1 line
2.38.1
Greg Kroah-Hartman
maintainerPATCH 274/314 s390/dcssblk: fix deadlock when adding a DCSS
In reply to Greg Kroah-HartmanFrom: Gerald Schaefer <[email protected]>
commit a41a11b4009580edb6e2b4c76e5e2ee303f87157 upstream.
After the rework from commit 1ebe2e5f9d68 ("block: remove GENHD_FL_EXT_DEVT"), when calling device_add_disk(), dcssblk will end up in disk_scan_partitions(), and not break out early w/o GENHD_FL_NO_PART. This will trigger implicit open/release via blkdev_get/put_whole() later. dcssblk_release() will then deadlock on dcssblk_devices_sem semaphore, which is already held from dcssblk_add_store() when calling device_add_disk().
dcssblk does not support partitions (DCSSBLK_MINORS_PER_DISK == 1), and never scanned partitions before. Therefore restore the previous behavior, and explicitly disallow partition scanning by setting the GENHD_FL_NO_PART flag. This will also prevent this deadlock scenario.
--- drivers/s390/block/dcssblk.c | 1 + 1 file changed, 1 insertion(+)
drivers/s390/block/dcssblk.c +1 -0
@@ -636,6 +636,7 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char dev_info->gd->minors =DCSSBLK_MINORS_PER_DISK ; dev_info->gd->fops = &dcssblk_devops; dev_info->gd->private_data = dev_info; + dev_info->gd->flags |=GENHD_FL_NO_PART ;blk_queue_logical_block_size (dev_info->gd->queue,4096 );blk_queue_flag_set (QUEUE_FLAG_DAX , dev_info->gd->queue);
Signature · 1 line
2.38.1
Greg Kroah-Hartman
maintainerPATCH 275/314 misc/vmw_vmci: fix an infoleak in vmci_host_do_receive_datagram()
In reply to Greg Kroah-HartmanFrom: Alexander Potapenko <[email protected]>
commit e5b0d06d9b10f5f43101bd6598b076c347f9295f upstream.
struct vmci_event_qp allocated by qp_notify_peer() contains padding, which may carry uninitialized data to the userspace, as observed by KMSAN:
BUG: KMSAN: kernel-infoleak in instrument_copy_to_user ./include/linux/instrumented.h:121 instrument_copy_to_user ./include/linux/instrumented.h:121 _copy_to_user+0x5f/0xb0 lib/usercopy.c:33 copy_to_user ./include/linux/uaccess.h:169 vmci_host_do_receive_datagram drivers/misc/vmw_vmci/vmci_host.c:431 vmci_host_unlocked_ioctl+0x33d/0x43d0 drivers/misc/vmw_vmci/vmci_host.c:925 vfs_ioctl fs/ioctl.c:51 ...
Uninit was stored to memory at:
kmemdup+0x74/0xb0 mm/util.c:131 dg_dispatch_as_host drivers/misc/vmw_vmci/vmci_datagram.c:271 vmci_datagram_dispatch+0x4f8/0xfc0 drivers/misc/vmw_vmci/vmci_datagram.c:339 qp_notify_peer+0x19a/0x290 drivers/misc/vmw_vmci/vmci_queue_pair.c:1479 qp_broker_attach drivers/misc/vmw_vmci/vmci_queue_pair.c:1662 qp_broker_alloc+0x2977/0x2f30 drivers/misc/vmw_vmci/vmci_queue_pair.c:1750 vmci_qp_broker_alloc+0x96/0xd0 drivers/misc/vmw_vmci/vmci_queue_pair.c:1940 vmci_host_do_alloc_queuepair drivers/misc/vmw_vmci/vmci_host.c:488 vmci_host_unlocked_ioctl+0x24fd/0x43d0 drivers/misc/vmw_vmci/vmci_host.c:927 ...
Local variable ev created at:
qp_notify_peer+0x54/0x290 drivers/misc/vmw_vmci/vmci_queue_pair.c:1456 qp_broker_attach drivers/misc/vmw_vmci/vmci_queue_pair.c:1662 qp_broker_alloc+0x2977/0x2f30 drivers/misc/vmw_vmci/vmci_queue_pair.c:1750
Bytes 28-31 of 48 are uninitialized
Memory access of size 48 starts at ffff888035155e00 Data copied to user address 0000000020000100
Use memset() to prevent the infoleaks.
Also speculatively fix qp_notify_peer_local(), which may suffer from the same problem.
--- drivers/misc/vmw_vmci/vmci_queue_pair.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/misc/vmw_vmci/vmci_queue_pair.c +2 -0
@@ -854,6 +854,7 @@ static int qp_notify_peer_local(bool attu32 context_id =vmci_get_context_id ();struct vmci_event_qp ev; +memset (&ev,0 ,sizeof (ev)); ev.msg.hdr.dst =vmci_make_handle (context_id,VMCI_EVENT_HANDLER ); ev.msg.hdr.src =vmci_make_handle (VMCI_HYPERVISOR_CONTEXT_ID ,VMCI_CONTEXT_RESOURCE_ID );
@@ -1467,6 +1468,7 @@ static int qp_notify_peer(bool attach,* kernel. */ +memset (&ev,0 ,sizeof (ev)); ev.msg.hdr.dst =vmci_make_handle (peer_id,VMCI_EVENT_HANDLER ); ev.msg.hdr.src =vmci_make_handle (VMCI_HYPERVISOR_CONTEXT_ID ,VMCI_CONTEXT_RESOURCE_ID );
Greg Kroah-Hartman
maintainerPATCH 276/314 blk-cgroup: properly pin the parent in blkcg_css_online
In reply to Greg Kroah-HartmanFrom: Chris Mason <[email protected]>
commit d7dbd43f4a828fa1d9a8614d5b0ac40aee6375fe upstream.
blkcg_css_online is supposed to pin the blkcg of the parent, but 397c9f46ee4d refactored things and along the way, changed it to pin the css instead. This results in extra pins, and we end up leaking blkcgs and cgroups.
--- block/blk-cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-cgroup.c +1 -1
@@ -1251,7 +1251,7 @@ static int blkcg_css_online(struct cgrou* parent so that offline always happens towards the root. */ if (parent) -blkcg_pin_online (css); +blkcg_pin_online (&parent->css);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 277/314 x86/sgx: Add overflow check in sgx_validate_offset_length()
In reply to Greg Kroah-HartmanFrom: Borys Popławski <[email protected]>
commit f0861f49bd946ff94fce4f82509c45e167f63690 upstream.
sgx_validate_offset_length() function verifies "offset" and "length" arguments provided by userspace, but was missing an overflow check on their addition. Add it.
--- arch/x86/kernel/cpu/sgx/ioctl.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kernel/cpu/sgx/ioctl.c +3 -0
@@ -356,6 +356,9 @@ static int sgx_validate_offset_length(stif (!length || !IS_ALIGNED (length,PAGE_SIZE ))return -EINVAL ; +if (offset + length < offset) +return -EINVAL ; +if (offset + length -PAGE_SIZE >= encl->size)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 278/314 x86/fpu: Drop fpregs lock before inheriting FPU permissions
In reply to Greg Kroah-HartmanFrom: Mel Gorman <[email protected]>
commit 36b038791e1e2baea892e9276588815fd14894b4 upstream.
Mike Galbraith reported the following against an old fork of preempt-rt but the same issue also applies to the current preempt-rt tree.
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: systemd
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:
fpu_clone
CPU: 6 PID: 1 Comm: systemd Tainted: G E (unreleased)
Call Trace:
<TASK>
dump_stack_lvl
? fpu_clone
__might_resched
rt_spin_lock
fpu_clone
? copy_thread
? copy_process
? shmem_alloc_inode
? kmem_cache_alloc
? kernel_clone
? __do_sys_clone
? do_syscall_64
? __x64_sys_rt_sigprocmask
? syscall_exit_to_user_mode
? do_syscall_64
? syscall_exit_to_user_mode
? do_syscall_64
? syscall_exit_to_user_mode
? do_syscall_64
? exc_page_fault
? entry_SYSCALL_64_after_hwframe
</TASK>Mike says:
The splat comes from fpu_inherit_perms() being called under fpregs_lock(), and us reaching the spin_lock_irq() therein due to fpu_state_size_dynamic() returning true despite static key __fpu_state_size_dynamic having never been enabled.
Mike's assessment looks correct. fpregs_lock on a PREEMPT_RT kernel disables preemption so calling spin_lock_irq() in fpu_inherit_perms() is unsafe. This problem exists since commit
9e798e9aa14c ("x86/fpu: Prepare fpu_clone() for dynamically enabled features").
Even though the original bug report should not have enabled the paths at all, the bug still exists.
fpregs_lock is necessary when editing the FPU registers or a task's FP state but it is not necessary for fpu_inherit_perms(). The only write of any FP state in fpu_inherit_perms() is for the new child which is not running yet and cannot context switch or be borrowed by a kernel thread yet. Hence, fpregs_lock is not protecting anything in the new child until clone() completes and can be dropped earlier. The siglock still needs to be acquired by fpu_inherit_perms() as the read of the parent's permissions has to be serialised.
[ bp: Cleanup splat. ]
--- arch/x86/kernel/fpu/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/fpu/core.c +1 -1
@@ -605,9 +605,9 @@ int fpu_clone(struct task_struct *dst, unsigned long clone_flags, bool minimal)if (test_thread_flag (TIF_NEED_FPU_LOAD ))fpregs_restore_userregs ();save_fpregs_to_fpstate (dst_fpu); +fpregs_unlock ();if (!(clone_flags &CLONE_THREAD ))fpu_inherit_perms (dst_fpu); -fpregs_unlock ();/* * Children never inherit PASID state.
Signature · 1 line
2.38.1
Greg Kroah-Hartman
maintainerPATCH 279/314 perf/x86/amd/uncore: Fix memory leak for events array
In reply to Greg Kroah-HartmanFrom: Sandipan Das <[email protected]>
commit bdfe34597139cfcecd47a2eb97fea44d77157491 upstream.
When a CPU comes online, the per-CPU NB and LLC uncore contexts are freed but not the events array within the context structure. This causes a memory leak as identified by the kmemleak detector.
[...]
unreferenced object 0xffff8c5944b8e320 (size 32):
comm "swapper/0", pid 1, jiffies 4294670387 (age 151.072s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<000000000759fb79>] amd_uncore_cpu_up_prepare+0xaf/0x230
[<00000000ddc9e126>] cpuhp_invoke_callback+0x2cf/0x470
[<0000000093e727d4>] cpuhp_issue_call+0x14d/0x170
[<0000000045464d54>] __cpuhp_setup_state_cpuslocked+0x11e/0x330
[<0000000069f67cbd>] __cpuhp_setup_state+0x6b/0x110
[<0000000015365e0f>] amd_uncore_init+0x260/0x321
[<00000000089152d2>] do_one_initcall+0x3f/0x1f0
[<000000002d0bd18d>] kernel_init_freeable+0x1ca/0x212
[<0000000030be8dde>] kernel_init+0x11/0x120
[<0000000059709e59>] ret_from_fork+0x22/0x30
unreferenced object 0xffff8c5944b8dd40 (size 64):
comm "swapper/0", pid 1, jiffies 4294670387 (age 151.072s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000306efe8b>] amd_uncore_cpu_up_prepare+0x183/0x230
[<00000000ddc9e126>] cpuhp_invoke_callback+0x2cf/0x470
[<0000000093e727d4>] cpuhp_issue_call+0x14d/0x170
[<0000000045464d54>] __cpuhp_setup_state_cpuslocked+0x11e/0x330
[<0000000069f67cbd>] __cpuhp_setup_state+0x6b/0x110
[<0000000015365e0f>] amd_uncore_init+0x260/0x321
[<00000000089152d2>] do_one_initcall+0x3f/0x1f0
[<000000002d0bd18d>] kernel_init_freeable+0x1ca/0x212
[<0000000030be8dde>] kernel_init+0x11/0x120
[<0000000059709e59>] ret_from_fork+0x22/0x30[...]
Fix the problem by freeing the events array before freeing the uncore context.
--- arch/x86/events/amd/uncore.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/events/amd/uncore.c +1 -0
@@ -553,6 +553,7 @@ static void uncore_clean_online(void)hlist_for_each_entry_safe (uncore, n, &uncore_unused_list, node) {hlist_del (&uncore->node); +kfree (uncore->events);kfree (uncore); } }
Signature · 1 line
2.38.1
Greg Kroah-Hartman
maintainerPATCH 280/314 perf/x86/intel/pt: Fix sampling using single range output
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit ce0d998be9274dd3a3d971cbeaa6fe28fd2c3062 upstream.
Deal with errata TGL052, ADL037 and RPL017 "Trace May Contain Incorrect Data When Configured With Single Range Output Larger Than 4KB" by disabling single range output whenever larger than 4KB.
--- arch/x86/events/intel/pt.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/x86/events/intel/pt.c +9 -0
@@ -1263,6 +1263,15 @@ static int pt_buffer_try_single(struct pif (1 << order != nr_pages) goto out; +/* +* Some processors cannot always support single range for more than +* 4KB - refer errata TGL052, ADL037 and RPL017. Future processors might +* also be affected, so for now rather than trying to keep track of +* which ones, just disable it for all. +*/ +if (nr_pages >1 ) + goto out; + buf->single = true; buf->nr_pages = nr_pages; ret =0 ;
Greg Kroah-Hartman
maintainerPATCH 281/314 nvme: restrict management ioctls to admin
In reply to Greg Kroah-HartmanFrom: Keith Busch <[email protected]>
commit 23e085b2dead13b51fe86d27069895b740f749c0 upstream.
The passthrough commands already have this restriction, but the other operations do not. Require the same capabilities for all users as all of these operations, which include resets and rescans, can be disruptive.
--- drivers/nvme/host/ioctl.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/nvme/host/ioctl.c +6 -0
@@ -764,11 +764,17 @@ long nvme_dev_ioctl(struct file *file, ucase NVME_IOCTL_IO_CMD :return nvme_dev_user_cmd (ctrl, argp);case NVME_IOCTL_RESET : +if (!capable (CAP_SYS_ADMIN )) +return -EACCES ;dev_warn (ctrl->device,"resetting controller\n" );return nvme_reset_ctrl_sync (ctrl);case NVME_IOCTL_SUBSYS_RESET : +if (!capable (CAP_SYS_ADMIN )) +return -EACCES ;return nvme_reset_subsystem (ctrl);case NVME_IOCTL_RESCAN : +if (!capable (CAP_SYS_ADMIN )) +return -EACCES ;nvme_queue_scan (ctrl);return 0 ;default :
Greg Kroah-Hartman
maintainerPATCH 282/314 nvme: ensure subsystem reset is single threaded
In reply to Greg Kroah-HartmanFrom: Keith Busch <[email protected]>
commit 1e866afd4bcdd01a70a5eddb4371158d3035ce03 upstream.
The subsystem reset writes to a register, so we have to ensure the device state is capable of handling that otherwise the driver may access unmapped registers. Use the state machine to ensure the subsystem reset doesn't try to write registers on a device already undergoing this type of reset.
--- drivers/nvme/host/nvme.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/nvme/host/nvme.h +13 -3
@@ -602,11 +602,23 @@ static inline void nvme_fault_inject_finstatic inline void nvme_should_fail (struct request *req) {}#endif +bool nvme_wait_reset (struct nvme_ctrl *ctrl); +int nvme_try_sched_reset (struct nvme_ctrl *ctrl); +static inline int nvme_reset_subsystem (struct nvme_ctrl *ctrl) { +int ret; +if (!ctrl->subsystem)return -ENOTTY ; -return ctrl->ops->reg_write32 (ctrl,NVME_REG_NSSR ,0x4E564D65 ); +if (!nvme_wait_reset (ctrl)) +return -EBUSY ; + + ret = ctrl->ops->reg_write32 (ctrl,NVME_REG_NSSR ,0x4E564D65 ); +if (ret) +return ret; + +return nvme_try_sched_reset (ctrl); }/*
@@ -712,7 +724,6 @@ void nvme_cancel_tagset(struct nvme_ctrlvoid nvme_cancel_admin_tagset (struct nvme_ctrl *ctrl);bool nvme_change_ctrl_state (struct nvme_ctrl *ctrl,enum nvme_ctrl_state new_state); -bool nvme_wait_reset (struct nvme_ctrl *ctrl);int nvme_disable_ctrl (struct nvme_ctrl *ctrl);int nvme_enable_ctrl (struct nvme_ctrl *ctrl);int nvme_shutdown_ctrl (struct nvme_ctrl *ctrl);
@@ -802,7 +813,6 @@ int nvme_set_queue_count(struct nvme_ctrvoid nvme_stop_keep_alive (struct nvme_ctrl *ctrl);int nvme_reset_ctrl (struct nvme_ctrl *ctrl);int nvme_reset_ctrl_sync (struct nvme_ctrl *ctrl); -int nvme_try_sched_reset (struct nvme_ctrl *ctrl);int nvme_delete_ctrl (struct nvme_ctrl *ctrl);void nvme_queue_scan (struct nvme_ctrl *ctrl); int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
Greg Kroah-Hartman
maintainerPATCH 283/314 ASoC: SOF: topology: No need to assign core ID if token parsing failed
In reply to Greg Kroah-HartmanFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit 3d59eaef49ca2db581156a7b77c9afc0546eefc0 ]
Move the return value check before attempting to assign the core ID to the swidget since we are going to fail the sof_widget_ready() and free up swidget anyways.
--- sound/soc/sof/topology.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
sound/soc/sof/topology.c +10 -10
@@ -1346,16 +1346,6 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,break ; } -if (sof_debug_check_flag (SOF_DBG_DISABLE_MULTICORE )) { - swidget->core =SOF_DSP_PRIMARY_CORE ; - }else { -int core =sof_get_token_value (SOF_TKN_COMP_CORE_ID , swidget->tuples, - swidget->num_tuples); - -if (core >=0 ) - swidget->core = core; - } -/* check token parsing reply */ if (ret <0 ) { dev_err(scomp->dev,
@@ -1367,6 +1357,16 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,return ret; } +if (sof_debug_check_flag (SOF_DBG_DISABLE_MULTICORE )) { + swidget->core =SOF_DSP_PRIMARY_CORE ; + }else { +int core =sof_get_token_value (SOF_TKN_COMP_CORE_ID , swidget->tuples, + swidget->num_tuples); + +if (core >=0 ) + swidget->core = core; + } +/* bind widget to external event */ if (tw->event_type) {if (widget_ops[w->id].bind_event) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 284/314 perf: Improve missing SIGTRAP checking
In reply to Greg Kroah-HartmanFrom: Marco Elver <[email protected]>
[ Upstream commit bb88f9695460bec25aa30ba9072595025cf6c8af ]
To catch missing SIGTRAP we employ a WARN in __perf_event_overflow(), which fires if pending_sigtrap was already set: returning to user space without consuming pending_sigtrap, and then having the event fire again would re-enter the kernel and trigger the WARN.
This, however, seemed to miss the case where some events not associated with progress in the user space task can fire and the interrupt handler runs before the IRQ work meant to consume pending_sigtrap (and generate the SIGTRAP).
syzbot gifted us this stack trace:
| WARNING: CPU: 0 PID: 3607 at kernel/events/core.c:9313 __perf_event_overflow | Modules linked in: | CPU: 0 PID: 3607 Comm: syz-executor100 Not tainted 6.1.0-rc2-syzkaller-00073-g88619e77b33d #0 | Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/11/2022 | RIP: 0010:__perf_event_overflow+0x498/0x540 kernel/events/core.c:9313 | <...> | Call Trace: | <TASK> | perf_swevent_hrtimer+0x34f/0x3c0 kernel/events/core.c:10729 | __run_hrtimer kernel/time/hrtimer.c:1685 [inline] | __hrtimer_run_queues+0x1c6/0xfb0 kernel/time/hrtimer.c:1749 | hrtimer_interrupt+0x31c/0x790 kernel/time/hrtimer.c:1811 | local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1096 [inline] | __sysvec_apic_timer_interrupt+0x17c/0x640 arch/x86/kernel/apic/apic.c:1113 | sysvec_apic_timer_interrupt+0x40/0xc0 arch/x86/kernel/apic/apic.c:1107 | asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:649 | <...> | </TASK>
In this case, syzbot produced a program with event type PERF_TYPE_SOFTWARE and config PERF_COUNT_SW_CPU_CLOCK. The hrtimer manages to fire again before the IRQ work got a chance to run, all while never having returned to user space.
Improve the WARN to check for real progress in user space: approximate this by storing a 32-bit hash of the current IP into pending_sigtrap, and if an event fires while pending_sigtrap still matches the previous IP, we assume no progress (false negatives are possible given we could return to user space and trigger again on the same IP).
--- kernel/events/core.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
kernel/events/core.c +19 -6
@@ -9282,14 +9282,27 @@ static int __perf_event_overflow(struct perf_event *event, }if (event->attr.sigtrap) { -/* -* Should not be able to return to user space without processing -* pending_sigtrap (kernel events can overflow multiple times). -*/ -WARN_ON_ONCE (event->pending_sigtrap && event->attr.exclude_kernel); +unsigned int pending_id =1 ; + +if (regs) + pending_id =hash32_ptr ((void *)instruction_pointer (regs)) ?:1 ;if (!event->pending_sigtrap) { - event->pending_sigtrap =1 ; + event->pending_sigtrap = pending_id;local_inc (&event->ctx->nr_pending); + }else if (event->attr.exclude_kernel) { +/* +* Should not be able to return to user space without +* consuming pending_sigtrap; with exceptions: +* +* 1. Where !exclude_kernel, events can overflow again +* in the kernel without returning to user space. +* +* 2. Events that can overflow again before the IRQ- +* work without user space progress (e.g. hrtimer). +* To approximate progress (with false negatives), +* check 32-bit hash of the current IP. +*/ +WARN_ON_ONCE (event->pending_sigtrap != pending_id); } event->pending_addr = data->addr;irq_work_queue (&event->pending_irq);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 285/314 vfio: Rename vfio_ioctl_check_extension()
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 1408640d578887d7860737221043d91fc6d5a723 ]
To vfio_container_ioctl_check_extension().
A following patch will turn this into a non-static function, make it clear it is related to the container.
Stable-dep-of: 7fdba0011157 ("vfio: Fix container device registration life cycle")
--- drivers/vfio/vfio_main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/vfio/vfio_main.c +6 -5
@@ -710,8 +710,9 @@ EXPORT_SYMBOL_GPL(vfio_unregister_group_dev);/* * VFIO base fd, /dev/vfio/vfio */ -static long vfio_ioctl_check_extension (struct vfio_container *container, -unsigned long arg) +static long +vfio_container_ioctl_check_extension (struct vfio_container *container, +unsigned long arg) {struct vfio_iommu_driver *driver;long ret =0 ;
@@ -868,7 +869,7 @@ static long vfio_fops_unl_ioctl(struct file *filep, ret =VFIO_API_VERSION ;break ;case VFIO_CHECK_EXTENSION : - ret =vfio_ioctl_check_extension (container, arg); + ret =vfio_container_ioctl_check_extension (container, arg);break ;case VFIO_SET_IOMMU : ret =vfio_ioctl_set_iommu (container, arg);
@@ -1763,8 +1764,8 @@ bool vfio_file_enforced_coherent(struct file *file)down_read (&group->group_rwsem);if (group->container) { - ret =vfio_ioctl_check_extension (group->container, -VFIO_DMA_CC_IOMMU ); + ret =vfio_container_ioctl_check_extension (group->container, +VFIO_DMA_CC_IOMMU ); }else {/* * Since the coherency state is determined only once a container
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 286/314 vfio: Split the register_device ops call into functions
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 9446162e740aefff95c324ac0887f0b68c739695 ]
This is a container item.
A following patch will move the vfio_container functions to their own .c file.
Stable-dep-of: 7fdba0011157 ("vfio: Fix container device registration life cycle")
--- drivers/vfio/vfio_main.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
drivers/vfio/vfio_main.c +23 -16
@@ -1086,9 +1086,28 @@ static void vfio_device_unassign_container(struct vfio_device *device)up_write (&device->group->group_rwsem); } +static void vfio_device_container_register (struct vfio_device *device) +{ +struct vfio_iommu_driver *iommu_driver = + device->group->container->iommu_driver; + +if (iommu_driver && iommu_driver->ops->register_device) + iommu_driver->ops->register_device ( + device->group->container->iommu_data, device); +} + +static void vfio_device_container_unregister (struct vfio_device *device) +{ +struct vfio_iommu_driver *iommu_driver = + device->group->container->iommu_driver; + +if (iommu_driver && iommu_driver->ops->unregister_device) + iommu_driver->ops->unregister_device ( + device->group->container->iommu_data, device); +} +static struct file *vfio_device_open (struct vfio_device *device) { -struct vfio_iommu_driver *iommu_driver;struct file *filep;int ret;
@@ -1119,12 +1138,7 @@ static struct file *vfio_device_open(struct vfio_device *device)if (ret) goto err_undo_count; } - - iommu_driver = device->group->container->iommu_driver; -if (iommu_driver && iommu_driver->ops->register_device) - iommu_driver->ops->register_device ( - device->group->container->iommu_data, device); - +vfio_device_container_register (device);up_read (&device->group->group_rwsem); }mutex_unlock (&device->dev_set->lock);
@@ -1162,10 +1176,7 @@ static struct file *vfio_device_open(struct vfio_device *device)if (device->open_count ==1 && device->ops->close_device) { device->ops->close_device (device); - iommu_driver = device->group->container->iommu_driver; -if (iommu_driver && iommu_driver->ops->unregister_device) - iommu_driver->ops->unregister_device ( - device->group->container->iommu_data, device); +vfio_device_container_unregister (device); } err_undo_count:up_read (&device->group->group_rwsem);
@@ -1361,7 +1372,6 @@ static const struct file_operations vfio_group_fops = {static int vfio_device_fops_release (struct inode *inode,struct file *filep) {struct vfio_device *device = filep->private_data; -struct vfio_iommu_driver *iommu_driver;mutex_lock (&device->dev_set->lock);vfio_assert_device_open (device);
@@ -1369,10 +1379,7 @@ static int vfio_device_fops_release(struct inode *inode, struct file *filep)if (device->open_count ==1 && device->ops->close_device) device->ops->close_device (device); - iommu_driver = device->group->container->iommu_driver; -if (iommu_driver && iommu_driver->ops->unregister_device) - iommu_driver->ops->unregister_device ( - device->group->container->iommu_data, device); +vfio_device_container_unregister (device);up_read (&device->group->group_rwsem); device->open_count--;if (device->open_count ==0 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 287/314 perf/x86/amd: Fix crash due to race between amd_pmu_enable_all, perf NMI and throttling
In reply to Greg Kroah-HartmanFrom: Ravi Bangoria <[email protected]>
[ Upstream commit baa014b9543c8e5e94f5d15b66abfe60750b8284 ]
amd_pmu_enable_all() does:
if (!test_bit(idx, cpuc->active_mask))
continue;
amd_pmu_enable_event(cpuc->events[idx]);A perf NMI of another event can come between these two steps. Perf NMI handler internally disables and enables _all_ events, including the one which nmi-intercepted amd_pmu_enable_all() was in process of enabling. If that unintentionally enabled event has very low sampling period and causes immediate successive NMI, causing the event to be throttled, cpuc->events[idx] and cpuc->active_mask gets cleared by x86_pmu_stop(). This will result in amd_pmu_enable_event() getting called with event=NULL when amd_pmu_enable_all() resumes after handling the NMIs. This causes a kernel crash:
BUG: kernel NULL pointer dereference, address: 0000000000000198 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page [...] Call Trace: <TASK> amd_pmu_enable_all+0x68/0xb0 ctx_resched+0xd9/0x150 event_function+0xb8/0x130 ? hrtimer_start_range_ns+0x141/0x4a0 ? perf_duration_warn+0x30/0x30 remote_function+0x4d/0x60 __flush_smp_call_function_queue+0xc4/0x500 flush_smp_call_function_queue+0x11d/0x1b0 do_idle+0x18f/0x2d0 cpu_startup_entry+0x19/0x20 start_secondary+0x121/0x160 secondary_startup_64_no_verify+0xe5/0xeb </TASK>
amd_pmu_disable_all()/amd_pmu_enable_all() calls inside perf NMI handler were recently added as part of BRS enablement but I'm not sure whether we really need them. We can just disable BRS in the beginning and enable it back while returning from NMI. This will solve the issue by not enabling those events whose active_masks are set but are not yet enabled in hw pmu.
--- arch/x86/events/amd/core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/events/amd/core.c +2 -3
@@ -896,8 +896,7 @@ static int amd_pmu_handle_irq(struct pt_regs *regs) pmu_enabled = cpuc->enabled; cpuc->enabled =0 ; -/* stop everything (includes BRS) */ -amd_pmu_disable_all (); +amd_brs_disable_all ();/* Drain BRS is in use (could be inactive) */ if (cpuc->lbr_users)
@@ -908,7 +907,7 @@ static int amd_pmu_handle_irq(struct pt_regs *regs) cpuc->enabled = pmu_enabled;if (pmu_enabled) -amd_pmu_enable_all (0 ); +amd_brs_enable_all ();return amd_pmu_adjust_nmi_window (handled); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 288/314 ring-buffer: Include dropped pages in counting dirty patches
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
[ Upstream commit 31029a8b2c7e656a0289194ef16415050ae4c4ac ]
The function ring_buffer_nr_dirty_pages() was created to find out how many pages are filled in the ring buffer. There's two running counters. One is incremented whenever a new page is touched (pages_touched) and the other is whenever a page is read (pages_read). The dirty count is the number touched minus the number read. This is used to determine if a blocked task should be woken up if the percentage of the ring buffer it is waiting for is hit.
The problem is that it does not take into account dropped pages (when the new writes overwrite pages that were not read). And then the dirty pages will always be greater than the percentage.
This makes the "buffer_percent" file inaccurate, as the number of dirty pages end up always being larger than the percentage, event when it's not and this causes user space to be woken up more than it wants to be.
Add a new counter to keep track of lost pages, and include that in the accounting of dirty pages so that it is actually accurate.
--- kernel/trace/ring_buffer.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
kernel/trace/ring_buffer.c +12 -0
@@ -519,6 +519,7 @@ struct ring_buffer_per_cpu {local_t committing;local_t commits;local_t pages_touched; +local_t pages_lost;local_t pages_read;long last_pages_touch;size_t shortest_full;
@@ -894,10 +895,18 @@ size_t ring_buffer_nr_pages(struct trace_buffer *buffer, int cpu)size_t ring_buffer_nr_dirty_pages (struct trace_buffer *buffer,int cpu) {size_t read; +size_t lost;size_t cnt; read =local_read (&buffer->buffers[cpu]->pages_read); + lost =local_read (&buffer->buffers[cpu]->pages_lost); cnt =local_read (&buffer->buffers[cpu]->pages_touched); + +if (WARN_ON_ONCE (cnt < lost)) +return 0 ; + + cnt -= lost; +/* The reader can read an empty page, but not more than that */ if (cnt < read) {WARN_ON_ONCE (read > cnt +1 );
@@ -2031,6 +2040,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned long nr_pages)*/ local_add (page_entries, &cpu_buffer->overrun);local_sub (BUF_PAGE_SIZE , &cpu_buffer->entries_bytes); +local_inc (&cpu_buffer->pages_lost); }/*
@@ -2515,6 +2525,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,*/ local_add (entries, &cpu_buffer->overrun);local_sub (BUF_PAGE_SIZE , &cpu_buffer->entries_bytes); +local_inc (&cpu_buffer->pages_lost);/* * The entries will be zeroed out when we move the
@@ -5265,6 +5276,7 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)local_set (&cpu_buffer->committing,0 );local_set (&cpu_buffer->commits,0 );local_set (&cpu_buffer->pages_touched,0 ); +local_set (&cpu_buffer->pages_lost,0 );local_set (&cpu_buffer->pages_read,0 ); cpu_buffer->last_pages_touch =0 ; cpu_buffer->shortest_full =0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 289/314 tracing: Fix warning on variable struct trace_array
In reply to Greg Kroah-HartmanFrom: Aashish Sharma <[email protected]>
[ Upstream commit bedf06833b1f63c2627bd5634602e05592129d7a ]
Move the declaration of 'struct trace_array' out of #ifdef CONFIG_TRACING block, to fix the following warning when CONFIG_TRACING is not set:
Quoted 1 line
Quoted 1 line
include/linux/trace.h:63:45: warning: 'structtrace_array' declared
inside parameter list will not be visible outside of this definition or declaration
--- include/linux/trace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/trace.h +2 -2
@@ -26,13 +26,13 @@ struct trace_export {int flags; }; +struct trace_array ; +#ifdef CONFIG_TRACING int register_ftrace_export (struct trace_export *export);int unregister_ftrace_export (struct trace_export *export); -struct trace_array ; -void trace_printk_init_buffers (void ); __printf(3, 4) int trace_array_printk(struct trace_array *tr, unsigned long ip,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 290/314 net: usb: smsc95xx: fix external PHY reset
In reply to Greg Kroah-HartmanFrom: Alexandru Tachici <[email protected]>
[ Upstream commit 809ff97a677ff85dfb7ce2b63be261d1633dcf29 ]
An external PHY needs settling time after power up or reset. In the bind() function an mdio bus is registered. If at this point the external PHY is still initialising, no valid PHY ID will be read and on phy_find_first() the bind() function will fail.
If an external PHY is present, wait the maximum time specified in 802.3 45.2.7.1.1.
--- drivers/net/usb/smsc95xx.c | 46 ++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-)
drivers/net/usb/smsc95xx.c +42 -4
@@ -66,6 +66,7 @@ struct smsc95xx_priv {spinlock_t mac_cr_lock;u8 features;u8 suspend_flags; +bool is_internal_phy;struct irq_chip irqchip;struct irq_domain *irqdomain;struct fwnode_handle *irqfwnode;
@@ -252,6 +253,43 @@ static void smsc95xx_mdio_write(struct usbnet *dev, int phy_id, int idx,mutex_unlock (&dev->phy_mutex); } +static int smsc95xx_mdiobus_reset (struct mii_bus *bus) +{ +struct smsc95xx_priv *pdata; +struct usbnet *dev; +u32 val; +int ret; + + dev = bus->priv; + pdata = dev->driver_priv; + +if (pdata->is_internal_phy) +return 0 ; + +mutex_lock (&dev->phy_mutex); + + ret =smsc95xx_read_reg (dev,PM_CTRL , &val); +if (ret <0 ) + goto reset_out; + + val |=PM_CTL_PHY_RST_ ; + + ret =smsc95xx_write_reg (dev,PM_CTRL , val); +if (ret <0 ) + goto reset_out; + +/* Driver has no knowledge at this point about the external PHY. +* The 802.3 specifies that the reset process shall +* be completed within 0.5 s. +*/ +fsleep (500000 ); + +reset_out: +mutex_unlock (&dev->phy_mutex); + +return 0 ; +} +static int smsc95xx_mdiobus_read (struct mii_bus *bus,int phy_id,int idx) {struct usbnet *dev = bus->priv;
@@ -1052,7 +1090,6 @@ static void smsc95xx_handle_link_change(struct net_device *net)static int smsc95xx_bind (struct usbnet *dev,struct usb_interface *intf) {struct smsc95xx_priv *pdata; -bool is_internal_phy;char usb_path[64 ];int ret, phy_irq;u32 val;
@@ -1133,13 +1170,14 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)if (ret <0 ) goto free_mdio; - is_internal_phy = !(val &HW_CFG_PSEL_ ); -if (is_internal_phy) + pdata->is_internal_phy = !(val &HW_CFG_PSEL_ ); +if (pdata->is_internal_phy) pdata->mdiobus->phy_mask = ~(1u <<SMSC95XX_INTERNAL_PHY_ID ); pdata->mdiobus->priv = dev; pdata->mdiobus->read = smsc95xx_mdiobus_read; pdata->mdiobus->write = smsc95xx_mdiobus_write; + pdata->mdiobus->reset = smsc95xx_mdiobus_reset; pdata->mdiobus->name ="smsc95xx-mdiobus" ; pdata->mdiobus->parent = &dev->udev->dev;
@@ -1160,7 +1198,7 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) } pdata->phydev->irq = phy_irq; - pdata->phydev->is_internal = is_internal_phy; + pdata->phydev->is_internal = pdata->is_internal_phy;/* detect device revision as different features may be available */ ret =smsc95xx_read_reg (dev,ID_REV , &val);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 291/314 net: use struct_group to copy ip/ipv6 header addresses
In reply to Greg Kroah-HartmanFrom: Hangbin Liu <[email protected]>
[ Upstream commit 58e0be1ef6118c5352b56a4d06e974c5599993a5 ]
kernel test robot reported warnings when build bonding module with make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/net/bonding/:
from ../drivers/net/bonding/bond_main.c:35:
In function ‘fortify_memcpy_chk’,
inlined from ‘iph_to_flow_copy_v4addrs’ at ../include/net/ip.h:566:2,
inlined from ‘bond_flow_ip’ at ../drivers/net/bonding/bond_main.c:3984:3:../include/linux/fortify-string.h:413:25: warning: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of f ield (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
413 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~In function ‘fortify_memcpy_chk’,
inlined from ‘iph_to_flow_copy_v6addrs’ at ../include/net/ipv6.h:900:2,
inlined from ‘bond_flow_ip’ at ../drivers/net/bonding/bond_main.c:3994:3:../include/linux/fortify-string.h:413:25: warning: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of f ield (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
413 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This is because we try to copy the whole ip/ip6 address to the flow_key, while we only point the to ip/ip6 saddr. Note that since these are UAPI headers, __struct_group() is used to avoid the compiler warnings.
--- include/net/ip.h | 2 +- include/net/ipv6.h | 2 +- include/uapi/linux/ip.h | 6 ++++-- include/uapi/linux/ipv6.h | 6 ++++-- 4 files changed, 10 insertions(+), 6 deletions(-)
include/net/ip.h +1 -1
@@ -563,7 +563,7 @@ static inline void iph_to_flow_copy_v4addrs(struct flow_keys *flow, BUILD_BUG_ON(offsetof(typeof(flow->addrs), v4addrs.dst) != offsetof(typeof(flow->addrs), v4addrs.src) + sizeof(flow->addrs.v4addrs.src)); -memcpy (&flow->addrs.v4addrs, &iph->saddr,sizeof (flow->addrs.v4addrs)); +memcpy (&flow->addrs.v4addrs, &iph->addrs,sizeof (flow->addrs.v4addrs)); flow->control.addr_type =FLOW_DISSECTOR_KEY_IPV4_ADDRS ; }
include/net/ipv6.h +1 -1
@@ -897,7 +897,7 @@ static inline void iph_to_flow_copy_v6addrs(struct flow_keys *flow, BUILD_BUG_ON(offsetof(typeof(flow->addrs), v6addrs.dst) != offsetof(typeof(flow->addrs), v6addrs.src) + sizeof(flow->addrs.v6addrs.src)); -memcpy (&flow->addrs.v6addrs, &iph->saddr,sizeof (flow->addrs.v6addrs)); +memcpy (&flow->addrs.v6addrs, &iph->addrs,sizeof (flow->addrs.v6addrs)); flow->control.addr_type =FLOW_DISSECTOR_KEY_IPV6_ADDRS ; }
include/uapi/linux/ip.h +4 -2
@@ -100,8 +100,10 @@ struct iphdr {__u8 ttl;__u8 protocol;__sum16 check; -__be32 saddr; -__be32 daddr; + __struct_group(/* no tag */, addrs, /* no attrs */, + __be32 saddr; +__be32 daddr; + );/*The options start here. */ };
include/uapi/linux/ipv6.h +4 -2
@@ -130,8 +130,10 @@ struct ipv6hdr {__u8 nexthdr;__u8 hop_limit; -struct in6_addr saddr; -struct in6_addr daddr; + __struct_group(/* no tag */, addrs, /* no attrs */, +struct in6_addr saddr; +struct in6_addr daddr; + ); };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 292/314 scsi: target: tcm_loop: Fix possible name leak in tcm_loop_setup_hba_bus()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit bc68e428d4963af0201e92159629ab96948f0893 ]
If device_register() fails in tcm_loop_setup_hba_bus(), the name allocated by dev_set_name() need be freed. As comment of device_register() says, it should use put_device() to give up the reference in the error path. So fix this by calling put_device(), then the name can be freed in kobject_cleanup(). The 'tl_hba' will be freed in tcm_loop_release_adapter(), so it don't need goto error label in this case.
--- drivers/target/loopback/tcm_loop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/target/loopback/tcm_loop.c +2 -1
@@ -397,6 +397,7 @@ static int tcm_loop_setup_hba_bus(struct tcm_loop_hba *tl_hba, int tcm_loop_host ret =device_register (&tl_hba->dev);if (ret) {pr_err ("device_register() failed for tl_hba->dev: %d\n" , ret); +put_device (&tl_hba->dev);return -ENODEV ; }
@@ -1073,7 +1074,7 @@ static struct se_wwn *tcm_loop_make_scsi_hba(*/ ret =tcm_loop_setup_hba_bus (tl_hba, tcm_loop_hba_no_cnt);if (ret) - goto out; +return ERR_PTR (ret); sh = tl_hba->sh; tcm_loop_hba_no_cnt++;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 293/314 scsi: scsi_debug: Fix possible UAF in sdebug_add_host_helper()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit e208a1d795a08d1ac0398c79ad9c58106531bcc5 ]
If device_register() fails in sdebug_add_host_helper(), it will goto clean and sdbg_host will be freed, but sdbg_host->host_list will not be removed from sdebug_host_list, then list traversal may cause UAF. Fix it.
--- drivers/scsi/scsi_debug.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +5 -1
@@ -7316,8 +7316,12 @@ static int sdebug_add_host_helper(int per_host_idx)dev_set_name (&sdbg_host->dev,"adapter%d" , sdebug_num_hosts); error =device_register (&sdbg_host->dev); -if (error) +if (error) { +spin_lock (&sdebug_host_list_lock); +list_del (&sdbg_host->host_list); +spin_unlock (&sdebug_host_list_lock); goto clean; + } ++sdebug_num_hosts;return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 294/314 kprobes: Skip clearing aggrprobes post_handler in kprobe-on-ftrace case
In reply to Greg Kroah-HartmanFrom: Li Huafei <[email protected]>
[ Upstream commit 5dd7caf0bdc5d0bae7cf9776b4d739fb09bd5ebb ]
In __unregister_kprobe_top(), if the currently unregistered probe has post_handler but other child probes of the aggrprobe do not have post_handler, the post_handler of the aggrprobe is cleared. If this is a ftrace-based probe, there is a problem. In later calls to disarm_kprobe(), we will use kprobe_ftrace_ops because post_handler is NULL. But we're armed with kprobe_ipmodify_ops. This triggers a WARN in __disarm_kprobe_ftrace() and may even cause use-after-free:
Failed to disarm kprobe-ftrace at kernel_clone+0x0/0x3c0 (error -2)
WARNING: CPU: 5 PID: 137 at kernel/kprobes.c:1135 __disarm_kprobe_ftrace.isra.21+0xcf/0xe0 Modules linked in: testKprobe_007(-) CPU: 5 PID: 137 Comm: rmmod Not tainted 6.1.0-rc4-dirty #18 [...] Call Trace: <TASK> __disable_kprobe+0xcd/0xe0 __unregister_kprobe_top+0x12/0x150 ? mutex_lock+0xe/0x30 unregister_kprobes.part.23+0x31/0xa0 unregister_kprobe+0x32/0x40 __x64_sys_delete_module+0x15e/0x260 ? do_user_addr_fault+0x2cd/0x6b0 do_syscall_64+0x3a/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd [...]
For the kprobe-on-ftrace case, we keep the post_handler setting to identify this aggrprobe armed with kprobe_ipmodify_ops. This way we can disarm it correctly.
--- kernel/kprobes.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/kprobes.c +7 -1
@@ -1762,7 +1762,13 @@ static int __unregister_kprobe_top(struct kprobe *p)if ((list_p != p) && (list_p->post_handler)) goto noclean; } - ap->post_handler =NULL ; +/* +* For the kprobe-on-ftrace case, we keep the +* post_handler setting to identify this aggrprobe +* armed with kprobe_ipmodify_ops. +*/ +if (!kprobe_ftrace (ap)) + ap->post_handler =NULL ; } noclean:/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 295/314 tracing: Fix potential null-pointer-access of entry in list tr->err_log
In reply to Greg Kroah-HartmanFrom: Zheng Yejian <[email protected]>
[ Upstream commit 067df9e0ad48a97382ab2179bbe773a13a846028 ]
Entries in list 'tr->err_log' will be reused after entry number exceed TRACING_LOG_ERRS_MAX.
The cmd string of the to be reused entry will be freed first then allocated a new one. If the allocation failed, then the entry will still be in list 'tr->err_log' but its 'cmd' field is set to be NULL, later access of 'cmd' is risky.
Currently above problem can cause the loss of 'cmd' information of first entry in 'tr->err_log'. When execute cat /sys/kernel/tracing/error_log, reproduce logs like:
[ 37.495100] trace_kprobe: error: Maxactive is not for kprobe(null) ^
[ 38.412517] trace_kprobe: error: Maxactive is not for kprobe
Command: p4:myprobe2 do_sys_openat2
^--- kernel/trace/trace.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/trace/trace.c +5 -4
@@ -7803,6 +7803,7 @@ static struct tracing_log_err *get_tracing_log_err(struct trace_array *tr, int len) {struct tracing_log_err *err; +char *cmd;if (tr->n_err_log_entries <TRACING_LOG_ERRS_MAX ) { err =alloc_tracing_log_err (len);
@@ -7811,12 +7812,12 @@ static struct tracing_log_err *get_tracing_log_err(struct trace_array *tr,return err; } - + cmd =kzalloc (len,GFP_KERNEL ); +if (!cmd) +return ERR_PTR (-ENOMEM ); err = list_first_entry(&tr->err_log, struct tracing_log_err, list);kfree (err->cmd); - err->cmd =kzalloc (len,GFP_KERNEL ); -if (!err->cmd) -return ERR_PTR (-ENOMEM ); + err->cmd = cmd;list_del (&err->list);return err;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 296/314 arm64/mm: fix incorrect file_map_count for non-leaf pmd/pud
In reply to Greg Kroah-HartmanFrom: Liu Shixin <[email protected]>
[ Upstream commit 5b47348fc0b18a78c96f8474cc90b7525ad1bbfe ]
The page table check trigger BUG_ON() unexpectedly when collapse hugepage:
------------[ cut here ]------------
kernel BUG at mm/page_table_check.c:82!
Internal error: Oops - BUG: 00000000f2000800 [#1] SMP
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in:
CPU: 6 PID: 68 Comm: khugepaged Not tainted 6.1.0-rc3+ #750
Hardware name: linux,dummy-virt (DT)
pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : page_table_check_clear.isra.0+0x258/0x3f0
lr : page_table_check_clear.isra.0+0x240/0x3f0
[...]
Call trace:
page_table_check_clear.isra.0+0x258/0x3f0
__page_table_check_pmd_clear+0xbc/0x108
pmdp_collapse_flush+0xb0/0x160
collapse_huge_page+0xa08/0x1080
hpage_collapse_scan_pmd+0xf30/0x1590
khugepaged_scan_mm_slot.constprop.0+0x52c/0xac8
khugepaged+0x338/0x518
kthread+0x278/0x2f8
ret_from_fork+0x10/0x20[...]
Since pmd_user_accessible_page() doesn't check if a pmd is leaf, it decrease file_map_count for a non-leaf pmd comes from collapse_huge_page(). and so trigger BUG_ON() unexpectedly.
Fix this problem by using pmd_leaf() insteal of pmd_present() in pmd_user_accessible_page(). Moreover, use pud_leaf() for pud_user_accessible_page() too.
--- arch/arm64/include/asm/pgtable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/pgtable.h +2 -2
@@ -863,12 +863,12 @@ static inline bool pte_user_accessible_page(pte_t pte)static inline bool pmd_user_accessible_page (pmd_t pmd) { -return pmd_present (pmd) && (pmd_user (pmd) ||pmd_user_exec (pmd)); +return pmd_leaf (pmd) && (pmd_user (pmd) ||pmd_user_exec (pmd)); }static inline bool pud_user_accessible_page (pud_t pud) { -return pud_present (pud) &&pud_user (pud); +return pud_leaf (pud) &&pud_user (pud); }#endif
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 297/314 Input: i8042 - fix leaking of platform device on module removal
In reply to Greg Kroah-HartmanFrom: Chen Jun <[email protected]>
[ Upstream commit 81cd7e8489278d28794e7b272950c3e00c344e44 ]
Avoid resetting the module-wide i8042_platform_device pointer in i8042_probe() or i8042_remove(), so that the device can be properly destroyed by i8042_exit() on module unload.
--- drivers/input/serio/i8042.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/input/serio/i8042.c +0 -4
@@ -1543,8 +1543,6 @@ static int i8042_probe(struct platform_d {int error; - i8042_platform_device = dev; -if (i8042_reset ==I8042_RESET_ALWAYS ) { error =i8042_controller_selftest ();if (error)
@@ -1582,7 +1580,6 @@ static int i8042_probe(struct platform_di8042_free_aux_ports ();/* in case KBD failed but AUX not */ i8042_free_irqs ();i8042_controller_reset (false); - i8042_platform_device =NULL ;return error; }
@@ -1592,7 +1589,6 @@ static int i8042_remove(struct platform_i8042_unregister_ports ();i8042_free_irqs ();i8042_controller_reset (false); - i8042_platform_device =NULL ;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 298/314 macvlan: enforce a consistent minimal mtu
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
commit b64085b00044bdf3cd1c9825e9ef5b2e0feae91a upstream.
macvlan should enforce a minimal mtu of 68, even at link creation.
This patch avoids the current behavior (which could lead to crashes in ipv6 stack if the link is brought up)
$ ip link add macvlan1 link eno1 mtu 8 type macvlan # This should fail !
$ ip link sh dev macvlan1
5: macvlan1@eno1: <BROADCAST,MULTICAST> mtu 8 qdisc noop
state DOWN mode DEFAULT group default qlen 1000
link/ether 02:47:6c:24:74:82 brd ff:ff:ff:ff:ff:ff
$ ip link set macvlan1 mtu 67
Error: mtu less than device minimum.
$ ip link set macvlan1 mtu 68
$ ip link set macvlan1 mtu 8
Error: mtu less than device minimum.--- drivers/net/macvlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/macvlan.c +1 -1
@@ -1192,7 +1192,7 @@ void macvlan_common_setup(struct net_dev {ether_setup (dev); - dev->min_mtu =0 ; +/* ether_setup() has set dev->min_mtu to ETH_MIN_MTU. */ dev->max_mtu =ETH_MAX_MTU ; dev->priv_flags &= ~IFF_TX_SKB_SHARING ;netif_keep_dst (dev);
Greg Kroah-Hartman
maintainerPATCH 299/314 tcp: cdg: allow tcp_cdg_release() to be called multiple times
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
commit 72e560cb8c6f80fc2b4afc5d3634a32465e13a51 upstream.
Apparently, mptcp is able to call tcp_disconnect() on an already disconnected flow. This is generally fine, unless current congestion control is CDG, because it might trigger a double-free [1]
Instead of fixing MPTCP, and future bugs, we can make tcp_disconnect() more resilient.
[1]
BUG: KASAN: double-free in slab_free mm/slub.c:3539 [inline] BUG: KASAN: double-free in kfree+0xe2/0x580 mm/slub.c:4567 CPU: 0 PID: 3645 Comm: kworker/0:7 Not tainted 6.0.0-syzkaller-02734-g0326074ff465 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022 Workqueue: events mptcp_worker Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:317 [inline] print_report.cold+0x2ba/0x719 mm/kasan/report.c:433 kasan_report_invalid_free+0x81/0x190 mm/kasan/report.c:462 ____kasan_slab_free+0x18b/0x1c0 mm/kasan/common.c:356 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1759 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1785 slab_free mm/slub.c:3539 [inline] kfree+0xe2/0x580 mm/slub.c:4567 tcp_disconnect+0x980/0x1e20 net/ipv4/tcp.c:3145 __mptcp_close_ssk+0x5ca/0x7e0 net/mptcp/protocol.c:2327 mptcp_do_fastclose net/mptcp/protocol.c:2592 [inline] mptcp_worker+0x78c/0xff0 net/mptcp/protocol.c:2627 process_one_work+0x991/0x1610 kernel/workqueue.c:2289 worker_thread+0x665/0x1080 kernel/workqueue.c:2436 kthread+0x2e4/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 </TASK> Allocated by task 3671: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:437 [inline] ____kasan_kmalloc mm/kasan/common.c:516 [inline] ____kasan_kmalloc mm/kasan/common.c:475 [inline] __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:525 kmalloc_array include/linux/slab.h:640 [inline] kcalloc include/linux/slab.h:671 [inline] tcp_cdg_init+0x10d/0x170 net/ipv4/tcp_cdg.c:380 tcp_init_congestion_control+0xab/0x550 net/ipv4/tcp_cong.c:193 tcp_reinit_congestion_control net/ipv4/tcp_cong.c:217 [inline] tcp_set_congestion_control+0x96c/0xaa0 net/ipv4/tcp_cong.c:391 do_tcp_setsockopt+0x505/0x2320 net/ipv4/tcp.c:3513 tcp_setsockopt+0xd4/0x100 net/ipv4/tcp.c:3801 mptcp_setsockopt+0x35f/0x2570 net/mptcp/sockopt.c:844 __sys_setsockopt+0x2d6/0x690 net/socket.c:2252 __do_sys_setsockopt net/socket.c:2263 [inline] __se_sys_setsockopt net/socket.c:2260 [inline] __x64_sys_setsockopt+0xba/0x150 net/socket.c:2260 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 16: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:45 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:367 [inline] ____kasan_slab_free+0x166/0x1c0 mm/kasan/common.c:329 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1759 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1785 slab_free mm/slub.c:3539 [inline] kfree+0xe2/0x580 mm/slub.c:4567 tcp_cleanup_congestion_control+0x70/0x120 net/ipv4/tcp_cong.c:226 tcp_v4_destroy_sock+0xdd/0x750 net/ipv4/tcp_ipv4.c:2254 tcp_v6_destroy_sock+0x11/0x20 net/ipv6/tcp_ipv6.c:1969 inet_csk_destroy_sock+0x196/0x440 net/ipv4/inet_connection_sock.c:1157 tcp_done+0x23b/0x340 net/ipv4/tcp.c:4649 tcp_rcv_state_process+0x40e7/0x4990 net/ipv4/tcp_input.c:6624 tcp_v6_do_rcv+0x3fc/0x13c0 net/ipv6/tcp_ipv6.c:1525 tcp_v6_rcv+0x2e8e/0x3830 net/ipv6/tcp_ipv6.c:1759 ip6_protocol_deliver_rcu+0x2db/0x1950 net/ipv6/ip6_input.c:439 ip6_input_finish+0x14c/0x2c0 net/ipv6/ip6_input.c:484 NF_HOOK include/linux/netfilter.h:302 [inline] NF_HOOK include/linux/netfilter.h:296 [inline] ip6_input+0x9c/0xd0 net/ipv6/ip6_input.c:493 dst_input include/net/dst.h:455 [inline] ip6_rcv_finish+0x193/0x2c0 net/ipv6/ip6_input.c:79 ip_sabotage_in net/bridge/br_netfilter_hooks.c:874 [inline] ip_sabotage_in+0x1fa/0x260 net/bridge/br_netfilter_hooks.c:865 nf_hook_entry_hookfn include/linux/netfilter.h:142 [inline] nf_hook_slow+0xc5/0x1f0 net/netfilter/core.c:614 nf_hook.constprop.0+0x3ac/0x650 include/linux/netfilter.h:257 NF_HOOK include/linux/netfilter.h:300 [inline] ipv6_rcv+0x9e/0x380 net/ipv6/ip6_input.c:309 __netif_receive_skb_one_core+0x114/0x180 net/core/dev.c:5485 __netif_receive_skb+0x1f/0x1c0 net/core/dev.c:5599 netif_receive_skb_internal net/core/dev.c:5685 [inline] netif_receive_skb+0x12f/0x8d0 net/core/dev.c:5744 NF_HOOK include/linux/netfilter.h:302 [inline] NF_HOOK include/linux/netfilter.h:296 [inline] br_pass_frame_up+0x303/0x410 net/bridge/br_input.c:68 br_handle_frame_finish+0x909/0x1aa0 net/bridge/br_input.c:199 br_nf_hook_thresh+0x2f8/0x3d0 net/bridge/br_netfilter_hooks.c:1041 br_nf_pre_routing_finish_ipv6+0x695/0xef0 net/bridge/br_netfilter_ipv6.c:207 NF_HOOK include/linux/netfilter.h:302 [inline] br_nf_pre_routing_ipv6+0x417/0x7c0 net/bridge/br_netfilter_ipv6.c:237 br_nf_pre_routing+0x1496/0x1fe0 net/bridge/br_netfilter_hooks.c:507 nf_hook_entry_hookfn include/linux/netfilter.h:142 [inline] nf_hook_bridge_pre net/bridge/br_input.c:255 [inline] br_handle_frame+0x9c9/0x12d0 net/bridge/br_input.c:399 __netif_receive_skb_core+0x9fe/0x38f0 net/core/dev.c:5379 __netif_receive_skb_one_core+0xae/0x180 net/core/dev.c:5483 __netif_receive_skb+0x1f/0x1c0 net/core/dev.c:5599 process_backlog+0x3a0/0x7c0 net/core/dev.c:5927 __napi_poll+0xb3/0x6d0 net/core/dev.c:6494 napi_poll net/core/dev.c:6561 [inline] net_rx_action+0x9c1/0xd90 net/core/dev.c:6672 __do_softirq+0x1d0/0x9c8 kernel/softirq.c:571
--- net/ipv4/tcp_cdg.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv4/tcp_cdg.c +2 -0
@@ -375,6 +375,7 @@ static void tcp_cdg_init(struct sock *skstruct cdg *ca =inet_csk_ca (sk);struct tcp_sock *tp =tcp_sk (sk); + ca->gradients =NULL ;/* We silently fall back to window = 1 if allocation fails. */ if (window >1 ) ca->gradients = kcalloc(window, sizeof(ca->gradients[0]),
@@ -388,6 +389,7 @@ static void tcp_cdg_release(struct sockstruct cdg *ca =inet_csk_ca (sk);kfree (ca->gradients); + ca->gradients =NULL ; }static struct tcp_congestion_ops tcp_cdg__read_mostly = {
Greg Kroah-Hartman
maintainerPATCH 300/314 kcm: avoid potential race in kcm_tx_work
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
commit ec7eede369fe5b0d085ac51fdbb95184f87bfc6c upstream.
syzbot found that kcm_tx_work() could crash [1] in:
/* Primarily for SOCK_SEQPACKET sockets */
if (likely(sk->sk_socket) &&
test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) {
<<*>> clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
sk->sk_write_space(sk);
}I think the reason is that another thread might concurrently run in kcm_release() and call sock_orphan(sk) while sk is not locked. kcm_tx_work() find sk->sk_socket being NULL.
[1]
BUG: KASAN: null-ptr-deref in instrument_atomic_write include/linux/instrumented.h:86 [inline] BUG: KASAN: null-ptr-deref in clear_bit include/asm-generic/bitops/instrumented-atomic.h:41 [inline] BUG: KASAN: null-ptr-deref in kcm_tx_work+0xff/0x160 net/kcm/kcmsock.c:742 Write of size 8 at addr 0000000000000008 by task kworker/u4:3/53 CPU: 0 PID: 53 Comm: kworker/u4:3 Not tainted 5.19.0-rc3-next-20220621-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: kkcmd kcm_tx_work Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 kasan_report+0xbe/0x1f0 mm/kasan/report.c:495 check_region_inline mm/kasan/generic.c:183 [inline] kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189 instrument_atomic_write include/linux/instrumented.h:86 [inline] clear_bit include/asm-generic/bitops/instrumented-atomic.h:41 [inline] kcm_tx_work+0xff/0x160 net/kcm/kcmsock.c:742 process_one_work+0x996/0x1610 kernel/workqueue.c:2289 worker_thread+0x665/0x1080 kernel/workqueue.c:2436 kthread+0x2e9/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302 </TASK>
--- net/kcm/kcmsock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/kcm/kcmsock.c +1 -1
@@ -1799,10 +1799,10 @@ static int kcm_release(struct socket *so kcm =kcm_sk (sk); mux = kcm->mux; +lock_sock (sk);sock_orphan (sk);kfree_skb (kcm->seq_skb); -lock_sock (sk);/* Purge queue under lock to avoid race condition with tx_work trying * to act when queue is nonempty. If tx_work runs after this point * it will just return.
Greg Kroah-Hartman
maintainerPATCH 301/314 KVM: x86/xen: Fix eventfd error handling in kvm_xen_eventfd_assign()
In reply to Greg Kroah-HartmanFrom: Eiichi Tsukata <[email protected]>
commit 7353633814f6e5b4899fb9ee1483709d6bb0e1cd upstream.
Should not call eventfd_ctx_put() in case of error.
Message-Id: <[email protected]>
--- arch/x86/kvm/xen.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/x86/kvm/xen.c +4 -3
@@ -1667,18 +1667,18 @@ static int kvm_xen_eventfd_assign(structcase EVTCHNSTAT_ipi:/* IPI must map back to the same port# */ if (data->u.evtchn.deliver.port.port != data->u.evtchn.send_port) - goto out;/* -EINVAL */ + goto out_noeventfd;/* -EINVAL */ break ;case EVTCHNSTAT_interdomain:if (data->u.evtchn.deliver.port.port) {if (data->u.evtchn.deliver.port.port >=max_evtchn_port (kvm)) - goto out;/* -EINVAL */ + goto out_noeventfd;/* -EINVAL */ }else { eventfd =eventfd_ctx_fdget (data->u.evtchn.deliver.eventfd.fd);if (IS_ERR (eventfd)) { ret =PTR_ERR (eventfd); - goto out; + goto out_noeventfd; } }break ;
@@ -1718,6 +1718,7 @@ static int kvm_xen_eventfd_assign(struct out:if (eventfd)eventfd_ctx_put (eventfd); +out_noeventfd:kfree (evtchnfd);return ret; }
Greg Kroah-Hartman
maintainerPATCH 302/314 9p: trans_fd/p9_conn_cancel: drop client lock earlier
In reply to Greg Kroah-HartmanFrom: Dominique Martinet <[email protected]>
commit 52f1c45dde9136f964d63a77d19826c8a74e2c7f upstream.
syzbot reported a double-lock here and we no longer need this lock after requests have been moved off to local list:
just drop the lock earlier.
--- net/9p/trans_fd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/9p/trans_fd.c +2 -1
@@ -205,6 +205,8 @@ static void p9_conn_cancel(struct p9_conlist_move (&req->req_list, &cancel_list); } +spin_unlock (&m->client->lock); +list_for_each_entry_safe (req, rtmp, &cancel_list, req_list) {p9_debug (P9_DEBUG_ERROR ,"call back req %p\n" , req);list_del (&req->req_list);
@@ -212,7 +214,6 @@ static void p9_conn_cancel(struct p9_con req->t_err = err;p9_client_cb (m->client, req,REQ_STATUS_ERROR ); } -spin_unlock (&m->client->lock); } static __poll_t
Greg Kroah-Hartman
maintainerPATCH 303/314 gfs2: Check sb_bsize_shift after reading superblock
In reply to Greg Kroah-HartmanFrom: Andrew Price <[email protected]>
commit 670f8ce56dd0632dc29a0322e188cc73ce3c6b92 upstream.
Fuzzers like to scribble over sb_bsize_shift but in reality it's very unlikely that this field would be corrupted on its own. Nevertheless it should be checked to avoid the possibility of messy mount errors due to bad calculations. It's always a fixed value based on the block size so we can just check that it's the expected value.
Tested with:
mkfs.gfs2 -O -p lock_nolock /dev/vdb
for i in 0 -1 64 65 32 33; do
gfs2_edit -p sb field sb_bsize_shift $i /dev/vdb mount /dev/vdb /mnt/test && umount /mnt/test
done
Before this patch we get a withdraw after
[ 76.413681] gfs2: fsid=loop0.0: fatal: invalid metadata block [ 76.413681] bh = 19 (type: exp=5, found=4) [ 76.413681] function = gfs2_meta_buffer, file = fs/gfs2/meta_io.c, line = 492
and with UBSAN configured we also get complaints like
[ 76.373395] UBSAN: shift-out-of-bounds in fs/gfs2/ops_fstype.c:295:19 [ 76.373815] shift exponent 4294967287 is too large for 64-bit type 'long unsigned int'
After the patch, these complaints don't appear, mount fails immediately and we get an explanation in dmesg.
--- fs/gfs2/ops_fstype.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/gfs2/ops_fstype.c +4 -1
@@ -178,7 +178,10 @@ static int gfs2_check_sb(struct gfs2_sbdpr_warn ("Invalid block size\n" );return -EINVAL ; } - +if (sb->sb_bsize_shift !=ffs (sb->sb_bsize) -1 ) { +pr_warn ("Invalid block size shift\n" ); +return -EINVAL ; + }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 304/314 gfs2: Switch from strlcpy to strscpy
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
commit 204c0300c4e99707e9fb6e57840aa1127060e63f upstream.
Switch from strlcpy to strscpy and make sure that @count is the size of the smaller of the source and destination buffers. This prevents reading beyond the end of the source buffer when the source string isn't null terminated.
Found by a modified version of syzkaller.
--- fs/gfs2/ops_fstype.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/gfs2/ops_fstype.c +7 -5
@@ -384,8 +384,10 @@ static int init_names(struct gfs2_sbd *sif (!table[0 ]) table = sdp->sd_vfs->s_id; -strlcpy (sdp->sd_proto_name, proto,GFS2_FSNAME_LEN ); -strlcpy (sdp->sd_table_name, table,GFS2_FSNAME_LEN ); +BUILD_BUG_ON (GFS2_LOCKNAME_LEN >GFS2_FSNAME_LEN ); + +strscpy (sdp->sd_proto_name, proto,GFS2_LOCKNAME_LEN ); +strscpy (sdp->sd_table_name, table,GFS2_LOCKNAME_LEN ); table = sdp->sd_table_name;while ((table =strchr (table,'/' )))
@@ -1442,13 +1444,13 @@ static int gfs2_parse_param(struct fs_coswitch (o) {case Opt_lockproto: -strlcpy (args->ar_lockproto, param->string,GFS2_LOCKNAME_LEN ); +strscpy (args->ar_lockproto, param->string,GFS2_LOCKNAME_LEN );break ;case Opt_locktable: -strlcpy (args->ar_locktable, param->string,GFS2_LOCKNAME_LEN ); +strscpy (args->ar_locktable, param->string,GFS2_LOCKNAME_LEN );break ;case Opt_hostdata: -strlcpy (args->ar_hostdata, param->string,GFS2_LOCKNAME_LEN ); +strscpy (args->ar_hostdata, param->string,GFS2_LOCKNAME_LEN );break ;case Opt_spectator: args->ar_spectator =1 ;
Greg Kroah-Hartman
maintainerPATCH 305/314 9p/trans_fd: always use O_NONBLOCK read/write
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
commit ef575281b21e9a34dfae544a187c6aac2ae424a9 upstream.
syzbot is reporting hung task at p9_fd_close() [1], for p9_mux_poll_stop()
from p9_conn_destroy() from p9_fd_close() is failing to interrupt already
started kernel_read() from p9_fd_read() from p9_read_work() and/or kernel_write() from p9_fd_write() from p9_write_work() requests.
Since p9_socket_open() sets O_NONBLOCK flag, p9_mux_poll_stop() does not need to interrupt kernel_read()/kernel_write(). However, since p9_fd_open() does not set O_NONBLOCK flag, but pipe blocks unless signal is pending, p9_mux_poll_stop() needs to interrupt kernel_read()/kernel_write() when the file descriptor refers to a pipe. In other words, pipe file descriptor needs to be handled as if socket file descriptor.
We somehow need to interrupt kernel_read()/kernel_write() on pipes.
A minimal change, which this patch is doing, is to set O_NONBLOCK flag
from p9_fd_open(), for O_NONBLOCK flag does not affect reading/writing
of regular files. But this approach changes O_NONBLOCK flag on userspace- supplied file descriptors (which might break userspace programs), and O_NONBLOCK flag could be changed by userspace. It would be possible to set O_NONBLOCK flag every time p9_fd_read()/p9_fd_write() is invoked, but still remains small race window for clearing O_NONBLOCK flag.
If we don't want to manipulate O_NONBLOCK flag, we might be able to surround kernel_read()/kernel_write() with set_thread_flag(TIF_SIGPENDING) and recalc_sigpending(). Since p9_read_work()/p9_write_work() works are processed by kernel threads which process global system_wq workqueue, signals could not be delivered from remote threads when p9_mux_poll_stop()
from p9_conn_destroy() from p9_fd_close() is called. Therefore, calling
set_thread_flag(TIF_SIGPENDING)/recalc_sigpending() every time would be needed if we count on signals for making kernel_read()/kernel_write() non-blocking.
--- net/9p/trans_fd.c | 3 +++ 1 file changed, 3 insertions(+)
net/9p/trans_fd.c +3 -0
@@ -822,11 +822,14 @@ static int p9_fd_open(struct p9_client * goto out_free_ts;if (!(ts->rd->f_mode &FMODE_READ )) goto out_put_rd; +/* prevent workers from hanging on IO when fd is a pipe */ + ts->rd->f_flags |=O_NONBLOCK ; ts->wr =fget (wfd);if (!ts->wr) goto out_put_rd;if (!(ts->wr->f_mode &FMODE_WRITE )) goto out_put_wr; + ts->wr->f_flags |=O_NONBLOCK ; client->trans = ts; client->status = Connected;
Greg Kroah-Hartman
maintainerPATCH 306/314 netlink: Bounds-check struct nlmsgerr creation
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit 710d21fdff9a98d621cd4e64167f3ef8af4e2fd1 upstream.
In preparation for FORTIFY_SOURCE doing bounds-check on memcpy(), switch from __nlmsg_put to nlmsg_put(), and explain the bounds check for dealing with the memcpy() across a composite flexible array struct. Avoids this future run-time warning:
memcpy: detected field-spanning write (size 32) of single field "&errmsg->msg" at net/netlink/af_netlink.c:2447 (size 16)
--- net/netfilter/ipset/ip_set_core.c | 8 +++++--- net/netlink/af_netlink.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-)
net/netfilter/ipset/ip_set_core.c +5 -3
@@ -1719,11 +1719,13 @@ call_ad(struct net *net, struct sock *ct skb2 =nlmsg_new (payload,GFP_KERNEL );if (!skb2)return -ENOMEM ; - rep =__nlmsg_put (skb2,NETLINK_CB (skb).portid, - nlh->nlmsg_seq,NLMSG_ERROR , payload,0 ); + rep =nlmsg_put (skb2,NETLINK_CB (skb).portid, + nlh->nlmsg_seq,NLMSG_ERROR , payload,0 ); errmsg =nlmsg_data (rep); errmsg->error = ret; -memcpy (&errmsg->msg, nlh, nlh->nlmsg_len); +unsafe_memcpy (&errmsg->msg, nlh, nlh->nlmsg_len, + /* Bounds checked by the skb layer. */); + cmdattr = (void *)&errmsg->msg + min_len; ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr,
net/netlink/af_netlink.c +5 -3
@@ -2440,11 +2440,13 @@ void netlink_ack(struct sk_buff *in_skb,return ; } - rep =__nlmsg_put (skb,NETLINK_CB (in_skb).portid, nlh->nlmsg_seq, -NLMSG_ERROR , payload, flags); + rep =nlmsg_put (skb,NETLINK_CB (in_skb).portid, nlh->nlmsg_seq, +NLMSG_ERROR , payload, flags); errmsg =nlmsg_data (rep); errmsg->error = err; -memcpy (&errmsg->msg, nlh, payload >sizeof (*errmsg) ? nlh->nlmsg_len :sizeof (*nlh)); +unsafe_memcpy (&errmsg->msg, nlh, payload >sizeof (*errmsg) + ? nlh->nlmsg_len :sizeof (*nlh), + /* Bounds checked by the skb layer. */);if (nlk_has_extack && extack) {if (extack->_msg) {
Greg Kroah-Hartman
maintainerPATCH 307/314 wifi: wext: use flex array destination for memcpy()
In reply to Greg Kroah-HartmanFrom: Hawkins Jiawei <[email protected]>
commit e3e6e1d16a4cf7b63159ec71774e822194071954 upstream.
Syzkaller reports buffer overflow false positive as follows:
------------[ cut here ]------------ memcpy: detected field-spanning write (size 8) of single field "&compat_event->pointer" at net/wireless/wext-core.c:623 (size 4) WARNING: CPU: 0 PID: 3607 at net/wireless/wext-core.c:623 wireless_send_event+0xab5/0xca0 net/wireless/wext-core.c:623 Modules linked in: CPU: 1 PID: 3607 Comm: syz-executor659 Not tainted 6.0.0-rc6-next-20220921-syzkaller #0 [...] Call Trace: <TASK> ioctl_standard_call+0x155/0x1f0 net/wireless/wext-core.c:1022 wireless_process_ioctl+0xc8/0x4c0 net/wireless/wext-core.c:955 wext_ioctl_dispatch net/wireless/wext-core.c:988 [inline] wext_ioctl_dispatch net/wireless/wext-core.c:976 [inline] wext_handle_ioctl+0x26b/0x280 net/wireless/wext-core.c:1049 sock_ioctl+0x285/0x640 net/socket.c:1220 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd [...] </TASK>
Wireless events will be sent on the appropriate channels in wireless_send_event(). Different wireless events may have different payload structure and size, so kernel uses **len** and **cmd** field in struct __compat_iw_event as wireless event common LCP part, uses **pointer** as a label to mark the position of remaining different part.
Yet the problem is that, **pointer** is a compat_caddr_t type, which may be smaller than the relative structure at the same position. So during wireless_send_event() tries to parse the wireless events payload, it may trigger the memcpy() run-time destination buffer bounds checking when the relative structure's data is copied to the position marked by **pointer**.
This patch solves it by introducing flexible-array field **ptr_bytes**, to mark the position of the wireless events remaining part next to LCP part. What's more, this patch also adds **ptr_len** variable in wireless_send_event() to improve its maintainability.
--- include/linux/wireless.h | 10 +++++++++- net/wireless/wext-core.c | 17 ++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-)
include/linux/wireless.h +9 -1
@@ -26,7 +26,15 @@ struct compat_iw_point {struct __compat_iw_event {__u16 len;/* Real length of this stuff */ __u16 cmd;/* Wireless IOCTL */ -compat_caddr_t pointer; + +union { +compat_caddr_t pointer; + +/* we need ptr_bytes to make memcpy() run-time destination +* buffer bounds checking happy, nothing special +*/ + DECLARE_FLEX_ARRAY(__u8, ptr_bytes); + }; };#define IW_EV_COMPAT_LCP_LEN offsetof(struct __compat_iw_event, pointer)#define IW_EV_COMPAT_POINT_OFF offsetof(struct compat_iw_point, length)
net/wireless/wext-core.c +10 -7
@@ -468,6 +468,7 @@ void wireless_send_event(struct net_devistruct __compat_iw_event *compat_event;struct compat_iw_point compat_wrqu;struct sk_buff *compskb; +int ptr_len;#endif /*
@@ -582,6 +583,9 @@ void wireless_send_event(struct net_devinlmsg_end (skb, nlh);#ifdef CONFIG_COMPAT hdr_len = compat_event_type_size[descr->header_type]; + +/* ptr_len is remaining size in event header apart from LCP */ + ptr_len = hdr_len -IW_EV_COMPAT_LCP_LEN ; event_len = hdr_len + extra_len; compskb =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_ATOMIC );
@@ -612,16 +616,15 @@ void wireless_send_event(struct net_deviif (descr->header_type ==IW_HEADER_TYPE_POINT ) { compat_wrqu.length = wrqu->data.length; compat_wrqu.flags = wrqu->data.flags; -memcpy (&compat_event->pointer, - ((char *) &compat_wrqu) +IW_EV_COMPAT_POINT_OFF , - hdr_len -IW_EV_COMPAT_LCP_LEN ); +memcpy (compat_event->ptr_bytes, + ((char *)&compat_wrqu) +IW_EV_COMPAT_POINT_OFF , + ptr_len);if (extra_len) -memcpy (((char *) compat_event) + hdr_len, - extra, extra_len); +memcpy (&compat_event->ptr_bytes[ptr_len], + extra, extra_len); }else {/* extra_len must be zero, so no if (extra) needed */ -memcpy (&compat_event->pointer, wrqu, - hdr_len -IW_EV_COMPAT_LCP_LEN ); +memcpy (compat_event->ptr_bytes, wrqu, ptr_len); }nlmsg_end (compskb, nlh);
Greg Kroah-Hartman
maintainerPATCH 308/314 rseq: Use pr_warn_once() when deprecated/unknown ABI flags are encountered
In reply to Greg Kroah-HartmanFrom: Mathieu Desnoyers <[email protected]>
commit 448dca8c88755b768552e19bd1618be34ef6d1ff upstream.
These commits use WARN_ON_ONCE() and kill the offending processes when deprecated and unknown flags are encountered:
commit c17a6ff93213 ("rseq: Kill process when unknown flags are encountered in ABI structures") commit 0190e4198e47 ("rseq: Deprecate RSEQ_CS_FLAG_NO_RESTART_ON_* flags")
The WARN_ON_ONCE() triggered by userspace input prevents use of Syzkaller to fuzz the rseq system call.
Replace this WARN_ON_ONCE() by pr_warn_once() messages which contain actually useful information.
--- kernel/rseq.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
kernel/rseq.c +17 -2
@@ -171,12 +171,27 @@ static int rseq_get_rseq_cs(struct task_return 0 ; } +static bool rseq_warn_flags (const char *str,u32 flags) +{ +u32 test_flags; + +if (!flags) +return false; + test_flags = flags &RSEQ_CS_NO_RESTART_FLAGS ; +if (test_flags) +pr_warn_once ("Deprecated flags (%u) in %s ABI structure" , test_flags, str); + test_flags = flags & ~RSEQ_CS_NO_RESTART_FLAGS ; +if (test_flags) +pr_warn_once ("Unknown flags (%u) in %s ABI structure" , test_flags, str); +return true; +} +static int rseq_need_restart (struct task_struct *t,u32 cs_flags) {u32 flags, event_mask;int ret; -if (WARN_ON_ONCE (cs_flags &RSEQ_CS_NO_RESTART_FLAGS ) || cs_flags) +if (rseq_warn_flags ("rseq_cs" , cs_flags))return -EINVAL ;/* Get thread flags. */
@@ -184,7 +199,7 @@ static int rseq_need_restart(struct taskif (ret)return ret; -if (WARN_ON_ONCE (flags &RSEQ_CS_NO_RESTART_FLAGS ) || flags) +if (rseq_warn_flags ("rseq" , flags))return -EINVAL ;/*
Greg Kroah-Hartman
maintainerPATCH 309/314 mm: fs: initialize fsdata passed to write_begin/write_end interface
In reply to Greg Kroah-HartmanFrom: Alexander Potapenko <[email protected]>
commit 1468c6f4558b1bcd92aa0400f2920f9dc7588402 upstream.
Functions implementing the a_ops->write_end() interface accept the void *fsdata parameter that is supposed to be initialized by the corresponding a_ops->write_begin() (which accepts void **fsdata).
However not all a_ops->write_begin() implementations initialize fsdata unconditionally, so it may get passed uninitialized to a_ops->write_end(), resulting in undefined behavior.
Fix this by initializing fsdata with NULL before the call to write_begin(), rather than doing so in all possible a_ops implementations.
This patch covers only the following cases found by running x86 KMSAN under syzkaller:
- generic_perform_write()
- cont_expand_zero() and generic_cont_expand_simple()
- page_symlink()
Other cases of passing uninitialized fsdata may persist in the codebase.
--- fs/buffer.c | 4 ++-- fs/namei.c | 2 +- mm/filemap.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/buffer.c +2 -2
@@ -2352,7 +2352,7 @@ int generic_cont_expand_simple(struct instruct address_space *mapping = inode->i_mapping;const struct address_space_operations *aops = mapping->a_ops;struct page *page; -void *fsdata; +void *fsdata =NULL ;int err; err =inode_newsize_ok (inode, size);
@@ -2378,7 +2378,7 @@ static int cont_expand_zero(struct fileconst struct address_space_operations *aops = mapping->a_ops;unsigned int blocksize =i_blocksize (inode);struct page *page; -void *fsdata; +void *fsdata =NULL ;pgoff_t index, curidx;loff_t curpos;unsigned zerofrom, offset, len;
fs/namei.c +1 -1
@@ -5088,7 +5088,7 @@ int page_symlink(struct inode *inode, coconst struct address_space_operations *aops = mapping->a_ops;bool nofs = !mapping_gfp_constraint (mapping, __GFP_FS);struct page *page; -void *fsdata; +void *fsdata =NULL ;int err;unsigned int flags;
mm/filemap.c +1 -1
@@ -3712,7 +3712,7 @@ ssize_t generic_perform_write(struct kiounsigned long offset;/* Offset into pagecache page */ unsigned long bytes;/* Bytes to write to page */ size_t copied;/* Bytes copied from user */ -void *fsdata; +void *fsdata =NULL ; offset = (pos & (PAGE_SIZE -1 )); bytes = min_t(unsigned long, PAGE_SIZE - offset,
Greg Kroah-Hartman
maintainerPATCH 310/314 net/9p: use a dedicated spinlock for trans_fd
In reply to Greg Kroah-HartmanFrom: Dominique Martinet <[email protected]>
commit 296ab4a813841ba1d5f40b03190fd1bd8f25aab0 upstream.
Shamelessly copying the explanation from Tetsuo Handa's suggested patch[1] (slightly reworded):
syzbot is reporting inconsistent lock state in p9_req_put()[2], for p9_tag_remove() from p9_req_put() from IRQ context is using spin_lock_irqsave() on "struct p9_client"->lock but trans_fd (not from IRQ context) is using spin_lock().
Since the locks actually protect different things in client.c and in trans_fd.c, just replace trans_fd.c's lock by a new one specific to the transport (client.c's protect the idr for fid/tag allocations, while trans_fd.c's protects its own req list and request status field that acts as the transport's state machine)
--- net/9p/trans_fd.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-)
net/9p/trans_fd.c +25 -16
@@ -91,6 +91,7 @@ struct p9_poll_wait {* @mux_list: list link for mux to manage multiple connections (?) * @client: reference to client instance for this connection * @err: error state +* @req_lock: lock protecting req_list and requests statuses * @req_list: accounting for requests which have been sent * @unsent_req_list: accounting for requests that haven't been sent * @rreq: read request
@@ -114,6 +115,7 @@ struct p9_conn {struct list_head mux_list;struct p9_client *client;int err; +spinlock_t req_lock;struct list_head req_list;struct list_head unsent_req_list;struct p9_req_t *rreq;
@@ -189,10 +191,10 @@ static void p9_conn_cancel(struct p9_conp9_debug (P9_DEBUG_ERROR ,"mux %p err %d\n" , m, err); -spin_lock (&m->client->lock); +spin_lock (&m->req_lock);if (m->err) { -spin_unlock (&m->client->lock); +spin_unlock (&m->req_lock);return ; }
@@ -205,7 +207,7 @@ static void p9_conn_cancel(struct p9_conlist_move (&req->req_list, &cancel_list); } -spin_unlock (&m->client->lock); +spin_unlock (&m->req_lock);list_for_each_entry_safe (req, rtmp, &cancel_list, req_list) {p9_debug (P9_DEBUG_ERROR ,"call back req %p\n" , req);
@@ -360,7 +362,7 @@ static void p9_read_work(struct work_strif ((m->rreq) && (m->rc.offset == m->rc.capacity)) {p9_debug (P9_DEBUG_TRANS ,"got new packet\n" ); m->rreq->rc.size = m->rc.offset; -spin_lock (&m->client->lock); +spin_lock (&m->req_lock);if (m->rreq->status ==REQ_STATUS_SENT ) {list_del (&m->rreq->req_list);p9_client_cb (m->client, m->rreq,REQ_STATUS_RCVD );
@@ -369,14 +371,14 @@ static void p9_read_work(struct work_strp9_debug (P9_DEBUG_TRANS ,"Ignore replies associated with a cancelled request\n" ); }else { -spin_unlock (&m->client->lock); +spin_unlock (&m->req_lock);p9_debug (P9_DEBUG_ERROR ,"Request tag %d errored out while we were reading the reply\n" , m->rc.tag); err = -EIO ; goto error; } -spin_unlock (&m->client->lock); +spin_unlock (&m->req_lock); m->rc.sdata =NULL ; m->rc.offset =0 ; m->rc.capacity =0 ;
@@ -454,10 +456,10 @@ static void p9_write_work(struct work_st }if (!m->wsize) { -spin_lock (&m->client->lock); +spin_lock (&m->req_lock);if (list_empty (&m->unsent_req_list)) {clear_bit (Wworksched, &m->wsched); -spin_unlock (&m->client->lock); +spin_unlock (&m->req_lock);return ; }
@@ -472,7 +474,7 @@ static void p9_write_work(struct work_st m->wpos =0 ;p9_req_get (req); m->wreq = req; -spin_unlock (&m->client->lock); +spin_unlock (&m->req_lock); } p9_debug(P9_DEBUG_TRANS, "mux %p pos %d size %d\n",
@@ -589,6 +591,7 @@ static void p9_conn_create(struct p9_cliINIT_LIST_HEAD (&m->mux_list); m->client = client; +spin_lock_init (&m->req_lock);INIT_LIST_HEAD (&m->req_list);INIT_LIST_HEAD (&m->unsent_req_list);INIT_WORK (&m->rq, p9_read_work);
@@ -670,10 +673,10 @@ static int p9_fd_request(struct p9_clienif (m->err <0 )return m->err; -spin_lock (&client->lock); +spin_lock (&m->req_lock); req->status =REQ_STATUS_UNSENT ;list_add_tail (&req->req_list, &m->unsent_req_list); -spin_unlock (&client->lock); +spin_unlock (&m->req_lock);if (test_and_clear_bit (Wpending, &m->wsched)) n =EPOLLOUT ;
@@ -688,11 +691,13 @@ static int p9_fd_request(struct p9_clienstatic int p9_fd_cancel (struct p9_client *client,struct p9_req_t *req) { +struct p9_trans_fd *ts = client->trans; +struct p9_conn *m = &ts->conn;int ret =1 ;p9_debug (P9_DEBUG_TRANS ,"client %p req %p\n" , client, req); -spin_lock (&client->lock); +spin_lock (&m->req_lock);if (req->status ==REQ_STATUS_UNSENT ) {list_del (&req->req_list);
@@ -700,21 +705,24 @@ static int p9_fd_cancel(struct p9_clientp9_req_put (client, req); ret =0 ; } -spin_unlock (&client->lock); +spin_unlock (&m->req_lock);return ret; }static int p9_fd_cancelled (struct p9_client *client,struct p9_req_t *req) { +struct p9_trans_fd *ts = client->trans; +struct p9_conn *m = &ts->conn; +p9_debug (P9_DEBUG_TRANS ,"client %p req %p\n" , client, req); -spin_lock (&client->lock); +spin_lock (&m->req_lock);/* Ignore cancelled request if message has been received * before lock. */ if (req->status ==REQ_STATUS_RCVD ) { -spin_unlock (&client->lock); +spin_unlock (&m->req_lock);return 0 ; }
@@ -723,7 +731,8 @@ static int p9_fd_cancelled(struct p9_cli*/ list_del (&req->req_list); req->status =REQ_STATUS_FLSHD ; -spin_unlock (&client->lock); +spin_unlock (&m->req_lock); +p9_req_put (client, req);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 311/314 bpf: Prevent bpf program recursion for raw tracepoint probes
In reply to Greg Kroah-HartmanFrom: Jiri Olsa <[email protected]>
commit 05b24ff9b2cfabfcfd951daaa915a036ab53c9e1 upstream.
We got report from sysbot [1] about warnings that were caused by bpf program attached to contention_begin raw tracepoint triggering the same tracepoint by using bpf_trace_printk helper that takes trace_printk_lock lock.
Call Trace: <TASK> ? trace_event_raw_event_bpf_trace_printk+0x5f/0x90 bpf_trace_printk+0x2b/0xe0 bpf_prog_a9aec6167c091eef_prog+0x1f/0x24 bpf_trace_run2+0x26/0x90 native_queued_spin_lock_slowpath+0x1c6/0x2b0 _raw_spin_lock_irqsave+0x44/0x50 bpf_trace_printk+0x3f/0xe0 bpf_prog_a9aec6167c091eef_prog+0x1f/0x24 bpf_trace_run2+0x26/0x90 native_queued_spin_lock_slowpath+0x1c6/0x2b0 _raw_spin_lock_irqsave+0x44/0x50 bpf_trace_printk+0x3f/0xe0 bpf_prog_a9aec6167c091eef_prog+0x1f/0x24 bpf_trace_run2+0x26/0x90 native_queued_spin_lock_slowpath+0x1c6/0x2b0 _raw_spin_lock_irqsave+0x44/0x50 bpf_trace_printk+0x3f/0xe0 bpf_prog_a9aec6167c091eef_prog+0x1f/0x24 bpf_trace_run2+0x26/0x90 native_queued_spin_lock_slowpath+0x1c6/0x2b0 _raw_spin_lock_irqsave+0x44/0x50 __unfreeze_partials+0x5b/0x160 ...
The can be reproduced by attaching bpf program as raw tracepoint on contention_begin tracepoint. The bpf prog calls bpf_trace_printk helper. Then by running perf bench the spin lock code is forced to take slow path and call contention_begin tracepoint.
Fixing this by skipping execution of the bpf program if it's already running, Using bpf prog 'active' field, which is being currently used by trampoline programs for the same reason.
Moving bpf_prog_inc_misses_counter to syscall.c because trampoline.c is compiled in just for CONFIG_BPF_JIT option.
[1] https://lore.kernel.org/bpf/YxhFe3EwqchC%2FfYf@krava/T/#t
--- include/linux/bpf.h | 5 +++++ kernel/bpf/syscall.c | 11 +++++++++++ kernel/bpf/trampoline.c | 15 ++------------- kernel/trace/bpf_trace.c | 6 ++++++ 4 files changed, 24 insertions(+), 13 deletions(-)
include/linux/bpf.h +5 -0
@@ -1967,6 +1967,7 @@ static inline bool unprivileged_ebpf_enareturn !sysctl_unprivileged_bpf_disabled; } +void notrace bpf_prog_inc_misses_counter(struct bpf_prog *prog);#else /* !CONFIG_BPF_SYSCALL */ static inline struct bpf_prog *bpf_prog_get (u32 ufd) {
@@ -2305,6 +2306,10 @@ static inline int sock_map_bpf_prog_quer {return -EINVAL ; } + +static inline void bpf_prog_inc_misses_counter (struct bpf_prog *prog) +{ +}#endif /* CONFIG_BPF_SYSCALL */ #endif /* CONFIG_NET && CONFIG_BPF_SYSCALL */
kernel/bpf/syscall.c +11 -0
@@ -2094,6 +2094,17 @@ struct bpf_prog_kstats {u64 misses; }; +void notrace bpf_prog_inc_misses_counter(struct bpf_prog *prog) +{ +struct bpf_prog_stats *stats; +unsigned int flags; + + stats =this_cpu_ptr (prog->stats); + flags =u64_stats_update_begin_irqsave (&stats->syncp); +u64_stats_inc (&stats->misses); +u64_stats_update_end_irqrestore (&stats->syncp, flags); +} +static void bpf_prog_get_stats (const struct bpf_prog *prog,struct bpf_prog_kstats *stats) {
kernel/bpf/trampoline.c +2 -13
@@ -863,17 +863,6 @@ static __always_inline u64 notrace bpf_preturn start; } -static void notrace inc_misses_counter(struct bpf_prog *prog) -{ -struct bpf_prog_stats *stats; -unsigned int flags; - - stats =this_cpu_ptr (prog->stats); - flags =u64_stats_update_begin_irqsave (&stats->syncp); -u64_stats_inc (&stats->misses); -u64_stats_update_end_irqrestore (&stats->syncp, flags); -} -/* The logic is similar to bpf_prog_run(), but with an explicit * rcu_read_lock() and migrate_disable() which are required * for the trampoline. The macro is split into
@@ -896,7 +885,7 @@ u64 notrace __bpf_prog_enter(struct bpf_ run_ctx->saved_run_ctx =bpf_set_run_ctx (&run_ctx->run_ctx);if (unlikely (this_cpu_inc_return (*(prog->active)) !=1 )) { -inc_misses_counter (prog); +bpf_prog_inc_misses_counter (prog);return 0 ; }return bpf_prog_start_time ();
@@ -967,7 +956,7 @@ u64 notrace __bpf_prog_enter_sleepable(smight_fault ();if (unlikely (this_cpu_inc_return (*(prog->active)) !=1 )) { -inc_misses_counter (prog); +bpf_prog_inc_misses_counter (prog);return 0 ; }
kernel/trace/bpf_trace.c +6 -0
@@ -2058,9 +2058,15 @@ static __always_inlinevoid __bpf_trace_run (struct bpf_prog *prog,u64 *args) {cant_sleep (); +if (unlikely (this_cpu_inc_return (*(prog->active)) !=1 )) { +bpf_prog_inc_misses_counter (prog); + goto out; + }rcu_read_lock (); (void )bpf_prog_run (prog, args);rcu_read_unlock (); +out: +this_cpu_dec (*(prog->active)); }#define UNPACK (...) __VA_ARGS__
Greg Kroah-Hartman
maintainerPATCH 312/314 ntfs: fix use-after-free in ntfs_attr_find()
In reply to Greg Kroah-HartmanFrom: Hawkins Jiawei <[email protected]>
commit d85a1bec8e8d552ab13163ca1874dcd82f3d1550 upstream.
Patch series "ntfs: fix bugs about Attribute", v2.
This patchset fixes three bugs relative to Attribute in record:
Patch 1 adds a sanity check to ensure that, attrs_offset field in first mft record loading from disk is within bounds.
Patch 2 moves the ATTR_RECORD's bounds checking earlier, to avoid dereferencing ATTR_RECORD before checking this ATTR_RECORD is within bounds.
Patch 3 adds an overflow checking to avoid possible forever loop in ntfs_attr_find().
Without patch 1 and patch 2, the kernel triggersa KASAN use-after-free detection as reported by Syzkaller.
Although one of patch 1 or patch 2 can fix this, we still need both of them. Because patch 1 fixes the root cause, and patch 2 not only fixes the direct cause, but also fixes the potential out-of-bounds bug.
This patch (of 3):
Syzkaller reported use-after-free read as follows:
==================================================================
BUG: KASAN: use-after-free in ntfs_attr_find+0xc02/0xce0 fs/ntfs/attrib.c:597 Read of size 2 at addr ffff88807e352009 by task syz-executor153/3607
[...]
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:317 [inline]
print_report.cold+0x2ba/0x719 mm/kasan/report.c:433
kasan_report+0xb1/0x1e0 mm/kasan/report.c:495
ntfs_attr_find+0xc02/0xce0 fs/ntfs/attrib.c:597
ntfs_attr_lookup+0x1056/0x2070 fs/ntfs/attrib.c:1193
ntfs_read_inode_mount+0x89a/0x2580 fs/ntfs/inode.c:1845
ntfs_fill_super+0x1799/0x9320 fs/ntfs/super.c:2854
mount_bdev+0x34d/0x410 fs/super.c:1400
legacy_get_tree+0x105/0x220 fs/fs_context.c:610
vfs_get_tree+0x89/0x2f0 fs/super.c:1530
do_new_mount fs/namespace.c:3040 [inline]
path_mount+0x1326/0x1e20 fs/namespace.c:3370
do_mount fs/namespace.c:3383 [inline]
__do_sys_mount fs/namespace.c:3591 [inline]
__se_sys_mount fs/namespace.c:3568 [inline]
__x64_sys_mount+0x27f/0x300 fs/namespace.c:3568
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
[...]
</TASK>
The buggy address belongs to the physical page:
page:ffffea0001f8d400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7e350
head:ffffea0001f8d400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888011842140
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88807e351f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88807e351f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88807e352000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807e352080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807e352100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================Kernel will loads $MFT/$DATA's first mft record in ntfs_read_inode_mount().
Yet the problem is that after loading, kernel doesn't check whether attrs_offset field is a valid value.
To be more specific, if attrs_offset field is larger than bytes_allocated field, then it may trigger the out-of-bounds read bug(reported as use-after-free bug) in ntfs_attr_find(), when kernel tries to access the corresponding mft record's attribute.
This patch solves it by adding the sanity check between attrs_offset field and bytes_allocated field, after loading the first mft record.
--- fs/ntfs/inode.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/ntfs/inode.c +7 -0
@@ -1829,6 +1829,13 @@ int ntfs_read_inode_mount(struct inode * goto err_out; } +/* Sanity check offset to the first attribute */ +if (le16_to_cpu (m->attrs_offset) >=le32_to_cpu (m->bytes_allocated)) { +ntfs_error (sb,"Incorrect mft offset to the first attribute %u in superblock." , +le16_to_cpu (m->attrs_offset)); + goto err_out; + } +/* Need this to sanity check attribute list references to $MFT. */ vi->i_generation = ni->seq_no =le16_to_cpu (m->sequence_number);
Greg Kroah-Hartman
maintainerPATCH 313/314 ntfs: fix out-of-bounds read in ntfs_attr_find()
In reply to Greg Kroah-HartmanFrom: Hawkins Jiawei <[email protected]>
commit 36a4d82dddbbd421d2b8e79e1cab68c8126d5075 upstream.
Kernel iterates over ATTR_RECORDs in mft record in ntfs_attr_find(). To ensure access on these ATTR_RECORDs are within bounds, kernel will do some checking during iteration.
The problem is that during checking whether ATTR_RECORD's name is within bounds, kernel will dereferences the ATTR_RECORD name_offset field, before checking this ATTR_RECORD strcture is within bounds. This problem may result out-of-bounds read in ntfs_attr_find(), reported by Syzkaller:
==================================================================
BUG: KASAN: use-after-free in ntfs_attr_find+0xc02/0xce0 fs/ntfs/attrib.c:597 Read of size 2 at addr ffff88807e352009 by task syz-executor153/3607
[...]
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:317 [inline]
print_report.cold+0x2ba/0x719 mm/kasan/report.c:433
kasan_report+0xb1/0x1e0 mm/kasan/report.c:495
ntfs_attr_find+0xc02/0xce0 fs/ntfs/attrib.c:597
ntfs_attr_lookup+0x1056/0x2070 fs/ntfs/attrib.c:1193
ntfs_read_inode_mount+0x89a/0x2580 fs/ntfs/inode.c:1845
ntfs_fill_super+0x1799/0x9320 fs/ntfs/super.c:2854
mount_bdev+0x34d/0x410 fs/super.c:1400
legacy_get_tree+0x105/0x220 fs/fs_context.c:610
vfs_get_tree+0x89/0x2f0 fs/super.c:1530
do_new_mount fs/namespace.c:3040 [inline]
path_mount+0x1326/0x1e20 fs/namespace.c:3370
do_mount fs/namespace.c:3383 [inline]
__do_sys_mount fs/namespace.c:3591 [inline]
__se_sys_mount fs/namespace.c:3568 [inline]
__x64_sys_mount+0x27f/0x300 fs/namespace.c:3568
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
[...]
</TASK>
The buggy address belongs to the physical page:
page:ffffea0001f8d400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7e350
head:ffffea0001f8d400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888011842140
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88807e351f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88807e351f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88807e352000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807e352080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807e352100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================This patch solves it by moving the ATTR_RECORD strcture's bounds checking earlier, then checking whether ATTR_RECORD's name is within bounds. What's more, this patch also add some comments to improve its maintainability.
--- fs/ntfs/attrib.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
fs/ntfs/attrib.c +16 -4
@@ -594,11 +594,23 @@ static int ntfs_attr_find(const ATTR_TYPfor (;; a = (ATTR_RECORD *)((u8 *)a +le32_to_cpu (a->length))) {u8 *mrec_end = (u8 *)ctx->mrec +le32_to_cpu (ctx->mrec->bytes_allocated); -u8 *name_end = (u8 *)a +le16_to_cpu (a->name_offset) + - a->name_length *sizeof (ntfschar); -if ((u8 *)a < (u8 *)ctx->mrec || (u8 *)a > mrec_end || - name_end > mrec_end) +u8 *name_end; + +/* check whether ATTR_RECORD wrap */ +if ((u8 *)a < (u8 *)ctx->mrec)break ; + +/* check whether Attribute Record Header is within bounds */ +if ((u8 *)a > mrec_end || + (u8 *)a +sizeof (ATTR_RECORD ) > mrec_end) +break ; + +/* check whether ATTR_RECORD's name is within bounds */ + name_end = (u8 *)a +le16_to_cpu (a->name_offset) + + a->name_length *sizeof (ntfschar); +if (name_end > mrec_end) +break ; + ctx->attr = a;if (unlikely (le32_to_cpu (a->type) >le32_to_cpu (type) || a->type ==AT_END ))
Greg Kroah-Hartman
maintainerPATCH 314/314 ntfs: check overflow when iterating ATTR_RECORDs
In reply to Greg Kroah-HartmanFrom: Hawkins Jiawei <[email protected]>
commit 63095f4f3af59322bea984a6ae44337439348fe0 upstream.
Kernel iterates over ATTR_RECORDs in mft record in ntfs_attr_find(). Because the ATTR_RECORDs are next to each other, kernel can get the next ATTR_RECORD from end address of current ATTR_RECORD, through current ATTR_RECORD length field.
The problem is that during iteration, when kernel calculates the end address of current ATTR_RECORD, kernel may trigger an integer overflow bug in executing a = (ATTR_RECORD*)((u8*)a + le32_to_cpu(a->length)). This may wrap, leading to a forever iteration on 32bit systems.
This patch solves it by adding some checks on calculating end address of current ATTR_RECORD during iteration.
--- fs/ntfs/attrib.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/ntfs/attrib.c +8 -0
@@ -617,6 +617,14 @@ static int ntfs_attr_find(const ATTR_TYPreturn -ENOENT ;if (unlikely (!a->length))break ; + +/* check whether ATTR_RECORD's length wrap */ +if ((u8 *)a +le32_to_cpu (a->length) < (u8 *)a) +break ; +/* check whether ATTR_RECORD's length is within bounds */ +if ((u8 *)a +le32_to_cpu (a->length) > mrec_end) +break ; +if (a->type != type)continue ;/*
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.0.10 release. There are 314 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 Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.0.10-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.0.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v6.0:
11 builds: 11 pass, 0 fail
28 boots: 28 pass, 0 fail
130 tests: 130 pass, 0 failLinux version: 6.0.10-rc1-gdcf677c9377c
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra194-p3509-0000+p3668-0000,
tegra20-ventana, tegra210-p2371-2180,
tegra210-p3450-0000, tegra30-cardhu-a04Jon
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.0.10 release. There are 314 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 Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
Build reference: v6.0.9-315-gdcf677c Compiler version: arm-linux-gnueabi-gcc (GCC) 11.3.0 Assembler version: GNU assembler (GNU Binutils) 2.39
Building arm:allmodconfig ... failed
--------------
Error log:drivers/rtc/rtc-cmos.c:1347:13: error: 'rtc_wake_setup' defined but not used [-Werror=unused-function]
1347 | static void rtc_wake_setup(struct device *dev)
Guenter
Greg Kroah-Hartman
maintainerQuoted 14 lines · Guenter Roeck
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.0.10 release. There are 314 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 Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
Build reference: v6.0.9-315-gdcf677c Compiler version: arm-linux-gnueabi-gcc (GCC) 11.3.0 Assembler version: GNU assembler (GNU Binutils) 2.39
Quoted 5 lines
Building arm:allmodconfig ... failed
--------------
Error log:drivers/rtc/rtc-cmos.c:1347:13: error: 'rtc_wake_setup' defined but not used [-Werror=unused-function]
1347 | static voidrtc_wake_setup(struct device *dev)
Now fixed, this commit should not have been added, as it wasn't obvious that it was fixing an issue only in 6.1-rc, not the stable trees.
Dropped from everywhere.
greg k-h
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.0.10 release. There are 314 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 Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.0.10-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.0.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Hey Greg,
Ran tests and boot tested on my system, no regressions found
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.0.10 release. There are 314 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 Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
Build results:
total: 152 pass: 147 fail: 5
Failed builds:
arm:allmodconfig
mips:allmodconfig
powerpc:allmodconfig
powerpc:ppc32_allmodconfig
sparc64:allmodconfig
Qemu test results:
total: 500 pass: 500 fail: 0
Error log:drivers/rtc/rtc-cmos.c:1347:13: error: 'rtc_wake_setup' defined but not used [-Werror=unused-function]
1347 | static void rtc_wake_setup(struct device *dev)
Guenter
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.0.10 release. There are 314 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 Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.0.10-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.0.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro's test farm.
No regressions on arm64, arm, x86_64, and i386.
NOTE:
As others reported arm: allmodconfig build failed due to
rtc: cmos: fix build on non-ACPI platforms
[ Upstream commit db4e955ae333567dea02822624106c0b96a2f84f ]
Build error:drivers/rtc/rtc-cmos.c:1347:13: error: 'rtc_wake_setup' defined but not used [-Werror=unused-function]
1347 | static void rtc_wake_setup(struct device *dev)
| ^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
## Build
* kernel: 6.0.10-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-6.0.y
* git commit: dcf677c9377c88653b9cbbfc7e59e70f7a2af096
* git describe: v6.0.9-315-gdcf677c9377c
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.0.y/build/v6.0.9-315-gdcf677c9377c
## Test Regressions (compared to v6.0.9)
## Metric Regressions (compared to v6.0.9)
## Test Fixes (compared to v6.0.9)
## Metric Fixes (compared to v6.0.9)
## Test result summary
total: 148325, pass: 129685, fail: 3631, skip: 14746, xfail: 263
## Build Summary
* arc: 5 total, 5 passed, 0 failed
* arm: 147 total, 144 passed, 3 failed
* arm64: 45 total, 45 passed, 0 failed
* i386: 35 total, 34 passed, 1 failed
* mips: 27 total, 26 passed, 1 failed
* parisc: 6 total, 6 passed, 0 failed
* powerpc: 34 total, 30 passed, 4 failed
* riscv: 12 total, 12 passed, 0 failed
* s390: 12 total, 12 passed, 0 failed
* sh: 12 total, 12 passed, 0 failed
* sparc: 6 total, 6 passed, 0 failed
* x86_64: 38 total, 38 passed, 0 failed
## Test suites summary
* boot
* fwts
* igt-gpu-tools
* kselftest-android
* kselftest-arm64
* kselftest-arm64/arm64.btitest.bti_c_func
* kselftest-arm64/arm64.btitest.bti_j_func
* kselftest-arm64/arm64.btitest.bti_jc_func
* kselftest-arm64/arm64.btitest.bti_none_func
* kselftest-arm64/arm64.btitest.nohint_func
* kselftest-arm64/arm64.btitest.paciasp_func
* kselftest-arm64/arm64.nobtitest.bti_c_func
* kselftest-arm64/arm64.nobtitest.bti_j_func
* kselftest-arm64/arm64.nobtitest.bti_jc_func
* kselftest-arm64/arm64.nobtitest.bti_none_func
* kselftest-arm64/arm64.nobtitest.nohint_func
* kselftest-arm64/arm64.nobtitest.paciasp_func
* kselftest-breakpoints
* kselftest-drivers-dma-buf
* kselftest-efivarfs
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-kvm
* kselftest-lib
* kselftest-net
* kselftest-net-forwarding
* kselftest-net-mptcp
* kselftest-netfilter
* kselftest-openat2
* kselftest-seccomp
* kselftest-timens
* kunit
* kvm-unit-tests
* libgpiod
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-open-posix-tests
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* network-basic-tests
* perf
* perf/Zstd-perf.data-compression
* rcutorture
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org
Quoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.0.10 release. There are 314 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.
Successfully cross-compiled for arm64 (bcm2711_defconfig, GCC 10.2.0) and powerpc (ps3_defconfig, GCC 12.2.0).
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Hi Greg,
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.0.10 release. There are 314 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 Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
Build test (gcc version 12.2.1 20221016):
mips: 52 configs -> 1 failure
arm: 100 configs -> 2 failures
arm64: 3 configs -> no failurex86_64: 4 configs -> no failure
alpha allmodconfig -> no failure
csky allmodconfig -> no failure
powerpc allmodconfig -> 1 failure
riscv allmodconfig -> no failure
s390 allmodconfig -> no failure
xtensa allmodconfig -> no failure
Note:
1. As reported by others arm mips and powerpc allmodconfig fails with:drivers/rtc/rtc-cmos.c:1299:13: error: 'rtc_wake_setup' defined but not used [-Werror=unused-function]
1299 | static void rtc_wake_setup(struct device *dev)
| ^~~~~~~~~~~~~~
2. arm imxrt_defconfig fails with:
In file included from ./include/linux/bpf-cgroup.h:5,
from security/device_cgroup.c:8:./include/linux/bpf.h:2310:20: error: static declaration of 'bpf_prog_inc_misses_counter' follows non-static declaration
2310 | static inline void bpf_prog_inc_misses_counter(struct bpf_prog *prog)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/bpf.h:1970:14: note: previous declaration of 'bpf_prog_inc_misses_counter' with type 'void(struct bpf_prog *)'
1970 | void notrace bpf_prog_inc_misses_counter(struct bpf_prog *prog);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~Caused by a1ba348f5325 ("bpf: Prevent bpf program recursion for raw tracepoint probes").
Boot test:x86_64: Booted on my test laptop. No regression.x86_64: Booted on qemu. No regression. [1]
arm64: Booted on rpi4b (4GB model). No regression. [2]
mips: Booted on ci20 board. No regression. [3]
[1]. https://openqa.qa.codethink.co.uk/tests/2210
[2]. https://openqa.qa.codethink.co.uk/tests/2214
[3]. https://openqa.qa.codethink.co.uk/tests/2216
Signature · 2 lines
Regards Sudip
Greg Kroah-Hartman
maintainerQuoted 23 lines · Sudip Mukherjee
Hi Greg,
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.0.10 release. There are 314 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 Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
Build test (gcc version 12.2.1 20221016):
mips: 52 configs -> 1 failure
arm: 100 configs -> 2 failures
arm64: 3 configs -> no failurex86_64: 4 configs -> no failure alpha allmodconfig -> no failure csky allmodconfig -> no failure powerpc allmodconfig -> 1 failure riscv allmodconfig -> no failure s390 allmodconfig -> no failure xtensa allmodconfig -> no failure
Quoted 6 lines
Note:
1. As reported by others arm mips and powerpc allmodconfig fails with:drivers/rtc/rtc-cmos.c:1299:13: error: 'rtc_wake_setup' defined but not used [-Werror=unused-function]
1299 | static voidrtc_wake_setup(struct device *dev)| ^~~~~~~~~~~~~~
Should now be fixed, thanks.
Quoted 7 lines
2. arm
imxrt_defconfigfails with:In file included from
./include/linux/bpf-cgroup.h:5,
fromsecurity/device_cgroup.c:8:./include/linux/bpf.h:2310:20: error: static declaration of 'bpf_prog_inc_misses_counter' follows non-static declaration
2310 | static inline voidbpf_prog_inc_misses_counter(struct bpf_prog *prog)
Quoted 6 lines
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/bpf.h:1970:14: note: previous declaration of 'bpf_prog_inc_misses_counter' with type 'void(struct bpf_prog *)' 1970 | void notrace bpf_prog_inc_misses_counter(struct bpf_prog *prog); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~Caused by
a1ba348f5325("bpf: Prevent bpf program recursion for raw tracepoint probes").
Oh, nice catch! I messed up the backport of this commit, and put the prototype in the wrong place in the .h file. Let me push out a -rc2 with this moved a bit to see if that solves the problem.
Interesting that your build tests were the only one that caught this.
thanks,
greg k-h
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.0.10 release. There are 314 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 Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.0.10-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.0.y
and the diffstat can be found below.thanks,
greg k-h
Tested rc1 against the Fedora build system (aarch64, armv7, ppc64le, s390x, x86_64), and boot tested x86_64. No regressions noted.