6.19.9-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 289/378 memcg: fix slab accounting in refill_obj_stock() trylock path
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hao Li <[email protected]>
commit dccd5ee2625d50239510bcd73ed78559005e00a3 upstream.
In the trylock path of refill_obj_stock(), mod_objcg_mlstate() should use the real alloc/free bytes (i.e., nr_acct) for accounting, rather than nr_bytes.
The user-visible impact is that the NR_SLAB_RECLAIMABLE_B and NR_SLAB_UNRECLAIMABLE_B stats can end up being incorrect.
For example, if a user allocates a 6144-byte object, then before this fix efill_obj_stock() calls mod_objcg_mlstate(..., nr_bytes=2048), even though it should account for 6144 bytes (i.e., nr_acct).
When the user later frees the same object with kfree(), refill_obj_stock() calls mod_objcg_mlstate(..., nr_bytes=6144). This ends up adding 6144 to the stats, but it should be applying -6144 (i.e., nr_acct) since the object is being freed.
--- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
@@ -3052,7 +3052,7 @@ static void refill_obj_stock(struct obj_if (!local_trylock (&obj_stock.lock)) {if (pgdat) -mod_objcg_mlstate (objcg, pgdat, idx, nr_bytes); +mod_objcg_mlstate (objcg, pgdat, idx, nr_acct); nr_pages = nr_bytes >>PAGE_SHIFT ; nr_bytes = nr_bytes & (PAGE_SIZE -1 );atomic_add (nr_bytes, &objcg->nr_charged_bytes);
Greg Kroah-Hartman
maintainerPATCH 290/378 ksmbd: fix use-after-free in smb_lazy_parent_lease_break_close()
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit eac3361e3d5dd8067b3258c69615888eb45e9f25 upstream.
opinfo pointer obtained via rcu_dereference(fp->f_opinfo) is being accessed after rcu_read_unlock() has been called. This creates a race condition where the memory could be freed by a concurrent writer between the unlock and the subsequent pointer dereferences (opinfo->is_lease, etc.), leading to a use-after-free.
--- fs/smb/server/oplock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/smb/server/oplock.c +4 -2
@@ -1123,10 +1123,12 @@ void smb_lazy_parent_lease_break_close(srcu_read_lock (); opinfo =rcu_dereference (fp->f_opinfo); -rcu_read_unlock (); -if (!opinfo || !opinfo->is_lease || opinfo->o_lease->version !=2 ) +if (!opinfo || !opinfo->is_lease || opinfo->o_lease->version !=2 ) { +rcu_read_unlock ();return ; + } +rcu_read_unlock (); p_ci =ksmbd_inode_lookup_lock (fp->filp->f_path.dentry->d_parent);if (!p_ci)
Greg Kroah-Hartman
maintainerPATCH 291/378 smb: server: fix use-after-free in smb2_open()
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marios Makassikis <[email protected]>
commit 1e689a56173827669a35da7cb2a3c78ed5c53680 upstream.
The opinfo pointer obtained via rcu_dereference(fp->f_opinfo) is dereferenced after rcu_read_unlock(), creating a use-after-free window.
--- fs/smb/server/smb2pdu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/smb/server/smb2pdu.c +2 -3
@@ -3616,10 +3616,8 @@ int smb2_open(struct ksmbd_work *work) reconnected_fp: rsp->StructureSize =cpu_to_le16 (89 ); -rcu_read_lock (); - opinfo =rcu_dereference (fp->f_opinfo); + opinfo =opinfo_get (fp); rsp->OplockLevel = opinfo !=NULL ? opinfo->level :0 ; -rcu_read_unlock (); rsp->Flags =0 ; rsp->CreateAction =cpu_to_le32 (file_info); rsp->CreationTime =cpu_to_le64 (fp->create_time);
@@ -3660,6 +3658,7 @@ reconnected_fp: next_ptr = &lease_ccontext->Next; next_off = conn->vals->create_lease_size; } +opinfo_put (opinfo);if (maximal_access_ctxt) {struct create_context *mxac_ccontext;
Greg Kroah-Hartman
maintainerPATCH 292/378 ksmbd: Dont log keys in SMB3 signing and encryption key generation
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit 441336115df26b966575de56daf7107ed474faed upstream.
When KSMBD_DEBUG_AUTH logging is enabled, generate_smb3signingkey() and generate_smb3encryptionkey() log the session, signing, encryption, and decryption key bytes. Remove the logs to avoid exposing credentials.
--- fs/smb/server/auth.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-)
fs/smb/server/auth.c +2 -20
@@ -589,12 +589,8 @@ static int generate_smb3signingkey(strucif (!(conn->dialect >=SMB30_PROT_ID && signing->binding))memcpy (chann->smb3signingkey, key,SMB3_SIGN_KEY_SIZE ); -ksmbd_debug (AUTH ,"dumping generated AES signing keys\n" ); +ksmbd_debug (AUTH ,"generated SMB3 signing key\n" );ksmbd_debug (AUTH ,"Session Id %llu\n" , sess->id); -ksmbd_debug (AUTH ,"Session Key %*ph\n" , -SMB2_NTLMV2_SESSKEY_SIZE , sess->sess_key); -ksmbd_debug (AUTH ,"Signing Key %*ph\n" , -SMB3_SIGN_KEY_SIZE , key);return 0 ; }
@@ -652,23 +648,9 @@ static void generate_smb3encryptionkey(s ptwin->decryption.context, sess->smb3decryptionkey, SMB3_ENC_DEC_KEY_SIZE); -ksmbd_debug (AUTH ,"dumping generated AES encryption keys\n" ); +ksmbd_debug (AUTH ,"generated SMB3 encryption/decryption keys\n" );ksmbd_debug (AUTH ,"Cipher type %d\n" , conn->cipher_type);ksmbd_debug (AUTH ,"Session Id %llu\n" , sess->id); -ksmbd_debug (AUTH ,"Session Key %*ph\n" , -SMB2_NTLMV2_SESSKEY_SIZE , sess->sess_key); -if (conn->cipher_type ==SMB2_ENCRYPTION_AES256_CCM || - conn->cipher_type ==SMB2_ENCRYPTION_AES256_GCM ) { -ksmbd_debug (AUTH ,"ServerIn Key %*ph\n" , -SMB3_GCM256_CRYPTKEY_SIZE , sess->smb3encryptionkey); -ksmbd_debug (AUTH ,"ServerOut Key %*ph\n" , -SMB3_GCM256_CRYPTKEY_SIZE , sess->smb3decryptionkey); - }else { -ksmbd_debug (AUTH ,"ServerIn Key %*ph\n" , -SMB3_GCM128_CRYPTKEY_SIZE , sess->smb3encryptionkey); -ksmbd_debug (AUTH ,"ServerOut Key %*ph\n" , -SMB3_GCM128_CRYPTKEY_SIZE , sess->smb3decryptionkey); - } } void ksmbd_gen_smb30_encryptionkey(struct ksmbd_conn *conn,
Greg Kroah-Hartman
maintainerPATCH 293/378 ksmbd: fix use-after-free by using call_rcu() for oplock_info
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit 1dfd062caa165ec9d7ee0823087930f3ab8a6294 upstream.
ksmbd currently frees oplock_info immediately using kfree(), even though it is accessed under RCU read-side critical sections in places like opinfo_get() and proc_show_files().
Since there is no RCU grace period delay between nullifying the pointer and freeing the memory, a reader can still access oplock_info structure after it has been freed. This can leads to a use-after-free especially in opinfo_get() where atomic_inc_not_zero() is called on already freed memory.
Fix this by switching to deferred freeing using call_rcu().
--- fs/smb/server/oplock.c | 29 +++++++++++++++++++++-------- fs/smb/server/oplock.h | 5 +++-- 2 files changed, 24 insertions(+), 10 deletions(-)
fs/smb/server/oplock.c +21 -8
@@ -120,7 +120,7 @@ static void free_lease(struct oplock_infkfree (lease); } -static void free_opinfo (struct oplock_info *opinfo) +static void __free_opinfo (struct oplock_info *opinfo) {if (opinfo->is_lease)free_lease (opinfo);
@@ -129,6 +129,18 @@ static void free_opinfo(struct oplock_inkfree (opinfo); } +static void free_opinfo_rcu (struct rcu_head *rcu) +{ + struct oplock_info *opinfo = container_of(rcu, struct oplock_info, rcu); + +__free_opinfo (opinfo); +} + +static void free_opinfo (struct oplock_info *opinfo) +{ +call_rcu (&opinfo->rcu, free_opinfo_rcu); +} +struct oplock_info *opinfo_get (struct ksmbd_file *fp) {struct oplock_info *opinfo;
@@ -176,9 +188,9 @@ void opinfo_put(struct oplock_info *opinfree_opinfo (opinfo); } -static void opinfo_add (struct oplock_info *opinfo) +static void opinfo_add (struct oplock_info *opinfo,struct ksmbd_file *fp) { -struct ksmbd_inode *ci = opinfo->o_fp->f_ci; +struct ksmbd_inode *ci = fp->f_ci;down_write (&ci->m_lock);list_add (&opinfo->op_entry, &ci->m_op_list);
@@ -1279,20 +1291,21 @@ set_lev:set_oplock_level (opinfo, req_op_level, lctx); out: -rcu_assign_pointer (fp->f_opinfo, opinfo); - opinfo->o_fp = fp; -opinfo_count_inc (fp); -opinfo_add (opinfo); +opinfo_add (opinfo, fp); +if (opinfo->is_lease) { err =add_lease_global_list (opinfo);if (err) goto err_out; } +rcu_assign_pointer (fp->f_opinfo, opinfo); + opinfo->o_fp = fp; +return 0 ; err_out: -free_opinfo (opinfo); +__free_opinfo (opinfo);return err; }
fs/smb/server/oplock.h +3 -2
@@ -69,8 +69,9 @@ struct oplock_info {struct lease *o_lease;struct list_head op_entry;struct list_head lease_entry; -wait_queue_head_t oplock_q;/* Other server threads */ -wait_queue_head_t oplock_brk;/* oplock breaking wait */ +wait_queue_head_t oplock_q;/* Other server threads */ +wait_queue_head_t oplock_brk;/* oplock breaking wait */ +struct rcu_head rcu; };struct lease_break_info {
Greg Kroah-Hartman
maintainerPATCH 294/378 net: mctp: fix device leak on probe failure
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 224a0d284c3caf1951302d1744a714784febed71 upstream.
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
This driver takes a reference to the USB device during probe but does not to release it on probe failures.
Drop the redundant device reference to fix the leak, reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of further memory leaks.
--- drivers/net/mctp/mctp-usb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/mctp/mctp-usb.c +1 -2
@@ -329,7 +329,7 @@ static int mctp_usb_probe(struct usb_intSET_NETDEV_DEV (netdev, &intf->dev); dev =netdev_priv (netdev); dev->netdev = netdev; - dev->usbdev =usb_get_dev (interface_to_usbdev (intf)); + dev->usbdev =interface_to_usbdev (intf); dev->intf = intf;usb_set_intfdata (intf, dev);
@@ -365,7 +365,6 @@ static void mctp_usb_disconnect(struct umctp_unregister_netdev (dev->netdev);usb_free_urb (dev->tx_urb);usb_free_urb (dev->rx_urb); -usb_put_dev (dev->usbdev);free_netdev (dev->netdev); }
Greg Kroah-Hartman
maintainerPATCH 295/378 net: nexthop: fix percpu use-after-free in remove_nh_grp_entry
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mehul Rao <[email protected]>
commit b2662e7593e94ae09b1cf7ee5f09160a3612bcb2 upstream.
When removing a nexthop from a group, remove_nh_grp_entry() publishes the new group via rcu_assign_pointer() then immediately frees the removed entry's percpu stats with free_percpu(). However, the synchronize_net() grace period in the caller remove_nexthop_from_groups() runs after the free. RCU readers that entered before the publish still see the old group and can dereference the freed stats via nh_grp_entry_stats_inc() -> get_cpu_ptr(nhge->stats), causing a use-after-free on percpu memory.
Fix by deferring the free_percpu() until after synchronize_net() in the caller. Removed entries are chained via nh_list onto a local deferred free list. After the grace period completes and all RCU readers have finished, the percpu stats are safely freed.
--- net/ipv4/nexthop.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
net/ipv4/nexthop.c +11 -3
@@ -2005,7 +2005,8 @@ static void nh_hthr_group_rebalance(stru }static void remove_nh_grp_entry (struct net *net,struct nh_grp_entry *nhge, -struct nl_info *nlinfo) +struct nl_info *nlinfo, +struct list_head *deferred_free) {struct nh_grp_entry *nhges, *new_nhges;struct nexthop *nhp = nhge->nh_parent;
@@ -2065,8 +2066,8 @@ static void remove_nh_grp_entry(struct nrcu_assign_pointer (nhp->nh_grp, newg);list_del (&nhge->nh_list); -free_percpu (nhge->stats);nexthop_put (nhge->nh); +list_add (&nhge->nh_list, deferred_free);/* Removal of a NH from a resilient group is notified through * bucket notifications.
@@ -2086,6 +2087,7 @@ static void remove_nexthop_from_groups(s struct nl_info *nlinfo) {struct nh_grp_entry *nhge, *tmp; +LIST_HEAD (deferred_free);/* If there is nothing to do, let's avoid the costly call to * synchronize_net()
@@ -2094,10 +2096,16 @@ static void remove_nexthop_from_groups(sreturn ;list_for_each_entry_safe (nhge, tmp, &nh->grp_list, nh_list) -remove_nh_grp_entry (net, nhge, nlinfo); +remove_nh_grp_entry (net, nhge, nlinfo, &deferred_free);/* make sure all see the newly published array before releasing rtnl */ synchronize_net (); + +/* Now safe to free percpu stats — all RCU readers have finished */ +list_for_each_entry_safe (nhge, tmp, &deferred_free, nh_list) { +list_del (&nhge->nh_list); +free_percpu (nhge->stats); + } }static void remove_nexthop_group (struct nexthop *nh,struct nl_info *nlinfo)
Greg Kroah-Hartman
maintainerPATCH 296/378 net: ncsi: fix skb leak in error paths
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jian Zhang <[email protected]>
commit 5c3398a54266541610c8d0a7082e654e9ff3e259 upstream.
Early return paths in NCSI RX and AEN handlers fail to release the received skb, resulting in a memory leak.
Specifically, ncsi_aen_handler() returns on invalid AEN packets without consuming the skb. Similarly, ncsi_rcv_rsp() exits early when failing to resolve the NCSI device, response handler, or request, leaving the skb unfreed.
--- net/ncsi/ncsi-aen.c | 3 ++- net/ncsi/ncsi-rsp.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-)
net/ncsi/ncsi-aen.c +2 -1
@@ -224,7 +224,8 @@ int ncsi_aen_handler(struct ncsi_dev_priif (!nah) {netdev_warn (ndp->ndev.dev,"Invalid AEN (0x%x) received\n" , h->type); -return -ENOENT ; + ret = -ENOENT ; + goto out; } ret =ncsi_validate_aen_pkt (h, nah->payload);
net/ncsi/ncsi-rsp.c +12 -4
@@ -1176,8 +1176,10 @@ int ncsi_rcv_rsp(struct sk_buff *skb, st/* Find the NCSI device */ nd =ncsi_find_dev (orig_dev); ndp = nd ?TO_NCSI_DEV_PRIV (nd) :NULL ; -if (!ndp) -return -ENODEV ; +if (!ndp) { + ret = -ENODEV ; + goto err_free_skb; + }/* Check if it is AEN packet */ hdr = (struct ncsi_pkt_hdr *)skb_network_header (skb);
@@ -1199,7 +1201,8 @@ int ncsi_rcv_rsp(struct sk_buff *skb, stif (!nrh) {netdev_err (nd->dev,"Received unrecognized packet (0x%x)\n" , hdr->type); -return -ENOENT ; + ret = -ENOENT ; + goto err_free_skb; }/* Associate with the request */
@@ -1207,7 +1210,8 @@ int ncsi_rcv_rsp(struct sk_buff *skb, st nr = &ndp->requests[hdr->id];if (!nr->used) {spin_unlock_irqrestore (&ndp->lock, flags); -return -ENODEV ; + ret = -ENODEV ; + goto err_free_skb; } nr->rsp = skb;
@@ -1261,4 +1265,8 @@ out_netlink: out:ncsi_free_request (nr);return ret; + +err_free_skb: +kfree_skb (skb); +return ret; }
Greg Kroah-Hartman
maintainerPATCH 297/378 net: ethernet: arc: emac: quiesce interrupts before requesting IRQ
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit 2503d08f8a2de618e5c3a8183b250ff4a2e2d52c upstream.
Normal RX/TX interrupts are enabled later, in arc_emac_open(), so probe should not see interrupt delivery in the usual case. However, hardware may still present stale or latched interrupt status left by firmware or the bootloader.
If probe later unwinds after devm_request_irq() has installed the handler, such a stale interrupt can still reach arc_emac_intr() during teardown and race with release of the associated net_device.
Avoid that window by putting the device into a known quiescent state before requesting the IRQ: disable all EMAC interrupt sources and clear any pending EMAC interrupt status bits. This keeps the change hardware-focused and minimal, while preventing spurious IRQ delivery from leftover state.
--- drivers/net/ethernet/arc/emac_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/ethernet/arc/emac_main.c +11 -0
@@ -934,6 +934,17 @@ int arc_emac_probe(struct net_device *nd/* Set poll rate so that it polls every 1 ms */ arc_reg_set (priv,R_POLLRATE , clock_frequency /1000000 ); +/* +* Put the device into a known quiescent state before requesting +* the IRQ. Clear only EMAC interrupt status bits here; leave the +* MDIO completion bit alone and avoid writing TXPL_MASK, which is +* used to force TX polling rather than acknowledge interrupts. +*/ +arc_reg_set (priv,R_ENABLE ,0 ); +arc_reg_set (priv,R_STATUS ,RXINT_MASK |TXINT_MASK |ERR_MASK | +TXCH_MASK |MSER_MASK |RXCR_MASK | +RXFR_MASK |RXFL_MASK ); + ndev->irq = irq;dev_info (dev,"IRQ is %d\n" , ndev->irq);
Greg Kroah-Hartman
maintainerPATCH 298/378 net: dsa: microchip: Fix error path in PTP IRQ setup
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bastien Curutchet (Schneider Electric) <[email protected]>
commit 99c8c16a4aad0b37293cae213e15957c573cf79b upstream.
If request_threaded_irq() fails during the PTP message IRQ setup, the newly created IRQ mapping is never disposed. Indeed, the ksz_ptp_irq_setup()'s error path only frees the mappings that were successfully set up.
Dispose the newly created mapping if the associated request_threaded_irq() fails at setup.
--- drivers/net/dsa/microchip/ksz_ptp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/dsa/microchip/ksz_ptp.c +8 -3
@@ -1095,6 +1095,7 @@ static int ksz_ptp_msg_irq_setup(structconst struct ksz_dev_ops *ops = port->ksz_dev->dev_ops;struct ksz_irq *ptpirq = &port->ptpirq;struct ksz_ptp_irq *ptpmsg_irq; +int ret; ptpmsg_irq = &port->ptpmsg_irq[n]; ptpmsg_irq->num =irq_create_mapping (ptpirq->domain, n);
@@ -1106,9 +1107,13 @@ static int ksz_ptp_msg_irq_setup(structstrscpy (ptpmsg_irq->name, name[n]); -return request_threaded_irq (ptpmsg_irq->num,NULL , - ksz_ptp_msg_thread_fn,IRQF_ONESHOT , - ptpmsg_irq->name, ptpmsg_irq); + ret =request_threaded_irq (ptpmsg_irq->num,NULL , + ksz_ptp_msg_thread_fn,IRQF_ONESHOT , + ptpmsg_irq->name, ptpmsg_irq); +if (ret) +irq_dispose_mapping (ptpmsg_irq->num); + +return ret; }int ksz_ptp_irq_setup (struct dsa_switch *ds,u8 p)
Greg Kroah-Hartman
maintainerPATCH 299/378 net: macb: Shuffle the tx ring before enabling tx
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kevin Hao <[email protected]>
commit 881a0263d502e1a93ebc13a78254e9ad19520232 upstream.
Quanyang observed that when using an NFS rootfs on an AMD ZynqMp board, the rootfs may take an extended time to recover after a suspend. Upon investigation, it was determined that the issue originates from a problem in the macb driver.
According to the Zynq UltraScale TRM [1], when transmit is disabled, the transmit buffer queue pointer resets to point to the address specified by the transmit buffer queue base address register.
In the current implementation, the code merely resets queue->tx_head and queue->tx_tail to '0'. This approach presents several issues:
- Packets already queued in the tx ring are silently lost, leading to memory leaks since the associated skbs cannot be released.
- Concurrent write access to queue->tx_head and queue->tx_tail may occur from macb_tx_poll() or macb_start_xmit() when these values are reset to '0'.
- The transmission may become stuck on a packet that has already been sent out, with its 'TX_USED' bit set, but has not yet been processed. However, due to the manipulation of 'queue->tx_head' and 'queue->tx_tail', macb_tx_poll() incorrectly assumes there are no packets to handle because queue->tx_head == queue->tx_tail. This issue is only resolved when a new packet is placed at this position. This is the root cause of the prolonged recovery time observed for the NFS root filesystem.
To resolve this issue, shuffle the tx ring and tx skb array so that the first unsent packet is positioned at the start of the tx ring. Additionally, ensure that updates to queue->tx_head and queue->tx_tail are properly protected with the appropriate lock.
[1] https://docs.amd.com/v/u/en-US/ug1085-zynq-ultrascale-trm
--- drivers/net/ethernet/cadence/macb_main.c | 98 ++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 3 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +95 -3
@@ -36,6 +36,7 @@#include <linux/tcp.h> #include <linux/types.h> #include <linux/udp.h> +#include <linux/gcd.h> #include <net/pkt_sched.h> #include "macb.h"
@@ -668,6 +669,97 @@ static void macb_mac_link_down(struct phnetif_tx_stop_all_queues (ndev); } +/* Use juggling algorithm to left rotate tx ring and tx skb array */ +static void gem_shuffle_tx_one_ring (struct macb_queue *queue) +{ +unsigned int head, tail, count, ring_size, desc_size; +struct macb_tx_skb tx_skb, *skb_curr, *skb_next; +struct macb_dma_desc *desc_curr, *desc_next; +unsigned int i, cycles, shift, curr, next; +struct macb *bp = queue->bp; +unsigned char desc[24 ]; +unsigned long flags; + + desc_size =macb_dma_desc_get_size (bp); + +if (WARN_ON_ONCE (desc_size >ARRAY_SIZE (desc))) +return ; + +spin_lock_irqsave (&queue->tx_ptr_lock, flags); + head = queue->tx_head; + tail = queue->tx_tail; + ring_size = bp->tx_ring_size; + count =CIRC_CNT (head, tail, ring_size); + +if (!(tail % ring_size)) + goto unlock; + +if (!count) { + queue->tx_head =0 ; + queue->tx_tail =0 ; + goto unlock; + } + + shift = tail % ring_size; + cycles =gcd (ring_size, shift); + +for (i =0 ; i < cycles; i++) { +memcpy (&desc,macb_tx_desc (queue, i), desc_size); +memcpy (&tx_skb,macb_tx_skb (queue, i), +sizeof (struct macb_tx_skb )); + + curr = i; + next = (curr + shift) % ring_size; + +while (next != i) { + desc_curr =macb_tx_desc (queue, curr); + desc_next =macb_tx_desc (queue, next); + +memcpy (desc_curr, desc_next, desc_size); + +if (next == ring_size -1 ) + desc_curr->ctrl &= ~MACB_BIT (TX_WRAP ); +if (curr == ring_size -1 ) + desc_curr->ctrl |=MACB_BIT (TX_WRAP ); + + skb_curr =macb_tx_skb (queue, curr); + skb_next =macb_tx_skb (queue, next); +memcpy (skb_curr, skb_next,sizeof (struct macb_tx_skb )); + + curr = next; + next = (curr + shift) % ring_size; + } + + desc_curr =macb_tx_desc (queue, curr); +memcpy (desc_curr, &desc, desc_size); +if (i == ring_size -1 ) + desc_curr->ctrl &= ~MACB_BIT (TX_WRAP ); +if (curr == ring_size -1 ) + desc_curr->ctrl |=MACB_BIT (TX_WRAP ); +memcpy (macb_tx_skb (queue, curr), &tx_skb, +sizeof (struct macb_tx_skb )); + } + + queue->tx_head = count; + queue->tx_tail =0 ; + +/* Make descriptor updates visible to hardware */ +wmb (); + +unlock: +spin_unlock_irqrestore (&queue->tx_ptr_lock, flags); +} + +/* Rotate the queue so that the tail is at index 0 */ +static void gem_shuffle_tx_rings (struct macb *bp) +{ +struct macb_queue *queue; +int q; + +for (q =0 , queue = bp->queues; q < bp->num_queues; q++, queue++) +gem_shuffle_tx_one_ring (queue); +} + static void macb_mac_link_up(struct phylink_config *config, struct phy_device *phy, unsigned int mode, phy_interface_t interface,
@@ -706,8 +798,6 @@ static void macb_mac_link_up(struct phyl ctrl |=MACB_BIT (PAE );for (q =0 , queue = bp->queues; q < bp->num_queues; ++q, ++queue) { - queue->tx_head =0 ; - queue->tx_tail =0 ;queue_writel (queue,IER , bp->rx_intr_mask |MACB_TX_INT_FLAGS |MACB_BIT (HRESP )); }
@@ -721,8 +811,10 @@ static void macb_mac_link_up(struct phylspin_unlock_irqrestore (&bp->lock, flags); -if (!(bp->caps &MACB_CAPS_MACB_IS_EMAC )) +if (!(bp->caps &MACB_CAPS_MACB_IS_EMAC )) {macb_set_tx_clk (bp, speed); +gem_shuffle_tx_rings (bp); + }/* Enable Rx and Tx; Enable PTP unicast */ ctrl =macb_readl (bp,NCR );
Greg Kroah-Hartman
maintainerPATCH 300/378 drm/amd/pm: remove invalid gpu_metrics.energy_accumulator on smu v13.0.x
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Wang <[email protected]>
commit 68785c5e79e0fc1eacf63026fbba32be3867f410 upstream.
v1:
The metrics->EnergyAccumulator field has been deprecated on newer pmfw.
v2:
add smu 13.0.0/13.0.7/13.0.10 support.
--- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 8 +++++++- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +7 -1
@@ -2110,6 +2110,7 @@ static ssize_t smu_v13_0_0_get_gpu_metri (struct gpu_metrics_v1_3 *)smu_table->gpu_metrics_table;SmuMetricsExternal_t metrics_ext;SmuMetrics_t *metrics = &metrics_ext.SmuMetrics; +uint32_t mp1_ver =amdgpu_ip_version (smu->adev,MP1_HWIP ,0 );int ret =0 ; ret = smu_cmn_get_metrics_table(smu,
@@ -2134,7 +2135,12 @@ static ssize_t smu_v13_0_0_get_gpu_metri metrics->Vcn1ActivityPercentage); gpu_metrics->average_socket_power = metrics->AverageSocketPower; - gpu_metrics->energy_accumulator = metrics->EnergyAccumulator; + +if ((mp1_ver ==IP_VERSION (13 ,0 ,0 ) && smu->smc_fw_version <=0x004e1e00 ) || + (mp1_ver ==IP_VERSION (13 ,0 ,10 ) && smu->smc_fw_version <=0x00500800 )) + gpu_metrics->energy_accumulator = metrics->EnergyAccumulator; +else + gpu_metrics->energy_accumulator =UINT_MAX ;if (metrics->AverageGfxActivity <=SMU_13_0_0_BUSY_THRESHOLD ) gpu_metrics->average_gfxclk_frequency = metrics->AverageGfxclkFrequencyPostDs;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +2 -1
@@ -2120,7 +2120,8 @@ static ssize_t smu_v13_0_7_get_gpu_metri metrics->Vcn1ActivityPercentage); gpu_metrics->average_socket_power = metrics->AverageSocketPower; - gpu_metrics->energy_accumulator = metrics->EnergyAccumulator; + gpu_metrics->energy_accumulator = smu->smc_fw_version <=0x00521400 ? + metrics->EnergyAccumulator :UINT_MAX ;if (metrics->AverageGfxActivity <=SMU_13_0_7_BUSY_THRESHOLD ) gpu_metrics->average_gfxclk_frequency = metrics->AverageGfxclkFrequencyPostDs;
Greg Kroah-Hartman
maintainerPATCH 301/378 drm/amdgpu: Fix use-after-free race in VM acquire
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alysa Liu <[email protected]>
commit 2c1030f2e84885cc58bffef6af67d5b9d2e7098f upstream.
Replace non-atomic vm->process_info assignment with cmpxchg() to prevent race when parent/child processes sharing a drm_file both try to acquire the same VM after fork().
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +5 -1
@@ -1428,7 +1428,10 @@ static int init_kfd_vm(struct amdgpu_vm *process_info = info; } - vm->process_info = *process_info; +if (cmpxchg (&vm->process_info,NULL , *process_info) !=NULL ) { + ret = -EINVAL ; + goto already_acquired; + }/* Validate page directory and attach eviction fence */ ret =amdgpu_bo_reserve (vm->root.bo, true);
@@ -1468,6 +1471,7 @@ validate_pd_fail:amdgpu_bo_unreserve (vm->root.bo); reserve_pd_fail: vm->process_info =NULL ; +already_acquired:if (info) {dma_fence_put (&info->eviction_fence->base); *process_info =NULL ;
Greg Kroah-Hartman
maintainerPATCH 302/378 drm/amd: Set num IP blocks to 0 if discovery fails
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit 3646ff28780b4c52c5b5081443199e7a430110e5 upstream.
If discovery has failed for any reason (such as no support for a block) then there is no need to unwind all the IP blocks in fini. In this condition there can actually be failures during the unwind too.
Reset num_ip_blocks to zero during failure path and skip the unnecessary cleanup path.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
@@ -2843,8 +2843,10 @@ static int amdgpu_device_ip_early_init(sbreak ;default : r =amdgpu_discovery_set_ip_blocks (adev); -if (r) +if (r) { + adev->num_ip_blocks =0 ;return r; + }break ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
@@ -83,7 +83,7 @@ void amdgpu_driver_unload_kms(struct drm {struct amdgpu_device *adev =drm_to_adev (dev); -if (adev ==NULL ) +if (adev ==NULL || !adev->num_ip_blocks)return ;amdgpu_unregister_gpu_instance (adev);
Greg Kroah-Hartman
maintainerPATCH 303/378 drm/amd: Fix NULL pointer dereference in device cleanup
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit 062ea905fff7756b2e87143ffccaece5cdb44267 upstream.
When GPU initialization fails due to an unsupported HW block IP blocks may have a NULL version pointer. During cleanup in amdgpu_device_fini_hw, the code calls amdgpu_device_set_pg_state and amdgpu_device_set_cg_state which iterate over all IP blocks and access adev->ip_blocks[i].version without NULL checks, leading to a kernel NULL pointer dereference.
Add NULL checks for adev->ip_blocks[i].version in both amdgpu_device_set_cg_state and amdgpu_device_set_pg_state to prevent dereferencing NULL pointers during GPU teardown when initialization has failed.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
@@ -3404,6 +3404,8 @@ int amdgpu_device_set_cg_state(struct am i = state ==AMD_CG_STATE_GATE ? j : adev->num_ip_blocks - j -1 ;if (!adev->ip_blocks[i].status.late_initialized)continue ; +if (!adev->ip_blocks[i].version) +continue ;/* skip CG for GFX, SDMA on S0ix */ if (adev->in_s0ix && (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GFX ||
@@ -3443,6 +3445,8 @@ int amdgpu_device_set_pg_state(struct am i = state ==AMD_PG_STATE_GATE ? j : adev->num_ip_blocks - j -1 ;if (!adev->ip_blocks[i].status.late_initialized)continue ; +if (!adev->ip_blocks[i].version) +continue ;/* skip PG for GFX, SDMA on S0ix */ if (adev->in_s0ix && (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GFX ||
Greg Kroah-Hartman
maintainerPATCH 304/378 drm/bridge: ti-sn65dsi83: fix CHA_DSI_CLK_RANGE rounding
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Ceresoli <[email protected]>
commit 2f22702dc0fee06a240404e0f7ead5b789b253d8 upstream.
The DSI frequency must be in the range:
(CHA_DSI_CLK_RANGE * 5 MHz) <= DSI freq < ((CHA_DSI_CLK_RANGE + 1) * 5 MHz)
So the register value should point to the lower range value, but DIV_ROUND_UP() rounds the division to the higher range value, resulting in an excess of 1 (unless the frequency is an exact multiple of 5 MHz).
For example for a 437100000 MHz clock CHA_DSI_CLK_RANGE should be 87 (0x57):
(87 * 5 = 435) <= 437.1 < (88 * 5 = 440)
but current code returns 88 (0x58).
Fix the computation by removing the DIV_ROUND_UP().
--- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi83.c +3 -3
@@ -351,9 +351,9 @@ static u8 sn65dsi83_get_dsi_range(struct* DSI_CLK = mode clock * bpp / dsi_data_lanes / 2 * the 2 is there because the bus is DDR. */ -return DIV_ROUND_UP (clamp ((unsigned int )mode->clock * -mipi_dsi_pixel_format_to_bpp (ctx->dsi->format) / - ctx->dsi->lanes /2 ,40000U ,500000U ),5000U ); +return clamp ((unsigned int )mode->clock * +mipi_dsi_pixel_format_to_bpp (ctx->dsi->format) / + ctx->dsi->lanes /2 ,40000U ,500000U ) /5000U ; }static u8 sn65dsi83_get_dsi_div (struct sn65dsi83 *ctx)
Greg Kroah-Hartman
maintainerPATCH 305/378 drm/bridge: ti-sn65dsi83: halve horizontal syncs for dual LVDS output
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Ceresoli <[email protected]>
commit d0d727746944096a6681dc6adb5f123fc5aa018d upstream.
Dual LVDS output (available on the SN65DSI84) requires HSYNC_PULSE_WIDTH and HORIZONTAL_BACK_PORCH to be divided by two with respect to the values used for single LVDS output.
While not clearly stated in the datasheet, this is needed according to the DSI Tuner [0] output. It also makes sense intuitively because in dual LVDS output two pixels at a time are output and so the output clock is half of the pixel clock.
Some dual-LVDS panels refuse to show any picture without this fix.
Divide by two HORIZONTAL_FRONT_PORCH too, even though this register is used only for test pattern generation which is not currently implemented by this driver.
[0] https://www.ti.com/tool/DSI-TUNER
--- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi83.c +4 -3
@@ -474,6 +474,7 @@ static void sn65dsi83_atomic_pre_enable( struct drm_atomic_state *state) {struct sn65dsi83 *ctx =bridge_to_sn65dsi83 (bridge); +const unsigned int dual_factor = ctx->lvds_dual_link ?2 :1 ;const struct drm_bridge_state *bridge_state;const struct drm_crtc_state *crtc_state;const struct drm_display_mode *mode;
@@ -606,18 +607,18 @@ static void sn65dsi83_atomic_pre_enable(/* 32 + 1 pixel clock to ensure proper operation */ le16val =cpu_to_le16 (32 +1 );regmap_bulk_write (ctx->regmap,REG_VID_CHA_SYNC_DELAY_LOW , &le16val,2 ); - le16val =cpu_to_le16 (mode->hsync_end - mode->hsync_start); + le16val =cpu_to_le16 ((mode->hsync_end - mode->hsync_start) / dual_factor);regmap_bulk_write (ctx->regmap,REG_VID_CHA_HSYNC_PULSE_WIDTH_LOW , &le16val,2 ); le16val =cpu_to_le16 (mode->vsync_end - mode->vsync_start);regmap_bulk_write (ctx->regmap,REG_VID_CHA_VSYNC_PULSE_WIDTH_LOW , &le16val,2 );regmap_write (ctx->regmap,REG_VID_CHA_HORIZONTAL_BACK_PORCH , - mode->htotal - mode->hsync_end); + (mode->htotal - mode->hsync_end) / dual_factor);regmap_write (ctx->regmap,REG_VID_CHA_VERTICAL_BACK_PORCH , mode->vtotal - mode->vsync_end);regmap_write (ctx->regmap,REG_VID_CHA_HORIZONTAL_FRONT_PORCH , - mode->hsync_start - mode->hdisplay); + (mode->hsync_start - mode->hdisplay) / dual_factor);regmap_write (ctx->regmap,REG_VID_CHA_VERTICAL_FRONT_PORCH , mode->vsync_start - mode->vdisplay);regmap_write (ctx->regmap,REG_VID_CHA_TEST_PATTERN ,0x00 );
Greg Kroah-Hartman
maintainerPATCH 306/378 drm/i915: Fix potential overflow of shmem scatterlist length
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Janusz Krzysztofik <[email protected]>
commit 029ae067431ab9d0fca479bdabe780fa436706ea upstream.
When a scatterlists table of a GEM shmem object of size 4 GB or more is populated with pages allocated from a folio, unsigned int .length attribute of a scatterlist may get overflowed if total byte length of pages allocated to that single scatterlist happens to reach or cross the 4GB limit. As a consequence, users of the object may suffer from hitting unexpected, premature end of the object's backing pages.
[278.780187] ------------[ cut here ]------------ [278.780377] WARNING: CPU: 1 PID: 2326 at drivers/gpu/drm/i915/i915_mm.c:55 remap_sg+0x199/0x1d0 [i915] ... [278.780654] CPU: 1 UID: 0 PID: 2326 Comm: gem_mmap_offset Tainted: G S U 6.17.0-rc1-CI_DRM_16981-ged823aaa0607+ #1 PREEMPT(voluntary) [278.780656] Tainted: [S]=CPU_OUT_OF_SPEC, [U]=USER [278.780658] Hardware name: Intel Corporation Meteor Lake Client Platform/MTL-P LP5x T3 RVP, BIOS MTLPFWI1.R00.3471.D91.2401310918 01/31/2024 [278.780659] RIP: 0010:remap_sg+0x199/0x1d0 [i915] ... [278.780786] Call Trace: [278.780787] <TASK> [278.780788] ? __apply_to_page_range+0x3e6/0x910 [278.780795] ? __pfx_remap_sg+0x10/0x10 [i915] [278.780906] apply_to_page_range+0x14/0x30 [278.780908] remap_io_sg+0x14d/0x260 [i915] [278.781013] vm_fault_cpu+0xd2/0x330 [i915] [278.781137] __do_fault+0x3a/0x1b0 [278.781140] do_fault+0x322/0x640 [278.781143] __handle_mm_fault+0x938/0xfd0 [278.781150] handle_mm_fault+0x12c/0x300 [278.781152] ? lock_mm_and_find_vma+0x4b/0x760 [278.781155] do_user_addr_fault+0x2d6/0x8e0 [278.781160] exc_page_fault+0x96/0x2c0 [278.781165] asm_exc_page_fault+0x27/0x30
...
That issue was apprehended by the author of a change that introduced it, and potential risk even annotated with a comment, but then never addressed.
When adding folio pages to a scatterlist table, take care of byte length of any single scatterlist not exceeding max_segment.
--- drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_shmem.c +9 -3
@@ -151,8 +151,12 @@ int shmem_sg_alloc_table(struct drm_i915 } }while (1 ); - nr_pages = min_t(unsigned long, -folio_nr_pages (folio), page_count - i); + nr_pages =min_array (((unsigned long []) { +folio_nr_pages (folio), + page_count - i, + max_segment /PAGE_SIZE , + }),3 ); +if (!i || sg->length >= max_segment ||folio_pfn (folio) != next_pfn) {
@@ -162,7 +166,9 @@ int shmem_sg_alloc_table(struct drm_i915 st->nents++;sg_set_folio (sg, folio, nr_pages *PAGE_SIZE ,0 ); }else { -/* XXX: could overflow? */ + nr_pages = min_t(unsigned long, nr_pages, + (max_segment - sg->length) /PAGE_SIZE ); + sg->length += nr_pages *PAGE_SIZE ; } next_pfn =folio_pfn (folio) + nr_pages;
Greg Kroah-Hartman
maintainerPATCH 307/378 drm/i915/psr: Repeat Selective Update area alignment
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jouni Högander <[email protected]>
commit 1be2fca84f520105413d0d89ed04bb0ff742ab16 upstream.
Currently we are aligning Selective Update area to cover cursor fully if needed only once. It may happen that cursor is in Selective Update area after pipe alignment and after that covering cursor plane only partially. Fix this by looping alignment as long as alignment isn't needed anymore.
v2:
- do not unecessarily loop if cursor was already fully covered
- rename aligned as su_area_changed
--- drivers/gpu/drm/i915/display/intel_psr.c | 50 +++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/display/intel_psr.c +38 -12
@@ -2667,11 +2667,12 @@ static void clip_area_update(struct drm_ overlap_damage_area->y2 = damage_area->y2; } -static void intel_psr2_sel_fetch_pipe_alignment (struct intel_crtc_state *crtc_state) +static bool intel_psr2_sel_fetch_pipe_alignment (struct intel_crtc_state *crtc_state) {struct intel_display *display =to_intel_display (crtc_state);const struct drm_dsc_config *vdsc_cfg = &crtc_state->dsc.config;u16 y_alignment; +bool su_area_changed = false;/* ADLP aligns the SU region to vdsc slice height in case dsc is enabled */ if (crtc_state->dsc.compression_enable &&
@@ -2680,10 +2681,18 @@ static void intel_psr2_sel_fetch_pipe_alelse y_alignment = crtc_state->su_y_granularity; - crtc_state->psr2_su_area.y1 -= crtc_state->psr2_su_area.y1 % y_alignment; -if (crtc_state->psr2_su_area.y2 % y_alignment) +if (crtc_state->psr2_su_area.y1 % y_alignment) { + crtc_state->psr2_su_area.y1 -= crtc_state->psr2_su_area.y1 % y_alignment; + su_area_changed = true; + } + +if (crtc_state->psr2_su_area.y2 % y_alignment) { crtc_state->psr2_su_area.y2 = ((crtc_state->psr2_su_area.y2 / y_alignment) +1 ) * y_alignment; + su_area_changed = true; + } + +return su_area_changed; }/*
@@ -2816,7 +2825,7 @@ int intel_psr2_sel_fetch_update(struct istruct intel_crtc_state *crtc_state =intel_atomic_get_new_crtc_state (state, crtc);struct intel_plane_state *new_plane_state, *old_plane_state;struct intel_plane *plane; -bool full_update = false, cursor_in_su_area = false; +bool full_update = false, su_area_changed;int i, ret;if (!crtc_state->enable_psr2_sel_fetch)
@@ -2923,15 +2932,32 @@ int intel_psr2_sel_fetch_update(struct iif (ret)return ret; -/* -* Adjust su area to cover cursor fully as necessary (early -* transport). This needs to be done after -* drm_atomic_add_affected_planes to ensure visible cursor is added into -* affected planes even when cursor is not updated by itself. -*/ -intel_psr2_sel_fetch_et_alignment (state, crtc, &cursor_in_su_area); +do { +bool cursor_in_su_area; -intel_psr2_sel_fetch_pipe_alignment (crtc_state); +/* +* Adjust su area to cover cursor fully as necessary +* (early transport). This needs to be done after +* drm_atomic_add_affected_planes to ensure visible +* cursor is added into affected planes even when +* cursor is not updated by itself. +*/ +intel_psr2_sel_fetch_et_alignment (state, crtc, &cursor_in_su_area); + + su_area_changed =intel_psr2_sel_fetch_pipe_alignment (crtc_state); + +/* +* If the cursor was outside the SU area before +* alignment, the alignment step (which only expands +* SU) may pull the cursor partially inside, so we +* must run ET alignment again to fully cover it. But +* if the cursor was already fully inside before +* alignment, expanding the SU area won't change that, +* so no further work is needed. +*/ +if (cursor_in_su_area) +break ; + }while (su_area_changed);/* * Now that we have the pipe damaged area check if it intersect with
Greg Kroah-Hartman
maintainerPATCH 308/378 drm/msm: Fix dma_free_attrs() buffer size
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
commit e4eb6e4dd6348dd00e19c2275e3fbaed304ca3bd upstream.
The gpummu->table buffer is alloc'd with size TABLE_SIZE + 32 in a2xx_gpummu_new() but freed with size TABLE_SIZE in a2xx_gpummu_destroy().
Change the free size to match the allocation.
Patchwork: https://patchwork.freedesktop.org/patch/707340/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a2xx_gpummu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a2xx_gpummu.c +1 -1
@@ -78,7 +78,7 @@ static void a2xx_gpummu_destroy(struct m {struct a2xx_gpummu *gpummu =to_a2xx_gpummu (mmu); -dma_free_attrs (mmu->dev,TABLE_SIZE , gpummu->table, gpummu->pt_base, +dma_free_attrs (mmu->dev,TABLE_SIZE +32 , gpummu->table, gpummu->pt_base,DMA_ATTR_FORCE_CONTIGUOUS );kfree (gpummu);
Greg Kroah-Hartman
maintainerPATCH 309/378 drm/amd: Fix a few more NULL pointer dereference in device cleanup
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit 72ecb1dae72775fa9fea0159d8445d620a0a2295 upstream.
I found a few more paths that cleanup fails due to a NULL version pointer on unsupported hardware.
Add NULL checks as applicable.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
@@ -3654,6 +3654,8 @@ static int amdgpu_device_ip_fini_early(sint i, r;for (i =0 ; i < adev->num_ip_blocks; i++) { +if (!adev->ip_blocks[i].version) +continue ;if (!adev->ip_blocks[i].version->funcs->early_fini)continue ;
@@ -3730,6 +3732,8 @@ static int amdgpu_device_ip_fini(structif (!adev->ip_blocks[i].status.sw)continue ; +if (!adev->ip_blocks[i].version) +continue ;if (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_GMC ) {amdgpu_ucode_free_bo (adev);amdgpu_free_static_csa (&adev->virt.csa_obj);
@@ -3756,6 +3760,8 @@ static int amdgpu_device_ip_fini(structfor (i = adev->num_ip_blocks -1 ; i >=0 ; i--) {if (!adev->ip_blocks[i].status.late_initialized)continue ; +if (!adev->ip_blocks[i].version) +continue ;if (adev->ip_blocks[i].version->funcs->late_fini) adev->ip_blocks[i].version->funcs->late_fini (&adev->ip_blocks[i]); adev->ip_blocks[i].status.late_initialized = false;
Greg Kroah-Hartman
maintainerPATCH 310/378 drm/msm/dpu: Correct the SA8775P intr_underrun/intr_underrun index
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhinav Kumar <[email protected]>
commit 4ce71cea574658f5c5c7412b1a3cc54efe4f9b50 upstream.
The intr_underrun and intr_vsync indices have been swapped, just simply corrects them.
Patchwork: https://patchwork.freedesktop.org/patch/709209/
--- drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_8_4_sa8775p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_8_4_sa8775p.h +2 -2
@@ -366,8 +366,8 @@ static const struct dpu_intf_cfg sa8775p .type = INTF_NONE, .controller_id = MSM_DP_CONTROLLER_0, /* pair with intf_0 for DP MST */ .prog_fetch_lines_worst_case = 24, - .intr_underrun = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 17), - .intr_vsync = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 16), + .intr_underrun = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 16), + .intr_vsync = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR, 17), }, { .name = "intf_7", .id = INTF_7, .base = 0x3b000, .len = 0x280,
Greg Kroah-Hartman
maintainerPATCH 311/378 drm/i915/vrr: Configure VRR timings after enabling TRANS_DDI_FUNC_CTL
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 237aab549676288d9255bb8dcc284738e56eaa31 upstream.
Apparently ICL may hang with an MCE if we write TRANS_VRR_VMAX/FLIPLINE before enabling TRANS_DDI_FUNC_CTL.
Personally I was only able to reproduce a hang (on an Dell XPS 7390 2-in-1) with an external display connected via a dock using a dodgy type-C cable that made the link training fail. After the failed link training the machine would hang. TGL seemed immune to the problem for whatever reason.
BSpec does tell us to configure VRR after enabling TRANS_DDI_FUNC_CTL as well. The DMC firmware also does the VRR restore in two stages:
- first stage seems to be unconditional and includes TRANS_VRR_CTL and a few other VRR registers, among other things
- second stage is conditional on the DDI being enabled, and includes TRANS_DDI_FUNC_CTL and TRANS_VRR_VMAX/VMIN/FLIPLINE, among other things
So let's reorder the steps to match to avoid the hang, and toss in an extra WARN to make sure we don't screw this up later.
BSpec: 22243
--- drivers/gpu/drm/i915/display/intel_display.c | 1 - drivers/gpu/drm/i915/display/intel_vrr.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_display.c +0 -1
@@ -1614,7 +1614,6 @@ static void hsw_configure_cpu_transcoder }intel_set_transcoder_timings (crtc_state); -intel_vrr_set_transcoder_timings (crtc_state);if (cpu_transcoder !=TRANSCODER_EDP ) intel_de_write(display, TRANS_MULT(display, cpu_transcoder),
drivers/gpu/drm/i915/display/intel_vrr.c +14 -0
@@ -529,6 +529,18 @@ void intel_vrr_set_transcoder_timings(coreturn ;/* +* Bspec says: +* "(note: VRR needs to be programmed after +* TRANS_DDI_FUNC_CTL and before TRANS_CONF)." +* +* In practice it turns out that ICL can hang if +* TRANS_VRR_VMAX/FLIPLINE are written before +* enabling TRANS_DDI_FUNC_CTL. +*/ +drm_WARN_ON (display->drm, + !(intel_de_read (display,TRANS_DDI_FUNC_CTL (display, cpu_transcoder)) &TRANS_DDI_FUNC_ENABLE )); + +/* * This bit seems to have two meanings depending on the platform: * TGL: generate VRR "safe window" for DSB vblank waits * ADL/DG2: make TRANS_SET_CONTEXT_LATENCY effective with VRR
@@ -754,6 +766,8 @@ void intel_vrr_transcoder_enable(const s {struct intel_display *display =to_intel_display (crtc_state); +intel_vrr_set_transcoder_timings (crtc_state); +if (!intel_vrr_possible (crtc_state))return ;
Greg Kroah-Hartman
maintainerPATCH 312/378 tracing: Fix enabling multiple events on the kernel command line and bootconfig
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrei-Alexandru Tachici <[email protected]>
commit 3b1679e086bb869ca02722f6bd29b3573a6a0e7e upstream.
Multiple events can be enabled on the kernel command line via a comma separator. But if the are specified one at a time, then only the last event is enabled. This is because the event names are saved in a temporary buffer, and each call by the init cmdline code will reset that buffer.
This also affects names in the boot config file, as it may call the callback multiple times with an example of:
kernel.trace_event = ":mod:rproc_qcom_common", ":mod:qrtr", ":mod:qcom_aoss"
Change the cmdline callback function to append a comma and the next value if the temporary buffer already has content.
--- kernel/trace/trace_events.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/trace/trace_events.c +5 -1
@@ -4341,7 +4341,11 @@ static char bootup_event_buf[COMMAND_LINstatic __init int setup_trace_event (char *str) { -strscpy (bootup_event_buf, str,COMMAND_LINE_SIZE ); +if (bootup_event_buf[0 ] !='\0' ) +strlcat (bootup_event_buf,"," ,COMMAND_LINE_SIZE ); + +strlcat (bootup_event_buf, str,COMMAND_LINE_SIZE ); +trace_set_ring_buffer_expanded (NULL );disable_tracing_selftest ("running event tracing" );
Greg Kroah-Hartman
maintainerPATCH 313/378 tracing: Fix trace_buf_size= cmdline parameter with sizes >= 2G
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Calvin Owens <[email protected]>
commit d008ba8be8984760e36d7dcd4adbd5a41a645708 upstream.
Some of the sizing logic through tracer_alloc_buffers() uses int internally, causing unexpected behavior if the user passes a value that does not fit in an int (on my x86 machine, the result is uselessly tiny buffers).
Fix by plumbing the parameter's real type (unsigned long) through to the ring buffer allocation functions, which already use unsigned long.
It has always been possible to create larger ring buffers via the sysfs
interface: this only affects the cmdline parameter.
--- kernel/trace/trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace.c +3 -3
@@ -10136,7 +10136,7 @@ static void setup_trace_scratch(struct t }static int -allocate_trace_buffer (struct trace_array *tr,struct array_buffer *buf,int size) +allocate_trace_buffer (struct trace_array *tr,struct array_buffer *buf,unsigned long size) {enum ring_buffer_flags rb_flags;struct trace_scratch *tscratch;
@@ -10191,7 +10191,7 @@ static void free_trace_buffer(struct arr } } -static int allocate_trace_buffers (struct trace_array *tr,int size) +static int allocate_trace_buffers (struct trace_array *tr,unsigned long size) {int ret;
@@ -11557,7 +11557,7 @@ __init static void enable_instances(void__init static int tracer_alloc_buffers (void ) { -int ring_buf_size; +unsigned long ring_buf_size;int ret = -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 314/378 net-shapers: dont free reply skb after genlmsg_reply()
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moses <[email protected]>
commit 57885276cc16a2e2b76282c808a4e84cbecb3aae upstream.
genlmsg_reply() hands the reply skb to netlink, and netlink_unicast() consumes it on all return paths, whether the skb is queued successfully or freed on an error path.
net_shaper_nl_get_doit() and net_shaper_nl_cap_get_doit() currently jump to free_msg after genlmsg_reply() fails and call nlmsg_free(msg), which can hit the same skb twice.
Return the genlmsg_reply() error directly and keep free_msg only for pre-reply failures.
--- net/shaper/shaper.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
net/shaper/shaper.c +2 -9
@@ -759,11 +759,7 @@ int net_shaper_nl_get_doit(struct sk_bufif (ret) goto free_msg; - ret =genlmsg_reply (msg, info); -if (ret) - goto free_msg; - -return 0 ; +return genlmsg_reply (msg, info); free_msg:nlmsg_free (msg);
@@ -1314,10 +1310,7 @@ int net_shaper_nl_cap_get_doit(struct skif (ret) goto free_msg; - ret =genlmsg_reply (msg, info); -if (ret) - goto free_msg; -return 0 ; +return genlmsg_reply (msg, info); free_msg:nlmsg_free (msg);
Greg Kroah-Hartman
maintainerPATCH 315/378 qmi_wwan: allow max_mtu above hard_mtu to control rx_urb_size
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Vivier <[email protected]>
commit 55f854dd5bdd8e19b936a00ef1f8d776ac32c7b0 upstream.
Commit c7159e960f14 ("usbnet: limit max_mtu based on device's hard_mtu") capped net->max_mtu to the device's hard_mtu in usbnet_probe(). While this correctly prevents oversized packets on standard USB network devices, it breaks the qmi_wwan driver.
qmi_wwan relies on userspace (e.g. ModemManager) setting a large MTU on the wwan0 interface to configure rx_urb_size via usbnet_change_mtu(). QMI modems negotiate USB transfer sizes of 16,383 or 32,767 bytes, and the USB receive buffers must be sized accordingly. With max_mtu capped to hard_mtu (~1500 bytes), userspace can no longer raise the MTU, the receive buffers remain small, and download speeds drop from >300 Mbps to ~0.8 Mbps.
Introduce a FLAG_NOMAXMTU driver flag that allows individual usbnet drivers to opt out of the max_mtu cap. Set this flag in qmi_wwan's driver_info structures to restore the previous behavior for QMI devices, while keeping the safety fix in place for all other usbnet drivers.
--- drivers/net/usb/qmi_wwan.c | 4 ++-- drivers/net/usb/usbnet.c | 7 ++++--- include/linux/usb/usbnet.h | 1 + 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/net/usb/qmi_wwan.c +2 -2
@@ -928,7 +928,7 @@ err:static const struct driver_info qmi_wwan_info = { .description ="WWAN/QMI device" , - .flags =FLAG_WWAN |FLAG_SEND_ZLP , + .flags =FLAG_WWAN |FLAG_NOMAXMTU |FLAG_SEND_ZLP , .bind = qmi_wwan_bind, .unbind = qmi_wwan_unbind, .manage_power = qmi_wwan_manage_power,
@@ -937,7 +937,7 @@ static const struct driver_info qmi_wwanstatic const struct driver_info qmi_wwan_info_quirk_dtr = { .description ="WWAN/QMI device" , - .flags =FLAG_WWAN |FLAG_SEND_ZLP , + .flags =FLAG_WWAN |FLAG_NOMAXMTU |FLAG_SEND_ZLP , .bind = qmi_wwan_bind, .unbind = qmi_wwan_unbind, .manage_power = qmi_wwan_manage_power,
drivers/net/usb/usbnet.c +4 -3
@@ -1821,11 +1821,12 @@ usbnet_probe(struct usb_interface *udev,if ((dev->driver_info->flags &FLAG_NOARP ) !=0 ) net->flags |=IFF_NOARP ; -if (net->max_mtu > (dev->hard_mtu - net->hard_header_len)) +if ((dev->driver_info->flags &FLAG_NOMAXMTU ) ==0 && + net->max_mtu > (dev->hard_mtu - net->hard_header_len)) net->max_mtu = dev->hard_mtu - net->hard_header_len; -if (net->mtu > net->max_mtu) - net->mtu = net->max_mtu; +if (net->mtu > (dev->hard_mtu - net->hard_header_len)) + net->mtu = dev->hard_mtu - net->hard_header_len; }else if (!info->in || !info->out) status =usbnet_get_endpoints (dev, udev);
include/linux/usb/usbnet.h +1 -0
@@ -132,6 +132,7 @@ struct driver_info {#define FLAG_MULTI_PACKET 0x2000#define FLAG_RX_ASSEMBLE 0x4000/* rx packets may span >1 frames */ #define FLAG_NOARP 0x8000/* device can't do ARP */ +#define FLAG_NOMAXMTU 0x10000/* allow max_mtu above hard_mtu */ /* init device ... can sleep, or cause probe() failure */ int (*bind)(struct usbnet *,struct usb_interface *);
Greg Kroah-Hartman
maintainerPATCH 316/378 can: dev: keep the max bitrate error at 5%
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haibo Chen <[email protected]>
commit 1eea46908c57abb7109b1fce024f366ae6c69c4f upstream.
Commit b360a13d44db ("can: dev: print bitrate error with two decimal digits") changed calculation of the bit rate error from on-tenth of a percent to on-hundredth of a percent, but forgot to adjust the scale of the CAN_CALC_MAX_ERROR constant.
Keeping the existing logic unchanged: Only when the bitrate error exceeds 5% should an error be returned. Otherwise, simply output a warning log.
--- drivers/net/can/dev/calc_bittiming.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/dev/calc_bittiming.c +1 -1
@@ -8,7 +8,7 @@#include <linux/units.h> #include <linux/can/dev.h> -#define CAN_CALC_MAX_ERROR 50/* in one-tenth of a percent */ +#define CAN_CALC_MAX_ERROR 500/* max error 5% */ /* CiA recommended sample points for Non Return to Zero encoding. */ static int can_calc_sample_point_nrz (const struct can_bittiming *bt)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 317/378 io_uring/kbuf: check if target buffer list is still legacy on recycle
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit c2c185be5c85d37215397c8e8781abf0a69bec1f upstream.
There's a gap between when the buffer was grabbed and when it potentially gets recycled, where if the list is empty, someone could've upgraded it to a ring provided type. This can happen if the request is forced via io-wq. The legacy recycling is missing checking if the buffer_list still exists, and if it's of the correct type. Add those checks.
--- io_uring/kbuf.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
io_uring/kbuf.c +11 -2
@@ -111,9 +111,18 @@ bool io_kbuf_recycle_legacy(struct io_ki buf = req->kbuf; bl =io_buffer_get_list (ctx, buf->bgid); -list_add (&buf->list, &bl->buf_list); - bl->nbufs++; +/* +* If the buffer list was upgraded to a ring-based one, or removed, +* while the request was in-flight in io-wq, drop it. +*/ +if (bl && !(bl->flags &IOBL_BUF_RING )) { +list_add (&buf->list, &bl->buf_list); + bl->nbufs++; + }else { +kfree (buf); + } req->flags &= ~REQ_F_BUFFER_SELECTED ; + req->kbuf =NULL ;io_ring_submit_unlock (ctx, issue_flags);return true;
Greg Kroah-Hartman
maintainerPATCH 318/378 cifs: make default value of retrans as zero
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit e3beefd3af09f8e460ddaf39063d3d7664d7ab59 upstream.
When retrans mount option was introduced, the default value was set as 1. However, in the light of some bugs that this has exposed recently we should change it to 0 and retain the old behaviour before this option was introduced.
--- fs/smb/client/fs_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/fs_context.c +1 -1
@@ -1998,7 +1998,7 @@ int smb3_init_fs_context(struct fs_conte ctx->backupuid_specified = false;/* no backup intent for a user */ ctx->backupgid_specified = false;/* no backup intent for a group */ - ctx->retrans =1 ; + ctx->retrans =0 ; ctx->reparse_type =CIFS_REPARSE_TYPE_DEFAULT ; ctx->symlink_type =CIFS_SYMLINK_TYPE_DEFAULT ; ctx->nonativesocket =0 ;
Greg Kroah-Hartman
maintainerPATCH 319/378 xfs: fix integer overflow in bmap intent sort comparator
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Li <[email protected]>
commit 362c490980867930a098b99f421268fbd7ca05fd upstream.
xfs_bmap_update_diff_items() sorts bmap intents by inode number using a subtraction of two xfs_ino_t (uint64_t) values, with the result truncated to int. This is incorrect when two inode numbers differ by more than INT_MAX (2^31 - 1), which is entirely possible on large XFS filesystems.
Fix this by replacing the subtraction with cmp_int().
--- fs/xfs/xfs_bmap_item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_bmap_item.c +1 -1
@@ -247,7 +247,7 @@ xfs_bmap_update_diff_items(struct xfs_bmap_intent *ba =bi_entry (a);struct xfs_bmap_intent *bb =bi_entry (b); -return ba->bi_owner->i_ino - bb->bi_owner->i_ino; +return cmp_int (ba->bi_owner->i_ino, bb->bi_owner->i_ino); }/* Log bmap updates in the intent item. */
Greg Kroah-Hartman
maintainerPATCH 320/378 xfs: fix returned valued from xfs_defer_can_append
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Maiolino <[email protected]>
commit 54fcd2f95f8d216183965a370ec69e1aab14f5da upstream.
xfs_defer_can_append returns a bool, it shouldn't be returning a NULL.
Found by code inspection.
--- fs/xfs/libxfs/xfs_defer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_defer.c +1 -1
@@ -809,7 +809,7 @@ xfs_defer_can_append(/* Paused items cannot absorb more work */ if (dfp->dfp_flags &XFS_DEFER_PAUSED ) -return NULL ; +return false;/* Already full? */ if (ops->max_items && dfp->dfp_count >= ops->max_items)
Greg Kroah-Hartman
maintainerPATCH 321/378 xfs: fix undersized l_iclog_roundoff values
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
commit 52a8a1ba883defbfe3200baa22cf4cd21985d51a upstream.
If the superblock doesn't list a log stripe unit, we set the incore log roundoff value to 512. This leads to corrupt logs and unmountable filesystems in generic/617 on a disk with 4k physical sectors...
XFS (sda1): Mounting V5 Filesystem ff3121ca-26e6-4b77-b742-aaff9a449e1c
XFS (sda1): Torn write (CRC failure) detected at log block 0x318e. Truncating head block from 0x3197. XFS (sda1): failed to locate log tail
XFS (sda1): log mount/recovery failed: error -74
XFS (sda1): log mount failed
XFS (sda1): Mounting V5 Filesystem ff3121ca-26e6-4b77-b742-aaff9a449e1c
XFS (sda1): Ending clean mount
...on the current xfsprogs for-next which has a broken mkfs. xfs_info shows this...
meta-data=/dev/sda1 isize=512 agcount=4, agsize=644992 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=1
= reflink=1 bigtime=1 inobtcount=1 nrext64=1
= exchange=1 metadir=1
data = bsize=4096 blocks=2579968, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1, parent=1
log =internal log bsize=4096 blocks=16384, version=2
= sectsz=4096 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
= rgcount=0 rgsize=268435456 extents
= zoned=0 start=0 reserved=0...observe that the log section has sectsz=4096 sunit=0, which means that the roundoff factor is 512, not 4096 as you'd expect. We should fix mkfs not to generate broken filesystems, but anyone can fuzz the ondisk superblock so we should be more cautious. I think the inadequate logic predates commit a6a65fef5ef8d0, but that's clearly going to require a different backport.
--- fs/xfs/xfs_log.c | 2 ++ 1 file changed, 2 insertions(+)
fs/xfs/xfs_log.c +2 -0
@@ -1399,6 +1399,8 @@ xlog_alloc_log(if (xfs_has_logv2 (mp) && mp->m_sb.sb_logsunit >1 ) log->l_iclog_roundoff = mp->m_sb.sb_logsunit; +else if (mp->m_sb.sb_logsectsize >0 ) + log->l_iclog_roundoff = mp->m_sb.sb_logsectsize;else log->l_iclog_roundoff =BBSIZE ;
Greg Kroah-Hartman
maintainerPATCH 322/378 xfs: ensure dquot item is deleted from AIL only after log shutdown
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Li <[email protected]>
commit 186ac39b8a7d3ec7ce9c5dd45e5c2730177f375c upstream.
In xfs_qm_dqflush(), when a dquot flush fails due to corruption (the out_abort error path), the original code removed the dquot log item from the AIL before calling xfs_force_shutdown(). This ordering introduces a subtle race condition that can lead to data loss after a crash.
The AIL tracks the oldest dirty metadata in the journal. The position of the tail item in the AIL determines the log tail LSN, which is the oldest LSN that must be preserved for crash recovery. When an item is removed from the AIL, the log tail can advance past the LSN of that item.
The race window is as follows: if the dquot item happens to be at the tail of the log, removing it from the AIL allows the log tail to advance. If a concurrent log write is sampling the tail LSN at the same time and subsequently writes a complete checkpoint (i.e., one containing a commit record) to disk before the shutdown takes effect, the journal will no longer protect the dquot's last modification. On the next mount, log recovery will not replay the dquot changes, even though they were never written back to disk, resulting in silent data loss.
Fix this by calling xfs_force_shutdown() before xfs_trans_ail_delete() in the out_abort path. Once the log is shut down, no new log writes can complete with an updated tail LSN, making it safe to remove the dquot item from the AIL.
--- fs/xfs/xfs_dquot.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/xfs/xfs_dquot.c +7 -1
@@ -1439,9 +1439,15 @@ xfs_qm_dqflush(return 0 ; out_abort: +/* +* Shut down the log before removing the dquot item from the AIL. +* Otherwise, the log tail may advance past this item's LSN while +* log writes are still in progress, making these unflushed changes +* unrecoverable on the next mount. +*/ +xfs_force_shutdown (mp,SHUTDOWN_CORRUPT_INCORE ); dqp->q_flags &= ~XFS_DQFLAG_DIRTY ;xfs_trans_ail_delete (lip,0 ); -xfs_force_shutdown (mp,SHUTDOWN_CORRUPT_INCORE );xfs_dqfunlock (dqp);return error; }
Greg Kroah-Hartman
maintainerPATCH 323/378 sched_ext: Fix enqueue_task_scx() truncation of upper enqueue flags
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit 57ccf5ccdc56954f2a91a7f66684fd31c566bde5 upstream.
enqueue_task_scx() takes int enq_flags from the sched_class interface. SCX enqueue flags starting at bit 32 (SCX_ENQ_PREEMPT and above) are silently truncated when passed through activate_task(). extra_enq_flags was added as a workaround - storing high bits in rq->scx.extra_enq_flags and OR-ing them back in enqueue_task_scx(). However, the OR target is still the int parameter, so the high bits are lost anyway.
The current impact is limited as the only affected flag is SCX_ENQ_PREEMPT which is informational to the BPF scheduler - its loss means the scheduler doesn't know about preemption but doesn't cause incorrect behavior.
Fix by renaming the int parameter to core_enq_flags and introducing a u64 enq_flags local that merges both sources. All downstream functions already take u64 enq_flags.
--- kernel/sched/ext.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/sched/ext.c +2 -3
@@ -1464,16 +1464,15 @@ static void clr_task_runnable(struct tas p->scx.flags |=SCX_TASK_RESET_RUNNABLE_AT ; } -static void enqueue_task_scx (struct rq *rq,struct task_struct *p,int enq_flags) +static void enqueue_task_scx (struct rq *rq,struct task_struct *p,int core_enq_flags) {struct scx_sched *sch = scx_root;int sticky_cpu = p->scx.sticky_cpu; +u64 enq_flags = core_enq_flags | rq->scx.extra_enq_flags;if (enq_flags &ENQUEUE_WAKEUP ) rq->scx.flags |=SCX_RQ_IN_WAKEUP ; - enq_flags |= rq->scx.extra_enq_flags; -if (sticky_cpu >=0 ) p->scx.sticky_cpu =-1 ;
Greg Kroah-Hartman
maintainerPATCH 324/378 s390/zcrypt: Enable AUTOSEL_DOM for CCA serialnr sysfs attribute
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harald Freudenberger <[email protected]>
commit 598bbefa8032cc58b564a81d1ad68bd815c8dc0f upstream.
The serialnr sysfs attribute for CCA cards when queried always used the default domain for sending the request down to the card. If for any reason exactly this default domain is disabled then the attribute code fails to retrieve the CCA info and the sysfs entry shows an empty string. Works as designed but the serial number is a card attribute and thus it does not matter which domain is used for the query. So if there are other domains on this card available, these could be used.
So extend the code to use AUTOSEL_DOM for the domain value to address any online domain within the card for querying the cca info and thus show the serialnr as long as there is one domain usable regardless of the default domain setting.
--- drivers/s390/crypto/zcrypt_ccamisc.c | 12 +++++++----- drivers/s390/crypto/zcrypt_cex4.c | 3 +-- 2 files changed, 8 insertions(+), 7 deletions(-)
drivers/s390/crypto/zcrypt_ccamisc.c +7 -5
@@ -1639,11 +1639,13 @@ int cca_get_info(u16 cardnr, u16 domain,memset (ci,0 ,sizeof (*ci)); -/* get first info from zcrypt device driver about this apqn */ - rc =zcrypt_device_status_ext (cardnr, domain, &devstat); -if (rc) -return rc; - ci->hwtype = devstat.hwtype; +/* if specific domain given, fetch status and hw info for this apqn */ +if (domain !=AUTOSEL_DOM ) { + rc =zcrypt_device_status_ext (cardnr, domain, &devstat); +if (rc) +return rc; + ci->hwtype = devstat.hwtype; + }/* * Prep memory for rule array and var array use.
drivers/s390/crypto/zcrypt_cex4.c +1 -2
@@ -84,8 +84,7 @@ static ssize_t cca_serialnr_show(structmemset (&ci,0 ,sizeof (ci)); -if (ap_domain_index >=0 ) -cca_get_info (ac->id, ap_domain_index, &ci,0 ); +cca_get_info (ac->id,AUTOSEL_DOM , &ci,0 );return sysfs_emit (buf,"%s\n" , ci.serial); }
Greg Kroah-Hartman
maintainerPATCH 325/378 dt-bindings: display: msm: Fix reg ranges and clocks on Glymur
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
commit 7403e87c138475a74e5176176778f391d847f42d upstream.
The Glymur platform has four DisplayPort controllers. The hardware supports four streams (MST) per controller. However, on Glymur the first three controllers only have two streams wired to the display subsystem, while the fourth controller operates in single-stream mode.
Add a dedicated clause for the Glymur compatible to require the register ranges for all four stream blocks, while allowing either one pixel clock (for the single-stream controller) or two pixel clocks (for the remaining controllers).
Update the Glymur MDSS schema example by adding the missing p2, p3, mst2link and mst3link register blocks. Without these, the bindings validation fails. Also replace the made-up register addresses with the actual addresses from the first controller to match the SoC devicetree description.
Patchwork: https://patchwork.freedesktop.org/patch/708518/
--- .../bindings/display/msm/dp-controller.yaml | 21 ++++++++++++++++++- .../display/msm/qcom,glymur-mdss.yaml | 16 ++++++++------ 2 files changed, 30 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/display/msm/dp-controller.yaml +20 -1
@@ -253,7 +253,6 @@ allOf: enum: # these platforms support 2 streams MST on some interfaces, # others are SST only - - qcom,glymur-dp - qcom,sc8280xp-dp - qcom,x1e80100-dp then:
@@ -310,6 +309,26 @@ allOf: minItems: 6 maxItems: 8 + - if: + properties: + compatible: + contains: + enum: + # these platforms support 2 streams MST on some interfaces, + # others are SST only, but all controllers have 4 ports + - qcom,glymur-dp + then: + properties: + reg: + minItems: 9 + maxItems: 9 + clocks: + minItems: 5 + maxItems: 6 + clocks-names: + minItems: 5 + maxItems: 6 + unevaluatedProperties: false examples:
Documentation/devicetree/bindings/display/msm/qcom,glymur-mdss.yaml +10 -6
@@ -176,13 +176,17 @@ examples: }; }; - displayport-controller@ae90000 { + displayport-controller@af54000 { compatible = "qcom,glymur-dp"; - reg = <0xae90000 0x200>, - <0xae90200 0x200>, - <0xae90400 0x600>, - <0xae91000 0x400>, - <0xae91400 0x400>; + reg = <0xaf54000 0x200>, + <0xaf54200 0x200>, + <0xaf55000 0xc00>, + <0xaf56000 0x400>, + <0xaf57000 0x400>, + <0xaf58000 0x400>, + <0xaf59000 0x400>, + <0xaf5a000 0x600>, + <0xaf5b000 0x600>; interrupt-parent = <&mdss>; interrupts = <12>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 326/378 ublk: fix NULL pointer dereference in ublk_ctrl_set_size()
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mehul Rao <[email protected]>
commit 25966fc097691e5c925ad080f64a2f19c5fd940a upstream.
ublk_ctrl_set_size() unconditionally dereferences ub->ub_disk via set_capacity_and_notify() without checking if it is NULL.
ub->ub_disk is NULL before UBLK_CMD_START_DEV completes (it is only assigned in ublk_ctrl_start_dev()) and after UBLK_CMD_STOP_DEV runs (ublk_detach_disk() sets it to NULL). Since the UBLK_CMD_UPDATE_SIZE handler performs no state validation, a user can trigger a NULL pointer dereference by sending UPDATE_SIZE to a device that has been added but not yet started, or one that has been stopped.
Fix this by checking ub->ub_disk under ub->mutex before dereferencing it, and returning -ENODEV if the disk is not available.
--- drivers/block/ublk_drv.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/block/ublk_drv.c +9 -3
@@ -3534,15 +3534,22 @@ static int ublk_ctrl_get_features(constreturn 0 ; } -static void ublk_ctrl_set_size (struct ublk_device *ub,const struct ublksrv_ctrl_cmd *header) +static int ublk_ctrl_set_size (struct ublk_device *ub,const struct ublksrv_ctrl_cmd *header) {struct ublk_param_basic *p = &ub->params.basic;u64 new_size = header->data[0 ]; +int ret =0 ;mutex_lock (&ub->mutex); +if (!ub->ub_disk) { + ret = -ENODEV ; + goto out; + } p->dev_sectors = new_size;set_capacity_and_notify (ub->ub_disk, p->dev_sectors); +out:mutex_unlock (&ub->mutex); +return ret; }struct count_busy {
@@ -3853,8 +3860,7 @@ static int ublk_ctrl_uring_cmd(struct io ret =ublk_ctrl_end_recovery (ub, &header);break ;case UBLK_CMD_UPDATE_SIZE : -ublk_ctrl_set_size (ub, &header); - ret =0 ; + ret =ublk_ctrl_set_size (ub, &header);break ;case UBLK_CMD_QUIESCE_DEV : ret =ublk_ctrl_quiesce_dev (ub, &header);
Greg Kroah-Hartman
maintainerPATCH 327/378 s390/dasd: Move quiesce state with pprc swap
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Haberland <[email protected]>
commit 40e9cd4ae8ec43b107ed2bff422a8fa39dcf4e4b upstream.
Quiesce and resume is a mechanism to suspend operations on DASD devices. In the context of a controlled copy pair swap operation, the quiesce operation is usually issued before the actual swap and a resume afterwards.
During the swap operation, the underlying device is exchanged. Therefore, the quiesce flag must be moved to the secondary device to ensure a consistent quiesce state after the swap.
The secondary device itself cannot be suspended separately because there is no separate block device representation for it.
--- drivers/s390/block/dasd_eckd.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/s390/block/dasd_eckd.c +5 -0
@@ -6182,6 +6182,11 @@ static int dasd_eckd_copy_pair_swap(stru dev_name(&secondary->cdev->dev), rc); } +if (primary->stopped &DASD_STOPPED_QUIESCE ) { +dasd_device_set_stop_bits (secondary,DASD_STOPPED_QUIESCE ); +dasd_device_remove_stop_bits (primary,DASD_STOPPED_QUIESCE ); + } +/* re-enable device */ dasd_device_remove_stop_bits (primary,DASD_STOPPED_PPRC );dasd_device_remove_stop_bits (secondary,DASD_STOPPED_PPRC );
Greg Kroah-Hartman
maintainerPATCH 328/378 s390/dasd: Copy detected format information to secondary device
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Haberland <[email protected]>
commit 4c527c7e030672efd788d0806d7a68972a7ba3c1 upstream.
During online processing for a DASD device an IO operation is started to determine the format of the device. CDL format contains specifically sized blocks at the beginning of the disk.
For a PPRC secondary device no real IO operation is possible therefore this IO request can not be started and this step is skipped for online processing of secondary devices. This is generally fine since the secondary is a copy of the primary device.
In case of an additional partition detection that is run after a swap operation the format information is needed to properly drive partition detection IO.
Currently the information is not passed leading to IO errors during partition detection and a wrongly detected partition table which in turn might lead to data corruption on the disk with the wrong partition table.
Fix by passing the format information from primary to secondary device.
--- drivers/s390/block/dasd_eckd.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/s390/block/dasd_eckd.c +11 -0
@@ -6135,6 +6135,7 @@ static void copy_pair_set_active(structstatic int dasd_eckd_copy_pair_swap (struct dasd_device *device,char *prim_busid,char *sec_busid) { +struct dasd_eckd_private *prim_priv, *sec_priv;struct dasd_device *primary, *secondary;struct dasd_copy_relation *copy;struct dasd_block *block;
@@ -6155,6 +6156,9 @@ static int dasd_eckd_copy_pair_swap(struif (!secondary)return DASD_COPYPAIRSWAP_SECONDARY ; + prim_priv = primary->private; + sec_priv = secondary->private; +/* * usually the device should be quiesced for swap * for paranoia stop device and requeue requests again
@@ -6187,6 +6191,13 @@ static int dasd_eckd_copy_pair_swap(strudasd_device_remove_stop_bits (primary,DASD_STOPPED_QUIESCE ); } +/* +* The secondary device never got through format detection, but since it +* is a copy of the primary device, the format is exactly the same; +* therefore, the detected layout can simply be copied. +*/ + sec_priv->uses_cdl = prim_priv->uses_cdl; +/* re-enable device */ dasd_device_remove_stop_bits (primary,DASD_STOPPED_PPRC );dasd_device_remove_stop_bits (secondary,DASD_STOPPED_PPRC );
Greg Kroah-Hartman
maintainerPATCH 329/378 powerpc/pseries: Correct MSI allocation tracking
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nam Cao <[email protected]>
commit 35e4f2a17eb40288f9bcdb09549fa04a63a96279 upstream.
The per-device MSI allocation calculation in pseries_irq_domain_alloc() is clearly wrong. It can still happen to work when nr_irqs is 1.
Correct it.
--- arch/powerpc/platforms/pseries/msi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/pseries/msi.c +1 -1
@@ -605,7 +605,7 @@ static int pseries_irq_domain_alloc(stru &pseries_msi_irq_chip, pseries_dev); } - pseries_dev->msi_used++; + pseries_dev->msi_used += nr_irqs;return 0 ; out:
Greg Kroah-Hartman
maintainerPATCH 330/378 powerpc64/bpf: fix kfunc call support
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hari Bathini <[email protected]>
commit 01b6ac72729610ae732ca2a66e3a642e23f6cd60 upstream.
Commit 61688a82e047 ("powerpc/bpf: enable kfunc call") inadvertently enabled kfunc call support for 32-bit powerpc but that support will not be possible until ABI mismatch between 32-bit powerpc and eBPF is handled in 32-bit powerpc JIT code. Till then, advertise support only for 64-bit powerpc. Also, in powerpc ABI, caller needs to extend the arguments properly based on signedness. The JIT code is responsible for handling this explicitly for kfunc calls as verifier can't handle this for each architecture-specific ABI needs. But this was not taken care of while kfunc call support was enabled for powerpc. Fix it by handling this with bpf_jit_find_kfunc_model() and using zero_extend() & sign_extend() helper functions.
--- arch/powerpc/net/bpf_jit_comp.c | 2 arch/powerpc/net/bpf_jit_comp64.c | 101 ++++++++++++++++++++++++++++++++++---- 2 files changed, 94 insertions(+), 9 deletions(-)
arch/powerpc/net/bpf_jit_comp.c +1 -1
@@ -437,7 +437,7 @@ void bpf_jit_free(struct bpf_prog *fp)bool bpf_jit_supports_kfunc_call (void ) { -return true; +return IS_ENABLED (CONFIG_PPC64 ); }bool bpf_jit_supports_arena (void )
arch/powerpc/net/bpf_jit_comp64.c +93 -8
119 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 331/378 powerpc64/bpf: fix the address returned by bpf_get_func_ip
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hari Bathini <[email protected]>
commit 157820264ac3dadfafffad63184b883eb28f9ae0 upstream.
bpf_get_func_ip() helper function returns the address of the traced function. It relies on the IP address stored at ctx - 16 by the bpf trampoline. On 64-bit powerpc, this address is recovered from LR accounting for OOL trampoline. But the address stored here was off by 4-bytes. Ensure the address is the actual start of the traced function.
--- arch/powerpc/net/bpf_jit_comp.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
arch/powerpc/net/bpf_jit_comp.c +19 -9
@@ -722,9 +722,9 @@ static int __arch_prepare_bpf_trampoline* retval_off [ return value ] * [ reg argN ] * [ ... ] -* regs_off [ reg_arg1 ] prog ctx context -* nregs_off [ args count ] -* ip_off [ traced function ] +* regs_off [ reg_arg1 ] prog_ctx +* nregs_off [ args count ] ((u64 *)prog_ctx)[-1] +* ip_off [ traced function ] ((u64 *)prog_ctx)[-2] * [ ... ] * run_ctx_off [ bpf_tramp_run_ctx ] * [ reg argN ]
@@ -824,7 +824,7 @@ static int __arch_prepare_bpf_trampolinebpf_trampoline_save_args (image, ctx, func_frame_offset, nr_regs, regs_off); -/* Save our return address */ +/* Save our LR/return address */ EMIT (PPC_RAW_MFLR (_R3));if (IS_ENABLED (CONFIG_PPC_FTRACE_OUT_OF_LINE ))EMIT (PPC_RAW_STL (_R3, _R1, alt_lr_off));
@@ -832,24 +832,34 @@ static int __arch_prepare_bpf_trampolineEMIT (PPC_RAW_STL (_R3, _R1, bpf_frame_size +PPC_LR_STKOFF ));/* -* Save ip address of the traced function. -* We could recover this from LR, but we will need to address for OOL trampoline, -* and optional GEP area. +* Derive IP address of the traced function. +* In case of CONFIG_PPC_FTRACE_OUT_OF_LINE or BPF program, LR points to the instruction +* after the 'bl' instruction in the OOL stub. Refer to ftrace_init_ool_stub() and +* bpf_arch_text_poke() for OOL stub of kernel functions and bpf programs respectively. +* Relevant stub sequence: +* +* bl <tramp> +* LR (R3) => mtlr r0 +* b <func_addr+4> +* +* Recover kernel function/bpf program address from the unconditional +* branch instruction at the end of OOL stub. */ if (IS_ENABLED (CONFIG_PPC_FTRACE_OUT_OF_LINE ) || flags &BPF_TRAMP_F_IP_ARG ) {EMIT (PPC_RAW_LWZ (_R4, _R3,4 ));EMIT (PPC_RAW_SLWI (_R4, _R4,6 ));EMIT (PPC_RAW_SRAWI (_R4, _R4,6 ));EMIT (PPC_RAW_ADD (_R3, _R3, _R4)); -EMIT (PPC_RAW_ADDI (_R3, _R3,4 )); }if (flags &BPF_TRAMP_F_IP_ARG )EMIT (PPC_RAW_STL (_R3, _R1, ip_off)); -if (IS_ENABLED (CONFIG_PPC_FTRACE_OUT_OF_LINE )) +if (IS_ENABLED (CONFIG_PPC_FTRACE_OUT_OF_LINE )) {/* Fake our LR for unwind */ +EMIT (PPC_RAW_ADDI (_R3, _R3,4 ));EMIT (PPC_RAW_STL (_R3, _R1, bpf_frame_size +PPC_LR_STKOFF )); + }/* Save function arg count -- see bpf_get_func_arg_cnt() */ EMIT (PPC_RAW_LI (_R3, nr_regs));
Greg Kroah-Hartman
maintainerPATCH 332/378 lib/bootconfig: fix off-by-one in xbc_verify_tree() unclosed brace error
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Law <[email protected]>
commit 39ebc8d7f561e1b64eca87353ef9b18e2825e591 upstream.
__xbc_open_brace() pushes entries with post-increment (open_brace[brace_index++]), so brace_index always points one past the last valid entry. xbc_verify_tree() reads open_brace[brace_index] to report which brace is unclosed, but this is one past the last pushed entry and contains stale/zero data, causing the error message to reference the wrong node.
Use open_brace[brace_index - 1] to correctly identify the unclosed brace. brace_index is known to be > 0 here since we are inside the if (brace_index) guard.
--- lib/bootconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bootconfig.c +1 -1
@@ -791,7 +791,7 @@ static int __init xbc_verify_tree(void)/* Brace closing */ if (brace_index) { - n = &xbc_nodes[open_brace[brace_index]]; + n = &xbc_nodes[open_brace[brace_index -1 ]];return xbc_parse_error ("Brace is not closed" ,xbc_node_get_data (n)); }
Greg Kroah-Hartman
maintainerPATCH 333/378 scsi: core: Fix error handling for scsi_alloc_sdev()
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxiao Bi <[email protected]>
commit 4ce7ada40c008fa21b7e52ab9d04e8746e2e9325 upstream.
After scsi_sysfs_device_initialize() was called, error paths must call __scsi_remove_device().
--- drivers/scsi/scsi_scan.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/scsi_scan.c +2 -6
@@ -360,12 +360,8 @@ static struct scsi_device *scsi_alloc_sd* default device queue depth to figure out sbitmap shift * since we use this queue depth most of times. */ -if (scsi_realloc_sdev_budget_map (sdev, depth)) { -kref_put (&sdev->host->tagset_refcnt, scsi_mq_free_tags); -put_device (&starget->dev); -kfree (sdev); - goto out; - } +if (scsi_realloc_sdev_budget_map (sdev, depth)) + goto out_device_destroy;scsi_change_queue_depth (sdev, depth);
Greg Kroah-Hartman
maintainerPATCH 334/378 x86/apic: Disable x2apic on resume if the kernel expects so
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shashank Balaji <[email protected]>
commit 8cc7dd77a1466f0ec58c03478b2e735a5b289b96 upstream.
When resuming from s2ram, firmware may re-enable x2apic mode, which may have been disabled by the kernel during boot either because it doesn't support IRQ remapping or for other reasons. This causes the kernel to continue using the xapic interface, while the hardware is in x2apic mode, which causes hangs. This happens on defconfig + bare metal + s2ram.
Fix this in lapic_resume() by disabling x2apic if the kernel expects it to be disabled, i.e. when x2apic_mode = 0.
The ACPI v6.6 spec, Section 16.3 [1] says firmware restores either the pre-sleep configuration or initial boot configuration for each CPU, including MSR state:
When executing from the power-on reset vector as a result of waking from an S2 or S3 sleep state, the platform firmware performs only the hardware initialization required to restore the system to either the state the platform was in prior to the initial operating system boot, or to the pre-sleep configuration state. In multiprocessor systems, non-boot processors should be placed in the same state as prior to the initial operating system boot.
(further ahead)
If this is an S2 or S3 wake, then the platform runtime firmware restores minimum context of the system before jumping to the waking vector. This includes:
CPU configuration. Platform runtime firmware restores the pre-sleep configuration or initial boot configuration of each CPU (MSR, MTRR, firmware update, SMBase, and so on). Interrupts must be disabled (for IA-32 processors, disabled by CLI instruction).
(and other things)
So at least as per the spec, re-enablement of x2apic by the firmware is allowed if "x2apic on" is a part of the initial boot configuration.
[1] https://uefi.org/specs/ACPI/6.6/16_Waking_and_Sleeping.html#initialization
[ bp: Massage. ]
--- arch/x86/kernel/apic/apic.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/x86/kernel/apic/apic.c +6 -0
@@ -1894,6 +1894,7 @@ void __init check_x2apic(void)static inline void try_to_enable_x2apic (int remap_mode) { }static inline void __x2apic_enable (void ) { } +static inline void __x2apic_disable (void ) { }#endif /* !CONFIG_X86_X2APIC */ void __init enable_IR_x2apic (void )
@@ -2456,6 +2457,11 @@ static void lapic_resume(void *data)if (x2apic_mode) {__x2apic_enable (); }else { +if (x2apic_enabled ()) { +pr_warn_once ("x2apic: re-enabled by firmware during resume. Disabling\n" ); +__x2apic_disable (); + } +/* * Make sure the APICBASE points to the right address *
Greg Kroah-Hartman
maintainerPATCH 335/378 kprobes: Remove unneeded warnings from __arm_kprobe_ftrace()
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
commit 5ef268cb7a0aac55521fd9881f1939fa94a8988e upstream.
Remove unneeded warnings for handled errors from __arm_kprobe_ftrace() because all caller handled the error correctly.
--- kernel/kprobes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/kprobes.c +2 -2
@@ -1070,12 +1070,12 @@ static int __arm_kprobe_ftrace(struct kplockdep_assert_held (&kprobe_mutex); ret =ftrace_set_filter_ip (ops, (unsigned long )p->addr,0 ,0 ); -if (WARN_ONCE (ret <0 ,"Failed to arm kprobe-ftrace at %pS (error %d)\n" , p->addr, ret)) +if (ret <0 )return ret;if (*cnt ==0 ) { ret =register_ftrace_function (ops); -if (WARN (ret <0 ,"Failed to register kprobe-ftrace (error %d)\n" , ret)) { +if (ret <0 ) {/* * At this point, sinec ops is not registered, we should be sefe from * registering empty filter.
Greg Kroah-Hartman
maintainerPATCH 336/378 lib/bootconfig: fix snprintf truncation check in xbc_node_compose_key_after()
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Law <[email protected]>
commit 1120a36bb1e9b9e22de75ecb4ef0b998f73a97f1 upstream.
snprintf() returns the number of characters that would have been written excluding the NUL terminator. Output is truncated when the return value is >= the buffer size, not just > the buffer size.
When ret == size, the current code takes the non-truncated path, advancing buf by ret and reducing size to 0. This is wrong because the output was actually truncated (the last character was replaced by NUL). Fix by using >= so the truncation path is taken correctly.
--- lib/bootconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bootconfig.c +1 -1
@@ -316,7 +316,7 @@ int __init xbc_node_compose_key_after(st depth ? "." : "");if (ret <0 )return ret; -if (ret > size) { +if (ret >= size) { size =0 ; }else { size -= ret;
Greg Kroah-Hartman
maintainerPATCH 337/378 lib/bootconfig: check bounds before writing in __xbc_open_brace()
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Law <[email protected]>
commit 560f763baa0f2c9a44da4294c06af071405ac46f upstream.
The bounds check for brace_index happens after the array write. While the current call pattern prevents an actual out-of-bounds access (the previous call would have returned an error), the write-before-check pattern is fragile and would become a real out-of-bounds write if the error return were ever not propagated.
Move the bounds check before the array write so the function is self-contained and safe regardless of caller behavior.
--- lib/bootconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bootconfig.c +1 -1
@@ -532,9 +532,9 @@ static char *skip_spaces_until_newline(cstatic int __init __xbc_open_brace (char *p) {/* Push the last key as open brace */ - open_brace[brace_index++] =xbc_node_index (last_parent);if (brace_index >=XBC_DEPTH_MAX )return xbc_parse_error ("Exceed max depth of braces" , p); + open_brace[brace_index++] =xbc_node_index (last_parent);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 338/378 smb: client: fix atomic open with O_DIRECT & O_SYNC
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit 4a7d2729dc99437dbb880a64c47828c0d191b308 upstream.
When user application requests O_DIRECT|O_SYNC along with O_CREAT on open(2), CREATE_NO_BUFFER and CREATE_WRITE_THROUGH bits were missed in CREATE request when performing an atomic open, thus leading to potentially data integrity issues.
Fix this by setting those missing bits in CREATE request when O_DIRECT|O_SYNC has been specified in cifs_do_create().
--- fs/smb/client/cifsglob.h | 11 +++++++++++ fs/smb/client/dir.c | 1 + fs/smb/client/file.c | 18 +++--------------- 3 files changed, 15 insertions(+), 15 deletions(-)
fs/smb/client/cifsglob.h +11 -0
@@ -20,6 +20,7 @@#include <linux/utsname.h> #include <linux/sched/mm.h> #include <linux/netfs.h> +#include <linux/fcntl.h> #include "cifs_fs_sb.h" #include "cifsacl.h" #include <crypto/internal/hash.h>
@@ -2313,4 +2314,14 @@ static inline void cifs_requeue_server_r queue_delayed_work(cifsiod_wq, &server->reconnect, delay * HZ); } +static inline int cifs_open_create_options (unsigned int oflags,int opts) +{ +/* O_SYNC also has bit for O_DSYNC so following check picks up either */ +if (oflags &O_SYNC ) + opts |=CREATE_WRITE_THROUGH ; +if (oflags &O_DIRECT ) + opts |=CREATE_NO_BUFFER ; +return opts; +} +#endif /* _CIFS_GLOB_H */
fs/smb/client/dir.c +1 -0
@@ -307,6 +307,7 @@ static int cifs_do_create(struct inode * goto out; } + create_options |=cifs_open_create_options (oflags, create_options);/* * if we're not using unix extensions, see if we need to set * ATTR_READONLY on the create call
fs/smb/client/file.c +3 -15
@@ -585,15 +585,8 @@ static int cifs_nt_open(const char *full*********************************************************************/ disposition =cifs_get_disposition (f_flags); -/* BB pass O_SYNC flag through on file attributes .. BB */ - -/* O_SYNC also has bit for O_DSYNC so following check picks up either */ -if (f_flags &O_SYNC ) - create_options |=CREATE_WRITE_THROUGH ; - -if (f_flags &O_DIRECT ) - create_options |=CREATE_NO_BUFFER ; + create_options |=cifs_open_create_options (f_flags, create_options); retry_open: oparms = (struct cifs_open_parms ) {
@@ -1319,13 +1312,8 @@ cifs_reopen_file(struct cifsFileInfo *cf rdwr_for_fscache =1 ; desired_access =cifs_convert_flags (cfile->f_flags, rdwr_for_fscache); - -/* O_SYNC also has bit for O_DSYNC so following check picks up either */ -if (cfile->f_flags &O_SYNC ) - create_options |=CREATE_WRITE_THROUGH ; - -if (cfile->f_flags &O_DIRECT ) - create_options |=CREATE_NO_BUFFER ; + create_options |=cifs_open_create_options (cfile->f_flags, + create_options);if (server->ops->get_lease_key) server->ops->get_lease_key (inode, &cfile->fid);
Greg Kroah-Hartman
maintainerPATCH 339/378 smb: client: fix in-place encryption corruption in SMB2_write()
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bharath SM <[email protected]>
commit d78840a6a38d312dc1a51a65317bb67e46f0b929 upstream.
SMB2_write() places write payload in iov[1..n] as part of rq_iov. smb3_init_transform_rq() pointer-shares rq_iov, so crypt_message() encrypts iov[1] in-place, replacing the original plaintext with ciphertext. On a replayable error, the retry sends the same iov[1] which now contains ciphertext instead of the original data, resulting in corruption.
The corruption is most likely to be observed when connections are unstable, as reconnects trigger write retries that re-send the already-encrypted data.
This affects SFU mknod, MF symlinks, etc. On kernels before 6.10 (prior to the netfs conversion), sync writes also used this path and were similarly affected. The async write path wasn't unaffected as it uses rq_iter which gets deep-copied.
Fix by moving the write payload into rq_iter via iov_iter_kvec(), so smb3_init_transform_rq() deep-copies it before encryption.
--- fs/smb/client/smb2pdu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/smb/client/smb2pdu.c +4 -1
@@ -5237,7 +5237,10 @@ replay_again:memset (&rqst,0 ,sizeof (struct smb_rqst )); rqst.rq_iov = iov; - rqst.rq_nvec = n_vec +1 ; +/* iov[0] is the SMB header; move payload to rq_iter for encryption safety */ + rqst.rq_nvec =1 ; +iov_iter_kvec (&rqst.rq_iter,ITER_SOURCE , &iov[1 ], n_vec, + io_parms->length);if (retries)smb2_set_replay (server, &rqst);
Greg Kroah-Hartman
maintainerPATCH 340/378 smb: client: fix iface port assignment in parse_server_interfaces
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henrique Carvalho <[email protected]>
commit d4c7210d2f3ea481a6481f03040a64d9077a6172 upstream.
parse_server_interfaces() initializes interface socket addresses with CIFS_PORT. When the mount uses a non-default port this overwrites the configured destination port.
Later, cifs_chan_update_iface() copies this sockaddr into server->dstaddr, causing reconnect attempts to use the wrong port after server interface updates.
Use the existing port from server->dstaddr instead.
--- fs/smb/client/smb2ops.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
fs/smb/client/smb2ops.c +12 -2
@@ -628,6 +628,7 @@ parse_server_interfaces(struct network_istruct smb_sockaddr_in6 *p6;struct cifs_server_iface *info =NULL , *iface =NULL , *niface =NULL ;struct cifs_server_iface tmp_iface; +__be16 port;ssize_t bytes_left;size_t next =0 ;int nb_iface =0 ;
@@ -662,6 +663,15 @@ parse_server_interfaces(struct network_i goto out; } +spin_lock (&ses->server->srv_lock); +if (ses->server->dstaddr.ss_family ==AF_INET ) + port = ((struct sockaddr_in *)&ses->server->dstaddr)->sin_port; +else if (ses->server->dstaddr.ss_family ==AF_INET6 ) + port = ((struct sockaddr_in6 *)&ses->server->dstaddr)->sin6_port; +else + port =cpu_to_be16 (CIFS_PORT ); +spin_unlock (&ses->server->srv_lock); +while (bytes_left >= (ssize_t )sizeof (*p)) {memset (&tmp_iface,0 ,sizeof (tmp_iface));/* default to 1Gbps when link speed is unset */
@@ -682,7 +692,7 @@ parse_server_interfaces(struct network_imemcpy (&addr4->sin_addr, &p4->IPv4Address,4 );/* [MS-SMB2] 2.2.32.5.1.1 Clients MUST ignore these */ - addr4->sin_port =cpu_to_be16 (CIFS_PORT ); + addr4->sin_port = port;cifs_dbg (FYI ,"%s: ipv4 %pI4\n" , __func__, &addr4->sin_addr);
@@ -696,7 +706,7 @@ parse_server_interfaces(struct network_i/* [MS-SMB2] 2.2.32.5.1.2 Clients MUST ignore these */ addr6->sin6_flowinfo =0 ; addr6->sin6_scope_id =0 ; - addr6->sin6_port =cpu_to_be16 (CIFS_PORT ); + addr6->sin6_port = port;cifs_dbg (FYI ,"%s: ipv6 %pI6\n" , __func__, &addr6->sin6_addr);
Greg Kroah-Hartman
maintainerPATCH 341/378 btrfs: fix transaction abort when snapshotting received subvolumes
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit e1b18b959025e6b5dbad668f391f65d34b39595a upstream.
Currently a user can trigger a transaction abort by snapshotting a previously received snapshot a bunch of times until we reach a BTRFS_UUID_KEY_RECEIVED_SUBVOL item overflow (the maximum item size we can store in a leaf). This is very likely not common in practice, but if it happens, it turns the filesystem into RO mode. The snapshot, send and set_received_subvol and subvol_setflags (used by receive) don't require CAP_SYS_ADMIN, just inode_owner_or_capable(). A malicious user could use this to turn a filesystem into RO mode and disrupt a system.
Reproducer script:
$ cat test.sh #!/bin/bash
DEV=/dev/sdi
MNT=/mnt/sdi
# Use smallest node size to make the test faster. mkfs.btrfs -f --nodesize 4K $DEV mount $DEV $MNT
# Create a subvolume and set it to RO so that it can be used for send. btrfs subvolume create $MNT/sv
touch $MNT/sv/foo
btrfs property set $MNT/sv ro true
# Send and receive the subvolume into snaps/sv.
mkdir $MNT/snaps
btrfs send $MNT/sv | btrfs receive $MNT/snaps
# Now snapshot the received subvolume, which has a received_uuid, a
# lot of times to trigger the leaf overflow.
total=500
for ((i = 1; i <= $total; i++)); do
echo -ne "\rCreating snapshot $i/$total"
btrfs subvolume snapshot -r $MNT/snaps/sv $MNT/snaps/sv_$i > /dev/null
done
echoumount $MNT
When running the test:
$ ./test.sh (...) Create subvolume '/mnt/sdi/sv' At subvol /mnt/sdi/sv At subvol sv Creating snapshot 496/500ERROR: Could not create subvolume: Value too large for defined data type Creating snapshot 497/500ERROR: Could not create subvolume: Read-only file system Creating snapshot 498/500ERROR: Could not create subvolume: Read-only file system Creating snapshot 499/500ERROR: Could not create subvolume: Read-only file system Creating snapshot 500/500ERROR: Could not create subvolume: Read-only file system
And in dmesg/syslog:
$ dmesg (...) [251067.627338] BTRFS warning (device sdi): insert uuid item failed -75 (0x4628b21c4ac8d898, 0x2598bee2b1515c91) type 252! [251067.629212] ------------[ cut here ]------------ [251067.630033] BTRFS: Transaction aborted (error -75) [251067.630871] WARNING: fs/btrfs/transaction.c:1907 at create_pending_snapshot.cold+0x52/0x465 [btrfs], CPU#10: btrfs/615235 [251067.632851] Modules linked in: btrfs dm_zero (...) [251067.644071] CPU: 10 UID: 0 PID: 615235 Comm: btrfs Tainted: G W 6.19.0-rc8-btrfs-next-225+ #1 PREEMPT(full) [251067.646165] Tainted: [W]=WARN [251067.646733] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org 04/01/2014 [251067.648735] RIP: 0010:create_pending_snapshot.cold+0x55/0x465 [btrfs] [251067.649984] Code: f0 48 0f (...) [251067.653313] RSP: 0018:ffffce644908fae8 EFLAGS: 00010292 [251067.653987] RAX: 00000000ffffff01 RBX: ffff8e5639e63a80 RCX: 00000000ffffffd3 [251067.655042] RDX: ffff8e53faa76b00 RSI: 00000000ffffffb5 RDI: ffffffffc0919750 [251067.656077] RBP: ffffce644908fbd8 R08: 0000000000000000 R09: ffffce644908f820 [251067.657068] R10: ffff8e5adc1fffa8 R11: 0000000000000003 R12: ffff8e53c0431bd0 [251067.658050] R13: ffff8e5414593600 R14: ffff8e55efafd000 R15: 00000000ffffffb5 [251067.659019] FS: 00007f2a4944b3c0(0000) GS:ffff8e5b27dae000(0000) knlGS:0000000000000000 [251067.660115] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [251067.660943] CR2: 00007ffc5aa57898 CR3: 00000005813a2003 CR4: 0000000000370ef0 [251067.661972] Call Trace: [251067.662292] <TASK> [251067.662653] create_pending_snapshots+0x97/0xc0 [btrfs] [251067.663413] btrfs_commit_transaction+0x26e/0xc00 [btrfs] [251067.664257] ? btrfs_qgroup_convert_reserved_meta+0x35/0x390 [btrfs] [251067.665238] ? _raw_spin_unlock+0x15/0x30 [251067.665837] ? record_root_in_trans+0xa2/0xd0 [btrfs] [251067.666531] btrfs_mksubvol+0x330/0x580 [btrfs] [251067.667145] btrfs_mksnapshot+0x74/0xa0 [btrfs] [251067.667827] __btrfs_ioctl_snap_create+0x194/0x1d0 [btrfs] [251067.668595] btrfs_ioctl_snap_create_v2+0x107/0x130 [btrfs] [251067.669479] btrfs_ioctl+0x1580/0x2690 [btrfs] [251067.670093] ? count_memcg_events+0x6d/0x180 [251067.670849] ? handle_mm_fault+0x1a0/0x2a0 [251067.671652] __x64_sys_ioctl+0x92/0xe0 [251067.672406] do_syscall_64+0x50/0xf20 [251067.673129] entry_SYSCALL_64_after_hwframe+0x76/0x7e [251067.674096] RIP: 0033:0x7f2a495648db [251067.674812] Code: 00 48 89 (...) [251067.678227] RSP: 002b:00007ffc5aa57840 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [251067.679691] RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f2a495648db [251067.681145] RDX: 00007ffc5aa588b0 RSI: 0000000050009417 RDI: 0000000000000004 [251067.682511] RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000 [251067.683842] R10: 000000000000000a R11: 0000000000000246 R12: 00007ffc5aa59910 [251067.685176] R13: 00007ffc5aa588b0 R14: 0000000000000004 R15: 0000000000000006 [251067.686524] </TASK> [251067.686972] ---[ end trace 0000000000000000 ]--- [251067.687890] BTRFS: error (device sdi state A) in create_pending_snapshot:1907: errno=-75 unknown [251067.689049] BTRFS info (device sdi state EA): forced readonly [251067.689054] BTRFS warning (device sdi state EA): Skipping commit of aborted transaction. [251067.690119] BTRFS: error (device sdi state EA) in cleanup_transaction:2043: errno=-75 unknown [251067.702028] BTRFS info (device sdi state EA): last unmount of filesystem 46dc3975-30a2-4a69-a18f-418b859cccda
Fix this by ignoring -EOVERFLOW errors from btrfs_uuid_tree_add() in the snapshot creation code when attempting to add the BTRFS_UUID_KEY_RECEIVED_SUBVOL item. This is OK because it's not critical and we are still able to delete the snapshot, as snapshot/subvolume deletion ignores if a BTRFS_UUID_KEY_RECEIVED_SUBVOL is missing (see inode.c:btrfs_delete_subvolume()). As for send/receive, we can still do send/receive operations since it always peeks the first root ID in the existing BTRFS_UUID_KEY_RECEIVED_SUBVOL (it could peek any since all snapshots have the same content), and even if the key is missing, it falls back to searching by BTRFS_UUID_KEY_SUBVOL key.
A test case for fstests will be sent soon.
--- fs/btrfs/transaction.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
fs/btrfs/transaction.c +16 -0
@@ -1904,6 +1904,22 @@ static noinline int create_pending_snaps ret =btrfs_uuid_tree_add (trans, new_root_item->received_uuid,BTRFS_UUID_KEY_RECEIVED_SUBVOL , objectid); +/* +* We are creating of lot of snapshots of the same root that was +* received (has a received UUID) and reached a leaf's limit for +* an item. We can safely ignore this and avoid a transaction +* abort. A deletion of this snapshot will still work since we +* ignore if an item with a BTRFS_UUID_KEY_RECEIVED_SUBVOL key +* is missing (see btrfs_delete_subvolume()). Send/receive will +* work too since it peeks the first root id from the existing +* item (it could peek any), and in case it's missing it +* falls back to search by BTRFS_UUID_KEY_SUBVOL keys. +* Creation of a snapshot does not require CAP_SYS_ADMIN, so +* we don't want users triggering transaction aborts, either +* intentionally or not. +*/ +if (ret == -EOVERFLOW ) + ret =0 ;if (unlikely (ret && ret != -EEXIST )) {btrfs_abort_transaction (trans, ret); goto fail;
Greg Kroah-Hartman
maintainerPATCH 342/378 btrfs: fix transaction abort on file creation due to name hash collision
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 2d1ababdedd4ba38867c2500eb7f95af5ddeeef7 upstream.
If we attempt to create several files with names that result in the same hash, we have to pack them in same dir item and that has a limit inherent to the leaf size. However if we reach that limit, we trigger a transaction abort and turns the filesystem into RO mode. This allows for a malicious user to disrupt a system, without the need to have administration privileges/capabilities.
Reproducer:
$ cat exploit-hash-collisions.sh #!/bin/bash
DEV=/dev/sdi
MNT=/mnt/sdi
# Use smallest node size to make the test faster and require fewer file # names that result in hash collision. mkfs.btrfs -f --nodesize 4K $DEV mount $DEV $MNT
# List of names that result in the same crc32c hash for btrfs.
declare -a names=(
'foobar' '%a8tYkxfGMLWRGr55QSeQc4PBNH9PCLIvR6jZnkDtUUru1t@RouaUe_L:@xGkbO3nCwvLNYeK9vhE628gss:T$yZjZ5l-Nbd6CbC$M=hqE-ujhJICXyIxBvYrIU9-TDC' 'AQci3EUB%shMsg-N%frgU:02ByLs=IPJU0OpgiWit5nexSyxZDncY6WB:=zKZuk5Zy0DD$Ua78%MelgBuMqaHGyKsJUFf9s=UW80PcJmKctb46KveLSiUtNmqrMiL9-Y0I_l5Fnam04CGIg=8@U:Z' 'CvVqJpJzueKcuA$wqwePfyu7VxuWNN3ho$p0zi2H8QFYK$7YlEqOhhb%:hHgjhIjW5vnqWHKNP4' 'ET:vk@rFU4tsvMB0$C_p=xQHaYZjvoF%-BTc%wkFW8yaDAPcCYoR%x$FH5O:' 'HwTon%v7SGSP4FE08jBwwiu5aot2CFKXHTeEAa@38fUcNGOWvE@Mz6WBeDH_VooaZ6AgsXPkVGwy9l@@ZbNXabUU9csiWrrOp0MWUdfi$EZ3w9GkIqtz7I_eOsByOkBOO' 'Ij%2VlFGXSuPvxJGf5UWy6O@1svxGha%b@=%wjkq:CIgE6u7eJOjmQY5qTtxE2Rjbis9@us' 'KBkjG5%9R8K9sOG8UTnAYjxLNAvBmvV5vz3IiZaPmKuLYO03-6asI9lJ_j4@6Xo$KZicaLWJ3Pv8XEwVeUPMwbHYWwbx0pYvNlGMO9F:ZhHAwyctnGy%_eujl%WPd4U2BI7qooOSr85J-C2V$LfY' 'NcRfDfuUQ2=zP8K3CCF5dFcpfiOm6mwenShsAb_F%n6GAGC7fT2JFFn:c35X-3aYwoq7jNX5$ZJ6hI3wnZs$7KgGi7wjulffhHNUxAT0fRRLF39vJ@NvaEMxsMO' 'Oj42AQAEzRoTxa5OuSKIr=A_lwGMy132v4g3Pdq1GvUG9874YseIFQ6QU'
'Ono7avN5GjC:_6dBJ_'
'WHmN2gnmaN-9dVDy4aWo:yNGFzz8qsJyJhWEWcud7$QzN2D9R0efIWWEdu5kwWr73NZm4=@CoCDxrrZnRITr-kGtU_cfW2:%2_am' 'WiFnuTEhAG9FEC6zopQmj-A-$LDQ0T3WULz%ox3UZAPybSV6v1Z$b4L_XBi4M4BMBtJZpz93r9xafpB77r:lbwvitWRyo$odnAUYlYMmU4RvgnNd--e=I5hiEjGLETTtaScWlQp8mYsBovZwM2k' 'XKyH=OsOAF3p%uziGF_ZVr$ivrvhVgD@1u%5RtrV-gl_vqAwHkK@x7YwlxX3qT6WKKQ%PR56NrUBU2dOAOAdzr2=5nJuKPM-T-$ZpQfCL7phxQbUcb:BZOTPaFExc-qK-gDRCDW2' 'd3uUR6OFEwZr%ns1XH_@tbxA@cCPmbBRLdyh7p6V45H$P2$F%w0RqrD3M0g8aGvWpoTFMiBdOTJXjD:JF7=h9a_43xBywYAP%r$SPZi%zDg%ql-KvkdUCtF9OLaQlxmd' 'ePTpbnit%hyNm@WELlpKzNZYOzOTf8EQ$sEfkMy1VOfIUu3coyvIr13-Y7Sv5v-Ivax2Go_GQRFMU1b3362nktT9WOJf3SpT%z8sZmM3gvYQBDgmKI%%RM-G7hyrhgYflOw%z::ZRcv5O:lDCFm' 'evqk743Y@dvZAiG5J05L_ROFV@$2%rVWJ2%3nxV72-W7$e$-SK3tuSHA2mBt$qloC5jwNx33GmQUjD%akhBPu=VJ5g$xhlZiaFtTrjeeM5x7dt4cHpX0cZkmfImndYzGmvwQG:$euFYmXn$_2rA9mKZ' 'gkgUtnihWXsZQTEkrMAWIxir09k3t7jk_IK25t1:cy1XWN0GGqC%FrySdcmU7M8MuPO_ppkLw3=Dfr0UuBAL4%GFk2$Ma10V1jDRGJje%Xx9EV2ERaWKtjpwiZwh0gCSJsj5UL7CR8RtW5opCVFKGGy8Cky' 'hNgsG_8lNRik3PvphqPm0yEH3P%%fYG:kQLY=6O-61Wa6nrV_WVGR6TLB09vHOv%g4VQRP8Gzx7VXUY1qvZyS' 'isA7JVzN12xCxVPJZ_qoLm-pTBuhjjHMvV7o=F:EaClfYNyFGlsfw-Kf%uxdqW-kwk1sPl2vhbjyHU1A6$hz' 'kiJ_fgcdZFDiOptjgH5PN9-PSyLO4fbk_:u5_2tz35lV_iXiJ6cx7pwjTtKy-XGaQ5IefmpJ4N_ZqGsqCsKuqOOBgf9LkUdffHet@Wu' 'lvwtxyhE9:%Q3UxeHiViUyNzJsy:fm38pg_b6s25JvdhOAT=1s0$pG25x=LZ2rlHTszj=gN6M4zHZYr_qrB49i=pA--@WqWLIuX7o1S_SfS@2FSiUZN' 'rC24cw3UBDZ=5qJBUMs9e$=S4Y94ni%Z8639vnrGp=0Hv4z3dNFL0fBLmQ40=EYIY:Z=SLc@QLMSt2zsss2ZXrP7j4=' 'uwGl2s-fFrf@GqS=DQqq2I0LJSsOmM%xzTjS:lzXguE3wChdMoHYtLRKPvfaPOZF2fER@j53evbKa7R%A7r4%YEkD=kicJe@SFiGtXHbKe4gCgPAYbnVn' 'UG37U6KKua2bgc:IHzRs7BnB6FD:2Mt5Cc5NdlsW%$1tyvnfz7S27FvNkroXwAW:mBZLA1@qa9WnDbHCDmQmfPMC9z-Eq6QT0jhhPpqyymaD:R02ghwYo%yx7SAaaq-:x33LYpei$5g8DMl3C' 'y2vjek0FE1PDJC0qpfnN:x8k2wCFZ9xiUF2ege=JnP98R%wxjKkdfEiLWvQzmnW' '8-HCSgH5B%K7P8_jaVtQhBXpBk:pE-$P7ts58U0J@iR9YZntMPl7j$s62yAJO@_9eanFPS54b=UTw$94C-t=HLxT8n6o9P=QnIxq-f1=Ne2dvhe6WbjEQtc' 'YPPh:IFt2mtR6XWSmjHptXL_hbSYu8bMw-JP8@PNyaFkdNFsk$M=xfL6LDKCDM-mSyGA_2MBwZ8Dr4=R1D%7-mCaaKGxb990jzaagRktDTyp' '9hD2ApKa_t_7x-a@GCG28kY:7$M@5udI1myQ$x5udtggvagmCQcq9QXWRC5hoB0o-_zHQUqZI5rMcz_kbMgvN5jr63LeYA4Cj-c6F5Ugmx6DgVf@2Jqm%MafecpgooqreJ53P-QTS'
)
# Now create files with all those names in the same parent directory.
# It should not fail since a 4K leaf has enough space for them.
for name in "${names[@]}"; do
touch $MNT/$name
done# Now add one more file name that causes a crc32c hash collision. # This should fail, but it should not turn the filesystem into RO mode # (which could be exploited by malicious users) due to a transaction
# abort. touch $MNT/'W6tIm-VK2@BGC@IBfcgg6j_p:pxp_QUqtWpGD5Ok_GmijKOJJt'
# Check that we are able to create another file, with a name that does not cause
# a crc32c hash collision. echo -n "hello world" > $MNT/baz
# Unmount and mount again, verify file baz exists and with the right content. umount $MNT mount $DEV $MNT echo "File baz content: $(cat $MNT/baz)"
umount $MNT
When running the reproducer:
$ ./exploit-hash-collisions.sh (...) touch: cannot touch '/mnt/sdi/W6tIm-VK2@BGC@IBfcgg6j_p:pxp_QUqtWpGD5Ok_GmijKOJJt': Value too large for defined data type ./exploit-hash-collisions.sh: line 57: /mnt/sdi/baz: Read-only file system cat: /mnt/sdi/baz: No such file or directory File baz content:
And the transaction abort stack trace in dmesg/syslog:
$ dmesg (...) [758240.509761] ------------[ cut here ]------------ [758240.510668] BTRFS: Transaction aborted (error -75) [758240.511577] WARNING: fs/btrfs/inode.c:6854 at btrfs_create_new_inode+0x805/0xb50 [btrfs], CPU#6: touch/888644 [758240.513513] Modules linked in: btrfs dm_zero (...) [758240.523221] CPU: 6 UID: 0 PID: 888644 Comm: touch Tainted: G W 6.19.0-rc8-btrfs-next-225+ #1 PREEMPT(full) [758240.524621] Tainted: [W]=WARN [758240.525037] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org 04/01/2014 [758240.526331] RIP: 0010:btrfs_create_new_inode+0x80b/0xb50 [btrfs] [758240.527093] Code: 0f 82 cf (...) [758240.529211] RSP: 0018:ffffce64418fbb48 EFLAGS: 00010292 [758240.529935] RAX: 00000000ffffffd3 RBX: 0000000000000000 RCX: 00000000ffffffb5 [758240.531040] RDX: 0000000d04f33e06 RSI: 00000000ffffffb5 RDI: ffffffffc0919dd0 [758240.531920] RBP: ffffce64418fbc10 R08: 0000000000000000 R09: 00000000ffffffb5 [758240.532928] R10: 0000000000000000 R11: ffff8e52c0000000 R12: ffff8e53eee7d0f0 [758240.533818] R13: ffff8e57f70932a0 R14: ffff8e5417629568 R15: 0000000000000000 [758240.534664] FS: 00007f1959a2a740(0000) GS:ffff8e5b27cae000(0000) knlGS:0000000000000000 [758240.535821] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [758240.536644] CR2: 00007f1959b10ce0 CR3: 000000012a2cc005 CR4: 0000000000370ef0 [758240.537517] Call Trace: [758240.537828] <TASK> [758240.538099] btrfs_create_common+0xbf/0x140 [btrfs] [758240.538760] path_openat+0x111a/0x15b0 [758240.539252] do_filp_open+0xc2/0x170 [758240.539699] ? preempt_count_add+0x47/0xa0 [758240.540200] ? __virt_addr_valid+0xe4/0x1a0 [758240.540800] ? __check_object_size+0x1b3/0x230 [758240.541661] ? alloc_fd+0x118/0x180 [758240.542315] do_sys_openat2+0x70/0xd0 [758240.543012] __x64_sys_openat+0x50/0xa0 [758240.543723] do_syscall_64+0x50/0xf20 [758240.544462] entry_SYSCALL_64_after_hwframe+0x76/0x7e [758240.545397] RIP: 0033:0x7f1959abc687 [758240.546019] Code: 48 89 fa (...) [758240.548522] RSP: 002b:00007ffe16ff8690 EFLAGS: 00000202 ORIG_RAX: 0000000000000101 [758240.566278] RAX: ffffffffffffffda RBX: 00007f1959a2a740 RCX: 00007f1959abc687 [758240.567068] RDX: 0000000000000941 RSI: 00007ffe16ffa333 RDI: ffffffffffffff9c [758240.567860] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 [758240.568707] R10: 00000000000001b6 R11: 0000000000000202 R12: 0000561eec7c4b90 [758240.569712] R13: 0000561eec7c311f R14: 00007ffe16ffa333 R15: 0000000000000000 [758240.570758] </TASK> [758240.571040] ---[ end trace 0000000000000000 ]--- [758240.571681] BTRFS: error (device sdi state A) in btrfs_create_new_inode:6854: errno=-75 unknown [758240.572899] BTRFS info (device sdi state EA): forced readonly
Fix this by checking for hash collision, and if the adding a new name is possible, early in btrfs_create_new_inode() before we do any tree updates, so that we don't need to abort the transaction if we cannot add the new name due to the leaf size limit.
A test case for fstests will be sent soon.
--- fs/btrfs/inode.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
fs/btrfs/inode.c +19 -0
@@ -6542,6 +6542,25 @@ int btrfs_create_new_inode(struct btrfs_int ret;bool xa_reserved = false; +if (!args->orphan && !args->subvol) { +/* +* Before anything else, check if we can add the name to the +* parent directory. We want to avoid a dir item overflow in +* case we have an existing dir item due to existing name +* hash collisions. We do this check here before we call +* btrfs_add_link() down below so that we can avoid a +* transaction abort (which could be exploited by malicious +* users). +* +* For subvolumes we already do this in btrfs_mksubvol(). +*/ + ret =btrfs_check_dir_item_collision (BTRFS_I (dir)->root, +btrfs_ino (BTRFS_I (dir)), + name); +if (ret <0 ) +return ret; + } + path =btrfs_alloc_path ();if (!path)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 343/378 btrfs: fix transaction abort on set received ioctl due to item overflow
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 87f2c46003fce4d739138aab4af1942b1afdadac upstream.
If the set received ioctl fails due to an item overflow when attempting to add the BTRFS_UUID_KEY_RECEIVED_SUBVOL we have to abort the transaction since we did some metadata updates before.
This means that if a user calls this ioctl with the same received UUID field for a lot of subvolumes, we will hit the overflow, trigger the transaction abort and turn the filesystem into RO mode. A malicious user could exploit this, and this ioctl does not even requires that a user has admin privileges (CAP_SYS_ADMIN), only that he/she owns the subvolume.
Fix this by doing an early check for item overflow before starting a transaction. This is also race safe because we are holding the subvol_sem semaphore in exclusive (write) mode.
A test case for fstests will follow soon.
--- fs/btrfs/ioctl.c | 21 +++++++++++++++++++-- fs/btrfs/uuid-tree.c | 38 ++++++++++++++++++++++++++++++++++++++ fs/btrfs/uuid-tree.h | 2 ++ 3 files changed, 59 insertions(+), 2 deletions(-)
fs/btrfs/ioctl.c +19 -2
@@ -3932,6 +3932,25 @@ static long _btrfs_ioctl_set_received_su goto out; } + received_uuid_changed =memcmp (root_item->received_uuid, sa->uuid, +BTRFS_UUID_SIZE ); + +/* +* Before we attempt to add the new received uuid, check if we have room +* for it in case there's already an item. If the size of the existing +* item plus this root's ID (u64) exceeds the maximum item size, we can +* return here without the need to abort a transaction. If we don't do +* this check, the btrfs_uuid_tree_add() call below would fail with +* -EOVERFLOW and result in a transaction abort. Malicious users could +* exploit this to turn the fs into RO mode. +*/ +if (received_uuid_changed && !btrfs_is_empty_uuid (sa->uuid)) { + ret =btrfs_uuid_tree_check_overflow (fs_info, sa->uuid, +BTRFS_UUID_KEY_RECEIVED_SUBVOL ); +if (ret <0 ) + goto out; + } +/* * 1 - root item * 2 - uuid items (received uuid + subvol uuid)
@@ -3947,8 +3966,6 @@ static long _btrfs_ioctl_set_received_su sa->rtime.sec = ct.tv_sec; sa->rtime.nsec = ct.tv_nsec; - received_uuid_changed =memcmp (root_item->received_uuid, sa->uuid, -BTRFS_UUID_SIZE );if (received_uuid_changed && !btrfs_is_empty_uuid (root_item->received_uuid)) { ret = btrfs_uuid_tree_remove(trans, root_item->received_uuid,
fs/btrfs/uuid-tree.c +38 -0
@@ -199,6 +199,44 @@ int btrfs_uuid_tree_remove(struct btrfs_return 0 ; } +/* +* Check if we can add one root ID to a UUID key. +* If the key does not yet exists, we can, otherwise only if extended item does +* not exceeds the maximum item size permitted by the leaf size. +* +* Returns 0 on success, negative value on error. +*/ +int btrfs_uuid_tree_check_overflow (struct btrfs_fs_info *fs_info, +const u8 *uuid,u8 type) +{ +BTRFS_PATH_AUTO_FREE (path); +int ret; +u32 item_size; +struct btrfs_key key; + +if (WARN_ON_ONCE (!fs_info->uuid_root)) +return -EINVAL ; + + path =btrfs_alloc_path (); +if (!path) +return -ENOMEM ; + +btrfs_uuid_to_key (uuid, type, &key); + ret =btrfs_search_slot (NULL , fs_info->uuid_root, &key, path,0 ,0 ); +if (ret <0 ) +return ret; +if (ret >0 ) +return 0 ; + + item_size =btrfs_item_size (path->nodes[0 ], path->slots[0 ]); + +if (sizeof (struct btrfs_item ) + item_size +sizeof (u64) > +BTRFS_LEAF_DATA_SIZE (fs_info)) +return -EOVERFLOW ; + +return 0 ; +} +static int btrfs_uuid_iter_rem (struct btrfs_root *uuid_root,u8 *uuid,u8 type,u64 subid) {
fs/btrfs/uuid-tree.h +2 -0
@@ -12,6 +12,8 @@ int btrfs_uuid_tree_add(struct btrfs_tra u64 subid);int btrfs_uuid_tree_remove (struct btrfs_trans_handle *trans,const u8 *uuid,u8 type,u64 subid); +int btrfs_uuid_tree_check_overflow (struct btrfs_fs_info *fs_info, +const u8 *uuid,u8 type);int btrfs_uuid_tree_iterate (struct btrfs_fs_info *fs_info);int btrfs_create_uuid_tree (struct btrfs_fs_info *fs_info);int btrfs_uuid_scan_kthread (void *data);
Greg Kroah-Hartman
maintainerPATCH 344/378 btrfs: add missing RCU unlock in error path in try_release_subpage_extent_buffer()
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
commit b2840e33127ce0eea880504b7f133e780f567a9b upstream.
Call rcu_read_lock() before exiting the loop in try_release_subpage_extent_buffer() because there is a rcu_read_unlock() call past the loop.
This has been detected by the Clang thread-safety analyzer.
--- fs/btrfs/extent_io.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/extent_io.c +1 -0
@@ -4475,6 +4475,7 @@ static int try_release_subpage_extent_bu*/ if (!test_and_clear_bit (EXTENT_BUFFER_TREE_REF , &eb->bflags)) {spin_unlock (&eb->refs_lock); +rcu_read_lock ();break ; }
Greg Kroah-Hartman
maintainerPATCH 345/378 btrfs: abort transaction on failure to update root in the received subvol ioctl
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 0f475ee0ebce5c9492b260027cd95270191675fa upstream.
If we failed to update the root we don't abort the transaction, which is wrong since we already used the transaction to remove an item from the uuid tree.
--- fs/btrfs/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/ioctl.c +2 -1
@@ -3987,7 +3987,8 @@ static long _btrfs_ioctl_set_received_su ret =btrfs_update_root (trans, fs_info->tree_root, &root->root_key, &root->root_item); -if (ret <0 ) { +if (unlikely (ret <0 )) { +btrfs_abort_transaction (trans, ret);btrfs_end_transaction (trans); goto out; }
Greg Kroah-Hartman
maintainerPATCH 346/378 iio: dac: ds4424: reject -128 RAW value
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
commit 5187e03b817c26c1c3bcb2645a612ea935c4be89 upstream.
The DS442x DAC uses sign-magnitude encoding, so -128 cannot be represented in hardware (7-bit magnitude).
Previously, passing -128 resulted in a truncated value that programmed 0mA (magnitude 0) instead of the expected maximum negative current, effectively failing silently.
Reject -128 to avoid producing the wrong current.
--- drivers/iio/dac/ds4424.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ds4424.c +1 -1
@@ -141,7 +141,7 @@ static int ds4424_write_raw(struct iio_dswitch (mask) {case IIO_CHAN_INFO_RAW : -if (val <S8_MIN || val >S8_MAX ) +if (val <=S8_MIN || val >S8_MAX )return -EINVAL ;if (val >0 ) {
Greg Kroah-Hartman
maintainerPATCH 347/378 iio: frequency: adf4377: Fix duplicated soft reset mask
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeungJu Cheon <[email protected]>
commit 6c8bf4b604a8a6346ca71f1c027fa01c2c2e04cb upstream.
The regmap_read_poll_timeout() uses ADF4377_0000_SOFT_RESET_R_MSK twice instead of checking both SOFT_RESET_MSK (bit 0) and SOFT_RESET_R_MSK (bit 7). This causes an incomplete reset status check.
The code first sets both SOFT_RESET and SOFT_RESET_R bits to 1 via regmap_update_bits(), then polls for them to be cleared. Since we set both bits before polling, we should be waiting for both to clear.
Fix by using both masks as done in regmap_update_bits() above.
--- drivers/iio/frequency/adf4377.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/frequency/adf4377.c +1 -1
@@ -501,7 +501,7 @@ static int adf4377_soft_reset(struct adfreturn ret;return regmap_read_poll_timeout (st->regmap,0x0 , read_val, - !(read_val & (ADF4377_0000_SOFT_RESET_R_MSK | + !(read_val & (ADF4377_0000_SOFT_RESET_MSK |ADF4377_0000_SOFT_RESET_R_MSK )),200 ,200 *100 ); }
Greg Kroah-Hartman
maintainerPATCH 348/378 iio: chemical: sps30_serial: fix buffer size in sps30_serial_read_meas()
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
commit c3914ce1963c4db25e186112c90fa5d2361e9e0a upstream.
sizeof(num) evaluates to sizeof(size_t) which is 8 bytes on 64-bit, but the buffer elements are only 4 bytes. The same function already uses sizeof(*meas) on line 312, making the mismatch evident. Use sizeof(*meas) consistently.
--- drivers/iio/chemical/sps30_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/chemical/sps30_serial.c +1 -1
@@ -303,7 +303,7 @@ static int sps30_serial_read_meas(structif (msleep_interruptible (1000 ))return -EINTR ; - ret =sps30_serial_command (state,SPS30_SERIAL_READ_MEAS ,NULL ,0 , meas, num *sizeof (num)); + ret =sps30_serial_command (state,SPS30_SERIAL_READ_MEAS ,NULL ,0 , meas, num *sizeof (*meas));if (ret <0 )return ret;/* if measurements aren't ready sensor returns empty frame */
Greg Kroah-Hartman
maintainerPATCH 349/378 iio: chemical: sps30_i2c: fix buffer size in sps30_i2c_read_meas()
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
commit 216345f98cae7fcc84f49728c67478ac00321c87 upstream.
sizeof(num) evaluates to sizeof(size_t) (8 bytes on 64-bit) instead of the intended __be32 element size (4 bytes). Use sizeof(*meas) to correctly match the buffer element type.
--- drivers/iio/chemical/sps30_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/chemical/sps30_i2c.c +1 -1
@@ -171,7 +171,7 @@ static int sps30_i2c_read_meas(struct spif (!sps30_i2c_meas_ready (state))return -ETIMEDOUT ; -return sps30_i2c_command (state,SPS30_I2C_READ_MEAS ,NULL ,0 , meas,sizeof (num) * num); +return sps30_i2c_command (state,SPS30_I2C_READ_MEAS ,NULL ,0 , meas,sizeof (*meas) * num); }static int sps30_i2c_clean_fan (struct sps30_state *state)
Greg Kroah-Hartman
maintainerPATCH 350/378 iio: magnetometer: tlv493d: remove erroneous shift in X-axis data
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
commit 82ee91d6b15f06b6094eea2c26afe0032fe8e177 upstream.
TLV493D_BX2_MAG_X_AXIS_LSB is defined as GENMASK(7, 4). FIELD_GET() already right-shifts bits [7:4] to [3:0], so the additional >> 4 discards most of the X-axis low nibble. The Y and Z axes correctly omit this extra shift. Remove it.
--- drivers/iio/magnetometer/tlv493d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/magnetometer/tlv493d.c +1 -1
@@ -171,7 +171,7 @@ static s16 tlv493d_get_channel_data(u8 *switch (ch) {case TLV493D_AXIS_X : val =FIELD_GET (TLV493D_BX_MAG_X_AXIS_MSB , b[TLV493D_RD_REG_BX ]) <<4 | -FIELD_GET (TLV493D_BX2_MAG_X_AXIS_LSB , b[TLV493D_RD_REG_BX2 ]) >>4 ; +FIELD_GET (TLV493D_BX2_MAG_X_AXIS_LSB , b[TLV493D_RD_REG_BX2 ]);break ;case TLV493D_AXIS_Y : val = FIELD_GET(TLV493D_BY_MAG_Y_AXIS_MSB, b[TLV493D_RD_REG_BY]) << 4 |
Greg Kroah-Hartman
maintainerPATCH 351/378 iio: potentiometer: mcp4131: fix double application of wiper shift
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Schmid <[email protected]>
commit 85e4614524dca6c0a43874f475a17de2b9725648 upstream.
The MCP4131 wiper address is shifted twice when preparing the SPI command in mcp4131_write_raw().
The address is already shifted when assigned to the local variable "address", but is then shifted again when written to data->buf[0]. This results in an incorrect command being sent to the device and breaks wiper writes to the second channel.
Remove the second shift and use the pre-shifted address directly when composing the SPI transfer.
--- drivers/iio/potentiometer/mcp4131.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/potentiometer/mcp4131.c +1 -1
@@ -221,7 +221,7 @@ static int mcp4131_write_raw(struct iio_mutex_lock (&data->lock); - data->buf[0 ] = address <<MCP4131_WIPER_SHIFT ; + data->buf[0 ] = address; data->buf[0 ] |=MCP4131_WRITE | (val >>8 ); data->buf[1 ] = val &0xFF ;/* 8 bits here */
Greg Kroah-Hartman
maintainerPATCH 352/378 iio: chemical: bme680: Fix measurement wait duration calculation
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Spencer <[email protected]>
commit f55b9510cd9437da3a0efa08b089caeb47595ff1 upstream.
This function refers to the Bosch BME680 API as the source of the calculation, but one of the constants does not match the Bosch implementation. This appears to be a simple transposition of two digits, resulting in a wait time that is too short. This can cause the following 'device measurement cycle incomplete' check to occasionally fail, returning EBUSY to user space.
Adjust the constant to match the Bosch implementation and resolve the EBUSY errors.
--- drivers/iio/chemical/bme680_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/chemical/bme680_core.c +1 -1
@@ -613,7 +613,7 @@ static int bme680_wait_for_eoc(struct bm* + heater duration */ int wait_eoc_us = ((data->oversampling_temp + data->oversampling_press + - data->oversampling_humid) *1936 ) + (477 *4 ) + + data->oversampling_humid) *1963 ) + (477 *4 ) + (477 *5 ) +1000 + (data->heater_dur *1000 );fsleep (wait_eoc_us);
Greg Kroah-Hartman
maintainerPATCH 353/378 iio: buffer: Fix wait_queue not being removed
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuno Sá <[email protected]>
commit 064234044056c93a3719d6893e6e5a26a94a61b6 upstream.
In the edge case where the IIO device is unregistered while we're buffering, we were directly returning an error without removing the wait queue. Instead, set 'ret' and break out of the loop.
--- drivers/iio/industrialio-buffer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iio/industrialio-buffer.c +4 -2
@@ -228,8 +228,10 @@ static ssize_t iio_buffer_write(struct f written =0 ;add_wait_queue (&rb->pollq, &wait); do { - if (!indio_dev->info) - return -ENODEV; + if (!indio_dev->info) { + ret = -ENODEV; + break; + } if (!iio_buffer_space_available(rb)) { if (signal_pending(current)) {
Greg Kroah-Hartman
maintainerPATCH 354/378 iio: gyro: mpu3050-core: fix pm_runtime error handling
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
commit acc3949aab3e8094641a9c7c2768de1958c88378 upstream.
The return value of pm_runtime_get_sync() is not checked, allowing the driver to access hardware that may fail to resume. The device usage count is also unconditionally incremented. Use pm_runtime_resume_and_get() which propagates errors and avoids incrementing the usage count on failure.
In preenable, add pm_runtime_put_autosuspend() on set_8khz_samplerate() failure since postdisable does not run when preenable fails.
--- drivers/iio/gyro/mpu3050-core.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/iio/gyro/mpu3050-core.c +13 -5
@@ -322,7 +322,9 @@ static int mpu3050_read_raw(struct iio_d }case IIO_CHAN_INFO_RAW :/* Resume device */ -pm_runtime_get_sync (mpu3050->dev); + ret =pm_runtime_resume_and_get (mpu3050->dev); +if (ret) +return ret;mutex_lock (&mpu3050->lock); ret =mpu3050_set_8khz_samplerate (mpu3050);
@@ -647,14 +649,20 @@ out_trigger_unlock:static int mpu3050_buffer_preenable (struct iio_dev *indio_dev) {struct mpu3050 *mpu3050 =iio_priv (indio_dev); +int ret; -pm_runtime_get_sync (mpu3050->dev); + ret =pm_runtime_resume_and_get (mpu3050->dev); +if (ret) +return ret;/* Unless we have OUR trigger active, run at full speed */ -if (!mpu3050->hw_irq_trigger) -return mpu3050_set_8khz_samplerate (mpu3050); +if (!mpu3050->hw_irq_trigger) { + ret =mpu3050_set_8khz_samplerate (mpu3050); +if (ret) +pm_runtime_put_autosuspend (mpu3050->dev); + } -return 0 ; +return ret; }static int mpu3050_buffer_postdisable (struct iio_dev *indio_dev)
Greg Kroah-Hartman
maintainerPATCH 355/378 iio: imu: adis: Fix NULL pointer dereference in adis_init
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Radu Sabau <[email protected]>
commit 9990cd4f8827bd1ae3fb6eb7407630d8d463c430 upstream.
The adis_init() function dereferences adis->ops to check if the individual function pointers (write, read, reset) are NULL, but does not first check if adis->ops itself is NULL.
Drivers like adis16480, adis16490, adis16545 and others do not set custom ops and rely on adis_init() assigning the defaults. Since struct adis is zero-initialized by devm_iio_device_alloc(), adis->ops is NULL when adis_init() is called, causing a NULL pointer dereference:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
pc : adis_init+0xc0/0x118
Call trace:
adis_init+0xc0/0x118
adis16480_probe+0xe0/0x670Fix this by checking if adis->ops is NULL before dereferencing it, falling through to assign the default ops in that case.
--- drivers/iio/imu/adis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/adis.c +1 -1
@@ -526,7 +526,7 @@ int adis_init(struct adis *adis, struct adis->spi = spi; adis->data = data; -if (!adis->ops->write && !adis->ops->read && !adis->ops->reset) +if (!adis->ops) adis->ops = &adis_default_ops;else if (!adis->ops->write || !adis->ops->read || !adis->ops->reset)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 356/378 iio: gyro: mpu3050-i2c: fix pm_runtime error handling
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
commit 91f950b4cbb1aa9ea4eb3999f1463e8044b717fb upstream.
The return value of pm_runtime_get_sync() is not checked, and the function always returns success. This allows I2C mux operations to proceed even when the device fails to resume.
Use pm_runtime_resume_and_get() and propagate its return value to properly handle resume failures.
--- drivers/iio/gyro/mpu3050-i2c.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/gyro/mpu3050-i2c.c +1 -2
@@ -19,8 +19,7 @@ static int mpu3050_i2c_bypass_select(strstruct mpu3050 *mpu3050 =i2c_mux_priv (mux);/* Just power up the device, that is all that is needed */ -pm_runtime_get_sync (mpu3050->dev); -return 0 ; +return pm_runtime_resume_and_get (mpu3050->dev); }static int mpu3050_i2c_bypass_deselect (struct i2c_mux_core *mux,u32 chan_id)
Greg Kroah-Hartman
maintainerPATCH 357/378 iio: imu: inv_icm45600: fix regulator put warning when probe fails
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit 2617595538be8a2f270ad13fccb9f56007b292d7 upstream.
When the driver probe fails we encounter a regulator put warning because vddio regulator is not stopped before release. The issue comes from pm_runtime not already setup when core probe fails and the vddio regulator disable callback is called.
Fix the issue by setting pm_runtime active early before vddio regulator resource cleanup. This requires to cut pm_runtime set_active and enable in 2 function calls.
--- drivers/iio/imu/inv_icm45600/inv_icm45600_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/iio/imu/inv_icm45600/inv_icm45600_core.c +6 -1
@@ -744,6 +744,11 @@ int inv_icm45600_core_probe(struct regmap *regmap, const struct inv_icm45600_chi*/ fsleep (5 *USEC_PER_MSEC ); +/* set pm_runtime active early for disable vddio resource cleanup */ + ret =pm_runtime_set_active (dev); +if (ret) +return ret; + ret =inv_icm45600_enable_regulator_vddio (st);if (ret)return ret;
@@ -776,7 +781,7 @@ int inv_icm45600_core_probe(struct regmap *regmap, const struct inv_icm45600_chiif (ret)return ret; - ret =devm_pm_runtime_set_active_enabled (dev); + ret =devm_pm_runtime_enable (dev);if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 358/378 iio: light: bh1780: fix PM runtime leak on error path
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
commit dd72e6c3cdea05cad24e99710939086f7a113fb5 upstream.
Move pm_runtime_put_autosuspend() before the error check to ensure the PM runtime reference count is always decremented after pm_runtime_get_sync(), regardless of whether the read operation succeeds or fails.
--- drivers/iio/light/bh1780.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/bh1780.c +1 -1
@@ -109,9 +109,9 @@ static int bh1780_read_raw(struct iio_decase IIO_LIGHT :pm_runtime_get_sync (&bh1780->client->dev); value =bh1780_read_word (bh1780,BH1780_REG_DLOW ); +pm_runtime_put_autosuspend (&bh1780->client->dev);if (value <0 )return value; -pm_runtime_put_autosuspend (&bh1780->client->dev); *val = value;return IIO_VAL_INT ;
Greg Kroah-Hartman
maintainerPATCH 359/378 iio: imu: inv_icm45600: fix INT1 drive bit inverted
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit 7ef74d961d1ad6ec72b50887ca119d7f98f07717 upstream.
Drive bit must be set for open-drain mode and be cleared for push-pull mode.
Referring to datasheet DS-000576_ICM-45605.pdf section 17.23 INT1_CONFIG2.
--- drivers/iio/imu/inv_icm45600/inv_icm45600.h | 2 +- drivers/iio/imu/inv_icm45600/inv_icm45600_core.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/iio/imu/inv_icm45600/inv_icm45600.h +1 -1
@@ -205,7 +205,7 @@ struct inv_icm45600_sensor_state {#define INV_ICM45600_SPI_SLEW_RATE_38NS 0#define INV_ICM45600_REG_INT1_CONFIG2 0x0018 -#define INV_ICM45600_INT1_CONFIG2_PUSH_PULL BIT(2) +#define INV_ICM45600_INT1_CONFIG2_OPEN_DRAIN BIT(2)#define INV_ICM45600_INT1_CONFIG2_LATCHED BIT(1)#define INV_ICM45600_INT1_CONFIG2_ACTIVE_HIGH BIT(0)#define INV_ICM45600_INT1_CONFIG2_ACTIVE_LOW 0x00
drivers/iio/imu/inv_icm45600/inv_icm45600_core.c +2 -2
@@ -637,8 +637,8 @@ static int inv_icm45600_irq_init(structbreak ; } -if (!open_drain) - val |=INV_ICM45600_INT1_CONFIG2_PUSH_PULL ; +if (open_drain) + val |=INV_ICM45600_INT1_CONFIG2_OPEN_DRAIN ; ret =regmap_write (st->map,INV_ICM45600_REG_INT1_CONFIG2 , val);if (ret)
Greg Kroah-Hartman
maintainerPATCH 360/378 iio: imu: inv_icm42600: fix odr switch to the same value
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit c9f3a593137d862d424130343e77d4b5260a4f5a upstream.
ODR switch is done in 2 steps when FIFO is on : change the ODR register value and acknowledge change when reading the FIFO ODR change flag. When we are switching to the same odr value, we end up waiting for a FIFO ODR flag that is never happening.
Fix the issue by doing nothing and exiting properly when we are switching to the same ODR value.
--- drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 2 ++ drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +2 -0
@@ -651,6 +651,8 @@ static int inv_icm42600_accel_write_odr(return -EINVAL ; conf.odr = inv_icm42600_accel_odr_conv[idx /2 ]; +if (conf.odr == st->conf.accel.odr) +return 0 ;pm_runtime_get_sync (dev);mutex_lock (&st->lock);
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +2 -0
@@ -358,6 +358,8 @@ static int inv_icm42600_gyro_write_odr(sreturn -EINVAL ; conf.odr = inv_icm42600_gyro_odr_conv[idx /2 ]; +if (conf.odr == st->conf.gyro.odr) +return 0 ;pm_runtime_get_sync (dev);mutex_lock (&st->lock);
Greg Kroah-Hartman
maintainerPATCH 361/378 iio: imu: inv_icm42600: fix odr switch when turning buffer off
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit ffd32db8263d2d785a2c419486a450dc80693235 upstream.
ODR switch is done in 2 steps when FIFO is on : change the ODR register value and acknowledge change when reading the FIFO ODR change flag. When we are switching odr and turning buffer off just afterward, we are losing the FIFO ODR change flag and ODR switch is blocked.
Fix the issue by force applying any waiting ODR change when turning buffer off.
--- drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c +4 -0
@@ -371,6 +371,8 @@ static int inv_icm42600_buffer_predisablstatic int inv_icm42600_buffer_postdisable (struct iio_dev *indio_dev) {struct inv_icm42600_state *st =iio_device_get_drvdata (indio_dev); +struct inv_icm42600_sensor_state *sensor_st =iio_priv (indio_dev); +struct inv_sensors_timestamp *ts = &sensor_st->ts;struct device *dev =regmap_get_device (st->map);unsigned int sensor;unsigned int *watermark;
@@ -392,6 +394,8 @@ static int inv_icm42600_buffer_postdisabmutex_lock (&st->lock); +inv_sensors_timestamp_apply_odr (ts,0 ,0 ,0 ); + ret =inv_icm42600_buffer_set_fifo_en (st, st->fifo.en & ~sensor);if (ret) goto out_unlock;
Greg Kroah-Hartman
maintainerPATCH 362/378 iio: proximity: hx9023s: fix assignment order for __counted_by
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yasin Lee <[email protected]>
commit 585b90c0161ab77416fe3acdbdc55b978e33e16c upstream.
Initialize fw_size before copying firmware data into the flexible array member to match the __counted_by() annotation. This fixes the incorrect assignment order that triggers runtime safety checks.
--- drivers/iio/proximity/hx9023s.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/proximity/hx9023s.c +1 -2
@@ -1034,9 +1034,8 @@ static int hx9023s_send_cfg(const structif (!bin)return -ENOMEM ; -memcpy (bin->data, fw->data, fw->size); - bin->fw_size = fw->size; +memcpy (bin->data, fw->data, bin->fw_size); bin->fw_ver = bin->data[FW_VER_OFFSET ]; bin->reg_count =get_unaligned_le16 (bin->data +FW_REG_CNT_OFFSET );
Greg Kroah-Hartman
maintainerPATCH 363/378 iio: proximity: hx9023s: Protect against division by zero in set_samp_freq
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yasin Lee <[email protected]>
commit a318cfc0853706f1d6ce682dba660bc455d674ef upstream.
Avoid division by zero when sampling frequency is unspecified.
--- drivers/iio/proximity/hx9023s.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/proximity/hx9023s.c +3 -0
@@ -719,6 +719,9 @@ static int hx9023s_set_samp_freq(structstruct device *dev =regmap_get_device (data->regmap);unsigned int i, period_ms; +if (!val && !val2) +return -EINVAL ; + period_ms =div_u64 (NANO , (val *MEGA + val2));for (i =0 ; i <ARRAY_SIZE (hx9023s_samp_freq_table); i++) {
Greg Kroah-Hartman
maintainerPATCH 364/378 i3c: mipi-i3c-hci: Use ETIMEDOUT instead of ETIME for timeout errors
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit 4167b8914463132654e01e16259847d097f8a7f7 upstream.
The MIPI I3C HCI driver currently returns -ETIME for various timeout conditions, while other I3C master drivers consistently use -ETIMEDOUT for the same class of errors. Align the HCI driver with the rest of the subsystem by replacing all uses of -ETIME with -ETIMEDOUT.
--- drivers/i3c/master/mipi-i3c-hci/cmd_v1.c | 2 +- drivers/i3c/master/mipi-i3c-hci/cmd_v2.c | 2 +- drivers/i3c/master/mipi-i3c-hci/core.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/i3c/master/mipi-i3c-hci/cmd_v1.c +1 -1
@@ -336,7 +336,7 @@ static int hci_cmd_v1_daa(struct i3c_hci hci->io->queue_xfer (hci, xfer,1 );if (!wait_for_completion_timeout (&done,HZ ) && hci->io->dequeue_xfer (hci, xfer,1 )) { - ret = -ETIME ; + ret = -ETIMEDOUT ;break ; } if ((RESP_STATUS(xfer->response) == RESP_ERR_ADDR_HEADER ||
drivers/i3c/master/mipi-i3c-hci/cmd_v2.c +1 -1
@@ -277,7 +277,7 @@ static int hci_cmd_v2_daa(struct i3c_hci hci->io->queue_xfer (hci, xfer,2 );if (!wait_for_completion_timeout (&done,HZ ) && hci->io->dequeue_xfer (hci, xfer,2 )) { - ret = -ETIME ; + ret = -ETIMEDOUT ;break ; }if (RESP_STATUS (xfer[0 ].response) !=RESP_SUCCESS ) {
drivers/i3c/master/mipi-i3c-hci/core.c +3 -3
@@ -230,7 +230,7 @@ static int i3c_hci_send_ccc_cmd(struct i goto out;if (!wait_for_completion_timeout (&done,HZ ) && hci->io->dequeue_xfer (hci, xfer, nxfers)) { - ret = -ETIME ; + ret = -ETIMEDOUT ; goto out; }for (i = prefixed; i < nxfers; i++) {
@@ -309,7 +309,7 @@ static int i3c_hci_i3c_xfers(struct i3c_ goto out;if (!wait_for_completion_timeout (&done,HZ ) && hci->io->dequeue_xfer (hci, xfer, nxfers)) { - ret = -ETIME ; + ret = -ETIMEDOUT ; goto out; }for (i =0 ; i < nxfers; i++) {
@@ -357,7 +357,7 @@ static int i3c_hci_i2c_xfers(struct i2c_ goto out;if (!wait_for_completion_timeout (&done, m->i2c.timeout) && hci->io->dequeue_xfer (hci, xfer, nxfers)) { - ret = -ETIME ; + ret = -ETIMEDOUT ; goto out; }for (i =0 ; i < nxfers; i++) {
Greg Kroah-Hartman
maintainerPATCH 365/378 i3c: mipi-i3c-hci: Factor out DMA mapping from queuing path
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit f3bcbfe1b8b0b836b772927f75f8cb6e759eb00a upstream.
Prepare for fixing a race in the DMA ring enqueue path when handling parallel transfers. Move all DMA mapping out of hci_dma_queue_xfer() and into a new helper that performs the mapping up front.
This refactoring allows the upcoming fix to extend the spinlock coverage around the enqueue operation without performing DMA mapping under the spinlock.
No functional change is intended in this patch.
--- drivers/i3c/master/mipi-i3c-hci/dma.c | 49 ++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 16 deletions(-)
drivers/i3c/master/mipi-i3c-hci/dma.c +33 -16
@@ -375,6 +375,33 @@ static void hci_dma_unmap_xfer(struct i3 } } +static struct i3c_dma *hci_dma_map_xfer (struct device *dev,struct hci_xfer *xfer) +{ +enum dma_data_direction dir = xfer->rnw ?DMA_FROM_DEVICE :DMA_TO_DEVICE ; +bool need_bounce =device_iommu_mapped (dev) && xfer->rnw && (xfer->data_len &3 ); + +return i3c_master_dma_map_single (dev, xfer->data, xfer->data_len, need_bounce, dir); +} + +static int hci_dma_map_xfer_list (struct i3c_hci *hci,struct device *dev, +struct hci_xfer *xfer_list,int n) +{ +for (int i =0 ; i < n; i++) { +struct hci_xfer *xfer = xfer_list + i; + +if (!xfer->data) +continue ; + + xfer->dma =hci_dma_map_xfer (dev, xfer); +if (!xfer->dma) { +hci_dma_unmap_xfer (hci, xfer_list, i); +return -ENOMEM ; + } + } + +return 0 ; +} +static int hci_dma_queue_xfer (struct i3c_hci *hci,struct hci_xfer *xfer_list,int n) {
@@ -382,6 +409,11 @@ static int hci_dma_queue_xfer(struct i3cstruct hci_rh_data *rh;unsigned int i, ring, enqueue_ptr;u32 op1_val, op2_val; +int ret; + + ret =hci_dma_map_xfer_list (hci, rings->sysdev, xfer_list, n); +if (ret) +return ret;/* For now we only use ring 0 */ ring =0 ;
@@ -392,9 +424,6 @@ static int hci_dma_queue_xfer(struct i3cfor (i =0 ; i < n; i++) {struct hci_xfer *xfer = xfer_list + i;u32 *ring_data = rh->xfer + rh->xfer_struct_sz * enqueue_ptr; -enum dma_data_direction dir = xfer->rnw ?DMA_FROM_DEVICE : -DMA_TO_DEVICE ; -bool need_bounce;/* store cmd descriptor */ *ring_data++ = xfer->cmd_desc[0 ];
@@ -413,18 +442,6 @@ static int hci_dma_queue_xfer(struct i3c/* 2nd and 3rd words of Data Buffer Descriptor Structure */ if (xfer->data) { - need_bounce =device_iommu_mapped (rings->sysdev) && - xfer->rnw && - xfer->data_len !=ALIGN (xfer->data_len,4 ); - xfer->dma =i3c_master_dma_map_single (rings->sysdev, - xfer->data, - xfer->data_len, - need_bounce, - dir); -if (!xfer->dma) { -hci_dma_unmap_xfer (hci, xfer_list, i); -return -ENOMEM ; - } *ring_data++ =lower_32_bits (xfer->dma->addr); *ring_data++ =upper_32_bits (xfer->dma->addr); }else {
@@ -447,7 +464,7 @@ static int hci_dma_queue_xfer(struct i3c op2_val =rh_reg_read (RING_OPERATION2 );if (enqueue_ptr ==FIELD_GET (RING_OP2_CR_DEQ_PTR , op2_val)) {/* the ring is full */ -hci_dma_unmap_xfer (hci, xfer_list, i +1 ); +hci_dma_unmap_xfer (hci, xfer_list, n);return -EBUSY ; } }
Greg Kroah-Hartman
maintainerPATCH 366/378 i3c: mipi-i3c-hci: Consolidate spinlocks
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit fa12bb903bc3ed1826e355d267fe134bde95e23c upstream.
The MIPI I3C HCI driver currently uses separate spinlocks for different contexts (PIO vs. DMA rings). This split is unnecessary and complicates upcoming fixes. The driver does not support concurrent PIO and DMA operation, and it only supports a single DMA ring, so a single lock is sufficient for all paths.
Introduce a unified spinlock in struct i3c_hci, switch both PIO and DMA code to use it, and remove the per-context locks.
No functional change is intended in this patch.
--- drivers/i3c/master/mipi-i3c-hci/core.c | 2 ++ drivers/i3c/master/mipi-i3c-hci/dma.c | 14 ++++++-------- drivers/i3c/master/mipi-i3c-hci/hci.h | 1 + drivers/i3c/master/mipi-i3c-hci/pio.c | 16 +++++++--------- 4 files changed, 16 insertions(+), 17 deletions(-)
drivers/i3c/master/mipi-i3c-hci/core.c +2 -0
@@ -631,6 +631,8 @@ static int i3c_hci_init(struct i3c_hci *if (ret)return ret; +spin_lock_init (&hci->lock); +/* * Now let's reset the hardware. * SOFT_RST must be clear before we write to it.
drivers/i3c/master/mipi-i3c-hci/dma.c +6 -8
@@ -133,7 +133,6 @@ struct hci_rh_data {unsigned int xfer_struct_sz, resp_struct_sz, ibi_status_sz, ibi_chunk_sz;unsigned int done_ptr, ibi_chunk_ptr;struct hci_xfer **src_xfers; -spinlock_t lock;struct completion op_done; };
@@ -240,7 +239,6 @@ static int hci_dma_init(struct i3c_hci * goto err_out; rh = &rings->headers[i]; rh->regs = hci->base_regs + offset; -spin_lock_init (&rh->lock);init_completion (&rh->op_done); rh->xfer_entries =XFER_RING_ENTRIES ;
@@ -470,12 +468,12 @@ static int hci_dma_queue_xfer(struct i3c }/* take care to update the hardware enqueue pointer atomically */ -spin_lock_irq (&rh->lock); +spin_lock_irq (&hci->lock); op1_val =rh_reg_read (RING_OPERATION1 ); op1_val &= ~RING_OP1_CR_ENQ_PTR ; op1_val |=FIELD_PREP (RING_OP1_CR_ENQ_PTR , enqueue_ptr);rh_reg_write (RING_OPERATION1 , op1_val); -spin_unlock_irq (&rh->lock); +spin_unlock_irq (&hci->lock);return 0 ; }
@@ -573,12 +571,12 @@ static void hci_dma_xfer_done(struct i3c }/* take care to update the software dequeue pointer atomically */ -spin_lock (&rh->lock); +spin_lock (&hci->lock); op1_val =rh_reg_read (RING_OPERATION1 ); op1_val &= ~RING_OP1_CR_SW_DEQ_PTR ; op1_val |=FIELD_PREP (RING_OP1_CR_SW_DEQ_PTR , done_ptr);rh_reg_write (RING_OPERATION1 , op1_val); -spin_unlock (&rh->lock); +spin_unlock (&hci->lock); } static int hci_dma_request_ibi(struct i3c_hci *hci, struct i3c_dev_desc *dev,
@@ -759,12 +757,12 @@ static void hci_dma_process_ibi(struct i done:/* take care to update the ibi dequeue pointer atomically */ -spin_lock (&rh->lock); +spin_lock (&hci->lock); op1_val =rh_reg_read (RING_OPERATION1 ); op1_val &= ~RING_OP1_IBI_DEQ_PTR ; op1_val |=FIELD_PREP (RING_OP1_IBI_DEQ_PTR , deq_ptr);rh_reg_write (RING_OPERATION1 , op1_val); -spin_unlock (&rh->lock); +spin_unlock (&hci->lock);/* update the chunk pointer */ rh->ibi_chunk_ptr += ibi_chunks;
drivers/i3c/master/mipi-i3c-hci/hci.h +1 -0
@@ -45,6 +45,7 @@ struct i3c_hci {const struct hci_io_ops *io;void *io_data;const struct hci_cmd_ops *cmd; +spinlock_t lock;atomic_t next_cmd_tid;u32 caps;unsigned int quirks;
drivers/i3c/master/mipi-i3c-hci/pio.c +7 -9
@@ -124,7 +124,6 @@ struct hci_pio_ibi_data { };struct hci_pio_data { -spinlock_t lock;struct hci_xfer *curr_xfer, *xfer_queue;struct hci_xfer *curr_rx, *rx_queue;struct hci_xfer *curr_tx, *tx_queue;
@@ -146,7 +145,6 @@ static int hci_pio_init(struct i3c_hci *return -ENOMEM ; hci->io_data = pio; -spin_lock_init (&pio->lock); size_val =pio_reg_read (QUEUE_SIZE ); dev_info(&hci->master.dev, "CMD/RESP FIFO = %ld entries\n",
@@ -609,7 +607,7 @@ static int hci_pio_queue_xfer(struct i3c xfer[i].data_left = xfer[i].data_len; } -spin_lock_irq (&pio->lock); +spin_lock_irq (&hci->lock); prev_queue_tail = pio->xfer_queue; pio->xfer_queue = &xfer[n -1 ];if (pio->curr_xfer) {
@@ -623,7 +621,7 @@ static int hci_pio_queue_xfer(struct i3cpio_reg_read (INTR_STATUS ), pio_reg_read(INTR_SIGNAL_ENABLE)); } -spin_unlock_irq (&pio->lock); +spin_unlock_irq (&hci->lock);return 0 ; }
@@ -694,14 +692,14 @@ static bool hci_pio_dequeue_xfer(structstruct hci_pio_data *pio = hci->io_data;int ret; -spin_lock_irq (&pio->lock); +spin_lock_irq (&hci->lock);dev_dbg (&hci->master.dev,"n=%d status=%#x/%#x" , n,pio_reg_read (INTR_STATUS ),pio_reg_read (INTR_SIGNAL_ENABLE ));dev_dbg (&hci->master.dev,"main_status = %#x/%#x" ,readl (hci->base_regs +0x20 ),readl (hci->base_regs +0x28 )); ret =hci_pio_dequeue_xfer_common (hci, pio, xfer, n); -spin_unlock_irq (&pio->lock); +spin_unlock_irq (&hci->lock);return ret; }
@@ -994,13 +992,13 @@ static bool hci_pio_irq_handler(struct istruct hci_pio_data *pio = hci->io_data;u32 status; -spin_lock (&pio->lock); +spin_lock (&hci->lock); status =pio_reg_read (INTR_STATUS );dev_dbg (&hci->master.dev,"PIO_INTR_STATUS %#x/%#x" , status, pio->enabled_irqs); status &= pio->enabled_irqs |STAT_LATENCY_WARNINGS ;if (!status) { -spin_unlock (&pio->lock); +spin_unlock (&hci->lock);return false; }
@@ -1036,7 +1034,7 @@ static bool hci_pio_irq_handler(struct ipio_reg_write (INTR_SIGNAL_ENABLE , pio->enabled_irqs);dev_dbg (&hci->master.dev,"PIO_INTR_STATUS %#x/%#x" ,pio_reg_read (INTR_STATUS ),pio_reg_read (INTR_SIGNAL_ENABLE )); -spin_unlock (&pio->lock); +spin_unlock (&hci->lock);return true; }
Greg Kroah-Hartman
maintainerPATCH 367/378 i3c: mipi-i3c-hci: Restart DMA ring correctly after dequeue abort
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit b6d586431ae20d5157ee468d0ef62ad26798ef13 upstream.
The DMA dequeue path attempts to restart the ring after aborting an in-flight transfer, but the current sequence is incomplete. The controller must be brought out of the aborted state and the ring control registers must be programmed in the correct order: first clearing ABORT, then re-enabling the ring and asserting RUN_STOP to resume operation.
Add the missing controller resume step and update the ring control writes so that the ring is restarted using the proper sequence.
--- drivers/i3c/master/mipi-i3c-hci/dma.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/i3c/master/mipi-i3c-hci/dma.c +2 -0
@@ -528,7 +528,9 @@ static bool hci_dma_dequeue_xfer(struct }/* restart the ring */ +mipi_i3c_hci_resume (hci);rh_reg_write (RING_CONTROL ,RING_CTRL_ENABLE ); +rh_reg_write (RING_CONTROL ,RING_CTRL_ENABLE |RING_CTRL_RUN_STOP );return did_unqueue; }
Greg Kroah-Hartman
maintainerPATCH 368/378 i3c: mipi-i3c-hci: Add missing TID field to no-op command descriptor
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit ec3cfd835f7c4bbd23bc9ad909d2fdc772a578bb upstream.
The internal control command descriptor used for no-op commands includes a Transaction ID (TID) field, but the no-op command constructed in hci_dma_dequeue_xfer() omitted it. As a result, the hardware receives a no-op descriptor without the expected TID.
This bug has gone unnoticed because the TID is currently not validated in the no-op completion path, but the descriptor format requires it to be present.
Add the missing TID field when generating a no-op descriptor so that its layout matches the defined command structure.
--- drivers/i3c/master/mipi-i3c-hci/cmd.h | 1 + drivers/i3c/master/mipi-i3c-hci/dma.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/i3c/master/mipi-i3c-hci/cmd.h +1 -0
@@ -17,6 +17,7 @@#define CMD_0_TOC W0_BIT_(31)#define CMD_0_ROC W0_BIT_(30)#define CMD_0_ATTR W0_MASK(2, 0) +#define CMD_0_TID W0_MASK(6, 3)/* * Response Descriptor Structure
drivers/i3c/master/mipi-i3c-hci/dma.c +1 -1
@@ -510,7 +510,7 @@ static bool hci_dma_dequeue_xfer(structu32 *ring_data = rh->xfer + rh->xfer_struct_sz * idx;/* store no-op cmd descriptor */ - *ring_data++ =FIELD_PREP (CMD_0_ATTR ,0x7 ); + *ring_data++ =FIELD_PREP (CMD_0_ATTR ,0x7 ) |FIELD_PREP (CMD_0_TID , xfer->cmd_tid); *ring_data++ =0 ;if (hci->cmd == &mipi_i3c_hci_cmd_v2) { *ring_data++ =0 ;
Greg Kroah-Hartman
maintainerPATCH 369/378 i3c: mipi-i3c-hci: Fix race in DMA ring dequeue
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit 1dca8aee80eea76d2aae21265de5dd64f6ba0f09 upstream.
The HCI DMA dequeue path (hci_dma_dequeue_xfer()) may be invoked for multiple transfers that timeout around the same time. However, the function is not serialized and can race with itself.
When a timeout occurs, hci_dma_dequeue_xfer() stops the ring, processes incomplete transfers, and then restarts the ring. If another timeout triggers a parallel call into the same function, the two instances may interfere with each other - stopping or restarting the ring at unexpected times.
Add a mutex so that hci_dma_dequeue_xfer() is serialized with respect to itself.
--- drivers/i3c/master/mipi-i3c-hci/core.c | 1 + drivers/i3c/master/mipi-i3c-hci/dma.c | 2 ++ drivers/i3c/master/mipi-i3c-hci/hci.h | 1 + 3 files changed, 4 insertions(+)
drivers/i3c/master/mipi-i3c-hci/core.c +1 -0
@@ -632,6 +632,7 @@ static int i3c_hci_init(struct i3c_hci *return ret;spin_lock_init (&hci->lock); +mutex_init (&hci->control_mutex);/* * Now let's reset the hardware.
drivers/i3c/master/mipi-i3c-hci/dma.c +2 -0
@@ -486,6 +486,8 @@ static bool hci_dma_dequeue_xfer(structunsigned int i;bool did_unqueue = false; +guard (mutex)(&hci->control_mutex); +/* stop the ring */ rh_reg_write (RING_CONTROL ,RING_CTRL_ABORT );if (wait_for_completion_timeout (&rh->op_done,HZ ) ==0 ) {
drivers/i3c/master/mipi-i3c-hci/hci.h +1 -0
@@ -46,6 +46,7 @@ struct i3c_hci {void *io_data;const struct hci_cmd_ops *cmd;spinlock_t lock; +struct mutex control_mutex;atomic_t next_cmd_tid;u32 caps;unsigned int quirks;
Greg Kroah-Hartman
maintainerPATCH 370/378 i3c: mipi-i3c-hci: Correct RING_CTRL_ABORT handling in DMA dequeue
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit b795e68bf3073d67bebbb5a44d93f49efc5b8cc7 upstream.
The logic used to abort the DMA ring contains several flaws:
1. The driver unconditionally issues a ring abort even when the ring has already stopped.
2. The completion used to wait for abort completion is never re-initialized, resulting in incorrect wait behavior.
3. The abort sequence unintentionally clears RING_CTRL_ENABLE, which resets hardware ring pointers and disrupts the controller state.
4. If the ring is already stopped, the abort operation should be considered successful without attempting further action.
Fix the abort handling by checking whether the ring is running before issuing an abort, re-initializing the completion when needed, ensuring that RING_CTRL_ENABLE remains asserted during abort, and treating an already stopped ring as a successful condition.
--- drivers/i3c/master/mipi-i3c-hci/dma.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
drivers/i3c/master/mipi-i3c-hci/dma.c +16 -9
@@ -485,18 +485,25 @@ static bool hci_dma_dequeue_xfer(structstruct hci_rh_data *rh = &rings->headers[xfer_list[0 ].ring_number];unsigned int i;bool did_unqueue = false; +u32 ring_status;guard (mutex)(&hci->control_mutex); -/* stop the ring */ -rh_reg_write (RING_CONTROL ,RING_CTRL_ABORT ); -if (wait_for_completion_timeout (&rh->op_done,HZ ) ==0 ) { -/* -* We're deep in it if ever this condition is ever met. -* Hardware might still be writing to memory, etc. -*/ -dev_crit (&hci->master.dev,"unable to abort the ring\n" ); -WARN_ON (1 ); + ring_status =rh_reg_read (RING_STATUS ); +if (ring_status &RING_STATUS_RUNNING ) { +/* stop the ring */ +reinit_completion (&rh->op_done); +rh_reg_write (RING_CONTROL ,RING_CTRL_ENABLE |RING_CTRL_ABORT ); +wait_for_completion_timeout (&rh->op_done,HZ ); + ring_status =rh_reg_read (RING_STATUS ); +if (ring_status &RING_STATUS_RUNNING ) { +/* +* We're deep in it if ever this condition is ever met. +* Hardware might still be writing to memory, etc. +*/ +dev_crit (&hci->master.dev,"unable to abort the ring\n" ); +WARN_ON (1 ); + } }for (i =0 ; i < n; i++) {
Greg Kroah-Hartman
maintainerPATCH 371/378 mm/damon: rename DAMON_MIN_REGION to DAMON_MIN_REGION_SZ
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
[ Upstream commit dfb1b0c9dc0d61e422905640e1e7334b3cf6f384 ]
The macro is for the default minimum size of each DAMON region. There was a case that a reader was confused if it is the minimum number of total DAMON regions, which is set on damon_attrs->min_nr_regions. Make the name more explicit.
Stable-dep-of: c80f46ac228b ("mm/damon/core: disallow non-power of two min_region_sz")
--- include/linux/damon.h | 2 +- mm/damon/core.c | 2 +- mm/damon/lru_sort.c | 2 +- mm/damon/reclaim.c | 2 +- mm/damon/sysfs.c | 2 +- mm/damon/tests/vaddr-kunit.h | 2 +- mm/damon/vaddr.c | 24 ++++++++++++------------ 7 files changed, 18 insertions(+), 18 deletions(-)
include/linux/damon.h +1 -1
@@ -15,7 +15,7 @@#include <linux/random.h> /* Minimal region size. Every damon_region is aligned by this. */ -#define DAMON_MIN_REGION PAGE_SIZE +#define DAMON_MIN_REGION_SZ PAGE_SIZE/* Max priority score for DAMON-based operation schemes */ #define DAMOS_MAX_SCORE (99)
mm/damon/core.c +1 -1
@@ -546,7 +546,7 @@ struct damon_ctx *damon_new_ctx(void) ctx->attrs.max_nr_regions =1000 ; ctx->addr_unit =1 ; - ctx->min_sz_region =DAMON_MIN_REGION ; + ctx->min_sz_region =DAMON_MIN_REGION_SZ ;INIT_LIST_HEAD (&ctx->adaptive_targets);INIT_LIST_HEAD (&ctx->schemes);
mm/damon/lru_sort.c +1 -1
@@ -212,7 +212,7 @@ static int damon_lru_sort_apply_parameteif (!monitor_region_start && !monitor_region_end) addr_unit =1 ; param_ctx->addr_unit = addr_unit; - param_ctx->min_sz_region =max (DAMON_MIN_REGION / addr_unit,1 ); + param_ctx->min_sz_region =max (DAMON_MIN_REGION_SZ / addr_unit,1 );if (!damon_lru_sort_mon_attrs.sample_interval) { err = -EINVAL ;
mm/damon/reclaim.c +1 -1
@@ -208,7 +208,7 @@ static int damon_reclaim_apply_parameterif (!monitor_region_start && !monitor_region_end) addr_unit =1 ; param_ctx->addr_unit = addr_unit; - param_ctx->min_sz_region =max (DAMON_MIN_REGION / addr_unit,1 ); + param_ctx->min_sz_region =max (DAMON_MIN_REGION_SZ / addr_unit,1 );if (!damon_reclaim_mon_attrs.aggr_interval) { err = -EINVAL ;
mm/damon/sysfs.c +1 -1
@@ -1470,7 +1470,7 @@ static int damon_sysfs_apply_inputs(stru/* addr_unit is respected by only DAMON_OPS_PADDR */ if (sys_ctx->ops_id ==DAMON_OPS_PADDR ) ctx->min_sz_region =max ( -DAMON_MIN_REGION / sys_ctx->addr_unit,1 ); +DAMON_MIN_REGION_SZ / sys_ctx->addr_unit,1 ); err =damon_sysfs_set_attrs (ctx, sys_ctx->attrs);if (err)return err;
mm/damon/tests/vaddr-kunit.h +1 -1
@@ -147,7 +147,7 @@ static void damon_do_test_apply_three_redamon_add_region (r, t); } -damon_set_regions (t, three_regions,3 ,DAMON_MIN_REGION ); +damon_set_regions (t, three_regions,3 ,DAMON_MIN_REGION_SZ );for (i =0 ; i < nr_expected /2 ; i++) { r =__nth_region_of (t, i);
mm/damon/vaddr.c +12 -12
@@ -19,8 +19,8 @@#include "ops-common.h" #ifdef CONFIG_DAMON_VADDR_KUNIT_TEST -#undef DAMON_MIN_REGION -#define DAMON_MIN_REGION 1 +#undef DAMON_MIN_REGION_SZ +#define DAMON_MIN_REGION_SZ 1#endif /*
@@ -78,7 +78,7 @@ static int damon_va_evenly_split_region( orig_end = r->ar.end; sz_orig =damon_sz_region (r); - sz_piece =ALIGN_DOWN (sz_orig / nr_pieces,DAMON_MIN_REGION ); + sz_piece =ALIGN_DOWN (sz_orig / nr_pieces,DAMON_MIN_REGION_SZ );if (!sz_piece)return -EINVAL ;
@@ -161,12 +161,12 @@ next:swap (first_gap, second_gap);/* Store the result */ - regions[0 ].start =ALIGN (start,DAMON_MIN_REGION ); - regions[0 ].end =ALIGN (first_gap.start,DAMON_MIN_REGION ); - regions[1 ].start =ALIGN (first_gap.end,DAMON_MIN_REGION ); - regions[1 ].end =ALIGN (second_gap.start,DAMON_MIN_REGION ); - regions[2 ].start =ALIGN (second_gap.end,DAMON_MIN_REGION ); - regions[2 ].end =ALIGN (prev->vm_end,DAMON_MIN_REGION ); + regions[0 ].start =ALIGN (start,DAMON_MIN_REGION_SZ ); + regions[0 ].end =ALIGN (first_gap.start,DAMON_MIN_REGION_SZ ); + regions[1 ].start =ALIGN (first_gap.end,DAMON_MIN_REGION_SZ ); + regions[1 ].end =ALIGN (second_gap.start,DAMON_MIN_REGION_SZ ); + regions[2 ].start =ALIGN (second_gap.end,DAMON_MIN_REGION_SZ ); + regions[2 ].end =ALIGN (prev->vm_end,DAMON_MIN_REGION_SZ );return 0 ; }
@@ -259,8 +259,8 @@ static void __damon_va_init_regions(stru sz += regions[i].end - regions[i].start;if (ctx->attrs.min_nr_regions) sz /= ctx->attrs.min_nr_regions; -if (sz <DAMON_MIN_REGION ) - sz =DAMON_MIN_REGION ; +if (sz <DAMON_MIN_REGION_SZ ) + sz =DAMON_MIN_REGION_SZ ;/* Set the initial three regions of the target */ for (i =0 ; i <3 ; i++) {
@@ -299,7 +299,7 @@ static void damon_va_update(struct damondamon_for_each_target (t, ctx) {if (damon_va_three_regions (t, three_regions))continue ; -damon_set_regions (t, three_regions,3 ,DAMON_MIN_REGION ); +damon_set_regions (t, three_regions,3 ,DAMON_MIN_REGION_SZ ); } }
Greg Kroah-Hartman
maintainerPATCH 372/378 mm/damon: rename min_sz_region of damon_ctx to min_region_sz
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
[ Upstream commit cc1db8dff8e751ec3ab352483de366b7f23aefe2 ]
'min_sz_region' field of 'struct damon_ctx' represents the minimum size of each DAMON region for the context. 'struct damos_access_pattern' has a field of the same name. It confuses readers and makes 'grep' less optimal for them. Rename it to 'min_region_sz'.
Stable-dep-of: c80f46ac228b ("mm/damon/core: disallow non-power of two min_region_sz")
--- include/linux/damon.h | 8 ++--- mm/damon/core.c | 69 +++++++++++++++++++++++++------------------------- mm/damon/lru_sort.c | 4 +- mm/damon/reclaim.c | 4 +- mm/damon/stat.c | 2 - mm/damon/sysfs.c | 9 +++--- 6 files changed, 49 insertions(+), 47 deletions(-)
include/linux/damon.h +4 -4
@@ -769,7 +769,7 @@ struct damon_attrs {* * @ops: Set of monitoring operations for given use cases. * @addr_unit: Scale factor for core to ops address conversion. -* @min_sz_region: Minimum region size. +* @min_region_sz: Minimum region size. * @adaptive_targets: Head of monitoring targets (&damon_target) list. * @schemes: Head of schemes (&damos) list. */
@@ -812,7 +812,7 @@ struct damon_ctx {struct damon_operations ops;unsigned long addr_unit; -unsigned long min_sz_region; +unsigned long min_region_sz;struct list_head adaptive_targets;struct list_head schemes;
@@ -901,7 +901,7 @@ static inline void damon_insert_region(svoid damon_add_region (struct damon_region *r,struct damon_target *t);void damon_destroy_region (struct damon_region *r,struct damon_target *t);int damon_set_regions (struct damon_target *t,struct damon_addr_range *ranges, -unsigned int nr_ranges,unsigned long min_sz_region); +unsigned int nr_ranges,unsigned long min_region_sz);void damon_update_region_access_rate (struct damon_region *r,bool accessed,struct damon_attrs *attrs);
@@ -968,7 +968,7 @@ int damos_walk(struct damon_ctx *ctx, stint damon_set_region_biggest_system_ram_default (struct damon_target *t,unsigned long *start,unsigned long *end, -unsigned long min_sz_region); +unsigned long min_region_sz);#endif /* CONFIG_DAMON */
mm/damon/core.c +35 -34
235 lines not on this page · raw message
mm/damon/lru_sort.c +2 -2
@@ -212,7 +212,7 @@ static int damon_lru_sort_apply_parameteif (!monitor_region_start && !monitor_region_end) addr_unit =1 ; param_ctx->addr_unit = addr_unit; - param_ctx->min_sz_region =max (DAMON_MIN_REGION_SZ / addr_unit,1 ); + param_ctx->min_region_sz =max (DAMON_MIN_REGION_SZ / addr_unit,1 );if (!damon_lru_sort_mon_attrs.sample_interval) { err = -EINVAL ;
@@ -243,7 +243,7 @@ static int damon_lru_sort_apply_paramete err =damon_set_region_biggest_system_ram_default (param_target, &monitor_region_start, &monitor_region_end, - param_ctx->min_sz_region); + param_ctx->min_region_sz);if (err) goto out; err =damon_commit_ctx (ctx, param_ctx);
mm/damon/reclaim.c +2 -2
@@ -208,7 +208,7 @@ static int damon_reclaim_apply_parameterif (!monitor_region_start && !monitor_region_end) addr_unit =1 ; param_ctx->addr_unit = addr_unit; - param_ctx->min_sz_region =max (DAMON_MIN_REGION_SZ / addr_unit,1 ); + param_ctx->min_region_sz =max (DAMON_MIN_REGION_SZ / addr_unit,1 );if (!damon_reclaim_mon_attrs.aggr_interval) { err = -EINVAL ;
@@ -251,7 +251,7 @@ static int damon_reclaim_apply_parameter err =damon_set_region_biggest_system_ram_default (param_target, &monitor_region_start, &monitor_region_end, - param_ctx->min_sz_region); + param_ctx->min_region_sz);if (err) goto out; err =damon_commit_ctx (ctx, param_ctx);
mm/damon/stat.c +1 -1
@@ -189,7 +189,7 @@ static struct damon_ctx *damon_stat_buil goto free_out;damon_add_target (ctx, target);if (damon_set_region_biggest_system_ram_default (target, &start, &end, - ctx->min_sz_region)) + ctx->min_region_sz)) goto free_out;return ctx; free_out:
mm/damon/sysfs.c +5 -4
@@ -1365,7 +1365,7 @@ static int damon_sysfs_set_attrs(structstatic int damon_sysfs_set_regions (struct damon_target *t,struct damon_sysfs_regions *sysfs_regions, -unsigned long min_sz_region) +unsigned long min_region_sz) {struct damon_addr_range *ranges =kmalloc_array (sysfs_regions->nr,sizeof (*ranges),GFP_KERNEL | __GFP_NOWARN);
@@ -1387,7 +1387,7 @@ static int damon_sysfs_set_regions(strucif (ranges[i -1 ].end > ranges[i].start) goto out; } - err =damon_set_regions (t, ranges, sysfs_regions->nr, min_sz_region); + err =damon_set_regions (t, ranges, sysfs_regions->nr, min_region_sz); out:kfree (ranges);return err;
@@ -1409,7 +1409,8 @@ static int damon_sysfs_add_target(structreturn -EINVAL ; } t->obsolete = sys_target->obsolete; -return damon_sysfs_set_regions (t, sys_target->regions, ctx->min_sz_region); +return damon_sysfs_set_regions (t, sys_target->regions, + ctx->min_region_sz); } static int damon_sysfs_add_targets(struct damon_ctx *ctx,
@@ -1469,7 +1470,7 @@ static int damon_sysfs_apply_inputs(stru ctx->addr_unit = sys_ctx->addr_unit;/* addr_unit is respected by only DAMON_OPS_PADDR */ if (sys_ctx->ops_id ==DAMON_OPS_PADDR ) - ctx->min_sz_region =max ( + ctx->min_region_sz =max (DAMON_MIN_REGION_SZ / sys_ctx->addr_unit,1 ); err =damon_sysfs_set_attrs (ctx, sys_ctx->attrs);if (err)
Greg Kroah-Hartman
maintainerPATCH 373/378 mm/damon/core: disallow non-power of two min_region_sz
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
[ Upstream commit c80f46ac228b48403866d65391ad09bdf0e8562a ]
DAMON core uses min_region_sz parameter value as the DAMON region alignment. The alignment is made using ALIGN() and ALIGN_DOWN(), which support only the power of two alignments. But DAMON core API callers can set min_region_sz to an arbitrary number. Users can also set it indirectly, using addr_unit.
When the alignment is not properly set, DAMON behavior becomes difficult to expect and understand, makes it effectively broken. It doesn't cause a kernel crash-like significant issue, though.
Fix the issue by disallowing min_region_sz input that is not a power of two. Add the check to damon_commit_ctx(), as all DAMON API callers who set min_region_sz uses the function.
This can be a sort of behavioral change, but it does not break users, for the following reasons. As the symptom is making DAMON effectively broken, it is not reasonable to believe there are real use cases of non-power of two min_region_sz. There is no known use case or issue reports from the setup, either.
In future, if we find real use cases of non-power of two alignments and we can support it with low enough overhead, we can consider moving the restriction. But, for now, simply disallowing the corner case should be good enough as a hot fix.
--- mm/damon/core.c | 3 +++ 1 file changed, 3 insertions(+)
mm/damon/core.c +3 -0
@@ -1241,6 +1241,9 @@ int damon_commit_ctx(struct damon_ctx *d {int err; +if (!is_power_of_2 (src->min_region_sz)) +return -EINVAL ; + err =damon_commit_schemes (dst, src);if (err)return err;
Greg Kroah-Hartman
maintainerPATCH 374/378 KVM: arm64: gic: Set vgic_model before initing private IRQs
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sascha Bischoff <[email protected]>
[ Upstream commit 9435c1e1431003e23aa34ef8e46c30d09c3dbcb5 ]
Different GIC types require the private IRQs to be initialised differently. GICv5 is the culprit as it supports both a different number of private IRQs, and all of these are PPIs (there are no SGIs). Moreover, as GICv5 uses the top bits of the interrupt ID to encode the type, the intid also needs to computed differently.
Up until now, the GIC model has been set after initialising the private IRQs for a VCPU. Move this earlier to ensure that the GIC model is available when configuring the private IRQs. While we're at it, also move the setting of the in_kernel flag and implementation revision to keep them grouped together as before.
Stable-dep-of: ac6769c8f948 ("KVM: arm64: Eagerly init vgic dist/redist on vgic creation")
--- arch/arm64/kvm/vgic/vgic-init.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/kvm/vgic/vgic-init.c +4 -4
@@ -140,6 +140,10 @@ int kvm_vgic_create(struct kvm *kvm, u32 goto out_unlock; } + kvm->arch.vgic.in_kernel = true; + kvm->arch.vgic.vgic_model = type; + kvm->arch.vgic.implementation_rev =KVM_VGIC_IMP_REV_LATEST ; +kvm_for_each_vcpu (i, vcpu, kvm) { ret =vgic_allocate_private_irqs_locked (vcpu, type);if (ret)
@@ -156,10 +160,6 @@ int kvm_vgic_create(struct kvm *kvm, u32 goto out_unlock; } - kvm->arch.vgic.in_kernel = true; - kvm->arch.vgic.vgic_model = type; - kvm->arch.vgic.implementation_rev =KVM_VGIC_IMP_REV_LATEST ; - kvm->arch.vgic.vgic_dist_base =VGIC_ADDR_UNDEF ; aa64pfr0 =kvm_read_vm_id_reg (kvm,SYS_ID_AA64PFR0_EL1 ) & ~ID_AA64PFR0_EL1_GIC ;
Greg Kroah-Hartman
maintainerPATCH 375/378 KVM: arm64: Eagerly init vgic dist/redist on vgic creation
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
[ Upstream commit ac6769c8f948dff33265c50e524aebf9aa6f1be0 ]
If vgic_allocate_private_irqs_locked() fails for any odd reason, we exit kvm_vgic_create() early, leaving dist->rd_regions uninitialised.
kvm_vgic_dist_destroy() then comes along and walks into the weeds trying to free the RDs. Got to love this stuff.
Solve it by moving all the static initialisation early, and make sure that if we fail halfway, we're in a reasonable shape to perform the rest of the teardown. While at it, reset the vgic model on failure, just in case...
--- arch/arm64/kvm/vgic/vgic-init.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
arch/arm64/kvm/vgic/vgic-init.c +16 -16
@@ -143,6 +143,21 @@ int kvm_vgic_create(struct kvm *kvm, u32 kvm->arch.vgic.in_kernel = true; kvm->arch.vgic.vgic_model = type; kvm->arch.vgic.implementation_rev =KVM_VGIC_IMP_REV_LATEST ; + kvm->arch.vgic.vgic_dist_base =VGIC_ADDR_UNDEF ; + + aa64pfr0 =kvm_read_vm_id_reg (kvm,SYS_ID_AA64PFR0_EL1 ) & ~ID_AA64PFR0_EL1_GIC ; + pfr1 =kvm_read_vm_id_reg (kvm,SYS_ID_PFR1_EL1 ) & ~ID_PFR1_EL1_GIC ; + +if (type ==KVM_DEV_TYPE_ARM_VGIC_V2 ) { + kvm->arch.vgic.vgic_cpu_base =VGIC_ADDR_UNDEF ; + }else { +INIT_LIST_HEAD (&kvm->arch.vgic.rd_regions); + aa64pfr0 |=SYS_FIELD_PREP_ENUM (ID_AA64PFR0_EL1 ,GIC ,IMP ); + pfr1 |=SYS_FIELD_PREP_ENUM (ID_PFR1_EL1 ,GIC , GICv3); + } + +kvm_set_vm_id_reg (kvm,SYS_ID_AA64PFR0_EL1 , aa64pfr0); +kvm_set_vm_id_reg (kvm,SYS_ID_PFR1_EL1 , pfr1);kvm_for_each_vcpu (i, vcpu, kvm) { ret =vgic_allocate_private_irqs_locked (vcpu, type);
@@ -157,25 +172,10 @@ int kvm_vgic_create(struct kvm *kvm, u32 vgic_cpu->private_irqs =NULL ; } + kvm->arch.vgic.vgic_model =0 ; goto out_unlock; } - kvm->arch.vgic.vgic_dist_base =VGIC_ADDR_UNDEF ; - - aa64pfr0 =kvm_read_vm_id_reg (kvm,SYS_ID_AA64PFR0_EL1 ) & ~ID_AA64PFR0_EL1_GIC ; - pfr1 =kvm_read_vm_id_reg (kvm,SYS_ID_PFR1_EL1 ) & ~ID_PFR1_EL1_GIC ; - -if (type ==KVM_DEV_TYPE_ARM_VGIC_V2 ) { - kvm->arch.vgic.vgic_cpu_base =VGIC_ADDR_UNDEF ; - }else { -INIT_LIST_HEAD (&kvm->arch.vgic.rd_regions); - aa64pfr0 |=SYS_FIELD_PREP_ENUM (ID_AA64PFR0_EL1 ,GIC ,IMP ); - pfr1 |=SYS_FIELD_PREP_ENUM (ID_PFR1_EL1 ,GIC , GICv3); - } - -kvm_set_vm_id_reg (kvm,SYS_ID_AA64PFR0_EL1 , aa64pfr0); -kvm_set_vm_id_reg (kvm,SYS_ID_PFR1_EL1 , pfr1); -if (type ==KVM_DEV_TYPE_ARM_VGIC_V3 ) kvm->arch.vgic.nassgicap =system_supports_direct_sgis ();
Greg Kroah-Hartman
maintainerPATCH 376/378 io_uring: ensure ctx->rings is stable for task work flags manipulation
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
Commit 96189080265e6bb5dde3a4afbaf947af493e3f82 upstream.
If DEFER_TASKRUN | SETUP_TASKRUN is used and task work is added while the ring is being resized, it's possible for the OR'ing of IORING_SQ_TASKRUN to happen in the small window of swapping into the new rings and the old rings being freed.
Prevent this by adding a 2nd ->rings pointer, ->rings_rcu, which is protected by RCU. The task work flags manipulation is inside RCU already, and if the resize ring freeing is done post an RCU synchronize, then there's no need to add locking to the fast path of task work additions.
Note: this is only done for DEFER_TASKRUN, as that's the only setup mode that supports ring resizing. If this ever changes, then they too need to use the io_ctx_mark_taskrun() helper.
--- include/linux/io_uring_types.h | 1 + io_uring/io_uring.c | 24 ++++++++++++++++++++++-- io_uring/register.c | 12 ++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-)
include/linux/io_uring_types.h +1 -0
@@ -371,6 +371,7 @@ struct io_ring_ctx {* regularly bounce b/w CPUs. */ struct { +struct io_rings __rcu *rings_rcu;struct llist_head work_llist;struct llist_head retry_llist;unsigned long check_cq;
io_uring/io_uring.c +22 -2
@@ -1202,6 +1202,21 @@ void tctx_task_work(struct callback_headWARN_ON_ONCE (ret); } +/* +* Sets IORING_SQ_TASKRUN in the sq_flags shared with userspace, using the +* RCU protected rings pointer to be safe against concurrent ring resizing. +*/ +static void io_ctx_mark_taskrun (struct io_ring_ctx *ctx) +{ +lockdep_assert_in_rcu_read_lock (); + +if (ctx->flags &IORING_SETUP_TASKRUN_FLAG ) { +struct io_rings *rings =rcu_dereference (ctx->rings_rcu); + +atomic_or (IORING_SQ_TASKRUN , &rings->sq_flags); + } +} +static void io_req_local_work_add (struct io_kiocb *req,unsigned flags) {struct io_ring_ctx *ctx = req->ctx;
@@ -1256,8 +1271,7 @@ static void io_req_local_work_add(struct*/ if (!head) { -if (ctx->flags &IORING_SETUP_TASKRUN_FLAG ) -atomic_or (IORING_SQ_TASKRUN , &ctx->rings->sq_flags); +io_ctx_mark_taskrun (ctx);if (ctx->has_evfd)io_eventfd_signal (ctx, false); }
@@ -1281,6 +1295,10 @@ static void io_req_normal_work_add(strucif (!llist_add (&req->io_task_work.node, &tctx->task_list))return ; +/* +* Doesn't need to use ->rings_rcu, as resizing isn't supported for +* !DEFER_TASKRUN. +*/ if (ctx->flags &IORING_SETUP_TASKRUN_FLAG )atomic_or (IORING_SQ_TASKRUN , &ctx->rings->sq_flags);
@@ -2760,6 +2778,7 @@ static void io_rings_free(struct io_ringio_free_region (ctx->user, &ctx->sq_region);io_free_region (ctx->user, &ctx->ring_region); ctx->rings =NULL ; +RCU_INIT_POINTER (ctx->rings_rcu,NULL ); ctx->sq_sqes =NULL ; }
@@ -3389,6 +3408,7 @@ static __cold int io_allocate_scq_uringsif (ret)return ret; ctx->rings = rings =io_region_get_ptr (&ctx->ring_region); +rcu_assign_pointer (ctx->rings_rcu, rings);if (!(ctx->flags &IORING_SETUP_NO_SQARRAY )) ctx->sq_array = (u32 *)((char *)rings + rl->sq_array_offset);
io_uring/register.c +12 -0
@@ -545,7 +545,15 @@ overflow: ctx->sq_entries = p->sq_entries; ctx->cq_entries = p->cq_entries; +/* +* Just mark any flag we may have missed and that the application +* should act on unconditionally. Worst case it'll be an extra +* syscall. +*/ +atomic_or (IORING_SQ_TASKRUN |IORING_SQ_NEED_WAKEUP , &n.rings->sq_flags); ctx->rings = n.rings; +rcu_assign_pointer (ctx->rings_rcu, n.rings); + ctx->sq_sqes = n.sq_sqes;swap_old (ctx, o, n, ring_region);swap_old (ctx, o, n, sq_region);
@@ -554,6 +562,10 @@ overflow: out:spin_unlock (&ctx->completion_lock);mutex_unlock (&ctx->mmap_lock); + +/* Wait for concurrent io_ctx_mark_taskrun() */ +if (to_free == &o) +synchronize_rcu_expedited ();io_register_free_rings (ctx, to_free);if (ctx->sq_data)
Greg Kroah-Hartman
maintainerPATCH 377/378 io_uring/eventfd: use ctx->rings_rcu for flags checking
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
Commit 177c69432161f6e4bab07ccacf8a1748a6898a6b upstream.
Similarly to what commit e78f7b70e837 did for local task work additions, use ->rings_rcu under RCU rather than dereference ->rings directly. See that commit for more details.
--- io_uring/eventfd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
io_uring/eventfd.c +7 -3
@@ -76,11 +76,15 @@ void io_eventfd_signal(struct io_ring_ct {bool skip = false;struct io_ev_fd *ev_fd; - -if (READ_ONCE (ctx->rings->cq_flags) &IORING_CQ_EVENTFD_DISABLED ) -return ; +struct io_rings *rings;guard (rcu)(); + + rings =rcu_dereference (ctx->rings_rcu); +if (!rings) +return ; +if (READ_ONCE (rings->cq_flags) &IORING_CQ_EVENTFD_DISABLED ) +return ; ev_fd =rcu_dereference (ctx->io_ev_fd);/* * Check again if ev_fd exists in case an io_eventfd_unregister call
Greg Kroah-Hartman
maintainerPATCH 378/378 cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
In reply to Greg Kroah-Hartman6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
commit 93d0fcdddc9e7be9d4f42acbe57bc90dbb0fe75d upstream.
Commit e7e222ad73d9 ("cxl: Move devm_cxl_add_nvdimm_bridge() to cxl_pmem.ko") moves devm_cxl_add_nvdimm_bridge() into the cxl_pmem file, which has independent config compile options for built-in or module. The call from cxl_acpi_probe() is guarded by IS_ENABLED(CONFIG_CXL_PMEM), which evaluates to true for both =y and =m.
When CONFIG_CXL_PMEM=m, a built-in cxl_acpi attempts to reference a symbol exported by a module, which fails to link. CXL_PMEM cannot simply be promoted to =y in this configuration because it depends on LIBNVDIMM, which may itself be =m.
Add a Kconfig dependency to prevent CXL_ACPI from being built-in when CXL_PMEM is a module. This contrains CXL_ACPI to =m when CXL_PMEM=m, while still allowing CXL_ACPI to be freely configured when CXL_PMEM is either built-in or disabled.
[ dj: Fix up commit reference formatting. ]
--- drivers/cxl/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/cxl/Kconfig +1 -0
@@ -58,6 +58,7 @@ config CXL_ACPI tristate "CXL ACPI: Platform Support" depends on ACPI depends on ACPI_NUMA + depends on CXL_PMEM || !CXL_PMEM default CXL_BUS select ACPI_TABLE_LIB select ACPI_HMAT
Re: [PATCH 6.19 378/378] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
Quoted 1 line · Greg Kroah-Hartman
6.19-stable review patch. If anyone has any objections, please let me know.
No objection, but a little confused how this got to stable before landing in Linus' tree. Does stable pull directly from downstream subsystems now?
Speaking of upstream, will the CXL maintainers be submitting a pull request for the staged fixes soon? I'm just getting new bug reports from people testing 7.0-rc, so wanted to check in on that.
Re: [PATCH 6.19 378/378] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
Quoted 10 lines · Keith Busch
Quoted 1 line · Greg Kroah-Hartman
6.19-stable review patch. If anyone has any objections, please let me know.
No objection, but a little confused how this got to stable before landing in Linus' tree. Does stable pull directly from downstream subsystems now?
Speaking of upstream, will the CXL maintainers be submitting a pull request for the staged fixes soon? I'm just getting new bug reports from people testing 7.0-rc, so wanted to check in on that.
I can send it today. Looks like I got enough days in linux-next soaking for the PR.
Greg Kroah-Hartman
maintainerRe: [PATCH 6.19 378/378] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
Quoted 10 lines · Dave Jiang
Quoted 7 lines · Keith Busch
Quoted 1 line · Greg Kroah-Hartman
6.19-stable review patch. If anyone has any objections, please let me know.
No objection, but a little confused how this got to stable before landing in Linus' tree. Does stable pull directly from downstream subsystems now?
Quoted 6 lines
Quoted 3 lines
Speaking of upstream, will the CXL maintainers be submitting a pull request for the staged fixes soon? I'm just getting new bug reports from people testing 7.0-rc, so wanted to check in on that.
I can send it today. Looks like I got enough days in linux-next soaking for the PR.
I took it as it was "obviously" correct, fixed reported regressions, and it was in linux-next and going to Linus "soon".
thanks,
greg k-h
Re: [PATCH 6.19 378/378] cxl/acpi: Fix CXL_ACPI and CXL_PMEM Kconfig tristate mismatch
Quoted 15 lines · Greg Kroah-Hartman
Quoted 14 lines · Dave Jiang
Quoted 10 lines · Keith Busch
Quoted 1 line · Greg Kroah-Hartman
6.19-stable review patch. If anyone has any objections, please let me know.
No objection, but a little confused how this got to stable before landing in Linus' tree. Does stable pull directly from downstream subsystems now?
Speaking of upstream, will the CXL maintainers be submitting a pull request for the staged fixes soon? I'm just getting new bug reports from people testing 7.0-rc, so wanted to check in on that.
Quoted 5 lines
Quoted 2 lines
I can send it today. Looks like I got enough days in linux-next soaking for the PR.
I took it as it was "obviously" correct, fixed reported regressions, and it was in linux-next and going to Linus "soon".
It's now in Linus's tree as of yesterday. We are all good.
Quoted 4 lines
thanks,
greg k-h
Hi
compile runs in an error:
LD vmlinux.unstripped
BTFIDS vmlinux.unstripped
WARN: resolve_btfids: unresolved symbol kthread_exit make[2]: *** [scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255 make[2]: *** Deleting file 'vmlinux.unstripped'
make[1]: *** [/home/DATA/DEVEL/linux/Makefile:1277: vmlinux] Error 2
make: *** [Makefile:248: __sub-make] Error 2
if I do:
git revert f5ee297b23d843d4ae690595aa29e8f5baeaecf9 --no-edit
see:
all is fine here on x86_64 (Intel 11th Gen. CPU)
Thanks
Peter Schneider
Tested-byAm 17.03.2026 um 18:47 schrieb Ronald Warsow:
Quoted 23 lines
Hi
compile runs in an error:
LD vmlinux.unstripped
BTFIDS vmlinux.unstripped
WARN:resolve_btfids: unresolved symbolkthread_exitmake[2]: *** [scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255 make[2]: *** Deleting file 'vmlinux.unstripped'
make[1]: *** [/home/DATA/DEVEL/linux/Makefile:1277: vmlinux] Error 2
make: *** [Makefile:248: __sub-make] Error 2if I do:
git revert
f5ee297b23d843d4ae690595aa29e8f5baeaecf9--no-editsee:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/commit/? h=linux-6.19.y&id=f5ee297b23d843d4ae690595aa29e8f5baeaecf9
Quoted 5 lines
all is fine here on
x86_64(Intel 11th Gen. CPU)Thanks
Tested-by Ronald Warsow <[email protected]>
I can confirm Ronald's finding. I see the same error on my 2-socket Ivy Bridge Xeon E5-2697 v2 server, and the same revert helps.
Beste Grüße,
Peter Schneider
Signature · 8 lines
Climb the mountain not to plant your flag, but to embrace the challenge, enjoy the air and behold the view. Climb it so you can see the world, not so the world can see you. -- David McCullough Jr. OpenPGP: 0xA3828BD796CCE11A8CADE8866E3A92C92C3FF244 Download: https://www.peters-netzplatz.de/download/pschneider1968_pub.asc https://keys.mailvelope.com/pks/lookup?op=get&[email protected] https://keys.mailvelope.com/pks/lookup?op=get&[email protected]
Greg Kroah-Hartman
maintainerQuoted 23 lines · Ronald Warsow
Hi
compile runs in an error:
LD vmlinux.unstripped
BTFIDS vmlinux.unstripped
WARN:resolve_btfids: unresolved symbolkthread_exitmake[2]: *** [scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255 make[2]: *** Deleting file 'vmlinux.unstripped'
make[1]: *** [/home/DATA/DEVEL/linux/Makefile:1277: vmlinux] Error 2
make: *** [Makefile:248: __sub-make] Error 2if I do:
git revert
f5ee297b23d843d4ae690595aa29e8f5baeaecf9--no-editsee:
Quoted 6 lines
all is fine here on
x86_64(Intel 11th Gen. CPU)Thanks
Tested-by Ronald Warsow <[email protected]>
I've fixed this now, thanks!
greg k-h
# Librecast Test Results
020/020 [ OK ] liblcrq
010/010 [ OK ] libmld
120/120 [ OK ] liblibrecast
CPU/kernel: Linux auntie 6.19.9-rc1-g4f987e117969 #2 SMP PREEMPT_DYNAMIC Tue Mar 17 20:08:14 -00 2026 x86_64 AMD Ryzen 9 9950X 16-Core Processor AuthenticAMD GNU/Linux
Quoted 8 lines · On Tue, 17 Mar 2026 17:29:17 +0100 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.19.9 release. There are 378 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 Thu, 19 Mar 2026 16:28:59 +0000. Anything received after that time might be too late.
Boot-tested under QEMU for Rust x86_64, arm64 and riscv64; built-tested for loongarch64:
Thanks!
Cheers,
Miguel
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.19.9 release. There are 378 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 Thu, 19 Mar 2026 16:28:59 +0000. Anything received after that time might be too late.
test_progs, test_progs-no_alu32, test_progs-cpuv4, test_maps, test_verifier in BPF selftests all passes[1] on x86_64.
1: https://github.com/shunghsiyu/libbpf/actions/runs/23211625016/job/67531397718
[...]
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.19.9 release. There are 378 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 Thu, 19 Mar 2026 16:28:59 +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.19.9-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.19.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v6.19:
11 builds: 11 pass, 0 fail
28 boots: 28 pass, 0 fail
133 tests: 133 pass, 0 failLinux version: 6.19.9-rc1-g4f987e117969
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra186-p3509-0000+p3636-0001, tegra194-p2972-0000,
tegra194-p3509-0000+p3668-0000, tegra20-ventana,
tegra210-p2371-2180, tegra210-p3450-0000,
tegra234-p3737-0000+p3701-0000,
tegra234-p3768-0000+p3767-0005, tegra30-cardhu-a04Jon
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.19.9 release. There are 378 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 Thu, 19 Mar 2026 16:28:59 +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.19.9-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.19.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Luna Jernberg
Tested-byAMD Ryzen 5 5600 6-Core Processor:
https://www.inet.se/produkt/5304697/amd-ryzen-5-5600-3-5-ghz-35mb on a
https://www.gigabyte.com/Motherboard/B550-AORUS-ELITE-V2-rev-12
https://www.inet.se/produkt/1903406/gigabyte-b550-aorus-elite-v2
motherboard :)
running Arch Linux with the testing repos enabled:
https://archlinux.org/ https://archboot.com/
https://wiki.archlinux.org/title/Arch_Testing_Team
Den ons 18 mars 2026 kl 10:04 skrev Ron Economos <[email protected]>:
Quoted 25 lines · Greg Kroah-Hartman
Quoted 9 lines
This is the start of the stable review cycle for the 6.19.9 release. There are 378 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 Thu, 19 Mar 2026 16:28:59 +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.19.9-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.19.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Tested-by Ron Economos <[email protected]>
Hi Greg
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.19.9 release. There are 378 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 Thu, 19 Mar 2026 16:28:59 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.19.9-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.19.y
and the diffstat can be found below.thanks,
greg k-h
6.19.9-rc1 tested.
Build successfully completed.
Boot successfully completed.
No dmesg regressions.
Video output normal.
Sound output normal.
Lenovo ThinkPad X1 Carbon Gen10(Intel i7-1260P(x86_64) arch linux)
[ 0.000000] Linux version 6.19.9-rc1rv-g4f987e117969
(takeshi@ThinkPadX1Gen10J0764) (gcc (GCC) 15.2.1 20260209, GNU ld (GNU Binutils) 2.46) #1 SMP PREEMPT_DYNAMIC Wed Mar 18 18:51:42 JST 2026
Thanks