6.12.91-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 598/666 ntfs: ->d_compare() must not block
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit ca2a04e84af79596e5cd9cfe697d5122ec39c8ce ]
... so don't use __getname() there. Switch it (and ntfs_d_hash(), while we are at it) to kmalloc(PATH_MAX, GFP_NOWAIT). Yes, ntfs_d_hash() almost certainly can do with smaller allocations, but let ntfs folks deal with that - keep the allocation size as-is for now.
Stop abusing names_cachep in ntfs, period - various uses of that thing in there have nothing to do with pathnames; just use k[mz]alloc() and be done with that. For now let's keep sizes as-in, but AFAICS none of the users actually want PATH_MAX.
--- fs/ntfs3/dir.c | 5 ++--- fs/ntfs3/fsntfs.c | 4 ++-- fs/ntfs3/inode.c | 13 ++++++------- fs/ntfs3/namei.c | 17 ++++++++--------- fs/ntfs3/xattr.c | 5 ++--- 5 files changed, 20 insertions(+), 24 deletions(-)
fs/ntfs3/dir.c +2 -3
@@ -425,8 +425,7 @@ static int ntfs_readdir(struct file *file, struct dir_context *ctx)if (!dir_emit_dots (file, ctx))return 0 ; -/* Allocate PATH_MAX bytes. */ - name =__getname (); + name =kmalloc (PATH_MAX ,GFP_KERNEL );if (!name)return -ENOMEM ;
@@ -504,7 +503,7 @@ static int ntfs_readdir(struct file *file, struct dir_context *ctx) out: -__putname (name); +kfree (name);put_indx_node (node);if (err ==1 ) {
fs/ntfs3/fsntfs.c +2 -2
@@ -2670,7 +2670,7 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8 *label, int len)u32 uni_bytes;struct ntfs_inode *ni = sbi->volume.ni;/* Allocate PATH_MAX bytes. */ -struct cpu_str *uni =__getname (); +struct cpu_str *uni =kmalloc (PATH_MAX ,GFP_KERNEL );if (!uni)return -ENOMEM ;
@@ -2714,6 +2714,6 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8 *label, int len) err =_ni_write_inode (&ni->vfs_inode,0 ); out: -__putname (uni); +kfree (uni);return err; }
fs/ntfs3/inode.c +6 -7
@@ -1301,7 +1301,7 @@ int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, fa |=FILE_ATTRIBUTE_READONLY ;/* Allocate PATH_MAX bytes. */ - new_de =kmem_cache_zalloc (names_cachep,GFP_KERNEL ); + new_de =kzalloc (PATH_MAX ,GFP_KERNEL );if (!new_de) { err = -ENOMEM ; goto out1;
@@ -1713,7 +1713,7 @@ int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,ntfs_mark_rec_free (sbi, ino, false); out2: -__putname (new_de); +kfree (new_de);kfree (rp); out1:
@@ -1734,7 +1734,7 @@ int ntfs_link_inode(struct inode *inode, struct dentry *dentry)struct NTFS_DE *de;/* Allocate PATH_MAX bytes. */ - de =kmem_cache_zalloc (names_cachep,GFP_KERNEL ); + de =kzalloc (PATH_MAX ,GFP_KERNEL );if (!de)return -ENOMEM ;
@@ -1748,7 +1748,7 @@ int ntfs_link_inode(struct inode *inode, struct dentry *dentry) err =ni_add_name (ntfs_i (d_inode (dentry->d_parent)), ni, de); out: -__putname (de); +kfree (de);return err; }
@@ -1771,8 +1771,7 @@ int ntfs_unlink_inode(struct inode *dir, const struct dentry *dentry)if (ntfs_is_meta_file (sbi, ni->mi.rno))return -EINVAL ; -/* Allocate PATH_MAX bytes. */ - de =kmem_cache_zalloc (names_cachep,GFP_KERNEL ); + de =kzalloc (PATH_MAX ,GFP_KERNEL );if (!de)return -ENOMEM ;
@@ -1808,7 +1807,7 @@ int ntfs_unlink_inode(struct inode *dir, const struct dentry *dentry) out:ni_unlock (ni); -__putname (de); +kfree (de);return err; }
fs/ntfs3/namei.c +8 -9
@@ -68,7 +68,7 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry, u32 flags) {struct ntfs_inode *ni =ntfs_i (dir); -struct cpu_str *uni =__getname (); +struct cpu_str *uni =kmalloc (PATH_MAX ,GFP_KERNEL );struct inode *inode;int err;
@@ -85,7 +85,7 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry, inode =dir_search_u (dir, uni,NULL );ni_unlock (ni); } -__putname (uni); +kfree (uni); }/*
@@ -287,8 +287,7 @@ static int ntfs_rename(struct mnt_idmap *idmap, struct inode *dir,return err; } -/* Allocate PATH_MAX bytes. */ - de =__getname (); + de =kmalloc (PATH_MAX ,GFP_KERNEL );if (!de)return -ENOMEM ;
@@ -333,7 +332,7 @@ static int ntfs_rename(struct mnt_idmap *idmap, struct inode *dir,ni_unlock (ni);ni_unlock (dir_ni); out: -__putname (de); +kfree (de);return err; }
@@ -391,7 +390,7 @@ static int ntfs_d_hash(const struct dentry *dentry, struct qstr *name)/* * Try slow way with current upcase table */ - uni =kmem_cache_alloc (names_cachep,GFP_NOWAIT ); + uni =kmalloc (PATH_MAX ,GFP_NOWAIT );if (!uni)return -ENOMEM ;
@@ -413,7 +412,7 @@ static int ntfs_d_hash(const struct dentry *dentry, struct qstr *name) err =0 ; out: -kmem_cache_free (names_cachep, uni); +kfree (uni);return err; }
@@ -452,7 +451,7 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1,* Try slow way with current upcase table */ sbi = dentry->d_sb->s_fs_info; - uni1 =__getname (); + uni1 =kmalloc (PATH_MAX ,GFP_NOWAIT );if (!uni1)return -ENOMEM ;
@@ -482,7 +481,7 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1, ret = !ntfs_cmp_names_cpu (uni1, uni2, sbi->upcase, false) ?0 :1 ; out: -__putname (uni1); +kfree (uni1);return ret; }
fs/ntfs3/xattr.c +2 -3
@@ -552,8 +552,7 @@ struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,int err;void *buf; -/* Allocate PATH_MAX bytes. */ - buf =__getname (); + buf =kmalloc (PATH_MAX ,GFP_KERNEL );if (!buf)return ERR_PTR (-ENOMEM );
@@ -584,7 +583,7 @@ struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,if (!IS_ERR (acl))set_cached_acl (inode, type, acl); -__putname (buf); +kfree (buf);return acl; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 599/666 PCI: Initialize temporary device in new_id_store()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samiullah Khawaja <[email protected]>
[ Upstream commit f45a49a2380a47332817b7248c61a0ebbc6f0d00 ]
When setting new_id of a PCI device driver using sysfs a lockdep splat occurs. This is because new_id_store() builds a temporary pci_dev for pci_match_device(), which calls device_match_driver_override(). That depends on the driver_override.lock added by cb3d1049f4ea ("driver core:
generalize driver_override in struct device").
The new driver_override.lock was not initialized in the temporary pci_dev, resulting in this lockdep splat.
Initialize the temporary pci_dev to fix this.
Repro:
Build with CONFIG_LOCKDEP=y, boot with QEMU, and add a new ID:
# echo "8086 10f5" > /sys/bus/pci/drivers/e1000e/new_id
INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe you didn't initialize this object before use? turning off the locking correctness validator.
CPU: 2 UID: 0 PID: 177 Comm: liveupdate-iomm Not tainted 7.0.0+ #9 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x5d/0x80 register_lock_class+0x77e/0x790 lock_acquire+0xbf/0x2e0 pci_match_device+0x24/0x180 new_id_store+0x189/0x1d0 kernfs_fop_write_iter+0x14f/0x210 vfs_write+0x263/0x5e0 ksys_write+0x79/0xf0 do_syscall_64+0x117/0xf80
--- drivers/pci/pci-driver.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/pci/pci-driver.c +8 -1
@@ -179,6 +179,11 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv,return NULL ; } +static void _pci_free_device (struct device *dev) +{ +kfree (to_pci_dev (dev)); +} +/** * new_id_store - sysfs frontend to pci_add_dynid() * @driver: target device driver
@@ -214,11 +219,13 @@ static ssize_t new_id_store(struct device_driver *driver, const char *buf, pdev->subsystem_vendor = subvendor; pdev->subsystem_device = subdevice; pdev->class = class; + pdev->dev.release = _pci_free_device; +device_initialize (&pdev->dev);if (pci_match_device (pdrv, pdev)) retval = -EEXIST ; -kfree (pdev); +put_device (&pdev->dev);if (retval)return retval;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 600/666 erofs: fix offset truncation when shifting pgoff on 32-bit platforms
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gao Xiang <[email protected]>
[ Upstream commit c99493ce409c3b98fec1616dbcf24c102e006deb ]
On 32-bit platforms, pgoff_t is 32 bits wide, so left-shifting large arbitrary pgoff_t values by PAGE_SHIFT performs 32-bit arithmetic and silently truncates the result for pages beyond the 4 GiB boundary.
Cast the page index to loff_t before shifting to produce a correct 64-bit byte offset.
--- fs/erofs/data.c | 2 +- fs/erofs/zdata.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/erofs/data.c +1 -1
@@ -39,7 +39,7 @@ void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset,* However, the data access range must be verified here in advance. */ if (buf->file) { - fpos = index <<PAGE_SHIFT ; + fpos = (loff_t )index <<PAGE_SHIFT ; err =rw_verify_area (READ , buf->file, &fpos,PAGE_SIZE );if (err <0 )return ERR_PTR (err);
fs/erofs/zdata.c +1 -1
@@ -1853,7 +1853,7 @@ static void z_erofs_pcluster_readmore(struct z_erofs_frontend *f,if (cur <PAGE_SIZE )break ; - cur = (index <<PAGE_SHIFT ) -1 ; + cur = ((loff_t )index <<PAGE_SHIFT ) -1 ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 601/666 net: bcmgenet: Initialize u64 stats seq counter
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryo Takakura <[email protected]>
[ Upstream commit ffc2c8c4a714df53a715827d6334ab9474424f6a ]
Initialize u64 stats as it uses seq counter on 32bit machines as suggested by lockdep below.
[ 1.830953][ T1] INFO: trying to register non-static key. [ 1.830993][ T1] The code is fine but needs lockdep annotation, or maybe [ 1.831027][ T1] you didn't initialize this object before use? [ 1.831057][ T1] turning off the locking correctness validator. [ 1.831090][ T1] CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Tainted: G W 6.16.0-rc2-v7l+ #1 PREEMPT [ 1.831097][ T1] Tainted: [W]=WARN [ 1.831099][ T1] Hardware name: BCM2711 [ 1.831101][ T1] Call trace: [ 1.831104][ T1] unwind_backtrace from show_stack+0x18/0x1c [ 1.831120][ T1] show_stack from dump_stack_lvl+0x8c/0xcc [ 1.831129][ T1] dump_stack_lvl from register_lock_class+0x9e8/0x9fc [ 1.831141][ T1] register_lock_class from __lock_acquire+0x420/0x22c0 [ 1.831154][ T1] __lock_acquire from lock_acquire+0x130/0x3f8 [ 1.831166][ T1] lock_acquire from bcmgenet_get_stats64+0x4a4/0x4c8 [ 1.831176][ T1] bcmgenet_get_stats64 from dev_get_stats+0x4c/0x408 [ 1.831184][ T1] dev_get_stats from rtnl_fill_stats+0x38/0x120 [ 1.831193][ T1] rtnl_fill_stats from rtnl_fill_ifinfo+0x7f8/0x1890 [ 1.831203][ T1] rtnl_fill_ifinfo from rtmsg_ifinfo_build_skb+0xd0/0x138 [ 1.831214][ T1] rtmsg_ifinfo_build_skb from rtmsg_ifinfo+0x48/0x8c [ 1.831225][ T1] rtmsg_ifinfo from register_netdevice+0x8c0/0x95c [ 1.831237][ T1] register_netdevice from register_netdev+0x28/0x40 [ 1.831247][ T1] register_netdev from bcmgenet_probe+0x690/0x6bc [ 1.831255][ T1] bcmgenet_probe from platform_probe+0x64/0xbc [ 1.831263][ T1] platform_probe from really_probe+0xd0/0x2d4 [ 1.831269][ T1] really_probe from __driver_probe_device+0x90/0x1a4 [ 1.831273][ T1] __driver_probe_device from driver_probe_device+0x38/0x11c [ 1.831278][ T1] driver_probe_device from __driver_attach+0x9c/0x18c [ 1.831282][ T1] __driver_attach from bus_for_each_dev+0x84/0xd4 [ 1.831291][ T1] bus_for_each_dev from bus_add_driver+0xd4/0x1f4 [ 1.831303][ T1] bus_add_driver from driver_register+0x88/0x120 [ 1.831312][ T1] driver_register from do_one_initcall+0x78/0x360 [ 1.831320][ T1] do_one_initcall from kernel_init_freeable+0x2bc/0x314 [ 1.831331][ T1] kernel_init_freeable from kernel_init+0x1c/0x144 [ 1.831339][ T1] kernel_init from ret_from_fork+0x14/0x20 [ 1.831344][ T1] Exception stack(0xf082dfb0 to 0xf082dff8) [ 1.831349][ T1] dfa0: 00000000 00000000 00000000 00000000 [ 1.831353][ T1] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 1.831356][ T1] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +6 -0
@@ -4075,6 +4075,12 @@ static int bcmgenet_probe(struct platform_device *pdev)for (i =0 ; i <= priv->hw_params->rx_queues; i++) priv->rx_rings[i].rx_max_coalesced_frames =1 ; +/* Initialize u64 stats seq counter for 32bit machines */ +for (i =0 ; i <= priv->hw_params->rx_queues; i++) +u64_stats_init (&priv->rx_rings[i].stats64.syncp); +for (i =0 ; i <= priv->hw_params->tx_queues; i++) +u64_stats_init (&priv->tx_rings[i].stats64.syncp); +/* libphy will determine the link state */ netif_carrier_off (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 602/666 net: bcmgenet: fix leaking free_bds
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Chen <[email protected]>
[ Upstream commit 3f3168300efb839028328d720ab3962f91d6a0d0 ]
While reclaiming the tx queue we fast forward the write pointer to drop any data in flight. These dropped frames are not added back to the pool of free bds. We also need to tell the netdev that we are dropping said data.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +2 -0
@@ -1933,6 +1933,7 @@ static unsigned int bcmgenet_tx_reclaim(struct net_device *dev, drop = (ring->prod_index - ring->c_index) &DMA_C_INDEX_MASK ; released += drop; ring->prod_index = ring->c_index &DMA_C_INDEX_MASK ; + ring->free_bds += drop;while (drop--) { cb_ptr =bcmgenet_put_txcb (priv, ring); skb = cb_ptr->skb;
@@ -1944,6 +1945,7 @@ static unsigned int bcmgenet_tx_reclaim(struct net_device *dev, }if (skb)dev_consume_skb_any (skb); +netdev_tx_reset_queue (netdev_get_tx_queue (dev, ring->index));bcmgenet_tdma_ring_writel (priv, ring->index, ring->prod_index,TDMA_PROD_INDEX ); wr_ptr = ring->write_ptr *WORDS_PER_BD (priv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 603/666 iommu/amd: Reorder attach device code
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasant Hegde <[email protected]>
[ Upstream commit 0b136493d3ffa1358783dcf5b9f866ceef2ff122 ]
Ideally in attach device path, it should take dev_data lock before making changes to device data including IOPF enablement. So far dev_data was using spinlock and it was hitting lock order issue when it tries to enable IOPF. Hence Commit 526606b0a199 ("iommu/amd: Fix Invalid wait context issue") moved IOPF enablement outside dev_data->lock.
Previous patch converted dev_data lock to mutex. Now its safe to call amd_iommu_iopf_add_device() with dev_data->mutex. Hence move back PCI device capability enablement (ATS, PRI, PASID) and IOPF enablement code inside the lock. Also in attach_device(), update 'dev_data->domain' at the end so that error handling becomes simple.
Stable-dep-of: 4a552f7890f0 ("iommu/amd: Put list_add/del(dev_data) back under the domain->lock")
--- drivers/iommu/amd/iommu.c | 65 +++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 36 deletions(-)
drivers/iommu/amd/iommu.c +29 -36
@@ -2291,6 +2291,7 @@ static int attach_device(struct device *dev, {struct iommu_dev_data *dev_data =dev_iommu_priv_get (dev);struct amd_iommu *iommu =get_amd_iommu_from_dev_data (dev_data); +struct pci_dev *pdev;int ret =0 ;mutex_lock (&dev_data->mutex);
@@ -2300,10 +2301,6 @@ static int attach_device(struct device *dev, goto out; } -/* Update data structures */ - dev_data->domain = domain; -list_add (&dev_data->list, &domain->dev_list); -/* Do reference counting */ ret =pdom_attach_iommu (iommu, domain);if (ret)
@@ -2318,6 +2315,28 @@ static int attach_device(struct device *dev, } } + pdev =dev_is_pci (dev_data->dev) ?to_pci_dev (dev_data->dev) :NULL ; +if (pdev &&pdom_is_sva_capable (domain)) { +pdev_enable_caps (pdev); + +/* +* Device can continue to function even if IOPF +* enablement failed. Hence in error path just +* disable device PRI support. +*/ +if (amd_iommu_iopf_add_device (iommu, dev_data)) +pdev_disable_cap_pri (pdev); + }else if (pdev) { +pdev_enable_cap_ats (pdev); + } + +/* Update data structures */ + dev_data->domain = domain; +list_add (&dev_data->list, &domain->dev_list); + +/* Update device table */ +dev_update_dte (dev_data, true); + out:mutex_unlock (&dev_data->mutex);
@@ -2332,7 +2351,6 @@ static void detach_device(struct device *dev)struct iommu_dev_data *dev_data =dev_iommu_priv_get (dev);struct amd_iommu *iommu =get_amd_iommu_from_dev_data (dev_data);struct protection_domain *domain = dev_data->domain; -bool ppr = dev_data->ppr;unsigned long flags;mutex_lock (&dev_data->mutex);
@@ -2346,13 +2364,15 @@ static void detach_device(struct device *dev)if (WARN_ON (!dev_data->domain)) goto out; -if (ppr) { +/* Remove IOPF handler */ +if (dev_data->ppr) {iopf_queue_flush_dev (dev); - -/* Updated here so that it gets reflected in DTE */ - dev_data->ppr = false; +amd_iommu_iopf_remove_device (iommu, dev_data); } +if (dev_is_pci (dev)) +pdev_disable_caps (to_pci_dev (dev)); +/* Clear DTE and flush the entry */ dev_update_dte (dev_data, false);
@@ -2374,14 +2394,6 @@ static void detach_device(struct device *dev) out:mutex_unlock (&dev_data->mutex); - -/* Remove IOPF handler */ -if (ppr) -amd_iommu_iopf_remove_device (iommu, dev_data); - -if (dev_is_pci (dev)) -pdev_disable_caps (to_pci_dev (dev)); - }static struct iommu_device *amd_iommu_probe_device (struct device *dev)
@@ -2670,7 +2682,6 @@ static int amd_iommu_attach_device(struct iommu_domain *dom,struct iommu_dev_data *dev_data =dev_iommu_priv_get (dev);struct protection_domain *domain =to_pdomain (dom);struct amd_iommu *iommu =get_amd_iommu_from_dev (dev); -struct pci_dev *pdev;int ret;/*
@@ -2703,24 +2714,6 @@ static int amd_iommu_attach_device(struct iommu_domain *dom, }#endif - pdev =dev_is_pci (dev_data->dev) ?to_pci_dev (dev_data->dev) :NULL ; -if (pdev &&pdom_is_sva_capable (domain)) { -pdev_enable_caps (pdev); - -/* -* Device can continue to function even if IOPF -* enablement failed. Hence in error path just -* disable device PRI support. -*/ -if (amd_iommu_iopf_add_device (iommu, dev_data)) -pdev_disable_cap_pri (pdev); - }else if (pdev) { -pdev_enable_cap_ats (pdev); - } - -/* Update device table */ -dev_update_dte (dev_data, true); -return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 568/666 ASoC: codecs: ab8500: Fix casting of private data
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
[ Upstream commit a201aef1a88b675e9eb8487e27d14e2eef3cef80 ]
ab8500_filter_controls[i].private_value is initialized using
.private_value = (unsigned long)&(struct filter_control)
{.count = xcount, .min = xmin, .max = xmax}thus it's a pointer to a struct filter_control casted to unsigned long.
So to get back that pointer .private_data must be cast back, not its address.
--- sound/soc/codecs/ab8500-codec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/ab8500-codec.c +3 -3
@@ -2496,13 +2496,13 @@ static int ab8500_codec_probe(struct snd_soc_component *component)return status; } fc = (struct filter_control *) - &ab8500_filter_controls[AB8500_FILTER_ANC_FIR ].private_value; + ab8500_filter_controls[AB8500_FILTER_ANC_FIR ].private_value; drvdata->anc_fir_values = (long *)fc->value; fc = (struct filter_control *) - &ab8500_filter_controls[AB8500_FILTER_ANC_IIR ].private_value; + ab8500_filter_controls[AB8500_FILTER_ANC_IIR ].private_value; drvdata->anc_iir_values = (long *)fc->value; fc = (struct filter_control *) - &ab8500_filter_controls[AB8500_FILTER_SID_FIR ].private_value; + ab8500_filter_controls[AB8500_FILTER_SID_FIR ].private_value; drvdata->sid_fir_values = (long *)fc->value;snd_soc_dapm_disable_pin (dapm,"ANC Configure Input" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 604/666 iommu/amd: Put list_add/del(dev_data) back under the domain->lock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit 4a552f7890f0870f6d9fd4fbc6c05cea7bfd4503 ]
The list domain->dev_list is protected by the domain->lock spinlock. Any iteration, addition or removal must be under the lock.
Move the list_del() up into the critical section. pdom_is_sva_capable(), and destroy_gcr3_table() do not interact with the list element.
Wrap the list_add() in a lock, it would make more sense if this was under the same critical section as adjusting the refcounts earlier, but that requires more complications.
--- drivers/iommu/amd/iommu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iommu/amd/iommu.c +4 -1
@@ -2292,6 +2292,7 @@ static int attach_device(struct device *dev,struct iommu_dev_data *dev_data =dev_iommu_priv_get (dev);struct amd_iommu *iommu =get_amd_iommu_from_dev_data (dev_data);struct pci_dev *pdev; +unsigned long flags;int ret =0 ;mutex_lock (&dev_data->mutex);
@@ -2332,7 +2333,9 @@ static int attach_device(struct device *dev,/* Update data structures */ dev_data->domain = domain; +spin_lock_irqsave (&domain->lock, flags);list_add (&dev_data->list, &domain->dev_list); +spin_unlock_irqrestore (&domain->lock, flags);/* Update device table */ dev_update_dte (dev_data, true);
@@ -2379,6 +2382,7 @@ static void detach_device(struct device *dev)/* Flush IOTLB and wait for the flushes to finish */ spin_lock_irqsave (&domain->lock, flags);amd_iommu_domain_flush_all (domain); +list_del (&dev_data->list);spin_unlock_irqrestore (&domain->lock, flags);/* Clear GCR3 table */
@@ -2387,7 +2391,6 @@ static void detach_device(struct device *dev)/* Update data structures */ dev_data->domain =NULL ; -list_del (&dev_data->list);/* decrease reference counters - needs to happen after the flushes */ pdom_detach_iommu (iommu, domain);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 605/666 perf tool_pmu: Fix aggregation on duration_time
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 68cb1567439fa325ba980f3b5b67f95d3953eafd ]
evsel__count_has_error() fails counters when the enabled or running time are 0. The duration_time event reads 0 when the cpu_map_idx != 0 to avoid aggregating time over CPUs. Change the enable and running time to always have a ratio of 100% so that evsel__count_has_error won't fail.
Before:
```
$ sudo /tmp/perf/perf stat --per-core -a -M UNCORE_FREQ sleep 1
Performance counter stats for 'system wide':
S0-D0-C0 1 2,615,819,485 UNC_CLOCK.SOCKET # 2.61 UNCORE_FREQ
S0-D0-C0 2 <not counted> duration_time
1.002111784 seconds time elapsed
```After:
```
$ perf stat --per-core -a -M UNCORE_FREQ sleep 1
Performance counter stats for 'system wide':
S0-D0-C0 1 758,160,296 UNC_CLOCK.SOCKET # 0.76 UNCORE_FREQ
S0-D0-C0 2 1,003,438,246 duration_time
1.002486017 seconds time elapsed
```Note: the metric reads the value a different way and isn't impacted.
--- tools/perf/util/tool_pmu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tools/perf/util/tool_pmu.c +7 -1
@@ -392,8 +392,14 @@ int evsel__read_tool(struct evsel *evsel, int cpu_map_idx, int thread) delta_start *=1000000000 / ticks_per_sec; } count->val = delta_start; - count->ena = count->run = delta_start; count->lost =0 ; +/* +* The values of enabled and running must make a ratio of 100%. The +* exact values don't matter as long as they are non-zero to avoid +* issues with evsel__count_has_error. +*/ + count->ena++; + count->run++;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 606/666 net/sched: sch_pie: annotate more data-races in pie_dump_stats()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 6d4106e8df94c0c52cf3ca6a6a0d01567fb3844e ]
My prior patch missed few READ_ONCE()/WRITE_ONCE() annotations.
--- net/sched/sch_pie.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
net/sched/sch_pie.c +6 -8
@@ -214,16 +214,14 @@ void pie_process_dequeue(struct sk_buff *skb, struct pie_params *params,* packet timestamp. */ if (!params->dq_rate_estimator) { - vars->qdelay = now -pie_get_enqueue_time (skb); +WRITE_ONCE (vars->qdelay, + backlog ? now -pie_get_enqueue_time (skb) :0 );if (vars->dq_tstamp !=DTIME_INVALID ) dtime = now - vars->dq_tstamp; vars->dq_tstamp = now; -if (backlog ==0 ) - vars->qdelay =0 ; -if (dtime ==0 )return ;
@@ -371,7 +369,7 @@ void pie_calculate_probability(struct pie_params *params, struct pie_vars *vars,if (qdelay > (PSCHED_NS2TICKS (250 *NSEC_PER_MSEC ))) delta +=MAX_PROB / (100 /2 ); - vars->prob += delta; +WRITE_ONCE (vars->prob, vars->prob + delta);if (delta >0 ) {/* prevent overflow */
@@ -396,7 +394,7 @@ void pie_calculate_probability(struct pie_params *params, struct pie_vars *vars,if (qdelay ==0 && qdelay_old ==0 && update_prob)/* Reduce drop probability to 98.4% */ - vars->prob -= vars->prob /64 ; +WRITE_ONCE (vars->prob, vars->prob - vars->prob /64 );WRITE_ONCE (vars->qdelay, qdelay); vars->backlog_old = backlog;
@@ -496,7 +494,7 @@ static int pie_dump_stats(struct Qdisc *sch, struct gnet_dump *d) {struct pie_sched_data *q =qdisc_priv (sch);struct tc_pie_xstats st = { - .prob = q->vars.prob <<BITS_PER_BYTE , + .prob =READ_ONCE (q->vars.prob) <<BITS_PER_BYTE , .delay = ((u32 )PSCHED_TICKS2NS (READ_ONCE (q->vars.qdelay))) /NSEC_PER_USEC , .packets_in =READ_ONCE (q->stats.packets_in),
@@ -507,7 +505,7 @@ static int pie_dump_stats(struct Qdisc *sch, struct gnet_dump *d) };/* avg_dq_rate is only valid if dq_rate_estimator is enabled */ - st.dq_rate_estimating = q->params.dq_rate_estimator; + st.dq_rate_estimating =READ_ONCE (q->params.dq_rate_estimator);/* unscale and return dq_rate in bytes per sec */ if (st.dq_rate_estimating)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 607/666 netpoll: Extract IPv6 address retrieval function
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 6ad7969a361cbec5822285fb39203678ff462b64 ]
Extract the IPv6 address retrieval logic from netpoll_setup() into a dedicated helper function netpoll_take_ipv6() to improve code organization and readability.
The function handles obtaining the local IPv6 address from the network device, including proper address type matching between local and remote addresses (link-local vs global), and includes appropriate error handling when IPv6 is not supported or no suitable address is available.
Stable-dep-of: 76b93a810757 ("netpoll: pass buffer size to egress_dev() to avoid MAC truncation")
--- net/core/netpoll.c | 76 +++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 32 deletions(-)
net/core/netpoll.c +44 -32
@@ -721,6 +721,47 @@ static void netpoll_wait_carrier(struct netpoll *np, struct net_device *ndev, } } +/* +* Take the IPv6 from ndev and populate local_ip structure in netpoll +*/ +static int netpoll_take_ipv6 (struct netpoll *np,struct net_device *ndev) +{ +char buf[MAC_ADDR_STR_LEN +1 ]; +int err = -EDESTADDRREQ ; +struct inet6_dev *idev; + +if (!IS_ENABLED (CONFIG_IPV6 )) { +np_err (np,"IPv6 is not supported %s, aborting\n" , +egress_dev (np, buf)); +return -EINVAL ; + } + + idev =__in6_dev_get (ndev); +if (idev) { +struct inet6_ifaddr *ifp; + +read_lock_bh (&idev->lock); +list_for_each_entry (ifp, &idev->addr_list, if_list) { +if (!!(ipv6_addr_type (&ifp->addr) &IPV6_ADDR_LINKLOCAL ) != + !!(ipv6_addr_type (&np->remote_ip.in6) &IPV6_ADDR_LINKLOCAL )) +continue ; +/* Got the IP, let's return */ + np->local_ip.in6 = ifp->addr; + err =0 ; +break ; + } +read_unlock_bh (&idev->lock); + } +if (err) { +np_err (np,"no IPv6 address for %s, aborting\n" , +egress_dev (np, buf)); +return err; + } + +np_info (np,"local IPv6 %pI6c\n" , &np->local_ip.in6); +return 0 ; +} +/* * Take the IPv4 from ndev and populate local_ip structure in netpoll */
@@ -815,41 +856,12 @@ int netpoll_setup(struct netpoll *np) err =netpoll_take_ipv4 (np, ndev);if (err) goto put; - ip_overwritten = true; }else { -#if IS_ENABLED (CONFIG_IPV6 ) -struct inet6_dev *idev; - - err = -EDESTADDRREQ ; - idev =__in6_dev_get (ndev); -if (idev) { -struct inet6_ifaddr *ifp; - -read_lock_bh (&idev->lock); -list_for_each_entry (ifp, &idev->addr_list, if_list) { -if (!!(ipv6_addr_type (&ifp->addr) &IPV6_ADDR_LINKLOCAL ) != - !!(ipv6_addr_type (&np->remote_ip.in6) &IPV6_ADDR_LINKLOCAL )) -continue ; - np->local_ip.in6 = ifp->addr; - ip_overwritten = true; - err =0 ; -break ; - } -read_unlock_bh (&idev->lock); - } -if (err) { -np_err (np,"no IPv6 address for %s, aborting\n" , -egress_dev (np, buf)); + err =netpoll_take_ipv6 (np, ndev); +if (err) goto put; - }else -np_info (np,"local IPv6 %pI6c\n" , &np->local_ip.in6); -#else -np_err (np,"IPv6 is not supported %s, aborting\n" , -egress_dev (np, buf)); - err = -EINVAL ; - goto put; -#endif } + ip_overwritten = true; } err =__netpoll_setup (np, ndev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 569/666 netfilter: skip recording stale or retransmitted INIT
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit 576a5d2bad4814c881a829576b1261b9b8159d2b ]
An INIT whose init_tag matches the peer's vtag does not provide new state information. It indicates either:
- a stale INIT (after INIT-ACK has already been seen on the same side), or
- a retransmitted INIT (after INIT has already been recorded on the same side).
In both cases, the INIT must not update ct->proto.sctp.init[] state, since it does not advance the handshake tracking and may otherwise corrupt INIT/INIT-ACK validation logic.
Allow INIT processing only when the conntrack entry is newly created (SCTP_CONNTRACK_NONE), or when the init_tag differs from the stored peer vtag.
Note it skips the check for the ct with old_state SCTP_CONNTRACK_NONE in nf_conntrack_sctp_packet(), as it is just created in sctp_new() where it set ct->proto.sctp.vtag[IP_CT_DIR_REPLY] = ih->init_tag.
--- net/netfilter/nf_conntrack_proto_sctp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_proto_sctp.c +7 -3
@@ -471,9 +471,13 @@ int nf_conntrack_sctp_packet(struct nf_conn *ct,if (!ih) goto out_unlock; -if (ct->proto.sctp.init[dir] && ct->proto.sctp.init[!dir]) - ct->proto.sctp.init[!dir] =0 ; - ct->proto.sctp.init[dir] =1 ; +/* Do not record INIT matching peer vtag (stale or retransmitted INIT). */ +if (old_state ==SCTP_CONNTRACK_NONE || + ct->proto.sctp.vtag[!dir] != ih->init_tag) { +if (ct->proto.sctp.init[dir] && ct->proto.sctp.init[!dir]) + ct->proto.sctp.init[!dir] =0 ; + ct->proto.sctp.init[dir] =1 ; + }pr_debug ("Setting vtag %x for dir %d\n" , ih->init_tag, !dir); ct->proto.sctp.vtag[!dir] = ih->init_tag;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 570/666 sctp: discard stale INIT after handshake completion
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit 8a92cb475ca90d84db769e4d4383e631ace0d6e5 ]
After an association reaches ESTABLISHED, the peer’s init_tag is already known from the handshake. Any subsequent INIT with the same init_tag is not a valid restart, but a delayed or duplicate INIT.
Drop such INIT chunks in sctp_sf_do_unexpected_init() instead of processing them as new association attempts.
--- net/sctp/sm_statefuns.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/sctp/sm_statefuns.c +6 -0
@@ -1556,6 +1556,12 @@ static enum sctp_disposition sctp_sf_do_unexpected_init(/* Tag the variable length parameters. */ chunk->param_hdr.v =skb_pull (chunk->skb,sizeof (struct sctp_inithdr )); +if (asoc->state >=SCTP_STATE_ESTABLISHED ) { +/* Discard INIT matching peer vtag after handshake completion (stale INIT). */ +if (ntohl (chunk->subh.init_hdr->init_tag) == asoc->peer.i.init_tag) +return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); + } +/* Verify the INIT chunk before processing it. */ err_chunk =NULL ; if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 571/666 bareudp: fix NULL pointer dereference in bareudp_fill_metadata_dst()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit aa6c6d9ee064aabfede4402fd1283424e649ca19 ]
bareudp_fill_metadata_dst() passes bareudp->sock to udp_tunnel6_dst_lookup() in the IPv6 path without a NULL check. The socket is only created in bareudp_open() and NULLed in bareudp_stop(), so calling this function while the device is down triggers a NULL dereference via sock->sk.
BUG: kernel NULL pointer dereference, address: 0000000000000018 RIP: 0010:udp_tunnel6_dst_lookup (net/ipv6/ip6_udp_tunnel.c:160) Call Trace: <TASK> bareudp_fill_metadata_dst (drivers/net/bareudp.c:532) do_execute_actions (net/openvswitch/actions.c:901) ovs_execute_actions (net/openvswitch/actions.c:1589) ovs_packet_cmd_execute (net/openvswitch/datapath.c:700) genl_family_rcv_msg_doit (net/netlink/genetlink.c:1114) genl_rcv_msg (net/netlink/genetlink.c:1209) netlink_rcv_skb (net/netlink/af_netlink.c:2550) </TASK>
Add a NULL check returning -ESHUTDOWN, consistent with the xmit paths in the same driver.
--- drivers/net/bareudp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/bareudp.c +3 -0
@@ -528,6 +528,9 @@ static int bareudp_fill_metadata_dst(struct net_device *dev,struct in6_addr saddr;struct socket *sock =rcu_dereference (bareudp->sock); +if (!sock) +return -ESHUTDOWN ; + dst = udp_tunnel6_dst_lookup(skb, dev, bareudp->net, sock, 0, &saddr, &info->key, sport, bareudp->port, info->key.tos,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 572/666 net/sched: sch_cake: annotate data-races in cake_dump_stats() (V)
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit a6c95b833dc17e84d16a8ac0f40fd0931616a52d ]
cake_dump_stats() runs without qdisc spinlock being held.
In this final patch, I add READ_ONCE()/WRITE_ONCE() annotations for cparams.target and cparams.interval.
--- net/sched/sch_cake.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
net/sched/sch_cake.c +7 -6
@@ -2297,10 +2297,11 @@ static void cake_set_rate(struct cake_tin_data *b, u64 rate, u32 mtu, byte_target_ns = (byte_target * rate_ns) >> rate_shft; - b->cparams.target =max ((byte_target_ns *3 ) /2 , target_ns); - b->cparams.interval =max (rtt_est_ns + - b->cparams.target - target_ns, - b->cparams.target *2 ); +WRITE_ONCE (b->cparams.target, +max ((byte_target_ns *3 ) /2 , target_ns)); +WRITE_ONCE (b->cparams.interval, +max (rtt_est_ns + b->cparams.target - target_ns, + b->cparams.target *2 )); b->cparams.mtu_time = byte_target_ns; b->cparams.p_inc =1 <<24 ;/* 1/256 */ b->cparams.p_dec =1 <<20 ;/* 1/4096 */
@@ -2930,9 +2931,9 @@ static int cake_dump_stats(struct Qdisc *sch, struct gnet_dump *d)PUT_TSTAT_U32 (BACKLOG_BYTES , b->tin_backlog);PUT_TSTAT_U32 (TARGET_US , -ktime_to_us (ns_to_ktime (b->cparams.target))); +ktime_to_us (ns_to_ktime (READ_ONCE (b->cparams.target))));PUT_TSTAT_U32 (INTERVAL_US , -ktime_to_us (ns_to_ktime (b->cparams.interval))); +ktime_to_us (ns_to_ktime (READ_ONCE (b->cparams.interval))));PUT_TSTAT_U32 (SENT_PACKETS , b->packets);PUT_TSTAT_U32 (DROPPED_PACKETS , b->tin_dropped);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 573/666 netconsole: propagate device name truncation in dev_name_store()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 92ceb7bff62c2606f664c204750eca0b85d44112 ]
dev_name_store() calls strscpy(nt->np.dev_name, buf, IFNAMSIZ) without checking the return value. If userspace writes an interface name longer than IFNAMSIZ - 1, strscpy() silently truncates and returns -E2BIG, but the function ignores it and reports a fully successful write back to userspace.
If a real interface happens to match the truncated name, netconsole will bind to the wrong device on the next enable, sending kernel logs and panic output to an unintended network segment with no indication to userspace that anything was rewritten.
Reject writes whose length cannot fit in nt->np.dev_name up front:
if (count >= IFNAMSIZ) return -ENAMETOOLONG;
This is not a big deal of a problem, but, it is still the correct approach.
--- drivers/net/netconsole.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/netconsole.c +7 -0
@@ -502,6 +502,13 @@ static ssize_t dev_name_store(struct config_item *item, const char *buf, size_t count) {struct netconsole_target *nt =to_target (item); +size_t len = count; + +/* Account for a trailing newline appended by tools like echo */ +if (len && buf[len -1 ] =='\n' ) + len--; +if (len >=IFNAMSIZ ) +return -ENAMETOOLONG ;mutex_lock (&dynamic_netconsole_mutex);if (nt->enabled) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 564/666 drm/amdgpu/jpeg: set no_user_fence for JPEG v4.0 ring
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yinjie Yao <[email protected]>
[ Upstream commit e7e90b5839aeb8805ec83bb4da610b8dab8e184d ]
JPEG rings do not support 64-bit user fence writes, reject CS submissions with user fences.
--- drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c +1 -0
@@ -724,6 +724,7 @@ static const struct amd_ip_funcs jpeg_v4_0_ip_funcs = {static const struct amdgpu_ring_funcs jpeg_v4_0_dec_ring_vm_funcs = { .type =AMDGPU_RING_TYPE_VCN_JPEG , .align_mask =0xf , + .no_user_fence = true, .get_rptr = jpeg_v4_0_dec_ring_get_rptr, .get_wptr = jpeg_v4_0_dec_ring_get_wptr, .set_wptr = jpeg_v4_0_dec_ring_set_wptr,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 609/666 page_pool: fix incorrect mp_ops error handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mina Almasry <[email protected]>
[ Upstream commit abadf0ff63be488dc502ecfc9f622929a21b7117 ]
Minor fix to the memory provider error handling, we should be jumping to free_ptr_ring in this error case rather than returning directly.
Found by code-inspection.
--- net/core/page_pool.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/core/page_pool.c +4 -2
@@ -285,8 +285,10 @@ static int page_pool_init(struct page_pool *pool, }if (pool->mp_ops) { -if (!pool->dma_map || !pool->dma_sync) -return -EOPNOTSUPP ; +if (!pool->dma_map || !pool->dma_sync) { + err = -EOPNOTSUPP ; + goto free_ptr_ring; + }if (WARN_ON (!is_kernel_rodata ((unsigned long )pool->mp_ops))) { err = -EFAULT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 618/666 audit: enforce AUDIT_LOCKED for AUDIT_TRIM and AUDIT_MAKE_EQUIV
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergio Correia <[email protected]>
commit f9e1c1324b4d98d591a6f7568fdebf5cf456dfc2 upstream.
AUDIT_ADD_RULE and AUDIT_DEL_RULE correctly check for AUDIT_LOCKED and return -EPERM, but AUDIT_TRIM and AUDIT_MAKE_EQUIV do not. This allows a process with CAP_AUDIT_CONTROL to modify directory tree watches and equivalence mappings even when the audit configuration has been locked, undermining the purpose of the lock.
Add AUDIT_LOCKED checks to both commands.
--- kernel/audit.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/audit.c +4 -0
@@ -1427,6 +1427,8 @@ static int audit_receive_msg(struct sk_b err =audit_list_rules_send (skb, seq);break ;case AUDIT_TRIM : +if (audit_enabled ==AUDIT_LOCKED ) +return -EPERM ;audit_trim_trees ();audit_log_common_recv_msg (audit_context (), &ab,AUDIT_CONFIG_CHANGE );
@@ -1439,6 +1441,8 @@ static int audit_receive_msg(struct sk_bsize_t msglen = data_len;char *old, *new; +if (audit_enabled ==AUDIT_LOCKED ) +return -EPERM ; err = -EINVAL ;if (msglen <2 *sizeof (u32))break ;
Greg Kroah-Hartman
maintainerPATCH 619/666 KVM: Reject wrapped offset in kvm_reset_dirty_gfn()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Sacks <[email protected]>
commit 577a8d3bae0531f0e5ccfac919cd8192f920a804 upstream.
kvm_reset_dirty_gfn() guards the gfn range with
if (!memslot || (offset + __fls(mask)) >= memslot->npages) return;
but offset is u64 and the addition is unchecked. The check can be silently bypassed by a u64 wrap.
The dirty ring backing those entries is MAP_SHARED at KVM_DIRTY_LOG_PAGE_OFFSET of the vcpu fd, so the VMM can rewrite the slot and offset fields of any entry between when the kernel pushes them and when KVM_RESET_DIRTY_RINGS consumes them. On reset, kvm_dirty_ring_reset() re-reads the values via READ_ONCE() and feeds them straight back into this check; only the flags handshake is treated as the handover, the slot/offset payload is taken on trust.
Crafting two entries
entry[i].offset = 0xffffffffffffffc1 entry[i+1].offset = 0
makes the coalescing loop in kvm_dirty_ring_reset() compute
delta = (s64)(0 - 0xffffffffffffffc1) = 63
which falls in [0, BITS_PER_LONG), so it folds entry[i+1] into the existing mask by setting bit 63. The trailing kvm_reset_dirty_gfn() call then sees offset = 0xffffffffffffffc1 and __fls(mask) = 63; the sum is 0 in u64 and the bounds check passes.
That offset propagates into kvm_arch_mmu_enable_log_dirty_pt_masked() unchanged. On the legacy MMU path -- kvm_memslots_have_rmaps() == true, i.e. shadow paging, any VM that has allocated shadow roots, or a write-tracked slot -- it reaches gfn_to_rmap(), which indexes slot->arch.rmap[0][] with a near-U64_MAX gfn. That is an out-of-bounds load of a kvm_rmap_head, followed by a conditional clear of PT_WRITABLE_MASK in whatever the loaded pointer points at. The path is reachable from any process holding /dev/kvm.
Range-check offset on its own first, so the addition cannot wrap. memslot->npages is bounded well below U64_MAX, so once offset < npages holds, offset + __fls(mask) (with __fls(mask) < BITS_PER_LONG) stays in range.
--- virt/kvm/dirty_ring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
virt/kvm/dirty_ring.c +2 -1
@@ -66,7 +66,8 @@ static void kvm_reset_dirty_gfn(struct k memslot =id_to_memslot (__kvm_memslots (kvm, as_id), id); -if (!memslot || (offset +__fls (mask)) >= memslot->npages) +if (!memslot || offset >= memslot->npages || + offset +__fls (mask) >= memslot->npages)return ;KVM_MMU_LOCK (kvm);
Greg Kroah-Hartman
maintainerPATCH 620/666 KVM: s390: pci: fix GAIT table indexing due to double-scaling pointer arithmetic
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
commit 16d990a15491cf76cd6eef0846e1b4100e63261a upstream.
kvm_s390_pci_aif_enable(), kvm_s390_pci_aif_disable(), and aen_host_forward() index the GAIT by manually multiplying the index with sizeof(struct zpci_gaite).
Since aift->gait is already a struct zpci_gaite pointer, this double-scales the offset, accessing element aisb*16 instead of aisb.
This causes out-of-bounds accesses when aisb >= 32 (with ZPCI_NR_DEVICES=512)
Fix by removing the erroneous sizeof multiplication.
--- arch/s390/kvm/interrupt.c | 3 +-- arch/s390/kvm/pci.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-)
arch/s390/kvm/interrupt.c +1 -2
@@ -3329,8 +3329,7 @@ static void aen_host_forward(unsigned lostruct zpci_gaite *gaite;struct kvm *kvm; - gaite = (struct zpci_gaite *)aift->gait + - (si *sizeof (struct zpci_gaite )); + gaite = aift->gait + si;if (gaite->count ==0 )return ;if (gaite->aisb !=0 )
arch/s390/kvm/pci.c +2 -4
@@ -292,8 +292,7 @@ static int kvm_s390_pci_aif_enable(struc phys_to_virt(fib->fmt0.aibv));spin_lock_irq (&aift->gait_lock); - gaite = (struct zpci_gaite *)aift->gait + (zdev->aisb * -sizeof (struct zpci_gaite )); + gaite = aift->gait + zdev->aisb;/* If assist not requested, host will get all alerts */ if (assist)
@@ -359,8 +358,7 @@ static int kvm_s390_pci_aif_disable(struif (zdev->kzdev->fib.fmt0.aibv ==0 ) goto out;spin_lock_irq (&aift->gait_lock); - gaite = (struct zpci_gaite *)aift->gait + (zdev->aisb * -sizeof (struct zpci_gaite )); + gaite = aift->gait + zdev->aisb; isc = gaite->gisc; gaite->count--;if (gaite->count ==0 ) {
Greg Kroah-Hartman
maintainerPATCH 621/666 KVM: x86: Fix Xen hypercall tracepoint argument assignment
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiang Ma <[email protected]>
commit 2b72f1674e427c56e3772c5ccf785fdda2138820 upstream.
TRACE_EVENT(kvm_xen_hypercall) stores a5 in __entry->a4 instead of __entry->a5.
That overwrites the recorded a4 argument and leaves a5 unset in the trace entry. Fix the typo so both arguments are captured correctly.
--- arch/x86/kvm/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/trace.h +1 -1
@@ -140,7 +140,7 @@ TRACE_EVENT(kvm_xen_hypercall, __entry->a2 = a2; __entry->a3 = a3; __entry->a4 = a4; - __entry->a4 = a5; + __entry->a5 = a5; ), TP_printk("cpl %d nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx a4 0x%lx a5 %lx",
Greg Kroah-Hartman
maintainerPATCH 622/666 netfilter: nf_tables: unconditionally bump set->nelems before insertion
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit def602e498a4f951da95c95b1b8ce8ae68aa733a ]
In case that the set is full, a new element gets published then removed without waiting for the RCU grace period, while RCU reader can be walking over it already.
To address this issue, add the element transaction even if set is full, but toggle the set_full flag to report -ENFILE so the abort path safely unwinds the set to its previous state.
As for element updates, decrement set->nelems to restore it.
A simpler fix is to call synchronize_rcu() in the error path. However, with a large batch adding elements to already maxed-out set, this could cause noticeable slowdown of such batches.
--- net/netfilter/nf_tables_api.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
net/netfilter/nf_tables_api.c +16 -14
@@ -6981,6 +6981,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,enum nft_registers dreg;struct nft_trans *trans;u8 update_flags; +bool set_full = false;u64 expiration;u64 timeout;int err, i;
@@ -7267,10 +7268,18 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,if (err <0 ) goto err_elem_free; +if (!(flags &NFT_SET_ELEM_CATCHALL )) { +unsigned int max =nft_set_maxsize (set), nelems; + + nelems =atomic_inc_return (&set->nelems); +if (nelems > max) + set_full = true; + } + trans =nft_trans_elem_alloc (ctx,NFT_MSG_NEWSETELEM , set);if (trans ==NULL ) { err = -ENOMEM ; - goto err_elem_free; + goto err_set_size; } ext->genmask =nft_genmask_cur (ctx->net);
@@ -7312,7 +7321,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,nft_trans_elem_priv (trans) = elem_priv;nft_trans_elem_update_flags (trans) = update_flags;nft_trans_commit_list_add_tail (ctx->net, trans); - goto err_elem_free; + goto err_set_size; } } }
@@ -7330,23 +7339,16 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, goto err_element_clash; } -if (!(flags &NFT_SET_ELEM_CATCHALL )) { -unsigned int max =nft_set_maxsize (set); - -if (!atomic_add_unless (&set->nelems,1 , max)) { - err = -ENFILE ; - goto err_set_full; - } - } -nft_trans_elem_priv (trans) = elem.priv;nft_trans_commit_list_add_tail (ctx->net, trans); -return 0 ; -err_set_full: -nft_setelem_remove (ctx->net, set, elem.priv); +return set_full ? -ENFILE :0 ; + err_element_clash:kfree (trans); +err_set_size: +if (!(flags &NFT_SET_ELEM_CATCHALL )) +atomic_dec (&set->nelems); err_elem_free:nf_tables_set_elem_destroy (ctx, set, elem.priv); err_parse_data:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 623/666 ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Pylypiv <[email protected]>
[ Upstream commit 8ebf408e7d463eee02c348a3c8277b95587b710d ]
Commit 0ea84089dbf6 ("ata: libata-scsi: avoid Non-NCQ command starvation") introduced ata_scsi_requeue_deferred_qc() to handle commands deferred during resets or NCQ failures. This deferral logic completed commands with DID_SOFT_ERROR to trigger a retry in the SCSI mid-layer.
However, DID_SOFT_ERROR is subject to scsi_cmd_retry_allowed() checks. ATA PASS-THROUGH commands sent via SG_IO ioctl have scmd->allowed set to zero. This causes the mid-layer to fail the command immediately instead of retrying, even though the command was never actually issued to the hardware.
Switch to DID_REQUEUE to ensure these commands are inserted back into the request queue regardless of retry limits.
--- drivers/ata/libata-scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/libata-scsi.c +2 -2
@@ -1705,7 +1705,7 @@ void ata_scsi_requeue_deferred_qc(struct ata_port *ap)/* * If we have a deferred qc when a reset occurs or NCQ commands fail, * do not try to be smart about what to do with this deferred command -* and simply retry it by completing it with DID_SOFT_ERROR. +* and simply requeue it by completing it with DID_REQUEUE. */ if (!qc)return ;
@@ -1714,7 +1714,7 @@ void ata_scsi_requeue_deferred_qc(struct ata_port *ap) ap->deferred_qc =NULL ;cancel_work (&ap->deferred_qc_work);ata_qc_free (qc); - scmd->result = (DID_SOFT_ERROR <<16 ); + scmd->result = (DID_REQUEUE <<16 );scsi_done (scmd); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 624/666 Bluetooth: btmtk: accept too short WMT FUNC_CTRL events
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
commit e3ac0d9f1a205f33a43fba3b79ef74d2f604c78b upstream.
MT7925 (USB ID 0e8d:e025) on fw version 20260106153314 sends WMT FUNC_CTRL events that are missing the status field.
Prior to commit 006b9943b982 ("Bluetooth: btmtk: validate WMT event SKB length before struct access") the status was read from out-of-bounds of SKB data, which usually would result to success with BTMTK_WMT_ON_UNDONE, although I don't know the intent here. The bounds check added in that commit returns with error instead, producing "Bluetooth: hci0: Failed to send wmt func ctrl (-22)" and makes the device unusable.
Fix the regression by interpreting too short packet as status BTMTK_WMT_ON_UNDONE, which makes the device work normally again.
--- drivers/bluetooth/btmtk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bluetooth/btmtk.c +2 -2
@@ -678,8 +678,8 @@ static int btmtk_usb_hci_wmt_sync(structcase BTMTK_WMT_FUNC_CTRL :if (!skb_pull_data (data->evt_skb,sizeof (wmt_evt_funcc->status))) { - err = -EINVAL ; - goto err_free_skb; + status =BTMTK_WMT_ON_UNDONE ; +break ; } wmt_evt_funcc = (struct btmtk_hci_wmt_evt_funcc *)wmt_evt;
Greg Kroah-Hartman
maintainerPATCH 625/666 smb/client: fix possible infinite loop and oob read in symlink_data()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
commit 7d9a7f1f96cd617ee9e75bb22217c709038e26b8 upstream.
On 32-bit architectures, the infinite loop is as follows:
len = p->ErrorDataLength == 0xfffffff8
u8 *next = p->ErrorContextData + len
next == p
On 32-bit architectures, the out-of-bounds read is as follows:
len = p->ErrorDataLength == 0xfffffff0
u8 *next = p->ErrorContextData + len
next == (u8 *)p - 8
--- fs/smb/client/smb2file.c | 3 +++ 1 file changed, 3 insertions(+)
fs/smb/client/smb2file.c +3 -0
@@ -49,6 +49,9 @@ static struct smb2_symlink_err_rsp *syml __func__, le32_to_cpu(p->ErrorId)); len =ALIGN (le32_to_cpu (p->ErrorDataLength),8 ); +if (len > end - ((u8 *)p +sizeof (*p))) +return ERR_PTR (-EINVAL ); + p = (struct smb2_error_context_rsp *)(p->ErrorContextData + len); } } else if (le32_to_cpu(err->ByteCount) >= sizeof(*sym) &&
Greg Kroah-Hartman
maintainerPATCH 626/666 drm/loongson: Use managed KMS polling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit 0a9c56dd387605d17dabeedd9fdd2c4c1d0bab7b upstream.
lsdc_pci_probe() initializes KMS polling before setting up vblank support, requesting the IRQ and registering the DRM device. If any of those later steps fails, probe returns without finalizing polling. The driver also never finalizes polling on regular removal.
Use drmm_kms_helper_poll_init() so polling is tied to the DRM device lifetime and automatically finalized on probe failure and device removal.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/gpu/drm/loongson/lsdc_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/loongson/lsdc_drv.c +1 -1
@@ -291,7 +291,7 @@ static int lsdc_pci_probe(struct pci_devvga_client_register (pdev, lsdc_vga_set_decode); -drm_kms_helper_poll_init (ddev); +drmm_kms_helper_poll_init (ddev);if (loongson_vblank) { ret =drm_vblank_init (ddev, descp->num_of_crtc);
Greg Kroah-Hartman
maintainerPATCH 627/666 drm/i915/dp: Fix VSC dynamic range signaling for RGB formats
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaitanya Kumar Borah <[email protected]>
commit 1ae15b6c7965d137eef21f2cc7d367b29cb88369 upstream.
For RGB, set dynamic_range to CTA or VESA based on crtc_state->limited_color_range so sinks apply correct quantization. YCbCr remains limited (CTA) range. (DP v1.4, Table 5-1)
v2:
- Added Reported-by and Tested-by tags
v3:
- Add back YCbCr comment(Suraj)
--- drivers/gpu/drm/i915/display/intel_dp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_dp.c +7 -2
@@ -2726,8 +2726,13 @@ static void intel_dp_compute_vsc_colorimdrm_WARN_ON (&dev_priv->drm, vsc->bpc ==6 && vsc->pixelformat !=DP_PIXELFORMAT_RGB ); -/* all YCbCr are always limited range */ - vsc->dynamic_range =DP_DYNAMIC_RANGE_CTA ; +/* All YCbCr formats are always limited range. */ +if (vsc->pixelformat ==DP_PIXELFORMAT_RGB ) + vsc->dynamic_range = crtc_state->limited_color_range ? +DP_DYNAMIC_RANGE_CTA :DP_DYNAMIC_RANGE_VESA ; +else + vsc->dynamic_range =DP_DYNAMIC_RANGE_CTA ; + vsc->content_type =DP_CONTENT_TYPE_NOT_DEFINED ; }
Greg Kroah-Hartman
maintainerPATCH 610/666 crypto: af_alg - Cap AEAD AD length to 0x80000000
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit e4c06479d7059888adf2f22bc1ebcf053bf691a2 upstream.
In order to prevent arithmetic overflows when checking the TX buffer size, cap the associated data length to 0x80000000.
--- crypto/af_alg.c | 2 ++ 1 file changed, 2 insertions(+)
crypto/af_alg.c +2 -0
@@ -586,6 +586,8 @@ static int af_alg_cmsg_send(struct msghdif (cmsg->cmsg_len <CMSG_LEN (sizeof (u32)))return -EINVAL ; con->aead_assoclen = *(u32 *)CMSG_DATA (cmsg); +if (con->aead_assoclen >=0x80000000u ) +return -EINVAL ;break ;default :
Greg Kroah-Hartman
maintainerPATCH 628/666 ALSA: usb-audio: Bound MIDI 2.0 endpoint descriptor scans
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit 918be519c7876329e1b6e2ea1c59f0b75e792dca upstream.
The USB MIDI 2.0 endpoint parser has the same descriptor walking pattern as the legacy MIDI parser. It validates bLength against bNumGrpTrmBlock before reading baAssoGrpTrmBlkID[], but not against the remaining bytes in the endpoint-extra scan.
A malformed device can therefore make later baAssoGrpTrmBlkID[] reads consume bytes past the walked descriptor.
Reject zero-length and overlong descriptors while walking endpoint extras.
--- sound/usb/midi2.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
sound/usb/midi2.c +7 -5
@@ -504,15 +504,17 @@ static void *find_usb_ms_endpoint_descriwhile (extralen >3 ) {struct usb_ms_endpoint_descriptor *ms_ep = (struct usb_ms_endpoint_descriptor *)extra; +int length = ms_ep->bLength; -if (ms_ep->bLength >3 && +if (!length || length > extralen) +break ; + +if (length >3 && ms_ep->bDescriptorType ==USB_DT_CS_ENDPOINT && ms_ep->bDescriptorSubtype == subtype)return ms_ep; -if (!extra[0 ]) -break ; - extralen -= extra[0 ]; - extra += extra[0 ]; + extralen -= length; + extra += length; }return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 629/666 ALSA: usb-audio: Bound MIDI endpoint descriptor scans
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit d6854daa67be623860f4e1873fd3d3c275aba4ed upstream.
snd_usbmidi_get_ms_info() validates the internal MIDIStreaming endpoint descriptor size before using baAssocJackID[], but the descriptor walker can still return a class-specific endpoint descriptor whose bLength exceeds the remaining bytes in the endpoint-extra scan.
That leaves later flexible-array reads bounded by bLength, but not by the remaining bytes in the endpoint-extra scan.
Stop walking when bLength is zero or
extends past the remaining endpoint-extra scan.
--- sound/usb/midi.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
sound/usb/midi.c +7 -5
@@ -1959,15 +1959,17 @@ static struct usb_ms_endpoint_descriptorwhile (extralen >3 ) {struct usb_ms_endpoint_descriptor *ms_ep = (struct usb_ms_endpoint_descriptor *)extra; +int length = ms_ep->bLength; -if (ms_ep->bLength >3 && +if (!length || length > extralen) +break ; + +if (length >3 && ms_ep->bDescriptorType ==USB_DT_CS_ENDPOINT && ms_ep->bDescriptorSubtype ==UAC_MS_GENERAL )return ms_ep; -if (!extra[0 ]) -break ; - extralen -= extra[0 ]; - extra += extra[0 ]; + extralen -= length; + extra += length; }return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 630/666 ceph: fix a buffer leak in __ceph_setxattr()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viacheslav Dubeyko <[email protected]>
commit 5d3cc36b4e77a27ce7b686b7c59c7072bcb3fa8e upstream.
The old_blob in __ceph_setxattr() can store ci->i_xattrs.prealloc_blob value during the retry. However, it is never called the ceph_buffer_put() for the old_blob object. This patch fixes the issue of the buffer leak.
--- fs/ceph/xattr.c | 1 + 1 file changed, 1 insertion(+)
fs/ceph/xattr.c +1 -0
@@ -1296,6 +1296,7 @@ retry: do_sync:spin_unlock (&ci->i_ceph_lock); +ceph_buffer_put (old_blob); do_sync_unlocked:if (lock_snap_rwsem)up_read (&mdsc->snap_rwsem);
Greg Kroah-Hartman
maintainerPATCH 631/666 ceph: fix BUG_ON in __ceph_build_xattrs_blob() due to stale blob size
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viacheslav Dubeyko <[email protected]>
commit 0c22d9511cbde746622f8e4c11aaa63fe76d45f9 upstream.
The generic/642 test-case can reproduce the kernel crash:
[40243.605254] ------------[ cut here ]------------ [40243.605956] kernel BUG at fs/ceph/xattr.c:918! [40243.607142] Oops: invalid opcode: 0000 [#1] SMP PTI [40243.608067] CPU: 7 UID: 0 PID: 498762 Comm: kworker/7:1 Not tainted 7.0.0-rc7+ #3 PREEMPT(full) [40243.609700] Hardware name: QEMU Ubuntu 25.10 PC v2 (i440FX + PIIX, + 10.1 machine, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [40243.611820] Workqueue: ceph-msgr ceph_con_workfn [40243.612715] RIP: 0010:__ceph_build_xattrs_blob+0x1b8/0x1e0 [40243.613731] Code: 0f 84 82 fe ff ff e9 cf 8e 56 ff 48 8d 65 e8 31 c0 5b 41 5c 41 5d 5d 31 d2 31 c9 31 f6 31 ff 45 31 c0 45 31 c9 c3 cc cc cc cc <0f> 0b 4c 8b 62 08 41 8b 85 24 07 00 00 49 83 c4 04 41 89 44 24 fc [40243.616888] RSP: 0018:ffffcc80c4d4b688 EFLAGS: 00010287 [40243.617773] RAX: 0000000000010026 RBX: 0000000000000001 RCX: 0000000000000000 [40243.618928] RDX: ffff8a773798dee0 RSI: 0000000000000000 RDI: 0000000000000000 [40243.620158] RBP: ffffcc80c4d4b6a0 R08: 0000000000000000 R09: 0000000000000000 [40243.621573] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8a75f3b58000 [40243.622907] R13: ffff8a75f3b58000 R14: 0000000000000080 R15: 000000000000bffd [40243.624054] FS: 0000000000000000(0000) GS:ffff8a787d1b4000(0000) knlGS:0000000000000000 [40243.625331] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [40243.626269] CR2: 000072f390b623c0 CR3: 000000011c02a003 CR4: 0000000000372ef0 [40243.627408] Call Trace: [40243.627839] <TASK> [40243.628188] __prep_cap+0x3fd/0x4a0 [40243.628789] ? do_raw_spin_unlock+0x4e/0xe0 [40243.629474] ceph_check_caps+0x46a/0xc80 [40243.630094] ? __lock_acquire+0x4a2/0x2650 [40243.630773] ? find_held_lock+0x31/0x90 [40243.631347] ? handle_cap_grant+0x79f/0x1060 [40243.632068] ? lock_release+0xd9/0x300 [40243.632696] ? __mutex_unlock_slowpath+0x3e/0x340 [40243.633429] ? lock_release+0xd9/0x300 [40243.634052] handle_cap_grant+0xcf6/0x1060 [40243.634745] ceph_handle_caps+0x122b/0x2110 [40243.635415] mds_dispatch+0x5bd/0x2160 [40243.636034] ? ceph_con_process_message+0x65/0x190 [40243.636828] ? lock_release+0xd9/0x300 [40243.637431] ceph_con_process_message+0x7a/0x190 [40243.638184] ? kfree+0x311/0x4f0 [40243.638749] ? kfree+0x311/0x4f0 [40243.639268] process_message+0x16/0x1a0 [40243.639915] ? sg_free_table+0x39/0x90 [40243.640572] ceph_con_v2_try_read+0xf58/0x2120 [40243.641255] ? lock_acquire+0xc8/0x300 [40243.641863] ceph_con_workfn+0x151/0x820 [40243.642493] process_one_work+0x22f/0x630 [40243.643093] ? process_one_work+0x254/0x630 [40243.643770] worker_thread+0x1e2/0x400 [40243.644332] ? __pfx_worker_thread+0x10/0x10 [40243.645020] kthread+0x109/0x140 [40243.645560] ? __pfx_kthread+0x10/0x10 [40243.646125] ret_from_fork+0x3f8/0x480 [40243.646752] ? __pfx_kthread+0x10/0x10 [40243.647316] ? __pfx_kthread+0x10/0x10 [40243.647919] ret_from_fork_asm+0x1a/0x30 [40243.648556] </TASK> [40243.648902] Modules linked in: overlay hctr2 libpolyval chacha libchacha adiantum libnh libpoly1305 essiv intel_rapl_msr intel_rapl_common intel_uncore_frequency_common skx_edac_common nfit kvm_intel kvm irqbypass joydev ghash_clmulni_intel aesni_intel rapl input_leds mac_hid psmouse vga16fb serio_raw vgastate floppy i2c_piix4 pata_acpi bochs qemu_fw_cfg i2c_smbus sch_fq_codel rbd dm_crypt msr parport_pc ppdev lp parport efi_pstore [40243.654766] ---[ end trace 0000000000000000 ]---
Commit d93231a6bc8a ("ceph: prevent a client from exceeding the MDS maximum xattr size") moved the required_blob_size computation to before the __build_xattrs() call, introducing a race.
__build_xattrs() releases and reacquires i_ceph_lock during execution. In that window, handle_cap_grant() may update i_xattrs.blob with a newer MDS-provided blob and bump i_xattrs.version. When __build_xattrs() detects that index_version < version, it destroys and rebuilds the entire xattr rb-tree from the new blob, potentially increasing count, names_size, and vals_size.
The prealloc_blob size check that follows still uses the stale required_blob_size computed before the rebuild, so it passes even when prealloc_blob is too small for the now-larger tree. After __set_xattr() adds one more xattr on top, __ceph_build_xattrs_blob() is called from the cap flush path and hits:
BUG_ON(need > ci->i_xattrs.prealloc_blob->alloc_len);
Fix this by recomputing required_blob_size after __build_xattrs() returns, using the current tree state. Also re-validate against m_max_xattr_size to fall back to the sync path if the rebuilt tree now exceeds the MDS limit.
--- fs/ceph/xattr.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
fs/ceph/xattr.c +16 -0
@@ -1256,6 +1256,22 @@ retry: ceph_vinop(inode), name, ceph_cap_string(issued));__build_xattrs (inode); +/* +* __build_xattrs() may have released and reacquired i_ceph_lock, +* during which handle_cap_grant() could have replaced i_xattrs.blob +* with a newer MDS-provided blob and bumped i_xattrs.version. If that +* caused __build_xattrs() to rebuild the rb-tree from the new blob, +* count/names_size/vals_size may now be larger than when +* required_blob_size was computed above. Recompute it here so the +* prealloc_blob size check below reflects the current tree state. +*/ + required_blob_size =__get_required_blob_size (ci, name_len, val_len); +if (required_blob_size > mdsc->mdsmap->m_max_xattr_size) { +doutc (cl,"sync (size too large): %d > %llu\n" , + required_blob_size, mdsc->mdsmap->m_max_xattr_size); + goto do_sync; + } +if (!ci->i_xattrs.prealloc_blob || required_blob_size > ci->i_xattrs.prealloc_blob->alloc_len) {struct ceph_buffer *blob;
Greg Kroah-Hartman
maintainerPATCH 632/666 io-wq: check that the predecessor is hashed in io_wq_remove_pending()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Carlini <[email protected]>
commit d6a2d7b04b5a093021a7a0e2e69e9d5237dfa8cc upstream.
io_wq_remove_pending() needs to fix up wq->hash_tail[] if the cancelled work was the tail of its hash bucket. When doing this, it checks whether the preceding entry in acct->work_list has the same hash value, but never checks that the predecessor is hashed at all. io_get_work_hash() is simply atomic_read(&work->flags) >> IO_WQ_HASH_SHIFT, and the hash bits are never set for non-hashed work, so it returns 0. Thus, when a hashed bucket-0 work is cancelled while a non-hashed work is its list predecessor, the check spuriously passes and a pointer to the non-hashed io_kiocb is stored in wq->hash_tail[0].
Because non-hashed work is dequeued via the fast path in io_get_next_work(), which never touches hash_tail[], the stale pointer is never cleared. Therefore, after the non-hashed io_kiocb completes and is freed back to req_cachep, wq->hash_tail[0] is a dangling pointer. The io_wq is per-task (tctx->io_wq) and survives ring open/close, so the dangling pointer persists for the lifetime of the task; the next hashed bucket-0 enqueue dereferences it in io_wq_insert_work() and wq_list_add_after() writes through freed memory.
Add the missing io_wq_is_hashed() check so a non-hashed predecessor never inherits a hash_tail[] slot.
--- io_uring/io-wq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
io_uring/io-wq.c +2 -1
@@ -1044,7 +1044,8 @@ static inline void io_wq_remove_pending(if (io_wq_is_hashed (work) && work == wq->hash_tail[hash]) {if (prev) prev_work = container_of(prev, struct io_wq_work, list); -if (prev_work &&io_get_work_hash (prev_work) == hash) +if (prev_work &&io_wq_is_hashed (prev_work) && +io_get_work_hash (prev_work) == hash) wq->hash_tail[hash] = prev_work;else wq->hash_tail[hash] =NULL ;
Greg Kroah-Hartman
maintainerPATCH 633/666 powerpc/warp: Fix error handling in pika_dtm_thread
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 108d7f951271cbd36ca36efc5e5d106966f5180c upstream.
pika_dtm_thread() acquires client through of_find_i2c_device_by_node() but fails to release it in error handling path. This could result in a reference count leak, preventing proper cleanup and potentially leading to resource exhaustion. Add put_device() to release the reference in the error handling path.
Found by code review.
--- arch/powerpc/platforms/44x/warp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/platforms/44x/warp.c +2 -0
@@ -293,6 +293,8 @@ static int pika_dtm_thread(void __iomemschedule_timeout (HZ ); } +put_device (&client->dev); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 634/666 netfs: fix error handling in netfs_extract_user_iter()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit 0aad5704c6b4d14007d4eab15883e8524e4310f4 upstream.
In netfs_extract_user_iter(), if iov_iter_extract_pages() failed to extract user pages, bail out on -ENOMEM, otherwise return the error code only if @npages == 0, allowing short DIO reads and writes to be issued.
This fixes mmapstress02 from LTP tests against CIFS.
--- fs/netfs/iterator.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
fs/netfs/iterator.c +10 -3
@@ -22,7 +22,7 @@* * Extract the page fragments from the given amount of the source iterator and * build up a second iterator that refers to all of those bits. This allows -* the original iterator to disposed of. +* the original iterator to be disposed of. * * @extraction_flags can have ITER_ALLOW_P2PDMA set to request peer-to-peer DMA be * allowed on the pages extracted.
@@ -67,8 +67,8 @@ ssize_t netfs_extract_user_iter(struct i ret =iov_iter_extract_pages (orig, &pages, count, max_pages - npages, extraction_flags, &offset); -if (ret <0 ) { -pr_err ("Couldn't get user pages (rc=%zd)\n" , ret); +if (unlikely (ret <=0 )) { + ret = ret ?: -EIO ;break ; }
@@ -97,6 +97,13 @@ ssize_t netfs_extract_user_iter(struct i npages += cur_npages; } +if (ret <0 && (ret == -ENOMEM || npages ==0 )) { +for (i =0 ; i < npages; i++) +unpin_user_page (bv[i].bv_page); +kvfree (bv); +return ret; + } +iov_iter_bvec (new, orig->data_source, bv, npages, orig_len - count);return npages; }
Greg Kroah-Hartman
maintainerPATCH 635/666 irqchip/riscv-imsic: Clear interrupt move state during CPU offlining
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yong-Xuan Wang <[email protected]>
commit cefafbd561402b0fe6447449364a30315b9b1570 upstream.
Affinity changes of IMSIC interrupts have to be careful to not lose an interrupt in the process. Each vector keeps track of an affinity change in progress with two pointers in struct imsic_vector.
imsic_vector::move_prev points to the previous CPU target data and imsic_vector::move_next to the designated new CPU target data.
imsic_vector::move_prev on the new CPU can only be cleared after the previous CPU has cleared imsic_vector::move_next, which ususally happens in __imsic_remote_sync().
In case of CPU hot-unplug __imsic_remote_sync() is not invoked because the CPU is already marked offline. That means imsic_vector::move_prev becomes stale until the CPU is onlined again.
The stale pointer prevents further affinity changes for the affected interrupts.
Solve this by clearing the imsic_vector::move_prev pointers in the CPU hotplug offline path.
[ tglx: Replace word salad in change log ]
--- drivers/irqchip/irq-riscv-imsic-early.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/irqchip/irq-riscv-imsic-early.c +2 -0
@@ -139,6 +139,8 @@ static int imsic_dying_cpu(unsigned int/* Cleanup IPIs */ imsic_ipi_dying_cpu (); +imsic_local_sync_all (false); +/* Mark per-CPU IMSIC state as offline */ imsic_state_offline ();
Greg Kroah-Hartman
maintainerPATCH 636/666 libceph: Fix potential out-of-bounds access in osdmap_decode()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Zimmer <[email protected]>
commit 35d0ed82d03e5ee77ea4f31f20e29562a7721649 upstream.
When decoding osd_state and osd_weight from an incoming osdmap in osdmap_decode(), both are decoded for each osd, i.e., map->max_osd times. The ceph_decode_need() check only accounts for sizeof(*map->osd_weight) once. This can potentially result in an out-of-bounds memory access if the incoming message is corrupted such that the max_osd value exceeds the actual content of the osdmap message.
This patch fixes the issue by changing the corresponding part in the ceph_decode_need() check to account for map->max_osd*sizeof(*map->osd_weight).
--- net/ceph/osdmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ceph/osdmap.c +1 -1
@@ -1703,7 +1703,7 @@ static int osdmap_decode(void **p, voidceph_decode_need (p, end,3 *sizeof (u32) + map->max_osd*(struct_v >=5 ?sizeof (u32) :sizeof (u8)) + -sizeof (*map->osd_weight), e_inval); + map->max_osd*sizeof (*map->osd_weight), e_inval);if (ceph_decode_32 (p) != map->max_osd) goto e_inval;
Greg Kroah-Hartman
maintainerPATCH 637/666 libceph: Fix potential null-ptr-deref in decode_choose_args()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Zimmer <[email protected]>
commit 28b0a2ab8c82d0bbdeb8013029c67c978ce6e4bf upstream.
A message of type CEPH_MSG_OSD_MAP contains an OSD map that itself contains a CRUSH map. When decoding this CRUSH map in crush_decode(), an array of max_buckets CRUSH buckets is decoded, where some indices may not refer to actual buckets and are therefore set to NULL. The received CRUSH map may optionally contain choose_args that get decoded in decode_choose_args(). When decoding a crush_choose_arg_map, a series of choose_args for different buckets is decoded, with the bucket_index being read from the incoming message. It is only checked that the bucket index does not exceed max_buckets, but not that it doesn't point to an index with a NULL bucket. If a (potentially corrupted) message contains a crush_choose_arg_map including such a bucket_index, a null pointer dereference may occur in the subsequent processing when attempting to access the bucket with the given index.
This patch fixes the issue by extending the affected check. Now, it is only attempted to access the bucket if it is not NULL.
--- net/ceph/osdmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ceph/osdmap.c +2 -1
@@ -390,7 +390,8 @@ static int decode_choose_args(void **p, goto fail;if (arg->ids_size && - arg->ids_size != c->buckets[bucket_index]->size) + (!c->buckets[bucket_index] || + arg->ids_size != c->buckets[bucket_index]->size)) goto e_inval; }
Greg Kroah-Hartman
maintainerPATCH 611/666 i40e: Cleanup PTP pins on probe failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Vollrath <[email protected]>
commit 678b713ece1e853f11e670a84cb887c35e1381b7 upstream.
PTP pin structs are allocated early in probe, but never cleaned up.
Fix this by calling i40e_ptp_free_pins in the error path.
To support this, i40e_ptp_free_pins is added to the header and pin_config is correctly nullified after being freed.
This has been an issue since i40e_ptp_alloc_pins was introduced.
--- drivers/net/ethernet/intel/i40e/i40e.h | 1 + drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + drivers/net/ethernet/intel/i40e/i40e_ptp.c | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e.h +1 -0
@@ -1310,6 +1310,7 @@ void i40e_ptp_restore_hw_time(struct i40void i40e_ptp_init (struct i40e_pf *pf);void i40e_ptp_stop (struct i40e_pf *pf);int i40e_ptp_alloc_pins (struct i40e_pf *pf); +void i40e_ptp_free_pins (struct i40e_pf *pf);int i40e_update_adq_vsi_queues (struct i40e_vsi *vsi,int vsi_offset);int i40e_is_vsi_uplink_mode_veb (struct i40e_vsi *vsi);int i40e_get_partition_bw_setting (struct i40e_pf *pf);
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
@@ -16226,6 +16226,7 @@ err_vsis:i40e_clear_interrupt_scheme (pf);kfree (pf->vsi); err_switch_setup: +i40e_ptp_free_pins (pf);i40e_reset_interrupt_capability (pf);timer_shutdown_sync (&pf->service_timer); err_mac_addr:
drivers/net/ethernet/intel/i40e/i40e_ptp.c +2 -1
@@ -937,12 +937,13 @@ int i40e_ptp_get_ts_config(struct i40e_p* * Release memory allocated for PTP pins. **/ -static void i40e_ptp_free_pins (struct i40e_pf *pf) +void i40e_ptp_free_pins (struct i40e_pf *pf) {if (i40e_is_ptp_pin_dev (&pf->hw)) {kfree (pf->ptp_pins);kfree (pf->ptp_caps.pin_config); pf->ptp_pins =NULL ; + pf->ptp_caps.pin_config =NULL ; } }
Greg Kroah-Hartman
maintainerPATCH 638/666 libceph: Fix potential out-of-bounds access in crush_decode()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Zimmer <[email protected]>
commit 4c79fc2d598694bda845b46229c9d48b65042970 upstream.
A message of type CEPH_MSG_OSD_MAP containing a crush map with at least one bucket has two fields holding the bucket algorithm. If the values in these two fields differ, an out-of-bounds access can occur. This is the case because the first algorithm field (alg) is used to allocate the correct amount of memory for a bucket of this type, while the second algorithm field inside the bucket (b->alg) is used in the subsequent processing.
This patch fixes the issue by adding a check that compares alg and b->alg and aborts the processing in case they differ. Furthermore, b->alg is set to 0 in this case, because the destruction of the crush map also uses this field to determine the bucket type, which can again result in an out-of-bounds access when trying to free the memory pointed to by the fields of the bucket. To correctly free the memory allocated for the bucket in such a case, the corresponding call to kfree is moved from the algorithm-specific crush_destroy_bucket functions to the generic crush_destroy_bucket().
--- net/ceph/crush/crush.c | 6 +----- net/ceph/osdmap.c | 4 ++++ 2 files changed, 5 insertions(+), 5 deletions(-)
net/ceph/crush/crush.c +1 -5
@@ -47,7 +47,6 @@ int crush_get_bucket_item_weight(const svoid crush_destroy_bucket_uniform (struct crush_bucket_uniform *b) {kfree (b->h.items); -kfree (b); }void crush_destroy_bucket_list (struct crush_bucket_list *b)
@@ -55,14 +54,12 @@ void crush_destroy_bucket_list(struct crkfree (b->item_weights);kfree (b->sum_weights);kfree (b->h.items); -kfree (b); }void crush_destroy_bucket_tree (struct crush_bucket_tree *b) {kfree (b->h.items);kfree (b->node_weights); -kfree (b); }void crush_destroy_bucket_straw (struct crush_bucket_straw *b)
@@ -70,14 +67,12 @@ void crush_destroy_bucket_straw(struct ckfree (b->straws);kfree (b->item_weights);kfree (b->h.items); -kfree (b); }void crush_destroy_bucket_straw2 (struct crush_bucket_straw2 *b) {kfree (b->item_weights);kfree (b->h.items); -kfree (b); }void crush_destroy_bucket (struct crush_bucket *b)
@@ -99,6 +94,7 @@ void crush_destroy_bucket(struct crush_bcrush_destroy_bucket_straw2 ((struct crush_bucket_straw2 *)b);break ; } +kfree (b); }/**
net/ceph/osdmap.c +4 -0
@@ -518,6 +518,10 @@ static struct crush_map *crush_decode(vo b->id =ceph_decode_32 (p); b->type =ceph_decode_16 (p); b->alg =ceph_decode_8 (p); +if (b->alg != alg) { + b->alg =0 ; + goto bad; + } b->hash =ceph_decode_8 (p); b->weight =ceph_decode_32 (p); b->size =ceph_decode_32 (p);
Greg Kroah-Hartman
maintainerPATCH 639/666 libceph: handle rbtree insertion error in decode_choose_args()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Zimmer <[email protected]>
commit d289478cfc0bcf81c7914200d6abdcb78bd04ded upstream.
A message of type CEPH_MSG_OSD_MAP contains an OSD map that itself contains a CRUSH map. The received CRUSH map may optionally contain choose_args that get decoded in decode_choose_args(). In this function, num_choose_arg_maps is read from the message, and a corresponding number of crush_choose_arg_maps gets decoded afterwards. Each crush_choose_arg_map has a choose_args_index, which serves as the key when inserting it into the choose_args rbtree of the decoded crush_map. If a (potentially corrupted) message contains two crush_choose_arg_maps with the same index, the assertion in insert_choose_arg_map() triggers a kernel BUG when trying to insert the second crush_choose_arg_map.
This patch fixes the issue by switching to the non-asserting rbtree insertion function and rejecting the message if the insertion fails.
[ idryomov: changelog ]
--- net/ceph/osdmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ceph/osdmap.c +4 -1
@@ -395,7 +395,10 @@ static int decode_choose_args(void **p, goto e_inval; } -insert_choose_arg_map (&c->choose_args, arg_map); +if (!__insert_choose_arg_map (&c->choose_args, arg_map)) { + ret = -EEXIST ; + goto fail; + } }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 640/666 iommu/vt-d: Disable DMAR for Intel Q35 IGFX
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naval Alcalá <[email protected]>
commit 2cda2e10dc8343ae01eae9e999a876b7e7d37861 upstream.
Intel Q35 integrated graphics (8086:29b2) exhibits broken DMAR behaviour similar to other G4x/GM45 devices for which DMAR is already disabled via quirks.
When DMAR is enabled, the system may hard lock up during boot or early device initialization, requiring a reset.
Add the missing PCI ID to the existing quirk list to disable DMAR for this device.
--- drivers/iommu/intel/iommu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iommu/intel/iommu.c +3 -0
@@ -4684,6 +4684,9 @@ static void quirk_iommu_igfx(struct pci_ disable_igfx_iommu =1 ; } +/* Q35 integrated gfx dmar support is totally busted. */ +DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0x29b2 , quirk_iommu_igfx); +/* G4x/GM45 integrated gfx dmar support is totally busted. */ DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0x2a40 , quirk_iommu_igfx);DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0x2e00 , quirk_iommu_igfx);
Greg Kroah-Hartman
maintainerPATCH 641/666 drm/i915: skip __i915_request_skip() for already signaled requests
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Brzezinka <[email protected]>
commit 4cfe4c0efbdcde742a47813180cc69b132d7598e upstream.
After a GPU reset the HWSP is zeroed, so previously completed requests appear incomplete. If such a request is picked up during reset_rewind() and marked guilty, i915_request_set_error_once() returns early (fence already signaled), leaving fence.error without a fatal error code. The subsequent __i915_request_skip() then hits:
``` GEM_BUG_ON(!fatal_error(rq->fence.error)) ```
Fixes a kernel BUG observed on Sandy Bridge (Gen6) during heartbeat-triggered engine resets.
``` kernel BUG at drivers/gpu/drm/i915/i915_request.c:556! RIP: __i915_request_skip+0x15e/0x1d0 [i915] ... __i915_request_reset+0x212/0xa70 [i915] reset_rewind+0xe4/0x280 [i915] intel_gt_reset+0x30d/0x5b0 [i915] heartbeat+0x516/0x530 [i915] ```
Guard __i915_request_skip() with i915_request_signaled(), if the fence is already signaled, the ring content is committed and there is nothing left to skip.
--- drivers/gpu/drm/i915/gt/intel_reset.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_reset.c +2 -1
@@ -135,7 +135,8 @@ void __i915_request_reset(struct i915_rercu_read_lock ();/* protect the GEM context */ if (guilty) {i915_request_set_error_once (rq, -EIO ); -__i915_request_skip (rq); +if (!i915_request_signaled (rq)) +__i915_request_skip (rq); banned =mark_guilty (rq); }else {i915_request_set_error_once (rq, -EAGAIN );
Greg Kroah-Hartman
maintainerPATCH 642/666 drm/panfrost: Fix wait_bo ioctl leaking positive return from dma_resv_wait_timeout()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gyeyoung Baek <[email protected]>
commit 459d75523b71c0ec254d153d8850d0b7008af396 upstream.
dma_resv_wait_timeout() returns a positive 'remaining jiffies' value on success, 0 on timeout, and -errno on failure.
panfrost_ioctl_wait_bo() returns this 'long' result from an int-typed ioctl handler, so positive values reach userspace as bogus errors. Explicitly set ret to 0 on the success path.
--- drivers/gpu/drm/panfrost/panfrost_drv.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/panfrost/panfrost_drv.c +2 -0
@@ -325,6 +325,8 @@ panfrost_ioctl_wait_bo(struct drm_device true, timeout);if (!ret) ret = timeout ? -ETIMEDOUT : -EBUSY ; +else if (ret >0 ) + ret =0 ;drm_gem_object_put (gem_obj);
Greg Kroah-Hartman
maintainerPATCH 643/666 drm/xe/dma-buf: handle empty bo and UAF races
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Auld <[email protected]>
commit 981bedbbe61364fcc3a3b87ebaf648a66cd07108 upstream.
There look to be some nasty races here when triggering the invalidate_mappings hook:
1) We do xe_bo_alloc() followed by the attach, before the actual full bo init step in xe_dma_buf_init_obj(). However the bo is visible on the attachments list after the attach. This is bad since exporter driver, say amdgpu, can at any time call back into our invalidate_mappings hook, with an empty/bogus bo, leading to potential bugs/crashes.
2) Similar to 1) but here we get a UAF, when the invalidate_mappings hook is triggered. For example, we get as far as xe_bo_init_locked() but this fails in some way. But here the bo will be freed on error, but we still have it attached from dma-buf pov, so if the invalidate_mappings is now triggered then the bo we access is gone and we trigger UAF and more bugs/crashes.
To fix this, move the attach step until after we actually have a fully set up buffer object. Note that the bo is not published to userspace until later, so not sure what the comment "Don't publish the bo until we have a valid attachment", is referring to.
We have at least two different customers reporting hitting a NULL ptr deref in evict_flags when importing something from amdgpu, followed by triggering the evict flow. Hit rate is also pretty low, which would hint at some kind of race, so something like 1) or 2) might explain this.
v2:
- Shuffle the order of the ops slightly (no functional change)
- Improve the comment to better explain the ordering (Matt B)
--- drivers/gpu/drm/xe/xe_dma_buf.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/gpu/drm/xe/xe_dma_buf.c +16 -15
@@ -278,15 +278,25 @@ struct drm_gem_object *xe_gem_prime_impo } } -/* -* Don't publish the bo until we have a valid attachment, and a -* valid attachment needs the bo address. So pre-create a bo before -* creating the attachment and publish. -*/ bo =xe_bo_alloc ();if (IS_ERR (bo))return ERR_CAST (bo); +/* +* xe_dma_buf_init_obj() takes ownership of the raw bo, so do not touch +* on fail, since it will already take care of cleanup. On success we +* still need to drop the ref, if something later fails. +* +* In addition this needs to happen before the attach, since +* it will create a new attachment for this, and add it to the list of +* attachments, at which point it is globally visible, and at any point +* the export side can call into on invalidate_mappings callback, which +* require a working object. +*/ + obj =xe_dma_buf_init_obj (dev, bo, dma_buf); +if (IS_ERR (obj)) +return obj; + attach_ops = &xe_dma_buf_attach_ops;#if IS_ENABLED (CONFIG_DRM_XE_KUNIT_TEST )if (test)
@@ -299,21 +309,12 @@ struct drm_gem_object *xe_gem_prime_impo goto out_err; } -/* -* xe_dma_buf_init_obj() takes ownership of bo on both success -* and failure, so we must not touch bo after this call. -*/ - obj =xe_dma_buf_init_obj (dev, bo, dma_buf); -if (IS_ERR (obj)) { -dma_buf_detach (dma_buf, attach); -return obj; - }get_dma_buf (dma_buf); obj->import_attach = attach;return obj; out_err: -xe_bo_free (bo); +xe_bo_put (bo);return obj; }
Greg Kroah-Hartman
maintainerPATCH 644/666 drm/gma500/oaktrail_hdmi: fix i2c adapter leak on setup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 950953f774b3f69da6f413e045ef075e1f3da2df upstream.
Make sure to drop the reference taken to the I2C adapter (and its module) when setting up HDMI to allow the adapter to be deregistered.
--- drivers/gpu/drm/gma500/oaktrail_hdmi.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/gma500/oaktrail_hdmi.c +1 -0
@@ -579,6 +579,7 @@ static int oaktrail_hdmi_get_modes(struc }else { edid = (struct edid *)raw_edid;/* FIXME ? edid = drm_get_edid(connector, i2c_adap); */ +i2c_put_adapter (i2c_adap); }if (edid) {
Greg Kroah-Hartman
maintainerPATCH 645/666 drm/gma500/oaktrail_lvds: fix hang on init failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 657a091ab6d01d0091b77660c75cfed573c9a53e upstream.
The LVDS init code looks up an I2C adapter using i2c_get_adapter() and tries to read the EDID before falling back to allocating and registering its own adapter.
The error handling does not separate these cases so on a late init failure it will try to deregister and free also an adapter that had previously been registered. Since i2c_get_adapter() takes another reference to the adapter, deregistration hangs indefinitely while waiting for the reference to be released.
Fix this by only destroying adapters allocated during LVDS init on errors.
--- drivers/gpu/drm/gma500/oaktrail_lvds.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/gma500/oaktrail_lvds.c +3 -2
@@ -292,7 +292,7 @@ void oaktrail_lvds_init(struct drm_devic {struct gma_encoder *gma_encoder;struct gma_connector *gma_connector; -struct gma_i2c_chan *ddc_bus; +struct gma_i2c_chan *ddc_bus =NULL ;struct drm_connector *connector;struct drm_encoder *encoder;struct drm_psb_private *dev_priv =to_drm_psb_private (dev);
@@ -420,7 +420,8 @@ out: err_unlock:mutex_unlock (&dev->mode_config.mutex); -gma_i2c_destroy (to_gma_i2c_chan (connector->ddc)); +if (!IS_ERR_OR_NULL (ddc_bus)) +gma_i2c_destroy (ddc_bus);drm_encoder_cleanup (encoder); err_connector_cleanup:drm_connector_cleanup (connector);
Greg Kroah-Hartman
maintainerPATCH 646/666 drm/gma500/oaktrail_lvds: fix i2c adapter leaks on init
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 84d1c9b416d54afe760ca4c378bd95c89261254c upstream.
The LVDS init code looks up an I2C adapter using i2c_get_adapter() and tries to read the EDID before falling back to allocating and registering its own adapter.
Make sure to drop the references taken by i2c_get_adapter() when falling back to allocating an adapter as well as on late errors to allow the looked up adapter to be deregistered.
--- drivers/gpu/drm/gma500/oaktrail_lvds.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/gma500/oaktrail_lvds.c +4 -0
@@ -366,6 +366,8 @@ void oaktrail_lvds_init(struct drm_devicif (edid ==NULL && dev_priv->lpc_gpio_base) { ddc_bus =oaktrail_lvds_i2c_init (dev);if (!IS_ERR (ddc_bus)) { +if (i2c_adap) +i2c_put_adapter (i2c_adap); i2c_adap = &ddc_bus->base; edid =drm_get_edid (connector, i2c_adap); }
@@ -422,6 +424,8 @@ err_unlock:mutex_unlock (&dev->mode_config.mutex);if (!IS_ERR_OR_NULL (ddc_bus))gma_i2c_destroy (ddc_bus); +else if (i2c_adap) +i2c_put_adapter (i2c_adap);drm_encoder_cleanup (encoder); err_connector_cleanup:drm_connector_cleanup (connector);
Greg Kroah-Hartman
maintainerPATCH 647/666 iommufd: Fix return value of iommufd_fault_fops_write()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenzhong Duan <[email protected]>
[ Upstream commit aaca2aa92785a6ab8e3183e7184bca447a99cd76 ]
copy_from_user() may return number of bytes failed to copy, we should not pass over this number to user space to cheat that write() succeed. Instead, -EFAULT should be returned.
--- drivers/iommu/iommufd/fault.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iommu/iommufd/fault.c +3 -2
@@ -317,9 +317,10 @@ static ssize_t iommufd_fault_fops_write(mutex_lock (&fault->mutex);while (count > done) { - rc =copy_from_user (&response, buf + done, response_size); -if (rc) +if (copy_from_user (&response, buf + done, response_size)) { + rc = -EFAULT ;break ; + }static_assert ((int )IOMMUFD_PAGE_RESP_SUCCESS == (int )IOMMU_PAGE_RESP_SUCCESS );
Greg Kroah-Hartman
maintainerPATCH 612/666 workqueue: Fix wq->cpu_pwq leak in alloc_and_link_pwqs() WQ_UNBOUND path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
commit 0143033dc22cdff912cfc13419f5db92fea3b4cb upstream.
For WQ_UNBOUND workqueues, alloc_and_link_pwqs() allocates wq->cpu_pwq via alloc_percpu() and then calls apply_workqueue_attrs_locked(). On failure it returns the error directly, bypassing the enomem: label which holds the only free_percpu(wq->cpu_pwq) in this function.
The caller's error path kfree()s wq without touching wq->cpu_pwq, leaking one percpu pointer table (nr_cpu_ids * sizeof(void *) bytes) per failed call.
If kmemleak is enabled, we can see:
unreferenced object (percpu) 0xc0fffa5b121048 (size 8):
comm "insmod", pid 776, jiffies 4294682844
backtrace (crc 0):
pcpu_alloc_noprof+0x665/0xac0
__alloc_workqueue+0x33f/0xa20
alloc_workqueue_noprof+0x60/0x100Route the error through the existing enomem: cleanup and any error before this one.
--- kernel/workqueue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/workqueue.c +3 -1
@@ -5568,7 +5568,9 @@ static int alloc_and_link_pwqs(struct wo ret =apply_workqueue_attrs_locked (wq, unbound_std_wq_attrs[highpri]); } -return ret; +if (ret) + goto enomem; +return 0 ; enomem:if (wq->cpu_pwq) {
Greg Kroah-Hartman
maintainerPATCH 648/666 eventfs: Use list_add_tail_rcu() for SRCU-protected children list
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
[ Upstream commit f67950b2887fa10df50c4317a1fe98a65bc6875b ]
Commit d2603279c7d6 ("eventfs: Use list_del_rcu() for SRCU protected list variable") converted the removal side to pair with the list_for_each_entry_srcu() walker in eventfs_iterate(). The insertion in eventfs_create_dir() was left as a plain list_add_tail(), which on weakly-ordered architectures can expose a new entry to the SRCU reader before its list pointers and fields are observable.
Use list_add_tail_rcu() so the publication pairs with the existing list_del_rcu() and list_for_each_entry_srcu().
--- fs/tracefs/event_inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/tracefs/event_inode.c +1 -1
@@ -732,7 +732,7 @@ struct eventfs_inode *eventfs_create_dirmutex_lock (&eventfs_mutex);if (!parent->is_freed) -list_add_tail (&ei->list, &parent->children); +list_add_tail_rcu (&ei->list, &parent->children);mutex_unlock (&eventfs_mutex);/* Was the parent freed? */
Greg Kroah-Hartman
maintainerPATCH 649/666 drm/v3d: Reject empty multisync extension to prevent infinite loop
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ashutosh Desai <[email protected]>
v3d_get_extensions() walks a userspace-provided singly-linked list of ioctl extensions without any bound on the chain length. A local user can craft a self-referential extension (ext->next == &ext) with zero in_sync_count and out_sync_count, which bypasses the existing duplicate- extension guard:
if (se->in_sync_count || se->out_sync_count)
return -EINVAL;The guard never fires because v3d_get_multisync_post_deps() returns immediately when count is zero, leaving both fields at zero on every iteration. The result is an infinite loop in kernel context, blocking the calling thread and pegging a CPU core indefinitely.
Fix this by rejecting a multisync extension where both in_sync_count and out_sync_count are zero in v3d_get_multisync_submit_deps(). An empty multisync carries no synchronization information and serves no useful purpose, so returning -EINVAL for such an extension is the correct defense against this attack vector.
--- drivers/gpu/drm/v3d/v3d_submit.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/v3d/v3d_submit.c +5 -0
@@ -389,6 +389,11 @@ v3d_get_multisync_submit_deps(struct drmif (multisync.pad)return -EINVAL ; +if (!multisync.in_sync_count && !multisync.out_sync_count) { +DRM_DEBUG ("Empty multisync extension\n" ); +return -EINVAL ; + } + ret =v3d_get_multisync_post_deps (file_priv, se, multisync.out_sync_count, multisync.out_syncs);if (ret)
Greg Kroah-Hartman
maintainerPATCH 650/666 btrfs: use inode already stored in local variable at btrfs_rmdir()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 9f82a4ed34d870b5719f9b95f7da4f74d3325a6f ]
There's no need to call d_inode(dentry) when calling btrfs_unlink_inode() since we have already stored that in a local inode variable. So just use the local variable to make the code less verbose.
Stable-dep-of: 999757231c49 ("btrfs: fix missing last_unlink_trans update when removing a directory")
--- fs/btrfs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/inode.c +1 -2
@@ -4801,8 +4801,7 @@ static int btrfs_rmdir(struct inode *dir goto out;/* now the directory is empty */ - ret =btrfs_unlink_inode (trans,BTRFS_I (dir),BTRFS_I (d_inode (dentry)), - &fname.disk_name); + ret =btrfs_unlink_inode (trans,BTRFS_I (dir),BTRFS_I (inode), &fname.disk_name);if (!ret)btrfs_i_size_write (BTRFS_I (inode),0 ); out:
Greg Kroah-Hartman
maintainerPATCH 651/666 btrfs: use btrfs inodes in btrfs_rmdir() to avoid so much usage of BTRFS_I()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 98060e1611177ddc842601a58258876ab435fdbf ]
Almost everywhere we want to use a btrfs inode and therefore we have a lot of calls to BTRFS_I(), making the code more verbose. Instead use btrfs inode local variables to avoid so much use of BTRFS_I().
Stable-dep-of: 999757231c49 ("btrfs: fix missing last_unlink_trans update when removing a directory")
--- fs/btrfs/inode.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
fs/btrfs/inode.c +16 -15
@@ -4743,32 +4743,33 @@ out_up_write:return ret; } -static int btrfs_rmdir (struct inode *dir,struct dentry *dentry) +static int btrfs_rmdir (struct inode *vfs_dir,struct dentry *dentry) { -struct inode *inode =d_inode (dentry); -struct btrfs_fs_info *fs_info =BTRFS_I (inode)->root->fs_info; +struct btrfs_inode *dir =BTRFS_I (vfs_dir); +struct btrfs_inode *inode =BTRFS_I (d_inode (dentry)); +struct btrfs_fs_info *fs_info = inode->root->fs_info;int ret =0 ;struct btrfs_trans_handle *trans;struct fscrypt_name fname; -if (inode->i_size >BTRFS_EMPTY_DIR_SIZE ) +if (inode->vfs_inode.i_size >BTRFS_EMPTY_DIR_SIZE )return -ENOTEMPTY ; -if (btrfs_ino (BTRFS_I (inode)) ==BTRFS_FIRST_FREE_OBJECTID ) { +if (btrfs_ino (inode) ==BTRFS_FIRST_FREE_OBJECTID ) {if (unlikely (btrfs_fs_incompat (fs_info,EXTENT_TREE_V2 ))) {btrfs_err (fs_info,"extent tree v2 doesn't support snapshot deletion yet" );return -EOPNOTSUPP ; } -return btrfs_delete_subvolume (BTRFS_I (dir), dentry); +return btrfs_delete_subvolume (dir, dentry); } - ret =fscrypt_setup_filename (dir, &dentry->d_name,1 , &fname); + ret =fscrypt_setup_filename (vfs_dir, &dentry->d_name,1 , &fname);if (ret)return ret;/* This needs to handle no-key deletions later on */ - trans =__unlink_start_trans (BTRFS_I (dir)); + trans =__unlink_start_trans (dir);if (IS_ERR (trans)) { ret =PTR_ERR (trans); goto out_notrans;
@@ -4788,22 +4789,22 @@ static int btrfs_rmdir(struct inode *dir* This is because we can't unlink other roots when replaying the dir * deletes for directory foo. */ -if (BTRFS_I (inode)->last_unlink_trans >= trans->transid) -btrfs_record_snapshot_destroy (trans,BTRFS_I (dir)); +if (inode->last_unlink_trans >= trans->transid) +btrfs_record_snapshot_destroy (trans, dir); -if (unlikely (btrfs_ino (BTRFS_I (inode)) ==BTRFS_EMPTY_SUBVOL_DIR_OBJECTID )) { - ret =btrfs_unlink_subvol (trans,BTRFS_I (dir), dentry); +if (unlikely (btrfs_ino (inode) ==BTRFS_EMPTY_SUBVOL_DIR_OBJECTID )) { + ret =btrfs_unlink_subvol (trans, dir, dentry); goto out; } - ret =btrfs_orphan_add (trans,BTRFS_I (inode)); + ret =btrfs_orphan_add (trans, inode);if (ret) goto out;/* now the directory is empty */ - ret =btrfs_unlink_inode (trans,BTRFS_I (dir),BTRFS_I (inode), &fname.disk_name); + ret =btrfs_unlink_inode (trans, dir, inode, &fname.disk_name);if (!ret) -btrfs_i_size_write (BTRFS_I (inode),0 ); +btrfs_i_size_write (inode,0 ); out:btrfs_end_transaction (trans); out_notrans:
Greg Kroah-Hartman
maintainerPATCH 652/666 btrfs: fix missing last_unlink_trans update when removing a directory
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 999757231c49376cd1a37308d2c8c4c9932571e1 ]
When removing a directory we are not updating its last_unlink_trans field, which can result in incorrect fsync behaviour in case some one fsyncs the directory after it was removed because it's holding a file descriptor on it.
Example scenario:
mkdir /mnt/dir1
mkdir /mnt/dir1/dir2
mkdir /mnt/dir3
sync -f /mnt
# Do some change to the directory and fsync it. chmod 700 /mnt/dir1
xfs_io -c fsync /mnt/dir1
# Move dir2 out of dir1 so that dir1 becomes empty. mv /mnt/dir1/dir2 /mnt/dir3/
open fd on /mnt/dir1
call rmdir(2) on path "/mnt/dir1"
fsync fd
<trigger power failure>
When attempting to mount the filesystem, the log replay will fail with an -EIO error and dmesg/syslog has the following:
[445771.626482] BTRFS info (device dm-0): first mount of filesystem 0368bbea-6c5e-44b5-b409-09abe496e650 [445771.626486] BTRFS info (device dm-0): using crc32c checksum algorithm [445771.627912] BTRFS info (device dm-0): start tree-log replay [445771.628335] page: refcount:2 mapcount:0 mapping:0000000061443ddc index:0x1d00 pfn:0x7072a5 [445771.629453] memcg:ffff89f400351b00 [445771.629892] aops:btree_aops [btrfs] ino:1 [445771.630737] flags: 0x17fffc00000402a(uptodate|lru|private|writeback|node=0|zone=2|lastcpupid=0x1ffff) [445771.632359] raw: 017fffc00000402a fffff47284d950c8 fffff472907b7c08 ffff89f458e412b8 [445771.633713] raw: 0000000000001d00 ffff89f6c51d1a90 00000002ffffffff ffff89f400351b00 [445771.635029] page dumped because: eb page dump [445771.635825] BTRFS critical (device dm-0): corrupt leaf: root=5 block=30408704 slot=10 ino=258, invalid nlink: has 2 expect no more than 1 for dir [445771.638088] BTRFS info (device dm-0): leaf 30408704 gen 10 total ptrs 17 free space 14878 owner 5 [445771.638091] BTRFS info (device dm-0): refs 4 lock_owner 0 current 3581087 [445771.638094] item 0 key (256 INODE_ITEM 0) itemoff 16123 itemsize 160 [445771.638097] inode generation 3 transid 9 size 16 nbytes 16384 [445771.638098] block group 0 mode 40755 links 1 uid 0 gid 0 [445771.638100] rdev 0 sequence 2 flags 0x0 [445771.638102] atime 1775744884.0 [445771.660056] ctime 1775744885.645502983 [445771.660058] mtime 1775744885.645502983 [445771.660060] otime 1775744884.0 [445771.660062] item 1 key (256 INODE_REF 256) itemoff 16111 itemsize 12 [445771.660064] index 0 name_len 2 [445771.660066] item 2 key (256 DIR_ITEM 1843588421) itemoff 16077 itemsize 34 [445771.660068] location key (259 1 0) type 2 [445771.660070] transid 9 data_len 0 name_len 4 [445771.660075] item 3 key (256 DIR_ITEM 2363071922) itemoff 16043 itemsize 34 [445771.660076] location key (257 1 0) type 2 [445771.660077] transid 9 data_len 0 name_len 4 [445771.660078] item 4 key (256 DIR_INDEX 2) itemoff 16009 itemsize 34 [445771.660079] location key (257 1 0) type 2 [445771.660080] transid 9 data_len 0 name_len 4 [445771.660081] item 5 key (256 DIR_INDEX 3) itemoff 15975 itemsize 34 [445771.660082] location key (259 1 0) type 2 [445771.660083] transid 9 data_len 0 name_len 4 [445771.660084] item 6 key (257 INODE_ITEM 0) itemoff 15815 itemsize 160 [445771.660086] inode generation 9 transid 9 size 8 nbytes 0 [445771.660087] block group 0 mode 40777 links 1 uid 0 gid 0 [445771.660088] rdev 0 sequence 2 flags 0x0 [445771.660089] atime 1775744885.641174097 [445771.660090] ctime 1775744885.645502983 [445771.660091] mtime 1775744885.645502983 [445771.660105] otime 1775744885.641174097 [445771.660106] item 7 key (257 INODE_REF 256) itemoff 15801 itemsize 14 [445771.660107] index 2 name_len 4 [445771.660108] item 8 key (257 DIR_ITEM 2676584006) itemoff 15767 itemsize 34 [445771.660109] location key (258 1 0) type 2 [445771.660110] transid 9 data_len 0 name_len 4 [445771.660111] item 9 key (257 DIR_INDEX 2) itemoff 15733 itemsize 34 [445771.660112] location key (258 1 0) type 2 [445771.660113] transid 9 data_len 0 name_len 4 [445771.660114] item 10 key (258 INODE_ITEM 0) itemoff 15573 itemsize 160 [445771.660115] inode generation 9 transid 10 size 0 nbytes 0 [445771.660116] block group 0 mode 40755 links 2 uid 0 gid 0 [445771.660117] rdev 0 sequence 0 flags 0x0 [445771.660118] atime 1775744885.645502983 [445771.660119] ctime 1775744885.645502983 [445771.660120] mtime 1775744885.645502983 [445771.660121] otime 1775744885.645502983 [445771.660122] item 11 key (258 INODE_REF 257) itemoff 15559 itemsize 14 [445771.660123] index 2 name_len 4 [445771.660124] item 12 key (258 INODE_REF 259) itemoff 15545 itemsize 14 [445771.660125] index 2 name_len 4 [445771.660126] item 13 key (259 INODE_ITEM 0) itemoff 15385 itemsize 160 [445771.660127] inode generation 9 transid 10 size 8 nbytes 0 [445771.660128] block group 0 mode 40755 links 1 uid 0 gid 0 [445771.660129] rdev 0 sequence 1 flags 0x0 [445771.660130] atime 1775744885.645502983 [445771.660130] ctime 1775744885.645502983 [445771.660131] mtime 1775744885.645502983 [445771.660132] otime 1775744885.645502983 [445771.660133] item 14 key (259 INODE_REF 256) itemoff 15371 itemsize 14 [445771.660134] index 3 name_len 4 [445771.660135] item 15 key (259 DIR_ITEM 2676584006) itemoff 15337 itemsize 34 [445771.660136] location key (258 1 0) type 2 [445771.660137] transid 10 data_len 0 name_len 4 [445771.660138] item 16 key (259 DIR_INDEX 2) itemoff 15303 itemsize 34 [445771.660139] location key (258 1 0) type 2 [445771.660140] transid 10 data_len 0 name_len 4 [445771.660144] BTRFS error (device dm-0): block=30408704 write time tree block corruption detected [445771.661650] ------------[ cut here ]------------ [445771.662358] WARNING: fs/btrfs/disk-io.c:326 at btree_csum_one_bio+0x217/0x230 [btrfs], CPU#8: mount/3581087 [445771.663588] Modules linked in: btrfs f2fs xfs (...) [445771.671229] CPU: 8 UID: 0 PID: 3581087 Comm: mount Tainted: G W 7.0.0-rc6-btrfs-next-230+ #2 PREEMPT(full) [445771.672575] Tainted: [W]=WARN [445771.672987] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org 04/01/2014 [445771.674460] RIP: 0010:btree_csum_one_bio+0x217/0x230 [btrfs] [445771.675222] Code: 89 44 24 (...) [445771.677364] RSP: 0018:ffffd23882247660 EFLAGS: 00010246 [445771.678029] RAX: 0000000000000000 RBX: ffff89f6c51d1a90 RCX: 0000000000000000 [445771.678975] RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff89f406020000 [445771.679983] RBP: ffff89f821204000 R08: 0000000000000000 R09: 00000000ffefffff [445771.680905] R10: ffffd23882247448 R11: 0000000000000003 R12: ffffd23882247668 [445771.681978] R13: ffff89f458e40fc0 R14: ffff89f737f4f500 R15: ffff89f737f4f500 [445771.682912] FS: 00007f0447a98840(0000) GS:ffff89fb9771d000(0000) knlGS:0000000000000000 [445771.684393] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [445771.685230] CR2: 00007f0447bf1330 CR3: 000000017cb02002 CR4: 0000000000370ef0 [445771.686273] Call Trace: [445771.686646] <TASK> [445771.686969] btrfs_submit_bbio+0x83f/0x860 [btrfs] [445771.687750] ? write_one_eb+0x28f/0x340 [btrfs] [445771.688428] btree_writepages+0x2e3/0x550 [btrfs] [445771.689180] ? kmem_cache_alloc_noprof+0x12a/0x490 [445771.689963] ? alloc_extent_state+0x19/0x120 [btrfs] [445771.690801] ? kmem_cache_free+0x135/0x380 [445771.691328] ? preempt_count_add+0x69/0xa0 [445771.691831] ? set_extent_bit+0x252/0x8e0 [btrfs] [445771.692468] ? xas_load+0x9/0xc0 [445771.692873] ? xas_find+0x14d/0x1a0 [445771.693304] do_writepages+0xc6/0x160 [445771.693756] filemap_writeback+0xb8/0xe0 [445771.694274] btrfs_write_marked_extents+0x61/0x170 [btrfs] [445771.694999] btrfs_write_and_wait_transaction+0x4e/0xc0 [btrfs] [445771.695818] btrfs_commit_transaction+0x5c8/0xd10 [btrfs] [445771.696530] ? kmem_cache_free+0x135/0x380 [445771.697120] ? release_extent_buffer+0x34/0x160 [btrfs] [445771.697786] btrfs_recover_log_trees+0x7be/0x7e0 [btrfs] [445771.698525] ? __pfx_replay_one_buffer+0x10/0x10 [btrfs] [445771.699206] open_ctree+0x11e5/0x1810 [btrfs] [445771.699776] btrfs_get_tree.cold+0xb/0x162 [btrfs] [445771.700463] ? fscontext_read+0x165/0x180 [445771.701146] ? rw_verify_area+0x50/0x180 [445771.701866] vfs_get_tree+0x25/0xd0 [445771.702491] vfs_cmd_create+0x59/0xe0 [445771.703125] __do_sys_fsconfig+0x303/0x610 [445771.703603] do_syscall_64+0xe9/0xf20 [445771.703974] entry_SYSCALL_64_after_hwframe+0x76/0x7e [445771.704700] RIP: 0033:0x7f0447cbd4aa [445771.705108] Code: 73 01 c3 (...) [445771.707263] RSP: 002b:00007ffc4e528318 EFLAGS: 00000246 ORIG_RAX: 00000000000001af [445771.708107] RAX: ffffffffffffffda RBX: 00005561585d8c20 RCX: 00007f0447cbd4aa [445771.708931] RDX: 0000000000000000 RSI: 0000000000000006 RDI: 0000000000000003 [445771.709744] RBP: 00005561585d9120 R08: 0000000000000000 R09: 0000000000000000 [445771.710674] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 [445771.711477] R13: 00007f0447e4f580 R14: 00007f0447e5126c R15: 00007f0447e36a23 [445771.712277] </TASK> [445771.712541] ---[ end trace 0000000000000000 ]--- [445771.713382] BTRFS error (device dm-0): error while writing out transaction: -5 [445771.714679] BTRFS warning (device dm-0): Skipping commit of aborted transaction. [445771.715562] BTRFS error (device dm-0 state A): Transaction aborted (error -5) [445771.716459] BTRFS: error (device dm-0 state A) in cleanup_transaction:2068: errno=-5 IO failure [445771.717936] BTRFS error (device dm-0 state EA): failed to recover log trees with error: -5 [445771.719681] BTRFS error (device dm-0 state EA): open_ctree failed: -5
The problem is that such a fsync should have result in a fallback to a transaction commit, but that did not happen because through the btrfs_rmdir() we never update the directory's last_unlink_trans field. Any inode that had a link removed must have its last_unlink_trans updated to the ID of transaction used for the operation, otherwise fsync and log replay will not work correctly.
btrfs_rmdir() calls btrfs_unlink_inode() and through that call chain we never call btrfs_record_unlink_dir() in order to update last_unlink_trans. However btrfs_unlink(), which is used for unlinking regular files, calls btrfs_record_unlink_dir() and then calls btrfs_unlink_inode(). So fix this by moving the call to btrfs_record_unlink_dir() from btrfs_unlink() to btrfs_unlink_inode().
A test case for fstests will follow soon.
--- fs/btrfs/inode.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/inode.c +2 -0
@@ -4801,6 +4801,8 @@ static int btrfs_rmdir(struct inode *vfsif (ret) goto out; +btrfs_record_unlink_dir (trans, dir, inode, false); +/* now the directory is empty */ ret =btrfs_unlink_inode (trans, dir, inode, &fname.disk_name);if (!ret)
Greg Kroah-Hartman
maintainerPATCH 613/666 netfilter: nf_conntrack_sip: get helper before allocating expectation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Xiasong <[email protected]>
commit eb6317739b1ea3ab28791e1f91b24781905fa815 upstream.
process_register_request() allocates an expectation and then checks whether a conntrack helper is available. If helper lookup fails, the function returns early and the allocated expectation is left behind.
Reorder the code to fetch and validate helper before calling nf_ct_expect_alloc(). This keeps the logic simpler and removes the leak path while preserving existing behavior.
--- net/netfilter/nf_conntrack_sip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/nf_conntrack_sip.c +4 -4
@@ -1367,6 +1367,10 @@ static int process_register_request(stru goto store_cseq; } + helper =rcu_dereference (nfct_help (ct)->helper); +if (!helper) +return NF_DROP ; + exp =nf_ct_expect_alloc (ct);if (!exp) {nf_ct_helper_log (skb, ct,"cannot alloc expectation" );
@@ -1377,10 +1381,6 @@ static int process_register_request(struif (sip_direct_signalling) saddr = &ct->tuplehash[!dir].tuple.src.u3; - helper =rcu_dereference (nfct_help (ct)->helper); -if (!helper) -return NF_DROP ; -nf_ct_expect_init (exp,SIP_EXPECT_SIGNALLING ,nf_ct_l3num (ct), saddr, &daddr, proto,NULL , &port); exp->timeout.expires = sip_timeout *HZ ;
Greg Kroah-Hartman
maintainerPATCH 614/666 audit: fix incorrect inheritable capability in CAPSET records
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergio Correia <[email protected]>
commit e4a640475e43f406fdfd56d370b1f34b0cbbc18d upstream.
__audit_log_capset() records the effective capability set into the inheritable field due to a copy-paste error. Every CAPSET audit record therefore reports cap_pi (process inheritable) with the value of cap_effective instead of cap_inheritable.
This silently corrupts audit data used for compliance and forensic
analysis: an attacker who modifies inheritable capabilities to prepare for a privilege-escalating exec would have the change masked in the audit trail.
The bug has been present since the original introduction of CAPSET audit records in 2008.
--- kernel/auditsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/auditsc.c +1 -1
@@ -2845,7 +2845,7 @@ void __audit_log_capset(const struct cre context->capset.pid =task_tgid_nr (current); context->capset.cap.effective = new->cap_effective; - context->capset.cap.inheritable = new->cap_effective; + context->capset.cap.inheritable = new->cap_inheritable; context->capset.cap.permitted = new->cap_permitted; context->capset.cap.ambient = new->cap_ambient; context->type =AUDIT_CAPSET ;
Greg Kroah-Hartman
maintainerPATCH 615/666 Revert "ACPI: CPPC: Adjust debug messages in amd_set_max_freq_ratio() to warn"
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit db5dadb562cabb6da49959b473ed0d9645b6f2da upstream.
Some older systems don't support CPPC in the firmware and this just makes noise for them when booting. Drop back to debug.
This reverts commit 21fb59ab4b9767085f4fe1edbdbe3177fbb9ec97.
--- arch/x86/kernel/acpi/cppc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/acpi/cppc.c +3 -3
@@ -86,19 +86,19 @@ static void amd_set_max_freq_ratio(void) rc =cppc_get_perf_caps (0 , &perf_caps);if (rc) { -pr_warn ("Could not retrieve perf counters (%d)\n" , rc); +pr_debug ("Could not retrieve perf counters (%d)\n" , rc);return ; } rc =amd_get_boost_ratio_numerator (0 , &numerator);if (rc) { -pr_warn ("Could not retrieve highest performance (%d)\n" , rc); +pr_debug ("Could not retrieve highest performance (%d)\n" , rc);return ; } nominal_perf = perf_caps.nominal_perf;if (!nominal_perf) { -pr_warn ("Could not retrieve nominal performance\n" ); +pr_debug ("Could not retrieve nominal performance\n" );return ; }
Greg Kroah-Hartman
maintainerPATCH 616/666 netfilter: nft_ct: fix missing expect put in obj eval
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Xiasong <[email protected]>
commit 19f94b6fee75b3ef7fbc06f3745b9a771a8a19a4 upstream.
nft_ct_expect_obj_eval() allocates an expectation and may call nf_ct_expect_related(), but never drops its local reference.
Add nf_ct_expect_put(exp) before return to balance allocation.
--- net/netfilter/nft_ct.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nft_ct.c +2 -0
@@ -1363,6 +1363,8 @@ static void nft_ct_expect_obj_eval(strucif (nf_ct_expect_related (exp,0 ) !=0 ) regs->verdict.code =NF_DROP ; + +nf_ct_expect_put (exp); }static const struct nla_policy nft_ct_expect_policy[NFTA_CT_EXPECT_MAX +1 ] = {
Greg Kroah-Hartman
maintainerPATCH 617/666 net: atlantic: preserve PCI wake-from-D3 on shutdown when WOL enabled
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zoran Ilievski <[email protected]>
commit 2c308cf34284420963607d677d576a2b4124d8bd upstream.
The shutdown handler aq_pci_shutdown() unconditionally calls pci_wake_from_d3(pdev, false), clearing the PCI PME_En bit even when wake-on-LAN has been configured. While aq_nic_shutdown() correctly programs the NIC firmware via aq_nic_set_power() to listen for magic packets, the PCI subsystem will not propagate the resulting PME wake event from D3, so the system never wakes after poweroff.
WOL from suspend (S3) is unaffected because aq_suspend_common() does not touch pci_wake_from_d3() and relies on the PM core's wake configuration via device_may_wakeup().
This affects all atlantic-supported NICs (AQC107/108/111/112/113); users have reported that WOL works if the atlantic driver is never loaded, but breaks once it has run its shutdown path.
Pass the configured WOL state to pci_wake_from_d3() instead of a literal false, so the PCI PME_En bit is preserved when the user has armed WOL via ethtool.
--- drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +1 -1
@@ -371,7 +371,7 @@ static void aq_pci_shutdown(struct pci_dpci_disable_device (pdev);if (system_state ==SYSTEM_POWER_OFF ) { -pci_wake_from_d3 (pdev, false); +pci_wake_from_d3 (pdev, self->aq_hw->aq_nic_cfg->wol);pci_set_power_state (pdev, PCI_D3hot); } }
Greg Kroah-Hartman
maintainerPATCH 608/666 netpoll: pass buffer size to egress_dev() to avoid MAC truncation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 76b93a8107574006b25495664304ea9237494d70 ]
egress_dev() formats np->dev_mac via snprintf() but receives buf as a bare char *, so it cannot derive the buffer size from the pointer. The size argument was hardcoded to MAC_ADDR_STR_LEN (3 * ETH_ALEN - 1 = 17), which is silly wrong in two ways:
1) misleading kernel log output on the MAC-selected target path (np->dev_name[0] == '\0'); for example "aa:bb:cc:dd:ee:ff doesn't exist, aborting" was logged as "aa:bb:cc:dd:ee:f doesn't exist, aborting".
2) the second argument of snprintf is the size of the buffer, not the size of what you want to write.
Add a bufsz parameter to egress_dev() and pass sizeof(buf) from each caller, matching the standard snprintf() idiom and removing the hardcoded size from the helper.
Every caller already declares "char buf[MAC_ADDR_STR_LEN + 1]" so the formatted MAC continues to fit.
Tested by booting with
netconsole=6665@/aa:bb:cc:dd:ee:ff,[email protected]/00:11:22:33:44:55
on a kernel without a matching device. Pre-fix dmesg shows "aa:bb:cc:dd:ee:f doesn't exist, aborting"; post-fix shows the full "aa:bb:cc:dd:ee:ff doesn't exist, aborting".
--- net/core/netpoll.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
net/core/netpoll.c +13 -10
@@ -695,14 +695,16 @@ EXPORT_SYMBOL_GPL(__netpoll_setup);/* * Returns a pointer to a string representation of the identifier used * to select the egress interface for the given netpoll instance. buf -* must be a buffer of length at least MAC_ADDR_STR_LEN + 1. +* is used to format np->dev_mac when np->dev_name is empty; bufsz must +* be at least MAC_ADDR_STR_LEN + 1 to fit the formatted MAC address +* and its NUL terminator. */ -static char *egress_dev (struct netpoll *np,char *buf) +static char *egress_dev (struct netpoll *np,char *buf,size_t bufsz) {if (np->dev_name[0 ])return np->dev_name; -snprintf (buf,MAC_ADDR_STR_LEN ,"%pM" , np->dev_mac); +snprintf (buf, bufsz,"%pM" , np->dev_mac);return buf; }
@@ -732,7 +734,7 @@ static int netpoll_take_ipv6(struct netpoll *np, struct net_device *ndev)if (!IS_ENABLED (CONFIG_IPV6 )) {np_err (np,"IPv6 is not supported %s, aborting\n" , -egress_dev (np, buf)); +egress_dev (np, buf,sizeof (buf)));return -EINVAL ; }
@@ -754,7 +756,7 @@ static int netpoll_take_ipv6(struct netpoll *np, struct net_device *ndev) }if (err) {np_err (np,"no IPv6 address for %s, aborting\n" , -egress_dev (np, buf)); +egress_dev (np, buf,sizeof (buf)));return err; }
@@ -774,14 +776,14 @@ static int netpoll_take_ipv4(struct netpoll *np, struct net_device *ndev) in_dev =__in_dev_get_rtnl (ndev);if (!in_dev) {np_err (np,"no IP address for %s, aborting\n" , -egress_dev (np, buf)); +egress_dev (np, buf,sizeof (buf)));return -EDESTADDRREQ ; } ifa =rtnl_dereference (in_dev->ifa_list);if (!ifa) {np_err (np,"no IP address for %s, aborting\n" , -egress_dev (np, buf)); +egress_dev (np, buf,sizeof (buf)));return -EDESTADDRREQ ; }
@@ -823,7 +825,8 @@ int netpoll_setup(struct netpoll *np) ndev =dev_getbyhwaddr (net,ARPHRD_ETHER , np->dev_mac);if (!ndev) { -np_err (np,"%s doesn't exist, aborting\n" ,egress_dev (np, buf)); +np_err (np,"%s doesn't exist, aborting\n" , +egress_dev (np, buf,sizeof (buf))); err = -ENODEV ; goto unlock; }
@@ -831,14 +834,14 @@ int netpoll_setup(struct netpoll *np)if (netdev_master_upper_dev_get (ndev)) {np_err (np,"%s is a slave device, aborting\n" , -egress_dev (np, buf)); +egress_dev (np, buf,sizeof (buf))); err = -EBUSY ; goto put; }if (!netif_running (ndev)) {np_info (np,"device %s not up yet, forcing it\n" , -egress_dev (np, buf)); +egress_dev (np, buf,sizeof (buf))); err =dev_open (ndev,NULL );if (err) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 654/666 btrfs: do not mark inode incompressible after inline attempt fails
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 2e0e3716c7b6f8d71df2fbe709b922e54700f71b ]
[BUG]
The following sequence will set the file with nocompress flag:
# mkfs.btrfs -f $dev # mount $dev $mnt -o max_inline=4,compress # xfs_io -f -c "pwrite 0 2k" -c sync $mnt/foobar
The inode will have NOCOMPRESS flag, even if the content itself (all 0xcd) can still be compressed very well:
item 4 key (257 INODE_ITEM 0) itemoff 15879 itemsize 160 generation 9 transid 10 size 2097152 nbytes 1052672 block group 0 mode 100600 links 1 uid 0 gid 0 rdev 0 sequence 257 flags 0x8(NOCOMPRESS)
Please note that, this behavior is there even before commit 59615e2c1f63 ("btrfs: reject single block sized compression early").
[CAUSE]
At compress_file_range(), after btrfs_compress_folios() call, we try making an inlined extent by calling cow_file_range_inline().
But cow_file_range_inline() calls can_cow_file_range_inline() which has more accurate checks on if the range can be inlined.
One of the user configurable conditions is the "max_inline=" mount option. If that value is set low (like the example, 4 bytes, which cannot store any header), or the compressed content is just slightly larger than 2K (the default value, meaning a 50% compression ratio), cow_file_range_inline() will return 1 immediately.
And since we're here only to try inline the compressed data, the range is no larger than a single fs block.
Thus compression is never going to make it a win, we fall back to marking the inode incompressible unavoidably.
[FIX]
Just add an extra check after inline attempt, so that if the inline attempt failed, do not set the nocompress flag.
As there is no way to remove that flag, and the default 50% compression ratio is way too strict for the whole inode.
--- fs/btrfs/inode.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/btrfs/inode.c +6 -0
@@ -1085,6 +1085,12 @@ again:mapping_set_error (mapping, -EIO ); goto free_pages; } +/* +* If a single block at file offset 0 cannot be inlined, fall back to +* regular writes without marking the file incompressible. +*/ +if (start ==0 && end <= blocksize) + goto cleanup_and_bail_uncompressed;/* * We aren't doing an inline extent. Round the compressed size up to a
Greg Kroah-Hartman
maintainerPATCH 663/666 spi: sifive: fix controller deregistration
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 0f25236694a2854627c1597465a071e6bb6fe572 ]
Make sure to deregister the controller before disabling underlying resources like interrupts during driver unbind.
Note that clocks were also disabled before the recent commit 140039c23aca ("spi: sifive: Simplify clock handling with devm_clk_get_enabled()").
--- drivers/spi/spi-sifive.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/spi/spi-sifive.c +7 -1
@@ -393,7 +393,7 @@ static int sifive_spi_probe(struct platfdev_info (&pdev->dev,"mapped; irq=%d, cs=%d\n" , irq, host->num_chipselect); - ret =devm_spi_register_controller (&pdev->dev, host); + ret =spi_register_controller (host);if (ret <0 ) {dev_err (&pdev->dev,"spi_register_host failed\n" ); goto put_host;
@@ -412,8 +412,14 @@ static void sifive_spi_remove(struct plastruct spi_controller *host =platform_get_drvdata (pdev);struct sifive_spi *spi =spi_controller_get_devdata (host); +spi_controller_get (host); + +spi_unregister_controller (host); +/* Disable all the interrupts just in case */ sifive_spi_write (spi,SIFIVE_SPI_REG_IE ,0 ); + +spi_controller_put (host); }static int sifive_spi_suspend (struct device *dev)
Greg Kroah-Hartman
maintainerPATCH 664/666 mptcp: pm: kernel: correctly retransmit ADD_ADDR ID 0
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Matthieu Baerts (NGI0)" <[email protected]>
[ Upstream commit b12014d2d36eaed4e4bec5f1ac7e91110eeb100d ]
When adding the ADD_ADDR to the list, the address including the IP, port and ID are copied. On the other hand, when the endpoint corresponds to the one from the initial subflow, the ID is set to 0, as specified by the MPTCP protocol.
The issue is that the ID was reset after having copied the ID in the ADD_ADDR entry. So the retransmission was done, but using a different ID than the initial one.
--- net/mptcp/pm_netlink.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
net/mptcp/pm_netlink.c +8 -5
@@ -590,6 +590,8 @@ static void mptcp_pm_create_subflow_or_s/* check first for announce */ if (msk->pm.add_addr_signaled < add_addr_signal_max) { +u8 endp_id; +/* due to racing events on both ends we can reach here while * previous add address is still running: if we invoke now * mptcp_pm_announce_addr(), that will fail and the
@@ -603,19 +605,20 @@ static void mptcp_pm_create_subflow_or_sif (!select_signal_address (pernet, msk, &local)) goto subflow; +/* Special case for ID0: set the correct ID */ + endp_id = local.addr.id; +if (endp_id == msk->mpc_endpoint_id) + local.addr.id =0 ; +/* If the alloc fails, we are on memory pressure, not worth * continuing, and trying to create subflows. */ if (!mptcp_pm_alloc_anno_list (msk, &local.addr))return ; -__clear_bit (local.addr.id, msk->pm.id_avail_bitmap); +__clear_bit (endp_id, msk->pm.id_avail_bitmap); msk->pm.add_addr_signaled++; -/* Special case for ID0: set the correct ID */ -if (local.addr.id == msk->mpc_endpoint_id) - local.addr.id =0 ; -mptcp_pm_announce_addr (msk, &local.addr, false);mptcp_pm_nl_addr_send_ack (msk);
Greg Kroah-Hartman
maintainerPATCH 665/666 mptcp: pm: ADD_ADDR rtx: fix potential data-race
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Matthieu Baerts (NGI0)" <[email protected]>
[ Upstream commit 5cd6e0ad79d2615264f63929f8b457ad97ae550d ]
This mptcp_pm_add_timer() helper is executed as a timer callback in softirq context. To avoid any data races, the socket lock needs to be held with bh_lock_sock().
If the socket is in use, retry again soon after, similar to what is done with the keepalive timer.
--- net/mptcp/pm_netlink.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/mptcp/pm_netlink.c +8 -0
@@ -307,6 +307,13 @@ static void mptcp_pm_add_timer(struct tiif (!entry->addr.id)return ; +bh_lock_sock (sk); +if (sock_owned_by_user (sk)) { +/* Try again later. */ +sk_reset_timer (sk, timer, jiffies +HZ /20 ); + goto out; + } +if (mptcp_pm_should_add_signal_addr (msk)) {sk_reset_timer (sk, timer, jiffies +TCP_RTO_MAX /8 ); goto out;
@@ -335,6 +342,7 @@ static void mptcp_pm_add_timer(struct timptcp_pm_subflow_established (msk); out: +bh_unlock_sock (sk);__sock_put (sk); }
Greg Kroah-Hartman
maintainerPATCH 666/666 mptcp: pm: ADD_ADDR rtx: resched blocked ADD_ADDR quicker
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Matthieu Baerts (NGI0)" <[email protected]>
[ Upstream commit 3cf12492891c4b5ff54dda404a2de4ec54c9e1b5 ]
When an ADD_ADDR needs to be retransmitted and another one has already been prepared -- e.g. multiple ADD_ADDRs have been sent in a row and need to be retransmitted later -- this additional retransmission will need to wait.
In this case, the timer was reset to TCP_RTO_MAX / 8, which is ~15 seconds. This delay is unnecessary long: it should just be rescheduled at the next opportunity, e.g. after the retransmission timeout.
Without this modification, some issues can be seen from time to time in the selftests when multiple ADD_ADDRs are sent, and the host takes time to process them, e.g. the "signal addresses, ADD_ADDR timeout" MPTCP Join selftest, especially with a debug kernel config.
Note that on older kernels, 'timeout' is not available. It should be enough to replace it by one second (HZ).
--- net/mptcp/pm_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/pm_netlink.c +1 -1
@@ -315,7 +315,7 @@ static void mptcp_pm_add_timer(struct ti }if (mptcp_pm_should_add_signal_addr (msk)) { -sk_reset_timer (sk, timer, jiffies +TCP_RTO_MAX /8 ); +sk_reset_timer (sk, timer, jiffies +HZ ); goto out; }
Greg Kroah-Hartman
maintainerPATCH 655/666 RDMA/mana: Remove user triggerable WARN_ON() in mana_ib_create_qp_rss()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit 159f2efabc89d3f931d38f2d35876535d4abf0a3 ]
Sashiko points out that the user can specify WQs sharing the same CQ as a part of the uAPI and this will trigger the WARN_ON() then go on to corrupt the kernel.
Just reject it outright and fail the QP creation.
--- drivers/infiniband/hw/mana/cq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mana/cq.c +3 -2
@@ -120,8 +120,9 @@ int mana_ib_install_cq_cb(struct mana_ibif (cq->queue.id >= gc->max_num_cqs)return -EINVAL ; -/* Create CQ table entry */ -WARN_ON (gc->cq_table[cq->queue.id]); +/* Create CQ table entry, sharing a CQ between WQs is not supported */ +if (gc->cq_table[cq->queue.id]) +return -EINVAL ; gdma_cq =kzalloc (sizeof (*gdma_cq),GFP_KERNEL );if (!gdma_cq)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 656/666 sched_ext: Guard scx_dsq_move() against NULL kit->dsq after failed iter_new
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
[ Upstream commit 4fda9f0e7c950da4fe03cedeb2ac818edf5d03e9 ]
bpf_iter_scx_dsq_new() clears kit->dsq on failure and bpf_iter_scx_dsq_{next,destroy}() guard against that. scx_dsq_move() doesn't - it dereferences kit->dsq immediately, so a BPF program that calls scx_bpf_dsq_move[_vtime]() after a failed iter_new oopses the kernel.
Return false if kit->dsq is NULL.
--- kernel/sched/ext.c | 8 ++++++++ 1 file changed, 8 insertions(+)
kernel/sched/ext.c +8 -0
@@ -6346,6 +6346,14 @@ static bool scx_dispatch_from_dsq(structbool in_balance;unsigned long flags; +/* +* The verifier considers an iterator slot initialized on any +* KF_ITER_NEW return, so a BPF program may legally reach here after +* bpf_iter_scx_dsq_new() failed and left @kit->dsq NULL. +*/ +if (unlikely (!src_dsq)) +return false; +if (!scx_kf_allowed_if_unlocked () && !scx_kf_allowed (SCX_KF_DISPATCH ))return false;
Greg Kroah-Hartman
maintainerPATCH 657/666 mptcp: pm: prio: skip closed subflows
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Matthieu Baerts (NGI0)" <[email protected]>
[ Upstream commit 166b78344031bf7ac9f55cb5282776cfd85f220e ]
When sending an MP_PRIO, closed subflows need to be skipped.
This fixes the case where the initial subflow got closed, re-opened later, then an MP_PRIO is needed for the same local address.
Note that explicit MP_PRIO cannot be sent during the 3WHS, so it is fine to use __mptcp_subflow_active().
--- net/mptcp/pm_netlink.c | 3 +++ 1 file changed, 3 insertions(+)
net/mptcp/pm_netlink.c +3 -0
@@ -920,6 +920,9 @@ int mptcp_pm_nl_mp_prio_send_ack(structstruct sock *ssk =mptcp_subflow_tcp_sock (subflow);struct mptcp_addr_info local, remote; +if (!__mptcp_subflow_active (subflow)) +continue ; +mptcp_local_address ((struct sock_common *)ssk, &local);if (!mptcp_addresses_equal (&local, addr, addr->port))continue ;
Greg Kroah-Hartman
maintainerPATCH 658/666 mptcp: drop __mptcp_fastopen_gen_msk_ackseq()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit f03afb3aeb9d81f6c5ab728a61a040012923e3b3 ]
When we will move the whole RX path under the msk socket lock, updating the already queued skb for passive fastopen socket at 3rd ack time will be extremely painful and race prone
The map_seq for already enqueued skbs is used only to allow correct coalescing with later data; preventing collapsing to the first skb of a fastopen connect we can completely remove the __mptcp_fastopen_gen_msk_ackseq() helper.
Before dropping this helper, a new item had to be added to the mptcp_skb_cb structure. Because this item will be frequently tested in the fast path -- almost on every packet -- and because there is free space there, a single byte is used instead of a bitfield. This micro optimisation slightly reduces the number of CPU operations to do the associated check.
Stable-dep-of: 6254a16d6f0c ("mptcp: fix rx timestamp corruption on fastopen")
--- net/mptcp/fastopen.c | 24 ++---------------------- net/mptcp/protocol.c | 4 +++- net/mptcp/protocol.h | 5 ++--- net/mptcp/subflow.c | 3 --- 4 files changed, 7 insertions(+), 29 deletions(-)
net/mptcp/fastopen.c +2 -22
@@ -40,13 +40,12 @@ void mptcp_fastopen_subflow_synack_set_p tp->copied_seq += skb->len; subflow->ssn_offset += skb->len; -/* initialize a dummy sequence number, we will update it at MPC -* completion, if needed -*/ +/* Only the sequence delta is relevant */ MPTCP_SKB_CB (skb)->map_seq = -skb->len;MPTCP_SKB_CB (skb)->end_seq =0 ;MPTCP_SKB_CB (skb)->offset =0 ;MPTCP_SKB_CB (skb)->has_rxtstamp =TCP_SKB_CB (skb)->has_rxtstamp; +MPTCP_SKB_CB (skb)->cant_coalesce =1 ;mptcp_data_lock (sk);
@@ -58,22 +57,3 @@ void mptcp_fastopen_subflow_synack_set_pmptcp_data_unlock (sk); } - -void __mptcp_fastopen_gen_msk_ackseq (struct mptcp_sock *msk,struct mptcp_subflow_context *subflow, -const struct mptcp_options_received *mp_opt) -{ -struct sock *sk = (struct sock *)msk; -struct sk_buff *skb; - - skb =skb_peek_tail (&sk->sk_receive_queue); -if (skb) { -WARN_ON_ONCE (MPTCP_SKB_CB (skb)->end_seq); -pr_debug ("msk %p moving seq %llx -> %llx end_seq %llx -> %llx\n" , sk, -MPTCP_SKB_CB (skb)->map_seq,MPTCP_SKB_CB (skb)->map_seq + msk->ack_seq, -MPTCP_SKB_CB (skb)->end_seq,MPTCP_SKB_CB (skb)->end_seq + msk->ack_seq); -MPTCP_SKB_CB (skb)->map_seq += msk->ack_seq; -MPTCP_SKB_CB (skb)->end_seq += msk->ack_seq; - } - -pr_debug ("msk=%p ack_seq=%llx\n" , msk, msk->ack_seq); -}
net/mptcp/protocol.c +3 -1
@@ -137,7 +137,8 @@ static bool mptcp_try_coalesce(struct sobool fragstolen;int delta; -if (MPTCP_SKB_CB (from)->offset || +if (unlikely (MPTCP_SKB_CB (to)->cant_coalesce) || +MPTCP_SKB_CB (from)->offset || ((to->len + from->len) > (sk->sk_rcvbuf >>3 )) || !skb_try_coalesce (to, from, &fragstolen, &delta))return false;
@@ -368,6 +369,7 @@ static bool __mptcp_move_skb(struct mptcMPTCP_SKB_CB (skb)->end_seq =MPTCP_SKB_CB (skb)->map_seq + copy_len;MPTCP_SKB_CB (skb)->offset = offset;MPTCP_SKB_CB (skb)->has_rxtstamp = has_rxtstamp; +MPTCP_SKB_CB (skb)->cant_coalesce =0 ;if (MPTCP_SKB_CB (skb)->map_seq == msk->ack_seq) {/* in sequence */
net/mptcp/protocol.h +2 -3
@@ -129,7 +129,8 @@ struct mptcp_skb_cb {u64 map_seq;u64 end_seq;u32 offset; - u8 has_rxtstamp:1; +u8 has_rxtstamp; +u8 cant_coalesce; };#define MPTCP_SKB_CB (__skb) ((struct mptcp_skb_cb *)&((__skb)->cb[0]))
@@ -1069,8 +1070,6 @@ void mptcp_event_pm_listener(const struc enum mptcp_event_type event);bool mptcp_userspace_pm_active (const struct mptcp_sock *msk); -void __mptcp_fastopen_gen_msk_ackseq (struct mptcp_sock *msk,struct mptcp_subflow_context *subflow, -const struct mptcp_options_received *mp_opt);void mptcp_fastopen_subflow_synack_set_params (struct mptcp_subflow_context *subflow,struct request_sock *req); int mptcp_nl_fill_addr(struct sk_buff *skb,
net/mptcp/subflow.c +0 -3
@@ -802,9 +802,6 @@ void __mptcp_subflow_fully_established(ssubflow_set_remote_key (msk, subflow, mp_opt);WRITE_ONCE (subflow->fully_established, true);WRITE_ONCE (msk->fully_established, true); - -if (subflow->is_mptfo) -__mptcp_fastopen_gen_msk_ackseq (msk, subflow, mp_opt); } static struct sock *subflow_syn_recv_sock(const struct sock *sk,
Greg Kroah-Hartman
maintainerPATCH 659/666 mptcp: fix rx timestamp corruption on fastopen
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 6254a16d6f0c672e3809ca5d7c9a28a55d71f764 ]
The skb cb offset containing the timestamp presence flag is cleared before loading such information. Cache such value before MPTCP CB initialization.
--- net/mptcp/fastopen.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/mptcp/fastopen.c +3 -1
@@ -12,6 +12,7 @@ void mptcp_fastopen_subflow_synack_set_pstruct sock *sk, *ssk;struct sk_buff *skb;struct tcp_sock *tp; +bool has_rxtstamp;/* on early fallback the subflow context is deleted by * subflow_syn_recv_sock()
@@ -39,12 +40,13 @@ void mptcp_fastopen_subflow_synack_set_p*/ tp->copied_seq += skb->len; subflow->ssn_offset += skb->len; + has_rxtstamp =TCP_SKB_CB (skb)->has_rxtstamp;/* Only the sequence delta is relevant */ MPTCP_SKB_CB (skb)->map_seq = -skb->len;MPTCP_SKB_CB (skb)->end_seq =0 ;MPTCP_SKB_CB (skb)->offset =0 ; -MPTCP_SKB_CB (skb)->has_rxtstamp =TCP_SKB_CB (skb)->has_rxtstamp; +MPTCP_SKB_CB (skb)->has_rxtstamp = has_rxtstamp;MPTCP_SKB_CB (skb)->cant_coalesce =1 ;mptcp_data_lock (sk);
Greg Kroah-Hartman
maintainerPATCH 660/666 f2fs: fix incorrect file address mapping when inline inode is unwritten
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongpeng Yang <[email protected]>
[ Upstream commit 68a0178981a0f493295afa29f8880246e561494c ]
When fileinfo->fi_flags does not have the FIEMAP_FLAG_SYNC bit set and inline data has not been persisted yet, the physical address of the extent is calculated incorrectly for unwritten inline inodes.
root@vm:/mnt/f2fs# dd if=/dev/zero of=data.3k bs=3k count=1 root@vm:/mnt/f2fs# f2fs_io fiemap 0 100 data.3k Fiemap: offset = 0 len = 100 logical addr. physical addr. length flags 0 0000000000000000 00000ffffffff16c 0000000000000c00 00000301
This patch fixes the issue by checking if the inode's address is valid. If the inline inode is unwritten, set the physical address to 0 and mark the extent with FIEMAP_EXTENT_UNKNOWN | FIEMAP_EXTENT_DELALLOC flags.
--- fs/f2fs/inline.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
fs/f2fs/inline.c +9 -4
@@ -790,7 +790,7 @@ int f2fs_read_inline_dir(struct file *fiint f2fs_inline_data_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo,__u64 start,__u64 len) { -__u64 byteaddr, ilen; +__u64 byteaddr =0 , ilen;__u32 flags =FIEMAP_EXTENT_DATA_INLINE |FIEMAP_EXTENT_NOT_ALIGNED |FIEMAP_EXTENT_LAST ;struct node_info ni;
@@ -823,9 +823,14 @@ int f2fs_inline_data_fiemap(struct inodeif (err) goto out; - byteaddr = (__u64 )ni.blk_addr << inode->i_sb->s_blocksize_bits; - byteaddr += (char *)inline_data_addr (inode, ipage) - - (char *)F2FS_INODE (ipage); +if (__is_valid_data_blkaddr (ni.blk_addr)) { + byteaddr = (__u64 )ni.blk_addr << inode->i_sb->s_blocksize_bits; + byteaddr += (char *)inline_data_addr (inode, ipage) - + (char *)F2FS_INODE (ipage); + }else { +f2fs_bug_on (F2FS_I_SB (inode), ni.blk_addr !=NEW_ADDR ); + flags |=FIEMAP_EXTENT_DELALLOC |FIEMAP_EXTENT_UNKNOWN ; + } err =fiemap_fill_next_extent (fieinfo, start, byteaddr, ilen, flags);trace_f2fs_fiemap (inode, start, byteaddr, ilen, flags, err); out:
Greg Kroah-Hartman
maintainerPATCH 661/666 f2fs: fix false alarm of lockdep on cp_global_sem lock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 6a5e3de9c2bb0b691d16789a5d19e9276a09b308 ]
lockdep reported a potential deadlock:
a) TCMU device removal context:
- call del_gendisk() to get q->q_usage_counter
- call start_flush_work() to get work_completion of wb->dwork
b) f2fs writeback context:
- in wb_workfn(), which holds work_completion of wb->dwork
- call f2fs_balance_fs() to get sbi->gc_lock
c) f2fs vfs_write context:
- call f2fs_gc() to get sbi->gc_lock
- call f2fs_write_checkpoint() to get sbi->cp_global_sem
d) f2fs mount context:
- call recover_fsync_data() to get sbi->cp_global_sem
- call f2fs_check_and_fix_write_pointer() to call blkdev_report_zones() that goes down to blk_mq_alloc_request and get q->q_usage_counter
Original callstack is in Closes tag.
However, I think this is a false alarm due to before mount returns successfully (context d), we can not access file therein via vfs_write (context c).
Let's introduce per-sb cp_global_sem_key, and assign the key for cp_global_sem, so that lockdep can recognize cp_global_sem from different super block correctly.
A lot of work are done by Shin'ichiro Kawasaki, thanks a lot for the work.
--- fs/f2fs/f2fs.h | 3 +++ fs/f2fs/super.c | 11 +++++++++++ 2 files changed, 14 insertions(+)
fs/f2fs/f2fs.h +3 -0
@@ -1858,6 +1858,9 @@ struct f2fs_sb_info {spinlock_t iostat_lat_lock;struct iostat_lat_info *iostat_io_lat;#endif +#ifdef CONFIG_DEBUG_LOCK_ALLOC +struct lock_class_key cp_global_sem_key; +#endif };/* Definitions to access f2fs_sb_info */
fs/f2fs/super.c +11 -0
@@ -4490,6 +4490,11 @@ try_onemore:init_f2fs_rwsem (&sbi->gc_lock);mutex_init (&sbi->writepages);init_f2fs_rwsem (&sbi->cp_global_sem); +#ifdef CONFIG_DEBUG_LOCK_ALLOC +lockdep_register_key (&sbi->cp_global_sem_key); +lockdep_set_class (&sbi->cp_global_sem.internal_rwsem, + &sbi->cp_global_sem_key); +#endif init_f2fs_rwsem (&sbi->node_write);init_f2fs_rwsem (&sbi->node_change);spin_lock_init (&sbi->stat_lock);
@@ -4963,6 +4968,9 @@ free_sb_buf: free_sbi:if (sbi->s_chksum_driver)crypto_free_shash (sbi->s_chksum_driver); +#ifdef CONFIG_DEBUG_LOCK_ALLOC +lockdep_unregister_key (&sbi->cp_global_sem_key); +#endif kfree (sbi); sb->s_fs_info =NULL ;
@@ -5015,6 +5023,9 @@ static void kill_f2fs_super(struct super/* Release block devices last, after fscrypt_destroy_keyring(). */ if (sbi) {destroy_device_list (sbi); +#ifdef CONFIG_DEBUG_LOCK_ALLOC +lockdep_unregister_key (&sbi->cp_global_sem_key); +#endif kfree (sbi); sb->s_fs_info =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 662/666 spi: sifive: Simplify clock handling with devm_clk_get_enabled()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit 140039c23aca067b9ff0242e3c0ce96276bb95f3 ]
Replace devm_clk_get() followed by clk_prepare_enable() with devm_clk_get_enabled() for the bus clock. This reduces boilerplate code and error handling, as the managed API automatically disables the clock when the device is removed or if probe fails.
Remove the now-unnecessary clk_disable_unprepare() calls from the probe error path and the remove callback. Adjust the error handling to use the existing put_host label.
Stable-dep-of: 0f25236694a2 ("spi: sifive: fix controller deregistration")
--- drivers/spi/spi-sifive.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/spi/spi-sifive.c +6 -15
@@ -312,7 +312,8 @@ static int sifive_spi_probe(struct platf goto put_host; } - spi->clk =devm_clk_get (&pdev->dev,NULL ); +/* Spin up the bus clock before hitting registers */ + spi->clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (spi->clk)) {dev_err (&pdev->dev,"Unable to find bus clock\n" ); ret =PTR_ERR (spi->clk);
@@ -342,13 +343,6 @@ static int sifive_spi_probe(struct platf goto put_host; } -/* Spin up the bus clock before hitting registers */ - ret =clk_prepare_enable (spi->clk); -if (ret) { -dev_err (&pdev->dev,"Unable to enable bus clock\n" ); - goto put_host; - } -/* probe the number of CS lines */ spi->cs_inactive =sifive_spi_read (spi,SIFIVE_SPI_REG_CSDEF );sifive_spi_write (spi,SIFIVE_SPI_REG_CSDEF ,0xffffffffU );
@@ -357,14 +351,14 @@ static int sifive_spi_probe(struct platfif (!cs_bits) {dev_err (&pdev->dev,"Could not auto probe CS lines\n" ); ret = -EINVAL ; - goto disable_clk; + goto put_host; } num_cs =ilog2 (cs_bits) +1 ;if (num_cs >SIFIVE_SPI_MAX_CS ) {dev_err (&pdev->dev,"Invalid number of spi targets\n" ); ret = -EINVAL ; - goto disable_clk; + goto put_host; }/* Define our host */
@@ -393,7 +387,7 @@ static int sifive_spi_probe(struct platf dev_name(&pdev->dev), spi);if (ret) {dev_err (&pdev->dev,"Unable to bind to interrupt\n" ); - goto disable_clk; + goto put_host; } dev_info(&pdev->dev, "mapped; irq=%d, cs=%d\n",
@@ -402,13 +396,11 @@ static int sifive_spi_probe(struct platf ret =devm_spi_register_controller (&pdev->dev, host);if (ret <0 ) {dev_err (&pdev->dev,"spi_register_host failed\n" ); - goto disable_clk; + goto put_host; }return 0 ; -disable_clk: -clk_disable_unprepare (spi->clk); put_host:spi_controller_put (host);
@@ -422,7 +414,6 @@ static void sifive_spi_remove(struct pla/* Disable all the interrupts just in case */ sifive_spi_write (spi,SIFIVE_SPI_REG_IE ,0 ); -clk_disable_unprepare (spi->clk); }static int sifive_spi_suspend (struct device *dev)
Greg Kroah-Hartman
maintainerPATCH 653/666 smb: client: Use FullSessionKey for AES-256 encryption key derivation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Piyush Sachdeva <[email protected]>
[ Upstream commit 5be7a0cef3229fb3b63a07c0d289daf752545424 ]
When Kerberos authentication is used with AES-256 encryption (AES-256-CCM or AES-256-GCM), the SMB3 encryption and decryption keys must be derived using the full session key (Session.FullSessionKey) rather than just the first 16 bytes (Session.SessionKey).
Per MS-SMB2 section 3.2.5.3.1, when Connection.Dialect is "3.1.1" and Connection.CipherId is AES-256-CCM or AES-256-GCM, Session.FullSessionKey must be set to the full cryptographic key from the GSS authentication context. The encryption and decryption key derivation (SMBC2SCipherKey, SMBS2CCipherKey) must use this FullSessionKey as the KDF input. The signing key derivation continues to use Session.SessionKey (first 16 bytes) in all cases.
Previously, generate_key() hardcoded SMB2_NTLMV2_SESSKEY_SIZE (16) as the HMAC-SHA256 key input length for all derivations. When Kerberos with AES-256 provides a 32-byte session key, the KDF for encryption/decryption was using only the first 16 bytes, producing keys that did not match the server's, causing mount failures with sec=krb5 and require_gcm_256=1.
Add a full_key_size parameter to generate_key() and pass the appropriate size from generate_smb3signingkey():
- Signing: always SMB2_NTLMV2_SESSKEY_SIZE (16 bytes)
- Encryption/Decryption: ses->auth_key.len when AES-256, otherwise 16
Also fix cifs_dump_full_key() to report the actual session key length for AES-256 instead of hardcoded CIFS_SESS_KEY_SIZE, so that userspace tools like Wireshark receive the correct key for decryption.
--- fs/smb/client/ioctl.c | 2 +- fs/smb/client/smb2transport.c | 32 +++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 8 deletions(-)
fs/smb/client/ioctl.c +1 -1
@@ -300,7 +300,7 @@ search_end:break ;case SMB2_ENCRYPTION_AES256_CCM :case SMB2_ENCRYPTION_AES256_GCM : - out.session_key_length =CIFS_SESS_KEY_SIZE ; + out.session_key_length = ses->auth_key.len; out.server_in_key_length = out.server_out_key_length =SMB3_GCM256_CRYPTKEY_SIZE ;break ;default :
fs/smb/client/smb2transport.c +25 -7
@@ -334,7 +334,8 @@ out: }static int generate_key (struct cifs_ses *ses,struct kvec label, -struct kvec context,__u8 *key,unsigned int key_size) +struct kvec context,__u8 *key,unsigned int key_size, +unsigned int full_key_size) {unsigned char zero =0x0 ;__u8 i[4 ] = {0 ,0 ,0 ,1 };
@@ -355,7 +356,7 @@ static int generate_key(struct cifs_ses } rc =crypto_shash_setkey (server->secmech.hmacsha256->tfm, - ses->auth_key.response,SMB2_NTLMV2_SESSKEY_SIZE ); + ses->auth_key.response, full_key_size);if (rc) {cifs_server_dbg (VFS ,"%s: Could not set with session key\n" , __func__); goto smb3signkey_ret;
@@ -430,6 +431,7 @@ generate_smb3signingkey(struct cifs_sesstruct TCP_Server_Info *server, const struct derivation_triplet *ptriplet) { + unsigned int full_key_size = SMB2_NTLMV2_SESSKEY_SIZE;int rc;bool is_binding = false;int chan_index =0 ;
@@ -464,17 +466,31 @@ generate_smb3signingkey(struct cifs_ses rc =generate_key (ses, ptriplet->signing.label, ptriplet->signing.context, ses->chans[chan_index].signkey, -SMB3_SIGN_KEY_SIZE ); +SMB3_SIGN_KEY_SIZE , +SMB2_NTLMV2_SESSKEY_SIZE );if (rc)return rc; }else { rc =generate_key (ses, ptriplet->signing.label, ptriplet->signing.context, ses->smb3signingkey, -SMB3_SIGN_KEY_SIZE ); +SMB3_SIGN_KEY_SIZE , +SMB2_NTLMV2_SESSKEY_SIZE );if (rc)return rc; +/* +* Per MS-SMB2 3.2.5.3.1, signing key always uses Session.SessionKey +* (first 16 bytes). Encryption/decryption keys use +* Session.FullSessionKey when dialect is 3.1.1 and cipher is +* AES-256-CCM or AES-256-GCM, otherwise Session.SessionKey. +*/ + +if (server->dialect ==SMB311_PROT_ID && + (server->cipher_type ==SMB2_ENCRYPTION_AES256_CCM || + server->cipher_type ==SMB2_ENCRYPTION_AES256_GCM )) + full_key_size = ses->auth_key.len; +/* safe to access primary channel, since it will never go away */ spin_lock (&ses->chan_lock); memcpy(ses->chans[chan_index].signkey, ses->smb3signingkey,
@@ -484,13 +500,15 @@ generate_smb3signingkey(struct cifs_ses rc =generate_key (ses, ptriplet->encryption.label, ptriplet->encryption.context, ses->smb3encryptionkey, -SMB3_ENC_DEC_KEY_SIZE ); +SMB3_ENC_DEC_KEY_SIZE , + full_key_size);if (rc)return rc; rc =generate_key (ses, ptriplet->decryption.label, ptriplet->decryption.context, ses->smb3decryptionkey, -SMB3_ENC_DEC_KEY_SIZE ); +SMB3_ENC_DEC_KEY_SIZE , + full_key_size);if (rc)return rc; }
@@ -505,7 +523,7 @@ generate_smb3signingkey(struct cifs_ses &ses->Suid);cifs_dbg (VFS ,"Cipher type %d\n" , server->cipher_type);cifs_dbg (VFS ,"Session Key %*ph\n" , -SMB2_NTLMV2_SESSKEY_SIZE , ses->auth_key.response); + (int )ses->auth_key.len, ses->auth_key.response);cifs_dbg (VFS ,"Signing Key %*ph\n" ,SMB3_SIGN_KEY_SIZE , ses->smb3signingkey); if ((server->cipher_type == SMB2_ENCRYPTION_AES256_CCM) ||
# Librecast Test Results
020/020 [ OK ] liblcrq
010/010 [ OK ] libmld
120/120 [ OK ] liblibrecast
CPU/kernel: Linux auntie 6.12.91-rc1-ge1a708751d80 #1 SMP PREEMPT_DYNAMIC Wed May 20 18:32:31 -00 2026 x86_64 AMD Ryzen 9 9950X 16-Core Processor AuthenticAMD GNU/Linux
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.91 release. There are 666 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 22 May 2026 16:20:16 +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.12.91-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.12.y
and the diffstat can be found below.thanks,
greg k-h
perf fails to build on ARM/ARM64/MIPS with:
In file included from libbpf.c:54:libbpf.c: In function 'bpf_object__elf_init':
libbpf.c:1538:76: error: implicit declaration of function 'errstr'; did you mean 'strstr'? [-Werror=implicit-function-declaration]
1538 | pr_warn("elf: failed to open %s: %s\n",
obj->path, errstr(err));
|
^~~~~~libbpf_internal.h:167:47: note: in definition of macro '__pr'
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~~
this is due to commit 2e81d08459c32c57d037ad160e755bcfe6d5003b
Author: Mykyta Yatsenko <[email protected]> Date: Mon Nov 11 21:29:17 2024 +0000
libbpf: Stringify errno in log messages in libbpf.c
[ Upstream commit 271abf041cb354ce99df33ce1f99db79faf90477 ]
we would need to backport the below commit, but it does not apply cleanly to 6.12.y:
commit c68b6fdc3600466e3c265bad34d099eb8c5280f1
Author: Andrii Nakryiko <[email protected]> Date: Wed Oct 1 10:13:24 2025 -0700
libbpf: move libbpf_errstr() into libbpf_utils.c
Signature · 1 line
Florian
Re: [PATCH 6.12 354/666] libbpf: Stringify errno in log messages in libbpf.c
In reply to Greg Kroah-HartmanHi Greg,
Quoted 11 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mykyta Yatsenko <[email protected]>
[ Upstream commit
271abf041cb354ce99df33ce1f99db79faf90477]Convert numeric error codes into the string representations in log messages in
libbpf.c.
Quoted 6 lines
Signed-off-by Mykyta Yatsenko <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>Stable-dep-of:
380044c40b16("libbpf: Prevent double close and leak of btf objects")Signed-off-by Sasha Levin <[email protected]>---
This commit caused a build failure while testing 6.12.91-rc1 to prepare it for Debian:
make -f /home/build/linux-stable-rc/tools/build/Makefile.build dir=./arch/x86 obj=objtool
In file included from libbpf.c:54:libbpf.c: In function ‘bpf_object__elf_init’:
libbpf.c:1538:76: error: implicit declaration of function ‘errstr’; did you mean ‘strstr’? [-Werror=implicit-function-declaration]
1538 | pr_warn("elf: failed to open %s: %s\n", obj->path, errstr(err));
| ^~~~~~
libbpf_internal.h:167:47: note: in definition of macro ‘__pr’
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~~
libbpf.c:1538:25: note: in expansion of macro ‘pr_warn’
1538 | pr_warn("elf: failed to open %s: %s\n", obj->path, errstr(err));
| ^~~~~~~libbpf.c:1538:76: error: nested extern declaration of ‘errstr’ [-Werror=nested-externs]
1538 | pr_warn("elf: failed to open %s: %s\n", obj->path, errstr(err));
| ^~~~~~
libbpf_internal.h:167:47: note: in definition of macro ‘__pr’
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~~
libbpf.c:1538:25: note: in expansion of macro ‘pr_warn’
1538 | pr_warn("elf: failed to open %s: %s\n", obj->path, errstr(err));
| ^~~~~~~
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:1538:25: note: in expansion of macro ‘pr_warn’
1538 | pr_warn("elf: failed to open %s: %s\n", obj->path, errstr(err));
| ^~~~~~~
libbpf.c: In function ‘bpf_object__init_internal_map’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:1938:17: note: in expansion of macro ‘pr_warn’
1938 | pr_warn("failed to alloc map '%s' content buffer: %s\n", map->name, errstr(err));
| ^~~~~~~
libbpf.c: In function ‘parse_u64’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:2102:17: note: in expansion of macro ‘pr_warn’
2102 | pr_warn("failed to parse '%s': %s\n", value, errstr(err));
| ^~~~~~~
libbpf.c: In function ‘bpf_object__read_kconfig_file’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:2268:25: note: in expansion of macro ‘pr_warn’
2268 | pr_warn("error parsing system Kconfig line '%s': %s\n",
| ^~~~~~~
libbpf.c: In function ‘bpf_object__read_kconfig_mem’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:2289:17: note: in expansion of macro ‘pr_warn’
2289 | pr_warn("failed to open in-memory Kconfig: %s\n", errstr(err));
| ^~~~~~~
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:2296:25: note: in expansion of macro ‘pr_warn’
2296 | pr_warn("error parsing in-memory Kconfig line '%s': %s\n",
| ^~~~~~~
libbpf.c: In function ‘bpf_object__init_btf’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:3212:25: note: in expansion of macro ‘pr_warn’
3212 | pr_warn("Error loading ELF section %s: %s.\n", BTF_ELF_SEC, errstr(err));
| ^~~~~~~
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:3230:25: note: in expansion of macro ‘pr_warn’
3230 | pr_warn("Error loading ELF section %s: %s. Ignored and continue.\n",
| ^~~~~~~
libbpf.c: In function ‘btf_fixup_datasec’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:172:33: note: in expansion of macro ‘__pr’
172 | #define pr_debug(fmt, ...) __pr(LIBBPF_DEBUG, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:3323:25: note: in expansion of macro ‘pr_debug’
3323 | pr_debug("sec '%s': failed to determine size from ELF: size %u, err %s\n",
| ^~~~~~~~
libbpf.c: In function ‘bpf_object__load_vmlinux_btf’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:3478:17: note: in expansion of macro ‘pr_warn’
3478 | pr_warn("Error loading vmlinux BTF: %s\n", errstr(err));
| ^~~~~~~
libbpf.c: In function ‘bpf_object__sanitize_and_load_btf’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:3582:25: note: in expansion of macro ‘pr_warn’
3582 | pr_warn("Error loading .BTF into kernel: %s. BTF is mandatory, can't proceed.\n",
| ^~~~~~~
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:171:33: note: in expansion of macro ‘__pr’
171 | #define pr_info(fmt, ...) __pr(LIBBPF_INFO, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:3585:25: note: in expansion of macro ‘pr_info’
3585 | pr_info("Error loading .BTF into kernel: %s. BTF is optional, ignoring.\n",
| ^~~~~~~
libbpf.c: In function ‘bpf_get_map_info_from_fdinfo’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:4798:17: note: in expansion of macro ‘pr_warn’
4798 | pr_warn("failed to open %s: %s. No procfs support?\n", file,
| ^~~~~~~
libbpf.c: In function ‘bpf_object_prepare_token’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf.c:4954:17: note: in expansion of macro ‘__pr’
4954 | __pr(level, "object '%s': failed (%s) to open BPF FS mount at '%s'%s\n",
| ^~~~
libbpf.c: In function ‘bpf_object__probe_loading’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5004:17: note: in expansion of macro ‘pr_warn’
5004 | pr_warn("Failed to bump RLIMIT_MEMLOCK (err = %s), you might need to do it explicitly!\n",
| ^~~~~~~
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5013:17: note: in expansion of macro ‘pr_warn’
5013 | pr_warn("Error in %s(): %s. Couldn't load trivial BPF program. Make sure your kernel supports BPF (CONFIG_BPF_SYSCALL=y) and/or that RLIMIT_MEMLOCK is set to big enough value.\n",
| ^~~~~~~
libbpf.c: In function ‘map_is_reuse_compat’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5047:17: note: in expansion of macro ‘pr_warn’
5047 | pr_warn("failed to get map info for map FD %d: %s\n", map_fd,
| ^~~~~~~
libbpf.c: In function ‘bpf_object__reuse_map’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5084:17: note: in expansion of macro ‘pr_warn’
5084 | pr_warn("couldn't retrieve pinned map '%s': %s\n",
| ^~~~~~~
libbpf.c: In function ‘bpf_object__populate_internal_map’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5125:17: note: in expansion of macro ‘pr_warn’
5125 | pr_warn("map '%s': failed to set initial contents: %s\n",
| ^~~~~~~
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5135:25: note: in expansion of macro ‘pr_warn’
5135 | pr_warn("map '%s': failed to freeze as read-only: %s\n",
| ^~~~~~~
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5162:25: note: in expansion of macro ‘pr_warn’
5162 | pr_warn("map '%s': failed to re-mmap() contents: %s\n",
| ^~~~~~~
libbpf.c: In function ‘bpf_object__create_map’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5220:33: note: in expansion of macro ‘pr_warn’
5220 | pr_warn("map '%s': failed to create inner map: %s\n",
| ^~~~~~~
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5276:17: note: in expansion of macro ‘pr_warn’
5276 | pr_warn("Error in bpf_create_map_xattr(%s): %s. Retrying without BTF.\n",
| ^~~~~~~
libbpf.c: In function ‘init_map_in_map_slots’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 7 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5332:25: note: in expansion of macro ‘pr_warn’
5332 | pr_warn("map '%s': failed to initialize slot [%d] to map '%s' fd=%d: %s\n",
| ^~~~~~~
libbpf.c: In function ‘init_prog_array_slots’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 7 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5365:25: note: in expansion of macro ‘pr_warn’
5365 | pr_warn("map '%s': failed to initialize slot [%d] to prog '%s' fd=%d: %s\n",
| ^~~~~~~
libbpf.c: In function ‘bpf_object__create_maps’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5492:41: note: in expansion of macro ‘pr_warn’
5492 | pr_warn("map '%s': failed to mmap arena: %s\n",
| ^~~~~~~
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5515:33: note: in expansion of macro ‘pr_warn’
5515 | pr_warn("map '%s': failed to auto-pin at '%s': %s\n",
| ^~~~~~~
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5525:9: note: in expansion of macro ‘pr_warn’
5525 | pr_warn("map '%s': failed to create: %s\n", map->name, errstr(err));
| ^~~~~~~
libbpf.c: In function ‘load_module_btfs’:
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5649:25: note: in expansion of macro ‘pr_warn’
5649 | pr_warn("failed to iterate BTF objects: %s\n", errstr(err));
| ^~~~~~~
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~
libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
| ^~~~
libbpf.c:5658:25: note: in expansion of macro ‘pr_warn’
5658 | pr_warn("failed to get BTF object #%d FD: %s\n", id, errstr(err));
| ^~~~~~~
libbpf_internal.h:167:29: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~libbpf_internal.h:170:33: note: in expansion of macro ‘__pr’
170 | #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
[...]
libbpf.c:13965:25: note: in expansion of macro ‘pr_warn’
13965 | pr_warn("map '%s': failed to auto-attach: %s\n",
| ^~~~~~~cc1: all warnings being treated as errors
make[8]: *** [/home/build/linux-stable-rc/tools/build/Makefile.build:105: /home/build/linux-stable-rc/tools/bpf/resolve_btfids/libbpf/staticobjs/libbpf.o] Error 1 make[7]: *** [Makefile:165: /home/build/linux-stable-rc/tools/bpf/resolve_btfids/libbpf/staticobjs/libbpf-in.o] Error 2
make[6]: *** [Makefile:63: /home/build/linux-stable-rc/tools/bpf/resolve_btfids//libbpf/libbpf.a] Error 2
make[5]: *** [Makefile:76: bpf/resolve_btfids] Error 2
make[4]: *** [Makefile:1391: tools/bpf/resolve_btfids] Error 2
Regards,
Salvatore
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.91 release. There are 666 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.
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 6.12.91 release. There are 666 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.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.12.y
Best regards,
Pavel
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.91 release. There are 666 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.
Re: [PATCH 6.12 354/666] libbpf: Stringify errno in log messages in libbpf.c
In reply to Salvatore BonaccorsoHi Greg,
Quoted 14 lines
Quoted 7 lines
From: Mykyta Yatsenko <[email protected]>
[ Upstream commit
271abf041cb354ce99df33ce1f99db79faf90477]Convert numeric error codes into the string representations in log messages in
libbpf.c.Quoted 6 lines
Signed-off-by Mykyta Yatsenko <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>Stable-dep-of:
380044c40b16("libbpf: Prevent double close and leak of btf objects")Signed-off-by Sasha Levin <[email protected]>---
Quoted 3 lines
This commit caused a build failure while testing 6.12.91-rc1 to prepare it for Debian:
+ 1 for Oracle Linux.
I cherry-picked this commit: 1633a83bf993 ("libbpf: Introduce errstr() for stringifying errno") and it seems to work, so Greg, can you please queue this up as a prerequisite for this commit ?
Quoted 10 lines
make -f
/home/build/linux-stable-rc/tools/build/Makefile.builddir=./arch/x86 obj=objtool
In file included from libbpf.c:54:libbpf.c: In function ‘bpf_object__elf_init’:
libbpf.c:1538:76: error: implicit declaration of function ‘errstr’; did you mean ‘strstr’? [-Werror=implicit-function-declaration]
1538 |pr_warn("elf: failed to open %s: %s\n", obj->path, errstr(err));
| ^~~~~~
libbpf_internal.h:167:47: note: in definition of macro ‘__pr’
167 |libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~~
libbpf.c:1538:25: note: in expansion of macro ‘pr_warn’
Quoted 8 lines
1538 | pr_warn("elf: failed to open %s: %s\n", obj->path, errstr(err)); | ^~~~~~~libbpf.c:1538:76: error: nested extern declaration of ‘errstr’ [-Werror=nested-externs]
1538 |pr_warn("elf: failed to open %s: %s\n", obj->path, errstr(err));
| ^~~~~~
libbpf_internal.h:167:47: note: in definition of macro ‘__pr’167 | libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \ |
thanks,
Harshit
Sasha Levin
maintainerRe: [PATCH 6.12 354/666] libbpf: Stringify errno in log messages in libbpf.c
In reply to Salvatore BonaccorsoQuoted 5 lines · Salvatore Bonaccorso
This commit caused a build failure while testing 6.12.91-rc1 to prepare it for Debian:
[...]
libbpf.c:1538:76: error: implicit declaration of function 'errstr'; did you mean 'strstr'? [-Werror=implicit-function-declaration]
Dropped from the 6.12 queue along with its two dep-of companions:
- libbpf: Stringify errno in log messages in libbpf.c
- libbpf: Prevent double close and leak of btf objects
- libbpf: Change log level of btf loading error message
The errstr() helper would need a larger libbpf refactor (c68b6fdc3600 and its prerequisites) to come along, which doesn't apply cleanly. Thanks for the report.
--
Thanks,
Sasha
Sasha Levin
maintainerQuoted 9 lines · Florian Fainelli
perf fails to build on ARM/ARM64/MIPS with:
[...]
libbpf.c:1538:76: error: implicit declaration of function 'errstr'; [...]
we would need to backport the below commit, but it does not apply cleanly to 6.12.y:commit
c68b6fdc3600466e3c265bad34d099eb8c5280f1
libbpf: movelibbpf_errstr()intolibbpf_utils.c
Dropped 271abf041cb3 ("libbpf: Stringify errno in log messages in libbpf.c") from the 6.12 queue, along with its two dep-of companions (libbpf: Prevent double close and leak of btf objects; libbpf: Change log level of btf loading error message), since c68b6fdc3600 doesn't apply without a larger libbpf refactor coming along.
Thanks for the report.
--
Thanks,
Sasha
Sasha Levin
maintainerRe: [PATCH 6.12 011/666] erofs: verify metadata accesses for file-backed mounts
In reply to Gao XiangQuoted 4 lines · Gao Xiang
Could you please help drop this too, the same reason as:
https://lore.kernel.org/r/ag3qlMOcTYM2FBUQ@debianI will address this backport manually later.
Dropped from the 6.12 queue (along with the 7.0 and 6.18 counterparts). Thanks.
--
Thanks,
Sasha
Re: [PATCH 6.12 354/666] libbpf: Stringify errno in log messages in libbpf.c
In reply to Sasha LevinHi Sasha,
Am 21.05.2026 um 14:55 schrieb Sasha Levin:
Quoted 13 lines · Salvatore Bonaccorso
Quoted 5 lines
This commit caused a build failure while testing 6.12.91-rc1 to prepare it for Debian:
[...]
libbpf.c:1538:76: error: implicit declaration of function 'errstr'; did you mean 'strstr'? [-Werror=implicit-function-declaration]Dropped from the 6.12 queue along with its two dep-of companions:
- libbpf: Stringify errno in log messages in
libbpf.c
- libbpf: Prevent double close and leak of btf objects
- libbpf: Change log level of btf loading error message
Quoted 7 lines
The
errstr()helper would need a larger libbpf refactor (c68b6fdc3600and its prerequisites) to come along, which doesn't apply cleanly. Thanks for the report.--
Thanks,
Sasha
I get the same build error. I tried, as you suggested, to revert
2e81d08459c32c57d037ad160e755bcfe6d5003b (libbpf: Stringify errno in log messages in libbpf.c) 5c758117c381172ccb60fe9a0313705794ccdce2 (libbpf: Prevent double close and leak of btf objects) a8061c6ed62cc94a5e19f0e31d03d23ff65d638a (libbpf: Change log level of btf loading error message)
but no matter how I do the revert, I get a conflict and I can't figure out how to resolve that.
Will wait to retest an -rc2 once it's pushed out...
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]
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.91 release. There are 666 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 22 May 2026 16:20:16 +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.12.91-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.12.y
and the diffstat can be found below.thanks,
greg k-h
The build fails on RISC-V RV64. Reverting commit "
bpf, riscv: Remove redundant bpf_flush_icache() after pack allocator finalize " commit id fcbec4603139755942d21547774a6b6b390368f3 resolves the issue.
Re: [PATCH 6.12 346/666] bpf, riscv: Remove redundant bpf_flush_icache() after pack allocator finalize
In reply to Greg Kroah-HartmanHi Greg,
Quoted 48 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Puranjay Mohan <[email protected]>
[ Upstream commit
46ee1342b887c9387a933397d846ff6c9584322c]
bpf_flush_icache()callsflush_icache_range()to clean the data cache and invalidate the instruction cache for the JITed code region. However, since commit48a8f78c50bd("bpf, riscv: use prog pack allocator in the BPF JIT"), this flush is redundant.
bpf_jit_binary_pack_finalize()copies the JITed instructions to the ROX region viabpf_arch_text_copy()->patch_text_nosync(), andpatch_text_nosync()already callsflush_icache_range()on the written range. The subsequentbpf_flush_icache()repeats the same cache maintenance on an overlapping range.Remove the redundant
bpf_flush_icache()call and its now-unused definition.Fixes 48a8f78c50bd ("bpf, riscv: use prog pack allocator in the BPF JIT")Acked-by Song Liu <[email protected]>Signed-off-by Puranjay Mohan <[email protected]>Reviewed-by Pu Lehui <[email protected]>Tested-by Paul Chaignon <[email protected]>Signed-off-by Alexei Starovoitov <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- arch/riscv/net/bpf_jit.h | 6 ------ arch/riscv/net/bpf_jit_core.c | 7 ------- 2 files changed, 13 deletions(-)arch/riscv/net/bpf_jit.h +0
-1@@ -11,7 +11,6 @@#include <linux/bpf.h> #include <linux/filter.h> -#include <asm/cacheflush.h> static inline bool rvc_enabled (void ) {
arch/riscv/net/bpf_jit.h static inline void bpf_fill_ill_insns(void *area, unsigned int size) · line 116
Quoted 8 lines
arch/riscv/net/bpf_jit.h +0
-5@@ -109,11 +108,6 @@ static inline void bpf_fill_ill_insns(void *area, unsigned int size)memset (area,0 , size); } -static inline void bpf_flush_icache (void *start,void *end) -{ -flush_icache_range ((unsigned long )start, (unsigned long )end); -} -
I have run an AI assisted backport review and it spotted an issue: I have taken a look and the issues goes like:
on 6.12.
$ git grep bpf_flush_icache arch/riscv/ arch/riscv/net/bpf_jit_comp64.c: bpf_flush_icache(ro_image, ro_image_end);
Upstream doesn't have this problem because this call is removed in commit: 6798668ab195 ("riscv, bpf: Remove duplicated bpf_flush_icache()") but this is not present in 6.12.91 so I think it is incorrect to backport this, should we drop this ?
I didn't try compiling this on risv.
thanks,
Harshit
Quoted 21 lines
arch/riscv/net/bpf_jit.h +0
-0/* Emit a 4-byte riscv instruction. */ static inline void emit (const u32 insn,struct rv_jit_context *ctx) {arch/riscv/net/bpf_jit_core.c +0
-7@@ -184,13 +184,6 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) prog = orig_prog; goto out_offset; } -/* -* The instructions have now been copied to the ROX region from -* where they will execute. -* Write any modified data cache blocks out to memory and -* invalidate the corresponding blocks in the instruction cache. -*/ -bpf_flush_icache (jit_data->ro_header, ctx->ro_insns + ctx->ninsns);for (i =0 ; i < prog->len; i++) ctx->offset[i] =ninsns_rvoff (ctx->offset[i]);bpf_prog_fill_jited_linfo (prog, ctx->offset);
Re: [PATCH 6.12 384/666] i3c: master: Fix error codes at send_ccc_cmd
In reply to Greg Kroah-HartmanHi Greg/Sasha,
Quoted 20 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jorge Marques <[email protected]>
[ Upstream commit
ef8b5229348f0719aca557c4ca5530630ae4d134]
i3c_master_send_ccc_cmd_locked()would propagatecmd->err(positive, Mx codes) to the ret variable, cascading down multiple methods until reaching methods that explicitly stated they would return 0 on success or negative error code. For example, the call chain:
i3c_device_enable_ibi<-i3c_dev_enable_ibi_locked<-master->ops.enable_ibi<-i3c_master_enec_locked<-i3c_master_enec_disec_locked<-i3c_master_send_ccc_cmd_lockedFix this by returning the ret value, callers can still read the
cmd->errvalue if ret is negative.
Quoted 9 lines
All corner cases where the Mx codes do need to be handled individually, are resolved in previous commits. Those corner cases are all scenarios when
I3C_ERROR_M2is expected and acceptable.
The prerequisite patches for the fix are:i3c: master: Move rstdaa error suppression
i3c: master: Move entdaa error suppression
i3c: master: Movebus_initerror suppression
I have run an AI assisted backport review and it spotted an issue: I have taken a look and the issues goes like:
The above mentioned prerequisites are not present in 6.12.91, so I think it is incorrect to backport this to 6.12.91.
Thanks,
Harshit
Quoted 93 lines
Reported-by Dan Carpenter <[email protected]>Fixes 3a379bbcea0a ("i3c: Add core I3C infrastructure")Reviewed-by Adrian Hunter <[email protected]>Signed-off-by Jorge Marques <[email protected]>Signed-off-by Alexandre Belloni <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/i3c/master.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-)drivers/i3c/master.c +13
-19@@ -825,11 +825,17 @@ static void i3c_ccc_cmd_init(struct i3c_ccc_cmd *cmd, bool rnw, u8 id, cmd->err =I3C_ERROR_UNKNOWN ; } +/** +* i3c_master_send_ccc_cmd_locked() - send a CCC (Common Command Codes) +* @master: master used to send frames on the bus +* @cmd: command to send +* +* Return: 0 in case of success, or a negative error code otherwise. +* I3C Mx error codes are stored in cmd->err. +*/ static int i3c_master_send_ccc_cmd_locked (struct i3c_master_controller *master,struct i3c_ccc_cmd *cmd) { -int ret; -if (!cmd || !master)return -EINVAL ;@@ -847,15 +853,7 @@ static int i3c_master_send_ccc_cmd_locked(struct i3c_master_controller *master, !master->ops->supports_ccc_cmd(master, cmd)) return -ENOTSUPP; - ret = master->ops->send_ccc_cmd (master, cmd); -if (ret) { -if (cmd->err !=I3C_ERROR_UNKNOWN ) -return cmd->err; - -return ret; - } - -return 0 ; +return master->ops->send_ccc_cmd (master, cmd); } static struct i2c_dev_desc *@@ -959,8 +957,7 @@ static int i3c_master_rstdaa_locked(struct i3c_master_controller *master,* * This function must be called with the bus lock held in write mode. * -* Return: 0 in case of success, a positive I3C error code if the error is -* one of the official Mx error codes, and a negative error code otherwise. +* Return: 0 in case of success, or a negative error code otherwise. */ int i3c_master_entdaa_locked (struct i3c_master_controller *master) {@@ -1012,8 +1009,7 @@ static int i3c_master_enec_disec_locked(struct i3c_master_controller *master,* * This function must be called with the bus lock held in write mode. * -* Return: 0 in case of success, a positive I3C error code if the error is -* one of the official Mx error codes, and a negative error code otherwise. +* Return: 0 in case of success, or a negative error code otherwise. */ int i3c_master_disec_locked (struct i3c_master_controller *master,u8 addr,u8 evts)@@ -1033,8 +1029,7 @@ EXPORT_SYMBOL_GPL(i3c_master_disec_locked);* * This function must be called with the bus lock held in write mode. * -* Return: 0 in case of success, a positive I3C error code if the error is -* one of the official Mx error codes, and a negative error code otherwise. +* Return: 0 in case of success, or a negative error code otherwise. */ int i3c_master_enec_locked (struct i3c_master_controller *master,u8 addr,u8 evts)@@ -1059,8 +1054,7 @@ EXPORT_SYMBOL_GPL(i3c_master_enec_locked);* * This function must be called with the bus lock held in write mode. * -* Return: 0 in case of success, a positive I3C error code if the error is -* one of the official Mx error codes, and a negative error code otherwise. +* Return: 0 in case of success, or a negative error code otherwise. */ int i3c_master_defslvs_locked (struct i3c_master_controller *master) {
Sasha Levin
maintainerRe: [PATCH 6.12 384/666] i3c: master: Fix error codes at send_ccc_cmd
Quoted 2 lines · Harshit Mogalapalli
The above mentioned prerequisites are not present in 6.12.91, so I think it is incorrect to backport this to 6.12.91.
Dropped from the 7.0, 6.18, 6.12, 6.6, 6.1, 5.15, and 5.10 queues — the same prerequisite gap exists across all of them. Thanks for catching it.
--
Thanks,
Sasha
Sasha Levin
maintainerRe: [PATCH 6.12 346/666] bpf, riscv: Remove redundant bpf_flush_icache() after pack allocator finalize
In reply to Harshit MogalapalliQuoted 4 lines · Harshit Mogalapalli
Upstream doesn't have this problem because this call is removed in
commit:6798668ab195("riscv, bpf: Remove duplicatedbpf_flush_icache()") but this is not present in 6.12.91 so I think it is incorrect to backport this, should we drop this ?
Dropped from the 6.12 and 6.6 queues — 6.6 has the same missing prerequisite. Thanks for the report.
--
Thanks,
Sasha
Re: [PATCH 6.12 505/666] sched/psi: fix race between file release and pressure write
In reply to Greg Kroah-HartmanHi Greg/Sasha,
Quoted 143 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
[ Upstream commit
a5b98009f16d8a5fb4a8ff9a193f5735515c38fa]A potential race condition exists between pressure write and cgroup file release regarding the priv member of struct
kernfs_open_file, which triggers the uaf reported in [1].Consider the following scenario involving execution on two separate CPUs:
CPU0 CPU1 ==== ==== vfs_rmdir() kernfs_iop_rmdir() cgroup_rmdir() cgroup_kn_lock_live() cgroup_destroy_locked() cgroup_addrm_files() cgroup_rm_file() kernfs_remove_by_name() kernfs_remove_by_name_ns() vfs_write() __kernfs_remove() new_sync_write() kernfs_drain() kernfs_fop_write_iter() kernfs_drain_open_files() cgroup_file_write() kernfs_release_file() pressure_write() cgroup_file_release() ctx = of->priv; kfree(ctx);
of->priv= NULL;cgroup_kn_unlock()
cgroup_kn_lock_live()
cgroup_get(cgrp)
cgroup_kn_unlock()
if (ctx->psi.trigger) // here, trigger uaf for ctx, that isof->privThe
cgroup_rmdir()is protected by thecgroup_mutex, it also safeguards the memory deallocation ofof->privperformed withincgroup_file_release(). However, the operations involvingof->privexecuted withinpressure_write()are not entirely covered by the protection ofcgroup_mutex. Consequently, if the code inpressure_write(), specifically the section handling the ctx variable executes aftercgroup_file_release()has completed, a uaf vulnerability involvingof->privis triggered.Therefore, the issue can be resolved by extending the scope of the
cgroup_mutexlock withinpressure_write()to encompass all code paths involvingof->priv, thereby properly synchronizing the race condition occurring betweencgroup_file_release()andpressure_write().And, if an live kn lock can be successfully acquired while executing the pressure write operation, it indicates that the cgroup deletion process has not yet reached its final stage; consequently, the priv pointer within
open_filecannot be NULL. Therefore, the operation to retrieve the ctx value must be moved to a point *after* the live kn lock has been successfully acquired.In another situation, specifically after entering
cgroup_kn_lock_live()but before acquiringcgroup_mutex, there exists a different class of race condition:CPU0: write memory.pressure CPU1: write cgroup.pressure=0
=========================== =============================
kernfs_fop_write_iter()
kernfs_get_active_of(of)
pressure_write()cgroup_kn_lock_live(memory.pressure) cgroup_tryget(cgrp) kernfs_break_active_protection(kn) ... blocks on cgroup_mutex cgroup_pressure_write() cgroup_kn_lock_live(cgroup.pressure) cgroup_file_show(memory.pressure, false) kernfs_show(false) kernfs_drain_open_files() cgroup_file_release(of) kfree(ctx) of->priv = NULL cgroup_kn_unlock() ... acquires cgroup_mutex ctx = of->priv; // may now be NULL if (ctx->psi.trigger) // NULL dereferenceConsequently, there is a possibility that
of->privis NULL, the pressure write needs to check for this.Now that the scope of the
cgroup_mutexhas been expanded, the original explicit cgroup_get/put operations are no longer necessary, this is because acquiring/releasing the live kn lock inherently executes a cgroup get/put operation.[1]
BUG: KASAN: slab-use-after-free in pressure_write+0xa4/0x210 kernel/cgroup/cgroup.c:4011 Call Trace: pressure_write+0xa4/0x210 kernel/cgroup/cgroup.c:4011 cgroup_file_write+0x36f/0x790 kernel/cgroup/cgroup.c:4311 kernfs_fop_write_iter+0x3b0/0x540 fs/kernfs/file.c:352 Allocated by task 9352: cgroup_file_open+0x90/0x3a0 kernel/cgroup/cgroup.c:4256 kernfs_fop_open+0x9eb/0xcb0 fs/kernfs/file.c:724 do_dentry_open+0x83d/0x13e0 fs/open.c:949 Freed by task 9353: cgroup_file_release+0xd6/0x100 kernel/cgroup/cgroup.c:4283 kernfs_release_file fs/kernfs/file.c:764 [inline] kernfs_drain_open_files+0x392/0x720 fs/kernfs/file.c:834 kernfs_drain+0x470/0x600 fs/kernfs/dir.c:525Fixes 0e94682b73bf ("psi: introduce psi monitor")Reported-by [email protected]Tested-by [email protected]Signed-off-by Edward Adam Davis <[email protected]>Reviewed-by Chen Ridong <[email protected]>Signed-off-by Tejun Heo <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- kernel/cgroup/cgroup.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)kernel/cgroup/cgroup.c +2
-1@@ -3876,33 +3876,41 @@ static int cgroup_cpu_pressure_show(struct seq_file *seq, void *v)static ssize_t pressure_write (struct kernfs_open_file *of,char *buf,size_t nbytes,enum psi_res res) { -struct cgroup_file_ctx *ctx = of->priv; +struct cgroup_file_ctx *ctx;struct psi_trigger *new;struct cgroup *cgrp;struct psi_group *psi; +ssize_t ret =0 ; cgrp =cgroup_kn_lock_live (of->kn, false);if (!cgrp)
kernel/cgroup/cgroup.c static int cgroup_cpu_pressure_show(struct seq_file *seq, void *v) · line 3894
Quoted 10 lines
kernel/cgroup/cgroup.c +5
-2return -ENODEV ; -cgroup_get (cgrp); -cgroup_kn_unlock (of->kn); + ctx = of->priv; +if (!ctx) { + ret = -ENODEV ; + goto out_unlock; + }
I have run an AI assisted backport review and it spotted an issue: I have taken a look and the issues goes like:
Upstream has:
static void cgroup_file_release(struct kernfs_open_file *of)
{
struct cftype *cft = of_cft(of);
struct cgroup_file_ctx *ctx = of->priv;
if (cft->release)
cft->release(of);
put_cgroup_ns(ctx->ns);
kfree(ctx);
of->priv = NULL;
}On 6.12.y:
static void cgroup_file_release(struct kernfs_open_file *of)
{
struct cftype *cft = of_cft(of);
struct cgroup_file_ctx *ctx = of->priv;
if (cft->release)
cft->release(of);
put_cgroup_ns(ctx->ns);
kfree(ctx);
}On 6.12.y, cgroup_file_release() frees ctx but does not clear of->priv. The posted backport adds
ctx = of->priv; if (!ctx)
in pressure_write(), but that only works if release turns of->priv into NULL. In the pressure_write() vs cgroup_pressure_write() race from the commit message, 6.12.y still leaves a dangling pointer there, so this backport alone is incomplete and can still hit UAF.
So upstream has commit: 94a4acfec146 ("cgroup/psi: Set of->priv to NULL upon file release") which might be needed here as well, without that I would suggest a drop.
Thanks,
Harshit
Re: [PATCH 6.12 634/666] netfs: fix error handling in netfs_extract_user_iter()
In reply to Greg Kroah-HartmanHi Greg/Sasha,
Quoted 53 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit
0aad5704c6b4d14007d4eab15883e8524e4310f4upstream.In
netfs_extract_user_iter(), ifiov_iter_extract_pages()failed to extract user pages, bail out on-ENOMEM, otherwise return the error code only if @npages == 0, allowing short DIO reads and writes to be issued.This fixes mmapstress02 from LTP tests against CIFS.
Fixes 85dd2c8ff368 ("netfs: Add a function to extract a UBUF or IOVEC into a BVEC iterator")Reported-by Xiaoli Feng <[email protected]>Signed-off-by Paulo Alcantara (Red Hat) <[email protected]>Signed-off-by David Howells <[email protected]>Signed-off-by Christian Brauner <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- fs/netfs/iterator.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)fs/netfs/iterator.c +3
-3@@ -22,7 +22,7 @@* * Extract the page fragments from the given amount of the source iterator and * build up a second iterator that refers to all of those bits. This allows -* the original iterator to disposed of. +* the original iterator to be disposed of. * * @extraction_flags can have ITER_ALLOW_P2PDMA set to request peer-to-peer DMA be * allowed on the pages extracted. @@ -67,8 +67,8 @@ ssize_t netfs_extract_user_iter(struct i ret =iov_iter_extract_pages (orig, &pages, count, max_pages - npages, extraction_flags, &offset); -if (ret <0 ) { -pr_err ("Couldn't get user pages (rc=%zd)\n" , ret); +if (unlikely (ret <=0 )) { + ret = ret ?: -EIO ;break ; }
fs/netfs/iterator.c ssize_t netfs_extract_user_iter(struct i · line 106
Quoted 10 lines
fs/netfs/iterator.c +7
-0@@ -97,6 +97,13 @@ ssize_t netfs_extract_user_iter(struct i npages += cur_npages; } +if (ret <0 && (ret == -ENOMEM || npages ==0 )) { +for (i =0 ; i < npages; i++) +unpin_user_page (bv[i].bv_page); +kvfree (bv); +return ret; + } +
I have run an AI assisted backport review and it spotted an issue: I have taken a look and the issues goes like:
Upstream has:
ssize_t ret = 0;
...
if (ret < 0 && (ret == -ENOMEM || npages == 0)) {
for (i = 0; i < npages; i++)
unpin_user_page(bv[i].bv_page);
kvfree(bv);
return ret;
}6.12.y has:
ssize_t ret;
...
if (ret < 0 && (ret == -ENOMEM || npages == 0)) {
for (i = 0; i < npages; i++)
unpin_user_page(bv[i].bv_page);
kvfree(bv);
return ret;
}I think 6.12.y misses commit: 7e3d8db899d5 ("netfs: Fix potential uninitialised var in netfs_extract_user_iter()") so backport might not be complete, thoughts ?
thanks,
Harshit
Quoted 6 lines
fs/netfs/iterator.c +0
-0iov_iter_bvec (new, orig->data_source, bv, npages, orig_len - count);return npages; }
Greg Kroah-Hartman
maintainerRe: [PATCH 6.12 505/666] sched/psi: fix race between file release and pressure write
In reply to Harshit MogalapalliQuoted 191 lines · Harshit Mogalapalli
Hi Greg/Sasha,
Quoted 140 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
[ Upstream commit
a5b98009f16d8a5fb4a8ff9a193f5735515c38fa]A potential race condition exists between pressure write and cgroup file release regarding the priv member of struct
kernfs_open_file, which triggers the uaf reported in [1].Consider the following scenario involving execution on two separate CPUs:
CPU0 CPU1 ==== ==== vfs_rmdir() kernfs_iop_rmdir() cgroup_rmdir() cgroup_kn_lock_live() cgroup_destroy_locked() cgroup_addrm_files() cgroup_rm_file() kernfs_remove_by_name() kernfs_remove_by_name_ns() vfs_write() __kernfs_remove() new_sync_write() kernfs_drain() kernfs_fop_write_iter() kernfs_drain_open_files() cgroup_file_write() kernfs_release_file() pressure_write() cgroup_file_release() ctx = of->priv; kfree(ctx);
of->priv= NULL;cgroup_kn_unlock()
cgroup_kn_lock_live()
cgroup_get(cgrp)
cgroup_kn_unlock()
if (ctx->psi.trigger) // here, trigger uaf for ctx, that isof->privThe
cgroup_rmdir()is protected by thecgroup_mutex, it also safeguards the memory deallocation ofof->privperformed withincgroup_file_release(). However, the operations involvingof->privexecuted withinpressure_write()are not entirely covered by the protection ofcgroup_mutex. Consequently, if the code inpressure_write(), specifically the section handling the ctx variable executes aftercgroup_file_release()has completed, a uaf vulnerability involvingof->privis triggered.Therefore, the issue can be resolved by extending the scope of the
cgroup_mutexlock withinpressure_write()to encompass all code paths involvingof->priv, thereby properly synchronizing the race condition occurring betweencgroup_file_release()andpressure_write().And, if an live kn lock can be successfully acquired while executing the pressure write operation, it indicates that the cgroup deletion process has not yet reached its final stage; consequently, the priv pointer within
open_filecannot be NULL. Therefore, the operation to retrieve the ctx value must be moved to a point *after* the live kn lock has been successfully acquired.In another situation, specifically after entering
cgroup_kn_lock_live()but before acquiringcgroup_mutex, there exists a different class of race condition:CPU0: write memory.pressure CPU1: write cgroup.pressure=0
=========================== =============================
kernfs_fop_write_iter()
kernfs_get_active_of(of)
pressure_write()cgroup_kn_lock_live(memory.pressure) cgroup_tryget(cgrp) kernfs_break_active_protection(kn) ... blocks on cgroup_mutex cgroup_pressure_write() cgroup_kn_lock_live(cgroup.pressure) cgroup_file_show(memory.pressure, false) kernfs_show(false) kernfs_drain_open_files() cgroup_file_release(of) kfree(ctx) of->priv = NULL cgroup_kn_unlock() ... acquires cgroup_mutex ctx = of->priv; // may now be NULL if (ctx->psi.trigger) // NULL dereferenceConsequently, there is a possibility that
of->privis NULL, the pressure write needs to check for this.Now that the scope of the
cgroup_mutexhas been expanded, the original explicit cgroup_get/put operations are no longer necessary, this is because acquiring/releasing the live kn lock inherently executes a cgroup get/put operation.[1]
BUG: KASAN: slab-use-after-free in pressure_write+0xa4/0x210 kernel/cgroup/cgroup.c:4011 Call Trace: pressure_write+0xa4/0x210 kernel/cgroup/cgroup.c:4011 cgroup_file_write+0x36f/0x790 kernel/cgroup/cgroup.c:4311 kernfs_fop_write_iter+0x3b0/0x540 fs/kernfs/file.c:352 Allocated by task 9352: cgroup_file_open+0x90/0x3a0 kernel/cgroup/cgroup.c:4256 kernfs_fop_open+0x9eb/0xcb0 fs/kernfs/file.c:724 do_dentry_open+0x83d/0x13e0 fs/open.c:949 Freed by task 9353: cgroup_file_release+0xd6/0x100 kernel/cgroup/cgroup.c:4283 kernfs_release_file fs/kernfs/file.c:764 [inline] kernfs_drain_open_files+0x392/0x720 fs/kernfs/file.c:834 kernfs_drain+0x470/0x600 fs/kernfs/dir.c:525Fixes 0e94682b73bf ("psi: introduce psi monitor")Reported-by [email protected]Tested-by [email protected]Signed-off-by Edward Adam Davis <[email protected]>Reviewed-by Chen Ridong <[email protected]>Signed-off-by Tejun Heo <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- kernel/cgroup/cgroup.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)kernel/cgroup/cgroup.c +2
-1@@ -3876,33 +3876,41 @@ static int cgroup_cpu_pressure_show(struct seq_file *seq, void *v)static ssize_t pressure_write (struct kernfs_open_file *of,char *buf,size_t nbytes,enum psi_res res) { -struct cgroup_file_ctx *ctx = of->priv; +struct cgroup_file_ctx *ctx;struct psi_trigger *new;struct cgroup *cgrp;struct psi_group *psi; +ssize_t ret =0 ;kernel/cgroup/cgroup.c static int cgroup_cpu_pressure_show(struct seq_file *seq, void *v) · line 3891
Quoted 10 lines
kernel/cgroup/cgroup.c +5
-2cgrp =cgroup_kn_lock_live (of->kn, false);if (!cgrp)return -ENODEV ; -cgroup_get (cgrp); -cgroup_kn_unlock (of->kn); + ctx = of->priv; +if (!ctx) { + ret = -ENODEV ; + goto out_unlock; + }I have run an AI assisted backport review and it spotted an issue: I have taken a look and the issues goes like:
Upstream has:
static void
cgroup_file_release(struct kernfs_open_file *of){ struct cftype *cft = of_cft(of); struct cgroup_file_ctx *ctx = of->priv; if (cft->release) cft->release(of); put_cgroup_ns(ctx->ns); kfree(ctx); of->priv = NULL; }On 6.12.y:
static void
cgroup_file_release(struct kernfs_open_file *of){ struct cftype *cft = of_cft(of); struct cgroup_file_ctx *ctx = of->priv; if (cft->release) cft->release(of); put_cgroup_ns(ctx->ns); kfree(ctx); }On 6.12.y,
cgroup_file_release()frees ctx but does not clearof->priv. The posted backport addsctx = of->priv; if (!ctx)
Quoted 8 lines
in
pressure_write(), but that only works if release turnsof->privinto NULL. In thepressure_write()vscgroup_pressure_write()race from the commit message, 6.12.y still leaves a dangling pointer there, so this backport alone is incomplete and can still hit UAF.So upstream has commit:
94a4acfec146("cgroup/psi: Setof->privto NULL upon file release") which might be needed here as well, without that I would suggest a drop.
Dropped from 6.12 and older, thanks.
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH 6.12 634/666] netfs: fix error handling in netfs_extract_user_iter()
In reply to Harshit MogalapalliQuoted 94 lines · Harshit Mogalapalli
Hi Greg/Sasha,
Quoted 52 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit
0aad5704c6b4d14007d4eab15883e8524e4310f4upstream.In
netfs_extract_user_iter(), ifiov_iter_extract_pages()failed to extract user pages, bail out on-ENOMEM, otherwise return the error code only if @npages == 0, allowing short DIO reads and writes to be issued.This fixes mmapstress02 from LTP tests against CIFS.
Fixes 85dd2c8ff368 ("netfs: Add a function to extract a UBUF or IOVEC into a BVEC iterator")Reported-by Xiaoli Feng <[email protected]>Signed-off-by Paulo Alcantara (Red Hat) <[email protected]>Signed-off-by David Howells <[email protected]>Signed-off-by Christian Brauner <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- fs/netfs/iterator.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)fs/netfs/iterator.c +3
-3@@ -22,7 +22,7 @@* * Extract the page fragments from the given amount of the source iterator and * build up a second iterator that refers to all of those bits. This allows -* the original iterator to disposed of. +* the original iterator to be disposed of. * * @extraction_flags can have ITER_ALLOW_P2PDMA set to request peer-to-peer DMA be * allowed on the pages extracted. @@ -67,8 +67,8 @@ ssize_t netfs_extract_user_iter(struct i ret =iov_iter_extract_pages (orig, &pages, count, max_pages - npages, extraction_flags, &offset); -if (ret <0 ) { -pr_err ("Couldn't get user pages (rc=%zd)\n" , ret); +if (unlikely (ret <=0 )) { + ret = ret ?: -EIO ;break ; }fs/netfs/iterator.c ssize_t netfs_extract_user_iter(struct i · line 105
Quoted 9 lines
fs/netfs/iterator.c +7
-0@@ -97,6 +97,13 @@ ssize_t netfs_extract_user_iter(struct i npages += cur_npages; } +if (ret <0 && (ret == -ENOMEM || npages ==0 )) { +for (i =0 ; i < npages; i++) +unpin_user_page (bv[i].bv_page); +kvfree (bv); +return ret; + } +I have run an AI assisted backport review and it spotted an issue: I have taken a look and the issues goes like:
Upstream has:
ssize_tret = 0;...
if (ret < 0 && (ret == -ENOMEM || npages == 0)) { for (i = 0; i < npages; i++) unpin_user_page(bv[i].bv_page); kvfree(bv); return ret; }6.12.y has:
ssize_tret;...
if (ret < 0 && (ret == -ENOMEM || npages == 0)) { for (i = 0; i < npages; i++) unpin_user_page(bv[i].bv_page); kvfree(bv); return ret; }
Quoted 3 lines
I think 6.12.y misses commit:
7e3d8db899d5("netfs: Fix potential uninitialised var innetfs_extract_user_iter()") so backport might not be complete, thoughts ?
Now applied, thanks.
greg k-h
Re: [PATCH 6.12 375/666] perf tool_pmu: Factor tool events into their own PMU
In reply to Greg Kroah-Hartmanhi Greg,
Quoted 8 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit
240505b2d0adcdc8fd018117e88dc27b09734735]
Quoted 8 lines
Rather than treat tool events as a special kind of event, create a tool only PMU where the events/aliases match the existing
duration_time,user_timeandsystem_timeevents. Remove special parsing and printing support for the tool events, but add function calls for when PMU functions are called on atool_pmu.Move the tool PMU code in evsel into
tool_pmu.cto better encapsulate the tool event behavior in that file.
While building now a complete set of packages for Debian for 6.12.91 where perf tools are included as well, I noticed that now the builds fails. In fact in v6.12.91
$ cd tools $ LC_ALL=C.UTF-8 ARCH=x86 make perf
fails with:
[...]
CC util/stat.outil/tool_pmu.c: In function ‘tool_pmu__config_term’:util/tool_pmu.c:62:49: error: implicit declaration of function ‘parse_events__term_type_str’; did you mean ‘parse_events_term__str’? [-Wimplicit-function-declaration]
62 | parse_events__term_type_str(term->type_term),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| parse_events_term__str
util/tool_pmu.c:61:79: error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Werror=format=]
61 | "unexpected tool event term (%s) %s",
| ~^
| |
| char *
| %d
62 | parse_events__term_type_str(term->type_term),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| int
cc1: all warnings being treated as errors
CC util/stat-shadow.o
LD util/hisi-ptt-decoder/perf-util-in.o
CC util/stat-display.omake[5]: *** [/home/build/linux-stable-rc/tools/build/Makefile.build:105: util/tool_pmu.o] Error 1 make[5]: *** Waiting for unfinished jobs....
CC util/perf_api_probe.o
LD util/perf-regs-arch/perf-util-in.outil/cgroup.c: In function ‘evlist__expand_cgroup’:util/cgroup.c:498:32: error: ‘struct evsel’ has no member named ‘first_wildcard_match’
498 | if (pos->first_wildcard_match)
| ^~util/cgroup.c:499:38: error: ‘struct evsel’ has no member named ‘first_wildcard_match’
499 | evsel->first_wildcard_match = pos->first_wildcard_match->priv;
| ^~util/cgroup.c:499:66: error: ‘struct evsel’ has no member named ‘first_wildcard_match’
499 | evsel->first_wildcard_match = pos->first_wildcard_match->priv;
| ^~
make[5]: *** [/home/build/linux-stable-rc/tools/build/Makefile.build:105: util/cgroup.o] Error 1
LD util/arm-spe-decoder/perf-util-in.o LD ui/browsers/perf-ui-in.o LD tests/workloads/perf-test-in.o LD ui/perf-ui-in.o LD perf-ui-in.o AR libperf-ui.a LD tests/perf-test-in.o LD perf-test-in.o AR libperf-test.a LD util/scripting-engines/perf-util-in.o LD util/intel-pt-decoder/perf-util-in.o LD perf-in.o
make[4]: *** [/home/build/linux-stable-rc/tools/build/Makefile.build:162: util] Error 2 make[3]: *** [Makefile.perf:789: perf-util-in.o] Error 2
make[3]: *** Waiting for unfinished jobs....
CC pmu-events/pmu-events.o
LD pmu-events/pmu-events-in.o
make[2]: *** [Makefile.perf:292: sub-make] Error 2
make[1]: *** [Makefile:76: all] Error 2
make: *** [Makefile:93: perf] Error 2
Regards,
Salvatore
Re: [PATCH 6.12 375/666] perf tool_pmu: Factor tool events into their own PMU
Quoted 85 lines · Salvatore Bonaccorso
hi Greg,
Quoted 8 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit
240505b2d0adcdc8fd018117e88dc27b09734735]Quoted 8 lines
Rather than treat tool events as a special kind of event, create a tool only PMU where the events/aliases match the existing
duration_time,user_timeandsystem_timeevents. Remove special parsing and printing support for the tool events, but add function calls for when PMU functions are called on atool_pmu.Move the tool PMU code in evsel into
tool_pmu.cto better encapsulate the tool event behavior in that file.While building now a complete set of packages for Debian for 6.12.91 where perf tools are included as well, I noticed that now the builds fails. In fact in v6.12.91
$ cd tools $ LC_ALL=C.UTF-8 ARCH=x86 make perffails with:
[...]
CCutil/stat.outil/tool_pmu.c: In function ‘tool_pmu__config_term’:util/tool_pmu.c:62:49: error: implicit declaration of function ‘parse_events__term_type_str’; did you mean ‘parse_events_term__str’? [-Wimplicit-function-declaration]62 | parse_events__term_type_str(term->type_term), | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ | parse_events_term__str util/tool_pmu.c:61:79: error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Werror=format=] 61 | "unexpected tool event term (%s) %s", | ~^ | | | char * | %d 62 | parse_events__term_type_str(term->type_term), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | int cc1: all warnings being treated as errors CC util/stat-shadow.o LD util/hisi-ptt-decoder/perf-util-in.o CC util/stat-display.omake[5]: *** [
/home/build/linux-stable-rc/tools/build/Makefile.build:105:util/tool_pmu.o] Error 1 make[5]: *** Waiting for unfinished jobs....
CCutil/perf_api_probe.o
LDutil/perf-regs-arch/perf-util-in.outil/cgroup.c: In function ‘evlist__expand_cgroup’:util/cgroup.c:498:32: error: ‘struct evsel’ has no member named ‘first_wildcard_match’
498 | if (pos->first_wildcard_match)
| ^~util/cgroup.c:499:38: error: ‘struct evsel’ has no member named ‘first_wildcard_match’
499 |evsel->first_wildcard_match=pos->first_wildcard_match->priv;
| ^~util/cgroup.c:499:66: error: ‘struct evsel’ has no member named ‘first_wildcard_match’
499 |evsel->first_wildcard_match=pos->first_wildcard_match->priv;
| ^~
make[5]: *** [/home/build/linux-stable-rc/tools/build/Makefile.build:105:util/cgroup.o] Error 1LD util/arm-spe-decoder/perf-util-in.o LD ui/browsers/perf-ui-in.o LD tests/workloads/perf-test-in.o LD ui/perf-ui-in.o LD perf-ui-in.o AR libperf-ui.a LD tests/perf-test-in.o LD perf-test-in.o AR libperf-test.a LD util/scripting-engines/perf-util-in.o LD util/intel-pt-decoder/perf-util-in.o LD perf-in.omake[4]: *** [
/home/build/linux-stable-rc/tools/build/Makefile.build:162: util] Error 2 make[3]: *** [Makefile.perf:789: perf-util-in.o] Error 2
make[3]: *** Waiting for unfinished jobs....
CCpmu-events/pmu-events.o
LDpmu-events/pmu-events-in.o
make[2]: *** [Makefile.perf:292: sub-make] Error 2
make[1]: *** [Makefile:76: all] Error 2
make: *** [Makefile:93: perf] Error 2
Quoted 2 lines
Regards,
Salvatore
Second this - moreover, because of the other commits introduced in tools/perf as of 6.12.91, it's not possible to revert just this one commit without other conflicts.
Cheers,
Tyler
Re: [PATCH 6.12 375/666] perf tool_pmu: Factor tool events into their own PMU
Hello,
Quoted 86 lines · Tyler Stachecki
Quoted 85 lines · Salvatore Bonaccorso
hi Greg,
Quoted 8 lines · Greg Kroah-Hartman
6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit
240505b2d0adcdc8fd018117e88dc27b09734735]Quoted 8 lines
Rather than treat tool events as a special kind of event, create a tool only PMU where the events/aliases match the existing
duration_time,user_timeandsystem_timeevents. Remove special parsing and printing support for the tool events, but add function calls for when PMU functions are called on atool_pmu.Move the tool PMU code in evsel into
tool_pmu.cto better encapsulate the tool event behavior in that file.While building now a complete set of packages for Debian for 6.12.91 where perf tools are included as well, I noticed that now the builds fails. In fact in v6.12.91
$ cd tools $ LC_ALL=C.UTF-8 ARCH=x86 make perffails with:
[...]
CCutil/stat.outil/tool_pmu.c: In function ‘tool_pmu__config_term’:util/tool_pmu.c:62:49: error: implicit declaration of function ‘parse_events__term_type_str’; did you mean ‘parse_events_term__str’? [-Wimplicit-function-declaration]62 | parse_events__term_type_str(term->type_term), | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ | parse_events_term__str util/tool_pmu.c:61:79: error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Werror=format=] 61 | "unexpected tool event term (%s) %s", | ~^ | | | char * | %d 62 | parse_events__term_type_str(term->type_term), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | int cc1: all warnings being treated as errors CC util/stat-shadow.o LD util/hisi-ptt-decoder/perf-util-in.o CC util/stat-display.omake[5]: *** [
/home/build/linux-stable-rc/tools/build/Makefile.build:105:util/tool_pmu.o] Error 1 make[5]: *** Waiting for unfinished jobs....
CCutil/perf_api_probe.o
LDutil/perf-regs-arch/perf-util-in.outil/cgroup.c: In function ‘evlist__expand_cgroup’:util/cgroup.c:498:32: error: ‘struct evsel’ has no member named ‘first_wildcard_match’
498 | if (pos->first_wildcard_match)
| ^~util/cgroup.c:499:38: error: ‘struct evsel’ has no member named ‘first_wildcard_match’
499 |evsel->first_wildcard_match=pos->first_wildcard_match->priv;
| ^~util/cgroup.c:499:66: error: ‘struct evsel’ has no member named ‘first_wildcard_match’
499 |evsel->first_wildcard_match=pos->first_wildcard_match->priv;
| ^~
make[5]: *** [/home/build/linux-stable-rc/tools/build/Makefile.build:105:util/cgroup.o] Error 1LD util/arm-spe-decoder/perf-util-in.o LD ui/browsers/perf-ui-in.o LD tests/workloads/perf-test-in.o LD ui/perf-ui-in.o LD perf-ui-in.o AR libperf-ui.a LD tests/perf-test-in.o LD perf-test-in.o AR libperf-test.a LD util/scripting-engines/perf-util-in.o LD util/intel-pt-decoder/perf-util-in.o LD perf-in.omake[4]: *** [
/home/build/linux-stable-rc/tools/build/Makefile.build:162: util] Error 2 make[3]: *** [Makefile.perf:789: perf-util-in.o] Error 2
make[3]: *** Waiting for unfinished jobs....
CCpmu-events/pmu-events.o
LDpmu-events/pmu-events-in.o
make[2]: *** [Makefile.perf:292: sub-make] Error 2
make[1]: *** [Makefile:76: all] Error 2
make: *** [Makefile:93: perf] Error 2
Quoted 6 lines
Quoted 2 lines
Regards,
SalvatoreSecond this - moreover, because of the other commits introduced in
tools/perfas of 6.12.91, it's not possible to revert just this one commit without other conflicts.
I don't think it's meant to be in the stable tree. Maybe need to drop this and later patches depend on it.
Thanks,
Namhyung