6.6.160-rc1 review
Subsystems (12)
Greg Kroah-Hartman
maintainerPATCH 96/1674 scsi: qla2xxx: Fix soft lockup polling continuation IOCB signature
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nilesh Javali <[email protected]>
[ Upstream commit d7e3fa7d06bf7fcaac186d3c4d635caac166d36c ]
qla27xx_copy_multiple_pkt() and qla27xx_copy_fpin_pkt() poll rsp_q->ring_ptr->signature for RESPONSE_PROCESSED (0xDEADDEAD) to decide whether the next continuation IOCB has arrived, spinning on cpu_relax() without advancing the ring or decrementing the entry count while it has not. response_t::signature lives at byte offset 60, but a continuation IOCB (sts_cont_entry_t / struct sts_cont_entry_ext) carries raw FC frame payload at that offset (data[56..59]). A received frame whose payload bytes happen to equal 0xDEADDEAD is therefore misread as "not yet arrived", and the loop spins forever in interrupt/DPC context, causing a CPU soft lockup.
The poll is also unnecessary: callers of qla27xx_copy_multiple_pkt() (PT_LS4_UNSOL and the NVMe purls path) already gate on qla_chk_cont_iocb_avail(), which guarantees all entry_count IOCBs are present before copying begins. The sibling helper __qla_copy_purex_to_buffer() already drops the signature poll and relies on the entry_type == STATUS_CONT_TYPE guard instead.
Remove the signature busy-wait from both helpers, keeping the entry_type guard, and gate the FPIN path with qla_chk_cont_iocb_avail() so it defers and re-processes on the next interrupt once all continuation IOCBs have arrived, mirroring the ELS_AUTH_ELS and PT_LS4_UNSOL arms. With this the signature field is never read on a continuation IOCB, eliminating the payload-aliasing lockup.
--- drivers/scsi/qla2xxx/qla_isr.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/scsi/qla2xxx/qla_isr.c +16 -17
@@ -921,14 +921,6 @@ qla27xx_copy_multiple_pkt(struct scsi_qla_host *vha, void **pkt, do { while ((total_bytes > 0) && (entry_count_remaining > 0)) { - if (rsp_q->ring_ptr->signature == RESPONSE_PROCESSED) { - ql_dbg(ql_dbg_async, vha, 0x5084, - "Ran out of IOCBs, partial data 0x%x\n", - buffer_copy_offset); - cpu_relax(); - continue; - } - new_pkt = (sts_cont_entry_t *)rsp_q->ring_ptr; *pkt = new_pkt;
@@ -1205,14 +1197,6 @@ qla27xx_copy_fpin_pkt(struct scsi_qla_host *vha, void **pkt, do { while ((total_bytes > 0) && (entry_count_remaining > 0)) { - if (rsp_q->ring_ptr->signature == RESPONSE_PROCESSED) { - ql_dbg(ql_dbg_async, vha, 0x5084, - "Ran out of IOCBs, partial data 0x%x\n", - buffer_copy_offset); - cpu_relax(); - continue; - } - new_pkt = (sts_cont_entry_t *)rsp_q->ring_ptr; *pkt = new_pkt;
@@ -4148,9 +4132,24 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha, "SCM not active for this port\n");break ; } +if (qla_chk_cont_iocb_avail (vha, rsp, + (response_t *)pkt, rsp_in)) { +/* +* ring_ptr and ring_index were +* pre-incremented above. Reset them +* back to current. Wait for next +* interrupt with all IOCBs to arrive +* and re-process. +*/ + rsp->ring_ptr = (response_t *)pkt; + rsp->ring_index = cur_ring_index; + +ql_dbg (ql_dbg_init, vha,0x5095 , +"Defer processing FPIN...\n" ); +return ; + } pure_item =qla27xx_copy_fpin_pkt (vha, (void **)&pkt, &rsp); -__update_rsp_in (is_shadow_hba, rsp, rsp_in);if (!pure_item)break ; qla24xx_queue_purex_item(vha, pure_item,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 97/1674 f2fs: limit recovery filename logging to stored length
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenjie Qi <[email protected]>
[ Upstream commit 01027b2fcb74dade59fb833b51023f6593b6a9a2 ]
F2FS stores recovery filenames as a length plus a fixed-size i_name buffer. The buffer is not NUL-terminated, but recover_inode() and recover_dentry() print it with %s.
For a 255-byte filename, recovery logging can read past i_name into the following raw inode fields.
Print the name with a precision bounded by i_namelen and F2FS_NAME_LEN.
--- fs/f2fs/recovery.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)
fs/f2fs/recovery.c +22 -11
@@ -176,7 +176,8 @@ static int recover_dentry(struct inode *inode, struct page *ipage,struct inode *dir, *einode;struct fsync_inode_entry *entry;int err =0 ; -char *name; +const char *name; +int name_len; entry =get_fsync_inode (dir_list, pino);if (!entry) {
@@ -235,12 +236,16 @@ static int recover_dentry(struct inode *inode, struct page *ipage, out_put:f2fs_put_page (page,0 ); out: -if (file_enc_name (inode)) +if (file_enc_name (inode)) { name ="<encrypted>" ; -else + name_len =sizeof ("<encrypted>" ) -1 ; + }else { name = raw_inode->i_name; -f2fs_notice (F2FS_I_SB (inode),"%s: ino = %x, name = %s, dir = %lx, err = %d" , - __func__,ino_of_node (ipage), name, + name_len = min_t(unsigned int, le32_to_cpu(raw_inode->i_namelen), +F2FS_NAME_LEN ); + } +f2fs_notice (F2FS_I_SB (inode),"%s: ino = %x, name = %.*s, dir = %lx, err = %d" , + __func__,ino_of_node (ipage), name_len, name,IS_ERR (dir) ?0 : dir->i_ino, err);return err; }
@@ -287,7 +292,8 @@ static void recover_inline_flags(struct inode *inode, struct f2fs_inode *ri)static int recover_inode (struct inode *inode,struct page *page) {struct f2fs_inode *raw =F2FS_INODE (page); -char *name; +const char *name; +int name_len;int err; inode->i_mode =le16_to_cpu (raw->i_mode);
@@ -336,13 +342,18 @@ static int recover_inode(struct inode *inode, struct page *page)f2fs_mark_inode_dirty_sync (inode, true); -if (file_enc_name (inode)) +if (file_enc_name (inode)) { name ="<encrypted>" ; -else - name =F2FS_INODE (page)->i_name; + name_len =sizeof ("<encrypted>" ) -1 ; + }else { + name = raw->i_name; + name_len = min_t(unsigned int, le32_to_cpu(raw->i_namelen), +F2FS_NAME_LEN ); + } -f2fs_notice (F2FS_I_SB (inode),"recover_inode: ino = %x, name = %s, inline = %x" , -ino_of_node (page), name, raw->i_inline); +f2fs_notice (F2FS_I_SB (inode),"%s: ino = %x, name = %.*s, inline = %x" , + __func__,ino_of_node (page), name_len, name, + raw->i_inline);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 98/1674 f2fs: fix dentry folio leak in find_in_level
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanghui Yang <[email protected]>
[ Upstream commit cca7d3e30bf30333314e31bc70b9a739f1342167 ]
find_in_level() gets a dentry folio with f2fs_find_data_folio() before calling find_in_block(). If find_in_block() returns an error, the function stores the error in res_folio and breaks out of the loop without dropping the dentry folio.
This leaks the folio reference on the find_in_block() error path. Drop the dentry folio before returning the error to the caller.
--- fs/f2fs/dir.c | 1 + 1 file changed, 1 insertion(+)
fs/f2fs/dir.c +1 -0
@@ -341,6 +341,7 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir, de =find_in_block (dir, dentry_page, fname, &max_slots, use_hash);if (IS_ERR (de)) { +f2fs_put_page (dentry_page,0 ); *res_page =ERR_CAST (de); de =NULL ;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 99/1674 drm/sysfb: simpledrm: Improve panel-size validation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
[ Upstream commit 3a75a0761914d01c7362adf1f906cc1d1762c189 ]
Validate the panel size from the device-tree node against the limitations of struct drm_display_mode. The type only stores sizes in 16-bit fields. Fail transparently on errors; do not warn.
v3:
- move comments to a more prominent place (Thierry) v2:
- only use initialized values in debugging output (Sashiko)
--- drivers/gpu/drm/tiny/simpledrm.c | 49 ++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-)
drivers/gpu/drm/tiny/simpledrm.c +46 -3
@@ -210,6 +210,39 @@ simplefb_get_memory_of(struct drm_device *dev, struct device_node *of_node)return res; } +static int __simplefb_get_panel_size_mm_of (struct drm_device *dev, +struct device_node *of_panel_node, +const char *name) +{ +int ret; +u32 value; + + ret =of_property_read_u32 (of_panel_node, name, &value); +if (ret) { +drm_dbg (dev,"simplefb: cannot parse panel %s: error %d\n" , + name, ret); +return ret; + }else if (value >U16_MAX ) { +drm_dbg (dev,"simplefb: panel %s of %u exceeds maximum value\n" , + name, value); +return -EINVAL ; + } + +return value; +} + +static int simplefb_get_panel_width_mm_of (struct drm_device *dev, +struct device_node *of_panel_node) +{ +return __simplefb_get_panel_size_mm_of (dev, of_panel_node,"width-mm" ); +} + +static int simplefb_get_panel_height_mm_of (struct drm_device *dev, +struct device_node *of_panel_node) +{ +return __simplefb_get_panel_size_mm_of (dev, of_panel_node,"height-mm" ); +} +/* * Simple Framebuffer device */
@@ -625,7 +658,7 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,struct simpledrm_device *sdev;struct drm_device *dev;int width, height, stride; -int width_mm =0 , height_mm =0 ; +u16 width_mm =0 , height_mm =0 ;struct device_node *panel_node;const struct drm_format_info *format;struct resource *res, *mem =NULL ;
@@ -685,8 +718,18 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,return ERR_CAST (mem); panel_node =of_parse_phandle (of_node,"panel" ,0 );if (panel_node) { -simplefb_read_u32_of (dev, panel_node,"width-mm" , &width_mm); -simplefb_read_u32_of (dev, panel_node,"height-mm" , &height_mm); +/* +* Ignore errors from parsing the physical panel +* size. Using the pre-initialized sizes of 0 will +* make drm_sysfb_mode() calculate a default physical +* size based on a resolution of 96 dpi. +*/ + ret =simplefb_get_panel_width_mm_of (dev, panel_node); +if (ret >0 ) + width_mm = ret; + ret =simplefb_get_panel_height_mm_of (dev, panel_node); +if (ret >0 ) + height_mm = ret;of_node_put (panel_node); } }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 100/1674 drm/sysfb: simpledrm: Improve stride validation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
[ Upstream commit df6533f11688aa30be3bb883c7637f4ffdbb7cbd ]
Validate the computed stride against the maximum value INT_MAX.
--- drivers/gpu/drm/tiny/simpledrm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/tiny/simpledrm.c +8 -2
@@ -737,9 +737,15 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,return ERR_PTR (-ENODEV ); }if (!stride) { - stride =drm_format_info_min_pitch (format,0 , width); -if (drm_WARN_ON (dev, !stride)) +u64 pitch =drm_format_info_min_pitch (format,0 , width); + +if (drm_WARN_ON (dev, !pitch)) { +return ERR_PTR (-EINVAL );/* driver bug */ + }else if (pitch >INT_MAX ) { +drm_warn (dev,"stride of %llu exceeds maximum\n" , pitch);return ERR_PTR (-EINVAL ); + } + stride = pitch; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 101/1674 drm/sysfb: ofdrm: Fix integer overflow in fb_size calculation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shixiong Ou <[email protected]>
[ Upstream commit c6f48e59ece0123f6a11527ad4d89b21c2d65b87 ]
The framebuffer size calculation fb_size = linebytes * height can overflow when both values are large (e.g., 46341 * 46341 > INT_MAX). Since linebytes and height are both int types, the multiplication is performed as int * int, which results in undefined behavior on overflow.
Use check_mul_overflow() to detect and prevent this overflow, consistent with the approach used in simpledrm.c and corebootdrm.c.
--- drivers/gpu/drm/tiny/ofdrm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/tiny/ofdrm.c +5 -1
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only #include <linux/of_address.h> +#include <linux/overflow.h> #include <linux/pci.h> #include <linux/platform_device.h>
@@ -1169,7 +1170,10 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv,return ERR_PTR (-EINVAL ); } - fb_size = linebytes * height; +if (check_mul_overflow (linebytes, height, &fb_size)) { +drm_err (dev,"framebuffer size exceeds maximum\n" ); +return ERR_PTR (-EINVAL ); + }/* * Try to figure out the address of the framebuffer. Unfortunately, Open
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 102/1674 drm/sysfb: ofdrm: Fix is_avivo() constant comparison bug
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shixiong Ou <[email protected]>
[ Upstream commit 958f35cbb8955ca3fa439cd9f2092cb42414aa8c ]
The is_avivo() function has a logic error where it compares a constant to another constant instead of checking the device parameter:
(PCI_VENDOR_ID_ATI_R600 >= 0x9400)
--- drivers/gpu/drm/tiny/ofdrm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tiny/ofdrm.c +1 -1
@@ -233,7 +233,7 @@ static bool is_avivo(u32 vendor, u32 device)/* This will match most R5xx */ return (vendor ==PCI_VENDOR_ID_ATI ) && ((device >=PCI_VENDOR_ID_ATI_R520 && device <0x7800 ) || - (PCI_VENDOR_ID_ATI_R600 >=0x9400 )); + (device >=PCI_VENDOR_ID_ATI_R600 )); }static enum ofdrm_model display_get_model_of (struct drm_device *dev,struct device_node *of_node)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 103/1674 ipmr: account multicast table and route memory
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
[ Upstream commit b7ee18725f2292ab554aa96a101ae42d45f008bd ]
A netadmin in a user+net namespace can create many IPv4 and IPv6 multicast routing tables with MRT_TABLE and MRT6_TABLE. Each unseen id allocates an mr_table via the shared mr_table_alloc(), links it into the per-net list, and leaves it until netns teardown. Those objects were not charged to memcg, so the host unreclaimable slab grows with the table count.
Account mr_table allocations with GFP_KERNEL_ACCOUNT and mark the IPv4/IPv6 MFC caches SLAB_ACCOUNT. This matches the established handling of IP addresses, routes and alternate interface names.
Unresolved MFC entries are still allocated from softIRQ with GFP_ATOMIC and are not charged. They expire after 10 seconds and are bounded by the socket receive queue; see commit 0079ad8e8dc3 ("ipmr: remove hard code cache_resolve_queue_len limit").
--- net/ipv4/ipmr.c | 3 ++- net/ipv4/ipmr_base.c | 2 +- net/ipv6/ip6mr.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)
net/ipv4/ipmr.c +2 -1
@@ -3159,7 +3159,8 @@ int __init ip_mr_init(void) mrt_cachep =kmem_cache_create ("ip_mrt_cache" ,sizeof (struct mfc_cache ), -0 ,SLAB_HWCACHE_ALIGN |SLAB_PANIC , +0 ,SLAB_HWCACHE_ALIGN |SLAB_PANIC | +SLAB_ACCOUNT ,NULL ); err =register_pernet_subsys (&ipmr_net_ops);
net/ipv4/ipmr_base.c +1 -1
@@ -38,7 +38,7 @@ mr_table_alloc(struct net *net, u32 id,struct mr_table *mrt;int err; - mrt =kzalloc (sizeof (*mrt),GFP_KERNEL ); + mrt =kzalloc (sizeof (*mrt),GFP_KERNEL_ACCOUNT );if (!mrt)return ERR_PTR (-ENOMEM ); mrt->id = id;
net/ipv6/ip6mr.c +1 -1
@@ -1389,7 +1389,7 @@ int __init ip6_mr_init(void) mrt_cachep =kmem_cache_create ("ip6_mrt_cache" ,sizeof (struct mfc6_cache ), -0 ,SLAB_HWCACHE_ALIGN , +0 ,SLAB_HWCACHE_ALIGN |SLAB_ACCOUNT ,NULL );if (!mrt_cachep)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 104/1674 virtio-mmio: Remove virtqueue list from mmio device
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viresh Kumar <[email protected]>
[ Upstream commit 564a69ad90d15c782176e1a8c9e1c95661e1aed0 ]
The MMIO transport implementation creates a list of virtqueues for a virtio device, while the same is already available in the struct virtio_device.
Don't create a duplicate list, and use the other one instead.
While at it, fix the virtio_device_for_each_vq() macro to accept an argument like "&vm_dev->vdev" (which currently fails to build).
Message-Id: <3e56c6f74002987e22f364d883cbad177cd9ad9c.1747827066.git.viresh.kumar@linaro.org>
Stable-dep-of: d14d693adb05 ("virtio_mmio: disable IRQ wake before free_irq")
--- drivers/virtio/virtio_mmio.c | 52 +++--------------------------------- include/linux/virtio.h | 2 +- 2 files changed, 4 insertions(+), 50 deletions(-)
drivers/virtio/virtio_mmio.c +3 -49
@@ -65,7 +65,6 @@#include <linux/platform_device.h> #include <linux/pm.h> #include <linux/slab.h> -#include <linux/spinlock.h> #include <linux/virtio.h> #include <linux/virtio_config.h> #include <uapi/linux/virtio_mmio.h>
@@ -88,22 +87,8 @@ struct virtio_mmio_device {void __iomem *base;unsigned long version; - -/* a list of queues so we can dispatch IRQs */ -spinlock_t lock; -struct list_head virtqueues; -}; - -struct virtio_mmio_vq_info { -/* the actual virtqueue */ -struct virtqueue *vq; - -/* the list node for the virtqueues list */ -struct list_head node; }; - -/* Configuration interface */ static u64 vm_get_features (struct virtio_device *vdev)
@@ -300,9 +285,8 @@ static bool vm_notify_with_data(struct virtqueue *vq)static irqreturn_t vm_interrupt (int irq,void *opaque) {struct virtio_mmio_device *vm_dev = opaque; -struct virtio_mmio_vq_info *info; +struct virtqueue *vq;unsigned long status; -unsigned long flags;irqreturn_t ret =IRQ_NONE ;/* Read and acknowledge interrupts */
@@ -315,10 +299,8 @@ static irqreturn_t vm_interrupt(int irq, void *opaque) }if (likely (status &VIRTIO_MMIO_INT_VRING )) { -spin_lock_irqsave (&vm_dev->lock, flags); -list_for_each_entry (info, &vm_dev->virtqueues, node) - ret |=vring_interrupt (irq, info->vq); -spin_unlock_irqrestore (&vm_dev->lock, flags); +virtio_device_for_each_vq (&vm_dev->vdev, vq) + ret |=vring_interrupt (irq, vq); }return ret;
@@ -329,14 +311,8 @@ static irqreturn_t vm_interrupt(int irq, void *opaque)static void vm_del_vq (struct virtqueue *vq) {struct virtio_mmio_device *vm_dev =to_virtio_mmio_device (vq->vdev); -struct virtio_mmio_vq_info *info = vq->priv; -unsigned long flags;unsigned int index = vq->index; -spin_lock_irqsave (&vm_dev->lock, flags); -list_del (&info->node); -spin_unlock_irqrestore (&vm_dev->lock, flags); -/* Select and deactivate the queue */ writel (index, vm_dev->base +VIRTIO_MMIO_QUEUE_SEL );if (vm_dev->version ==1 ) {
@@ -347,8 +323,6 @@ static void vm_del_vq(struct virtqueue *vq) }vring_del_virtqueue (vq); - -kfree (info); }static void vm_del_vqs (struct virtio_device *vdev)
@@ -375,9 +349,7 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned int in {struct virtio_mmio_device *vm_dev =to_virtio_mmio_device (vdev);bool (*notify)(struct virtqueue *vq); -struct virtio_mmio_vq_info *info;struct virtqueue *vq; -unsigned long flags;unsigned int num;int err;
@@ -399,13 +371,6 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned int in goto error_available; } -/* Allocate and fill out our active queue description */ - info =kmalloc (sizeof (*info),GFP_KERNEL ); -if (!info) { - err = -ENOMEM ; - goto error_kmalloc; - } - num =readl (vm_dev->base +VIRTIO_MMIO_QUEUE_NUM_MAX );if (num ==0 ) { err = -ENOENT ;
@@ -463,13 +428,6 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned int inwritel (1 , vm_dev->base +VIRTIO_MMIO_QUEUE_READY ); } - vq->priv = info; - info->vq = vq; - -spin_lock_irqsave (&vm_dev->lock, flags); -list_add (&info->node, &vm_dev->virtqueues); -spin_unlock_irqrestore (&vm_dev->lock, flags); -return vq; error_bad_pfn:
@@ -481,8 +439,6 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned int inwritel (0 , vm_dev->base +VIRTIO_MMIO_QUEUE_READY );WARN_ON (readl (vm_dev->base +VIRTIO_MMIO_QUEUE_READY )); } -kfree (info); -error_kmalloc: error_available:return ERR_PTR (err); }
@@ -627,8 +583,6 @@ static int virtio_mmio_probe(struct platform_device *pdev) vm_dev->vdev.dev.release = virtio_mmio_release_dev; vm_dev->vdev.config = &virtio_mmio_config_ops; vm_dev->pdev = pdev; -INIT_LIST_HEAD (&vm_dev->virtqueues); -spin_lock_init (&vm_dev->lock); vm_dev->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (vm_dev->base)) {
include/linux/virtio.h +1 -1
@@ -158,7 +158,7 @@ void virtio_reset_device(struct virtio_device *dev);size_t virtio_max_dma_size (const struct virtio_device *vdev);#define virtio_device_for_each_vq (vdev, vq) \ - list_for_each_entry(vq, &vdev->vqs, list) + list_for_each_entry(vq, &(vdev)->vqs, list)/** * struct virtio_driver - operations for a virtio I/O driver
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 105/1674 virtio_mmio: disable IRQ wake before free_irq
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiong Weimin <[email protected]>
[ Upstream commit d14d693adb055e98ca705822ba6daebc18602d9a ]
When the DT node has "wakeup-source", vm_find_vqs() calls enable_irq_wake() on the shared IRQ, but vm_del_vqs() freed that IRQ without a matching disable_irq_wake(). That leaves a wake reference behind and can warn on later free_irq()/request_irq() cycles.
Record whether enable_irq_wake() succeeded, and disable it in vm_del_vqs() before free_irq().
Message-ID: <[email protected]>
--- drivers/virtio/virtio_mmio.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/virtio/virtio_mmio.c +13 -3
@@ -87,6 +87,9 @@ struct virtio_mmio_device {void __iomem *base;unsigned long version; + +/* True if enable_irq_wake() succeeded for the shared IRQ. */ +bool wake_irq_enabled; };/* Configuration interface */
@@ -329,11 +332,17 @@ static void vm_del_vqs(struct virtio_device *vdev) {struct virtio_mmio_device *vm_dev =to_virtio_mmio_device (vdev);struct virtqueue *vq, *n; +int irq =platform_get_irq (vm_dev->pdev,0 );list_for_each_entry_safe (vq, n, &vdev->vqs, list)vm_del_vq (vq); -free_irq (platform_get_irq (vm_dev->pdev,0 ), vm_dev); +if (vm_dev->wake_irq_enabled) { +disable_irq_wake (irq); + vm_dev->wake_irq_enabled = false; + } + +free_irq (irq, vm_dev); }static void vm_synchronize_cbs (struct virtio_device *vdev)
@@ -462,8 +471,9 @@ static int vm_find_vqs(struct virtio_device *vdev, unsigned int nvqs,if (err)return err; -if (of_property_read_bool (vm_dev->pdev->dev.of_node,"wakeup-source" )) -enable_irq_wake (irq); +if (of_property_read_bool (vm_dev->pdev->dev.of_node,"wakeup-source" ) && + !enable_irq_wake (irq)) + vm_dev->wake_irq_enabled = true;for (i =0 ; i < nvqs; ++i) {if (!names[i]) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 106/1674 net/sched: act_api: release all action references on NEWACTION failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xuanqiang Luo <[email protected]>
[ Upstream commit 478eb5abb51931a152abab068f8a717b7ff480fd ]
When a batched RTM_NEWACTION request replaces an existing action, tcf_idr_check_alloc() takes a temporary reference on it. If a later action fails to initialize, tcf_action_destroy() uses strict release semantics to clean up the actions initialized so far. For an action bound to a filter, the strict check returns -EPERM without dropping the temporary reference.
This error also makes tcf_action_destroy() return before releasing subsequent entries. Any new action initialized between the bound action and the failing entry is leaked together with its reserved IDR slot, preventing reuse of its index.
Use tcf_idr_release() to drop each reference held by the batch without rejecting bound actions. This allows cleanup to continue through all initialized entries and preserves the module reference release when an action is destroyed. Explicit action deletion and flushing retain their separate bind-count checks.
--- net/sched/act_api.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
net/sched/act_api.c +2 -7
@@ -1144,19 +1144,14 @@ EXPORT_SYMBOL(tcf_action_exec);int tcf_action_destroy (struct tc_action *actions[],int bind) { -const struct tc_action_ops *ops;struct tc_action *a;int ret =0 , i;for (i =0 ; i <TCA_ACT_MAX_PRIO && actions[i]; i++) { a = actions[i]; actions[i] =NULL ; - ops = a->ops; - ret =__tcf_idr_release (a, bind, true); -if (ret ==ACT_P_DELETED ) -module_put (ops->owner); -else if (ret <0 ) -return ret; +/* Drop our reference even if the action is still bound to a filter. */ + ret =tcf_idr_release (a, bind); }return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 107/1674 erofs: preserve LZMA decoders on resize failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil Gurudasani <[email protected]>
[ Upstream commit 617d0d8d199ba1790c94310fd75a22d01c97a8d6 ]
The pool-resize path frees each stream's old decoder before allocating its replacement. If an allocation fails after some streams have already been replaced, the failed stream is put back on the list with state == NULL. z_erofs_lzma_max_dictsize is still advanced as if the whole pool had been resized.
An existing LZMA mount can select the broken stream and pass NULL to xz_dec_microlzma_reset(). A retry at the same size also skip another resize attempt. Since the global maximum was advanced, thus, the invalid state is left unrepaired.
Allocate each replacement before freeing the old decoder, temporarily retaining one old decoder during allocation. Stop at the first failure and advance z_erofs_lzma_max_dictsize only after all streams satisfy the request.
Record each stream's dictionary capacity so retries can skip streams already enlarged before a partial failure.
--- fs/erofs/decompressor_lzma.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
fs/erofs/decompressor_lzma.c +14 -4
@@ -6,6 +6,7 @@struct z_erofs_lzma {struct z_erofs_lzma *next;struct xz_dec_microlzma *state; +unsigned int dict_size;struct xz_buf buf;u8 bounce[PAGE_SIZE ]; };
@@ -132,11 +133,19 @@ int z_erofs_load_lzma_config(struct super_block *sb, err =0 ;/* 2. walk each isolated stream and grow max dict_size if needed */ for (strm = head; strm; strm = strm->next) { +struct xz_dec_microlzma *state; + +if (strm->dict_size >= dict_size) +continue ; + state =xz_dec_microlzma_alloc (XZ_PREALLOC , dict_size); +if (!state) { + err = -ENOMEM ; +break ; + }if (strm->state)xz_dec_microlzma_end (strm->state); - strm->state =xz_dec_microlzma_alloc (XZ_PREALLOC , dict_size); -if (!strm->state) - err = -ENOMEM ; + strm->state = state; + strm->dict_size = dict_size; }/* 3. push back all to the global list and update max dict_size */
@@ -146,7 +155,8 @@ int z_erofs_load_lzma_config(struct super_block *sb,spin_unlock (&z_erofs_lzma_lock);wake_up_all (&z_erofs_lzma_wq); - z_erofs_lzma_max_dictsize = dict_size; +if (!err) + z_erofs_lzma_max_dictsize = dict_size;mutex_unlock (&lzma_resize_mutex);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 108/1674 erofs: add sysfs feature entry for xattr prefixes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jingbo Xu <[email protected]>
[ Upstream commit 839f075aabdf5c21048f9801b87c0b841dd3d064 ]
Let /sys/fs/erofs/features/xattr_prefixes advertise that this kernel supports the EROFS_FEATURE_INCOMPAT_XATTR_PREFIXES on-disk format.
--- Documentation/ABI/testing/sysfs-fs-erofs | 2 +- fs/erofs/sysfs.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-fs-erofs +1 -1
@@ -5,7 +5,7 @@ Description: Shows all enabled kernel features. Supported features: zero_padding, compr_cfgs, big_pcluster, chunked_file, device_table, compr_head2, sb_chksum, ztailpacking, - dedupe, fragments. + dedupe, fragments, xattr_prefixes. What: /sys/fs/erofs/<disk>/sync_decompress Date: November 2021
fs/erofs/sysfs.c +2 -0
@@ -78,6 +78,7 @@ EROFS_ATTR_FEATURE(sb_chksum);EROFS_ATTR_FEATURE (ztailpacking);EROFS_ATTR_FEATURE (fragments);EROFS_ATTR_FEATURE (dedupe); +EROFS_ATTR_FEATURE (xattr_prefixes);static struct attribute *erofs_feat_attrs[] = {ATTR_LIST (zero_padding),
@@ -90,6 +91,7 @@ static struct attribute *erofs_feat_attrs[] = {ATTR_LIST (ztailpacking),ATTR_LIST (fragments),ATTR_LIST (dedupe), +ATTR_LIST (xattr_prefixes),NULL , };ATTRIBUTE_GROUPS (erofs_feat);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 109/1674 mptcp: pm: drop match in userspace_pm_append_new_local_addr
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
[ Upstream commit 640e3d69d0bc70d7d3de34800a1640793262bd08 ]
The variable 'match' in mptcp_userspace_pm_append_new_local_addr() is a redundant one, and this patch drops it.
No need to define 'match' as 'struct mptcp_pm_addr_entry *' type. In this function, it's only used to check whether it's NULL. It can be defined as a Boolean one.
Also other variables 'addr_match' and 'id_match' make 'match' a redundant one, which can be replaced by directly checking 'addr_match && id_match'.
Stable-dep-of: f9f0068e8813 ("mptcp: pm: userspace: fix address ID overflow")
--- net/mptcp/pm_userspace.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
net/mptcp/pm_userspace.c +3 -8
@@ -40,7 +40,6 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, bool needs_id) {DECLARE_BITMAP (id_bitmap,MPTCP_PM_MAX_ADDR_ID +1 ); -struct mptcp_pm_addr_entry *match =NULL ;struct sock *sk = (struct sock *)msk;struct mptcp_pm_addr_entry *e;bool addr_match = false;
@@ -59,16 +58,12 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,if (addr_match && entry->addr.id ==0 && needs_id) entry->addr.id = e->addr.id; id_match = (e->addr.id == entry->addr.id); -if (addr_match && id_match) { - match = e; +if (addr_match || id_match)break ; - }else if (addr_match || id_match) { -break ; - }__set_bit (e->addr.id, id_bitmap); } -if (!match && !addr_match && !id_match) { +if (!addr_match && !id_match) {/* Memory for the entry is allocated from the * sock option buffer. */
@@ -86,7 +81,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,list_add_tail_rcu (&e->list, &msk->pm.userspace_pm_local_addr_list); msk->pm.local_addr_used++; ret = e->addr.id; - }else if (match) { + }else if (addr_match && id_match) { ret = entry->addr.id; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 110/1674 sock: add sock_kmemdup helper
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
[ Upstream commit 456cc675b6d4cadd4872a477d8976ff56eef4b6f ]
This patch adds the sock version of kmemdup() helper, named sock_kmemdup(), to duplicate the input "src" memory block using the socket's option memory buffer.
Stable-dep-of: f9f0068e8813 ("mptcp: pm: userspace: fix address ID overflow")
--- include/net/sock.h | 2 ++ net/core/sock.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)
include/net/sock.h +2 -0
@@ -1955,6 +1955,8 @@ static inline struct sk_buff *sock_alloc_send_skb(struct sock *sk, }void *sock_kmalloc (struct sock *sk,int size,gfp_t priority); +void *sock_kmemdup (struct sock *sk,const void *src, +int size,gfp_t priority);void sock_kfree_s (struct sock *sk,void *mem,int size);void sock_kzfree_s (struct sock *sk,void *mem,int size);void sk_send_sigurg (struct sock *sk);
net/core/sock.c +16 -0
@@ -2736,6 +2736,22 @@ void *sock_kmalloc(struct sock *sk, int size, gfp_t priority) }EXPORT_SYMBOL (sock_kmalloc); +/* +* Duplicate the input "src" memory block using the socket's +* option memory buffer. +*/ +void *sock_kmemdup (struct sock *sk,const void *src, +int size,gfp_t priority) +{ +void *mem; + + mem =sock_kmalloc (sk, size, priority); +if (mem) +memcpy (mem, src, size); +return mem; +} +EXPORT_SYMBOL (sock_kmemdup); +/* Free an option memory block. Note, we actually want the inline * here as this allows gcc to detect the nullify and fold away the * condition entirely.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 111/1674 mptcp: use sock_kmemdup for address entry
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
[ Upstream commit 52f83c0b5f857dbe24f66fc9a7f035523e9ffbc9 ]
Instead of using sock_kmalloc() to allocate an address entry "e" and then immediately duplicate the input "entry" to it, the newly added sock_kmemdup() helper can be used in mptcp_userspace_pm_append_new_local_addr() to simplify the code.
More importantly, the code "*e = *entry;" that assigns "entry" to "e" is not easy to implemented in BPF if we use the same code to implement an append_new_local_addr() helper of a BFP path manager. This patch avoids this type of memory assignment operation.
Stable-dep-of: f9f0068e8813 ("mptcp: pm: userspace: fix address ID overflow")
--- net/mptcp/pm_userspace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/mptcp/pm_userspace.c +1 -2
@@ -67,13 +67,12 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,/* Memory for the entry is allocated from the * sock option buffer. */ - e =sock_kmalloc (sk,sizeof (*e),GFP_ATOMIC ); + e =sock_kmemdup (sk, entry,sizeof (*entry),GFP_ATOMIC );if (!e) { ret = -ENOMEM ; goto append_err; } - *e = *entry;if (!e->addr.id && needs_id) e->addr.id = find_next_zero_bit(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 112/1674 mptcp: pm: userspace: fix address ID overflow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qing Luo <[email protected]>
[ Upstream commit f9f0068e8813d8c10d016b030fc3a320d0b6767c ]
When all MPTCP address IDs (1-255) are exhausted in the userspace PM, find_next_zero_bit() returns MPTCP_PM_MAX_ADDR_ID + 1 (256). This value overflows when stored in the u8 field e->addr.id, resulting in ID 0 being stored and the entry being incorrectly added to the list.
ID 0 is reserved for the initial connection in MPTCP, so this overflow can cause address conflicts.
Note: the in-kernel PM already has an 'endpoints == MPTCP_PM_MAX_ADDR_ID' check in mptcp_pm_nl_append_new_local_addr() that returns -ERANGE before reaching find_next_zero_bit(), preventing this overflow. So this fix only addresses the userspace PM path.
Check the find_next_zero_bit() result against MPTCP_PM_MAX_ADDR_ID and return -ENOSPC if all IDs are truly exhausted. Move the ID allocation check before the memory allocation so that the error path does not need to free the allocated entry.
--- net/mptcp/pm_userspace.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
net/mptcp/pm_userspace.c +14 -4
@@ -64,6 +64,19 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, }if (!addr_match && !id_match) { +unsigned int id; + +if (!entry->addr.id && needs_id) { + id =find_next_zero_bit (id_bitmap, +MPTCP_PM_MAX_ADDR_ID +1 ,1 ); +if (id >MPTCP_PM_MAX_ADDR_ID ) { + ret = -ENOSPC ; + goto append_err; + } + }else { + id = entry->addr.id; + } +/* Memory for the entry is allocated from the * sock option buffer. */
@@ -73,10 +86,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, goto append_err; } -if (!e->addr.id && needs_id) - e->addr.id =find_next_zero_bit (id_bitmap, -MPTCP_PM_MAX_ADDR_ID +1 , -1 ); + e->addr.id = id;list_add_tail_rcu (&e->list, &msk->pm.userspace_pm_local_addr_list); msk->pm.local_addr_used++; ret = e->addr.id;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 113/1674 mptcp: pm: reset retrans_time when ADD_ADDR entry is reused
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
[ Upstream commit f968190c0b42ea2004dc1426359a53ec365a7a37 ]
When an ADD_ADDR entry is reused, the timer is re-armed, because the goal is to re-announce an ADD_ADDR, and eventually retransmit it if needed.
In this case, the retransmission counter should be reset as well, so the re-announced address gets its retransmissions back instead of relying on what was left before, and possibly not being able to retransmit it.
--- net/mptcp/pm_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/pm_netlink.c +1 -1
@@ -418,10 +418,10 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, add_entry->addr = *addr; add_entry->sock = msk; - add_entry->retrans_times =0 ;timer_setup (&add_entry->add_timer, mptcp_pm_add_timer,0 ); reset_timer: + add_entry->retrans_times =0 ; add_entry->timer_done = false; timeout =mptcp_get_add_addr_timeout (net);if (timeout)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 114/1674 mptcp: do not reschedule the RTX timer for fallback sockets
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit e2ab913f68c7d11e2561b8a8ad0b87ffefcad667 ]
On fallback socket the retrans timer is a quite convoluted no-op, but currently nothing prevents the MPTCP core to keep rescheduling it.
Additionally gate RTX timer reset to the msk not being fallen back to TCP yet. To avoid adding multiple tests in fast-path, use a new flags bit for such condition.
The RTX enable bit is clear at close time and set before the msk could start retransmitting, with a couple of caveats:
- passive sockets inherit the bit from the listener msk; set the bit on such socket to avoid flipping it in the fast-path, even if the listener will obviously never retransmit.
- while fastopening (MPTFO), mptcp_sendmsg_fastopen still ends-up calling mptcp_connect via tcp_sendmsg_fastopen -> __inet_stream_connect(ssk->sk_socket), and the first subflow's sk_socket points to the msk one.
--- net/mptcp/protocol.c | 12 +++++++++--- net/mptcp/protocol.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-)
net/mptcp/protocol.c +9 -3
@@ -977,13 +977,14 @@ static bool mptcp_rtx_timer_pending(struct sock *sk)static void mptcp_reset_rtx_timer (struct sock *sk) {struct inet_connection_sock *icsk =inet_csk (sk); +struct mptcp_sock *msk =mptcp_sk (sk);unsigned long tout; -/* prevent rescheduling on close */ -if (unlikely (inet_sk_state_load (sk) ==TCP_CLOSE )) +/* Prevent rescheduling on close and in case of fallback. */ +if (!test_bit (MPTCP_RTX_ENABLED , &msk->flags))return ; - tout =mptcp_sk (sk)->timer_ival; + tout = msk->timer_ival;sk_reset_timer (sk, &icsk->icsk_retransmit_timer, jiffies + tout); }
@@ -3067,6 +3068,9 @@ void mptcp_set_state(struct sock *sk, int state)* transition from TCP_SYN_RECV to TCP_CLOSE_WAIT. */ break ; +case TCP_CLOSE : +clear_bit (MPTCP_RTX_ENABLED , &mptcp_sk (sk)->flags); + fallthrough;default :if (oldstate ==TCP_ESTABLISHED || oldstate ==TCP_CLOSE_WAIT )MPTCP_DEC_STATS (sock_net (sk),MPTCP_MIB_CURRESTAB );
@@ -3900,6 +3904,7 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)if (IS_ERR (ssk))return PTR_ERR (ssk); +set_bit (MPTCP_RTX_ENABLED , &msk->flags);mptcp_set_state (sk,TCP_SYN_SENT ); subflow =mptcp_subflow_ctx (ssk);#ifdef CONFIG_TCP_MD5SIG
@@ -4043,6 +4048,7 @@ static int mptcp_listen(struct socket *sock, int backlog) goto unlock; } +set_bit (MPTCP_RTX_ENABLED , &msk->flags);mptcp_set_state (sk,TCP_LISTEN );sock_set_flag (sk,SOCK_RCU_FREE );
net/mptcp/protocol.h +2 -0
@@ -116,6 +116,7 @@#define MPTCP_WORK_RTX 2#define MPTCP_FALLBACK_DONE 4#define MPTCP_WORK_CLOSE_SUBFLOW 5 +#define MPTCP_RTX_ENABLED 6/* MPTCP socket release cb flags */ #define MPTCP_PUSH_PENDING 1
@@ -1134,6 +1135,7 @@ static inline bool __mptcp_try_fallback(struct mptcp_sock *msk) msk->allow_subflows = false;set_bit (MPTCP_FALLBACK_DONE , &msk->flags); +clear_bit (MPTCP_RTX_ENABLED , &msk->flags);spin_unlock_bh (&msk->fallback_lock);return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 115/1674 smb: client: fix cifsFileInfo reference leak in deferred close
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit 5520e89a5a4f834bced64cf2ac927001cc513a40 ]
When cifs_close() defers a close, it hands the cifsFileInfo reference of the closing struct file to the queued work. Each execution of smb2_deferred_work_close() drops one such reference.
deferred_close_scheduled can be false while the work is pending: the workqueue clears PENDING when the callback starts to run, before the callback clears the flag under deferred_lock. A close in that interval requeues the running work, and the callback then clears the flag, leaving the requeued work pending with the flag down. A later cifs_open() can reuse the handle and its cifs_close() reaches the same branch: queue_delayed_work() fails because the work is still pending, but cifs_close() returns without dropping the closing file's reference. The cifsFileInfo count stays pinned and its tlink, dentry and server handle are leaked.
Check the return value and hand off the reference only when work was actually queued. Otherwise, use the shared _cifsFileInfo_put(), like the mod_delayed_work() branch above: the pending execution already owns its reference.
This issue was found by an in-house static analysis tool.
--- fs/smb/client/file.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
fs/smb/client/file.c +12 -5
@@ -1260,11 +1260,18 @@ int cifs_close(struct inode *inode, struct file *file)cifsFileInfo_get (cfile); }else {/* Deferred close for files */ -queue_delayed_work (deferredclose_wq, - &cfile->deferred, cifs_sb->ctx->closetimeo); - cfile->deferred_close_scheduled = true; -spin_unlock (&cinode->deferred_lock); -return 0 ; +/* +* Each queued execution owns one reference. +* If nothing was queued, the reference of +* the closing file is dropped below. +*/ +if (queue_delayed_work (deferredclose_wq, + &cfile->deferred, + cifs_sb->ctx->closetimeo)) { + cfile->deferred_close_scheduled = true; +spin_unlock (&cinode->deferred_lock); +return 0 ; + } }spin_unlock (&cinode->deferred_lock);_cifsFileInfo_put (cfile, true, false);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 116/1674 btrfs: take commit root semaphore when iterating in mark_block_group_to_copy()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
[ Upstream commit 0594e3423f4ba3137c734371169491f9a98e9af4 ]
mark_block_group_to_copy() iterates over the commit root with skip_locking=true. A concurrent transaction commit can swap and free the commit root during iteration, causing use-after-free when accessing extent buffers.
Fix it by using path->need_commit_sem to protect the commit root search.
--- fs/btrfs/dev-replace.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/dev-replace.c +1 -0
@@ -506,6 +506,7 @@ static int mark_block_group_to_copy(struct btrfs_fs_info *fs_info, path->reada =READA_FORWARD ; path->search_commit_root =1 ; path->skip_locking =1 ; + path->need_commit_sem =1 ; key.objectid = src_dev->devid; key.type =BTRFS_DEV_EXTENT_KEY ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 117/1674 hwmon: (pwm-fan) Stop RPM timer before freeing tach data
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yibo Tan <[email protected]>
[ Upstream commit 26d5ff79768548efb1e604bb6e8697c101e06269 ]
sample_timer() rearms the RPM timer and accesses the devm-managed ctx->tachs and ctx->pulses_per_revolution arrays. The cleanup action which stops the timer is registered before those arrays are allocated.
Since devres releases entries in reverse order, driver detach can free the arrays before pwm_fan_cleanup() shuts down the timer. A timer expiry in that window accesses the freed tach data.
With a KASAN kernel, a test-only kprobe delayed entry to pwm_fan_cleanup() while normal sysfs unbind ran. Each of three runs reported three four-byte reads and two four-byte writes in sample_timer() after its backing devm allocations had been freed. The helper did not invoke the timer callback, cleanup actions or free functions.
With the fix, three matching unbind runs completed without KASAN, BUG, WARNING, Oops or panic. Instrumentation confirmed that timer retirement completed before the first timer backing allocation was released.
Split timer retirement from the power cleanup and register its devres action after the timer backing data and IRQ actions are installed. This preserves the early power rollback action while ensuring the timer is retired before its backing data is released. Use timer_shutdown_sync() because the callback can rearm itself.
--- drivers/hwmon/pwm-fan.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/hwmon/pwm-fan.c +12 -1
@@ -466,12 +466,18 @@ static void pwm_fan_cleanup(void *__ctx) {struct pwm_fan_ctx *ctx = __ctx; -del_timer_sync (&ctx->rpm_timer);/* Switch off everything */ ctx->enable_mode = pwm_disable_reg_disable;pwm_fan_power_off (ctx); } +static void pwm_fan_timer_cleanup (void *__ctx) +{ +struct pwm_fan_ctx *ctx = __ctx; + +timer_shutdown_sync (&ctx->rpm_timer); +} +static int pwm_fan_probe (struct platform_device *pdev) {struct thermal_cooling_device *cdev;
@@ -606,6 +612,10 @@ static int pwm_fan_probe(struct platform_device *pdev) }if (ctx->tach_count >0 ) { + ret =devm_add_action_or_reset (dev, pwm_fan_timer_cleanup, ctx); +if (ret) +return ret; + ctx->sample_start =ktime_get ();mod_timer (&ctx->rpm_timer, jiffies +HZ );
@@ -647,6 +657,7 @@ static void pwm_fan_shutdown(struct platform_device *pdev) {struct pwm_fan_ctx *ctx =platform_get_drvdata (pdev); +pwm_fan_timer_cleanup (ctx);pwm_fan_cleanup (ctx); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 118/1674 wifi: wcn36xx: Fix potential use-after-free in TX ack timer teardown
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit d9be5e75530772fc31637070d51e5717d6aeaa2a ]
wcn36xx_dxe_deinit() tears down the TX ack timer with timer_delete(), which only dequeues the timer and does not wait for a callback that is already executing; the preceding free_irq() calls synchronize the interrupt handlers only. The callback, wcn36xx_dxe_tx_timer(), can therefore be running past the teardown and use the wcn freed along with the ieee80211_hw in wcn36xx_remove(): it takes wcn->dxe_lock, reads wcn->tx_ack_skb and passes wcn->hw to ieee80211_tx_status_irqsafe().
Fix this by using timer_shutdown_sync(), which waits for a running callback and also prevents the timer from being rearmed again. The timer is set up again by wcn36xx_dxe_init() on the next start, so the start/stop cycle is unaffected.
This issue was found by an in-house static analysis tool.
--- drivers/net/wireless/ath/wcn36xx/dxe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/wcn36xx/dxe.c +1 -1
@@ -1055,7 +1055,7 @@ void wcn36xx_dxe_deinit(struct wcn36xx *wcn)free_irq (wcn->tx_irq, wcn);free_irq (wcn->rx_irq, wcn); -del_timer (&wcn->tx_ack_timer); +timer_shutdown_sync (&wcn->tx_ack_timer);if (wcn->tx_ack_skb) {ieee80211_tx_status_irqsafe (wcn->hw, wcn->tx_ack_skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 119/1674 smb/client: send lease break ACKs thru correct session for multiuser mounts
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: April Cardenas <[email protected]>
[ Upstream commit ebc5660132ddd244b57f03ed324922013a3d7363 ]
Currently, when cifs_oplock_break handles a break request from the server it searches for the appropriate tlink to handle the request but incorrectly uses the current fsuid as the search key, eventually causing read errors for users with multiuser mounts on NetApp. Fix this by using the tlink from the cfile struct instead to respond through the correct session.
As breaks are handled in a worker thread, the current fsuid isn't guaranteed to match the session that the break is intended for. This means that cifs_sb_tlink may search the rbtree using the wrong fsuid, and return a tlink with an incorrect session than
the lease break was intended for. As a result, the breaks
may be ACKed through an incorrect session.
While it seems that Samba/Windows Servers 2016-2025 ignore this as long as the lease key is correct, we ran into a case where if you're using NetApp ONTAP or Azure NetApp Files they will reject the ACK and return STATUS_LOCK_NOT_GRANTED errors on any future read requests a user may initiate through their still held open file handle, and the server will eventually close the file.
In the dmesg logs, the user may see errors like these:
CIFS: Status code returned 0xc0000128 STATUS_FILE_CLOSED
CIFS: VFS: Send error in read = -9
With a multiuser mount using NetApp, this issue is really easy for users to hit on a wide variety of kernel versions by attempting to copy a file from the share
to the local machine through GNOME Files/Nautilus.
This copy will always result in Nautilus throwing
a Bad File Descriptor error to the user and fail. With this fix, you can copy files through Nautilus without issue.
Quoted 1 line
From looking at the traces, it seems that glib will
open the file first, and call listxattr before actually attempting to copy the file data. The listxattr call always triggers a break, causing the copy to fail.
The proposed fix returns to the way the client grabbed the tlink before commit e8f5f849ffce2 ("cifs: fix potential oops in cifs_oplock_break").
The bulk of that commit (checking for list empty) remains untouched, and I think the change to using cifs_sb_tlink was intended to avoid a NULL/ERR deference on the tlink as well as update the reference count.
I believe this fix should preserve those safety properties, but of course I'd appreciate any corrections here.
--- fs/smb/client/file.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/smb/client/file.c +2 -4
@@ -5146,8 +5146,6 @@ void cifs_oplock_break(struct work_struct *work) struct cifsFileInfo *cfile = container_of(work, struct cifsFileInfo, oplock_break);struct inode *inode =d_inode (cfile->dentry); -struct super_block *sb = inode->i_sb; -struct cifs_sb_info *cifs_sb =CIFS_SB (sb);struct cifsInodeInfo *cinode =CIFS_I (inode);struct cifs_tcon *tcon;struct TCP_Server_Info *server;
@@ -5160,8 +5158,8 @@ void cifs_oplock_break(struct work_struct *work)wait_on_bit (&cinode->flags,CIFS_INODE_PENDING_WRITERS ,TASK_UNINTERRUPTIBLE ); - tlink =cifs_sb_tlink (cifs_sb); -if (IS_ERR (tlink)) { + tlink =cifs_get_tlink (cfile->tlink); +if (IS_ERR_OR_NULL (tlink)) {/* drop the reference taken when the break was queued */ _cifsFileInfo_put (cfile, false/* do not wait for ourself */ , false); goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 120/1674 smb: client: fix reparse buffer bounds in cifs_query_reparse_point()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Sorenson <[email protected]>
[ Upstream commit 5f0306e731e2f46e91419eae57eee3a241c055e0 ]
In cifs_query_reparse_point(), the start >= end check before casting to struct reparse_data_buffer * only ensures the start pointer is within the response. It fails to verify that there is enough space remaining for the fixed 8-byte header of the structure.
If a server provides a DataOffset that leaves less than 8 bytes remaining, the check passes, but subsequent reads of ReparseTag and ReparseDataLength will occur out-of-bounds.
Fix this by ensuring the remaining space is at least the size of the reparse_data_buffer structure before accessing its fields.
--- fs/smb/client/cifssmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/cifssmb.c +1 -1
@@ -2793,7 +2793,7 @@ int cifs_query_reparse_point(const unsigned int xid, end =2 +get_bcc (&io_rsp->hdr) + (__u8 *)&io_rsp->ByteCount; start = (__u8 *)&io_rsp->hdr.Protocol + data_offset; -if (start >= end) { +if (start >= end || (size_t )(end - start) <sizeof (*buf)) { rc = -EIO ; goto error; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 121/1674 bna: prevent IOC timer rearm during teardown
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 77b1718e39e5c9f6956fb60807326af20baf889d ]
bna: prevent IOC timer rearm during teardown
bnad_pci_remove() and the probe disable_ioceth path call timer_delete_sync() for ioc_timer, sem_timer and hb_timer, but not for iocpf_timer. bnad_iocpf_timeout() then takes bnad->bna_lock after free_netdev() has freed the struct bnad.
Deleting iocpf_timer last does not fix this. sem_timer and iocpf_timer rearm each other: bnad_iocpf_sem_timeout() can arm iocpf_timer, and bnad_iocpf_timeout() arms sem_timer from bfa_ioc_hw_sem_get() when the semaphore is busy. timer_delete_sync() only waits out its own callback. bnad_ioceth_disable() can time out and leave that callback live.
Shut all four IOC timers down with timer_shutdown_sync() on both paths, so a later mod_timer() is ignored.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/net/ethernet/brocade/bna/bnad.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.c +10 -6
@@ -3727,9 +3727,11 @@ bnad_pci_probe(struct pci_dev *pdev,bnad_res_free (bnad, &bnad->mod_res_info[0 ],BNA_MOD_RES_T_MAX ); disable_ioceth:bnad_ioceth_disable (bnad); -del_timer_sync (&bnad->bna.ioceth.ioc.ioc_timer); -del_timer_sync (&bnad->bna.ioceth.ioc.sem_timer); -del_timer_sync (&bnad->bna.ioceth.ioc.hb_timer); +/* The IOC timers rearm one another. Shut down all of them. */ +timer_shutdown_sync (&bnad->bna.ioceth.ioc.ioc_timer); +timer_shutdown_sync (&bnad->bna.ioceth.ioc.sem_timer); +timer_shutdown_sync (&bnad->bna.ioceth.ioc.hb_timer); +timer_shutdown_sync (&bnad->bna.ioceth.ioc.iocpf_timer);spin_lock_irqsave (&bnad->bna_lock, flags);bna_uninit (bna);spin_unlock_irqrestore (&bnad->bna_lock, flags);
@@ -3770,9 +3772,11 @@ bnad_pci_remove(struct pci_dev *pdev)mutex_lock (&bnad->conf_mutex);bnad_ioceth_disable (bnad); -del_timer_sync (&bnad->bna.ioceth.ioc.ioc_timer); -del_timer_sync (&bnad->bna.ioceth.ioc.sem_timer); -del_timer_sync (&bnad->bna.ioceth.ioc.hb_timer); +/* The IOC timers rearm one another. Shut down all of them. */ +timer_shutdown_sync (&bnad->bna.ioceth.ioc.ioc_timer); +timer_shutdown_sync (&bnad->bna.ioceth.ioc.sem_timer); +timer_shutdown_sync (&bnad->bna.ioceth.ioc.hb_timer); +timer_shutdown_sync (&bnad->bna.ioceth.ioc.iocpf_timer);spin_lock_irqsave (&bnad->bna_lock, flags);bna_uninit (bna);spin_unlock_irqrestore (&bnad->bna_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 122/1674 tcp: prevent collapsing skbs across boundary in rtx queue
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
[ Upstream commit fc6d80eb504458d6416b75a94188b268c95c6533 ]
tcp_write_collapse_fence() sets TCP_SKB_CB(skb)->eor = 1 on tcp_write_queue_tail(sk) to prevent skbs queued after a switch to device encryption from being collapsed into earlier skbs.
The fence is a no-op if all earlier data has already been transmitted when the switch happens: sk->sk_write_queue is empty. The not yet acknowledged earlier skbs wait in sk->tcp_rtx_queue with eor 0.
On a subsequent retransmit or SACK shift, tcp_retrans_try_collapse() or tcp_shift_skb_data() can then merge an skb queued after the switch into one queued before it.
Both users of the fence are affected:
- psp: devices only encrypt skbs with skb->decrypted set. The merged skb keeps decrypted = 0 from the earlier skb, so merged data sent after psp_sock_assoc_set_tx() is retransmitted in cleartext.
- tls device offload: the merged skb straddles the start marker set in tls_set_device_offload(). The software fallback (fill_sg_in() returns -EINVAL) and the mlx5, nfp and funeth drivers cannot handle such an skb and drop it. Every retransmit rebuilds the same skb, so the connection stalls.
Fix this in two places, for defense in depth:
1. Fall back to tcp_rtx_queue_tail(sk) in tcp_write_collapse_fence() when tcp_write_queue_tail(sk) is NULL.
2. Check !skb_cmp_decrypted(to, from) in tcp_skb_can_collapse(), as tcp_skb_can_collapse_rx() does on receive. skb_shift(), which both collapse paths call, already has a DEBUG_NET_WARN_ON_ONCE() for this condition.
--- include/net/tcp.h | 1 + net/tls/tls_device.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
include/net/tcp.h +1 -0
@@ -985,6 +985,7 @@ static inline bool tcp_skb_can_collapse(const struct sk_buff *to, {return likely (tcp_skb_can_collapse_to (to) &&mptcp_skb_can_collapse (to, from) && + !skb_cmp_decrypted (to, from) &&skb_pure_zcopy_same (to, from)); }
net/tls/tls_device.c +2 -2
@@ -239,7 +239,7 @@ static void tls_device_resync_tx(struct sock *sk, struct tls_context *tls_ctx,int err =0 ;u8 *rcd_sn; - skb =tcp_write_queue_tail (sk); + skb =tcp_write_queue_tail (sk) ?:tcp_rtx_queue_tail (sk);if (skb)TCP_SKB_CB (skb)->eor =1 ;
@@ -1157,7 +1157,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)* SKBs where only part of the payload needs to be encrypted. * So mark the last skb in the write queue as end of record. */ - skb =tcp_write_queue_tail (sk); + skb =tcp_write_queue_tail (sk) ?:tcp_rtx_queue_tail (sk);if (skb)TCP_SKB_CB (skb)->eor =1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 123/1674 perf/x86/intel: Remove anythread_deprecated bit from perf_capabilities
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dapeng Mi <[email protected]>
[ Upstream commit 8767b4d73018bd3143f4c55b672064fad292f11b ]
AnyThread mode deprecation is enumerated by CPUID.0AH:EDX[15] instead of PERF_CAPABILITIES MSR. It's not a good practice to define a bit to represent "anythread deprecation" in perf_capabilities. It leads to the anythread_deprecated bit could be overwritten by the real value of PERF_CAPABILITIES MSR, just like the below code in update_pmu_cap() does.
if (!intel_pmu_broken_perf_cap()) {
/* Perf Metric (Bit 15) and PEBS via PT (Bit 16) are hybrid enumeration */
rdmsrq(MSR_IA32_PERF_CAPABILITIES, hybrid(pmu, intel_cap).capabilities);
}It leads to the anythread_deprecated bit is cleared to 0 and the "any" attribute is incorrectly shown in the /sys/devices/cpu/format/ folder on these support Perfmon v6 platforms, like Clearwater Forest.
$ grep . /sys/devices/cpu/format/* /sys/devices/cpu/format/acr_mask:config2:0-63 /sys/devices/cpu/format/any:config:21 /sys/devices/cpu/format/cmask:config:24-31
So remove the anythread_deprecated bit from perf_capabilities structure and directly depends on CPUID.0AH:EDX[15] to judge if anythread is deprecated.
--- arch/x86/events/intel/core.c | 10 +++------- arch/x86/events/perf_event.h | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-)
arch/x86/events/intel/core.c +3 -7
@@ -6185,12 +6185,6 @@ __init int intel_pmu_init(void)x86_add_quirk (intel_arch_events_quirk);/* Install first, so it runs last */ -if (version >=5 ) { - x86_pmu.intel_cap.anythread_deprecated = edx.split.anythread_deprecated; -if (x86_pmu.intel_cap.anythread_deprecated) -pr_cont (" AnyThread deprecated, " ); - } -/* * Install the hw-cache-events table: */
@@ -6981,8 +6975,10 @@ __init int intel_pmu_init(void) (u64)fixed_mask);/* AnyThread may be deprecated on arch perfmon v5 or later */ -if (x86_pmu.intel_cap.anythread_deprecated) +if (version >=5 && edx.split.anythread_deprecated) { x86_pmu.format_attrs = intel_arch_formats_attr; +pr_cont ("AnyThread deprecated, " ); + } intel_pmu_check_event_constraints(x86_pmu.event_constraints, x86_pmu.num_counters,
arch/x86/events/perf_event.h +1 -1
@@ -609,7 +609,7 @@ union perf_capabilities { u64 perf_metrics:1; u64 pebs_output_pt_available:1; u64 pebs_timing_info:1; - u64 anythread_deprecated:1; + u64 __reserved:1; };u64 capabilities; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 124/1674 drm/amdgpu: Fix acpi device leak in amdgpu_acpi_enumerate_xcc()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit a997baa61179b450bd55c4810c7ccfed3b753a54 ]
amdgpu_acpi_enumerate_xcc() looks up each XCC ACPI device with acpi_dev_get_first_match_dev(), which takes a reference to the device. The reference is dropped with acpi_dev_put() after the XCC info is initialized, but if the kzalloc_obj() allocation of the XCC info fails the function returns -ENOMEM without releasing the reference, leaking the last reference to the ACPI device.
Drop the ACPI device reference on the allocation failure path before returning.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +1 -0
@@ -1110,6 +1110,7 @@ static int amdgpu_acpi_enumerate_xcc(void) GFP_KERNEL);if (!xcc_info) {DRM_ERROR ("Failed to allocate memory for xcc info\n" ); +acpi_dev_put (acpi_dev);return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 125/1674 drm/nouveau/uvmm: fix UAF in nouveau_uvmm_sm when BO is in TTM_PL_SYSTEM
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peiyang He <[email protected]>
[ Upstream commit 3359a372efb6d585c97019ee1b7f1874442bcebe ]
nouveau_uvmm_sm() calls op_map(), which passes bo->resource through nouveau_mem() to nouveau_uvma_map(). nouveau_uvmm_vmm_map() then reads mem->mem.type.
But this is only valid when bo->resource is backed by struct nouveau_mem, as is the case for VRAM and TT resources. If the BO is left in TTM_PL_SYSTEM, bo->resource is only a struct ttm_resource. Treating it as struct nouveau_mem makes the mem->mem.type read past the end of the resource, causing a KASAN: slab-use-after-free Read in nouveau_uvmm_sm report:
BUG: KASAN: slab-use-after-free in nouveau_uvmm_vmm_map drivers/gpu/drm/nouveau/nouveau_uvmm.c:152 [inline] BUG: KASAN: slab-use-after-free in nouveau_uvma_map drivers/gpu/drm/nouveau/nouveau_uvmm.c:199 [inline] BUG: KASAN: slab-use-after-free in op_map drivers/gpu/drm/nouveau/nouveau_uvmm.c:849 [inline] BUG: KASAN: slab-use-after-free in nouveau_uvmm_sm.constprop.0+0x6ab/0x900 drivers/gpu/drm/nouveau/nouveau_uvmm.c:903 Read of size 1 at addr ffff888127d3e3a0 by task kworker/0:1/11 CPU: 0 UID: 0 PID: 11 Comm: kworker/0:1 Not tainted 7.2.0 #5 PREEMPT(lazy) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Workqueue: nouveau_sched_wq_2224 drm_sched_run_job_work Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x95/0xe0 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xcb/0x5a0 mm/kasan/report.c:482 kasan_report+0xca/0x100 mm/kasan/report.c:595 nouveau_uvmm_vmm_map drivers/gpu/drm/nouveau/nouveau_uvmm.c:152 [inline] nouveau_uvma_map drivers/gpu/drm/nouveau/nouveau_uvmm.c:199 [inline] op_map drivers/gpu/drm/nouveau/nouveau_uvmm.c:849 [inline] nouveau_uvmm_sm.constprop.0+0x6ab/0x900 drivers/gpu/drm/nouveau/nouveau_uvmm.c:903 nouveau_uvmm_sm_unmap drivers/gpu/drm/nouveau/nouveau_uvmm.c:932 [inline] nouveau_uvmm_bind_job_run+0xd6/0x250 drivers/gpu/drm/nouveau/nouveau_uvmm.c:1532 nouveau_job_run drivers/gpu/drm/nouveau/nouveau_sched.c:350 [inline] nouveau_sched_run_job+0x62/0xd0 drivers/gpu/drm/nouveau/nouveau_sched.c:364 drm_sched_run_job_work+0x356/0xa10 drivers/gpu/drm/scheduler/sched_main.c:1061 process_one_work+0x8a5/0x1900 kernel/workqueue.c:3322 process_scheduled_works kernel/workqueue.c:3405 [inline] worker_thread+0x5dd/0xd80 kernel/workqueue.c:3486 kthread+0x31d/0x420 kernel/kthread.c:436 ret_from_fork+0x662/0x940 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK> Allocated by task 2224 on cpu 0 at 66.550027s: kasan_save_stack+0x24/0x50 mm/kasan/common.c:57 kasan_save_track+0x17/0x60 mm/kasan/common.c:78 poison_kmalloc_redzone mm/kasan/common.c:398 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:415 kasan_kmalloc include/linux/kasan.h:263 [inline] __do_kmalloc_node mm/slub.c:5334 [inline] __kmalloc_noprof+0x304/0x7c0 mm/slub.c:5359 _kmalloc_noprof include/linux/slab.h:992 [inline] dma_resv_list_alloc+0x27/0x90 drivers/dma-buf/dma-resv.c:106 dma_resv_reserve_fences+0x60e/0xa30 drivers/dma-buf/dma-resv.c:205 ttm_bo_alloc_resource+0x12c/0xbd0 drivers/gpu/drm/ttm/ttm_bo.c:721 ttm_bo_validate+0x1bc/0x4a0 drivers/gpu/drm/ttm/ttm_bo.c:856 ttm_bo_init_reserved+0x2c3/0x570 drivers/gpu/drm/ttm/ttm_bo.c:970 nouveau_bo_init+0x159/0x2c0 drivers/gpu/drm/nouveau/nouveau_bo.c:359 nouveau_gem_new+0x234/0x5f0 drivers/gpu/drm/nouveau/nouveau_gem.c:272 nouveau_gem_ioctl_new+0x1eb/0x420 drivers/gpu/drm/nouveau/nouveau_gem.c:352 drm_ioctl_kernel+0x192/0x350 drivers/gpu/drm/drm_ioctl.c:817 drm_ioctl+0x4f8/0xb40 drivers/gpu/drm/drm_ioctl.c:914 nouveau_drm_ioctl+0xea/0x2c0 drivers/gpu/drm/nouveau/nouveau_drm.c:1338 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:597 [inline] __se_sys_ioctl fs/ioctl.c:583 [inline] __x64_sys_ioctl+0x180/0x1d0 fs/ioctl.c:583 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x115/0x690 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 2223 on cpu 0 at 66.554063s: kasan_save_stack+0x24/0x50 mm/kasan/common.c:57 kasan_save_track+0x17/0x60 mm/kasan/common.c:78 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:584 poison_slab_object mm/kasan/common.c:253 [inline] __kasan_slab_free+0x61/0x80 mm/kasan/common.c:285 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:2677 [inline] __rcu_free_sheaf_prepare+0xb6/0x2e0 mm/slub.c:2928 rcu_free_sheaf+0x1b/0x120 mm/slub.c:5978 rcu_do_batch kernel/rcu/tree.c:2645 [inline] rcu_core+0x521/0x1490 kernel/rcu/tree.c:2897 handle_softirqs+0x1b1/0x8a0 kernel/softirq.c:622 __do_softirq kernel/softirq.c:656 [inline] invoke_softirq kernel/softirq.c:496 [inline] __irq_exit_rcu+0x137/0x1c0 kernel/softirq.c:735 irq_exit_rcu+0x9/0x20 kernel/softirq.c:752 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline] sysvec_apic_timer_interrupt+0x70/0x80 arch/x86/kernel/apic/apic.c:1062 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674 The buggy address belongs to the object at ffff888127d3e380 which belongs to the cache kmalloc-96 of size 96
The buggy address is located 32 bytes inside of
freed 96-byte region [ffff888127d3e380, ffff888127d3e3e0)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x127d3e
flags: 0x200000000000000(node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000000 ffff888100041280 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000200020 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888127d3e280: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc
ffff888127d3e300: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc
>ffff888127d3e380: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
^
ffff888127d3e400: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff888127d3e480: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fcFix by resetting the placement to the BO's valid domains before calling nouveau_bo_validate(), matching the handling in nouveau_uvmm_bo_validate(), so map jobs do not run for SYSTEM resources; Reject BO that cannot reside in VRAM or GART;
Also skip op_map() when the GPUVA has been invalidated, matching the handling in the unmap and remap paths.
Found when fuzzing the nouveau driver with a modified Syzkaller.
--- drivers/gpu/drm/nouveau/nouveau_uvmm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/nouveau/nouveau_uvmm.c +10 -0
@@ -772,6 +772,9 @@ op_map(struct nouveau_uvma *uvma) {struct nouveau_bo *nvbo =nouveau_gem_object (uvma->va.gem.obj); +if (drm_gpuva_invalidated (&uvma->va)) +return ; +nouveau_uvma_map (uvma,nouveau_mem (nvbo->bo.resource)); }
@@ -1334,6 +1337,13 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job)continue ; nvbo =nouveau_gem_object (obj); +if (!(nvbo->valid_domains & + (NOUVEAU_GEM_DOMAIN_VRAM |NOUVEAU_GEM_DOMAIN_GART ))) { + ret = -EINVAL ; + op =list_last_op (&bind_job->ops); + goto unwind; + } +nouveau_bo_placement_set (nvbo, nvbo->valid_domains,0 ); ret =nouveau_bo_validate (nvbo, true, false);if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 126/1674 mm/rmap: fix missing barrier between anon_vma init and vma->anon_vma publish
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjiang Tu <[email protected]>
[ Upstream commit b6ac0b3f6013c168f22cad97e79967accacb08e1 ]
On arm64 server, we find that a task trying to grab the anon_vma lock triggers hungtask.
INFO: task main:2354726 blocked for more than 120 seconds.
Tainted: G E 5.10.0-0021.aarch64 #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:main state:D stack: 0 pid:2354726 ppid:2350673 flags:0x00000a01
Call trace:
__switch_to+0x7c/0xbc
__schedule+0x3b4/0x8a0
schedule+0x50/0xe0
rwsem_down_write_slowpath+0x3cc/0x6cc
down_write+0x60/0x260
__anon_vma_prepare+0x6c/0x210
do_anonymous_page+0x258/0x660
handle_pte_fault+0x188/0x214
__handle_mm_fault+0x1b0/0x380
handle_mm_fault+0xf4/0x284
do_page_fault+0x19c/0x494
do_translation_fault+0xcc/0xf8
do_mem_abort+0x48/0xac
el0_da+0x44/0x80
el0_sync_handler+0x88/0xb4
el0_sync+0x160/0x180After analyzing the vmcore, we found the anon_vma->root->rwsem.count is -1. There is another anon_vma whose anon_vma->root->rwsem.count is 1, the anon_vma->root->rwsem.owner shows the lock is held, but the stack of the task shows the task doesn't hold the anon_vma lock.
After adding more debugging info, we found __anon_vma_prepare() reuses anon_vma and triggers the UAF of anon_vma->root due to missing memory barrier, leading to locking and unlocking two different anon_vma->root, thus leading to an anon_vma will never be unlocked, and another anon_vma couldn't be locked anymore.
This race requires two adjacent VMAs that are not merged but are anon_vma-compatible (e.g., they differ in VMA_ACCESS_FLAGS that can be changed by mprotect()). Two threads fault on each VMA concurrently, both calling __anon_vma_prepare() with only mmap_lock held for reading.
THREAD A THREAD B__anon_vma_prepare __anon_vma_prepare
find_mergeable_anon_vma() -> NULL
anon_vma = anon_vma_alloc();
anon_vma->root = anon_vma;
// the two stores may be reordered
vma->anon_vma = anon_vma;
// finds A's anon_vma
anon_vma = find_mergeable_anon_vma(vma);
anon_vma_lock_write(anon_vma);
// may still see the old root
down_write(&anon_vma->root->rwsem);
anon_vma_unlock_write(anon_vma);
// see the new root, never unlock old
up_write(&anon_vma->root->rwsem);thread A triggers page fault and calls __anon_vma_prepare() to prepare anon_vma for the faulting vma. __anon_vma_prepare() allocates and initializes a new anon_vma, and then publishes it to the vma with a plain store. anon_vma_prepare() only requires the mmap_lock to be held for reading, so two threads can fault on adjacent VMAs at the same time. While thread A publishes a new anon_vma, thread B could find the anon_vma via find_mergeable_anon_vma() and then locks anon_vma->root->rwsem.
The store to anon_vma->root in anon_vma_alloc() and the store to vma->anon_vma can be reordered. The anon_vma_lock_write() and spin_lock() only provide acquire semantics, which do not prevent prior stores from being reordered after them. The release semantics of the corresponding spin_unlock() and anon_vma_unlock_write() come too late, the store to vma->anon_vma is already published before they take effect. As a result, thread B can observe the following order:
vma->anon_vma = anon_vma;
anon_vma->root = anon_vma;The anon_vma slab is SLAB_TYPESAFE_BY_RCU, so a newly allocated anon_vma may reuse memory from a previously freed one. The constructor (anon_vma_ctor) does not reset anon_vma->root, and __put_anon_vma() doesn't clear it either, so the old root value persists until anon_vma_alloc() overwrites it. If that store isn't visible, thread B reads a root that points to the old anon_vma and locks it.
As a result, thread B can call anon_vma_lock_write() with the old root, and call anon_vma_unlock_write() with the new root, leading to an anon_vma will never be unlocked, and another anon_vma couldn't be locked anymore (its count is dropped from 0 to -1 due to wrong unlock).
To fix it, change the plain store vma->anon_vma = anon_vma to store release, so that the fields of anon_vma are visible before anon_vma is published to vma->anon_vma.
At read side, the load of anon_vma and anon_vma->root have address dependency. According to Documentation/memory-barriers.txt and some investigations, only Alpha needs address-dependency barriers and it has been handled by READ_ONCE() in reusable_anon_vma().
We reproduced this issue in v5.10 with KSM enabled. The kernel doesn't merge commit cf7e7a3503df ("mm: prevent KSM from breaking VMA merging for new VMAs"), so there are many adjacent VMAs that aren't merged but are compatible for anon_vma.
Without this fix, our production environment could reproduce this issue about 2-5 times each month. After adding a smp_mb() before anon_vma_lock_write(anon_vma) in __anon_vma_prepare(), which is different to this patch, this issue hasn't been reproduced for one month.
--- mm/mmap.c | 8 ++++++++ mm/rmap.c | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-)
mm/mmap.c +8 -0
@@ -1081,6 +1081,13 @@ static int anon_vma_compatible(struct vm_area_struct *a, struct vm_area_struct ** acceptable for merging, so we can do all of this optimistically. But * we do that READ_ONCE() to make sure that we never re-load the pointer. * +* The READ_ONCE() establishes an address dependency between anon_vma and +* any access to its fields, which pairs with the assignment to +* vma->anon_vma performed with release semantics in __anon_vma_prepare(). +* +* This is especially important as anon_vma's are SLAB_TYPESAFE_BY_RCU so +* accessing an uninitialised anon_vma's fields may result in a UAF. +* * IOW: that the "list_is_singular()" test on the anon_vma_chain only * matters for the 'stable anon_vma' case (ie the thing we want to avoid * is to return an anon_vma that is "complex" due to having gone through
@@ -1093,6 +1100,7 @@ static int anon_vma_compatible(struct vm_area_struct *a, struct vm_area_struct *static struct anon_vma *reusable_anon_vma (struct vm_area_struct *old,struct vm_area_struct *a,struct vm_area_struct *b) {if (anon_vma_compatible (a, b)) { +/* Paired with a memory barrier in __anon_vma_prepare(). */ struct anon_vma *anon_vma =READ_ONCE (old->anon_vma);if (anon_vma &&list_is_singular (&old->anon_vma_chain))
mm/rmap.c +5 -1
@@ -211,7 +211,11 @@ int __anon_vma_prepare(struct vm_area_struct *vma)/* page_table_lock to protect against threads */ spin_lock (&mm->page_table_lock);if (likely (!vma->anon_vma)) { - vma->anon_vma = anon_vma; +/* +* Make anon_vma fields visible before anon_vma is published. +* Paired with an address dependency in reusable_anon_vma(). +*/ +smp_store_release (&vma->anon_vma, anon_vma);anon_vma_chain_link (vma, avc, anon_vma); anon_vma->num_active_vmas++; allocated =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 127/1674 mm/hugetlb: preserve mremap address delta when skipping page tables
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaewook You <[email protected]>
[ Upstream commit 9bdad082d44bdcf93716973dcba6be77e8a06e7b ]
move_hugetlb_page_tables() optimizes mremap() by advancing to the last entry in the page table when the source page table does not exist, either initially or after unsharing a PMD table. The common loop increment then steps to the first entry in the next page table.
However, the code advances both the source and destination addresses to the last entries in their respective page tables, which is wrong. The destination address must be advanced only by the same amount as the source address.
If the source and destination offsets within their page tables differ, the destination address can be advanced too far, causing follow-up issues. Fix this by advancing the destination address by the source advance distance.
With a reproducer, we were able to trigger a kernel panic on x86-64. With this fix in place, we can no longer reproduce the issue.
--- mm/hugetlb.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
mm/hugetlb.c +7 -4
@@ -5295,18 +5295,21 @@ int move_hugetlb_page_tables(struct vm_area_struct *vma,hugetlb_vma_lock_write (vma);i_mmap_lock_write (mapping);for (; old_addr < old_end; old_addr += sz, new_addr += sz) { +const unsigned long offset_to_last_entry = + (old_addr | last_addr_mask) - old_addr; + src_pte =hugetlb_walk (vma, old_addr, sz);if (!src_pte) { - old_addr |= last_addr_mask; - new_addr |= last_addr_mask; + old_addr += offset_to_last_entry; + new_addr += offset_to_last_entry;continue ; }if (huge_pte_none (huge_ptep_get (src_pte)))continue ;if (huge_pmd_unshare (&tlb, vma, old_addr, src_pte)) { - old_addr |= last_addr_mask; - new_addr |= last_addr_mask; + old_addr += offset_to_last_entry; + new_addr += offset_to_last_entry;continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 128/1674 net/sched: act_ct: fix helper UAF due to extensions realloc
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
[ Upstream commit dad19b59da050cb60d3f7023dac2a042a84bf0bd ]
While calling the helpers, a raw pointer to the extensions area is wired into expectations list:
-> nf_ct_helper()
-> helper->help()
-> nf_ct_expect_related_report()
-> nf_ct_expect_insert()
-> hlist_add_head_rcu(&exp->lnode, &master_help->expectations)In case the connection is not confirmed yet, more extensions can be added afterwards with *_ext_add() calls reallocating the extension space and leaving the now invalid pointer in the expectations list that is later accessed while removing the expectation.
Make sure that helpers are called at the end after all the other extensions are already added.
Note that the helper rejection now leaves the mark and labels set, but that's not different from how the NAT was handled before or how the mark and the labels were handled on confirmation failure. And there are no atomicity guarantees provided by the API anyway.
--- net/sched/act_ct.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
net/sched/act_ct.c +11 -5
@@ -1083,18 +1083,24 @@ TC_INDIRECT_SCOPE int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a, } } -if (nf_ct_is_confirmed (ct) ? ((!cached && !skip_add) || add_helper) : commit) { -if (nf_ct_helper (skb, ct, ctinfo, family) !=NF_ACCEPT ) - goto drop; - } -if (commit) {tcf_ct_act_set_mark (ct, p->mark, p->mark_mask);tcf_ct_act_set_labels (ct, p->labels, p->labels_mask);if (!nf_ct_is_confirmed (ct))nf_conn_act_ct_ext_add (skb, ct, ctinfo); + } +/* Run helpers for the connection if nf_conntrack_in() was executed +* or if we're about to commit. This has to be done after all the +* extensions are already added. +*/ +if (nf_ct_is_confirmed (ct) ? ((!cached && !skip_add) || add_helper) : commit) { +if (nf_ct_helper (skb, ct, ctinfo, family) !=NF_ACCEPT ) + goto drop; + } + +if (commit) {/* This will take care of sending queued events * even if the connection is already confirmed. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 129/1674 net/sched: act_ct: avoid modifying shared unconfirmed ct entry
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
[ Upstream commit f85009dfcd65e5969526b0db7a49b5413746e630 ]
In a case where skb with an unconfirmed ct entry gets cloned, we may end up processing both again but with different sets of extensions.
The series of events:
1. The first clone wants to commit and runs the helpers wiring up the extension pointer into the expectation list.
2. Then it looses the confirmation keeping the entry unconfirmed.
3. Second clone now wants to commit labels or run NAT and adds the new extension for that breaking the pointer in the expectation list causing UAF on the destruction path later.
While this is possible to trigger, there should be no practical network pipeline where we need to process both clones without modifications in the same zone. So, let's just reset the entry in case for some reason we got an skb with a shared one. This doesn't affect any known use cases, but avoids any potential problems with sharing and modification of the unconfirmed ct entry.
Unlike openvswitch module, act_ct allows for NAT without commit. Changing that would be a uAPI break. So, act_ct needs to reset on NAT regardless of the commit flag to avoid reallocation of the extension space. This, however, doesn't really change the picture for sensible networking cases as there should be no need to run the same packet twice (before and after the clone) through conntrack without packet header or zone changes and without commit.
The fixes tag points to the introduction of helpers, since that's the main UAF trigger for the sharing.
--- net/sched/act_ct.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
net/sched/act_ct.c +16 -2
@@ -973,11 +973,11 @@ TC_INDIRECT_SCOPE int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a, struct tcf_result *res) {struct net *net =dev_net (skb->dev); +bool cached, commit, clear, nat;enum ip_conntrack_info ctinfo;struct tcf_ct *c =to_ct (a);struct nf_conn *tmpl =NULL ;struct nf_hook_state state; -bool cached, commit, clear;int nh_ofs, err, retval;struct tcf_ct_params *p;bool add_helper = false;
@@ -992,6 +992,7 @@ TC_INDIRECT_SCOPE int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a, retval =READ_ONCE (c->tcf_action); commit = p->ct_action &TCA_CT_ACT_COMMIT ; clear = p->ct_action &TCA_CT_ACT_CLEAR ; + nat = p->ct_action &TCA_CT_ACT_NAT ; tmpl = p->tmpl;tcf_lastuse_update (&c->tcf_tm);
@@ -1040,6 +1041,19 @@ TC_INDIRECT_SCOPE int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,* different zone. */ cached =tcf_ct_skb_nfct_cached (net, skb, p); + +/* If the ct entry is not confirmed and shared with some other skb, +* e.g., a cloned one, we can't just modify it with a commit or nat +* as we must not modify the extension set. Reset. +*/ +if (cached && (commit || nat)) { + ct =nf_ct_get (skb, &ctinfo); +if (ct && !nf_ct_is_confirmed (ct) &&nf_ct_shared (ct)) { +nf_reset_ct (skb); + cached = false; + } + } +if (!cached) {if (tcf_ct_flow_table_lookup (p, skb, family)) { skip_add = true;
@@ -1077,7 +1091,7 @@ TC_INDIRECT_SCOPE int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,if (err) goto drop; add_helper = true; -if (p->ct_action &TCA_CT_ACT_NAT && !nfct_seqadj (ct)) { +if (nat && !nfct_seqadj (ct)) {if (!nfct_seqadj_ext_add (ct)) goto drop; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 130/1674 openvswitch: prepare for stolen verdict coming from conntrack and nat engine
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit c7f79f2620b7776586c626edf21eb6ed6ed3d1eb ]
At this time, conntrack either returns NF_ACCEPT or NF_DROP. To improve debuging it would be nice to be able to replace NF_DROP verdict with NF_DROP_REASON() helper,
This helper releases the skb instantly (so drop_monitor can pinpoint precise location) and returns NF_STOLEN.
Prepare call sites to deal with this before introducing such changes in conntrack and nat core.
Stable-dep-of: 1a4151e6be57 ("net: openvswitch: conntrack: fix helper UAF due to extensions realloc")
--- net/openvswitch/conntrack.c | 47 +++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-)
net/openvswitch/conntrack.c +37 -10
@@ -679,6 +679,8 @@ static int ovs_ct_nat(struct net *net, struct sw_flow_key *key, action |=BIT (NF_NAT_MANIP_DST ); err =nf_ct_nat (skb, ct, ctinfo, &action, &info->range, info->commit); +if (err !=NF_ACCEPT ) +return err;if (action &BIT (NF_NAT_MANIP_SRC ))ovs_nat_update_key (key, skb,NF_NAT_MANIP_SRC );
@@ -697,6 +699,22 @@ static int ovs_ct_nat(struct net *net, struct sw_flow_key *key, }#endif +static int verdict_to_errno (unsigned int verdict) +{ +switch (verdict &NF_VERDICT_MASK ) { +case NF_ACCEPT : +return 0 ; +case NF_DROP : +return -EINVAL ; +case NF_STOLEN : +return -EINPROGRESS ; +default : +break ; + } + +return -EINVAL ; +} +/* Pass 'skb' through conntrack in 'net', using zone configured in 'info', if * not done already. Update key with new CT state after passing the packet * through conntrack.
@@ -747,7 +765,7 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, err =nf_conntrack_in (skb, &state);if (err !=NF_ACCEPT ) -return -ENOENT ; +return verdict_to_errno (err);/* Clear CT state NAT flags to mark that we have not yet done * NAT after the nf_conntrack_in() call. We can actually clear
@@ -774,9 +792,12 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,* the key->ct_state. */ if (info->nat && !(key->ct_state &OVS_CS_F_NAT_MASK ) && - (nf_ct_is_confirmed (ct) || info->commit) && -ovs_ct_nat (net, key, info, skb, ct, ctinfo) !=NF_ACCEPT ) { -return -EINVAL ; + (nf_ct_is_confirmed (ct) || info->commit)) { +int err =ovs_ct_nat (net, key, info, skb, ct, ctinfo); + + err =verdict_to_errno (err); +if (err) +return err; }/* Userspace may decide to perform a ct lookup without a helper
@@ -807,9 +828,12 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,* - When committing an unconfirmed connection. */ if ((nf_ct_is_confirmed (ct) ? !cached || add_helper : - info->commit) && -nf_ct_helper (skb, ct, ctinfo, info->family) !=NF_ACCEPT ) { -return -EINVAL ; + info->commit)) { +int err =nf_ct_helper (skb, ct, ctinfo, info->family); + + err =verdict_to_errno (err); +if (err) +return err; } if (nf_ct_protonum(ct) == IPPROTO_TCP &&
@@ -1017,10 +1041,9 @@ static int ovs_ct_commit(struct net *net, struct sw_flow_key *key,/* This will take care of sending queued events even if the connection * is already confirmed. */ -if (nf_conntrack_confirm (skb) !=NF_ACCEPT ) -return -EINVAL ; + err =nf_conntrack_confirm (skb); -return 0 ; +return verdict_to_errno (err); }/* Returns 0 on success, -EINPROGRESS if 'skb' is stolen, or other nonzero
@@ -1055,6 +1078,10 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb,else err =ovs_ct_lookup (net, key, info, skb); +/* conntrack core returned NF_STOLEN */ +if (err == -EINPROGRESS ) +return err; +skb_push_rcsum (skb, nh_ofs);if (err)ovs_kfree_skb_reason (skb,OVS_DROP_CONNTRACK );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 131/1674 net: openvswitch: conntrack: remove add_helper dead code
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
[ Upstream commit 5e6c14dd42a1c1fe938e573dc6c9098145b2b0c4 ]
This variable can only become 'true' when the connection is not confirmed, but it is only checked when it is confirmed. So, it can be treated as being always false and just removed.
Stable-dep-of: 1a4151e6be57 ("net: openvswitch: conntrack: fix helper UAF due to extensions realloc")
--- net/openvswitch/conntrack.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
net/openvswitch/conntrack.c +2 -8
@@ -779,8 +779,6 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, ct =nf_ct_get (skb, &ctinfo);if (ct) { -bool add_helper = false; -/* Packets starting a new connection must be NATted before the * helper, so that the helper knows about the NAT. We enforce * this by delaying both NAT and helper calls for unconfirmed
@@ -812,7 +810,6 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, GFP_ATOMIC);if (err)return err; - add_helper = true;/* helper installed, add seqadj if NAT is required */ if (info->nat && !nfct_seqadj (ct)) {
@@ -822,13 +819,10 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, }/* Call the helper only if: -* - nf_conntrack_in() was executed above ("!cached") or a -* helper was just attached ("add_helper") for a confirmed -* connection, or +* - nf_conntrack_in() was executed above ("!cached"), or * - When committing an unconfirmed connection. */ -if ((nf_ct_is_confirmed (ct) ? !cached || add_helper : - info->commit)) { +if ((nf_ct_is_confirmed (ct) ? !cached : info->commit)) {int err =nf_ct_helper (skb, ct, ctinfo, info->family); err =verdict_to_errno (err);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 132/1674 net: openvswitch: conntrack: fix helper UAF due to extensions realloc
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
[ Upstream commit 1a4151e6be57b098b7a5ebfbde58585e83200cdc ]
While calling the helpers, a raw pointer to the extensions area is wired into expectations list:
-> nf_ct_helper()
-> helper->help()
-> nf_ct_expect_related_report()
-> nf_ct_expect_insert()
-> hlist_add_head_rcu(&exp->lnode, &master_help->expectations)In case the connection is not confirmed yet, more extensions can be added afterwards with *_ext_add() calls reallocating the extension space and leaving the now invalid pointer in the expectations list that is later accessed while removing the expectation.
Make sure that helpers are called at the end after all the other extensions are already added.
Note that the helper rejection now leaves the mark and labels set, but that's not different from how the NAT was handled before or how the mark and the labels were handled on confirmation failure. And there are no atomicity guarantees provided by the API anyway.
--- net/openvswitch/conntrack.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
net/openvswitch/conntrack.c +15 -4
@@ -818,11 +818,14 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, } } -/* Call the helper only if: -* - nf_conntrack_in() was executed above ("!cached"), or -* - When committing an unconfirmed connection. +/* Call the helper only if nf_conntrack_in() was executed +* above ("!cached"). +* +* For unconfirmed connections it will be called later during +* commit as we need to have all the other extensions allocated +* before the call. */ -if ((nf_ct_is_confirmed (ct) ? !cached : info->commit)) { +if (nf_ct_is_confirmed (ct) && !cached) {int err =nf_ct_helper (skb, ct, ctinfo, info->family); err =verdict_to_errno (err);
@@ -1025,6 +1028,14 @@ static int ovs_ct_commit(struct net *net, struct sw_flow_key *key,return err;nf_conn_act_ct_ext_add (skb, ct, ctinfo); + +/* Call the helpers now. We couldn't do this before as +* all the extensions must be allocated before the call. +*/ + err =nf_ct_helper (skb, ct, ctinfo, info->family); + err =verdict_to_errno (err); +if (err) +return err; }else if (IS_ENABLED (CONFIG_NF_CONNTRACK_LABELS ) &&labels_nonzero (&info->labels.mask)) { err = ovs_ct_set_labels(ct, key, &info->labels.value,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 133/1674 RISC-V: KVM: Fix null pointer dereference in kvm_riscv_aia_imsic_rw_attr()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiakai Xu <[email protected]>
[ Upstream commit aeb1d17d1af5924f7357d7204a293bd8fc06ea13 ]
Add a null pointer check for imsic_state before dereferencing it in kvm_riscv_aia_imsic_rw_attr(). While the function checks that the vcpu exists, it doesn't verify that the vcpu's imsic_state has been initialized, leading to a null pointer dereference when accessed.
The crash manifests as:
Unable to handle kernel paging request at virtual address dfffffff00000006 ... kvm_riscv_aia_imsic_rw_attr+0x2d8/0x854 arch/riscv/kvm/aia_imsic.c:958 aia_set_attr+0x2ee/0x1726 arch/riscv/kvm/aia_device.c:354 kvm_device_ioctl_attr virt/kvm/kvm_main.c:4744 [inline] kvm_device_ioctl+0x296/0x374 virt/kvm/kvm_main.c:4761 vfs_ioctl fs/ioctl.c:51 [inline] ...
The fix adds a check to return -ENODEV if imsic_state is NULL and moves isel assignment after imsic_state NULL check.
Stable-dep-of: 8ae12ccaec6e ("RISC-V: KVM: Serialize IMSIC attributes with vCPU migration")
--- arch/riscv/kvm/aia_imsic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/kvm/aia_imsic.c +3 -1
@@ -895,8 +895,10 @@ int kvm_riscv_aia_imsic_rw_attr(struct kvm *kvm, unsigned long type,if (!vcpu)return -ENODEV ; - isel =KVM_DEV_RISCV_AIA_IMSIC_GET_ISEL (type); imsic = vcpu->arch.aia_context.imsic_state; +if (!imsic) +return -ENODEV ; + isel =KVM_DEV_RISCV_AIA_IMSIC_GET_ISEL (type);read_lock_irqsave (&imsic->vsfile_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 134/1674 RISC-V: KVM: Serialize IMSIC attributes with vCPU migration
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xie Bo <[email protected]>
[ Upstream commit 8ae12ccaec6ec74945d8c1ef39f2c1b8df779abc ]
KVM device ioctls are not serialized against KVM_RUN. As a result, kvm_riscv_aia_imsic_rw_attr() can snapshot the physical CPU and HGEI of an IMSIC VS-file before a concurrent vCPU migration releases it.
The HGEI can then be allocated to another vCPU before imsic_vsfile_rw() uses the stale tuple. A GET or SET attribute may consequently access the new owner's interrupt file.
Serialize the entire IMSIC attribute operation with the target vCPU mutex. This prevents the VS-file from being migrated and recycled until the attribute access completes. Acquire the mutex killably so that the device ioctl remains interruptible while waiting for KVM_RUN to finish.
--- arch/riscv/kvm/aia_imsic.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
arch/riscv/kvm/aia_imsic.c +9 -2
@@ -895,9 +895,14 @@ int kvm_riscv_aia_imsic_rw_attr(struct kvm *kvm, unsigned long type,if (!vcpu)return -ENODEV ; +if (mutex_lock_killable (&vcpu->mutex)) +return -EINTR ; + imsic = vcpu->arch.aia_context.imsic_state; -if (!imsic) -return -ENODEV ; +if (!imsic) { + rc = -ENODEV ; + goto out_unlock; + } isel =KVM_DEV_RISCV_AIA_IMSIC_GET_ISEL (type);read_lock_irqsave (&imsic->vsfile_lock, flags);
@@ -921,6 +926,8 @@ int kvm_riscv_aia_imsic_rw_attr(struct kvm *kvm, unsigned long type, rc =imsic_vsfile_rw (vsfile_hgei, vsfile_cpu, imsic->nr_eix, isel, write, val); +out_unlock: +mutex_unlock (&vcpu->mutex);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 135/1674 super: make iterate_supers_type() deletion-safe
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 2d2a2d7aa98741b58f54cacc99b52024e4d865f9 ]
iterate_supers_type() drops sb_lock while invoking the callback and keeps only a passive reference to the current superblock. That reference keeps the object allocated, but does not keep its s_instances node linked.
After the iterator releases s_umount, final teardown can unlink the current s_instances node. The iterator then advances through a reinitialized node. With the current hlist it stops without visiting the remaining superblocks. The unlink moved from generic_shutdown_super() to kill_super_notify(), but the cursor lifetime has been unsafe since the helper was introduced.
The CIFS DFS lookup can consequently miss a matching superblock and return -EINVAL.
Move removal from fs_supers to put_super(), alongside removal from super_blocks, so a passive reference keeps both list nodes linked. Keep the filesystem module reference until then, since unlinking s_instances may touch type->fs_supers.
Make sget_fc() skip SB_DEAD superblocks before invoking test(), and set SB_DEAD under sb_lock to serialize with those callbacks. This allows kernfs to free its private information after kill_anon_super() returns. Keep matching SB_DYING superblocks until SB_DEAD is set so concurrent mounts still wait for teardown before retrying.
--- fs/kernfs/mount.c | 4 ++-- fs/super.c | 43 +++++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 22 deletions(-)
fs/kernfs/mount.c +2 -2
@@ -396,8 +396,8 @@ void kernfs_kill_sb(struct super_block *sb)up_write (&root->kernfs_supers_rwsem);/* -* Remove the superblock from fs_supers/s_instances -* so we can't find it, before freeing kernfs_super_info. +* Mark the superblock dead so sget_fc() can't find it, +* before freeing kernfs_super_info. */ kill_anon_super (sb);kfree (info);
fs/super.c +23 -20
91 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 136/1674 PCI: Fix Resizable BAR restore order
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit 5528fd38f230c906fcebb202cc94fbb8ed8f122a ]
The commit 337b1b566db0 ("PCI: Fix restoring BARs on BAR resize rollback path") changed BAR resize to layer rebar code and resource setup/restore code cleanly. Unfortunately, it did not consider how the value of the BAR Size field impacts the read-only bits in the Base Address Register (PCIe7 spec, sec. 7.8.6.3). That is, it very much matters in which order the BAR Size and Base Address Register are restored.
Post-337b1b566db0 ("PCI: Fix restoring BARs on BAR resize rollback path") during BAR resize rollback, pci_do_resource_release_and_resize() attempts to restore the old address to the BAR that was resized, but it can fail to setup the address correctly if the address has low bits set that collide with the bits that are still read-only. As a result, kernel's resource and BAR will be out-of-sync.
Fix this by restoring BAR Size before rolling back the resource changes and restoring the BAR.
[6.12 dependency preparation for d58384c22739848efe14b34e9586e4f1242f33c0:
Keep the existing memory-decoding and supported-size checks in rebar.c. Move BAR size programming and rollback into the resource release helper, so the old size is restored before restoring BAR addresses.
Use the assigned parent window to select resources for release, retaining the old flags-based selection when the resized BAR has no parent. Provide file-local macro mappings for the follow-up's bridge reassignment and resource assignment checks; no functions are added.
Retain the upstream pre-target pci_bus_sem placement to allow the target to apply without conflicts. This preparatory dependency must be applied together with d58384c22739848efe14b34e9586e4f1242f33c0, which takes the lock before releasing resources and assigns released BARs on root buses.]
Stable-dep-of: d58384c22739 ("PCI: Fix BAR resize for devices on a root bus")
--- drivers/pci/rebar.c | 19 +------------------ drivers/pci/setup-bus.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 25 deletions(-)
drivers/pci/rebar.c +1 -18
@@ -177,7 +177,6 @@ int pci_resize_resource(struct pci_dev *dev, int resno, int size, int exclude_bars) {struct pci_host_bridge *host; -int old, ret;u32 sizes;u16 cmd;
@@ -197,22 +196,6 @@ int pci_resize_resource(struct pci_dev *dev, int resno, int size,if (!(sizes &BIT (size)))return -EINVAL ; - old =pci_rebar_get_current_size (dev, resno); -if (old <0 ) -return old; - - ret =pci_rebar_set_size (dev, resno, size); -if (ret) -return ret; - - ret =pci_do_resource_release_and_resize (dev, resno, size, exclude_bars); -if (ret) - goto error_resize; - -return 0 ; - -error_resize: -pci_rebar_set_size (dev, resno, old); -return ret; +return pci_do_resource_release_and_resize (dev, resno, size, exclude_bars); }EXPORT_SYMBOL (pci_resize_resource);
drivers/pci/setup-bus.c +32 -7
@@ -2292,6 +2292,11 @@ static int pci_reassign_bridge_resources(struct pci_dev *bridge, unsigned long treturn 0 ; } +/* Keep the resize follow-up compatible with the 6.12 resource helpers. */ +#define pbus_reassign_bridge_resources (bus, res, saved) \ + pci_reassign_bridge_resources((bus)->self, (res)->flags, (saved)) +#define resource_assigned (res) ((res)->parent != NULL) +int pci_do_resource_release_and_resize (struct pci_dev *pdev,int resno,int size,int exclude_bars) {
@@ -2299,12 +2304,20 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int sizeunsigned long flags = res->flags;struct pci_dev_resource *dev_res;struct pci_bus *bus = pdev->bus; -struct resource *r; +struct resource *b_win, *r;LIST_HEAD (saved);unsigned int i; -int ret =0 ; +int old, ret; -down_read (&pci_bus_sem); + b_win = res->parent; + + old =pci_rebar_get_current_size (pdev, resno); +if (old <0 ) +return old; + + ret =pci_rebar_set_size (pdev, resno, size); +if (ret) +return ret;pci_dev_for_each_resource (pdev, r, i) {if (i >=PCI_BRIDGE_RESOURCES )
@@ -2313,7 +2326,10 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int sizeif (exclude_bars &BIT (i))continue ; -if (!pci_resource_len (pdev, i) || r->flags != flags) +if (!pci_resource_len (pdev, i)) +continue ; + +if (b_win ? r->parent != b_win : r->flags != flags)continue ; ret =add_to_list (&saved, pdev, r,0 ,0 );
@@ -2327,7 +2343,8 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int sizeif (!bus->self) goto out; - ret =pci_reassign_bridge_resources (bus->self, res->flags, &saved); +down_read (&pci_bus_sem); + ret =pbus_reassign_bridge_resources (bus, res, &saved);if (ret) goto restore;
@@ -2337,14 +2354,22 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int sizereturn ret; restore: -/* Revert to the old configuration */ +/* +* Revert to the old configuration. +* +* BAR Size must be restored first because it affects the read-only +* bits in BAR (the old address might not be restorable otherwise +* due to low address bits). +*/ +pci_rebar_set_size (pdev, resno, old); +list_for_each_entry (dev_res, &saved, list) {struct resource *res = dev_res->res;struct pci_dev *dev = dev_res->dev; i = res - dev->resource; -if (res->parent) { +if (resource_assigned (res)) {release_child_resources (res);pci_release_resource (dev, i); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 137/1674 PCI: Fix BAR resize for devices on a root bus
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liz Fong-Jones <[email protected]>
[ Upstream commit d58384c22739848efe14b34e9586e4f1242f33c0 ]
pci_do_resource_release_and_resize() releases device BARs that share a bridge window with the BAR being resized, but when the device sits directly on a root bus (pdev->bus->self == NULL) it then skips resource assignment entirely and returns success, leaving the BARs it just released unassigned (IORESOURCE_UNSET).
Skipping pbus_reassign_bridge_resources() is correct in that case -- there is no bridge window to adjust -- but the device BARs still have to be reassigned. Before the BAR release was consolidated into the PCI core, this case worked for amdgpu because the driver released the BARs itself and then called pci_assign_unassigned_bus_resources() unconditionally after the resize, which assigns unassigned device BARs also on a root bus. Commit db92e3fef53e ("drm/amdgpu: Remove driver side BAR release before resize") removed that call, so nothing assigns the released BARs anymore.
This breaks amdgpu completely on the SolidRun HoneyComb LX2K (NXP LX2160A, arm64, ACPI), where ACPI doesn't expose the Root Port so the GPU endpoint appears directly on a "root bus" of its segment:
amdgpu 0004:01:00.0: BAR 0 [mem 0xa400000000-0xa40fffffff 64bit pref]: releasing amdgpu 0004:01:00.0: BAR 2 [mem 0xa410000000-0xa4101fffff 64bit pref]: releasing amdgpu 0004:01:00.0: sw_init of IP block <gmc_v8_0> failed -19 amdgpu 0004:01:00.0: amdgpu_device_ip_init failed
amdgpu 0004:01:00.0: Fatal error during GPU init
No error is logged because the resize path reports success; amdgpu then finds BAR 0 IORESOURCE_UNSET and bails out with -ENODEV.
When there is no upstream bridge, call pci_bus_assign_resources() on the root bus to place the BARs released above, using the same alignment-sorted algorithm as normal enumeration instead of a manual per-BAR loop. This also walks the rest of the hierarchy under the root bus, as pci_assign_unassigned_bus_resources() used to for amdgpu before commit db92e3fef53e ("drm/amdgpu: Remove driver side BAR release before resize") removed that call -- the core-side fix that commit asked for ("such a problem should be fixed inside pci_resize_resource() instead").
pci_bus_assign_resources() returns void, so failure is detected by checking whether the released BARs are still assigned afterward; if not, roll back as in the bridged case. This is stricter than the bridged path -- it fails on any unplaced resource, not just required ones -- since a root bus typically has one shared window, and failing loudly seemed better than leaving something silently unassigned.
The root bus path also had a locking bug that any fix here necessarily
touches: the old "goto out" jumped to up_read(&pci_bus_sem) without a matching down_read() (as does the "goto restore" taken when pci_dev_res_add_to_list() fails in the release loop). Take pci_bus_sem before the BAR release loop so every path through the function holds it exactly once.
--- drivers/pci/setup-bus.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/pci/setup-bus.c +17 -6
@@ -2304,6 +2304,7 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int sizeunsigned long flags = res->flags;struct pci_dev_resource *dev_res;struct pci_bus *bus = pdev->bus; +struct pci_dev *bridge =pci_upstream_bridge (pdev);struct resource *b_win, *r;LIST_HEAD (saved);unsigned int i;
@@ -2319,6 +2320,8 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int sizeif (ret)return ret; +down_read (&pci_bus_sem); +pci_dev_for_each_resource (pdev, r, i) {if (i >=PCI_BRIDGE_RESOURCES )break ;
@@ -2340,13 +2343,21 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size res->end = res->start +pci_rebar_size_to_bytes (size) -1 ; -if (!bus->self) - goto out; +if (bridge) { + ret =pbus_reassign_bridge_resources (bus, res, &saved); +if (ret) + goto restore; + }else { +/* No bridge window to adjust; let the core reassign the bus. */ +pci_bus_assign_resources (bus); -down_read (&pci_bus_sem); - ret =pbus_reassign_bridge_resources (bus, res, &saved); -if (ret) - goto restore; +list_for_each_entry (dev_res, &saved, list) { +if (!resource_assigned (dev_res->res)) { + ret = -ENOSPC ; + goto restore; + } + } + } out:up_read (&pci_bus_sem);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 138/1674 net: ipconfig: Remove outdated comment and indent code block
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit e405b3c9d4aaa10972525fe2ea5cf94224020561 ]
The comment has been around ever since commit 1da177e4c3f4 ("Linux-2.6.12-rc2") and can be removed. Remove it and indent the code block accordingly.
Stable-dep-of: e47a1958e12a ("net: ipconfig: bound DHCP option construction")
--- net/ipv4/ipconfig.c | 89 +++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 47 deletions(-)
net/ipv4/ipconfig.c +42 -47
@@ -679,8 +679,18 @@ static const u8 ic_bootp_cookie[4] = { 99, 130, 83, 99 };static void __init ic_dhcp_init_options (u8 *options,struct ic_device *d) { -u8 mt = ((ic_servaddr ==NONE ) - ?DHCPDISCOVER :DHCPREQUEST ); +static const u8 ic_req_params[] = { +1 ,/* Subnet mask */ +3 ,/* Default gateway */ +6 ,/* DNS server */ +12 ,/* Host name */ +15 ,/* Domain name */ +17 ,/* Boot path */ +26 ,/* MTU */ +40 ,/* NIS domain name */ +42 ,/* NTP servers */ + }; +u8 mt = (ic_servaddr ==NONE ) ?DHCPDISCOVER :DHCPREQUEST ;u8 *e = options;int len;
@@ -705,51 +715,36 @@ ic_dhcp_init_options(u8 *options, struct ic_device *d) e +=4 ; } -/* always? */ - { -static const u8 ic_req_params[] = { -1 ,/* Subnet mask */ -3 ,/* Default gateway */ -6 ,/* DNS server */ -12 ,/* Host name */ -15 ,/* Domain name */ -17 ,/* Boot path */ -26 ,/* MTU */ -40 ,/* NIS domain name */ -42 ,/* NTP servers */ - }; - - *e++ =55 ;/* Parameter request list */ - *e++ =sizeof (ic_req_params); -memcpy (e, ic_req_params,sizeof (ic_req_params)); - e +=sizeof (ic_req_params); - -if (ic_host_name_set) { - *e++ =12 ;/* host-name */ - len =strlen (utsname ()->nodename); - *e++ = len; -memcpy (e,utsname ()->nodename, len); - e += len; - } -if (*vendor_class_identifier) { -pr_info ("DHCP: sending class identifier \"%s\"\n" , - vendor_class_identifier); - *e++ =60 ;/* Class-identifier */ - len =strlen (vendor_class_identifier); - *e++ = len; -memcpy (e, vendor_class_identifier, len); - e += len; - } - len =strlen (dhcp_client_identifier +1 ); -/* the minimum length of identifier is 2, include 1 byte type, -* and can not be larger than the length of options -*/ -if (len >=1 && len <312 - (e - options) -1 ) { - *e++ =61 ; - *e++ = len +1 ; -memcpy (e, dhcp_client_identifier, len +1 ); - e += len +1 ; - } + *e++ =55 ;/* Parameter request list */ + *e++ =sizeof (ic_req_params); +memcpy (e, ic_req_params,sizeof (ic_req_params)); + e +=sizeof (ic_req_params); + +if (ic_host_name_set) { + *e++ =12 ;/* host-name */ + len =strlen (utsname ()->nodename); + *e++ = len; +memcpy (e,utsname ()->nodename, len); + e += len; + } +if (*vendor_class_identifier) { +pr_info ("DHCP: sending class identifier \"%s\"\n" , + vendor_class_identifier); + *e++ =60 ;/* Class-identifier */ + len =strlen (vendor_class_identifier); + *e++ = len; +memcpy (e, vendor_class_identifier, len); + e += len; + } + len =strlen (dhcp_client_identifier +1 ); +/* the minimum length of identifier is 2, include 1 byte type, +* and can not be larger than the length of options +*/ +if (len >=1 && len <312 - (e - options) -1 ) { + *e++ =61 ; + *e++ = len +1 ; +memcpy (e, dhcp_client_identifier, len +1 ); + e += len +1 ; } *e++ =255 ;/* End of the list */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 139/1674 net: ipconfig: bound DHCP option construction
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuqi Xu <[email protected]>
[ Upstream commit e47a1958e12abc3a17b5231a4f21c8f1bf662e08 ]
ic_dhcp_init_options() appends the hostname (option 12), vendor-class (option 60) and client-ID (option 61) options into the fixed 312-byte bootp_pkt.exten[] buffer. Only the client-ID branch checked the remaining space; the hostname and vendor-class writes were unbounded.
A 64-byte hostname together with the maximum 252-byte dhcpclass= identifier needs 18 + (2 + 64) + (2 + 252) = 338 of the 312 available bytes even before the terminating END marker, so the vendor-class memcpy runs past the end of exten[]. With CONFIG_FORTIFY_SOURCE this is reported as a field-spanning write and, when the kernel is booted with panic_on_warn=1, aborts boot with a panic.
Route the optional options through a common helper that makes sure the option, its 2-byte header and the END marker all fit and drops an option that would not. Configurations with short options keep sending exactly the same bytes as before.
--- net/ipv4/ipconfig.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-)
net/ipv4/ipconfig.c +26 -19
@@ -676,6 +676,24 @@ static const u8 ic_bootp_cookie[4] = { 99, 130, 83, 99 };#ifdef IPCONFIG_DHCP +static bool __init +ic_dhcp_add_option (u8 **options,const u8 *end,u8 type,const void *value, +int len) +{ +u8 *e = *options; + +/* leave room for the option header and the END marker */ +if (len >U8_MAX || end - e < len +3 ) +return false; + + *e++ = type; + *e++ = len; +memcpy (e, value, len); + *options = e + len; + +return true; +} +static void __init ic_dhcp_init_options (u8 *options,struct ic_device *d) {
@@ -691,6 +709,7 @@ ic_dhcp_init_options(u8 *options, struct ic_device *d) 42, /* NTP servers */ };u8 mt = (ic_servaddr ==NONE ) ?DHCPDISCOVER :DHCPREQUEST ; +u8 *end = options +sizeof (((struct bootp_pkt *)0 )->exten);u8 *e = options;int len;
@@ -721,31 +740,19 @@ ic_dhcp_init_options(u8 *options, struct ic_device *d) e +=sizeof (ic_req_params);if (ic_host_name_set) { - *e++ =12 ;/* host-name */ len =strlen (utsname ()->nodename); - *e++ = len; -memcpy (e,utsname ()->nodename, len); - e += len; +ic_dhcp_add_option (&e, end,12 ,utsname ()->nodename, len); }if (*vendor_class_identifier) { -pr_info ("DHCP: sending class identifier \"%s\"\n" , - vendor_class_identifier); - *e++ =60 ;/* Class-identifier */ len =strlen (vendor_class_identifier); - *e++ = len; -memcpy (e, vendor_class_identifier, len); - e += len; +if (ic_dhcp_add_option (&e, end,60 , vendor_class_identifier, len)) +pr_info ("DHCP: sending class identifier \"%s\"\n" , + vendor_class_identifier); } len =strlen (dhcp_client_identifier +1 ); -/* the minimum length of identifier is 2, include 1 byte type, -* and can not be larger than the length of options -*/ -if (len >=1 && len <312 - (e - options) -1 ) { - *e++ =61 ; - *e++ = len +1 ; -memcpy (e, dhcp_client_identifier, len +1 ); - e += len +1 ; - } +/* the minimum length of identifier is 2, include 1 byte type */ +if (len >=1 ) +ic_dhcp_add_option (&e, end,61 , dhcp_client_identifier, len +1 ); *e++ =255 ;/* End of the list */ }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 140/1674 perf: Supply task information to sched_task()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
[ Upstream commit d57e94f5b891925e4f2796266eba31edd5a01903 ]
To save/restore LBR call stack data in system-wide mode, the task_struct information is required.
Extend the parameters of sched_task() to supply task_struct information.
When schedule in, the LBR call stack data for new task will be restored. When schedule out, the LBR call stack data for old task will be saved. Only need to pass the required task_struct information.
[Backport to 6.6: retain task_ctx_sched_out(ctx, EVENT_ALL), since this tree does not have the additional PMU argument used upstream. Keep the sched_task task argument throughout the existing callbacks so 36bb85cf36ca can apply without further changes.]
Stable-dep-of: 36bb85cf36ca ("perf/core: Fix NULL pmu_ctx passed to pmu->sched_task()")
--- arch/powerpc/perf/core-book3s.c | 8 ++++++-- arch/s390/kernel/perf_pai_crypto.c | 3 ++- arch/s390/kernel/perf_pai_ext.c | 3 ++- arch/x86/events/amd/brs.c | 3 ++- arch/x86/events/amd/lbr.c | 3 ++- arch/x86/events/core.c | 5 +++-- arch/x86/events/intel/core.c | 4 ++-- arch/x86/events/intel/lbr.c | 3 ++- arch/x86/events/perf_event.h | 14 +++++++++----- include/linux/perf_event.h | 2 +- kernel/events/core.c | 20 +++++++++++--------- 11 files changed, 42 insertions(+), 26 deletions(-)
arch/powerpc/perf/core-book3s.c +6 -2
@@ -132,7 +132,10 @@ static unsigned long ebb_switch_in(bool ebb, struct cpu_hw_events *cpuhw)static inline void power_pmu_bhrb_enable (struct perf_event *event) {}static inline void power_pmu_bhrb_disable (struct perf_event *event) {} -static void power_pmu_sched_task (struct perf_event_pmu_context *pmu_ctx,bool sched_in) {} +static void power_pmu_sched_task (struct perf_event_pmu_context *pmu_ctx, +struct task_struct *task,bool sched_in) +{ +}static inline void power_pmu_bhrb_read (struct perf_event *event,struct cpu_hw_events *cpuhw) {}static void pmao_restore_workaround (bool ebb) { }#endif /* CONFIG_PPC32 */
@@ -451,7 +454,8 @@ static void power_pmu_bhrb_disable(struct perf_event *event)/* Called from ctxsw to prevent one process's branch entries to * mingle with the other process's entries during context switch. */ -static void power_pmu_sched_task (struct perf_event_pmu_context *pmu_ctx,bool sched_in) +static void power_pmu_sched_task (struct perf_event_pmu_context *pmu_ctx, +struct task_struct *task,bool sched_in) {if (!ppmu->bhrb_nr)return ;
arch/s390/kernel/perf_pai_crypto.c +2 -1
@@ -378,7 +378,8 @@ static int paicrypt_push_sample(void)/* Called on schedule-in and schedule-out. No access to event structure, * but for sampling only event CRYPTO_ALL is allowed. */ -static void paicrypt_sched_task (struct perf_event_pmu_context *pmu_ctx,bool sched_in) +static void paicrypt_sched_task (struct perf_event_pmu_context *pmu_ctx, +struct task_struct *task,bool sched_in) {/* We started with a clean page on event installation. So read out * results on schedule_out and if page was dirty, clear values.
arch/s390/kernel/perf_pai_ext.c +2 -1
@@ -467,7 +467,8 @@ static int paiext_push_sample(void)/* Called on schedule-in and schedule-out. No access to event structure, * but for sampling only event NNPA_ALL is allowed. */ -static void paiext_sched_task (struct perf_event_pmu_context *pmu_ctx,bool sched_in) +static void paiext_sched_task (struct perf_event_pmu_context *pmu_ctx, +struct task_struct *task,bool sched_in) {/* We started with a clean page on event installation. So read out * results on schedule_out and if page was dirty, clear values.
arch/x86/events/amd/brs.c +2 -1
@@ -381,7 +381,8 @@ static void amd_brs_poison_buffer(void)* On ctxswin, sched_in = true, called after the PMU has started * On ctxswout, sched_in = false, called before the PMU is stopped */ -void amd_pmu_brs_sched_task (struct perf_event_pmu_context *pmu_ctx,bool sched_in) +void amd_pmu_brs_sched_task (struct perf_event_pmu_context *pmu_ctx, +struct task_struct *task,bool sched_in) {struct cpu_hw_events *cpuc =this_cpu_ptr (&cpu_hw_events);
arch/x86/events/amd/lbr.c +2 -1
@@ -376,7 +376,8 @@ void amd_pmu_lbr_del(struct perf_event *event)perf_sched_cb_dec (event->pmu); } -void amd_pmu_lbr_sched_task (struct perf_event_pmu_context *pmu_ctx,bool sched_in) +void amd_pmu_lbr_sched_task (struct perf_event_pmu_context *pmu_ctx, +struct task_struct *task,bool sched_in) {struct cpu_hw_events *cpuc =this_cpu_ptr (&cpu_hw_events);
arch/x86/events/core.c +3 -2
@@ -2626,9 +2626,10 @@ static const struct attribute_group *x86_pmu_attr_groups[] = { NULL, }; -static void x86_pmu_sched_task (struct perf_event_pmu_context *pmu_ctx,bool sched_in) +static void x86_pmu_sched_task (struct perf_event_pmu_context *pmu_ctx, +struct task_struct *task,bool sched_in) { -static_call_cond (x86_pmu_sched_task)(pmu_ctx, sched_in); +static_call_cond (x86_pmu_sched_task)(pmu_ctx, task, sched_in); } static void x86_pmu_swap_task_ctx(struct perf_event_pmu_context *prev_epc,
arch/x86/events/intel/core.c +2 -2
@@ -4963,10 +4963,10 @@ static void intel_pmu_cpu_dead(int cpu) }static void intel_pmu_sched_task (struct perf_event_pmu_context *pmu_ctx, -bool sched_in) +struct task_struct *task,bool sched_in) {intel_pmu_pebs_sched_task (pmu_ctx, sched_in); -intel_pmu_lbr_sched_task (pmu_ctx, sched_in); +intel_pmu_lbr_sched_task (pmu_ctx, task, sched_in); } static void intel_pmu_swap_task_ctx(struct perf_event_pmu_context *prev_epc,
arch/x86/events/intel/lbr.c +2 -1
@@ -538,7 +538,8 @@ void intel_pmu_lbr_swap_task_ctx(struct perf_event_pmu_context *prev_epc, task_context_opt(next_ctx_data)->lbr_callstack_users); } -void intel_pmu_lbr_sched_task (struct perf_event_pmu_context *pmu_ctx,bool sched_in) +void intel_pmu_lbr_sched_task (struct perf_event_pmu_context *pmu_ctx, +struct task_struct *task,bool sched_in) {struct cpu_hw_events *cpuc =this_cpu_ptr (&cpu_hw_events);void *task_ctx;
arch/x86/events/perf_event.h +9 -5
@@ -816,7 +816,7 @@ struct x86_pmu {void (*check_microcode)(void );void (*sched_task)(struct perf_event_pmu_context *pmu_ctx, -bool sched_in); +struct task_struct *task,bool sched_in);/* * Intel Arch Perfmon v2+
@@ -1310,7 +1310,8 @@ void amd_pmu_lbr_reset(void);void amd_pmu_lbr_read (void );void amd_pmu_lbr_add (struct perf_event *event);void amd_pmu_lbr_del (struct perf_event *event); -void amd_pmu_lbr_sched_task (struct perf_event_pmu_context *pmu_ctx,bool sched_in); +void amd_pmu_lbr_sched_task (struct perf_event_pmu_context *pmu_ctx, +struct task_struct *task,bool sched_in);void amd_pmu_lbr_enable_all (void );void amd_pmu_lbr_disable_all (void );int amd_pmu_lbr_hw_config (struct perf_event *event);
@@ -1351,7 +1352,8 @@ static inline void amd_pmu_brs_del(struct perf_event *event) perf_sched_cb_dec(event->pmu); } -void amd_pmu_brs_sched_task (struct perf_event_pmu_context *pmu_ctx,bool sched_in); +void amd_pmu_brs_sched_task (struct perf_event_pmu_context *pmu_ctx, +struct task_struct *task,bool sched_in);#else static inline int amd_brs_init (void ) {
@@ -1376,7 +1378,8 @@ static inline void amd_pmu_brs_del(struct perf_event *event) { } -static inline void amd_pmu_brs_sched_task (struct perf_event_pmu_context *pmu_ctx,bool sched_in) +static inline void amd_pmu_brs_sched_task (struct perf_event_pmu_context *pmu_ctx, +struct task_struct *task,bool sched_in) { }
@@ -1558,7 +1561,8 @@ void intel_ds_init(void);void intel_pmu_lbr_swap_task_ctx (struct perf_event_pmu_context *prev_epc,struct perf_event_pmu_context *next_epc); -void intel_pmu_lbr_sched_task (struct perf_event_pmu_context *pmu_ctx,bool sched_in); +void intel_pmu_lbr_sched_task (struct perf_event_pmu_context *pmu_ctx, +struct task_struct *task,bool sched_in);u64 lbr_from_signext_quirk_wr (u64 val);
include/linux/perf_event.h +1 -1
@@ -453,7 +453,7 @@ struct pmu {* context-switches callback */ void (*sched_task) (struct perf_event_pmu_context *pmu_ctx, -bool sched_in); +struct task_struct *task,bool sched_in);/* * Kmem cache of PMU specific data
kernel/events/core.c +11 -9
@@ -3524,7 +3524,8 @@ static void perf_event_swap_task_ctx_data(struct perf_event_context *prev_ctx, } } -static void perf_ctx_sched_task_cb (struct perf_event_context *ctx,bool sched_in) +static void perf_ctx_sched_task_cb (struct perf_event_context *ctx, +struct task_struct *task,bool sched_in) {struct perf_event_pmu_context *pmu_ctx;struct perf_cpu_pmu_context *cpc;
@@ -3533,7 +3534,7 @@ static void perf_ctx_sched_task_cb(struct perf_event_context *ctx, bool sched_in cpc =this_cpu_ptr (pmu_ctx->pmu->cpu_pmu_context);if (cpc->sched_cb_usage && pmu_ctx->pmu->sched_task) - pmu_ctx->pmu->sched_task (pmu_ctx, sched_in); + pmu_ctx->pmu->sched_task (pmu_ctx, task, sched_in); } }
@@ -3591,7 +3592,7 @@ perf_event_context_sched_out(struct task_struct *task, struct task_struct *next)WRITE_ONCE (ctx->task, next);WRITE_ONCE (next_ctx->task, task); -perf_ctx_sched_task_cb (ctx, false); +perf_ctx_sched_task_cb (ctx, task, false);perf_event_swap_task_ctx_data (ctx, next_ctx);perf_ctx_enable (ctx, false);
@@ -3621,7 +3622,7 @@ perf_event_context_sched_out(struct task_struct *task, struct task_struct *next)perf_ctx_disable (ctx, false); inside_switch: -perf_ctx_sched_task_cb (ctx, false); +perf_ctx_sched_task_cb (ctx, task, false);task_ctx_sched_out (ctx,EVENT_ALL );perf_ctx_enable (ctx, false);
@@ -3663,7 +3664,8 @@ void perf_sched_cb_inc(struct pmu *pmu)* PEBS requires this to provide PID/TID information. This requires we flush * all queued PEBS records before we context switch to a new task. */ -static void __perf_pmu_sched_task (struct perf_cpu_pmu_context *cpc,bool sched_in) +static void __perf_pmu_sched_task (struct perf_cpu_pmu_context *cpc, +struct task_struct *task,bool sched_in) {struct perf_cpu_context *cpuctx =this_cpu_ptr (&perf_cpu_context);struct pmu *pmu;
@@ -3677,7 +3679,7 @@ static void __perf_pmu_sched_task(struct perf_cpu_pmu_context *cpc, bool sched_iperf_ctx_lock (cpuctx, cpuctx->task_ctx);perf_pmu_disable (pmu); - pmu->sched_task (cpc->task_epc, sched_in); + pmu->sched_task (cpc->task_epc, task, sched_in);perf_pmu_enable (pmu);perf_ctx_unlock (cpuctx, cpuctx->task_ctx);
@@ -3695,7 +3697,7 @@ static void perf_pmu_sched_task(struct task_struct *prev,return ;list_for_each_entry (cpc,this_cpu_ptr (&sched_cb_list), sched_cb_entry) -__perf_pmu_sched_task (cpc, sched_in); +__perf_pmu_sched_task (cpc, sched_in ? next : prev, sched_in); } static void perf_event_switch(struct task_struct *task,
@@ -3999,7 +4001,7 @@ static void perf_event_context_sched_in(struct task_struct *task)perf_ctx_lock (cpuctx, ctx);perf_ctx_disable (ctx, false); -perf_ctx_sched_task_cb (ctx, true); +perf_ctx_sched_task_cb (ctx, task, true);perf_ctx_enable (ctx, false);perf_ctx_unlock (cpuctx, ctx);
@@ -4030,7 +4032,7 @@ static void perf_event_context_sched_in(struct task_struct *task)perf_event_sched_in (cpuctx, ctx); -perf_ctx_sched_task_cb (cpuctx->task_ctx, true); +perf_ctx_sched_task_cb (cpuctx->task_ctx, task, true);if (!RB_EMPTY_ROOT (&ctx->pinned_groups.tree))perf_ctx_enable (&cpuctx->ctx, false);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 141/1674 perf/core: Fix NULL pmu_ctx passed to pmu->sched_task()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Puranjay Mohan <[email protected]>
[ Upstream commit 36bb85cf36cab15fb611cb44b78a5df06e4e69a2 ]
perf_pmu_sched_task() returns early when cpuctx->task_ctx is set, and cpc->task_epc is only non-NULL while a task context is scheduled in on this CPU. __perf_pmu_sched_task() therefore always passes NULL:
Unable to handle kernel NULL pointer dereference at virtual address 00 pc : armv8pmu_sched_task+0x14/0x50 Call trace: armv8pmu_sched_task+0x14/0x50 (P) perf_pmu_sched_task+0xac/0x108 __perf_event_task_sched_out+0x6c/0xe0
Pass &cpc->epc instead, the CPU-wide context for this PMU, which the function already dereferences a few lines up to find pmu.
armv8pmu_sched_task() is the only in-tree implementation that dereferences the argument, and it only reads ->pmu, so the oops needs BRBE, added in v6.17.
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -3679,7 +3679,7 @@ static void __perf_pmu_sched_task(struct perf_cpu_pmu_context *cpc,perf_ctx_lock (cpuctx, cpuctx->task_ctx);perf_pmu_disable (pmu); - pmu->sched_task (cpc->task_epc, task, sched_in); + pmu->sched_task (&cpc->epc, task, sched_in);perf_pmu_enable (pmu);perf_ctx_unlock (cpuctx, cpuctx->task_ctx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 142/1674 perf/core: Allow list_del during perf_event_overflow()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Richter <[email protected]>
[ Upstream commit 59e63416f5153e7d58652c616fbdcb7d5e01fff7 ]
A PMU might use perf_sched_cb_inc() and perf_sched_cb_dec() interface to get the PMU call back function pmu::sched_task invoked at schedule in and schedule out. This is achieved by walking along the list anchored by sched_cb_list.
The following scenario might lead to a list corruption.
perf_pmu_sched_task()
for_each_list_entry(..., &sched_cb_list)
+--> __perf_pmu_sched_task()
+--> event->pmu->sched_task())
+--> PMU_push_sample()
+--> perf_event_overflow()
+--> __perf_event_overflow()
+--> pmu->stop()
+--> perf_sched_cb_dec()
remove entry from sched_cb_list
while list node in use.This happens when ioctl(fd, PERF_EVENT_IOC_REFRESH, xxx) has been invoked and perf_event::event_limit hits zero.
Prevent the list corruption and convert for_each_list_entry() to for_each_list_entry_safe().
--- kernel/events/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/events/core.c +2 -2
@@ -3690,13 +3690,13 @@ static void perf_pmu_sched_task(struct task_struct *prev, bool sched_in) {struct perf_cpu_context *cpuctx =this_cpu_ptr (&perf_cpu_context); -struct perf_cpu_pmu_context *cpc; +struct perf_cpu_pmu_context *cpc, *cpc2;/* cpuctx->task_ctx will be handled in perf_event_context_sched_in/out */ if (prev == next || cpuctx->task_ctx)return ; -list_for_each_entry (cpc,this_cpu_ptr (&sched_cb_list), sched_cb_entry) +list_for_each_entry_safe (cpc, cpc2,this_cpu_ptr (&sched_cb_list), sched_cb_entry)__perf_pmu_sched_task (cpc, sched_in ? next : prev, sched_in); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 143/1674 perf/core: Run sched_task() for PMUs with only CPU-wide events
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Puranjay Mohan <[email protected]>
[ Upstream commit 3d8d74100954a3b17e5c5e37adfe14e16b1db103 ]
perf_pmu_sched_task() returns early when cpuctx->task_ctx is set and leaves the work to perf_ctx_sched_task_cb(), which only walks ctx->pmu_ctx_list. A PMU whose events are all CPU-wide is not on that list, so nothing calls its sched_task(). With
perf record -b -e cycles -a -- ls
armv8pmu_sched_task() is skipped on every switch to a task that has a perf context but no event on that PMU, and BRBE records leak across the task boundary. intel_pmu_lbr_add() calls perf_sched_cb_inc() unconditionally too, so LBR records leak the same way on x86.
Drop the early return and skip only the CPCs that perf_ctx_sched_task_cb() handles. That one needs a gate of its own to make the split exact: it tests cpc->sched_cb_usage, which perf_sched_cb_inc() sets per CPU for every branch stack user, so a task with an event for that PMU pinned to another CPU would be handled twice. On x86 the second __intel_pmu_lbr_restore() finds lbr_stack_state == LBR_NONE and calls intel_pmu_lbr_reset(), throwing away the callstack the first one restored.
cpc->task_epc is set only while a task context is scheduled in, and there is one epc per PMU on ctx->pmu_ctx_list, so the two gates are inverses.
For the CPCs perf_pmu_sched_task() picks up, the callback now runs outside the perf_ctx_disable() and perf_ctx_enable() pair in perf_event_context_sched_in(). __perf_pmu_sched_task() disables the PMU around the call itself.
--- kernel/events/core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
kernel/events/core.c +9 -4
@@ -3533,6 +3533,9 @@ static void perf_ctx_sched_task_cb(struct perf_event_context *ctx,list_for_each_entry (pmu_ctx, &ctx->pmu_ctx_list, pmu_ctx_entry) { cpc =this_cpu_ptr (pmu_ctx->pmu->cpu_pmu_context); +if (cpc->task_epc != pmu_ctx) +continue ; +if (cpc->sched_cb_usage && pmu_ctx->pmu->sched_task) pmu_ctx->pmu->sched_task (pmu_ctx, task, sched_in); }
@@ -3689,15 +3692,17 @@ static void perf_pmu_sched_task(struct task_struct *prev, struct task_struct *next, bool sched_in) { -struct perf_cpu_context *cpuctx =this_cpu_ptr (&perf_cpu_context);struct perf_cpu_pmu_context *cpc, *cpc2; -/* cpuctx->task_ctx will be handled in perf_event_context_sched_in/out */ -if (prev == next || cpuctx->task_ctx) +if (prev == next)return ; -list_for_each_entry_safe (cpc, cpc2,this_cpu_ptr (&sched_cb_list), sched_cb_entry) +list_for_each_entry_safe (cpc, cpc2,this_cpu_ptr (&sched_cb_list), sched_cb_entry) { +if (cpc->task_epc) +continue ; +__perf_pmu_sched_task (cpc, sched_in ? next : prev, sched_in); + } } static void perf_event_switch(struct task_struct *task,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 144/1674 net: ena: Remove autopolling mode
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dr. David Alan Gilbert <[email protected]>
[ Upstream commit b356b9170815f822394667010d478d53901ff581 ]
This manually reverts
commit a4e262cde3cd ("net: ena: allow automatic fallback to polling mode")
which is unused.
(I did it manually because there are other minor comment and function changes surrounding it).
Build tested only.
Stable-dep-of: 9476b4468862 ("net: ena: fix MMIO read buffer leak on probe failure")
--- drivers/net/ethernet/amazon/ena/ena_com.c | 25 +++++------------------ drivers/net/ethernet/amazon/ena/ena_com.h | 14 ------------- 2 files changed, 5 insertions(+), 34 deletions(-)
drivers/net/ethernet/amazon/ena/ena_com.c +5 -20
@@ -763,25 +763,16 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *comif (comp_ctx->status ==ENA_CMD_COMPLETED ) {netdev_err (admin_queue->ena_dev->net_device, -"The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n" , - comp_ctx->cmd_opcode, admin_queue->auto_polling ?"ON" :"OFF" ); -/* Check if fallback to polling is enabled */ -if (admin_queue->auto_polling) - admin_queue->polling = true; +"The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d)\n" , + comp_ctx->cmd_opcode); }else {netdev_err (admin_queue->ena_dev->net_device,"The ena device didn't send a completion for the admin cmd %d status %d\n" , comp_ctx->cmd_opcode, comp_ctx->status); } -/* Check if shifted to polling mode. -* This will happen if there is a completion without an interrupt -* and autopolling mode is enabled. Continuing normal execution in such case -*/ -if (!admin_queue->polling) { - admin_queue->running_state = false; - ret = -ETIME ; - goto err; - } + admin_queue->running_state = false; + ret = -ETIME ; + goto err; } ret =ena_com_comp_status_to_errno (admin_queue, comp_ctx->comp_status);
@@ -1658,12 +1649,6 @@ void ena_com_set_admin_polling_mode(struct ena_com_dev *ena_dev, bool polling) ena_dev->admin_queue.polling = polling; } -void ena_com_set_admin_auto_polling_mode (struct ena_com_dev *ena_dev, -bool polling) -{ - ena_dev->admin_queue.auto_polling = polling; -} -int ena_com_mmio_reg_read_request_init (struct ena_com_dev *ena_dev) {struct ena_com_mmio_read *mmio_read = &ena_dev->mmio_read;
drivers/net/ethernet/amazon/ena/ena_com.h +0 -14
@@ -227,9 +227,6 @@ struct ena_com_admin_queue {/* Indicate if the admin queue should poll for completion */ bool polling; -/* Define if fallback to polling mode should occur */ -bool auto_polling; -u16 curr_cmd_id;/* Indicate that the ena was initialized and can
@@ -484,17 +481,6 @@ bool ena_com_get_admin_running_state(struct ena_com_dev *ena_dev);*/ void ena_com_set_admin_polling_mode (struct ena_com_dev *ena_dev,bool polling); -/* ena_com_set_admin_auto_polling_mode - Enable autoswitch to polling mode -* @ena_dev: ENA communication layer struct -* @polling: Enable/Disable polling mode -* -* Set the autopolling mode. -* If autopolling is on: -* In case of missing interrupt when data is available switch to polling. -*/ -void ena_com_set_admin_auto_polling_mode (struct ena_com_dev *ena_dev, -bool polling); -/* ena_com_admin_q_comp_intr_handler - admin queue interrupt handler * @ena_dev: ENA communication layer struct *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 145/1674 net: ena: fix MMIO read buffer leak on probe failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 9476b4468862927297c94c440863cd8ed1e7cc83 ]
ena_device_init() initializes the MMIO read mechanism with ena_com_mmio_reg_read_request_init(), which allocates a coherent DMA buffer for MMIO read responses.
The normal removal path releases this buffer through ena_com_mmio_reg_read_request_destroy(). However, if ena_probe() fails after ena_device_init() succeeds, the error path destroys the admin resources and eventually frees ena_dev without destroying the MMIO read request, leaving the coherent DMA buffer allocated.
Call ena_com_mmio_reg_read_request_destroy() in the probe error path before releasing the remaining device resources.
This issue was found by manual code inspection.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/amazon/ena/ena_netdev.c +1 -0
@@ -3990,6 +3990,7 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_device_destroy:ena_com_delete_host_info (ena_dev);ena_com_admin_destroy (ena_dev); +ena_com_mmio_reg_read_request_destroy (ena_dev); err_netdev_destroy:free_netdev (netdev); err_free_region:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 146/1674 netfilter: nf_tables: set->ops->insert returns opaque set element in case of EEXIST
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 078996fcd657e6e0c3a72b7d5806d04c32e74250 ]
Return struct nft_elem_priv instead of struct nft_set_ext for consistency with ("netfilter: nf_tables: expose opaque set element as struct nft_elem_priv") and to prepare the introduction of element timeout updates from control path.
Backport notes for Linux 6.6:
The stable tree uses void * for private set elements and does not have struct nft_elem_priv or the backend priv members. Keep that representation:
return the backend element through void ** and recover its extensions with nft_set_elem_ext() in the -EEXIST caller. Update all insert implementations consistently, including catchall insertion, so commit 70194dc37670 can be applied without modification.
Preserve nft_add_set_elem()'s set_full handling and declaration order. Keep pipapo's existing initialization of e and return that element directly; do not introduce the unavailable nft_elem_priv_cast() helper. Correct the pipapo output-parameter documentation to describe private element data.
Stable-dep-of: 70194dc37670 ("netfilter: nf_tables: skip expired catchall elements on insert and delete")
--- include/net/netfilter/nf_tables.h | 2 +- net/netfilter/nf_tables_api.c | 15 +++++++++------ net/netfilter/nft_set_bitmap.c | 4 ++-- net/netfilter/nft_set_hash.c | 8 ++++---- net/netfilter/nft_set_pipapo.c | 10 +++++----- net/netfilter/nft_set_rbtree.c | 10 +++++----- 6 files changed, 26 insertions(+), 23 deletions(-)
include/net/netfilter/nf_tables.h +1 -1
@@ -462,7 +462,7 @@ struct nft_set_ops {int (*insert)(const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext); +void **priv);void (*activate)(const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem);
net/netfilter/nf_tables_api.c +9 -6
@@ -6553,7 +6553,7 @@ EXPORT_SYMBOL_GPL(nft_set_catchall_lookup);static int nft_setelem_catchall_insert (const struct net *net,struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **pext) +void **priv) {struct nft_set_elem_catchall *catchall;u8 genmask =nft_genmask_next (net);
@@ -6562,7 +6562,7 @@ static int nft_setelem_catchall_insert(const struct net *net,list_for_each_entry (catchall, &set->catchall_list, list) { ext =nft_set_elem_ext (set, catchall->elem);if (nft_set_elem_active (ext, genmask)) { - *pext = ext; + *priv = catchall->elem;return -EEXIST ; } }
@@ -6580,14 +6580,15 @@ static int nft_setelem_catchall_insert(const struct net *net,static int nft_setelem_insert (const struct net *net,struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext,unsigned int flags) +void **elem_priv, +unsigned int flags) {int ret;if (flags &NFT_SET_ELEM_CATCHALL ) - ret =nft_setelem_catchall_insert (net, set, elem, ext); + ret =nft_setelem_catchall_insert (net, set, elem, elem_priv);else - ret = set->ops->insert (net, set, elem, ext); + ret = set->ops->insert (net, set, elem, elem_priv);return ret; }
@@ -6755,6 +6756,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,enum nft_registers dreg;struct nft_trans *trans;bool set_full = false; +void *elem_priv;u64 timeout;u64 expiration;int err, i;
@@ -7063,9 +7065,10 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, ext->genmask =nft_genmask_cur (ctx->net); - err =nft_setelem_insert (ctx->net, set, &elem, &ext2, flags); + err =nft_setelem_insert (ctx->net, set, &elem, &elem_priv, flags); if (err) { if (err == -EEXIST) { + ext2 = nft_set_elem_ext(set, elem_priv); if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA) ^ nft_set_ext_exists(ext2, NFT_SET_EXT_DATA) || nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF) ^
net/netfilter/nft_set_bitmap.c +2 -2
@@ -123,7 +123,7 @@ static void *nft_bitmap_get(const struct net *net, const struct nft_set *set,static int nft_bitmap_insert (const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext) +void **elem_priv) {struct nft_bitmap *priv =nft_set_priv (set);struct nft_bitmap_elem *new = elem->priv, *be;
@@ -132,7 +132,7 @@ static int nft_bitmap_insert(const struct net *net, const struct nft_set *set, be =nft_bitmap_elem_find (set, new, genmask);if (be) { - *ext = &be->ext; + *elem_priv = be;return -EEXIST ; }
net/netfilter/nft_set_hash.c +4 -4
@@ -168,7 +168,7 @@ static bool nft_rhash_update(struct nft_set *set, const u32 *key,static int nft_rhash_insert (const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext) +void **elem_priv) {struct nft_rhash *priv =nft_set_priv (set);struct nft_rhash_elem *he = elem->priv;
@@ -185,7 +185,7 @@ static int nft_rhash_insert(const struct net *net, const struct nft_set *set,if (IS_ERR (prev))return PTR_ERR (prev);if (prev) { - *ext = &prev->ext; + *elem_priv = prev;return -EEXIST ; }return 0 ;
@@ -588,7 +588,7 @@ static u32 nft_jhash(const struct nft_set *set, const struct nft_hash *priv,static int nft_hash_insert (const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext) +void **elem_priv) {struct nft_hash_elem *this = elem->priv, *he;struct nft_hash *priv =nft_set_priv (set);
@@ -600,7 +600,7 @@ static int nft_hash_insert(const struct net *net, const struct nft_set *set,if (!memcmp (nft_set_ext_key (&this->ext),nft_set_ext_key (&he->ext), set->klen) &&nft_set_elem_active (&he->ext, genmask)) { - *ext = &he->ext; + *elem_priv = he;return -EEXIST ; } }
net/netfilter/nft_set_pipapo.c +5 -5
@@ -1260,13 +1260,13 @@ static struct nft_pipapo_match *pipapo_maybe_clone(const struct nft_set *set)* @net: Network namespace * @set: nftables API set representation * @elem: nftables API element representation containing key data -* @ext2: Filled with pointer to &struct nft_set_ext in inserted element +* @elem_priv: Filled with pointer to private element data * * Return: 0 on success, error pointer on failure. */ static int nft_pipapo_insert (const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext2) +void **elem_priv) {const struct nft_set_ext *ext =nft_set_elem_ext (set, elem->priv);union nft_pipapo_map_bucket rulemap[NFT_PIPAPO_MAX_FIELDS ];
@@ -1301,7 +1301,7 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,if (!memcmp (start, dup_key->data,sizeof (*dup_key->data)) && !memcmp (end, dup_end->data,sizeof (*dup_end->data))) { - *ext2 = &dup->ext; + *elem_priv = dup;return -EEXIST ; }
@@ -1317,7 +1317,7 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,if (PTR_ERR (dup) != -ENOENT ) {if (IS_ERR (dup))return PTR_ERR (dup); - *ext2 = &dup->ext; + *elem_priv = dup;return -ENOTEMPTY ; }
@@ -1379,7 +1379,7 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,put_cpu_ptr (m->scratch); } - *ext2 = &e->ext; + *elem_priv = e;pipapo_map (m, rulemap, e);
net/netfilter/nft_set_rbtree.c +5 -5
@@ -319,7 +319,7 @@ static struct nft_rbtree_elem *nft_rbtree_prev_active(struct nft_rbtree_elem *rbstatic int __nft_rbtree_insert (const struct net *net,const struct nft_set *set,struct nft_rbtree_elem *new, -struct nft_set_ext **ext) +void **elem_priv) {struct nft_rbtree_elem *rbe, *rbe_le =NULL , *rbe_ge =NULL , *rbe_prev;struct rb_node *node, *next, *parent, **p, *first =NULL ;
@@ -437,7 +437,7 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,*/ if (rbe_ge && !nft_rbtree_cmp (set, new, rbe_ge) &&nft_rbtree_interval_start (rbe_ge) ==nft_rbtree_interval_start (new)) { - *ext = &rbe_ge->ext; + *elem_priv = rbe_ge;return -EEXIST ; }
@@ -446,7 +446,7 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,*/ if (rbe_le && !nft_rbtree_cmp (set, new, rbe_le) &&nft_rbtree_interval_end (rbe_le) ==nft_rbtree_interval_end (new)) { - *ext = &rbe_le->ext; + *elem_priv = rbe_le;return -EEXIST ; }
@@ -506,7 +506,7 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,static int nft_rbtree_insert (const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext) +void **elem_priv) {struct nft_rbtree *priv =nft_set_priv (set);struct nft_rbtree_elem *rbe = elem->priv;
@@ -520,7 +520,7 @@ static int nft_rbtree_insert(const struct net *net, const struct nft_set *set,write_lock_bh (&priv->lock);write_seqcount_begin (&priv->count); - err =__nft_rbtree_insert (net, set, rbe, ext); + err =__nft_rbtree_insert (net, set, rbe, elem_priv);write_seqcount_end (&priv->count);write_unlock_bh (&priv->lock); }while (err == -EAGAIN );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 147/1674 netfilter: nf_tables: skip expired catchall elements on insert and delete
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aohan Mei <[email protected]>
[ Upstream commit 70194dc37670bd08e44b471389861cc01bd3a3c9 ]
nft_setelem_catchall_insert() looks up duplicates with nft_set_elem_active() only, while nft_set_catchall_lookup() and the dump path additionally skip expired elements.
Once a catchall element with a timeout expires, this predicate drift makes it invisible to userspace dumps, yet it still blocks
re-insertion: with NLM_F_EXCL the request fails with -EEXIST, and without it the request reports success but silently inserts nothing. The stale entry only goes away when the (user-tunable) gc interval elapses, so the catchall rule may silently stop matching for an arbitrarily long time after its first expiration.
The delete path shows the same drift: nft_setelem_catchall_deactivate() picks the first active-next entry in the catchall list, so with an expired entry still pending GC it retires the stale entry instead of the fresh one, and it deactivates an element that userspace no longer sees instead of failing with -ENOENT.
Align both walks with the lookup and dump predicates: only an element that is active and not expired counts as a duplicate or delete candidate, using the per-netns timestamp taken at transaction start, in line with the set backend .insert/.deactivate and catchall GC sync paths.
--- net/netfilter/nf_tables_api.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +8 -2
@@ -6557,11 +6557,14 @@ static int nft_setelem_catchall_insert(const struct net *net, {struct nft_set_elem_catchall *catchall;u8 genmask =nft_genmask_next (net); +u64 tstamp =nft_net_tstamp (net);struct nft_set_ext *ext;list_for_each_entry (catchall, &set->catchall_list, list) { ext =nft_set_elem_ext (set, catchall->elem); -if (nft_set_elem_active (ext, genmask)) { +if (nft_set_elem_active (ext, genmask) && + !__nft_set_elem_expired (ext, tstamp) && + !nft_set_elem_is_dead (ext)) { *priv = catchall->elem;return -EEXIST ; }
@@ -6622,11 +6625,14 @@ static int nft_setelem_catchall_deactivate(const struct net *net, struct nft_set_elem *elem) {struct nft_set_elem_catchall *catchall; +u64 tstamp =nft_net_tstamp (net);struct nft_set_ext *ext;list_for_each_entry (catchall, &set->catchall_list, list) { ext =nft_set_elem_ext (set, catchall->elem); -if (!nft_is_active_next (net, ext)) +if (!nft_is_active_next (net, ext) || +__nft_set_elem_expired (ext, tstamp) || +nft_set_elem_is_dead (ext))continue ;kfree (elem->priv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 148/1674 perf/x86/intel: Update event constraints and cache_extra_regsfor ADL
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dapeng Mi <[email protected]>
[ Upstream commit 4ef863352bcde482d65722ed721c3fd3967a67d6 ]
Update perf hard-coded event constraints and cache_extra_regs[] for Alderlake according to the latest ADL perfmon events (V1.39).
One important note is that ADL has differences on the L3/node related OCR events although it shares same uarch with SPR server, e.g., ADL has different extra MSR values and no node events. So some variants of structures and functions are introduced to reflect these differences, like adl_glc_hw_cache_event_ids[], adl_glc_hw_cache_extra_regs[] and intel_pmu_init_glc_hybrid(), etc.
Please note these changes would temporarily impact other platforms like MTL/ARL-U which shares hard-coded event structures, but it would be fixed soon in subsequent patches.
ADL perfmon events:
https://github.com/intel/perfmon/blob/main/ADL/events/alderlake_goldencove_core.json
https://github.com/intel/perfmon/blob/main/ADL/events/alderlake_gracemont_core.json
Backport dependency preparation for Linux 6.6:
Retain the Gracemont store-latency counter mask update from 0xf to 0x3f. Drop the unrelated cache tables, offcore register masks and PMU initialization changes: they depend on newer refactoring and are not needed by target 89dc568e8c0be60e05e5fcd0b528c79077d7b84b.
Prepare that target's existing latency path by renaming the ADL helper and callback to __grt_latency_data() and grt_latency_data(), updating all callers and the declaration. These are existing functions, not new ones. Guard the hybrid-only warning with is_hybrid(), retaining the 6.6 cpu_type field and existing data-source mask.
Include only the two hybrid load/store latency constraint macros from 608f6976c3097, preserving the hybrid decoder dispatch while making the target's explicit direction flags available. Leave the actual direction correction to the target commit.
Stable-dep-of: 89dc568e8c0b ("perf/x86/intel: Fix GRT PEBS load/store direction for latency events, to fix sample classification")
--- arch/x86/events/intel/core.c | 4 ++-- arch/x86/events/intel/ds.c | 23 ++++++++++++----------- arch/x86/events/perf_event.h | 10 +++++++++- 3 files changed, 23 insertions(+), 14 deletions(-)
arch/x86/events/intel/core.c +2 -2
@@ -6390,7 +6390,7 @@ __init int intel_pmu_init(void) x86_pmu.flags |=PMU_FL_INSTR_LATENCY ;intel_pmu_pebs_data_source_grt (); - x86_pmu.pebs_latency_data = adl_latency_data_small; + x86_pmu.pebs_latency_data = grt_latency_data; x86_pmu.get_event_constraints = tnt_get_event_constraints; x86_pmu.limit_period = spr_limit_period; td_attr = tnt_events_attrs;
@@ -6810,7 +6810,7 @@ __init int intel_pmu_init(void) x86_pmu.flags |=PMU_FL_NO_HT_SHARING ; x86_pmu.flags |=PMU_FL_INSTR_LATENCY ; x86_pmu.lbr_pt_coexist = true; - x86_pmu.pebs_latency_data = adl_latency_data_small; + x86_pmu.pebs_latency_data = grt_latency_data; x86_pmu.num_topdown_events =8 ;static_call_update (intel_pmu_update_topdown_event, &adl_update_topdown_event);
arch/x86/events/intel/ds.c +12 -11
@@ -256,12 +256,13 @@ static inline void pebs_set_tlb_lock(u64 *val, bool tlb, bool lock) }/* Retrieve the latency data for e-core of ADL */ -static u64 __adl_latency_data_small (struct perf_event *event,u64 status, -u8 dse,bool tlb,bool lock,bool blk) +static u64 __grt_latency_data (struct perf_event *event,u64 status, +u8 dse,bool tlb,bool lock,bool blk) {u64 val; -WARN_ON_ONCE (hybrid_pmu (event->pmu)->cpu_type == hybrid_big); +WARN_ON_ONCE (is_hybrid () && +hybrid_pmu (event->pmu)->cpu_type == hybrid_big); dse &=PERF_PEBS_DATA_SOURCE_MASK ; val =hybrid_var (event->pmu, pebs_data_source)[dse];
@@ -276,15 +277,15 @@ static u64 __adl_latency_data_small(struct perf_event *event, u64 status,return val; } -u64 adl_latency_data_small (struct perf_event *event,u64 status) +u64 grt_latency_data (struct perf_event *event,u64 status) {union intel_x86_pebs_dse dse; dse.val = status; -return __adl_latency_data_small (event, status, dse.ld_dse, - dse.ld_locked, dse.ld_stlb_miss, - dse.ld_data_blk); +return __grt_latency_data (event, status, dse.ld_dse, + dse.ld_locked, dse.ld_stlb_miss, + dse.ld_data_blk); }/* Retrieve the latency data for e-core of MTL */
@@ -294,9 +295,9 @@ u64 mtl_latency_data_small(struct perf_event *event, u64 status) dse.val = status; -return __adl_latency_data_small (event, status, dse.mtl_dse, - dse.mtl_stlb_miss, dse.mtl_locked, - dse.mtl_fwd_blk); +return __grt_latency_data (event, status, dse.mtl_dse, + dse.mtl_stlb_miss, dse.mtl_locked, + dse.mtl_fwd_blk); }static u64 load_latency_data (struct perf_event *event,u64 status)
@@ -892,7 +893,7 @@ struct event_constraint intel_glm_pebs_event_constraints[] = {struct event_constraint intel_grt_pebs_event_constraints[] = {/* Allow all events as PEBS with no flags */ INTEL_HYBRID_LAT_CONSTRAINT (0x5d0 ,0x3 ), -INTEL_HYBRID_LAT_CONSTRAINT (0x6d0 ,0xf ), +INTEL_HYBRID_LAT_CONSTRAINT (0x6d0 ,0x3f ),EVENT_CONSTRAINT_END };
arch/x86/events/perf_event.h +9 -1
@@ -470,6 +470,14 @@ struct cpu_hw_events {__EVENT_CONSTRAINT (c, n,INTEL_ARCH_EVENT_MASK |X86_ALL_EVENT_FLAGS , \ HWEIGHT(n), 0, PERF_X86_EVENT_PEBS_LAT_HYBRID) +#define INTEL_HYBRID_LDLAT_CONSTRAINT (c, n) \ + __EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK|X86_ALL_EVENT_FLAGS, \ + HWEIGHT(n), 0, PERF_X86_EVENT_PEBS_LAT_HYBRID|PERF_X86_EVENT_PEBS_LD_HSW) + +#define INTEL_HYBRID_STLAT_CONSTRAINT (c, n) \ + __EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK|X86_ALL_EVENT_FLAGS, \ + HWEIGHT(n), 0, PERF_X86_EVENT_PEBS_LAT_HYBRID|PERF_X86_EVENT_PEBS_ST_HSW) +/* Event constraint, but match on all event flags too. */ #define INTEL_FLAGS_EVENT_CONSTRAINT (c, n) \ EVENT_CONSTRAINT(c, n, ARCH_PERFMON_EVENTSEL_EVENT|X86_ALL_EVENT_FLAGS)
@@ -1502,7 +1510,7 @@ void intel_pmu_disable_bts(void);int intel_pmu_drain_bts_buffer (void ); -u64 adl_latency_data_small (struct perf_event *event,u64 status); +u64 grt_latency_data (struct perf_event *event,u64 status);u64 mtl_latency_data_small (struct perf_event *event,u64 status);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 149/1674 perf/x86/intel: Fix GRT PEBS load/store direction for latency events, to fix sample classification
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dapeng Mi <[email protected]>
[ Upstream commit 89dc568e8c0be60e05e5fcd0b528c79077d7b84b ]
On Gracemont, intel_grt_pebs_event_constraints[] applies LAT_CONSTRAINT constraints to MEM_UOPS_RETIRED.{LOAD,STORE}_LATENCY, but does not set explicit LOAD/STORE flags for those events.
The PEBS latency path (pebs_latency_data(), via __grt_latency_data()) uses the event flags to determine memory operation direction. Without an explicit STORE flag, samples from MEM_UOPS_RETIRED.STORE_LATENCY can be misclassified as LOADs.
Set explicit LOAD/STORE flags in intel_grt_pebs_event_constraints[] for:
- MEM_UOPS_RETIRED.LOAD_LATENCY
- MEM_UOPS_RETIRED.STORE_LATENCY
Also update __grt_latency_data() to explicitly interpret these flags when assigning the sampled memory operation direction.
This fixes incorrect STORE sample classification.
--- arch/x86/events/intel/ds.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
arch/x86/events/intel/ds.c +13 -3
@@ -259,6 +259,7 @@ static inline void pebs_set_tlb_lock(u64 *val, bool tlb, bool lock)static u64 __grt_latency_data (struct perf_event *event,u64 status,u8 dse,bool tlb,bool lock,bool blk) { +union perf_mem_data_src src;u64 val; WARN_ON_ONCE(is_hybrid() &&
@@ -274,7 +275,16 @@ static u64 __grt_latency_data(struct perf_event *event, u64 status,else val |=P (BLK ,NA ); -return val; + src.val = val; + +if (event->hw.flags & + (PERF_X86_EVENT_PEBS_LDLAT |PERF_X86_EVENT_PEBS_LD_HSW )) + src.mem_op =P (OP ,LOAD ); +if (event->hw.flags & + (PERF_X86_EVENT_PEBS_STLAT |PERF_X86_EVENT_PEBS_ST_HSW )) + src.mem_op =P (OP ,STORE ); + +return src.val; }u64 grt_latency_data (struct perf_event *event,u64 status)
@@ -892,8 +902,8 @@ struct event_constraint intel_glm_pebs_event_constraints[] = {struct event_constraint intel_grt_pebs_event_constraints[] = {/* Allow all events as PEBS with no flags */ -INTEL_HYBRID_LAT_CONSTRAINT (0x5d0 ,0x3 ), -INTEL_HYBRID_LAT_CONSTRAINT (0x6d0 ,0x3f ), +INTEL_HYBRID_LDLAT_CONSTRAINT (0x5d0 ,0x3 ), +INTEL_HYBRID_STLAT_CONSTRAINT (0x6d0 ,0x3f ),EVENT_CONSTRAINT_END };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 150/1674 smb: client: use finish_no_open() for non-regular inodes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit e66cf1625ec4a3fe68346119f371def713fd0a4d ]
An O_CREAT open can find an existing symlink or another non-regular inode. cifs_atomic_open() calls finish_open() on it and attaches a cifsFileInfo. Symlink inodes have no CIFS release operation, so the dentry reference held by cifsFileInfo is leaked. FMODE_OPENED also prevents the VFS from following the symlink.
Track whether cifs_do_create() returned an open server handle. For non-regular inodes, close the handle if present, remove the pending open, and call finish_no_open() so the VFS can continue the lookup. Do not set FMODE_CREATED unless a regular file was opened. For O_NOFOLLOW with __O_REGULAR, return -ELOOP before the VFS's -EFTYPE check.
Defer closing a legacy POSIX handle on a non-regular inode until after inode lookup. This avoids closing it again if lookup fails.
--- fs/smb/client/dir.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-)
fs/smb/client/dir.c +29 -10
@@ -176,7 +176,8 @@ check_name(struct dentry *direntry, struct cifs_tcon *tcon)static int cifs_do_create (struct inode *inode,struct dentry *direntry,unsigned int xid,struct tcon_link *tlink,unsigned int oflags,umode_t mode,__u32 *oplock, -struct cifs_fid *fid,struct cifs_open_info_data *buf) +struct cifs_fid *fid,struct cifs_open_info_data *buf, +bool *opened) {int rc = -ENOENT ;int create_options =CREATE_NOT_DIR ;
@@ -191,6 +192,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsignedstruct cifs_open_parms oparms;int rdwr_for_fscache =0 ; + *opened = false; *oplock =0 ;if (tcon->ses->server->oplocks) *oplock =REQ_OPLOCK ;
@@ -213,6 +215,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned oflags, oplock, &fid->netfid, xid);switch (rc) {case 0 : + *opened = true;if (newinode ==NULL ) {/* query inode info */ goto cifs_create_get_file_info;
@@ -229,11 +232,9 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned/* * The server may allow us to open things like * FIFOs, but the client isn't set up to deal -* with that. If it's not a regular file, just -* close it and proceed as if it were a normal -* lookup. +* with that. Keep the handle until the caller +* can finish the lookup. */ -CIFSSMBClose (xid, tcon, fid->netfid); goto cifs_create_get_file_info; }/* success, no need to query */
@@ -333,6 +334,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned } goto out; } + *opened = true;if (rdwr_for_fscache ==2 )cifs_invalidate_cache (inode,FSCACHE_INVAL_DIO_WRITE );
@@ -423,7 +425,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsignedreturn rc; out_err: -if (server->ops->close) +if (*opened && server->ops->close) server->ops->close (xid, tcon, fid);if (newinode)iput (newinode);
@@ -442,6 +444,8 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,struct cifs_fid fid = {};struct cifs_pending_open open;__u32 oplock; +bool is_regular; +bool opened;struct cifsFileInfo *file_info;struct cifs_open_info_data buf = {};
@@ -501,15 +505,28 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,cifs_add_pending_open (&fid, tlink, &open); rc =cifs_do_create (inode, direntry, xid, tlink, oflags, mode, - &oplock, &fid, &buf); + &oplock, &fid, &buf, &opened);if (rc) {cifs_del_pending_open (&open); goto out; } -if ((oflags & (O_CREAT |O_EXCL )) == (O_CREAT |O_EXCL )) + is_regular =d_is_reg (direntry); +if (!is_regular || !opened) { +if (opened && server->ops->close) + server->ops->close (xid, tcon, &fid); +cifs_del_pending_open (&open); + } + +if (is_regular && opened && + (oflags & (O_CREAT |O_EXCL )) == (O_CREAT |O_EXCL )) file->f_mode |=FMODE_CREATED ; +if (!is_regular || !opened) { + rc =finish_no_open (file,NULL ); + goto out; + } + rc =finish_open (file, direntry, generic_file_open);if (rc) {if (server->ops->close)
@@ -564,6 +581,7 @@ int cifs_create(struct mnt_idmap *idmap, struct inode *inode,struct TCP_Server_Info *server;struct cifs_fid fid;__u32 oplock; +bool opened;struct cifs_open_info_data buf = {}; cifs_dbg(FYI, "cifs_create parent inode = 0x%p name is: %pd and dentry = 0x%p\n",
@@ -585,8 +603,9 @@ int cifs_create(struct mnt_idmap *idmap, struct inode *inode,if (server->ops->new_lease_key) server->ops->new_lease_key (&fid); - rc =cifs_do_create (inode, direntry, xid, tlink, oflags, mode, &oplock, &fid, &buf); -if (!rc && server->ops->close) + rc =cifs_do_create (inode, direntry, xid, tlink, oflags, mode, + &oplock, &fid, &buf, &opened); +if (!rc && opened && server->ops->close) server->ops->close (xid, tcon, &fid);cifs_free_open_info (&buf);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 151/1674 drm/nouveau/uvmm: fix NULL deref unwinding an OP_MAP_SPARSE op
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenhao Wan <[email protected]>
[ Upstream commit 412a6ceb56d501ef2f8202e26ab4b5d4dfbca566 ]
Each bind_job_op is zeroed by kzalloc_obj() in bind_job_op_from_uop(), and the OP_MAP_SPARSE case in nouveau_uvmm_bind_job_submit() only creates a region, so op->ops stays NULL for a successfully processed sparse map.
If a later op in the same job fails, the reverse unwind loop revisits that op and calls drm_gpuva_ops_free(&uvmm->base, op->ops) unconditionally. drm_gpuva_ops_free() dereferences its argument right away (list_for_each_entry_safe on &ops->list), so a NULL op->ops oopses. The path is reachable by any render-node fd holder, since NOUVEAU_VM_BIND is DRM_RENDER_ALLOW.
Guard the free with IS_ERR_OR_NULL(), as nouveau_uvmm_bind_job_cleanup() already does for the identical free.
--- drivers/gpu/drm/nouveau/nouveau_uvmm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_uvmm.c +2 -1
@@ -1419,7 +1419,8 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job)break ; } -drm_gpuva_ops_free (&uvmm->umgr, op->ops); +if (!IS_ERR_OR_NULL (op->ops)) +drm_gpuva_ops_free (&uvmm->umgr, op->ops); op->ops =NULL ; op->reg =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 152/1674 RISC-V: KVM: Fix null pointer dereference in kvm_riscv_aia_imsic_has_attr()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiakai Xu <[email protected]>
[ Upstream commit 11366ead4f1412befea660777576c89a1bac0c1e ]
Add a null pointer check for imsic_state before dereferencing it in kvm_riscv_aia_imsic_has_attr(). While the function checks that the vcpu exists, it doesn't verify that the vcpu's imsic_state has been initialized, leading to a null pointer dereference when accessed.
This issue was discovered during fuzzing of RISC-V KVM code. The crash occurs when userspace calls KVM_HAS_DEVICE_ATTR ioctl on an AIA IMSIC device before the IMSIC state has been fully initialized for a vcpu.
The crash manifests as:
Unable to handle kernel paging request at virtual address dfffffff00000001 ... epc : kvm_riscv_aia_imsic_has_attr+0x464/0x50e arch/riscv/kvm/aia_imsic.c:998 ... kvm_riscv_aia_imsic_has_attr+0x464/0x50e arch/riscv/kvm/aia_imsic.c:998 aia_has_attr+0x128/0x2bc arch/riscv/kvm/aia_device.c:471 kvm_device_ioctl_attr virt/kvm/kvm_main.c:4722 [inline] kvm_device_ioctl+0x296/0x374 virt/kvm/kvm_main.c:4739 ...
The fix adds a check to return -ENODEV if imsic_state is NULL, which is consistent with other error handling in the function and prevents the null pointer dereference.
--- arch/riscv/kvm/aia_imsic.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/riscv/kvm/aia_imsic.c +4 -1
@@ -945,8 +945,11 @@ int kvm_riscv_aia_imsic_has_attr(struct kvm *kvm, unsigned long type)if (!vcpu)return -ENODEV ; - isel =KVM_DEV_RISCV_AIA_IMSIC_GET_ISEL (type); imsic = vcpu->arch.aia_context.imsic_state; +if (!imsic) +return -ENODEV ; + + isel =KVM_DEV_RISCV_AIA_IMSIC_GET_ISEL (type);return imsic_mrif_isel_check (imsic->nr_eix, isel); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 153/1674 bpf, xdp: move offload check into dev_xdp_install()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit ad27ed7d2309419a129078d781504f486b1b469a ]
bpf_xdp_link_update() calls dev_xdp_install() directly and skips dev_xdp_attach(), so the checks in dev_xdp_attach() do not run. A user can make an XDP link with a normal program and then swap in an offloaded or device-bound program with BPF_LINK_UPDATE, which puts it on the software path.
dev_xdp_install() is the one place all three paths go through:
"ip link set xdp" and BPF_LINK_CREATE reach it via dev_xdp_attach(), and BPF_LINK_UPDATE calls it directly. So move the program checks (offloaded, bound to another device, device-bound in generic mode, native vs generic, DEVMAP and CPUMAP) there, and keep only the netlink-flag check (XDP_FLAGS_UPDATE_IF_NOEXIST) in dev_xdp_attach().
--- net/core/dev.c | 59 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 28 deletions(-)
net/core/dev.c +31 -28
@@ -9304,6 +9304,37 @@ static int dev_xdp_install(struct net_destruct netdev_bpf xdp;int err; +if (prog) { +enum bpf_xdp_mode other_mode = mode ==XDP_MODE_SKB + ?XDP_MODE_DRV :XDP_MODE_SKB ; +bool offload = mode ==XDP_MODE_HW ; + +if (!offload &&dev_xdp_prog (dev, other_mode)) { +NL_SET_ERR_MSG (extack,"Native and generic XDP can't be active at the same time" ); +return -EEXIST ; + } +if (!offload &&bpf_prog_is_offloaded (prog->aux)) { +NL_SET_ERR_MSG (extack,"Using offloaded program without HW_MODE flag is not supported" ); +return -EINVAL ; + } +if (bpf_prog_is_dev_bound (prog->aux) && !bpf_offload_dev_match (prog, dev)) { +NL_SET_ERR_MSG (extack,"Program bound to different device" ); +return -EINVAL ; + } +if (bpf_prog_is_dev_bound (prog->aux) && mode ==XDP_MODE_SKB ) { +NL_SET_ERR_MSG (extack,"Can't attach device-bound programs in generic mode" ); +return -EINVAL ; + } +if (prog->expected_attach_type ==BPF_XDP_DEVMAP ) { +NL_SET_ERR_MSG (extack,"BPF_XDP_DEVMAP programs can not be attached to a device" ); +return -EINVAL ; + } +if (prog->expected_attach_type ==BPF_XDP_CPUMAP ) { +NL_SET_ERR_MSG (extack,"BPF_XDP_CPUMAP programs can not be attached to a device" ); +return -EINVAL ; + } + } +memset (&xdp,0 ,sizeof (xdp)); xdp.command = mode ==XDP_MODE_HW ?XDP_SETUP_PROG_HW :XDP_SETUP_PROG ; xdp.extack = extack;
@@ -9432,38 +9463,10 @@ static int dev_xdp_attach(struct net_dev new_prog = link->link.prog;if (new_prog) { -bool offload = mode ==XDP_MODE_HW ; -enum bpf_xdp_mode other_mode = mode ==XDP_MODE_SKB - ?XDP_MODE_DRV :XDP_MODE_SKB ; -if ((flags &XDP_FLAGS_UPDATE_IF_NOEXIST ) && cur_prog) {NL_SET_ERR_MSG (extack,"XDP program already attached" );return -EBUSY ; } -if (!offload &&dev_xdp_prog (dev, other_mode)) { -NL_SET_ERR_MSG (extack,"Native and generic XDP can't be active at the same time" ); -return -EEXIST ; - } -if (!offload &&bpf_prog_is_offloaded (new_prog->aux)) { -NL_SET_ERR_MSG (extack,"Using offloaded program without HW_MODE flag is not supported" ); -return -EINVAL ; - } -if (bpf_prog_is_dev_bound (new_prog->aux) && !bpf_offload_dev_match (new_prog, dev)) { -NL_SET_ERR_MSG (extack,"Program bound to different device" ); -return -EINVAL ; - } -if (bpf_prog_is_dev_bound (new_prog->aux) && mode ==XDP_MODE_SKB ) { -NL_SET_ERR_MSG (extack,"Can't attach device-bound programs in generic mode" ); -return -EINVAL ; - } -if (new_prog->expected_attach_type ==BPF_XDP_DEVMAP ) { -NL_SET_ERR_MSG (extack,"BPF_XDP_DEVMAP programs can not be attached to a device" ); -return -EINVAL ; - } -if (new_prog->expected_attach_type ==BPF_XDP_CPUMAP ) { -NL_SET_ERR_MSG (extack,"BPF_XDP_CPUMAP programs can not be attached to a device" ); -return -EINVAL ; - } }/* don't call drivers if the effective program didn't change */
Greg Kroah-Hartman
maintainerPATCH 154/1674 Bluetooth: btusb: Add IMC Networks QCA9377 to quirks table
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tibor Harcsa <[email protected]>
[ Upstream commit dc16388d45ecbd3be0d8c9424dbbaa2c81806578 ]
Add the USB ID (13d3:3503) for the IMC Networks Qualcomm Atheros QCA9377 Bluetooth controller to the btusb quirks table. This device requires Qualcomm Rome firmware and wideband speech support to function properly; otherwise, BLE scanning fails with HCI unexpected event opcode 0x2005 errors.
The device reports the following in /sys/kernel/debug/usb/devices:
P: Vendor=13d3 ProdID=3503 Rev= 0.01
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -305,6 +305,8 @@ static const struct usb_device_id quirks_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x13d3, 0x3503), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, /* QCA WCN6855 chipset */ { USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 |
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 155/1674 HID: core: remove #ifdef CONFIG_PM from hid_driver
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit df8b030d82dd1224881acb4e778fa06c4824f72b ]
Allow HID drivers to pass ->suspend, ->resume and ->reset_resume via pm_ptr().
Through the usage of pm_ptr() the CONFIG_PM-dependent code will always be compiled, protecting against bitrot.
The linker will then garbage-collect the unused function avoiding any overhead.
The only overhead in the final kernel image and at runtime are a few extra bytes in 'struct hid_driver'.
The same approach is chosen by 'struct usb_driver' and other subsystems.
--- include/linux/hid.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/hid.h +2 -2
@@ -869,11 +869,11 @@ struct hid_driver {void (*feature_mapping)(struct hid_device *hdev,struct hid_field *field,struct hid_usage *usage); -#ifdef CONFIG_PM +int (*suspend)(struct hid_device *hdev,pm_message_t message);int (*resume)(struct hid_device *hdev);int (*reset_resume)(struct hid_device *hdev); -#endif +/* private: */ struct device_driver driver; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 156/1674 HID: hid-alps: Use pm_ptr instead of #ifdef CONFIG_PM
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bastien Nocera <[email protected]>
[ Upstream commit 5e130f58629a2819c9d053507ad368160d25eb65 ]
This increases build coverage and allows to drop an #ifdef.
Stable-dep-of: aa9dde93e05a ("HID: alps: unregister DualPoint Stick input device on remove")
--- drivers/hid/hid-alps.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/hid/hid-alps.c +2 -4
@@ -845,10 +845,8 @@ static struct hid_driver alps_driver = { .raw_event = alps_raw_event, .input_mapping = alps_input_mapping, .input_configured = alps_input_configured, -#ifdef CONFIG_PM - .resume = alps_post_resume, - .reset_resume = alps_post_reset, -#endif + .resume = pm_ptr(alps_post_resume), + .reset_resume = pm_ptr(alps_post_reset), };module_hid_driver (alps_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 157/1674 HID: alps: unregister DualPoint Stick input device on remove
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Changcheng <[email protected]>
[ Upstream commit aa9dde93e05a837645fdfd577eea71f0733f0694 ]
alps_input_configured() allocates a second input device ("DualPoint Stick") with input_allocate_device() and registers it, but the alps_driver struct has no .remove handler and input2 is not tracked in hdev->inputs. The default remove path (hid_hw_stop -> hidinput_disconnect) only iterates hdev->inputs, so input2 is never unregistered and leaks on every device removal.
Add a .remove handler that stops the device first (preventing URB callbacks from touching input2 during teardown) and then unregisters input2.
--- drivers/hid/hid-alps.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/hid/hid-alps.c +19 -0
@@ -825,6 +825,24 @@ static int alps_probe(struct hid_device *hdev, const struct hid_device_id *id)return 0 ; } +static void alps_remove (struct hid_device *hdev) +{ +struct alps_dev *data =hid_get_drvdata (hdev); + +/* +* input2 ("DualPoint Stick") is allocated separately and is not +* tracked in hdev->inputs, so the default remove path +* (hid_hw_stop -> hidinput_disconnect) does not unregister it. +* +* Stop the device first so that no URB callback can touch input2 +* while it is being unregistered, then drop it explicitly. +*/ +hid_hw_stop (hdev); + +if (data->input2) +input_unregister_device (data->input2); +} +static const struct hid_device_id alps_id[] = { {HID_DEVICE (HID_BUS_ANY ,HID_GROUP_ANY ,USB_VENDOR_ID_ALPS_JP ,HID_DEVICE_ID_ALPS_U1_DUAL ) },
@@ -847,6 +865,7 @@ static struct hid_driver alps_driver = { .input_configured = alps_input_configured, .resume = pm_ptr(alps_post_resume), .reset_resume = pm_ptr(alps_post_reset), + .remove = alps_remove, };module_hid_driver (alps_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 158/1674 smb/client: use stack-allocated smb2_file_all_info in smb3_query_mf_symlink()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
[ Upstream commit fc8789bb57e625e5f32ac57ca2e7d3e7b7fda225 ]
SMB2_open() only fills the fixed fields, so a stack-allocated smb2_file_all_info is sufficient here.
Stable-dep-of: 566820af017e ("smb: client: close handle after create-context parsing failure")
--- fs/smb/client/link.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
fs/smb/client/link.c +3 -12
@@ -343,7 +343,7 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,int buf_type =CIFS_NO_BUFFER ;__le16 *utf16_path;__u8 oplock =SMB2_OPLOCK_LEVEL_NONE ; -struct smb2_file_all_info *pfile_info =NULL ; +struct smb2_file_all_info file_info = {}; oparms = (struct cifs_open_parms ) { .tcon = tcon,
@@ -359,20 +359,12 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,if (utf16_path ==NULL )return -ENOMEM ; - pfile_info =kzalloc (sizeof (struct smb2_file_all_info ) +PATH_MAX *2 , -GFP_KERNEL ); - -if (pfile_info ==NULL ) { -kfree (utf16_path); -return -ENOMEM ; - } - - rc =SMB2_open (xid, &oparms, utf16_path, &oplock, pfile_info,NULL , + rc =SMB2_open (xid, &oparms, utf16_path, &oplock, &file_info,NULL ,NULL ,NULL );if (rc) goto qmf_out_open_fail; -if (pfile_info->EndOfFile !=cpu_to_le64 (CIFS_MF_SYMLINK_FILE_SIZE )) { +if (file_info.EndOfFile !=cpu_to_le64 (CIFS_MF_SYMLINK_FILE_SIZE )) {/* it's not a symlink */ rc = -ENOENT ;/* Is there a better rc to return? */ goto qmf_out;
@@ -390,7 +382,6 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,SMB2_close (xid, tcon, fid.persistent_fid, fid.volatile_fid); qmf_out_open_fail:kfree (utf16_path); -kfree (pfile_info);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 159/1674 smb/client: pass cifs_open_info_data to SMB2_open()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
[ Upstream commit 1f551e407bb49dce0bbd34ed6a499dad69e18020 ]
Let SMB2_open() fill the smb2_file_all_info embedded in cifs_open_info_data directly. This removes the temporary smb2_file_all_info copy in smb2_open_file().
For the 6.6 backport, keep the existing retry delay initialization and header declaration style. Move the existing open-done trace after create context parsing, retaining the stable six-argument tracepoint signature. This supplies the context needed to apply the follow-up handle cleanup in 566820af017e ("smb: client: close handle after create-context parsing failure") without importing the newer tracepoint API.
Stable-dep-of: 566820af017e ("smb: client: close handle after create-context parsing failure")
--- fs/smb/client/link.c | 6 +++--- fs/smb/client/smb2file.c | 19 ++++++++----------- fs/smb/client/smb2pdu.c | 31 ++++++++++++++++--------------- fs/smb/client/smb2proto.h | 2 +- 4 files changed, 28 insertions(+), 30 deletions(-)
fs/smb/client/link.c +3 -3
@@ -343,7 +343,7 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,int buf_type =CIFS_NO_BUFFER ;__le16 *utf16_path;__u8 oplock =SMB2_OPLOCK_LEVEL_NONE ; -struct smb2_file_all_info file_info = {}; +struct cifs_open_info_data data = {}; oparms = (struct cifs_open_parms ) { .tcon = tcon,
@@ -359,12 +359,12 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,if (utf16_path ==NULL )return -ENOMEM ; - rc =SMB2_open (xid, &oparms, utf16_path, &oplock, &file_info,NULL , + rc =SMB2_open (xid, &oparms, utf16_path, &oplock, &data,NULL ,NULL ,NULL );if (rc) goto qmf_out_open_fail; -if (file_info.EndOfFile !=cpu_to_le64 (CIFS_MF_SYMLINK_FILE_SIZE )) { +if (data.fi.EndOfFile !=cpu_to_le64 (CIFS_MF_SYMLINK_FILE_SIZE )) {/* it's not a symlink */ rc = -ENOENT ;/* Is there a better rc to return? */ goto qmf_out;
fs/smb/client/smb2file.c +8 -11
@@ -111,8 +111,6 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32__le16 *smb2_path;__u8 smb2_oplock;struct cifs_open_info_data *data = buf; -struct smb2_file_all_info file_info = {}; -struct smb2_file_all_info *smb2_data = data ? &file_info :NULL ;struct kvec err_iov = {};int err_buftype =CIFS_NO_BUFFER ;struct cifs_fid *fid = oparms->fid;
@@ -129,14 +127,14 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32 } smb2_oplock =SMB2_OPLOCK_LEVEL_BATCH ; - rc =SMB2_open (xid, oparms, smb2_path, &smb2_oplock, smb2_data,NULL , &err_iov, + rc =SMB2_open (xid, oparms, smb2_path, &smb2_oplock, data,NULL , &err_iov, &err_buftype);if (rc == -EACCES && retry_without_read_attributes) {free_rsp_buf (err_buftype, err_iov.iov_base);memset (&err_iov,0 ,sizeof (err_iov)); err_buftype =CIFS_NO_BUFFER ; oparms->desired_access &= ~FILE_READ_ATTRIBUTES ; - rc =SMB2_open (xid, oparms, smb2_path, &smb2_oplock, smb2_data,NULL , &err_iov, + rc =SMB2_open (xid, oparms, smb2_path, &smb2_oplock, data,NULL , &err_iov, &err_buftype); }if (rc && data) {
@@ -149,9 +147,9 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32 oparms->path, &data->symlink_target);if (!rc) { -memset (smb2_data,0 ,sizeof (*smb2_data)); +memset (&data->fi,0 ,sizeof (data->fi)); oparms->create_options |=OPEN_REPARSE_POINT ; - rc =SMB2_open (xid, oparms, smb2_path, &smb2_oplock, smb2_data, + rc =SMB2_open (xid, oparms, smb2_path, &smb2_oplock, data,NULL ,NULL ,NULL ); oparms->create_options &= ~OPEN_REPARSE_POINT ; }
@@ -180,23 +178,22 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32 rc =0 ; } -if (smb2_data) { +if (data) {/* if open response does not have IndexNumber field - get it */ -if (smb2_data->IndexNumber ==0 ) { +if (data->fi.IndexNumber ==0 ) { rc =SMB2_get_srv_num (xid, oparms->tcon, fid->persistent_fid, fid->volatile_fid, - &smb2_data->IndexNumber); + &data->fi.IndexNumber);if (rc) {/* * let get_inode_info disable server inode * numbers */ - smb2_data->IndexNumber =0 ; + data->fi.IndexNumber =0 ; rc =0 ; } } -memcpy (&data->fi, smb2_data,sizeof (data->fi)); } *oplock = smb2_oplock;
fs/smb/client/smb2pdu.c +16 -15
@@ -3218,7 +3218,7 @@ SMB2_open_free(struct smb_rqst *rqst)int SMB2_open (const unsigned int xid,struct cifs_open_parms *oparms,__le16 *path, -__u8 *oplock,struct smb2_file_all_info *buf, +__u8 *oplock,struct cifs_open_info_data *buf,struct create_posix_rsp *posix,struct kvec *err_iov,int *buftype) {
@@ -3233,6 +3233,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,int rc =0 ;int flags =0 ;int retries =0 , cur_sleep =1 ; +struct smb2_file_all_info *file_info = buf ? &buf->fi :NULL ; replay_again:/* reinitialize for possible replay */
@@ -3288,9 +3289,6 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, goto creat_exit; }else if (rsp ==NULL )/* unlikely to happen, but safer to check */ goto creat_exit; -else -trace_smb3_open_done (xid, rsp->PersistentFileId, tcon->tid, ses->Suid, - oparms->create_options, oparms->desired_access);atomic_inc (&tcon->num_remote_opens); oparms->fid->persistent_fid = rsp->PersistentFileId;
@@ -3300,21 +3298,24 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, oparms->fid->mid =le64_to_cpu (rsp->hdr.MessageId);#endif /* CIFS_DEBUG2 */ -if (buf) { - buf->CreationTime = rsp->CreationTime; - buf->LastAccessTime = rsp->LastAccessTime; - buf->LastWriteTime = rsp->LastWriteTime; - buf->ChangeTime = rsp->ChangeTime; - buf->AllocationSize = rsp->AllocationSize; - buf->EndOfFile = rsp->EndofFile; - buf->Attributes = rsp->FileAttributes; - buf->NumberOfLinks =cpu_to_le32 (1 ); - buf->DeletePending =0 ; +if (file_info) { + file_info->CreationTime = rsp->CreationTime; + file_info->LastAccessTime = rsp->LastAccessTime; + file_info->LastWriteTime = rsp->LastWriteTime; + file_info->ChangeTime = rsp->ChangeTime; + file_info->AllocationSize = rsp->AllocationSize; + file_info->EndOfFile = rsp->EndofFile; + file_info->Attributes = rsp->FileAttributes; + file_info->NumberOfLinks =cpu_to_le32 (1 ); + file_info->DeletePending =0 ; } rc =smb2_parse_contexts (server, &rsp_iov, &oparms->fid->epoch, - oparms->fid->lease_key, oplock, buf, posix); + oparms->fid->lease_key, oplock, file_info, posix); + +trace_smb3_open_done (xid, rsp->PersistentFileId, tcon->tid, ses->Suid, + oparms->create_options, oparms->desired_access); creat_exit:SMB2_open_free (&rqst);free_rsp_buf (resp_buftype, rsp);
fs/smb/client/smb2proto.h +1 -1
@@ -154,7 +154,7 @@ extern int SMB2_tcon(const unsigned int xid, struct cifs_ses *ses,extern int SMB2_tdis (const unsigned int xid,struct cifs_tcon *tcon);extern int SMB2_open (const unsigned int xid,struct cifs_open_parms *oparms,__le16 *path,__u8 *oplock, -struct smb2_file_all_info *buf, +struct cifs_open_info_data *buf,struct create_posix_rsp *posix,struct kvec *err_iov,int *resp_buftype); extern int SMB2_open_init(struct cifs_tcon *tcon,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 160/1674 smb: client: close handle after create-context parsing failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
[ Upstream commit 566820af017e81497fb5e9d3ad6e7ffe2828bc8b ]
SMB2_open() accounts a successful CREATE response as a remote open before parsing its create contexts. If smb2_parse_contexts() rejects malformed context data, SMB2_open() returns without closing the handle, leaving the server-side handle open and num_remote_opens elevated.
Close the handle after a post-CREATE context parsing failure so the error path releases the remote resource and balances the open count.
--- fs/smb/client/smb2pdu.c | 3 +++ 1 file changed, 3 insertions(+)
fs/smb/client/smb2pdu.c +3 -0
@@ -3313,6 +3313,9 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, rc =smb2_parse_contexts (server, &rsp_iov, &oparms->fid->epoch, oparms->fid->lease_key, oplock, file_info, posix); +if (rc) +SMB2_close (xid, tcon, oparms->fid->persistent_fid, + oparms->fid->volatile_fid);trace_smb3_open_done (xid, rsp->PersistentFileId, tcon->tid, ses->Suid, oparms->create_options, oparms->desired_access);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 161/1674 smb: client: close completed creates on compound wait errors
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
[ Upstream commit 6c5c547f037bc18f0b8d0b5db5a648f8f630ce85 ]
compound_send_recv() waits for responses in order. If a later wait is interrupted, or if a later MID fails during response synchronization, an earlier CREATE may already have opened a remote handle. The earlier mid is then released without invoking handle_cancelled_mid(), leaving the remote handle open because no FID was copied to the caller.
Mark completed earlier mids as cancelled when a compound wait or MID synchronization aborts. Keep their response buffers attached while the MIDs are synchronized, and transfer them only after synchronization of the processed responses, so the release path can inspect successful CREATE responses and queue SMB2_close() after a later failure. Account for a remote open only after the close work is allocated and before it is queued, since the caller has not yet updated num_remote_opens. Mark the create+close compound used by smb2_unlink() so it is not closed again. Non-CREATE responses and compounds that already include a close keep their existing behavior.
--- fs/smb/client/smb2misc.c | 9 +++-- fs/smb/client/transport.c | 69 ++++++++++++++++++++++++++++++--------- 2 files changed, 59 insertions(+), 19 deletions(-)
fs/smb/client/smb2misc.c +6 -3
@@ -818,7 +818,8 @@ smb2_cancelled_close_fid(struct work_struct *work)*/ static int __smb2_handle_cancelled_cmd (struct cifs_tcon *tcon,__u16 cmd,__u64 mid, -__u64 persistent_fid,__u64 volatile_fid) +__u64 persistent_fid,__u64 volatile_fid, +bool account_remote_open) {struct close_cancelled_open *cancelled;
@@ -832,6 +833,8 @@ __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid, cancelled->cmd = cmd; cancelled->mid = mid;INIT_WORK (&cancelled->work, smb2_cancelled_close_fid); +if (account_remote_open) +atomic_inc (&tcon->num_remote_opens);WARN_ON (queue_work (cifsiod_wq, &cancelled->work) == false);return 0 ;
@@ -868,7 +871,7 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,spin_unlock (&tcon->tc_lock); rc =__smb2_handle_cancelled_cmd (tcon,SMB2_CLOSE_HE ,0 , - persistent_fid, volatile_fid); + persistent_fid, volatile_fid, false);if (rc)cifs_put_tcon (tcon, netfs_trace_tcon_ref_put_cancelled_close);
@@ -896,7 +899,7 @@ smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *servele16_to_cpu (hdr->Command),le64_to_cpu (hdr->MessageId), rsp->PersistentFileId, - rsp->VolatileFileId); + rsp->VolatileFileId, true);if (rc)cifs_put_tcon (tcon, netfs_trace_tcon_ref_put_cancelled_mid);
fs/smb/client/transport.c +53 -16
113 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 162/1674 xfs: fix cursor and pointer handling when recovering iunlink buckets
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 65f39d09d73718611cee40399179323b5d4ead00 ]
LOLLM pointed out a bug in xlog_recover_iunlink_bucket:
1. We don't null out prev_ip after releasing it, which can lead to UAF problems if the inodegc flush call in the loop fails.
at which point I noticed even more bugs:
2. If the inodegc flush inside the loop fails, we also leak @ip.
3. We set prev_agino to agino having already advanced agino, which results in inodes with i_prev_unlinked set to itself.
4. If we exit the bottom of the loop with prev_ip set, then prev_ip aliases ip and we also set its i_prev_unlinked to itself.
Bugs 3 and 4 introduce loops into the unlinked list, though these loops don't surface because we immediately flush each unlinked inode after loading it.
Fix all of these issues.
--- fs/xfs/xfs_log_recover.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
fs/xfs/xfs_log_recover.c +8 -5
@@ -2701,12 +2701,13 @@ xlog_recover_iunlink_bucket( {struct xfs_mount *mp = pag->pag_mount;struct xfs_inode *prev_ip =NULL ; -struct xfs_inode *ip;xfs_agino_t prev_agino, agino;int error =0 ; agino =be32_to_cpu (agi->agi_unlinked[bucket]);while (agino !=NULLAGINO ) { +struct xfs_inode *ip; + error =xfs_iget (mp,NULL ,XFS_AGINO_TO_INO (mp, pag->pag_agno, agino),0 ,0 , &ip);
@@ -2716,11 +2717,11 @@ xlog_recover_iunlink_bucket(ASSERT (VFS_I (ip)->i_nlink ==0 );ASSERT (VFS_I (ip)->i_mode !=0 );xfs_iflags_clear (ip,XFS_IRECOVERY ); - agino = ip->i_next_unlinked;if (prev_ip) { ip->i_prev_unlinked = prev_agino;xfs_irele (prev_ip); + prev_ip =NULL ;/* * Ensure the inode is removed from the unlinked list
@@ -2732,18 +2733,20 @@ xlog_recover_iunlink_bucket(* complete. */ error =xfs_inodegc_flush (mp); -if (error) -break ; +if (error) { +xfs_irele (ip); +return error; + } } prev_agino = agino; + agino = ip->i_next_unlinked; prev_ip = ip; }if (prev_ip) {int error2; - ip->i_prev_unlinked = prev_agino;xfs_irele (prev_ip); error2 =xfs_inodegc_flush (mp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 163/1674 mm/damon/vaddr: avoid hw-driven pte updates during damon_hugetlb_mkold()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: SJ Park <[email protected]>
[ Upstream commit 39c0ceedd54557bdc1542de08d22b2ed33e534e4 ]
damon_hugetlb_mkold() reads the page table entry into a local variable, unsets the accessed bit in the variable, and updates the page table entry with the updated variable value. If hardware updates the same page table entry in parallel, the hw updates could be lost. For example, hardware-updated dirty bits might be lost.
Avoid the parallel updates by clearing the page table entry when reading it together, using huge_ptep_get_and_clear(). If a parallel write to the memory is made after the clearing, the hw will see the page table entry is cleared, trigger page fault and wait until it is handled. The page fault handling will wait for damon_hugetlb_mkold() due to the page table lock.
Because hugetlbfs is an in-memory file system and hugetlb pages cannot be reclaimed, no critical issue is expected to my best knowledge. But definitely this is a nasty bug that should be fixed sooner rather than later.
The issue was discovered [1] by Sashiko.
--- mm/damon/vaddr.c | 1 + 1 file changed, 1 insertion(+)
mm/damon/vaddr.c +1 -0
@@ -347,6 +347,7 @@ static void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,if (pte_young (entry)) { referenced = true; + entry =huge_ptep_get_and_clear (mm, addr, pte, psize); entry =pte_mkold (entry);set_huge_pte_at (mm, addr, pte, entry, psize); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 164/1674 ALSA: usb-audio: Apply IGNORE_CTL_ERROR quirk to all Audient devices
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit a154f7b9f197b3d5e41fa3ad62083f5aa93b1fe8 ]
Faaris reported a problem with Audient EVO4 device and it turned out to be a regression by the recent fix commit 87a6f2fa6e6c ("ALSA:
usb-audio: Propagate write errors in generic mixer put callbacks"). It exhibited that the hardware gives errors at accessing the mixer unit 10 on certain channels, and the change above made it a fatal error.
We had already a quirk for Audient iD14 to work around such errors from the mixer controls, and we can simply apply the same for EVO4. OTOH, it's highly possible that other Audient devices suffer from the same issue; they must be using similar firmware, after all.
So, in this patch, we apply the quirk generically to all devices with the vendor ID Audient (2708), instead. Ignoring the control error isn't usually less critical than overreaction to the firmware misbehavior.
--- sound/usb/quirks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/quirks.c +2 -2
@@ -2271,8 +2271,6 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { QUIRK_FLAG_SET_IFACE_FIRST),DEVICE_FLG (0x262a ,0x9302 ,/* ddHiFi TC44C */ QUIRK_FLAG_DSD_RAW ), -DEVICE_FLG (0x2708 ,0x0002 ,/* Audient iD14 */ -QUIRK_FLAG_IGNORE_CTL_ERROR ),DEVICE_FLG (0x2772 ,0x0502 ,/* Musical Fidelity M6s DAC */ 0 ),/* for avoiding QUIRK_FLAG_DSD_RAW with vendor match */ DEVICE_FLG(0x2912, 0x30c8, /* Audioengine D1 */
@@ -2340,6 +2338,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { QUIRK_FLAG_DSD_RAW),VENDOR_FLG (0x2622 ,/* IAG Limited devices */ QUIRK_FLAG_DSD_RAW ), +VENDOR_FLG (0x2708 ,/* Audient devices */ +QUIRK_FLAG_IGNORE_CTL_ERROR ),VENDOR_FLG (0x2772 ,/* Musical Fidelity devices */ QUIRK_FLAG_DSD_RAW ), VENDOR_FLG(0x278b, /* Rotel? */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 165/1674 audit: fix exe mark UAF in kill_rules()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
commit aa650d87a498844060eecb1d336f4d46f4d1b0b3 upstream.
kill_rules() removes mixed AUDIT_DIR and AUDIT_EXE rules when an audit tree is pruned. It drops entry->rule.exe before removing the rule from the RCU-visible filter lists.
After a rule has been installed with AUDIT_ADD_RULE, which requires CAP_AUDIT_CONTROL, removing the watched directory can race with another task that is still evaluating the rule. In that case, fsnotify can free the executable mark before the reader reaches audit_mark_compare(), causing a use-after-free.
KASAN reports:
BUG: KASAN: slab-use-after-free in audit_mark_compare+0x8d/0xa0
Unlink the published rules from the RCU-visible lists and retain them on tree->rules for cleanup. If any rule has an executable mark, wait for a single RCU grace period before removing the marks and scheduling the entries for freeing. Otherwise, call_rcu() already provides the required deferred freeing without a synchronous wait.
--- kernel/audit_tree.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
kernel/audit_tree.c +20 -4
@@ -543,22 +543,38 @@ static void kill_rules(struct audit_cont {struct audit_krule *rule, *next;struct audit_entry *entry; +bool need_sync = false;list_for_each_entry_safe (rule, next, &tree->rules, rlist) { entry = container_of(rule, struct audit_entry, rule); -list_del_init (&rule->rlist);if (rule->tree) {/* not a half-baked one */ audit_tree_log_remove_rule (context, rule); -if (entry->rule.exe) -audit_remove_mark (entry->rule.exe); rule->tree =NULL ;list_del_rcu (&entry->list);list_del (&entry->rule.list); -call_rcu (&entry->rcu, audit_free_rule_rcu); +if (entry->rule.exe) + need_sync = true; + }else { +list_del_init (&rule->rlist); } } + +if (list_empty (&tree->rules)) +return ; + +if (need_sync) +synchronize_rcu (); + +list_for_each_entry_safe (rule, next, &tree->rules, rlist) { + entry = container_of(rule, struct audit_entry, rule); + +list_del_init (&rule->rlist); +if (entry->rule.exe) +audit_remove_mark (entry->rule.exe); +call_rcu (&entry->rcu, audit_free_rule_rcu); + } }/*
Greg Kroah-Hartman
maintainerPATCH 166/1674 kprobes: Skip disarmed probes when checking optkprobe overlap
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
commit 7a39c732a22ec4a369af9e19fbe3d666ec83eec4 upstream.
On x86, an optkprobe at A replaces five bytes with a jump. If a disabled probe B is at A+2, get_optimized_kprobe() stops at B when arming a new probe C at A+4. It leaves A optimized:
A A+1 A+2 A+3 A+4 A's jump | e9 | d0 | d1 | d2 | d3 | after C | e9 | d0 | d1 | d2 | cc |
The INT3 for C overwrites the last byte of A's jump displacement, so execution can jump to the wrong address. B can have prepared optinsns while disarmed, but has no jump to unoptimize.
Continue past disarmed and unprepared probes to find the active optimized probe before arming a probe in its jump.
--- kernel/kprobes.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/kprobes.c +5 -3
@@ -491,14 +491,16 @@ static bool kprobe_queued(struct kprobestatic struct kprobe *get_optimized_kprobe (kprobe_opcode_t *addr) {int i; -struct kprobe *p =NULL ; +struct kprobe *p;struct optimized_kprobe *op;/* Don't check i == 0, since that is a breakpoint case. */ -for (i =1 ; !p && i <MAX_OPTIMIZED_LENGTH /sizeof (kprobe_opcode_t); i++) +for (i =1 ; i <MAX_OPTIMIZED_LENGTH /sizeof (kprobe_opcode_t); i++) { p =get_kprobe (addr - i); +/* A disabled probe can have prepared, but inactive, optinsns. */ +if (!p || !kprobe_optready (p) ||kprobe_disarmed (p)) +continue ; -if (p &&kprobe_optready (p)) { op = container_of(p, struct optimized_kprobe, kp);if (arch_within_optimized_kprobe (op, addr))return p;
Greg Kroah-Hartman
maintainerPATCH 167/1674 of/irq: Fix remaining refcount leaks in of_irq_init()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 30724547b221e0e670ddfef140fc7d816b2aaec6 upstream.
Successfully initialized controllers are moved to intc_parent_list, but the final cleanup only frees the descriptors. The device node references taken with of_node_get() and the interrupt parent references are therefore leaked on the normal return path. Drop both before kfree(), as the intc_desc_list cleanup already does.
--- drivers/of/irq.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/of/irq.c +2 -0
@@ -660,6 +660,8 @@ void __init of_irq_init(const struct of_list_for_each_entry_safe (desc, temp_desc, &intc_parent_list, list) {list_del (&desc->list); +of_node_put (desc->interrupt_parent); +of_node_put (desc->dev);kfree (desc); } err:
Greg Kroah-Hartman
maintainerPATCH 168/1674 of/overlay: put property on deadprops only after changeset add succeeds
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
commit 814f2da6995772c07a7c9c2cc6028b6e3f3ecc9c upstream.
add_changeset_property() links a new property of a not-yet-live target node into the node's deadprops list before handing it to of_changeset_add_property(). If that fails, the error path frees the property but leaves the freed pointer linked in deadprops, and of_node_release() frees it a second time when the aborted overlay's node is released.
Record the changeset entry first and link the property into deadprops only on success. of_changeset_add_property() never looks at the node's property lists, so the order of the two steps is otherwise immaterial, and the error path frees a property that nothing references.
--- drivers/of/overlay.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/of/overlay.c +4 -3
@@ -353,12 +353,13 @@ static int add_changeset_property(structreturn -ENOMEM ;if (!prop) { -if (!target->in_livetree) { + ret =of_changeset_add_property (&ovcs->cset, target->np, + new_prop); +/* the detached node owns the property until the apply */ +if (!ret && !target->in_livetree) { new_prop->next = target->np->deadprops; target->np->deadprops = new_prop; } - ret =of_changeset_add_property (&ovcs->cset, target->np, - new_prop); }else { ret =of_changeset_update_property (&ovcs->cset, target->np, new_prop);
Greg Kroah-Hartman
maintainerPATCH 169/1674 of/overlay: only treat a positive changeset id as registered
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
commit 44081d708b5b885487bac792db78324b7b4c267d upstream.
of_overlay_fdt_apply() stores the idr_alloc() return value in ovcs->id before checking it. On failure the stored id is negative, free_overlay_changeset()'s "if (ovcs->id)" check passes, idr_remove() is called with a negative id and list_del() runs on ovcs->ovcs_list, which is not initialized until after the id allocation. An allocation failure at that point dereferences NULL.
Make free_overlay_changeset() treat only a strict-positive id as registered. The rest of the function already copes with a partially-initialized ovcs, so the error path stays a plain goto err_free_ovcs.
--- drivers/of/overlay.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/of/overlay.c +2 -1
@@ -861,7 +861,8 @@ static void free_overlay_changeset(strucif (ovcs->cset.entries.next)of_changeset_destroy (&ovcs->cset); -if (ovcs->id) { +/* a failed idr_alloc() leaves its negative error in ovcs->id */ +if (ovcs->id >0 ) {idr_remove (&ovcs_idr, ovcs->id);list_del (&ovcs->ovcs_list); ovcs->id =0 ;
Greg Kroah-Hartman
maintainerPATCH 170/1674 net: fix checksum offsets in skb_splice_from_iter()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alireza Asgari <[email protected]>
commit febec6a7076499d16b37f556724a942633a270a6 upstream.
skb_splice_from_iter() appends multiple page fragments before updating skb->len. However, skb_splice_csum_page() uses that unchanged length as the offset for every fragment checksum. If bytes already appended during the call have an odd total length, a later fragment's checksum is combined with the wrong parity.
For example, prime a UDP socket with sendto(MSG_MORE) and splice two distinct pipe buffers containing "abc" and "DEFGH". Uncorking reports success, but the receiver discards the packet for a bad checksum. This also affects IPv6 and fragments beginning near a page boundary.
Pass the initial skb length plus the bytes already spliced to the checksum helper. Keep the existing final length update and partial-progress error handling unchanged. CHECKSUM_PARTIAL does not use this helper and remains unaffected.
--- net/core/skbuff.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/core/skbuff.c +5 -3
@@ -6919,7 +6919,8 @@ nodefer: __kfree_skb(skb); }static void skb_splice_csum_page (struct sk_buff *skb,struct page *page, -size_t offset,size_t len) +size_t offset,size_t len, +unsigned int csum_offset) {const char *kaddr;__wsum csum;
@@ -6927,7 +6928,7 @@ static void skb_splice_csum_page(struct kaddr =kmap_local_page (page); csum =csum_partial (kaddr + offset, len,0 );kunmap_local (kaddr); - skb->csum =csum_block_add (skb->csum, csum, skb->len); + skb->csum =csum_block_add (skb->csum, csum, csum_offset); }/**
@@ -6988,7 +6989,8 @@ ssize_t skb_splice_from_iter(struct sk_b }if (skb->ip_summed ==CHECKSUM_NONE ) -skb_splice_csum_page (skb, page, off, part); +skb_splice_csum_page (skb, page, off, part, + skb->len + spliced); off =0 ; spliced += part;
Greg Kroah-Hartman
maintainerPATCH 171/1674 netfilter: nft_flow_offload: drop flowtable reference on init error path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aohan Mei <[email protected]>
commit 747928b5d4ff8c8de55138a54c13980e4bb88578 upstream.
nft_flow_offload_init() bumps the flowtable use count with nft_use_inc() before calling nf_ct_netns_get(). When the latter fails, the error is returned as-is and the reference is leaked.
The upper layers do not balance it either: nf_tables_newexpr() clears expr->ops when the expression init callback fails, so the nft_expr_more() iteration in nft_rule_expr_deactivate() and nf_tables_rule_destroy() stops right before the failed expression and its ->destroy callback, which would drop the reference, never runs.
Each failed rule addition therefore leaks one flowtable reference and the flowtable can no longer be removed: NFT_MSG_DELFLOWTABLE keeps reporting -EBUSY even though no rule references it.
Save the nf_ct_netns_get() return value and undo the nft_use_inc() when it fails, restoring the inc/dec pairing within nft_flow_offload_init() itself.
--- net/netfilter/nft_flow_offload.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/netfilter/nft_flow_offload.c +6 -1
@@ -416,6 +416,7 @@ static int nft_flow_offload_init(const sstruct nft_flow_offload *priv =nft_expr_priv (expr);u8 genmask =nft_genmask_next (ctx->net);struct nft_flowtable *flowtable; +int err;if (!tb[NFTA_FLOW_TABLE_NAME ])return -EINVAL ;
@@ -430,7 +431,11 @@ static int nft_flow_offload_init(const s priv->flowtable = flowtable; -return nf_ct_netns_get (ctx->net, ctx->family); + err =nf_ct_netns_get (ctx->net, ctx->family); +if (err <0 ) +nft_use_dec (&flowtable->use); + +return err; } static void nft_flow_offload_deactivate(const struct nft_ctx *ctx,
Greg Kroah-Hartman
maintainerPATCH 172/1674 net/packet: prevent TX_RING byte count overflow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilkka Lappeteläinen <[email protected]>
commit 2cf81fc9505b148b1b70068303ea6ea4b1212403 upstream.
tpacket_snd() drains every SEND_REQUEST frame in a TX ring and adds each valid packet length to the signed int len_sum. Userspace can recycle completed frames concurrently, so a single blocking send call is not bounded by the ring size.
After enough successful transmissions len_sum wraps into the negative range. In particular, 65536 65535-byte frames followed by a 65007-byte frame produce 0xfffffdef, or -EIOCBQUEUED. sock_sendmsg_nosec() treats that as an impossible return and triggers a BUG. On systems configured to panic on oops, a CAP_NET_RAW holder can panic the host kernel.
Stop before the next frame would make the byte count exceed INT_MAX. The positive short count leaves that frame pending for a later send call.
A two-thread TPACKET_V2 reproducer triggered the BUG on an arm64 build of Linux 7.3-rc4. With this change, the same reproducer returned the expected positive short count without an oops.
--- net/packet/af_packet.c | 3 +++ 1 file changed, 3 insertions(+)
net/packet/af_packet.c +3 -0
@@ -2917,6 +2917,9 @@ static int tpacket_snd(struct packet_soc vnet_hdr.hdr_len); has_vnet_hdr = true; } +/* Prevent the byte count from wrapping into a negative errno */ +if (unlikely (tp_len >INT_MAX - len_sum)) +break ; copylen =max_t (int, copylen, hard_header_len); skb = sock_alloc_send_skb(&po->sk, hlen + tlen + sizeof(struct sockaddr_ll) +
Greg Kroah-Hartman
maintainerPATCH 173/1674 rtc: ac100: Assign .num before accessing .hws
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aamir Ahmed <[email protected]>
commit 6a4117eee82dd85f11bf898bf66026764011eeb6 upstream.
Commit f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") annotated the hws member of 'struct clk_hw_onecell_data' with __counted_by, which informs the bounds sanitizer (UBSAN_BOUNDS) about the number of elements in .hws[], so that it can warn when .hws[] is accessed out of bounds. As noted in that change, the __counted_by member must be initialized with the number of elements before the first array access happens, otherwise there will be a warning from each access prior to the initialization because the number of elements is zero. This occurs in ac100_rtc_register_clks() due to .num being assigned only after every clkout clock has been stored in .hws[]. With CONFIG_UBSAN_BOUNDS and a compiler that implements __counted_by (GCC 15.1+ or Clang 20.1+), this triggers an array-index-out-of-bounds report during probe, and with CONFIG_UBSAN_TRAP the first store traps.
Initialize .num with AC100_CLKOUT_NUM, the number of elements .hws[] was allocated with, right after the allocation. That is the value the loop counter ends up at on the success path anyway, so the provider's behaviour is unchanged.
--- drivers/rtc/rtc-ac100.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/rtc-ac100.c +2 -1
@@ -316,6 +316,8 @@ static int ac100_rtc_register_clks(strucif (!chip->clk_data)return -ENOMEM ; + chip->clk_data->num =AC100_CLKOUT_NUM ; + chip->rtc_32k_clk = clk_hw_register_fixed_rate(chip->dev, AC100_RTC_32K_NAME, NULL, 0,
@@ -359,7 +361,6 @@ static int ac100_rtc_register_clks(struc chip->clk_data->hws[i] = &clk->hw; } - chip->clk_data->num = i; ret =of_clk_add_hw_provider (np, of_clk_hw_onecell_get, chip->clk_data);if (ret) goto err_unregister_rtc_32k;
Greg Kroah-Hartman
maintainerPATCH 174/1674 rtc: spear: initialize IRQ state before requesting alarm IRQ
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 055ef5ce9f67a6a3a1363fa663007f8196cc0fb8 upstream.
devm_request_irq() enables the interrupt before it returns, so the handler may run while probe is still initializing the device. Initialize the MMIO address and spinlock before requesting the alarm IRQ.
--- drivers/rtc/rtc-spear.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/rtc/rtc-spear.c +6 -5
@@ -363,6 +363,12 @@ static int spear_rtc_probe(struct platfoif (irq <0 )return irq; + config->ioaddr =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (config->ioaddr)) +return PTR_ERR (config->ioaddr); + +spin_lock_init (&config->lock); + status =devm_request_irq (&pdev->dev, irq, spear_rtc_irq,0 , pdev->name, config);if (status) {
@@ -371,10 +377,6 @@ static int spear_rtc_probe(struct platforeturn status; } - config->ioaddr =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (config->ioaddr)) -return PTR_ERR (config->ioaddr); - config->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (config->clk))return PTR_ERR (config->clk);
@@ -383,7 +385,6 @@ static int spear_rtc_probe(struct platfoif (status <0 )return status; -spin_lock_init (&config->lock);platform_set_drvdata (pdev, config); config->rtc->ops = &spear_rtc_ops;
Greg Kroah-Hartman
maintainerPATCH 175/1674 sctp: check RCV_SHUTDOWN after the sendmsg connect wait
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun Yang <[email protected]>
commit 4f1da630d13de0370e2f6361f961f1c8b384af1c upstream.
sctp_wait_for_connect() drops the socket lock while it sleeps. An out-of-the-blue ABORT can then be processed from the socket backlog and unlink the association. If a concurrent shutdown(fd, SHUT_RD) sets RCV_SHUTDOWN, the waiter breaks with err == 0 before checking asoc->base.dead. Its final sctp_association_put() can then free the association, leaving sctp_sendmsg_to_asoc() to continue with a dangling pointer.
Check RCV_SHUTDOWN along with the wait error in sctp_sendmsg_to_asoc() before using the association again. The check only accesses the socket, so it needs no additional association reference. Return the existing -ESRCH so that sctp_sendmsg() skips freeing a new association that may already have been destroyed.
Keep sctp_wait_for_connect() unchanged to preserve its behavior for the connect() caller.
--- net/sctp/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/socket.c +1 -1
@@ -1843,7 +1843,7 @@ static int sctp_sendmsg_to_asoc(struct sif (asoc->ep->intl_enable) { timeo =sock_sndtimeo (sk,0 ); err =sctp_wait_for_connect (asoc, &timeo); -if (err) { +if (err || sk->sk_shutdown &RCV_SHUTDOWN ) { err = -ESRCH ; goto err; }
Greg Kroah-Hartman
maintainerPATCH 176/1674 smb: client: clear setuid/setgid bit on write with cifsacl/modefromsid/posix extensions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiangshan Yi <[email protected]>
commit b8e5dc4f95e5484159b343903f302eb6d783f2e6 upstream.
When a file has the setuid or setgid bit set and is written to, the VFS strips those bits and issues a setattr with ATTR_KILL_SUID/ATTR_KILL_SGID together with an ATTR_MODE carrying the already-cleared mode.
Both cifs_setattr_unix() and cifs_setattr_nounix() unconditionally dropped ATTR_MODE in that case:
/* skip mode change if it's just for clearing setuid/setgid */ if (attrs->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) attrs->ia_valid &= ~ATTR_MODE;
This is fine for the default mount, where the mode is only emulated via the DOS read-only attribute and cannot represent the setuid/setgid bits anyway. However, with the "cifsacl" or "modefromsid" mount options the mode is stored on the server through an ACL (id_mode_to_cifs_acl()), with the SMB3.1.1 POSIX extensions the mode is sent to the server directly, and with the SMB1 Unix extensions (cifs_setattr_unix) the mode is sent via CIFSSMBUnixSetPathInfo(). In all those cases dropping ATTR_MODE means the cleared mode is never pushed to the server, so the setuid/setgid bit survives the write.
This is a security issue: on local filesystems the setuid bit is stripped when a file is written, but over these cifs.ko mounts the bit persists on the server, potentially allowing an unexpected privilege escalation on subsequent execution.
Fix this in two places:
1. cifs_setattr_nounix(): only take the "skip mode change" shortcut when the mode is emulated via the DOS read-only attribute (i.e. neither cifsacl/modefromsid nor the SMB3.1.1 POSIX extensions are in effect), so that the cleared mode is propagated to the server in the ACL / POSIX cases.
2. cifs_setattr_unix(): this function is only called when Unix extensions are in effect, so the mode is always stored on the server. Remove the shortcut entirely so that the cleared mode is always pushed.
[ Backport note for 6.6: no sbflags local exists here, so test
cifs_sb->mnt_cifs_flags directly (same flag bits); uses existing "bool posix". ]
--- fs/smb/client/inode.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
fs/smb/client/inode.c +25 -5
@@ -3064,9 +3064,13 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs) goto out; } -/* skip mode change if it's just for clearing setuid/setgid */ -if (attrs->ia_valid & (ATTR_KILL_SUID |ATTR_KILL_SGID )) - attrs->ia_valid &= ~ATTR_MODE ; +/* +* This function is only called when Unix extensions are in effect, +* so the mode is always sent to and stored on the server. Do not +* skip the mode change when clearing setuid/setgid bits: dropping +* ATTR_MODE here would leave those bits set on the server after a +* write, which is a security issue. +*/ args =kmalloc (sizeof (*args),GFP_KERNEL );if (args ==NULL ) {
@@ -3253,8 +3257,24 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SET_UID )) attrs->ia_valid &= ~(ATTR_UID |ATTR_GID ); -/* skip mode change if it's just for clearing setuid/setgid */ -if (attrs->ia_valid & (ATTR_KILL_SUID |ATTR_KILL_SGID )) +/* +* Skip the mode change if it is only being done to clear the +* setuid/setgid bits *and* the mode is emulated via the DOS +* read-only attribute (the default, non-ACL case), which cannot +* represent the setuid/setgid bits anyway. +* +* When the mode is instead stored on the server - i.e. with the +* cifsacl or modefromsid mount options (via an ACL) or with the +* SMB3.1.1 POSIX extensions - the cleared mode must be pushed to +* the server. Dropping ATTR_MODE here would leave the setuid/ +* setgid bit set on the server after a write, which is a security +* issue (the bits are not stripped as they are on local +* filesystems). +*/ +if ((attrs->ia_valid & (ATTR_KILL_SUID |ATTR_KILL_SGID )) && + !((cifs_sb->mnt_cifs_flags & + (CIFS_MOUNT_CIFS_ACL |CIFS_MOUNT_MODE_FROM_SID )) || + posix)) attrs->ia_valid &= ~ATTR_MODE ;if (attrs->ia_valid &ATTR_MODE ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 177/1674 scsi: lpfc: Define lpfc_dmabuf type for ctx_buf ptr
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Tee <[email protected]>
[ Upstream commit 115d137aa918d879e3cca9605bbf59e0482aa734 ]
In LPFC_MBOXQ_t, the ctx_buf ptr shouldn't be defined as a generic void *ptr. It is named ctx_buf and it should only be used as an lpfc_dmabuf *ptr. Due to the void* declaration, there have been abuses of ctx_buf for things not related to lpfc_dmabuf.
So, set the ptr type for *ctx_buf as lpfc_dmabuf. Remove all type casts on ctx_buf because it is no longer a void *ptr. Convert the abuse of ctx_buf for something not related to lpfc_dmabuf to use the void *context3 ptr.
A particular abuse of the ctx_buf warranted a new void *ext_buf ptr. However, the usage of this new void *ext_buf is not generic. It is intended to only hold virtual addresses for extended mailbox commands.
[ Backport to 6.6.y: retain only the ext_buf member and the corresponding
extended-mailbox producers and SLI3 copy sites. The remainder of the upstream context-pointer cleanup depends on earlier patches in the lpfc 14.4.0.1 series and is unrelated to this timeout fix. Keeping the SLI3 payload in ext_buf leaves ctx_buf pointing to its DMA descriptor through late completion and cleanup. ]
--- drivers/scsi/lpfc/lpfc_bsg.c | 2 +- drivers/scsi/lpfc/lpfc_els.c | 4 ++-- drivers/scsi/lpfc/lpfc_sli.c | 20 ++++++++++---------- drivers/scsi/lpfc/lpfc_sli.h | 1 + 4 files changed, 14 insertions(+), 13 deletions(-)
drivers/scsi/lpfc/lpfc_bsg.c +1 -1
@@ -4747,7 +4747,7 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct bsg_job *job,if (mbox_req->inExtWLen || mbox_req->outExtWLen) { from = pmbx; ext = from +sizeof (MAILBOX_t); - pmboxq->ctx_buf = ext; + pmboxq->ext_buf = ext; pmboxq->in_ext_byte_len = mbox_req->inExtWLen *sizeof (uint32_t ); pmboxq->out_ext_byte_len =
drivers/scsi/lpfc/lpfc_els.c +2 -2
@@ -7300,7 +7300,7 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba, mbox->in_ext_byte_len =DMP_SFF_PAGE_A0_SIZE ; mbox->out_ext_byte_len =DMP_SFF_PAGE_A0_SIZE ; mbox->mbox_offset_word =5 ; - mbox->ctx_buf = virt; + mbox->ext_buf = virt; }else {bf_set (lpfc_mbx_memory_dump_type3_length, &mbox->u.mqe.un.mem_dump_type3,DMP_SFF_PAGE_A0_SIZE );
@@ -7360,7 +7360,7 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba, mbox->in_ext_byte_len =DMP_SFF_PAGE_A2_SIZE ; mbox->out_ext_byte_len =DMP_SFF_PAGE_A2_SIZE ; mbox->mbox_offset_word =5 ; - mbox->ctx_buf = virt; + mbox->ext_buf = virt; }else {bf_set (lpfc_mbx_memory_dump_type3_length, &mbox->u.mqe.un.mem_dump_type3,DMP_SFF_PAGE_A2_SIZE );
drivers/scsi/lpfc/lpfc_sli.c +10 -10
@@ -9558,8 +9558,8 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, }/* Copy the mailbox extension data */ -if (pmbox->in_ext_byte_len && pmbox->ctx_buf) { -lpfc_sli_pcimem_bcopy (pmbox->ctx_buf, +if (pmbox->in_ext_byte_len && pmbox->ext_buf) { +lpfc_sli_pcimem_bcopy (pmbox->ext_buf, (uint8_t *)phba->mbox_ext, pmbox->in_ext_byte_len); }
@@ -9572,10 +9572,10 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, = MAILBOX_HBA_EXT_OFFSET;/* Copy the mailbox extension data */ -if (pmbox->in_ext_byte_len && pmbox->ctx_buf) +if (pmbox->in_ext_byte_len && pmbox->ext_buf)lpfc_memcpy_to_slim (phba->MBslimaddr +MAILBOX_HBA_EXT_OFFSET , - pmbox->ctx_buf, pmbox->in_ext_byte_len); + pmbox->ext_buf, pmbox->in_ext_byte_len);if (mbx->mbxCommand ==MBX_CONFIG_PORT )/* copy command data into host mbox for cmpl */
@@ -9698,9 +9698,9 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox,lpfc_sli_pcimem_bcopy (phba->mbox, mbx,MAILBOX_CMD_SIZE );/* Copy the mailbox extension data */ -if (pmbox->out_ext_byte_len && pmbox->ctx_buf) { +if (pmbox->out_ext_byte_len && pmbox->ext_buf) {lpfc_sli_pcimem_bcopy (phba->mbox_ext, - pmbox->ctx_buf, + pmbox->ext_buf, pmbox->out_ext_byte_len); } }else {
@@ -9708,9 +9708,9 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox,lpfc_memcpy_from_slim (mbx, phba->MBslimaddr,MAILBOX_CMD_SIZE );/* Copy the mailbox extension data */ -if (pmbox->out_ext_byte_len && pmbox->ctx_buf) { +if (pmbox->out_ext_byte_len && pmbox->ext_buf) {lpfc_memcpy_from_slim ( - pmbox->ctx_buf, + pmbox->ext_buf, phba->MBslimaddr +MAILBOX_HBA_EXT_OFFSET , pmbox->out_ext_byte_len);
@@ -13822,10 +13822,10 @@ lpfc_sli_sp_intr_handler(int irq, void *dev_id)lpfc_sli_pcimem_bcopy (mbox, pmbox,MAILBOX_CMD_SIZE );if (pmb->out_ext_byte_len && - pmb->ctx_buf) + pmb->ext_buf)lpfc_sli_pcimem_bcopy ( phba->mbox_ext, - pmb->ctx_buf, + pmb->ext_buf, pmb->out_ext_byte_len); }if (pmb->mbox_flag &LPFC_MBX_IMED_UNREG ) {
drivers/scsi/lpfc/lpfc_sli.h +1 -0
@@ -184,6 +184,7 @@ typedef struct lpfcMboxq {struct lpfc_vport *vport;/* virtual port pointer */ void *ctx_ndlp;/* caller ndlp information */ void *ctx_buf;/* caller buffer information */ +void *ext_buf;/* extended mailbox payload */ void *context3;void (*mbox_cmpl) (struct lpfc_hba *,struct lpfcMboxq *);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 178/1674 scsi: lpfc: Handle mailbox timeouts in lpfc_get_sfp_info
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Tee <[email protected]>
[ Upstream commit ede596b1434b57c0b3fd5c02b326efe5c54f6e48 ]
The MBX_TIMEOUT return code is not handled in lpfc_get_sfp_info and the routine unconditionally frees submitted mailbox commands regardless of return status. The issue is that for MBX_TIMEOUT cases, when firmware returns SFP information at a later time, that same mailbox memory region references previously freed memory in its cmpl routine.
Fix by adding checks for the MBX_TIMEOUT return code. During mailbox resource cleanup, check the mbox flag to make sure that the wait did not timeout. If the MBOX_WAKE flag is not set, then do not free the resources because it will be freed when firmware completes the mailbox at a later time in its cmpl routine.
Also, increase the timeout from 30 to 60 seconds to accommodate boot scripts requiring longer timeouts.
[ Backport to 6.6.y: depend on the preceding ext_buf split from upstream
commit 115d137aa918 ("scsi: lpfc: Define lpfc_dmabuf type for ctx_buf ptr") so an SLI3 late completion copies its payload separately from the DMA descriptor. Retain the 6.6.y ctx_ndlp assignments. ]
--- drivers/scsi/lpfc/lpfc_els.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +11 -6
@@ -7309,13 +7309,13 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba, } mbox->vport = phba->pport; mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; - - rc =lpfc_sli_issue_mbox_wait (phba, mbox,30 ); + rc =lpfc_sli_issue_mbox_wait (phba, mbox,LPFC_MBOX_SLI4_CONFIG_TMO );if (rc ==MBX_NOT_FINISHED ) { rc =1 ; goto error; } - +if (rc ==MBX_TIMEOUT ) + goto error;if (phba->sli_rev ==LPFC_SLI_REV4 ) mp = (struct lpfc_dmabuf *)(mbox->ctx_buf);else
@@ -7369,7 +7369,10 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba, } mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; - rc =lpfc_sli_issue_mbox_wait (phba, mbox,30 ); + rc =lpfc_sli_issue_mbox_wait (phba, mbox,LPFC_MBOX_SLI4_CONFIG_TMO ); + +if (rc ==MBX_TIMEOUT ) + goto error;if (bf_get (lpfc_mqe_status, &mbox->u.mqe)) { rc =1 ; goto error;
@@ -7380,8 +7383,10 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba, DMP_SFF_PAGE_A2_SIZE); error: - mbox->ctx_buf = mpsave; -lpfc_mbox_rsrc_cleanup (phba, mbox,MBOX_THD_UNLOCKED ); +if (mbox->mbox_flag &LPFC_MBX_WAKE ) { + mbox->ctx_buf = mpsave; +lpfc_mbox_rsrc_cleanup (phba, mbox,MBOX_THD_UNLOCKED ); + }return rc;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 179/1674 wifi: cfg80211: avoid double free if updating BSS fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Berg <[email protected]>
[ Upstream commit acc44cbd7727115f9381c35c2898b1b5af665ec8 ]
cfg80211_update_known_bss will always consume the passed IEs. As such, cfg80211_update_assoc_bss_entry also needs to always set the pointers to NULL so that no double free can occur.
Note that hitting this would probably require being connected to a hidden BSS which is then doing a channel switch while also switching to be not hidden anymore at the same time.
--- net/wireless/scan.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/wireless/scan.c +3 -4
@@ -3162,10 +3162,9 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev,if (new) {/* to save time, update IEs for transmitting bss only */ -if (cfg80211_update_known_bss (rdev, cbss, new, false)) { - new->pub.proberesp_ies =NULL ; - new->pub.beacon_ies =NULL ; - } +cfg80211_update_known_bss (rdev, cbss, new, false); + new->pub.proberesp_ies =NULL ; + new->pub.beacon_ies =NULL ; list_for_each_entry_safe(nontrans_bss, tmp, &new->pub.nontrans_list,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 180/1674 rds_tcp: close NULL deref window in rds_tcp_set_callbacks
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maoyi Xie <[email protected]>
commit d2bfdbb69cf87676981b1043010b6224d84c6d3a upstream.
rds_tcp_set_callbacks() links a new rds_tcp_connection onto rds_tcp_tc_list under rds_tcp_tc_list_lock. It releases the lock, then assigns tc->t_sock = sock outside the lock.
rds_tcp_tc_info() and rds6_tcp_tc_info() walk rds_tcp_tc_list under the same lock. Both dereference tc->t_sock->sk without a NULL check.
A reader can acquire rds_tcp_tc_list_lock between the writer's spin_unlock and the t_sock store. It then sees a list entry whose t_sock is NULL. The dereference of tc->t_sock->sk is a NULL access.
Move tc->t_sock = sock inside rds_tcp_tc_list_lock, before list_add_tail. A reader holding the lock then observes the linkage and the t_sock store together.
The restore path is safe. rds_tcp_restore_callbacks() does list_del_init inside the lock. The matching tc->t_sock = NULL after unlink is harmless to readers holding the lock.
[ achender: resolved context conflict; tc->t_rtn initialization is not
present in this tree ]
--- net/rds/tcp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/rds/tcp.c +6 -3
@@ -231,16 +231,19 @@ void rds_tcp_set_callbacks(struct socket *sock, struct rds_conn_path *cp)rdsdebug ("setting sock %p callbacks to tc %p\n" , sock, tc);write_lock_bh (&sock->sk->sk_callback_lock); -/* done under the callback_lock to serialize with write_space */ +/* done under the callback_lock to serialize with write_space. +* Set t_sock inside rds_tcp_tc_list_lock so readers walking +* rds_tcp_tc_list under the same lock cannot observe an +* entry whose t_sock is NULL. +*/ spin_lock (&rds_tcp_tc_list_lock); + tc->t_sock = sock;list_add_tail (&tc->t_list_item, &rds_tcp_tc_list);spin_unlock (&rds_tcp_tc_list_lock);/* accepted sockets need our listen data ready undone */ if (sock->sk->sk_data_ready == rds_tcp_listen_data_ready) sock->sk->sk_data_ready = sock->sk->sk_user_data; - - tc->t_sock = sock; tc->t_cpath = cp; tc->t_orig_data_ready = sock->sk->sk_data_ready; tc->t_orig_write_space = sock->sk->sk_write_space;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 181/1674 vt: skip screen update for DEC alignment test on backgroup consoles
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <[email protected]>
commit 0928ed9bd7946baee911efa401088697836e3b1e upstream.
[BUG]
Recently, we encountered a KASAN warning as follows:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0x11f/0x140 Read of size 1 at addr ff1100015fd9f6a4 by task tty_fbcon_oob/1239 CPU: 7 UID: 0 PID: 1239 Comm: tty_fbcon_oob Not tainted 7.3.0-rc1 #100 PREEMPT(full) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-4.fc41 04/01/2014 Call Trace: <TASK> ... kasan_report+0xf0/0x120 fb_pad_aligned_buffer+0x11f/0x140 ccw_putcs+0x86c/0xa80 fbcon_putcs+0x338/0x410 do_update_region+0x21d/0x450 do_con_write+0x1e0e/0x4880 con_write+0x13/0x80 n_tty_write+0x374/0x1010 file_tty_write.isra.0+0x404/0x7a0 ...
reproduce:
1) open /dev/tty0, set a KDFONTOP ioctl with op.op = KD_FONT_OP_SET, op.width = 8 and op.height = 16 (visible VC1)
2) open /dev/tty1, set a KDFONTOP ioctl with op.op = KD_FONT_OP_SET, op.width = 28 and op.height = 24 (invisible VC2)
3) echo 3 > /sys/devices/virtual/graphics/fbcon/rotate_all
4) write EShash8(esc hash8) to tty1
[CAUSE]
All VCs render to the framebuffer. setfont only modifies the target VC's font without resizing the framebuffer backing buffer (par->rotated.buf); the buffer is only resized for the visible VC (fbcon_do_set_font -> ... -> vc_do_resize -> update_screen). This relies on the con_should_update() check performed before every update_region().
However, the ESC # 8 path (do_con_trol -> do_update_region) omits the con_should_update() check. After changing the font size of an invisible VC, do_update_region() fills using the new font size against a buffer that was never resized, causing an out-of-bounds access.
[FIX]
Only push the update when the console is visible and not blanked, add the con_should_update() check in the do_con_trol() like every other call site of do_update_region() (update_region(), invert_screen(), ...).
--- drivers/tty/vt/vt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/vt/vt.c +2 -1
@@ -2497,7 +2497,8 @@ static void do_con_trol(struct tty_struccsi_J (vc,2 ); vc->vc_video_erase_char = (vc->vc_video_erase_char &0xff00 ) |' ' ; -do_update_region (vc, vc->vc_origin, vc->vc_screenbuf_size /2 ); +if (con_should_update (vc)) +do_update_region (vc, vc->vc_origin, vc->vc_screenbuf_size /2 ); }return ;case ESsetG0:
Greg Kroah-Hartman
maintainerPATCH 182/1674 ALSA: caiaq: unregister the input device when probe fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
commit 0b7bd20f6379bc5e431fd74d866390f5b5b63f3c upstream.
setup_card() registers the input device, whose name and phys point into struct snd_usb_caiaqdev, and then goes on to snd_card_register() and snd_usb_caiaq_control_init(). If either fails, snd_probe() calls snd_card_free(), which frees the device state but leaves the input device registered: card_free() only clears the pointer, and the input device is unregistered from snd_disconnect() alone. Reading its "uevent" attribute afterwards dereferences freed memory:
BUG: KASAN: slab-use-after-free in string+0x4a9/0x4f0 Read of size 1 at addr ffff8880208f5043 by task caiaq/4967 add_uevent_var+0x183/0x3a0 input_dev_uevent+0x162/0x900 dev_uevent+0x2f1/0x870 uevent_show+0x1ca/0x3a0 ...
Unregister the input device on the probe error path, as snd_disconnect() does. snd_usb_caiaq_input_disconnect() is a no-op when no input device was registered.
Reproduced with a raw-gadget Audio Kontrol 1 and a temporary hack that makes snd_usb_caiaq_control_init() fail.
--- sound/usb/caiaq/device.c | 3 +++ 1 file changed, 3 insertions(+)
sound/usb/caiaq/device.c +3 -0
@@ -562,6 +562,9 @@ static int snd_probe(struct usb_interfac ret =init_card (caiaqdev (card));if (ret <0 ) {dev_err (&usb_dev->dev,"unable to init card! (ret=%d)\n" , ret); +#ifdef CONFIG_SND_USB_CAIAQ_INPUT +snd_usb_caiaq_input_disconnect (caiaqdev (card)); +#endif snd_card_free (card);return ret; }
Greg Kroah-Hartman
maintainerPATCH 183/1674 ALSA: line6: reject oversized playback packets
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
commit 61b0a5a114fa4552892da5c0ff2f42e63bf08c6b upstream.
Each playback URB is handed a slice of out.buffer that is exactly LINE6_ISO_PACKETS * max_packet_size_out bytes, sized from the OUT endpoint, but the number of bytes written into that slice is never compared against it.
submit_audio_out_urb() takes the frame count from prev_fsize, which audio_in_callback() derived from the *IN* endpoint's received packet length, and rescales it with the playback frame size; when prev_fsize is still zero it synthesizes a length from the sample rate instead. On a device declaring a large IN wMaxPacketSize and a small OUT wMaxPacketSize, the resulting memcpy(), or the memset() when the playback stream is idle, runs past its slice and, as the reproducer below shows, beyond the allocation.
usb_submit_urb() is not a backstop. max_packet_size_out comes from usb_maxpacket(), which returns only the low 11 bits of wMaxPacketSize, while USB core validates a high-speed isochronous length against that base scaled by usb_endpoint_maxp_mult(). A length of up to three times the allocated slice is therefore accepted, and even a rejected URB is only rejected after the write.
Reject a packet that does not fit the slice the driver allocated for it. Clamping it instead would silently shorten the capture-derived rate feedback and desynchronize the two streams.
BUG: KASAN: slab-out-of-bounds in submit_audio_out_urb (sound/usb/line6/playback.c:229) Write of size 1024 at addr ffff888100bbd400 by task kworker/1:2/5002 Workqueue: events line6_startup_work Call Trace: __asan_memcpy (mm/kasan/shadow.c:106) submit_audio_out_urb (sound/usb/line6/playback.c:229) line6_submit_audio_out_all_urbs (sound/usb/line6/playback.c:291) line6_stream_start (sound/usb/line6/pcm.c:194) line6_pcm_acquire (sound/usb/line6/pcm.c:337) line6_startup_work (sound/usb/line6/driver.c:728) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) The buggy address belongs to the object at ffff888100bbd400 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 0 bytes inside of allocated 256-byte region [ffff888100bbd400, ffff888100bbd500)
--- sound/usb/line6/playback.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/usb/line6/playback.c +7 -0
@@ -182,6 +182,13 @@ static int submit_audio_out_urb(struct s fsize *= bytes_per_frame; +if (fsize > line6pcm->max_packet_size_out) { +dev_err (line6pcm->line6->ifcdev, +"playback packet too large: %d > %d\n" , + fsize, line6pcm->max_packet_size_out); +return -EMSGSIZE ; + } + fout->offset = urb_size; fout->length = fsize; urb_size += fsize;
Greg Kroah-Hartman
maintainerPATCH 184/1674 mm/secretmem: properly account locked pages
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Stoakes (ARM) <[email protected]>
[ Upstream commit 97d34aa65c29cca85e3e9050f4c936389b38a054 ]
secretmem accounts folios by treating memory as if it were mlock()'d and thus limited by the RLIMIT_MEMLOCK limit.
However the folios are unevictable and remain so until the inode is evicted, eliminating usual mlock() semantics - mapping folios then unmapping them does not clear their unevictable state, since it depends on AS_UNEVICTABLE, not PG_mlocked.
A user can therefore easily work around the RLIMIT_MEMLOCK limit - simply map then unmap and VmLck no longer counts the secretmem range. Worse, folios are not accounted in the process's RSS, meaning the OOM killer won't know to kill the process.
Repeatedly mapping/unmapping (or forking) can then result in the consumption of all available system memory with unevictable folios and cause system instability.
A secretmem fd can be passed between processes and over fork so a per-process limit simply does not make sense, so follow the precedent set by io_uring, perf, skbuff, iommufd and xdp by tracking the number of locked pages in user_struct->locked_vm.
Since the scope tracked is actually inode lifetime, the RLIMIT_MEMLOCK applies per-user not per-process, so it doesn't make sense to bypass for users with CAP_IPC_LOCK, therefore remove this bypass.
There is simply no reason to carry on marking the mapping as mlock()'d since it's misleading and the lifecycle is now correctly handled, so remove this too.
Note that secretmem does not support any form of truncation (including hole punching) and the folios are unreclaimable, so the folios need only be accounted on fault and unaccounted on inode destruction.
__secretmem_account_pages() is more or less a duplicate of the code that io_uring etc. use, but since this is a bug fix that needs backporting, defer any de-duplication efforts to a follow-up.
test_mlock_limit() asserts mlock_future_ok() on mmap(), however this has been removed, so remove the test altogether for the fix. A new test will be sent separately for upstream.
--- include/linux/sched/user.h | 3 +- mm/secretmem.c | 118 ++++++++++++++++++++-- tools/testing/selftests/mm/memfd_secret.c | 30 +----- 3 files changed, 111 insertions(+), 40 deletions(-)
include/linux/sched/user.h +2 -1
@@ -25,7 +25,8 @@ struct user_struct {#if defined(CONFIG_PERF_EVENTS ) || defined(CONFIG_BPF_SYSCALL ) || \ defined(CONFIG_NET ) || defined(CONFIG_IO_URING ) || \ - defined(CONFIG_VFIO_PCI_ZDEV_KVM ) ||IS_ENABLED (CONFIG_IOMMUFD ) + defined(CONFIG_VFIO_PCI_ZDEV_KVM ) ||IS_ENABLED (CONFIG_IOMMUFD ) || \ + defined(CONFIG_SECRETMEM )atomic_long_t locked_vm;#endif #ifdef CONFIG_WATCH_QUEUE
mm/secretmem.c +108 -10
191 lines not on this page · raw message
tools/testing/selftests/mm/memfd_secret.c +1 -29
@@ -56,33 +56,6 @@ static void test_file_apis(int fd)pass ("file IO is blocked as expected\n" ); } -static void test_mlock_limit (int fd) -{ -size_t len; -char *mem; - - len = mlock_limit_cur; -if (len % page_size !=0 ) - len = (len/page_size) * page_size; - - mem =mmap (NULL , len, prot, mode, fd,0 ); -if (mem ==MAP_FAILED ) { -fail ("unable to mmap secret memory\n" ); -return ; - } -munmap (mem, len); - - len = mlock_limit_max *2 ; - mem =mmap (NULL , len, prot, mode, fd,0 ); -if (mem !=MAP_FAILED ) { -fail ("unexpected mlock limit violation\n" ); -munmap (mem, len); -return ; - } - -pass ("mlock limit is respected\n" ); -} -static void try_process_vm_read (int fd,int pipefd[2 ]) {struct iovec liov, riov;
@@ -258,7 +231,7 @@ static void prepare(void) strerror(errno)); } -#define NUM_TESTS 4 +#define NUM_TESTS 3int main (int argc,char *argv[]) {
@@ -278,7 +251,6 @@ int main(int argc, char *argv[]) strerror(errno)); } -test_mlock_limit (fd);test_file_apis (fd);test_process_vm_read (fd);test_ptrace (fd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 185/1674 perf/core: Fix WARN in perf_sigtrap()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tetsuo Handa <[email protected]>
[ Upstream commit 3da6bb419750f3ad834786d6ba7c9d5d062c770b ]
Since exit_task_work() runs after perf_event_exit_task_context() updated ctx->task to TASK_TOMBSTONE, perf_sigtrap() from perf_pending_task() might observe event->ctx->task == TASK_TOMBSTONE.
Swap the early exit tests in order not to hit WARN_ON_ONCE().
--- kernel/events/core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
kernel/events/core.c +7 -7
@@ -6808,18 +6808,18 @@ void perf_event_wakeup(struct perf_event *event)static void perf_sigtrap (struct perf_event *event) {/* -* We'd expect this to only occur if the irq_work is delayed and either -* ctx->task or current has changed in the meantime. This can be the -* case on architectures that do not implement arch_irq_work_raise(). +* Both perf_pending_task() and perf_pending_irq() can race with the +* task exiting. */ -if (WARN_ON_ONCE (event->ctx->task != current)) +if (current->flags &PF_EXITING )return ;/* -* Both perf_pending_task() and perf_pending_irq() can race with the -* task exiting. +* We'd expect this to only occur if the irq_work is delayed and either +* ctx->task or current has changed in the meantime. This can be the +* case on architectures that do not implement arch_irq_work_raise(). */ -if (current->flags &PF_EXITING ) +if (WARN_ON_ONCE (event->ctx->task != current))return ; send_sig_perf((void __user *)event->pending_addr,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 186/1674 mm/damon/core: dont skip damos_adjust_quota() while esz is not zero
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: SJ Park <[email protected]>
[ Upstream commit 52ae167ce16609c7e6fffef588b3c2c26de2db19 ]
DAMOS could unexpectedly stop working when a user disables quota using the online parameters commit feature. Fix it by correcting a wrong quota unset check in damos_adjust_quota().
DAMON users could disable all quotas by unsetting time and size quotas, and removing all quota goals. The intention of disabling quotas would be making DAMOS run at full speed. When such quota disabled setup is detected, damos_adjust_quota() skips all its work. The skipped works include effective size quota (damos_quota->esz) updates and charged quota amount (damos_quota->charged_sz) resets. The intention is to avoid doing unnecessary work when quotas are disabled.
However, users could do the setup while effective size quota is non-zero, by doing the disabling with the online DAMON parameters commit feature. In this case, because the effective size quota exists, DAMOS will keep working with the quota until it is fully charged. After the effective quota is fully charged, the charged quota amount (damos_quota->charged_sz) cannot be reset because damos_adjust_quota() skips it. Then, DAMOS stops working until the quota is newly set or DAMON is entirely restarted.
The problem happens because damos_adjust_quota() assumes the user setup for disabling quota immediately disabled it. In reality, the quota is still working until the effective size quota is also updated to zero. Other logic for catching that uses damos_quota_is_set(), which understands the fact and therefore checks the effective size quota in addition to the user setup. Fix the issue by using damos_quota_is_set() in damos_adjust_quota() to determine if its works should be skipped.
The user impact is a non-deterministic and unexpected DAMOS stop behavior. That is, users would disable quotas using the online parameters commit feature, expecting DAMOS will run at full speed. However, depending on the timing, the setup can be updated while the effective size quota is non-zero. Due to the above mentioned internal mechanism, DAMOS stops working instead of running at full speed. It is unexpected behavior. It is also non-deterministic because sometimes the setup is done when the effective size quota is zero, depending on the timing. It doesn't cause critical issues like crashes or leaks. Users can simply set a reasonable quota again, or restart DAMON. But definitely it is an unexpected and non-deterministic behavior that makes it difficult to reliably use. Also investigating the root cause of the behavior would be quite difficult.
--- mm/damon/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/core.c +1 -1
@@ -1087,7 +1087,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)unsigned long cumulated_sz;unsigned int score, max_score =0 ; -if (!quota->ms && !quota->sz) +if (!quota->esz && !quota->ms && !quota->sz)return ;/* First charge window */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 187/1674 iio: accel: kionix-kx022a: Fix array boundary check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
[ Upstream commit 0e65412aee4f651d2c9785f542a13e4b44002a75 ]
The driver performs a sanity check for an array size, when converting a register value to an array index. The check incorrectly accepts the sizeof(array) as a last index, when last valid index should be sizeof(array) - 1.
Fix the check by bailing out when index >= sizeof(array).
--- drivers/iio/accel/kionix-kx022a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/kionix-kx022a.c +1 -1
@@ -507,7 +507,7 @@ static int kx022a_read_raw(struct iio_dev *idev,if (ret)return ret; -if ((regval &KX022A_MASK_ODR ) > +if ((regval &KX022A_MASK_ODR ) >=ARRAY_SIZE (kx022a_accel_samp_freq_table)) {dev_err (data->dev,"Invalid ODR\n" );return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 188/1674 mtd: core: call _get_device() with the master MTD
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 12b31d1acd20b3185bb5f0748db0cf6874c8e9d1 ]
__get_mtd_device() calls the master's _get_device() callback with mtd, which may be a partition. __put_mtd_device() passes the master.
This breaks gluebi partitions because gluebi_get_device() uses container_of() and therefore requires the master MTD. Pass the master to _get_device(), matching _put_device().
--- drivers/mtd/mtdcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/mtdcore.c +1 -1
@@ -1255,7 +1255,7 @@ int __get_mtd_device(struct mtd_info *mtd)int err;if (master->_get_device) { - err = master->_get_device (mtd); + err = master->_get_device (master);if (err)return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 189/1674 nvmet: preserve device path on allocation failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Sun <[email protected]>
[ Upstream commit 2f271b812170d4cad578bae1f91db72f3c2e36e7 ]
nvmet_ns_device_path_store() frees the old path before allocating its replacement, losing the existing configuration if allocation fails. Allocate the new path before freeing the old one.
--- drivers/nvme/target/configfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/nvme/target/configfs.c +6 -3
@@ -346,6 +346,7 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,struct nvmet_subsys *subsys = ns->subsys;size_t len;int ret; +char *new_path =NULL ;mutex_lock (&subsys->lock); ret = -EBUSY ;
@@ -357,12 +358,14 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,if (!len) goto out_unlock; -kfree (ns->device_path); ret = -ENOMEM ; - ns->device_path =kmemdup_nul (page, len,GFP_KERNEL ); -if (!ns->device_path) + new_path =kmemdup_nul (page, len,GFP_KERNEL ); +if (!new_path) goto out_unlock; +kfree (ns->device_path); + ns->device_path = new_path; +mutex_unlock (&subsys->lock);return count;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 190/1674 of/overlay: dont leak fragment references when changeset init fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
[ Upstream commit 1d62f0f2bc7edb12ed09f71203df0e47fa4efca4 ]
init_overlay_changeset() stores the number of initialized fragments in ovcs->count only on full success. When find_target() or the __symbols__ lookup fails partway through, the target and overlay references taken for the fragments initialized so far are never
dropped: free_overlay_changeset() bounds its cleanup loop by ovcs->count, which is still 0.
Store the running count on the error path so free_overlay_changeset() puts whatever was set up. The store is guarded by ovcs->fragments because on the allocation-failure path cnt still holds the counting pass total while there is no fragments array; everywhere else cnt only counts fully-initialized fragments.
--- drivers/of/overlay.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/of/overlay.c +4 -0
@@ -851,6 +851,10 @@ static int init_overlay_changeset(struct overlay_changeset *ovcs, err_out:pr_err ("%s() failed, ret = %d\n" , __func__, ret); +/* let free_overlay_changeset() put the fragments set up so far */ +if (ovcs->fragments) + ovcs->count = cnt; +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 191/1674 of/overlay: dont create "//" paths for fragments targeting the root
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
[ Upstream commit 21c89ff1fc86ffa517f3a9ca1ba5c48e9e37c1ba ]
dup_and_fixup_symbol_prop() rewrites a symbol value by replacing its "/fragment/__overlay__" prefix with the fragment's target path. When the fragment targets the root node the target path is "/" and the result starts with "//", which __of_find_node_by_full_path() cannot
resolve: symbols pointing into such fragments silently stop resolving.
Drop the target path when it is the root and the tail is non-empty. A value naming the fragment root itself (empty tail) keeps the "/".
--- drivers/of/overlay.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/of/overlay.c +3 -0
@@ -250,6 +250,9 @@ static struct property *dup_and_fixup_symbol_prop(if (!target_path)return NULL ; target_path_len =strlen (target_path); +/* a root target renders as "/"; drop it to avoid "//" results */ +if (target_path_len ==1 && target_path[0 ] =='/' && path_tail_len) + target_path_len =0 ; new_prop =kzalloc (sizeof (*new_prop),GFP_KERNEL );if (!new_prop)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 192/1674 ASoC: wm8903: Move the DRC QR threshold to the register that holds it
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit e31ae4aeb049983fe3be0cf1e12c8074811a7685 ]
The DRC_THRESH_QR field is bits 7 and 6 of DRC_1, but the control sits on DRC_0. Its shift and max are right for the field, only the register is wrong.
Those bits of DRC_0 belong to DRC_STARTUP_GAIN, which "DRC Startup Volume" claims as bits 10 to 6. So the two controls share bits 7 and 6. Writing either one moves the other, and the quick release threshold is never reached at all.
The six fields of DRC_1 tile it exactly, so there is nowhere else the threshold could live. Point the control at DRC_1.
Found by a sweep for two controls claiming the same bits of one register. No board with this codec was to hand, the register map is the driver's own wm8903.h.
--- sound/soc/codecs/wm8903.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8903.c +1 -1
@@ -677,7 +677,7 @@ SOC_ENUM("DRC Decay Rate", drc_decay),SOC_ENUM ("DRC FF Delay" , drc_ff_delay),SOC_SINGLE ("DRC Anticlip Switch" ,WM8903_DRC_0 ,1 ,1 ,0 ),SOC_SINGLE ("DRC QR Switch" ,WM8903_DRC_0 ,2 ,1 ,0 ), -SOC_SINGLE_TLV ("DRC QR Threshold Volume" ,WM8903_DRC_0 ,6 ,3 ,0 , drc_tlv_max), +SOC_SINGLE_TLV ("DRC QR Threshold Volume" ,WM8903_DRC_1 ,6 ,3 ,0 , drc_tlv_max),SOC_ENUM ("DRC QR Decay Rate" , drc_qr_decay),SOC_SINGLE ("DRC Smoothing Switch" ,WM8903_DRC_0 ,3 ,1 ,0 ), SOC_SINGLE("DRC Smoothing Hysteresis Switch", WM8903_DRC_0, 0, 1, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 193/1674 wifi: wfx: validate MIB read length before copying to caller
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aamir Ahmed <[email protected]>
[ Upstream commit ce67ebe9d8629776ce38e6995ae72fb903c828db ]
wfx_hif_read_mib() copies reply->length bytes from the firmware response into the caller-provided buffer without checking that reply->length does not exceed val_len. A firmware response with a length field larger than expected overruns the caller buffer and reads past the end of the reply allocation.
Replace the dead -ENOMEM check with an active validation that reply->length fits within val_len before the memcpy.
--- drivers/net/wireless/silabs/wfx/hif_tx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/silabs/wfx/hif_tx.c +3 -1
@@ -189,9 +189,11 @@ int wfx_hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val, sidev_warn (wdev->dev,"%s: confirmation mismatch request\n" , __func__); ret = -EIO ; } -if (ret == -ENOMEM ) +if (!ret &&le16_to_cpu (reply->length) > val_len) {dev_err (wdev->dev,"buffer is too small to receive %s (%zu < %d)\n" ,wfx_get_mib_name (mib_id), val_len,le16_to_cpu (reply->length)); + ret = -EIO ; + }if (!ret)memcpy (val, &reply->mib_data,le16_to_cpu (reply->length));else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 194/1674 ASoC: tegra: Fix ASRC Stream6 input threshold control
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sheetal <[email protected]>
[ Upstream commit 75fc8a3ee5aee72f2fea3b6436170fae175f7f19 ]
The Stream6 Input Threshold control points at stream index 4, which is already used by Stream5. The threshold get and put callbacks derive the lane ID from the register offset, so the duplicate index makes Stream6 operate on lane 4 and leaves lane 5 inaccessible from userspace.
Use stream index 5 for Stream6.
--- sound/soc/tegra/tegra186_asrc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/tegra/tegra186_asrc.c +1 -1
@@ -831,7 +831,7 @@ static const struct snd_kcontrol_new tegra186_asrc_controls[] = { tegra186_asrc_put_input_threshold),SOC_SINGLE_EXT ("Stream6 Input Threshold" , -ASRC_STREAM_REG (TEGRA186_ASRC_RX_THRESHOLD ,4 ),0 ,3 ,0 , +ASRC_STREAM_REG (TEGRA186_ASRC_RX_THRESHOLD ,5 ),0 ,3 ,0 , tegra186_asrc_get_input_threshold, tegra186_asrc_put_input_threshold),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 195/1674 wifi: ath11k: reset ar->num_stations on hardware start
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Escande <[email protected]>
[ Upstream commit 7e0ad05ebc72fffba2bdf2400400902d94ed7272 ]
When (multiple) hw restart occurs, we end up in a situation where we cannot accept new stations / mesh peers. This seems to be the 'num_stations' in 'struct ath11k' that did not get reset properly in this case. In ath11k_mac_op_start(), it was indeed the only accounting var that did not get reset so let's clear it too.
This avoids problems like those:
[1248828.088023] WARNING: CPU: 0 PID: 12281 at net/mac80211/util.c:1682 ieee80211_reconfig_stations+0x98/0xc0 [1248828.088115] Call trace: [1248828.088116] ieee80211_reconfig_stations+0x98/0xc0 (P) [1248828.088119] ieee80211_reconfig+0x774/0x1438 [1248828.088123] ieee80211_restart_work+0x10c/0x178 [1248828.088127] process_one_work+0x178/0x3c0 [1248828.088130] worker_thread+0x280/0x440 [1248828.088133] kthread+0xe0/0xf8 [1248828.088137] ret_from_fork+0x10/0x20 [1248828.088141] ---[ end trace 0000000000000000 ]--- [1248836.686604] ath11k_pci 0000:04:00.0: refusing to associate station: too many connected already (128) [1248836.686609] ath11k_pci 0000:04:00.0: Failed to add station: xx:xx:xx:xx:xx:xx for VDEV: 1
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.9.0.1-01977-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/mac.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath11k/mac.c +1 -0
@@ -6213,6 +6213,7 @@ static int ath11k_mac_op_start(struct ieee80211_hw *hw) ar->num_started_vdevs =0 ; ar->num_created_vdevs =0 ; ar->num_peers =0 ; + ar->num_stations =0 ; ar->allocated_vdev_map =0 ;/* Configure monitor status ring with default rx_filter to get rx status
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 196/1674 rtc: dev: zero-initialize struct rtc_wkalrm to prevent information leak
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Dalin <[email protected]>
[ Upstream commit 0ee5c5d804d592a8328a425b9274487d393d3a05 ]
The struct rtc_wkalrm has padding holes after the 'pending' member. When returned to userspace via the RTC_WKALRM_RD ioctl, uninitialized kernel stack data residing in these holes may be leaked.
Zero-initialize the struct at declaration to eliminate this information leak risk.
Fixes smatch warnings:
- drivers/rtc/dev.c:392 rtc_dev_ioctl() warn: check that 'alarm' doesn't leak information (struct has a hole after 'pending')
--- drivers/rtc/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/dev.c +1 -1
@@ -207,7 +207,7 @@ static long rtc_dev_ioctl(struct file *file,struct rtc_device *rtc = file->private_data;const struct rtc_class_ops *ops = rtc->ops;struct rtc_time tm; -struct rtc_wkalrm alarm; +struct rtc_wkalrm alarm = {0 };struct rtc_param param;void __user *uarg = (void __user *)arg;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 197/1674 rtc: mpfs: fix unchecked devm_clk_get() error pointer in probe()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manush Prajwal <[email protected]>
[ Upstream commit ac41b05d15db3134e839148290d67415ee0bdb58 ]
devm_clk_get(&pdev->dev, "rtcref")'s return value was passed straight into clk_get_rate() without checking it for an error first, unlike the "rtc" clock a few lines above which is correctly checked with IS_ERR(). clk_get_rate() only guards against a NULL clk, not an error pointer:
if (!clk) return 0; ... rate = clk_core_get_rate_recalc(clk->core);
so if devm_clk_get() ever returns an error pointer here (for example ERR_PTR(-EPROBE_DEFER), which is the normal, expected outcome if the clkcfg clock-provider this RTC depends on has not registered its clocks yet by the time this driver probes), clk_get_rate() dereferences that error pointer instead of returning 0, crashing instead of letting probe defer.
Capture the clock in the existing 'clk' local and check it with IS_ERR() before calling clk_get_rate(), matching the handling already used for the "rtc" clock in this same function.
--- drivers/rtc/rtc-mpfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/rtc/rtc-mpfs.c +5 -1
@@ -256,8 +256,12 @@ static int mpfs_rtc_probe(struct platform_device *pdev)return ret; } + clk =devm_clk_get (&pdev->dev,"rtcref" ); +if (IS_ERR (clk)) +return PTR_ERR (clk); +/* prescaler hardware adds 1 to reg value */ - prescaler =clk_get_rate (devm_clk_get (&pdev->dev,"rtcref" )) -1 ; + prescaler =clk_get_rate (clk) -1 ;if (prescaler >MAX_PRESCALER_COUNT ) {dev_dbg (&pdev->dev,"invalid prescaler %lu\n" , prescaler);return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 198/1674 wifi: cfg80211: preserve hidden-group beacon IE ownership
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
[ Upstream commit cc45f313d85533d647ce619326302aad6f797c14 ]
A hidden-group probe-response entry borrows its beacon IEs from the group's beacon entry. cfg80211_update_assoc_bss_entry() can pass such an entry to cfg80211_update_known_bss() when merging scan entries after a channel switch.
Copying the borrowed beacon_ies into the associated entry gives the same allocation two owners. Releasing the group's beacon entry can then leave the associated entry pointing to freed IEs, which are freed again when that entry is released.
Skip beacon IE replacement when the source entry belongs to a hidden group. Preserve probe-response processing, the subsequent metadata updates, and the existing rejection path for conflicting hidden beacon updates.
--- net/wireless/scan.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
net/wireless/scan.c +12 -10
@@ -1812,20 +1812,22 @@ cfg80211_update_known_bss(struct cfg80211_registered_device *rdev,return false; } - old =rcu_access_pointer (known->pub.beacon_ies); +if (!new->pub.hidden_beacon_bss) { + old =rcu_access_pointer (known->pub.beacon_ies); -rcu_assign_pointer (known->pub.beacon_ies, new->pub.beacon_ies); +rcu_assign_pointer (known->pub.beacon_ies, new->pub.beacon_ies); -/* Override IEs if they were from a beacon before */ -if (old ==rcu_access_pointer (known->pub.ies)) -rcu_assign_pointer (known->pub.ies, new->pub.beacon_ies); +/* Override IEs if they were from a beacon before */ +if (old ==rcu_access_pointer (known->pub.ies)) +rcu_assign_pointer (known->pub.ies, new->pub.beacon_ies); -cfg80211_update_hidden_bsses (known, -rcu_access_pointer (new->pub.beacon_ies), - old); +cfg80211_update_hidden_bsses (known, +rcu_access_pointer (new->pub.beacon_ies), + old); -if (old) -kfree_rcu ((struct cfg80211_bss_ies *)old, rcu_head); +if (old) +kfree_rcu ((struct cfg80211_bss_ies *)old, rcu_head); + } } known->pub.beacon_interval = new->pub.beacon_interval;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 199/1674 wifi: mac80211: Add multicast to unicast support for 802.3 path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tamizh Chelvam Raja <[email protected]>
[ Upstream commit 2307b36ce34fd2166509ea2aeef0de5768ed03b7 ]
mac80211 already supports multicast-to-unicast conversion for native 802.11 TX paths, but this handling is missing for the 802.3 transmit path. Due to that the packet never converted to unicast and directly pass it to 802.11 Tx path by checking the destination address as multicast.
Extend ieee80211_subif_start_xmit_8023() to honor the multicast_to_unicast setting by cloning and converting multicast Ethernet frames into per-station unicast transmissions, following the same behavior of the native 802.11 TX path and allow it to take 802.3 path.
Stable-dep-of: 7f93ca31f7fd ("wifi: mac80211: prevent AP VLAN tx from other interfaces")
--- net/mac80211/tx.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
net/mac80211/tx.c +26 -7
@@ -4701,19 +4701,14 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,kfree_skb (skb); } -netdev_tx_t ieee80211_subif_start_xmit_8023 (struct sk_buff *skb, -struct net_device *dev) +static void __ieee80211_subif_start_xmit_8023 (struct sk_buff *skb, +struct net_device *dev) {struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev);struct ethhdr *ehdr = (struct ethhdr *)skb->data;struct ieee80211_key *key;struct sta_info *sta; -if (unlikely (!ieee80211_sdata_running (sdata) || skb->len <ETH_HLEN )) { -kfree_skb (skb); -return NETDEV_TX_OK ; - } -rcu_read_lock ();if (ieee80211_lookup_ra_sta (sdata, skb, &sta)) {
@@ -4742,6 +4737,30 @@ netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb,ieee80211_subif_start_xmit (skb, dev); out:rcu_read_unlock (); +} + +netdev_tx_t ieee80211_subif_start_xmit_8023 (struct sk_buff *skb, +struct net_device *dev) +{ +struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev); +struct ethhdr *ehdr = (struct ethhdr *)skb->data; + +if (unlikely (!ieee80211_sdata_running (sdata) || skb->len <ETH_HLEN )) { +kfree_skb (skb); +return NETDEV_TX_OK ; + } + +if (unlikely (is_multicast_ether_addr (ehdr->h_dest) && +ieee80211_multicast_to_unicast (skb, dev))) { +struct sk_buff_head queue; + +__skb_queue_head_init (&queue); +ieee80211_convert_to_unicast (skb, dev, &queue); +while ((skb =__skb_dequeue (&queue))) +__ieee80211_subif_start_xmit_8023 (skb, dev); + }else { +__ieee80211_subif_start_xmit_8023 (skb, dev); + }return NETDEV_TX_OK ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 200/1674 wifi: mac80211: Add 802.3 multicast encapsulation offload support
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tamizh Chelvam Raja <[email protected]>
[ Upstream commit 4cc0cc0b297c17c2b106d6892bd13d9c32fe66ce ]
mac80211 converts 802.3 multicast packets to 802.11 format before driver TX, even when Ethernet encapsulation offload is enabled. This prevents drivers that support multicast Ethernet encapsulation offload from receiving frames in native 802.3 format.
Introduce the IEEE80211_OFFLOAD_ENCAP_MCAST flag to bypass the 802.11 encapsulation step and pass the multicast packet to the driver in 802.3 format. Drivers that support multicast Ethernet encapsulation offload can advertise this flag.
Disable multicast encapsulation offload in MLO case for drivers not advertising MLO_MCAST_MULTI_LINK_TX support for AP mode and for 3-address AP_VLAN multicast packets.
Stable-dep-of: 7f93ca31f7fd ("wifi: mac80211: prevent AP VLAN tx from other interfaces")
--- include/net/mac80211.h | 4 ++++ net/mac80211/tx.c | 51 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 7 deletions(-)
include/net/mac80211.h +4 -0
@@ -1786,12 +1786,16 @@ enum ieee80211_vif_flags {* @IEEE80211_OFFLOAD_DECAP_ENABLED: rx encapsulation offload is enabled * The driver supports passing received 802.11 frames as 802.3 frames to * mac80211. +* @IEEE80211_OFFLOAD_ENCAP_MCAST: tx multicast encapsulation offload is enabled +* The driver supports sending multicast frames passed as 802.3 frames +* by mac80211. */ enum ieee80211_offload_flags {IEEE80211_OFFLOAD_ENCAP_ENABLED =BIT (0 ),IEEE80211_OFFLOAD_ENCAP_4ADDR =BIT (1 ),IEEE80211_OFFLOAD_DECAP_ENABLED =BIT (2 ), +IEEE80211_OFFLOAD_ENCAP_MCAST =BIT (3 ), };/**
net/mac80211/tx.c +44 -7
69 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 201/1674 wifi: mac80211: prevent AP VLAN tx from other interfaces
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit 7f93ca31f7fd9b42e7d692f59514436d448ac908 ]
Since the station lookup was factored out of ieee80211_build_hdr(), ieee80211_lookup_ra_sta() uses sta_info_get_bss() for all AP and AP VLAN frames, not only for control port frames. A unicast frame sent on one interface thus matches a station of a different VLAN of the same BSS and is transmitted to it.
Only match stations of the interface the frame is sent on, except for control port frames, since those may be sent for VLAN stations directly on the BSS interface.
--- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/tx.c | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-)
net/mac80211/ieee80211_i.h +1 -1
@@ -2270,7 +2270,7 @@ void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,/* sta_out needs to be checked for ERR_PTR() before using */ int ieee80211_lookup_ra_sta (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb, -struct sta_info **sta_out); +struct sta_info **sta_out,bool bss); static inline void ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
net/mac80211/tx.c +15 -9
@@ -2467,7 +2467,7 @@ static inline bool ieee80211_is_tdls_setup(struct sk_buff *skb)int ieee80211_lookup_ra_sta (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb, -struct sta_info **sta_out) +struct sta_info **sta_out,bool bss) {struct sta_info *sta;
@@ -2488,7 +2488,10 @@ int ieee80211_lookup_ra_sta(struct ieee80211_sub_if_data *sdata, *sta_out =ERR_PTR (-ENOENT );return 0 ; } - sta =sta_info_get_bss (sdata, skb->data); +if (bss) + sta =sta_info_get_bss (sdata, skb->data); +else + sta =sta_info_get (sdata, skb->data);break ;#ifdef CONFIG_MAC80211_MESH case NL80211_IFTYPE_MESH_POINT :
@@ -4308,7 +4311,8 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb, ieee80211_mesh_xmit_fast(sdata, skb, ctrl_flags)) goto out; -if (ieee80211_lookup_ra_sta (sdata, skb, &sta)) +if (ieee80211_lookup_ra_sta (sdata, skb, &sta, + skb->protocol == sdata->control_port_protocol)) goto out_free;if (IS_ERR (sta))
@@ -4732,7 +4736,10 @@ static void __ieee80211_subif_start_xmit_8023(struct sk_buff *skb,rcu_read_lock (); -if (ieee80211_lookup_ra_sta (sdata, skb, &sta)) { +if (unlikely (sdata->control_port_protocol == ehdr->h_proto)) + goto skip_offload; + +if (ieee80211_lookup_ra_sta (sdata, skb, &sta, false)) {kfree_skb (skb); goto out; }
@@ -4753,8 +4760,7 @@ static void __ieee80211_subif_start_xmit_8023(struct sk_buff *skb, link = &sdata->deflink; key =rcu_dereference (link->default_multicast_key); }else if (unlikely (IS_ERR_OR_NULL (sta) || !sta->uploaded || - !test_sta_flag (sta,WLAN_STA_AUTHORIZED ) || - sdata->control_port_protocol == ehdr->h_proto)) { + !test_sta_flag (sta,WLAN_STA_AUTHORIZED ))) { goto skip_offload; }else { key =rcu_dereference (sta->ptk[sta->ptk_idx]);
@@ -4815,7 +4821,7 @@ ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,rcu_read_lock (); -if (ieee80211_lookup_ra_sta (sdata, skb, &sta)) { +if (ieee80211_lookup_ra_sta (sdata, skb, &sta, false)) {kfree_skb (skb); skb =ERR_PTR (-EINVAL ); goto out;
@@ -4886,7 +4892,7 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local, } result =ieee80211_tx (sdata,NULL , skb, true); }else if (info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) { -if (ieee80211_lookup_ra_sta (sdata, skb, &sta)) { +if (ieee80211_lookup_ra_sta (sdata, skb, &sta, true)) {dev_kfree_skb (skb);return true; }
@@ -6274,7 +6280,7 @@ int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,* AF_PACKET */ rcu_read_lock (); - err =ieee80211_lookup_ra_sta (sdata, skb, &sta); + err =ieee80211_lookup_ra_sta (sdata, skb, &sta, true);if (err) {dev_kfree_skb (skb);rcu_read_unlock ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 202/1674 ASoC: codecs: rt286: Revert delay value for jack setup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cezary Rojewski <[email protected]>
[ Upstream commit d30fba93ebfc11e4604a7fcc73fdf28684191dde ]
Fat fingered the change when reorganizing the jack-detect initialization. Equivalent changes for rt274 and rt298:
Commit a43b4394bb35 ("ASoC: codecs: rt274: Always init jack_detect_work") Commit 1eb73102da28 ("ASoC: codecs: rt298: Reorganize jack detect handling")
carry no update to the delay value.
Quoted 1 line
From user perspective, no difference has been observed between 1250 and
50 values on Intel's SkyLake, KabyLake and AmberLake configurations.
--- sound/soc/codecs/rt286.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/rt286.c +1 -1
@@ -951,7 +951,7 @@ static int rt286_probe(struct snd_soc_component *component)if (rt286->i2c->irq)schedule_delayed_work (&rt286->jack_detect_work, -msecs_to_jiffies (50 )); +msecs_to_jiffies (1250 ));return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 203/1674 ASoC: codecs: rt274: Fix format setting for 44100 rate
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cezary Rojewski <[email protected]>
[ Upstream commit 6eda8938a790f65bd24fcfaae7b40ad4613fb7a2 ]
As per specification, Sample Base Rate (bit 14) shall be set to 1 for 44.1 kHz.
--- sound/soc/codecs/rt274.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/rt274.c +3 -1
@@ -619,9 +619,11 @@ static int rt274_hw_params(struct snd_pcm_substream *substream,unsigned int val =0 ;int d_len_code =0 , c_len_code =0 ; +/* bit 14 Sample Rate Base, 0: 48kHz 1: 44.1kHz */ switch (params_rate (params)) { -/* bit 14 0:48K 1:44.1K */ case 44100 : + val |=BIT (14 ); +break ;case 48000 :break ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 204/1674 Bluetooth: hci_core: free the HCI ID if naming fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Hoon Choi <[email protected]>
[ Upstream commit d1ac915fb4184faad1b62148be50f317de7c24b5 ]
hci_register_dev() allocates an ID before calling dev_set_name(). If naming fails, it returns without releasing that ID. The device has not been registered and hdev->id has not been assigned, so the normal unregister path cannot release it.
Free the allocated ID before returning the naming error.
--- net/bluetooth/hci_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/bluetooth/hci_core.c +3 -1
@@ -2587,8 +2587,10 @@ int hci_register_dev(struct hci_dev *hdev)return id; error =dev_set_name (&hdev->dev,"hci%u" , id); -if (error) +if (error) { +ida_free (&hci_index_ida, id);return error; + } hdev->name =dev_name (&hdev->dev); hdev->id = id;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 205/1674 Bluetooth: btintel: validate DDC record lengths
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sai Teja Aluvala <[email protected]>
[ Upstream commit c9c15d4d8956df8c564f7c210e4dc5b9b820d97a ]
Parse DDC record lengths in unsigned storage so 0xFF does not wrap. Reject records smaller than the mandatory three-byte header, records exceeding U8_MAX, and records exceeding remaining firmware bytes before issuing Intel_Write_DDC.
This issue was reported by Claude Mythos.
--- drivers/bluetooth/btintel.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/bluetooth/btintel.c +10 -2
@@ -384,8 +384,16 @@ int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name)/* DDC file contains one or more DDC structure which has * Length (1 byte), DDC ID (2 bytes), and DDC value (Length - 2). */ -while (fw->size > fw_ptr - fw->data) { -u8 cmd_plen = fw_ptr[0 ] +sizeof (u8); +while (fw->size > (size_t )(fw_ptr - fw->data)) { +size_t remaining = fw->size - (fw_ptr - fw->data); +unsigned int cmd_plen = fw_ptr[0 ] +1U ; + +if (cmd_plen <3 || cmd_plen >U8_MAX || cmd_plen > remaining) { +bt_dev_err (hdev,"Malformed DDC record (plen=%u, remaining=%zu)" , + cmd_plen, remaining); +release_firmware (fw); +return -EINVAL ; + } skb =__hci_cmd_sync (hdev,0xfc8b , cmd_plen, fw_ptr,HCI_INIT_TIMEOUT );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 206/1674 net/mctp: publish the mctp_dev only after it is initialised
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Deng <[email protected]>
[ Upstream commit aadf655e8ea9a8ffa24bb8d69f504572e8d18181 ]
mctp_add_dev() links the new mctp_dev into dev->mctp_ptr before mdev->dev is assigned, so a reader that picks the device up in that window dereferences a net_device pointer that is still NULL:
KASAN: null-ptr-deref in range [0x00000000000000b0-0x00000000000000b7] Call Trace: <TASK> ? __pfx_mctp_sendmsg (./include/linux/sockptr.h:49) ? __pfx_mctp_dst_output (net/mctp/route.c:41) ? selinux_socket_sendmsg (security/selinux/hooks.c:5278) ____sys_sendmsg (net/socket.c:775 (discriminator 1) net/socket.c:790 (discriminator 1) net/socket.c:2684 (discriminator 1)) ? __pfx_____sys_sendmsg (net/socket.c:1131) ? __pfx_copy_msghdr_from_user (net/socket.c:2590) ? update_cfs_rq_load_avg (kernel/sched/fair.c:5478) ___sys_sendmsg (net/socket.c:2738) ? __pfx____sys_sendmsg (net/socket.c:2625) ? perf_event_task_tick (./include/linux/rcupdate.h:838) ? sched_tick (kernel/sched/core.c:5818) ? clockevents_program_event (kernel/time/clockevents.c:372) ? fdget (./include/linux/rcupdate.h:873 fs/file.c:1100) __sys_sendmsg (net/socket.c:2770) ? __pfx___sys_sendmsg (net/socket.c:2751) do_syscall_64 (arch/x86/entry/syscall_64.c:63) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) </TASK>
Fix by publishing only once the object is fully initialised:__mctp_dev_get() runs under rcu_read_lock() only and hands this object to readers as soon as mctp_ptr is assigned, so they must never observe mdev->dev == NULL.
--- net/mctp/device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/mctp/device.c +3 -3
@@ -344,13 +344,13 @@ static struct mctp_dev *mctp_add_dev(struct net_device *dev) mdev->net =mctp_default_net (dev_net (dev)); -/* associate to net_device */ refcount_set (&mdev->refs,1 ); -rcu_assign_pointer (dev->mctp_ptr, mdev); -dev_hold (dev); mdev->dev = dev; +/* Associate to net_device, publish the mdev. */ +rcu_assign_pointer (dev->mctp_ptr, mdev); +return mdev; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 207/1674 net/sched: cls_api: reclaim an empty proto on the error path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 0bb8eab29b55045281a4963d4557f2776cdf8cfa ]
Two racing tc filter add requests on the same chain/prio of an unlocked classifier both run change() on the shared proto and both can fail: the winner's tcf_chain_tp_delete_empty() attempt gives up because the loser's handle is still in the idr, and the loser's error path drops only its own reference without a second reclamation attempt. The empty proto stays linked in the chain, holding the chain reference, a block reference and the classifier module reference until the chain or block is torn down.
Reclaim the proto on the error path of any failed request that holds a proto reference. The reclamation is emptiness-gated:tcf_chain_tp_delete_empty() unlinks the proto only when delete_empty() admits it is empty, so a live shared proto is never unlinked. A proto the request created is reclaimed unconditionally - it is the only owner, so marking it for deletion is safe even without a delete_empty callback. Classifiers without one (the check marks the proto unconditionally) are rtnl-serialized, so the raced window this guard closes cannot arise for them.
This is a follow-up to commit d4e359b3608a ("net/sched: cls_api: fix teardown of an adopted proto on insert-race loss"), which stopped the loser of the insert race from unlinking the winner's live proto but left the empty-proto residual in place.
Conditions to recreate:
- CONFIG_NET_CLS_FLOWER=y; veth pair
- tc qdisc add dev veth0 ingress
- two concurrent tc filter add dev veth0 ingress protocol ip pref 1 flower skip_sw ... action drop (both fail in fl_hw_replace_filter after publishing their handle in the idr); repeat in a loop
- an empty flower tp stays linked after both requests fail; visible as a bare filter protocol ip pref 1 flower chain 0 header in tc filter show with no filter entries
- CAP_NET_ADMIN (namespace-local via unshare -Urn suffices)
--- net/sched/cls_api.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
net/sched/cls_api.c +14 -1
@@ -2436,7 +2436,20 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, } errout: -if (err && tp_state ==TP_CREATED ) +if (err && !IS_ERR_OR_NULL (tp) && + (tp_state ==TP_CREATED || tp->ops->delete_empty)) +/* +* The request is dropping its reference to tp. If it was +* the last user (the idr is empty now), reclaim the proto. +* A tp this request created is reclaimed unconditionally: +* it is the only owner, so marking it for deletion is +* safe. Otherwise only classifiers with a delete_empty +* callback are reclaimed -- the callback admits an empty +* proto only, so a live shared proto is never unlinked. +* Classifiers without one (deleting is set +* unconditionally) are rtnl-serialized, so the raced +* window this guard closes cannot arise for them. +*/ tcf_chain_tp_delete_empty (chain, tp, rtnl_held,NULL ); errout_tp:if (chain) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 208/1674 ipv6: fix prefix route expiry in modify_prefix_route()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qishuai Liu <[email protected]>
[ Upstream commit a7bfaba4823e3c165bb2004c74eff7c096672bc7 ]
modify_prefix_route() is given the lifetime in clock_t relative to now, but fib6_set_expires() wants an absolute jiffies value. So when a permanent address is changed to a finite valid_lft, the prefix route ends up already expired and GC removes it.
Steps to reproduce:
ip link add dummy9 type dummy
ip link set dummy9 up
ip -6 addr add 2001:db8:9::1/64 dev dummy9
ip -6 addr change 2001:db8:9::1/64 dev dummy9 valid_lft 3600 preferred_lft 3600
ip -6 route show dev dummy9 # expires is negative
--- net/ipv6/addrconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/addrconf.c +1 -1
@@ -4837,7 +4837,7 @@ static int modify_prefix_route(struct net *net, struct inet6_ifaddr *ifp,fib6_clean_expires (f6i);fib6_may_remove_gc_list (net, f6i); }else { -fib6_set_expires (f6i, expires); +fib6_set_expires (f6i, jiffies +clock_t_to_jiffies (expires));fib6_add_gc_list (f6i); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 209/1674 netfilter: ipset: do not update comments from kernel-side adds
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit a442c8a89fb9c531f9d6ab86120c31decd778d51 ]
'Fixes' commit stopped calling ip_set_init_comment() for hash types from kernel-side-adds (xtables .. -j SET). ip_set_init_comment() says:
"The kadt functions don't use the comment extensions in any way."
But bitmap set type calls the function from kadt cb too.
While this appears to be safe (serialized via the set spinlock), it seems better to not call the init function either, least of all to keep behaviour consistent.
ip_set_list calls ip_set_init_comment() only from uadt cb, it can be kept as-is.
This was triggered by yet another LLM review, hinting that the existing rcu_dereference_protected() cannot be downgraded to only check if the nfnl mutex is held.
--- net/netfilter/ipset/ip_set_bitmap_gen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipset/ip_set_bitmap_gen.h +1 -1
@@ -157,7 +157,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,if (SET_WITH_COUNTER (set))ip_set_init_counter (ext_counter (x, set), ext); -if (SET_WITH_COMMENT (set)) +if (SET_WITH_COMMENT (set) && !ext->target)ip_set_init_comment (set,ext_comment (x, set), ext);if (SET_WITH_SKBINFO (set))ip_set_init_skbinfo (ext_skbinfo (x, set), ext);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 210/1674 Bluetooth: hci_sync: dont drain cmd_sync backlog on unregister
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
[ Upstream commit b1f24c1ab52345e810c42a1a81286cb5a7c92252 ]
hci_unregister_dev() disables cmd_work and cmd_timer, then calls hci_cmd_sync_clear(), whose cancel_work_sync() waits for hci_cmd_sync_work() to return. That worker dequeues and runs every entry on cmd_sync_work_list. With cmd_work disabled nothing reaches the controller, so each queued HCI command waits the full HCI_CMD_TIMEOUT (2s).
The backlog has no bound. Userspace can keep queuing MGMT commands such as MGMT_OP_GET_CLOCK_INFO against a controller that doesn't answer. Closing /dev/vhci then blocks in vhci_release() for backlog * 2s:
INFO: task syz-executor:5749 blocked for more than 143 seconds. cancel_work_sync hci_cmd_sync_clear hci_unregister_dev vhci_release
In a local reproduction the backlog held more than 5000 entries, which comes to hours of hang.
Stop the worker from taking new entries once HCI_UNREGISTER is set, and wake any request still waiting with -ENODEV before cancelling the work. The entries left over are destroyed with -ECANCELED by the existing sweep in hci_cmd_sync_clear(). They stay on the list until the work has stopped, so hci_cmd_sync_dequeue() and friends still see them. A callback already running may still issue another command, which delays unregister by at most one timeout per remaining command, not by the whole backlog.
--- net/bluetooth/hci_sync.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/bluetooth/hci_sync.c +6 -0
@@ -313,6 +313,10 @@ static void hci_cmd_sync_work(struct work_struct *work)while (1 ) {struct hci_cmd_sync_work_entry *entry; +/* Leave the backlog to hci_cmd_sync_clear() */ +if (hci_dev_test_flag (hdev,HCI_UNREGISTER )) +break ; +mutex_lock (&hdev->cmd_sync_work_lock); entry = list_first_entry_or_null(&hdev->cmd_sync_work_list, struct hci_cmd_sync_work_entry,
@@ -682,6 +686,8 @@ void hci_cmd_sync_clear(struct hci_dev *hdev) {struct hci_cmd_sync_work_entry *entry, *tmp; +/* cmd_work is disabled, the pending request can only time out */ +hci_cmd_sync_cancel_sync (hdev,ENODEV );cancel_work_sync (&hdev->cmd_sync_work);cancel_work_sync (&hdev->reenable_adv_work);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 211/1674 net: systemport: Fix buffer overflow in bcm_sysport_get_stats()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit eb7b84af0ec5c71b4920e999611b466b3784496c ]
When running on SYSTEMPORT Lite, certain statistics are unsupported and skipped during bcm_sysport_get_stats(). The variable 'j' tracks the compacted index into the destination data buffer, whereas 'i' iterates over all elements in bcm_sysport_gstrings_stats.
Because the buffer allocated by ethtool is sized only according to bcm_sysport_get_sset_count(), storing values at data[i] instead of data[j] writes past the allocated array bounds, leading to memory corruption.
Fix this by writing to data[j] instead of data[i].
--- drivers/net/ethernet/broadcom/bcmsysport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +2 -2
@@ -516,10 +516,10 @@ static void bcm_sysport_get_stats(struct net_device *dev, s->type == BCM_SYSPORT_STAT_NETDEV64) {do { start =u64_stats_fetch_begin (syncp); - data[i] = *(u64 *)p; + data[j] = *(u64 *)p; }while (u64_stats_fetch_retry (syncp, start)); } else - data[i] = *(u32 *)p; + data[j] = *(u32 *)p; j++; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 212/1674 net: systemport: Fix RUNT MIB counter register offset calculation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 242935adfeb096f09b29fb2cfcf12f9eb2911fc6 ]
In UniMAC hardware, there is a 0xC byte gap between the RX MIB counters and the TX MIB counters, and a second 0xC byte gap between the TX MIB counters and the RX RUNT MIB counters.
In bcm_sysport_update_mib_counters(), 'offset' was only set to UMAC_MIB_STAT_OFFSET (0xC) for all non-RX counters, omitting the second 0xC gap for BCM_SYSPORT_STAT_RUNT counters. As a result, all 4 RUNT MIB counters were read from unmapped gap register space.
Fix this by setting offset to 2 * UMAC_MIB_STAT_OFFSET (0x18) when reading BCM_SYSPORT_STAT_RUNT counters.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bcmsysport.c +3 -1
@@ -425,8 +425,10 @@ static void bcm_sysport_update_mib_counters(struct bcm_sysport_priv *priv)if (priv->is_lite)continue ; -if (s->type !=BCM_SYSPORT_STAT_MIB_RX ) +if (s->type ==BCM_SYSPORT_STAT_MIB_TX ) offset =UMAC_MIB_STAT_OFFSET ; +else if (s->type ==BCM_SYSPORT_STAT_RUNT ) + offset =2 *UMAC_MIB_STAT_OFFSET ; val =umac_readl (priv,UMAC_MIB_START + j + offset);break ;case BCM_SYSPORT_STAT_RXCHK :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 213/1674 octeontx2-af: mcs: Fix SC resource cleanup loop
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baha Mesleh <[email protected]>
[ Upstream commit cdef07f3002f708a345392ee28d0d9bfac8383a1 ]
The SC resource cleanup and statistics loops were incorrectly iterating over secy.max instead of sc.max, so the highest SC id could be left allocated across teardown or FLR. Use sc.max as the loop bound.
--- drivers/net/ethernet/marvell/octeontx2/af/mcs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mcs.c +2 -2
@@ -314,7 +314,7 @@ int mcs_clear_all_stats(struct mcs *mcs, u16 pcifunc, int dir) }/* Clear SC stats */ -for (id =0 ; id < map->secy.max; id++) { +for (id =0 ; id < map->sc.max; id++) {if (map->sc2pf_map[id] != pcifunc)continue ;mcs_clear_stats (mcs,MCS_SC_STATS , id, dir);
@@ -738,7 +738,7 @@ int mcs_free_all_rsrc(struct mcs *mcs, int dir, u16 pcifunc) }/* free sc entries */ -for (id =0 ; id < map->secy.max; id++) { +for (id =0 ; id < map->sc.max; id++) {if (map->sc2pf_map[id] != pcifunc)continue ;mcs_free_rsrc (&map->sc, map->sc2pf_map, id, pcifunc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 214/1674 tipc: prevent GCM nonce reuse on peer key changes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 512ccd3d0e91e791fb37442aa0a2599aca19783d ]
TIPC can encrypt traffic between nodes using a different transmit key for each node. In this mode, the AES-GCM nonce for a packet sent to a known peer consists of a 32-bit prefix (a per-key salt XOR the peer's address) followed by a 64-bit counter. That counter is stored in the peer's RX crypto object. When the peer reports a change in which key it uses to receive packets, TIPC resets this counter. The sender can still be using the same TX key and salt, so subsequent packets reuse earlier nonces. This nonce reuse breaks confidentiality and exposes GCM's authentication key. This makes forgeries trivial: an attacker can exploit CTR malleability to alter captured ciphertexts and use the recovered authentication key to compute a valid tag for the modified ciphertext, under the same key and nonce.
Use the TX key's existing aead->seqno counter instead. All encryptions using that key object share the same atomic counter, so concurrent encryptions get distinct nonce counter values. The counter survives key activation and peer reconnection, and peer key-status reports cannot reset it. This prevents those transitions from causing nonce reuse while the same TX key remains installed.
The nonce format is unchanged, and receivers do not require consecutive counter values, so sharing the counter across peers remains compatible with existing receivers. A pre-existing check still invokes key revocation in the unlikely event that the counter wraps to zero.
--- net/tipc/crypto.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
net/tipc/crypto.c +5 -15
@@ -144,7 +144,7 @@ struct tipc_tfm {* @rcu: struct rcu_head * @key: the aead key * @gen: the key's generation -* @seqno: the key seqno (cluster scope) +* @seqno: the per-key TX nonce counter * @refcnt: the key reference counter */ struct tipc_aead {
@@ -190,7 +190,6 @@ struct tipc_crypto_stats {* @rekeying_intv: rekeying interval (in minutes) * @stats: the crypto statistics * @name: the crypto name -* @sndnxt: the per-peer sndnxt (TX) * @timer1: general timer 1 (jiffies) * @timer2: general timer 2 (jiffies) * @working: the crypto is working or not
@@ -219,7 +218,6 @@ struct tipc_crypto {struct tipc_crypto_stats __percpu *stats;char name[48 ]; -atomic64_t sndnxt____cacheline_aligned ;unsigned long timer1;unsigned long timer2;union {
@@ -1060,14 +1058,11 @@ static int tipc_ehdr_build(struct net *net, struct tipc_aead *aead,WARN_ON (skb_headroom (skb) < ehsz); ehdr = (struct tipc_ehdr *)skb_push (skb, ehsz); -/* Obtain a seqno first: -* Use the key seqno (= cluster wise) if dest is unknown or we're in -* cluster key mode, otherwise it's better for a per-peer seqno! +/* +* Keep the nonce unique for the lifetime of the TX key, +* including key state changes and peer reconnection. */ -if (!__rx || aead->mode ==CLUSTER_KEY ) - seqno =atomic64_inc_return (&aead->seqno); -else - seqno =atomic64_inc_return (&__rx->sndnxt); + seqno =atomic64_inc_return (&aead->seqno);/* Revoke the key if seqno is wrapped around */ if (unlikely (!seqno))
@@ -1246,7 +1241,6 @@ void tipc_crypto_key_flush(struct tipc_crypto *c)tipc_crypto_key_set_state (c,0 ,0 ,0 );for (k =KEY_MIN ; k <=KEY_MAX ; k++)tipc_crypto_key_detach (c->aead[k], &c->lock); -atomic64_set (&c->sndnxt,0 );spin_unlock_bh (&c->lock); }
@@ -1393,8 +1387,6 @@ static struct tipc_aead *tipc_crypto_key_pick_tx(struct tipc_crypto *tx,* It also considers if peer has no key, then we need to make own master key * (if any) taking over i.e. starting grace period and also trigger key * distributing process. -* -* The "per-peer" sndnxt is also reset when the peer key has switched. */ static void tipc_crypto_key_synch (struct tipc_crypto *rx,struct sk_buff *skb) {
@@ -1445,7 +1437,6 @@ static void tipc_crypto_key_synch(struct tipc_crypto *rx, struct sk_buff *skb)if (cur)tipc_aead_users_dec (tx->aead[cur],0 ); -atomic64_set (&rx->sndnxt,0 );/* Mark the point TX key users changed */ tx->timer1 = jiffies;
@@ -1510,7 +1501,6 @@ int tipc_crypto_start(struct tipc_crypto **crypto, struct net *net,tipc_crypto_key_set_state (c,0 ,0 ,0 );atomic_set (&c->key_distr,0 );atomic_set (&c->peer_rx_active,0 ); -atomic64_set (&c->sndnxt,0 ); c->timer1 = jiffies; c->timer2 = jiffies; c->rekeying_intv =TIPC_REKEYING_INTV_DEF ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 215/1674 net/sched: fq_codel: match the no-drop threshold to the packet size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit d031465acc362866f27e4f8f79cfecf1037fe2e5 ]
commit d9ebd8f9aa8b ("net/sched: fq_codel: clamp default quantum and mtu") clamped both q->quantum and q->cparams.mtu to [256, FQ_CODEL_QUANTUM_MAX]. The two fields mean different things: quantum is a DRR credit that wants the 256 floor, but cparams.mtu is the CoDel no-drop threshold (codel_impl.h "*backlog <= params->mtu"). On a link whose maximum transmitted packet size is below 256, the floor extends CoDel's minimum-backlog exemption beyond one packet and delays drop or mark eligibility by several small packets.
Split the clamp. quantum keeps [256, FQ_CODEL_QUANTUM_MAX]; cparams.mtu tracks psched_mtu() (the device MTU plus its hard-header length) with only the upper bound that guards the original overflow (psched_mtu() wrapping to ~2 GiB on a huge-MTU device).
Conditions to recreate the bug: attach an fq_codel qdisc on a link whose MTU plus hard_header_len is below 256 (e.g. a CAN interface). At that MTU the no-drop threshold must equal the device MTU plus its hard-header length; before this patch it was forced to 256. Basic Testing done: with dev->mtu=100 and hard_header_len=14, a return probe on fq_codel_init() observed cparams.mtu change from 256 to 114
--- net/sched/sch_fq_codel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/sch_fq_codel.c +2 -2
@@ -503,8 +503,8 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, q->flows_cnt =1024 ; q->memory_limit =32 <<20 ;/* 32 MBytes */ q->drop_batch_size =64 ; - mtu =clamp_t (u32,psched_mtu (qdisc_dev (sch)),256 ,FQ_CODEL_QUANTUM_MAX ); - q->quantum = mtu; + mtu =min_t (u32,psched_mtu (qdisc_dev (sch)),FQ_CODEL_QUANTUM_MAX ); + q->quantum =clamp_t (u32, mtu,256 ,FQ_CODEL_QUANTUM_MAX );INIT_LIST_HEAD (&q->new_flows);INIT_LIST_HEAD (&q->old_flows);codel_params_init (&q->cparams);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 216/1674 net/sched: sch_codel: match the no-drop threshold to the packet size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 54518e0e827f4ca9229ae657022c60bf60f5c1bf ]
commit 6439461f1618 ("net/sched: sch_codel: clamp default mtu to avoid disabling CoDel") clamped q->params.mtu to [256, 1 << 20]. The value is the CoDel no-drop threshold (codel_impl.h "*backlog <= params->mtu"), so on a link whose maximum transmitted packet size is below 256 the floor extends CoDel's minimum-backlog exemption beyond one packet and delays drop or mark eligibility by several small packets.
Keep the upper bound that guards the original overflow (psched_mtu() wrapping to ~2 GiB on a huge-MTU device) but drop the 256 floor, so the threshold tracks the real device packet size.
Conditions to recreate the bug: attach a codel qdisc on a link whose MTU plus hard_header_len is below 256 (e.g. a CAN interface). At that MTU the no-drop threshold must equal the device MTU plus its hard-header length; before this patch it was forced to 256. Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_codel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_codel.c +1 -1
@@ -228,7 +228,7 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt,codel_params_init (&q->params);codel_vars_init (&q->vars);codel_stats_init (&q->stats); - q->params.mtu =clamp_t (u32,psched_mtu (qdisc_dev (sch)),256 ,1 <<20 ); + q->params.mtu =min_t (u32,psched_mtu (qdisc_dev (sch)),1 <<20 );if (opt) {int err =codel_change (sch, opt, extack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 217/1674 net: bcmgenet: fix NULL dereference in set_coalesce before first open
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit 19419faf58dfe5bcc8a9e60e622976c5f8e3ddc1 ]
The Rx ring priv and index are only set in bcmgenet_init_rx_ring(), which runs at open. Setting the Rx coalescing parameters on an interface that was never opened, e.g. "ethtool -C eth0 rx-usecs 50", dereferences a NULL ring->priv. The oops happens with RTNL held, so networking stays stuck until a reboot:
Unable to handle kernel paging request at virtual address 0000000000002788 pc : bcmgenet_set_rx_coalesce.isra.0+0x10/0x88 lr : bcmgenet_set_coalesce+0xe8/0x180 Call trace: bcmgenet_set_rx_coalesce.isra.0+0x10/0x88 (P) __ethnl_set_coalesce.isra.0+0x490/0x570 ethnl_set_coalesce+0x48/0xc0 ethnl_default_set_doit+0xf4/0x230 genl_family_rcv_msg_doit+0xe8/0x160 genl_rcv_msg+0x220/0x2a0 netlink_rcv_skb+0x68/0x140 genl_rcv+0x40/0x60 netlink_unicast+0x338/0x3c0 netlink_sendmsg+0x19c/0x3f8 __sock_sendmsg+0x64/0xc0 __sys_sendto+0x124/0x198 __arm64_sys_sendto+0x30/0x48
Set priv and index at probe. Writing the registers while the interface is down is harmless because open resets the MAC and bcmgenet_init_rx_coalesce() reapplies the stored values.
It was observed on a Raspberry Pi CM4, but should apply to all other genet devices.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +4 -1
@@ -4084,8 +4084,11 @@ static int bcmgenet_probe(struct platform_device *pdev)netif_set_real_num_rx_queues (priv->dev, priv->hw_params->rx_queues +1 );/* Set default coalescing parameters */ -for (i =0 ; i <= priv->hw_params->rx_queues; i++) +for (i =0 ; i <= priv->hw_params->rx_queues; i++) { + priv->rx_rings[i].priv = priv; + priv->rx_rings[i].index = i; priv->rx_rings[i].rx_max_coalesced_frames =1 ; + }/* Initialize u64 stats seq counter for 32bit machines */ for (i =0 ; i <=GENET_MAX_MQ_CNT ; i++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 218/1674 net: ethernet: mtk_eth_soc: allocate dummy netdev sooner
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sandeep Haemoon <[email protected]>
[ Upstream commit 6f0c2c4f5e7143eba75153ecc8af3a03f7b6a98b ]
The RX rings and the shared NAPI are carried by an internal "dummy" netdev (eth->dummy_dev). mtk_probe() creates that dummy device, and adds the shared tx/rx NAPI to it, only after the MAC netdevs have been registered. That order has been there since the MT7623 support was added and leaves a window in which the netdevs are visible to the network core before the shared NAPI and the dummy device exist.
If anything brings the first netdev up during that window (e.g. netifd opening the WAN link the instant the interface is registered), the first-open path runs without them. On NETSYS v2 and later SoCs mtk_rx_alloc() -> __xdp_rxq_info_reg() then dereferences eth->dummy_dev == NULL:
WARNING: CPU: ... Missing net_device from driver
in net/core/xdp.c and mtk_open() fails with -ENODEV. On NETSYS v1 SoCs (MT7621/MT7622/MT7623/MT7629) there is no page pool, so the same open instead calls napi_enable() on a napi_struct that netif_napi_add() has not initialised yet and dereferences a NULL napi->dev.
Allocate the dummy netdev and add the shared tx/rx NAPI to it before the register_netdev() loop. Both the dummy-allocation failure and a register_netdev() failure now unwind through mtk_unreg_dev(), which unregisters the net_device notifiers and the netdevs registered so far, stopping a concurrently-opened netdev (ndo_stop) and its NAPI before the dummy carrier is freed.
A netdev that opened during the window can also have queued the frame-engine reset worker (via the tx watchdog or phylink), so the probe error path now cancels eth->pending_work before freeing the shared state, as mtk_cleanup() already does on remove.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 38 ++++++++++++++------- 1 file changed, 26 insertions(+), 12 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +26 -12
@@ -5031,6 +5031,22 @@ static int mtk_probe(struct platform_device *pdev) goto err_deinit_ppe; } +/* we run 2 devices on the same DMA ring so we need a dummy device +* for NAPI to work. Allocate it before registering the netdevs so a +* concurrent ndo_open (e.g. netifd bringing the first netdev up the +* instant it is registered) never observes eth->dummy_dev == NULL in +* mtk_dma_init() -> mtk_rx_alloc() -> __xdp_rxq_info_reg() (net/core/xdp.c +* "Missing net_device from driver") and fails the first open. +*/ + eth->dummy_dev =alloc_netdev_dummy (0 ); +if (!eth->dummy_dev) { + err = -ENOMEM ; +dev_err (eth->dev,"failed to allocated dummy device\n" ); + goto err_unreg_netdev; + } +netif_napi_add (eth->dummy_dev, ð->tx_napi, mtk_napi_tx); +netif_napi_add (eth->dummy_dev, ð->rx_napi, mtk_napi_rx); +for (i =0 ; i <MTK_MAX_DEVS ; i++) {if (!eth->netdev[i])continue ;
@@ -5045,18 +5061,6 @@ static int mtk_probe(struct platform_device *pdev) eth->netdev[i]->base_addr, eth->irq[0]); } -/* we run 2 devices on the same DMA ring so we need a dummy device -* for NAPI to work -*/ - eth->dummy_dev =alloc_netdev_dummy (0 ); -if (!eth->dummy_dev) { - err = -ENOMEM ; -dev_err (eth->dev,"failed to allocated dummy device\n" ); - goto err_unreg_netdev; - } -netif_napi_add (eth->dummy_dev, ð->tx_napi, mtk_napi_tx); -netif_napi_add (eth->dummy_dev, ð->rx_napi, mtk_napi_rx); -platform_set_drvdata (pdev, eth);schedule_delayed_work (ð->reset.monitor_work,MTK_DMA_MONITOR_TIMEOUT );
@@ -5066,6 +5070,16 @@ static int mtk_probe(struct platform_device *pdev) err_unreg_netdev:mtk_unreg_dev (eth); err_deinit_ppe: +/* A netdev opened while probe was still registering can have queued +* the frame-engine reset worker, which takes rtnl and drives the +* hardware; cancel it before anything below is torn down. +*/ +cancel_work_sync (ð->pending_work); +if (eth->dummy_dev) { +netif_napi_del (ð->tx_napi); +netif_napi_del (ð->rx_napi); +free_netdev (eth->dummy_dev); + }mtk_ppe_deinit (eth);mtk_mdio_cleanup (eth); err_free_dev:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 219/1674 tcp: refresh TS.Recent for accepted old ACKs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Jo <[email protected]>
[ Upstream commit 1b92780ae4fc3be64f05d97ed8833c445e73b0cf ]
A TCP packet can carry new data while acknowledging traffic in the opposite direction. With overlapping traffic in both directions, a delayed packet's acknowledgment can be older than one Linux has already accepted, even when that packet fills a gap in the received data.
Linux accepts the data, but tcp_ack() takes the old_ack path and skips updating TS.Recent, the timestamp saved for outgoing acknowledgments. The reply therefore echoes an older timestamp. If the sender uses this echo to measure round-trip time after a long idle period, its estimate includes the idle time and can reduce its sending rate.
Update TS.Recent in old_ack using tcp_replace_ts_recent(), before SACK processing can trigger a transmission. This reuses the existing timestamp and sequence checks, including PAWS protection against old duplicate packets. ACK validation already rejects old ACKs in SYN_RECV before this path, so no additional state check is needed.
Echoing the timestamp of the packet that fills the receive gap follows RFC 7323 section 4.3. In a socket reproduction with 300 seconds idle, controlled reordering and retransmission to exercise timestamp-based RTT sampling, the sender's smoothed round-trip time was 37.5 seconds without the fix and 15.5 ms with it.
--- net/ipv4/tcp_input.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ipv4/tcp_input.c +6 -0
@@ -4087,6 +4087,12 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)return 1 ; old_ack: +/* An old ACK can carry new data. Update TS.Recent before SACK +* processing can trigger a retransmission. +*/ +if (flag &FLAG_UPDATE_TS_RECENT ) +tcp_replace_ts_recent (tp,TCP_SKB_CB (skb)->seq); +/* If data was SACKed, tag it and see if we should send more data. * If data was DSACKed, see if we can undo a cwnd reduction. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 220/1674 ipvs: fix missing counter decrement in lblc
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit bdac17779f46817f60103baf09f0370546c3f023 ]
LBLC may delete cache entries for destinations that are removed or overloaded and replace them with available ones. But ip_vs_lblc_new() forgets to decrement the tbl->entries counter after calling ip_vs_lblc_del(). This can lead to increased shrinking of the cache with every new garbage collection.
--- net/netfilter/ipvs/ip_vs_lblc.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/ipvs/ip_vs_lblc.c +1 -0
@@ -205,6 +205,7 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,if (en->dest == dest)return en;ip_vs_lblc_del (en); +atomic_dec (&tbl->entries); } en =kmalloc (sizeof (*en),GFP_ATOMIC );if (!en)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 221/1674 ipvs: do not create invisible templates
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit 616cf5c06934364ab1002b420ebe975850b4b208 ]
The IP_VS_CONN_F_ONE_PACKET flag was implemented for normal connections. When conn template inherits this flag from dest->conn_flags it will not be hashed. As result, we will create new template for every new normal connection.
Fix it to allow one template to be used by many normal connections.
--- net/netfilter/ipvs/ip_vs_conn.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/ipvs/ip_vs_conn.c +3 -0
@@ -590,6 +590,9 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)if (cp->protocol !=IPPROTO_UDP ) conn_flags &= ~IP_VS_CONN_F_ONE_PACKET ; flags = cp->flags; +/* Only visible templates can control multiple connections */ +if (flags &IP_VS_CONN_F_TEMPLATE ) + conn_flags &= ~IP_VS_CONN_F_ONE_PACKET ;/* Bind with the destination and its corresponding transmitter */ if (flags &IP_VS_CONN_F_SYNC ) {/* Synced conns are hashed, so they can not get this flag */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 222/1674 ipvs: filter some flags received in the backup server
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit f96e91748f6304668fe647e686d199d7207d36f1 ]
While the IPVS SYNC protocol is not secure by design we can still protect the backup server from messages that can wreak havoc.
This commit addresses problems from received connection flags or their combinations. We now drop messages as follows:
1. the NO_CPORT+TEMPLATE combination allows lookups for normal connections to hit template which can break in many ways. While the master does not sync connections with NO_CPORT flag, i.e. before they are established, we still accept NO_CPORT without TEMPLATE.
2. ONE_PACKET: it is not sent by master, so we do not expect it in backup. Before now it was ignored by IP_VS_CONN_F_BACKUP_MASK for protocol v1 while protocol v0 created connections that are not hashed and dropped immediately. Better to apply the IP_VS_CONN_F_BACKUP_MASK also to the flags from v0 messages for consistency with v1.
--- net/netfilter/ipvs/ip_vs_sync.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +30 -3
@@ -950,6 +950,21 @@ static void ip_vs_proc_conn(struct netns_ipvs *ipvs, struct ip_vs_conn_param *paip_vs_conn_put (cp); } +/* Check for incompatible flags */ +static bool ip_vs_sync_validate_flags (u32 flags) +{ +/* We do not expect NO_CPORT, especially to allow lookups +* to hit templates +*/ +if (flags &IP_VS_CONN_F_NO_CPORT ) { +if (flags &IP_VS_CONN_F_TEMPLATE ) +return false; + } +if (flags &IP_VS_CONN_F_ONE_PACKET ) +return false; +return true; +} +/* * Process received multicast message for Version 0 */
@@ -973,8 +988,7 @@ static void ip_vs_process_message_v0(struct netns_ipvs *ipvs, const char *bufferreturn ; } s = (struct ip_vs_sync_conn_v0 *) p; - flags =ntohs (s->flags) |IP_VS_CONN_F_SYNC ; - flags &= ~IP_VS_CONN_F_HASHED ; + flags =ntohs (s->flags);if (flags &IP_VS_CONN_F_SEQ_MASK ) { opt = (struct ip_vs_sync_conn_options *)&s[1 ]; p +=FULL_CONN_SIZE ;
@@ -987,6 +1001,13 @@ static void ip_vs_process_message_v0(struct netns_ipvs *ipvs, const char *buffer p +=SIMPLE_CONN_SIZE ; } +if (!ip_vs_sync_validate_flags (flags)) { +IP_VS_DBG (2 ,"BACKUP v0, Invalid flags 0x%X\n" , flags); +continue ; + } + flags &=IP_VS_CONN_F_BACKUP_MASK ; + flags |=IP_VS_CONN_F_SYNC ; + state =ntohs (s->state);if (!(flags &IP_VS_CONN_F_TEMPLATE )) { pp =ip_vs_proto_get (s->protocol);
@@ -1142,7 +1163,13 @@ static inline int ip_vs_proc_sync_conn(struct netns_ipvs *ipvs, __u8 *p, __u8 *m }/* Get flags and Mask off unsupported */ - flags =ntohl (s->v4.flags) &IP_VS_CONN_F_BACKUP_MASK ; + flags =ntohl (s->v4.flags); +if (!ip_vs_sync_validate_flags (flags)) { +IP_VS_DBG (3 ,"BACKUP, Invalid flags 0x%X\n" , flags); + retc =25 ; + goto out; + } + flags &=IP_VS_CONN_F_BACKUP_MASK ; flags |=IP_VS_CONN_F_SYNC ; state =ntohs (s->v4.state);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 223/1674 netfilter: bpf: reject invalid NAT manipulation types
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 16d464013ec2267b00a83f4bfbb97b3ecc63bfa7 ]
As bpf_ct_set_nat_info() is not validating the NAT manipulation type a wrong value can be passed directly to nf_nat_setup_info(). This triggers the WARN_ON() at nf_nat_setup_info() and if panic_on_warn isn't set, then IPS_SRC_NAT_DONE is set without adding nat_bysource and conntrack cleanup tries to unlink an uninitialized hlist node.
Fix this by checking that NAT manipulation type is correct before calling nf_nat_setup_info(). In addition, if the WARN_ON is hit, return NF_DROP instead of continuing with the processing to avoid similar situations in the future.
--- net/netfilter/nf_nat_bpf.c | 3 +++ net/netfilter/nf_nat_core.c | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-)
net/netfilter/nf_nat_bpf.c +3 -0
@@ -41,6 +41,9 @@ __bpf_kfunc int bpf_ct_set_nat_info(struct nf_conn___init *nfct,if (proto !=NFPROTO_IPV4 && proto !=NFPROTO_IPV6 )return -EINVAL ; +if (manip !=NF_NAT_MANIP_SRC && manip !=NF_NAT_MANIP_DST ) +return -EINVAL ; +memset (&range,0 ,sizeof (struct nf_nat_range2 )); range.flags =NF_NAT_RANGE_MAP_IPS ; range.min_addr = *addr;
net/netfilter/nf_nat_core.c +3 -2
@@ -794,8 +794,9 @@ nf_nat_setup_info(struct nf_conn *ct,if (nf_ct_is_confirmed (ct))return NF_ACCEPT ; -WARN_ON (maniptype !=NF_NAT_MANIP_SRC && - maniptype !=NF_NAT_MANIP_DST ); +if (WARN_ON (maniptype !=NF_NAT_MANIP_SRC && + maniptype !=NF_NAT_MANIP_DST )) +return NF_DROP ;if (WARN_ON (nf_nat_initialized (ct, maniptype)))return NF_DROP ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 224/1674 netfilter: conntrack: remove skb argument from nf_ct_refresh
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 31768596b15aa8c9c55f078acad29d0238c8269b ]
Its not used (and could be NULL), so remove it.
This allows to use nf_ct_refresh in places where we don't have an skb without having to double-check that skb == NULL would be safe.
Stable-dep-of: 7c549fb7eecd ("netfilter: flowtable: generalize pending status bit")
--- include/net/netfilter/nf_conntrack.h | 8 +++----- net/netfilter/nf_conntrack_amanda.c | 2 +- net/netfilter/nf_conntrack_broadcast.c | 2 +- net/netfilter/nf_conntrack_core.c | 7 +++---- net/netfilter/nf_conntrack_h323_main.c | 4 ++-- net/netfilter/nf_conntrack_sip.c | 4 ++-- net/netfilter/nft_ct.c | 2 +- 7 files changed, 13 insertions(+), 16 deletions(-)
include/net/netfilter/nf_conntrack.h +3 -5
@@ -213,8 +213,7 @@ bool nf_ct_get_tuplepr(const struct sk_buff *skb, unsigned int nhoff, struct nf_conntrack_tuple *tuple);void __nf_ct_refresh_acct (struct nf_conn *ct,enum ip_conntrack_info ctinfo, -const struct sk_buff *skb, -u32 extra_jiffies,bool do_acct); +u32 extra_jiffies,unsigned int bytes);/* Refresh conntrack for this many jiffies and do accounting */ static inline void nf_ct_refresh_acct(struct nf_conn *ct,
@@ -222,15 +221,14 @@ static inline void nf_ct_refresh_acct(struct nf_conn *ct,const struct sk_buff *skb, u32 extra_jiffies) { -__nf_ct_refresh_acct (ct ,ctinfo ,skb ,extra_jiffies ,true ); + __nf_ct_refresh_acct(ct, ctinfo, extra_jiffies, skb->len); }/* Refresh conntrack for this many jiffies */ static inline void nf_ct_refresh (struct nf_conn *ct, -const struct sk_buff *skb,u32 extra_jiffies) { -__nf_ct_refresh_acct (ct,0 , skb, extra_jiffies, false); +__nf_ct_refresh_acct (ct,0 , extra_jiffies,0 ); }/* kill conntrack and do accounting */
net/netfilter/nf_conntrack_amanda.c +1 -1
@@ -106,7 +106,7 @@ static int amanda_help(struct sk_buff *skb,/* increase the UDP timeout of the master connection as replies from * Amanda clients to the server can be quite delayed */ -nf_ct_refresh (ct, skb, master_timeout *HZ ); +nf_ct_refresh (ct, master_timeout *HZ );/* No data? */ dataoff = protoff +sizeof (struct udphdr );
net/netfilter/nf_conntrack_broadcast.c +1 -1
@@ -80,7 +80,7 @@ int nf_conntrack_broadcast_help(struct sk_buff *skb,nf_ct_expect_related (exp,0 );nf_ct_expect_put (exp); -nf_ct_refresh (ct, skb, timeout *HZ ); +nf_ct_refresh (ct, timeout *HZ ); out:return NF_ACCEPT ; }
net/netfilter/nf_conntrack_core.c +3 -4
@@ -2037,9 +2037,8 @@ EXPORT_SYMBOL_GPL(nf_conntrack_alter_reply);/* Refresh conntrack for this many jiffies and do accounting if do_acct is 1 */ void __nf_ct_refresh_acct (struct nf_conn *ct,enum ip_conntrack_info ctinfo, -const struct sk_buff *skb,u32 extra_jiffies, -bool do_acct) +unsigned int bytes) {/* Only update if this is not a fixed timeout */ if (test_bit (IPS_FIXED_TIMEOUT_BIT , &ct->status))
@@ -2052,8 +2051,8 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,if (READ_ONCE (ct->timeout) != extra_jiffies)WRITE_ONCE (ct->timeout, extra_jiffies); acct: -if (do_acct) -nf_ct_acct_update (ct,CTINFO2DIR (ctinfo), skb->len); +if (bytes) +nf_ct_acct_update (ct,CTINFO2DIR (ctinfo), bytes); }EXPORT_SYMBOL_GPL (__nf_ct_refresh_acct);
net/netfilter/nf_conntrack_h323_main.c +2 -2
@@ -1385,7 +1385,7 @@ static int process_rcf(struct sk_buff *skb, struct nf_conn *ct,if (info->timeout >0 ) {pr_debug ("nf_ct_ras: set RAS connection timeout to " "%u seconds\n" , info->timeout); -nf_ct_refresh (ct, skb, info->timeout *HZ ); +nf_ct_refresh (ct, info->timeout *HZ );/* Set expect timeout */ spin_lock_bh (&nf_conntrack_expect_lock);
@@ -1433,7 +1433,7 @@ static int process_urq(struct sk_buff *skb, struct nf_conn *ct, info->sig_port[!dir] =0 ;/* Give it 30 seconds for UCF or URJ */ -nf_ct_refresh (ct, skb,30 *HZ ); +nf_ct_refresh (ct,30 *HZ );return 0 ; }
net/netfilter/nf_conntrack_sip.c +2 -2
@@ -1646,7 +1646,7 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff,if (dataoff >= skb->len)return NF_ACCEPT ; -nf_ct_refresh (ct, skb, sip_timeout *HZ ); +nf_ct_refresh (ct, sip_timeout *HZ );if (unlikely (skb_linearize (skb)))return NF_DROP ;
@@ -1720,7 +1720,7 @@ static int sip_help_udp(struct sk_buff *skb, unsigned int protoff,if (dataoff >= skb->len)return NF_ACCEPT ; -nf_ct_refresh (ct, skb, sip_timeout *HZ ); +nf_ct_refresh (ct, sip_timeout *HZ );if (unlikely (skb_linearize (skb)))return NF_DROP ;
net/netfilter/nft_ct.c +1 -1
@@ -886,7 +886,7 @@ static void nft_ct_timeout_obj_eval(struct nft_object *obj,*/ values =nf_ct_timeout_data (timeout);if (values) -nf_ct_refresh (ct, pkt->skb, values[0 ]); +nf_ct_refresh (ct, values[0 ]); } static int nft_ct_timeout_obj_init(const struct nft_ctx *ctx,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 225/1674 netfilter: conntrack: rework offload nf_conn timeout extension logic
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 03428ca5cee9f0792edc996c06ce4514816af1fb ]
Offload nf_conn entries may not see traffic for a very long time.
To prevent incorrect 'ct is stale' checks during nf_conntrack table lookup, the gc worker extends the timeout nf_conn entries marked for offload to a large value.
The existing logic suffers from a few problems.
Garbage collection runs without locks, its unlikely but possible that @ct is removed right after the 'offload' bit test.
In that case, the timeout of a new/reallocated nf_conn entry will be increased.
Prevent this by obtaining a reference count on the ct object and re-check of the confirmed and offload bits.
If those are not set, the ct is being removed, skip the timeout extension in this case.
Parallel teardown is also problematic:
cpu1 cpu2
gc_worker
calls flow_offload_teardown()
tests OFFLOAD bit, set
clear OFFLOAD bit
ct->timeout is repaired (e.g. set to timeout[UDP_CT_REPLIED])
nf_ct_offload_timeout() called
expire value is fetched
<INTERRUPT>
-> NF_CT_DAY timeout for flow that isn't offloaded
(and might not see any further packets).
Use cmpxchg: if ct->timeout was repaired after the 2nd 'offload bit' test passed, then ct->timeout will only be updated of ct->timeout was not altered in between.
As we already have a gc worker for flowtable entries, ct->timeout repair can be handled from the flowtable gc worker.
This avoids having flowtable specific logic in the conntrack core and avoids checking entries that were never offloaded.
This allows to remove the nf_ct_offload_timeout helper. Its safe to use in the add case, but not on teardown.
Stable-dep-of: 7c549fb7eecd ("netfilter: flowtable: generalize pending status bit")
--- include/net/netfilter/nf_conntrack.h | 10 --- net/netfilter/nf_conntrack_core.c | 6 -- net/netfilter/nf_flow_table_core.c | 105 ++++++++++++++++++++++++++- 3 files changed, 103 insertions(+), 18 deletions(-)
include/net/netfilter/nf_conntrack.h +0 -10
@@ -322,16 +322,6 @@ static inline bool nf_ct_should_gc(const struct nf_conn *ct)#define NF_CT_DAY (86400 * HZ) -/* Set an arbitrary timeout large enough not to ever expire, this save -* us a check for the IPS_OFFLOAD_BIT from the packet path via -* nf_ct_is_expired(). -*/ -static inline void nf_ct_offload_timeout (struct nf_conn *ct) -{ -if (nf_ct_expires (ct) <NF_CT_DAY /2 ) -WRITE_ONCE (ct->timeout, nfct_time_stamp +NF_CT_DAY ); -} -struct kernel_param ;int nf_conntrack_set_hashsize (const char *val,const struct kernel_param *kp);
net/netfilter/nf_conntrack_core.c +0 -6
@@ -1471,12 +1471,6 @@ static void gc_worker(struct work_struct *work) tmp =nf_ct_tuplehash_to_ctrack (h); -if (test_bit (IPS_OFFLOAD_BIT , &tmp->status)) { -nf_ct_offload_timeout (tmp); -if (!nf_conntrack_max95) -continue ; - } -if (expired_count >GC_SCAN_EXPIRED_MAX ) {rcu_read_unlock ();
net/netfilter/nf_flow_table_core.c +103 -2
125 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 226/1674 netfilter: flowtable: generalize pending status bit
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 7c549fb7eecd01fdba7c0d12c01da876ef8a3214 ]
Rename NF_FLOW_HW_PENDING to NF_FLOW_PENDING and use it to inhibit the flowtable GC worker until pending hw offload work has been completed.
Apparently, nf_flow_offload_stats() can schedule work to retrieve stats while the flow is being removed by GC.
And this bit can also be used in a follow up patch to disable GC until the flow has been fully added in both directions.
Revert the reordering done in commit d644b23afe1e ("netfilter:
flowtable: publish HW_DEAD after worker is done") to prevent a race between GC and hw offload handler.
--- include/net/netfilter/nf_flow_table.h | 2 +- net/netfilter/nf_flow_table_core.c | 7 ++++++- net/netfilter/nf_flow_table_offload.c | 14 +++++--------- net/sched/act_ct.c | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-)
include/net/netfilter/nf_flow_table.h +1 -1
@@ -163,10 +163,10 @@ enum nf_flow_flags {NF_FLOW_SNAT ,NF_FLOW_DNAT ,NF_FLOW_TEARDOWN , +NF_FLOW_PENDING ,NF_FLOW_HW ,NF_FLOW_HW_DYING ,NF_FLOW_HW_DEAD , -NF_FLOW_HW_PENDING ,NF_FLOW_HW_BIDIRECTIONAL , NF_FLOW_HW_ESTABLISHED, };
net/netfilter/nf_flow_table_core.c +6 -1
@@ -522,7 +522,12 @@ static void nf_flow_table_extend_ct_timeout(struct nf_conn *ct)static void nf_flow_offload_gc_step (struct nf_flowtable *flow_table,struct flow_offload *flow,void *data) { -bool teardown =test_bit (NF_FLOW_TEARDOWN , &flow->flags); +bool teardown; + +if (test_bit (NF_FLOW_PENDING , &flow->flags)) +return ; + + teardown =test_bit (NF_FLOW_TEARDOWN , &flow->flags); if (nf_flow_has_expired(flow) || nf_ct_is_dying(flow->ct) ||
net/netfilter/nf_flow_table_offload.c +5 -9
@@ -993,6 +993,7 @@ static void flow_offload_work_del(struct flow_offload_work *offload)flow_offload_tuple_del (offload,FLOW_OFFLOAD_DIR_ORIGINAL );if (test_bit (NF_FLOW_HW_BIDIRECTIONAL , &offload->flow->flags))flow_offload_tuple_del (offload,FLOW_OFFLOAD_DIR_REPLY ); +set_bit (NF_FLOW_HW_DEAD , &offload->flow->flags); } static void flow_offload_tuple_stats(struct flow_offload_work *offload,
@@ -1054,13 +1055,8 @@ static void flow_offload_work_handler(struct work_struct *work)default :WARN_ON_ONCE (1 ); } - -clear_bit (NF_FLOW_HW_PENDING , &offload->flow->flags); -if (offload->cmd ==FLOW_CLS_DESTROY ) { -/* Publish after the worker's last flow access. */ -smp_mb__before_atomic (); -set_bit (NF_FLOW_HW_DEAD , &offload->flow->flags); - } +smp_mb__before_atomic (); +clear_bit (NF_FLOW_PENDING , &offload->flow->flags);kfree (offload); }
@@ -1087,12 +1083,12 @@ nf_flow_offload_work_alloc(struct nf_flowtable *flowtable, {struct flow_offload_work *offload; -if (test_and_set_bit (NF_FLOW_HW_PENDING , &flow->flags)) +if (test_and_set_bit (NF_FLOW_PENDING , &flow->flags))return NULL ; offload =kmalloc (sizeof (struct flow_offload_work ),GFP_ATOMIC );if (!offload) { -clear_bit (NF_FLOW_HW_PENDING , &flow->flags); +clear_bit (NF_FLOW_PENDING , &flow->flags);return NULL ; }
net/sched/act_ct.c +1 -1
@@ -289,7 +289,7 @@ static bool tcf_ct_flow_is_outdated(const struct flow_offload *flow) {return test_bit (IPS_SEEN_REPLY_BIT , &flow->ct->status) &&test_bit (IPS_HW_OFFLOAD_BIT , &flow->ct->status) && - !test_bit (NF_FLOW_HW_PENDING , &flow->flags) && + !test_bit (NF_FLOW_PENDING , &flow->flags) && !test_bit (NF_FLOW_HW_ESTABLISHED , &flow->flags); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 227/1674 net: microchip: vcap: stop scanning after deleting key field
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harshit Mogalapalli <[email protected]>
[ Upstream commit 99b43ede9e355ba35244cc9470bf1819774ce39d ]
The only call outside the KUnit tests is in sparx5_tc_add_rule_copy(), which passes a fixed key list with no duplicate entries. Therefore, the potential double-free is not currently reachable in tree.
However, vcap_filter_rule_keys() is exported and does not require its key list entries to be unique. If a future or external caller supplies the same key at another position that the inner loop visits, it calls list_del() and kfree() a second time on the freed field, leading to a potential double-free.
Break the inner loop after removing a matching field. The outer safe list traversal continues to process the remaining rule fields.
--- drivers/net/ethernet/microchip/vcap/vcap_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/microchip/vcap/vcap_api.c +1 -1
@@ -3512,8 +3512,8 @@ int vcap_filter_rule_keys(struct vcap_rule *rule,if (key == keylist[idx]) {list_del (&ckf->ctrl.list);kfree (ckf); - idx++; err =0 ; +break ; } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 228/1674 net: sparx5: make ports inherit the switch base mac address type
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quentin Freimanis <[email protected]>
[ Upstream commit 5642b1648d5c4561d8ed7a410d0a7017f706604d ]
When the switch uses a random base MAC address it does not mark each port's address as random:
$ dmesg | grep "MAC addr" sparx5-switch e00c0000.switch: MAC addr was not set, use random MAC $ cat /sys/class/net/eth0/addr_assign_type 0
0 is NET_ADDR_PERM, so userspace thinks this is a stable address.
With a random MAC reported as NET_ADDR_PERM, systemd's MACAddressPolicy=persistent [1] leaves it unchanged, so a DHCP client gets a new IP address every boot and a static reservation can't be used. Reporting it as NET_ADDR_RANDOM makes systemd replace it with a stable address derived from the interface name and machine-id.
--- drivers/net/ethernet/microchip/sparx5/sparx5_main.c | 1 + drivers/net/ethernet/microchip/sparx5/sparx5_main.h | 1 + drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c | 1 + 3 files changed, 3 insertions(+)
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +1 -0
@@ -843,6 +843,7 @@ static int mchp_sparx5_probe(struct platform_device *pdev)dev_info (sparx5->dev,"MAC addr was not set, use random MAC\n" );eth_random_addr (sparx5->base_mac); sparx5->base_mac[5 ] =0 ; + sparx5->base_mac_assign_type =NET_ADDR_RANDOM ; } sparx5->fdma_irq =platform_get_irq_byname (sparx5->pdev,"fdma" );
drivers/net/ethernet/microchip/sparx5/sparx5_main.h +1 -0
@@ -257,6 +257,7 @@ struct sparx5 {struct notifier_block switchdev_blocking_nb;/* Switch state */ u8 base_mac[ETH_ALEN ]; +u8 base_mac_assign_type;/* Associated bridge device (when bridged) */ struct net_device *hw_bridge_dev;/* Bridged interfaces */
drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +1 -0
@@ -281,6 +281,7 @@ struct net_device *sparx5_create_netdev(struct sparx5 *sparx5, u32 portno) ndev->ethtool_ops = &sparx5_ethtool_ops;eth_hw_addr_gen (ndev, sparx5->base_mac, portno +1 ); + ndev->addr_assign_type = sparx5->base_mac_assign_type;return ndev; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 229/1674 net: add and use skb_get_hash_net
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit b975d3ee5962237c1e2f5d5aeeaaf0dc2173486c ]
Years ago flow dissector gained ability to delegate flow dissection to a bpf program, scoped per netns.
Unfortunately, skb_get_hash() only gets an sk_buff argument instead of both net+skb. This means the flow dissector needs to obtain the netns pointer from somewhere else.
The netns is derived from skb->dev, and if that is not available, from skb->sk. If neither is set, we hit a (benign) WARN_ON_ONCE().
Trying both dev and sk covers most cases, but not all, as recently reported by Christoph Paasch.
In case of nf-generated tcp reset, both sk and dev are NULL:
WARNING: .. net/core/flow_dissector.c:1104
skb_flow_dissect_flow_keys include/linux/skbuff.h:1536 [inline] skb_get_hash include/linux/skbuff.h:1578 [inline] nft_trace_init+0x7d/0x120 net/netfilter/nf_tables_trace.c:320 nft_do_chain+0xb26/0xb90 net/netfilter/nf_tables_core.c:268 nft_do_chain_ipv4+0x7a/0xa0 net/netfilter/nft_chain_filter.c:23 nf_hook_slow+0x57/0x160 net/netfilter/core.c:626 __ip_local_out+0x21d/0x260 net/ipv4/ip_output.c:118 ip_local_out+0x26/0x1e0 net/ipv4/ip_output.c:127 nf_send_reset+0x58c/0x700 net/ipv4/netfilter/nf_reject_ipv4.c:308 nft_reject_ipv4_eval+0x53/0x90 net/ipv4/netfilter/nft_reject_ipv4.c:30 [..]
syzkaller did something like this:
table inet filter {
chain input {
type filter hook input priority filter; policy accept; meta nftrace set 1
tcp dport 42 reject with tcp reset
}
chain output {
type filter hook output priority filter; policy accept; # empty chain is enough
}
}
... then sends a tcp packet to port 42.
Initial attempt to simply set skb->dev from nf_reject_ipv4 doesn't cover all cases: skbs generated via ipv4 igmp_send_report trigger similar splat.
Moreover, Pablo Neira found that nft_hash.c uses __skb_get_hash_symmetric() which would trigger same warn splat for such skbs.
Lets allow callers to pass the current netns explicitly. The nf_trace infrastructure is adjusted to use the new helper.
__skb_get_hash_symmetric is handled in the next patch.
Stable-dep-of: 8ec454dcd00c ("ipv6: sr: use skb_get_hash_net() in seg6_make_flowlabel()")
--- include/linux/skbuff.h | 12 ++++++++++-- net/core/flow_dissector.c | 15 +++++++++++---- net/netfilter/nf_tables_trace.c | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-)
include/linux/skbuff.h +10 -2
@@ -1500,7 +1500,7 @@ __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4)__skb_set_hash (skb, hash, true, is_l4); } -void __skb_get_hash (struct sk_buff *skb); +void __skb_get_hash_net (const struct net *net,struct sk_buff *skb);u32 __skb_get_hash_symmetric (const struct sk_buff *skb);u32 skb_get_poff (const struct sk_buff *skb); u32 __skb_get_poff(const struct sk_buff *skb, const void *data,
@@ -1580,10 +1580,18 @@ void skb_flow_dissect_hash(const struct sk_buff *skb,struct flow_dissector *flow_dissector, void *target_container); +static inline __u32 skb_get_hash_net (const struct net *net,struct sk_buff *skb) +{ +if (!skb->l4_hash && !skb->sw_hash) +__skb_get_hash_net (net, skb); + +return skb->hash; +} +static inline __u32 skb_get_hash (struct sk_buff *skb) {if (!skb->l4_hash && !skb->sw_hash) -__skb_get_hash (skb); +__skb_get_hash_net (NULL , skb);return skb->hash; }
net/core/flow_dissector.c +11 -4
@@ -1853,7 +1853,8 @@ u32 __skb_get_hash_symmetric(const struct sk_buff *skb)EXPORT_SYMBOL_GPL (__skb_get_hash_symmetric);/** -* __skb_get_hash: calculate a flow hash +* __skb_get_hash_net: calculate a flow hash +* @net: associated network namespace, derived from @skb if NULL * @skb: sk_buff to calculate flow hash from * * This function calculates a flow hash based on src/dst addresses
@@ -1861,18 +1862,24 @@ EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric);* on success, zero indicates no valid hash. Also, sets l4_hash in skb * if hash is a canonical 4-tuple hash over transport ports. */ -void __skb_get_hash (struct sk_buff *skb) +void __skb_get_hash_net (const struct net *net,struct sk_buff *skb) {struct flow_keys keys;u32 hash; +memset (&keys,0 ,sizeof (keys)); + +__skb_flow_dissect (net, skb, &flow_keys_dissector, + &keys,NULL ,0 ,0 ,0 , +FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL ); +__flow_hash_secret_init (); - hash =___skb_get_hash (skb, &keys, &hashrnd); + hash =__flow_hash_from_keys (&keys, &hashrnd);__skb_set_sw_hash (skb, hash,flow_keys_have_l4 (&keys)); } -EXPORT_SYMBOL (__skb_get_hash); +EXPORT_SYMBOL (__skb_get_hash_net);__u32 skb_get_hash_perturb (const struct sk_buff *skb,const siphash_key_t *perturb)
net/netfilter/nf_tables_trace.c +1 -1
@@ -313,7 +313,7 @@ void nft_trace_init(struct nft_traceinfo *info, const struct nft_pktinfo *pkt,net_get_random_once (&trace_key,sizeof (trace_key)); info->skbid = (u32 )siphash_3u32 (hash32_ptr (skb), -skb_get_hash (skb), +skb_get_hash_net (nft_net (pkt), skb), skb->skb_iif, &trace_key); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 230/1674 ipv6: sr: use skb_get_hash_net() in seg6_make_flowlabel()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 8ec454dcd00ce3375119111c6394964455b36d0d ]
Since commit d58e468b1112 ("flow_dissector: implements flow dissector BPF hook") __skb_flow_dissect() needs a net pointer, either from skb->dev, skb->sk, or since commit 3cbf4ffba5ee ("net: plumb network namespace into __skb_flow_dissect") a caller provided pointer.
syzbot was able to reach seg6_make_flowlabel() with an skb having neither skb->dev nor skb->sk set: a TIPC UDP bearer sends a discovery message through an IPv4 route using seg6 encap, while net.ipv6.seg6_flowlabel is set to 1.
seg6_make_flowlabel() already has a net pointer, use skb_get_hash_net().
WARNING: net/core/flow_dissector.c:1131 at __skb_flow_dissect+0x910/0x5368 net/core/flow_dissector.c:1126, CPU#0: syz.0.17/4930 Call trace: __skb_flow_dissect+0x910/0x5368 net/core/flow_dissector.c:1126 (P) __skb_get_hash_net+0xe0/0x29c net/core/flow_dissector.c:1903 skb_get_hash include/linux/skbuff.h:1663 [inline] seg6_make_flowlabel+0xcc/0x1ec net/ipv6/seg6_iptunnel.c:132 __seg6_do_srh_encap+0x320/0xbf4 net/ipv6/seg6_iptunnel.c:161 seg6_do_srh+0x4b4/0xa44 net/ipv6/seg6_iptunnel.c:431 seg6_output_core+0x164/0x688 net/ipv6/seg6_iptunnel.c:681 seg6_output+0x44/0x1ac net/ipv6/seg6_iptunnel.c:744 lwtunnel_output+0x3d0/0x664 net/core/lwtunnel.c:356 dst_output include/net/dst.h:470 [inline] ip_local_out+0x110/0x148 net/ipv4/ip_output.c:131 iptunnel_xmit+0x50c/0xd38 net/ipv4/ip_tunnel_core.c:97 udp_tunnel_xmit_skb+0x220/0x348 net/ipv4/udp_tunnel_core.c:187 tipc_udp_xmit+0x75c/0x9c0 net/tipc/udp_media.c:202 tipc_udp_send_msg+0x214/0x374 net/tipc/udp_media.c:274 tipc_bearer_xmit_skb+0x260/0x3b0 net/tipc/bearer.c:576 tipc_enable_bearer net/tipc/bearer.c:366 [inline] __tipc_nl_bearer_enable+0xc90/0xfb0 net/tipc/bearer.c:1048 tipc_nl_bearer_enable+0x2c/0x48 net/tipc/bearer.c:1057 genl_family_rcv_msg_doit+0x1e4/0x2d4 net/netlink/genetlink.c:1114
--- net/ipv6/seg6_iptunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/seg6_iptunnel.c +1 -1
@@ -116,7 +116,7 @@ static __be32 seg6_make_flowlabel(struct net *net, struct sk_buff *skb,u32 hash;if (do_flowlabel >0 ) { - hash =skb_get_hash (skb); + hash =skb_get_hash_net (net, skb); hash =rol32 (hash,16 ); flowlabel = (__force __be32 )hash &IPV6_FLOWLABEL_MASK ; }else if (!do_flowlabel && skb->protocol ==htons (ETH_P_IPV6 )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 231/1674 i2c: at91: release DMA channels when probe defers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongjian Dai <[email protected]>
[ Upstream commit c98bf3b86609a18ab16d067280257326e557c636 ]
at91_twi_probe_master() can return -EPROBE_DEFER from at91_init_twi_recovery_info() after at91_twi_configure_dma() has already claimed the tx/rx DMA channels. at91_twi_probe() then returns without releasing them, and since dma_request_chan() is not devres-managed the channels leak on every deferred probe attempt.
Release the channels before deferring the probe.
--- drivers/i2c/busses/i2c-at91-master.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-at91-master.c +7 -1
@@ -922,8 +922,14 @@ int at91_twi_probe_master(struct platform_device *pdev,at91_calc_twi_clock (dev); rc =at91_init_twi_recovery_info (pdev, dev); -if (rc == -EPROBE_DEFER ) +if (rc == -EPROBE_DEFER ) { +/* +* The DMA channels were already set up above, release them +* before deferring the probe so they are not leaked. +*/ +at91_twi_dma_release (dev);return rc; + } dev->adapter.algo = &at91_twi_algorithm; dev->adapter.quirks = &at91_twi_quirks;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 232/1674 perf: Fix race between perf_event_exit_task() and perf_pending_task()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luo Gengkun <[email protected]>
[ Upstream commit ffb684f2aa141eeb0caa6308422e7e05d1ded7c4 ]
A race condition exists between perf_event_exit_task() and perf_pending_task() during begin_new_exec().
During begin_new_exec(), perf_event_exit_task() may be called, and the PF_EXITING flag is not set on task. So perf_sigtrap() continues to execute and triggers WARN_ON_ONCE(event->ctx->task != current).
Since both task exit and exec paths can call perf_event_exit_task() which sets ctx->task to TASK_TOMBSTONE, fix this by explicitly checking if event->ctx->task equals TASK_TOMBSTONE and dropping the redundant PF_EXITING check.
--- kernel/events/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/events/core.c +4 -2
@@ -6809,9 +6809,11 @@ static void perf_sigtrap(struct perf_event *event) {/* * Both perf_pending_task() and perf_pending_irq() can race with the -* task exiting. +* task exiting or exec-ing. We can determine if such a race has +* occurred by checking if perf_event_exit_task(), which will set +* ctx->task to TASK_TOMBSTONE, has already been called. */ -if (current->flags &PF_EXITING ) +if (event->ctx->task ==TASK_TOMBSTONE )return ;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 233/1674 ALSA: core: Define auto-cleanup for snd_card_free()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit f1d565dc92955f05383794e0fa27e61ee0555027 ]
For the errors at the probe time, we'd need to call rather snd_card_free() instead of the snd_card_unref() -- the former calls explicitly snd_card_disconnect() that cleans up the registered devices, etc, while the latter may leak in corner cases.
For convenience, define a new auto-clean with snd_card_free.
Stable-dep-of: e6229c0402ea ("ALSA: ice1712: Fix the error handling via auto-cleanup at probe")
--- include/sound/core.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/sound/core.h +9 -0
@@ -316,6 +316,15 @@ static inline void snd_card_unref(struct snd_card *card) DEFINE_FREE(snd_card_unref, struct snd_card *, if (_T) snd_card_unref(_T)) +/* +* For automatic error handling at probe time, assign the card like: +* struct snd_card *card __free(snd_card_free) = NULL; +* then create and process as usual. +* But, don't forget to clear to NULL at successful return for avoiding +* the unexpected cleanup! + */ +DEFINE_FREE(snd_card_free, struct snd_card *, if (_T) snd_card_free(_T)) +#define snd_card_set_dev (card, devptr) ((card)->dev = (devptr))/* device.c */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 234/1674 ALSA: ice1712: Fix the error handling via auto-cleanup at probe
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit e6229c0402ea4863ec74802d79d5b52b9398d66c ]
We used the auto-cleanup via snd_card_unref() for errors at probe of ice1712 driver, but this may be problematic in a subtle way when an error happens at snd_card_register(); since snd_card_unref() skips the snd_card_disconnect() call, it may miss some resource clearance.
For fixing the issue, use the new __free(snd_card_free) instead, which does call snd_card_free() explicitly at errors for avoiding such a pitfall.
--- sound/pci/ice1712/ice1712.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/ice1712/ice1712.c +1 -1
@@ -2549,7 +2549,7 @@ static int snd_ice1712_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) {static int dev; - struct snd_card *card __free(snd_card_unref) = NULL; + struct snd_card *card __free(snd_card_free) = NULL;struct snd_ice1712 *ice;int pcm_dev =0 , err;const struct snd_ice1712_card_info *const *tbl, *c;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 235/1674 PCI: Accept AtomicOps already enabled by the hypervisor
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikola Prica <[email protected]>
[ Upstream commit 40cce45b921f7930886bcba43069edc579725457 ]
pci_enable_atomic_ops_to_root() currently fails when no Root Port is visible. That is common in passthrough guests (ESXi, Hyper-V): the Endpoint is assigned to the VM, but the Root Port above it is not visible in the guest topology.
In those setups the hypervisor may already have enabled AtomicOp Requester Enable on the device. If PCI_EXP_DEVCTL2_ATOMIC_REQ is set, treat AtomicOps as already enabled and return success instead of failing the Root Port walk.
After 1ae8c4ce1570 ("PCI: Enable AtomicOps only if Root Port supports them"), pci_enable_atomic_ops_to_root() always returns failure if the Root Port is not visible, so drivers don't use atomics when they could. On systems where the Root Port is not visible but *does* support AtomicOps, this is a regression: prior to 1ae8c4ce1570, it enabled AtomicOps in the endpoint and returned success.
--- drivers/pci/pci.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/pci/pci.c +14 -1
@@ -3868,8 +3868,21 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask) } root =pcie_find_root_port (dev); -if (!root) +if (!root) { + +/* +* A hypervisor may expose a topology with the root port +* not visible to the guest. If the hypervisor has already +* set AtomicOp Requester Enable in the endpoint, we assume +* it has verified support in the root port, so it is safe +* for the driver to use AtomicOps. +*/ +pcie_capability_read_dword (dev,PCI_EXP_DEVCTL2 , &ctl2); +if (ctl2 &PCI_EXP_DEVCTL2_ATOMIC_REQ ) +return 0 ; +return -EINVAL ; + }pcie_capability_read_dword (root,PCI_EXP_DEVCAP2 , &cap);if ((cap & cap_mask) != cap_mask)
Signature · 1 line
2.53.0